Bug 467117 - "Convert nsSpotlightIntegration and nsWinSearchIntegration to JS modules" [r=bienvenu]
authorSiddharth Agarwal <sid1337@gmail.com>
Wed, 17 Dec 2008 11:03:40 +0000
changeset 1438 b7d9726d941bded7a62c45a734e7a64518c78d41
parent 1437 b74725908891f4917f89d4c1482c5e956586d4f2
child 1439 bab0bf9760fa9d720011bd25ad0cf7c08138105c
push idunknown
push userunknown
push dateunknown
reviewersbienvenu
bugs467117
Bug 467117 - "Convert nsSpotlightIntegration and nsWinSearchIntegration to JS modules" [r=bienvenu]
mail/components/search/Makefile.in
mail/components/search/SpotlightIntegration.js
mail/components/search/WinSearchIntegration.js
mail/components/search/content/searchOverlay.js
mail/components/search/content/searchOverlay.xul
mail/components/search/jar.mn
mail/components/search/nsSpotlightIntegration.js
mail/components/search/nsWinSearchIntegration.js
mail/installer/removed-files.in
mail/installer/windows/packages-static
--- a/mail/components/search/Makefile.in
+++ b/mail/components/search/Makefile.in
@@ -48,20 +48,20 @@ endif
 
 ifneq (,$(filter windows, $(MOZ_WIDGET_TOOLKIT)))
 DIRS += wsenable
 endif
 
 #currently, we only build this dir on the mac, but if it gets built on other platforms,
 #make sure we still only build spotlight integration on the mac.
 ifneq (,$(filter cocoa mac, $(MOZ_WIDGET_TOOLKIT)))
-EXTRA_PP_COMPONENTS = \
-	nsSpotlightIntegration.js \
+EXTRA_PP_JS_MODULES = \
+	SpotlightIntegration.js \
 	$(NULL)
-endif         
+endif
 
 # If on Windows, build Windows Search integration
 ifneq (,$(filter windows, $(MOZ_WIDGET_TOOLKIT)))
 MODULE = mailwinsearch
 LIBRARY_NAME = winsearch_s
 MODULE_NAME = nsMailWinSearchHelperModule
 ifdef BUILD_STATIC_LIBS
 MOZILLA_INTERNAL_API = 1
@@ -78,16 +78,16 @@ REQUIRES = \
 
 CPPSRCS = \
   nsMailWinSearchHelper.cpp \
   $(NULL)
 
 DIRS += public
 
 # Windows Search component
-EXTRA_PP_COMPONENTS = \
-  nsWinSearchIntegration.js \
+EXTRA_PP_JS_MODULES = \
+  WinSearchIntegration.js \
   $(NULL)
 
 FORCE_STATIC_LIB = 1
 endif
 
 include $(topsrcdir)/config/rules.mk
rename from mail/components/search/nsSpotlightIntegration.js
rename to mail/components/search/SpotlightIntegration.js
--- a/mail/components/search/nsSpotlightIntegration.js
+++ b/mail/components/search/SpotlightIntegration.js
@@ -1,53 +1,53 @@
-# -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is spotlight integration code.
-#
-# The Initial Developer of the Original Code is
-# David Bienvenu <bienvenu@mozilla.com>
-# Portions created by the Initial Developer are Copyright (C) 2007
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#  Siddharth Agarwal <sid1337@gmail.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is spotlight integration code.
+ *
+ * The Initial Developer of the Original Code is
+ * David Bienvenu <bienvenu@mozilla.com>
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *  Siddharth Agarwal <sid1337@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
 
 #include content/searchCommon.js
 
+var EXPORTED_SYMBOLS = ["SearchIntegration"];
+
 const MSG_DB_LARGE_COMMIT = 1;
 const gFileHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.\ncom/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>";
 
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
 let SearchIntegration =
 {
   __proto__: SearchSupport,
 
   /// The property of the header that's used to check if a message is indexed
   _hdrIndexedProperty: "indexed",
 
   /// The file extension that is used for support files of this component
@@ -199,46 +199,15 @@ let SearchIntegration =
       catch (ex) {
         SearchIntegration._log.error(ex);
         this._onDoneStreaming(false);
       }
     }
   }
 };
 
-/* XPCOM boilerplate code */
-function SpotlightIntegration() { }
-SpotlightIntegration.prototype = {
-  classDescription: "Spotlight Integration",
-  classID: Components.ID("{cc9c2a34-567b-451a-a942-1a1c3ec26e07}"),
-  contractID: "@mozilla.org/spotlight-search-integration;1",
-
-  _xpcom_categories: [{
-    category: "app-startup",
-    service: true
-  }],
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupports]),
-
-  observe : function(aSubject, aTopic, aData)
-  {
-    switch(aTopic)
-    {
-    case "app-startup":
-      let obsSvc = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
-      obsSvc.addObserver(this, "profile-after-change", false);
-    break;
-    case "profile-after-change":
-      try { SearchIntegration._init(); }
-      catch(err) {
-        SearchIntegration._log.error("Could not initialize spotlight component");
-      }
-    break;
-    default:
-      throw Components.Exception("Unknown topic: " + aTopic);
-    }
-  }
-};
-var components = [SpotlightIntegration];
-function NSGetModule(aCompMgr, aFileSpec)
-{
-  return XPCOMUtils.generateModule(components);
+/* Initialize the search integration object */
+try {
+  SearchIntegration._init();
 }
+catch (ex) {
+  SearchIntegration._log.error("Could not initialize spotlight component");
+}
rename from mail/components/search/nsWinSearchIntegration.js
rename to mail/components/search/WinSearchIntegration.js
--- a/mail/components/search/nsWinSearchIntegration.js
+++ b/mail/components/search/WinSearchIntegration.js
@@ -1,48 +1,49 @@
-# -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is spotlight integration code.
-#
-# The Initial Developer of the Original Code is
-# David Bienvenu <bienvenu@mozilla.com>
-# Portions created by the Initial Developer are Copyright (C) 2007
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#  Siddharth Agarwal <sid1337@gmail.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is spotlight integration code.
+ *
+ * The Initial Developer of the Original Code is
+ * David Bienvenu <bienvenu@mozilla.com>
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *  Siddharth Agarwal <sid1337@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
 
 #include content/searchCommon.js
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+var EXPORTED_SYMBOLS = ["SearchIntegration"];
 
 const MSG_DB_LARGE_COMMIT = 1;
 const MSG_FLAG_ATTACHMENT = 0x10000000;
 const CRLF="\r\n";
 
 /**
  * Required to access the 64-bit registry, even though we're probably a 32-bit
  * program
@@ -338,56 +339,37 @@ let SearchIntegration =
       catch (ex) {
         SearchIntegration._log.error(ex);
         this._onDoneStreaming(false);
       }
     }
   }
 };
 
-/* XPCOM boilerplate code */
-function WinSearchIntegration() { }
-WinSearchIntegration.prototype = {
-  classDescription: "Windows Search Integration",
-  classID: Components.ID("{451a70f0-1b4f-11dd-bd0b-0800200c9a66}"),
-  contractID: "@mozilla.org/windows-search-integration;1",
-
-  _xpcom_categories: [{
-    category: "app-startup",
-    service: true
-  }],
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupports]),
-
-  observe : function(aSubject, aTopic, aData)
+/**
+ * Observer for first run dialog
+ */
+let FirstRunObserver =
+{
+  observe: function(aSubject, aTopic, aData)
   {
-    let obsSvc = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
-    switch(aTopic)
+    if (aTopic == "mail-startup-done")
     {
-    case "app-startup":
-      obsSvc.addObserver(this, "profile-after-change", false);
-      break;
-    case "profile-after-change":
-      try
-      {
-        if (SearchIntegration._init())
-          obsSvc.addObserver(this, "mail-startup-done", false);
-      }
-      catch (err) {
-        SearchIntegration._log.error("Could not initialize winsearch component");
-      }
-      break;
-    case "mail-startup-done":
       aSubject.QueryInterface(Ci.nsIDOMWindowInternal);
-      obsSvc.removeObserver(this, "mail-startup-done");
+      Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService)
+        .removeObserver(this, "mail-startup-done");
       try { SearchIntegration._firstRun(aSubject); }
-      catch(err) { SearchIntegration._log.warn("First run unsuccessful"); }
-      break;
-    default:
-      throw Components.Exception("Unknown topic: " + aTopic);
+      catch(ex) { SearchIntegration._log.warn("First run unsuccessful"); }
     }
   }
 };
-var components = [WinSearchIntegration];
-function NSGetModule(aCompMgr, aFileSpec)
-{
-  return XPCOMUtils.generateModule(components);
+
+/* Initialize the search integration object */
+try {
+  if (SearchIntegration._init())
+  {
+    Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService)
+      .addObserver(FirstRunObserver, "mail-startup-done", false);
+  }
 }
+catch (ex) {
+  SearchIntegration._log.error("Could not initialize winsearch component");
+}
new file mode 100644
--- /dev/null
+++ b/mail/components/search/content/searchOverlay.js
@@ -0,0 +1,43 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ *   Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Desktop search integration.
+ *
+ * The Initial Developer of the Original Code is
+ *  Siddharth Agarwal <sid1337@gmail.com>
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifdef XP_WIN
+Components.utils.import("resource://app/modules/WinSearchIntegration.js");
+#else
+#ifdef XP_MACOSX
+Components.utils.import("resource://app/modules/SpotlightIntegration.js");
+#endif
+#endif
new file mode 100644
--- /dev/null
+++ b/mail/components/search/content/searchOverlay.xul
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+  -   Version: MPL 1.1/GPL 2.0/LGPL 2.1
+  -
+  - The contents of this file are subject to the Mozilla Public License Version
+  - 1.1 (the "License"); you may not use this file except in compliance with
+  - the License. You may obtain a copy of the License at
+  - http://www.mozilla.org/MPL/
+  -
+  - Software distributed under the License is distributed on an "AS IS" basis,
+  - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+  - for the specific language governing rights and limitations under the
+  - License.
+  -
+  - The Original Code is Desktop search integration.
+  -
+  - The Initial Developer of the Original Code is
+  -   Siddharth Agarwal <sid1337@gmail.com>
+  - Portions created by the Initial Developer are Copyright (C) 2008
+  - the Initial Developer. All Rights Reserved.
+  -
+  - Contributor(s):
+  -
+  - Alternatively, the contents of this file may be used under the terms of
+  - either the GNU General Public License Version 2 or later (the "GPL"), or
+  - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+  - in which case the provisions of the GPL or the LGPL are applicable instead
+  - of those above. If you wish to allow use of your version of this file only
+  - under the terms of either the GPL or the LGPL, and not to allow others to
+  - use your version of this file under the terms of the MPL, indicate your
+  - decision by deleting the provisions above and replace them with the notice
+  - and other provisions required by the GPL or the LGPL. If you do not delete
+  - the provisions above, a recipient may use your version of this file under
+  - the terms of any one of the MPL, the GPL or the LGPL.
+  -
+  - ***** END LICENSE BLOCK ***** -->
+
+<overlay id="search-overlay"
+         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script src="searchOverlay.js"/>
+</overlay>
--- a/mail/components/search/jar.mn
+++ b/mail/components/search/jar.mn
@@ -1,2 +1,5 @@
 messenger.jar:
+%   overlay chrome://messenger/content/messenger.xul            chrome://messenger/content/search/searchOverlay.xul
 *   content/messenger/search/searchIntegrationDialog.xul        (content/searchIntegrationDialog.xul)
+    content/messenger/search/searchOverlay.xul                  (content/searchOverlay.xul)
+*   content/messenger/search/searchOverlay.js                   (content/searchOverlay.js)
--- a/mail/installer/removed-files.in
+++ b/mail/installer/removed-files.in
@@ -304,8 +304,15 @@ extensions/talkback@mozilla.org/componen
 components/airbag.xpt
 components/nsUrlClassifierTable.js
 components/nsScriptableIO.js
 #ifdef XP_WIN
 xpicleanup.exe
 #else
 xpicleanup
 #endif
+#ifdef XP_WIN
+components/nsWinSearchIntegration.js
+#else
+#ifdef XP_MACOSX
+components/nsSpotlightIntegration.js
+#endif
+#endif
--- a/mail/installer/windows/packages-static
+++ b/mail/installer/windows/packages-static
@@ -179,17 +179,17 @@ bin\components\nsUrlClassifierListManage
 bin\components\nsUrlClassifierLib.js
 bin\components\url-classifier.xpt
 
 ; Address Book autocomplete
 bin\components\nsAbAutoCompleteMyDomain.js
 bin\components\nsAbAutoCompleteSearch.js
 
 ; Windows Search integration
-bin\components\nsWinSearchIntegration.js
+; the module is included as part of the "Modules" rule
 bin\components\mailwinsearch.xpt
 bin\WSEnable.exe
 
 ; Bayesian trait analysis
 bin\components\nsMsgTraitService.js
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Base Package Files