[mozilla-firetray] Fix xpcom registration with gecko2
Hicham HAOUARI
hicham at fedoraproject.org
Tue Sep 14 19:33:25 UTC 2010
commit 4723a69c0acf4e8e4fb87010e75dab793e0e4d1d
Author: Hicham HAOUARI <hicham.haouari at gmail.com>
Date: Tue Sep 14 19:33:06 2010 +0000
Fix xpcom registration with gecko2
.gitignore | 1 +
...lla-firetray-0.2.8-fix-xpcom-registration.patch | 207 ++++++++++++++++++++
mozilla-firetray.spec | 38 +++-
3 files changed, 238 insertions(+), 8 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index ba3ec26..de2a728 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
firetray-0.2.8-src.zip
+/firetray-0.2.8-src.zip
diff --git a/mozilla-firetray-0.2.8-fix-xpcom-registration.patch b/mozilla-firetray-0.2.8-fix-xpcom-registration.patch
new file mode 100644
index 0000000..4713d17
--- /dev/null
+++ b/mozilla-firetray-0.2.8-fix-xpcom-registration.patch
@@ -0,0 +1,207 @@
+--- mozilla-firetray-0.2.8/components/nsTrayModue.cpp.fix-xpcom-registration 2010-07-13 15:23:21.000000000 +0100
++++ mozilla-firetray-0.2.8/components/nsTrayModue.cpp 2010-09-14 15:45:59.000000000 +0000
+@@ -1,16 +1,27 @@
+-#include "nsIGenericFactory.h"
++#include "mozilla/ModuleUtils.h"
+ #include "nsTray.h"
+
+ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTray)
+
+-static nsModuleComponentInfo components[] =
+-{
+- {
+- NS_ITRAY_CLASSNAME,
+- NS_ITRAY_CID,
+- NS_ITRAY_CONTRACTID,
+- nsTrayConstructor,
+- }
++NS_DEFINE_NAMED_CID(NS_ITRAY_CID);
++
++static const mozilla::Module::CIDEntry kTrayCIDs[] = {
++ { &kNS_ITRAY_CID, false, NULL, nsTrayConstructor },
++ { NULL }
++};
++
++static const mozilla::Module::ContractIDEntry kTrayContracts[] = {
++ { NS_ITRAY_CONTRACTID, &kNS_ITRAY_CID },
++ { NULL }
++};
++
++static const mozilla::Module kTrayModule =
++{
++ mozilla::Module::kVersion,
++ kTrayCIDs,
++ kTrayContracts,
++ NULL
+ };
+
+-NS_IMPL_NSGETMODULE("nsTrayMoudle", components)
++NSMODULE_DEFN(nsTrayModule) = &kTrayModule;
++NS_IMPL_MOZILLA192_NSGETMODULE(&kTrayModule)
+--- mozilla-firetray-0.2.8/chrome.manifest.old 2010-09-14 15:51:16.000000000 +0000
++++ mozilla-firetray-0.2.8/chrome.manifest 2010-09-14 15:52:12.000000000 +0000
+@@ -7,6 +7,14 @@ overlay chrome://sunbird/content/calenda
+ overlay chrome://navigator/content/navigator.xul chrome://firetray/content/navigatorOverlay.xul
+ overlay chrome://chatzilla/content/chatzilla.xul chrome://firetray/content/ircOverlay.xul
+
++binary-component components/libnptray.so
++
++component {77284574-9091-4b63-a5cf-533edb2897a1} components/nsMinimize.js
++contract @mozilla.org/Minimize;1 {77284574-9091-4b63-a5cf-533edb2897a1}
++
++interfaces components/nsITray.xpt
++interfaces components/nsIMinimize.xpt
++
+ locale firetray en-US jar:chrome/firetray.jar!/locale/en-US/
+ locale firetray it-IT jar:chrome/firetray.jar!/locale/it-IT/
+ locale firetray bg-BG jar:chrome/firetray.jar!/locale/bg-BG/
+--- mozilla-firetray-0.2.8/components/nsMinimize.js.old 2010-09-14 15:54:25.000000000 +0000
++++ mozilla-firetray-0.2.8/components/nsMinimize.js 2010-09-14 15:59:39.000000000 +0000
+@@ -1,25 +1,7 @@
+ /***********************************************************
+-constants
+-***********************************************************/
+-
+-// reference to the interface defined in nsIMinimize.idl
+-const nsIMinimize = Components.interfaces.nsIMinimize;
+-
+-// reference to the required base interface that all components must support
+-const nsISupports = Components.interfaces.nsISupports;
+-
+-// UUID uniquely identifying our component
+-const CLASS_ID = Components.ID("{77284574-9091-4b63-a5cf-533edb2897a1}");
+-
+-// description
+-const CLASS_NAME = "Minimize Javascript XPCOM Component for FireTray";
+-
+-// textual unique identifier
+-const CONTRACT_ID = "@mozilla.org/Minimize;1";
+-
+-/***********************************************************
+ class definition
+ ***********************************************************/
++Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+ //class constructor
+ function Minimize() {
+@@ -27,6 +9,13 @@ function Minimize() {
+
+ // class definition
+ Minimize.prototype = {
++
++ classDescription: "Minimize Javascript XPCOM Component for FireTray",
++ classID: Components.ID("{77284574-9091-4b63-a5cf-533edb2897a1}"),
++ contractID: "@mozilla.org/Minimize;1",
++ QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIMinimize,
++ Components.interfaces.nsISupports]),
++
+ _all_hidden: false,
+ _menu_window_list: 0,
+
+@@ -45,69 +34,18 @@ Minimize.prototype = {
+
+ set menu_window_list(menu) {
+ this._menu_window_list = menu;
+- },
+-
+- QueryInterface: function(aIID) {
+- if (!aIID.equals(nsIMinimize) && !aIID.equals(nsISupports)) {
+- throw Components.results.NS_ERROR_NO_INTERFACE;
+- }
+- return this;
+- }
+-};
+-
+-/***********************************************************
+-class factory
+-
+-This object is a member of the global-scope Components.classes.
+-It is keyed off of the contract ID. Eg:
+-
+-myMinimize = Components.classes["@dietrich.ganx4.com/helloworld;1"].
+- createInstance(Components.interfaces.nsIMinimize);
+-
+-***********************************************************/
+-var MinimizeFactory = {
+- createInstance: function (aOuter, aIID) {
+- if (aOuter != null) {
+- throw Components.results.NS_ERROR_NO_AGGREGATION;
+- }
+- return (new Minimize()).QueryInterface(aIID);
+ }
+ };
+
+ /***********************************************************
+-module definition (xpcom registration)
+-***********************************************************/
+-var MinimizeModule = {
+- _firstTime: true,
+- registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) {
+- aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+- aCompMgr.registerFactoryLocation(CLASS_ID, CLASS_NAME, CONTRACT_ID, aFileSpec, aLocation, aType);
+- },
+-
+- unregisterSelf: function(aCompMgr, aLocation, aType) {
+- aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+- aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
+- },
+-
+- getClassObject: function(aCompMgr, aCID, aIID) {
+- if (!aIID.equals(Components.interfaces.nsIFactory)) {
+- throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
+- }
+-
+- if (aCID.equals(CLASS_ID)) {
+- return MinimizeFactory;
+- }
+-
+- throw Components.results.NS_ERROR_NO_INTERFACE;
+- },
+-
+- canUnload: function(aCompMgr) { return true; }
+-};
+-
+-/***********************************************************
+ module initialization
+
+ When the application registers the component, this function
+ is called.
++XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
++XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
+ ***********************************************************/
+-function NSGetModule(aCompMgr, aFileSpec) { return MinimizeModule; }
++if (XPCOMUtils.generateNSGetFactory)
++ var NSGetFactory = XPCOMUtils.generateNSGetFactory([Minimize]);
++else
++ var NSGetModule = XPCOMUtils.generateNSGetModule([Minimize]);
+--- mozilla-firetray-0.2.8/install.rdf.old 2010-09-14 16:05:29.000000000 +0000
++++ mozilla-firetray-0.2.8/install.rdf 2010-09-14 16:05:46.000000000 +0000
+@@ -15,7 +15,7 @@
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>3.0</em:minVersion>
+- <em:maxVersion>3.6.*</em:maxVersion>
++ <em:maxVersion>4.0.*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+
+--- mozilla-firetray-0.2.8/components/SConscript.old 2010-09-14 16:37:32.000000000 +0000
++++ mozilla-firetray-0.2.8/components/SConscript 2010-09-14 16:37:58.000000000 +0000
+@@ -18,7 +18,7 @@ print "linking: " + linking_options
+
+
+
+-FLAGS += ' -fshort-wchar '
++FLAGS += ' -fshort-wchar -include mozilla-config.h '
+
+
+
+@@ -63,7 +63,7 @@ bhdr = Builder(action = 'xpidl -w -m hea
+ env = Environment(
+ CPPPATH = [gecko_include],
+ LIBPATH = [gecko_lib],
+- LIBS = ['xpcomglue', 'xpcomglue_s.a' ],
++ LIBS = ['xpcomglue', 'xpcomglue_s.a','mozalloc' ],
+ ENV = os.environ)
+ env.AppendENVPath('PATH', gecko_bin)
+ env.Append(BUILDERS = {'MozXPT' : bxpt, 'MozHeader' : bhdr })
diff --git a/mozilla-firetray.spec b/mozilla-firetray.spec
index e7bcf60..b987e3b 100644
--- a/mozilla-firetray.spec
+++ b/mozilla-firetray.spec
@@ -1,4 +1,4 @@
-%define rel 2
+%define rel 3
%define svn 0
@@ -54,8 +54,12 @@ Patch2: %{name}-%{version}-use-system-cxxflags.patch
# Patch3 : use our own icons instead of the provided ones, except the newmail one
# http://code.google.com/p/firetray/issues/detail?id=109
Patch3: %{name}-%{version}-use-our-icons.patch
-# Patch8 : add support for chatzilla
-Patch8: %{name}-%{version}-add-chatzilla-support.patch
+# Patch4 : add support for chatzilla
+# http://code.google.com/p/firetray/issues/detail?id=135
+Patch4: %{name}-%{version}-add-chatzilla-support.patch
+#Patch5: fix for the new way of registering xpcom components
+# http://code.google.com/p/firetray/issues/detail?id=127
+Patch5: %{name}-%{version}-fix-xpcom-registration.patch
BuildRequires: xulrunner-devel
@@ -192,7 +196,8 @@ Firetray is a system tray addon for chatzilla, current features are :
%patch1 -p1 -b .fix-unread-mail-count
%patch2 -p1 -b .use-system-cxxflags
%patch3 -p1 -b .use-our-icons
-%patch8 -p1 -b .add-chatzilla-support
+%patch4 -p1 -b .add-chatzilla-support
+%patch5 -p1 -b .fix-xpcom-registration
# Make sure we don't ship prebuilt stuff
find . \( -name '*.xpi' -o -name '*.jar' -o -name '*.xpt' -o -name '*.so' \) -exec rm -f '{}' \;
@@ -201,6 +206,9 @@ find . \( -name '*.xpi' -o -name '*.jar' -o -name '*.xpt' -o -name '*.so' \) -ex
mv components/pixmaps/newmail.xpm .
rm -rf components/pixmaps
+%if %{fedora} >= 14
+sed -i 's|nsIGenericFactory.h|mozilla/ModuleUtils.h|g' components/nsTrayModue.cpp
+%endif
%build
export GECKO_SDK=$(pkg-config libxul --variable=sdkdir)
@@ -211,11 +219,10 @@ scons %{upname}.xpi
%install
rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT%{mz_ext_dir}{%{ff_guid}/%{ft_guid},%{tb_guid}/%{ft_guid},%{sb_guid},%{cz_guid}/%{ft_guid},%{ib_guid}/%{ft_guid}}
+mkdir -p $RPM_BUILD_ROOT%{mz_ext_dir}{%{ff_guid}/%{ft_guid},%{tb_guid}/%{ft_guid},%{sb_guid}/%{ft_guid},%{cz_guid}/%{ft_guid},%{ib_guid}/%{ft_guid}}
mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{name}-%{version}
unzip %{upname}.xpi -d $RPM_BUILD_ROOT%{_libdir}/%{name}-%{version}
-chmod +x $RPM_BUILD_ROOT%{_libdir}/%{name}-%{version}/components/libnptray.so
# rename changes file to ChangeLog
mv changes ChangeLog
@@ -270,8 +277,20 @@ popd
%endif
#sunbird
-pushd $RPM_BUILD_ROOT%{mz_ext_dir}%{sb_guid}
- ln -s %{_libdir}/%{name}-%{version} %{ft_guid}
+#more symlink vodoo for sunbird since it crashes after the first start when using a whole symlinked extension directory
+pushd $RPM_BUILD_ROOT%{mz_ext_dir}%{sb_guid}/%{ft_guid}
+ ln -s %{_libdir}/%{name}-%{version}/install.rdf install.rdf
+ ln -s %{_libdir}/%{name}-%{version}/chrome.manifest chrome.manifest
+ ln -s %{_libdir}//%{name}-%{version}/chrome chrome
+ ln -s %{_libdir}//%{name}-%{version}/defaults defaults
+
+ mkdir components
+ cd components
+ ln -s %{_libdir}/%{name}-%{version}/components/nsMinimize.js nsMinimize.js
+ ln -s %{_libdir}/%{name}-%{version}/components/nsITray.xpt nsITray.xpt
+ ln -s %{_libdir}/%{name}-%{version}/components/nsIMinimize.xpt nsIMinimize.xpt
+ ln -s %{_libdir}/%{name}-%{version}/components/libnptray.so libnptray.so
+ cd ..
popd
# chatzilla
@@ -333,6 +352,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Tue Sep 14 2010 Hicham HAOUARI <hicham.haouari at gmail.com> - 0.2.8-3
+- Fix for the new way of xpcom registration
+
* Fri Aug 05 2010 Hicham HAOUARI <hicham.haouari at gmail.com> - 0.2.8-2
- Backport patch from upstream svn to use the system's CXXFLAGS, fixes
rhbz #621683
More information about the scm-commits
mailing list