Enable APOC adapter when build with --with-apoc-apdater
authorhawklu
Wed, 04 Feb 2009 08:44:39 +0000
changeset 15010 c61df03ccf5b
parent 15009 9cd4a1ffe12d
child 15011 c181f6833139
Enable APOC adapter when build with --with-apoc-apdater
ChangeLog
base-specs/firefox.spec
patches/firefox3-23-package-apoc-adapter.diff
patches/firefox3-24-enable-apoc-adapter.diff
--- a/ChangeLog	Wed Feb 04 08:36:25 2009 +0000
+++ b/ChangeLog	Wed Feb 04 08:44:39 2009 +0000
@@ -1,3 +1,10 @@
+2009-02-04  Brian Lu  <[email protected]>
+
+	* base-specs/firefox.spec:
+	* patches/firefox3-23-package-apoc-adapter.diff:
+	* patches/firefox3-24-enable-apoc-adapter.diff:
+	  Enable APOC adapter when build with --with-apoc-apdater
+
 2009-02-04  Takao Fujiwara  <[email protected]>
 
 	* SUNWdbus.spec: Updated to rename 0005.dbus.
--- a/base-specs/firefox.spec	Wed Feb 04 08:36:25 2009 +0000
+++ b/base-specs/firefox.spec	Wed Feb 04 08:44:39 2009 +0000
@@ -27,6 +27,11 @@
 Source7:     %{name}-js.pc.in
 %define without_moz_nss_nspr %{?_without_moz_nss_nspr:1}%{?!_without_moz_nss_nspr:0}
 %define with_apoc_adapter %{?_with_apoc_adapter:1}%{?!_with_apoc_adapter:0}
+%if %with_apoc_adapter
+%define apoc_version 3.1
+Source8:     firefox-%{apoc_version}-apoc-adapter.tar.bz2
+%endif
+
 
 # owner:evan date:2007-11-28 type:branding
 # change preference to support multi-language
@@ -100,6 +105,14 @@
 # owner:alfred date:2009-02-02 type:branding bugster:6735323
 Patch22: firefox3-22-default-to-downloads.diff
 
+%if %with_apoc_adapter
+# owner:brian.lu date:2009-02-04 type:branding bugster:6801006
+Patch23: firefox3-23-package-apoc-adapter.diff
+
+# owner:brian.lu date:2009-02-04 type:branding bugster:6478680
+Patch24: firefox3-24-enable-apoc-adapter.diff
+%endif
+
 URL:         http://www.mozilla.com/firefox
 
 BuildRoot:   %{_tmppath}/%{name}-%{tarball_version}-build
@@ -146,8 +159,11 @@
 #####################################
 
 %prep
-
+%if %with_apoc_adapter
+%setup -q -c -n %{name} -a8
+%else
 %setup -q -c -n %{name}
+%endif
 
 cd ..
 /bin/mv %{name} %{name}.tmp.$$
@@ -177,6 +193,11 @@
 %patch21 -p1
 %patch22 -p1
 
+%if %with_apoc_adapter
+%patch23 -p1 
+%patch24 -p1 
+%endif
+
 #####################################
 ##      Package Build Section      ##
 #####################################
@@ -364,6 +385,8 @@
 %{_datadir}/pixmaps/%{name}-icon.png
 
 %changelog
+* Web Feb 04 2009 - [email protected]
+- Enable APOC adapter when build with --with-apoc-apdater
 * Mon Feb 02 2009 - [email protected]
 - fit and finish: add default-to-downloads.diff for bugster CR#6735323.
 * Wed Jan 07 2009 - [email protected]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/firefox3-23-package-apoc-adapter.diff	Wed Feb 04 08:44:39 2009 +0000
@@ -0,0 +1,7 @@
+--- firefox/browser/installer/unix/packages-static.old	2009-02-04 11:44:59.752650899 +0800
++++ firefox/browser/installer/unix/packages-static	2009-02-04 11:41:35.252872330 +0800
+@@ -383,3 +383,4 @@
+ ; [Extensions]
+ ;
+ bin/components/libnkgnomevfs.so
++bin/components/libmozapoc.so
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/firefox3-24-enable-apoc-adapter.diff	Wed Feb 04 08:44:39 2009 +0000
@@ -0,0 +1,101 @@
+--- mozilla/xpcom/components/nsComponentManager.cpp.old	2009-02-04 14:12:38.803146859 +0800
++++ mozilla/xpcom/components/nsComponentManager.cpp	2009-02-04 14:12:53.523429846 +0800
+@@ -47,6 +47,7 @@
+  * 04/20/2000       IBM Corp.      Added PR_CALLBACK for Optlink use in OS2
+  */
+ #include <stdlib.h>
++#include "plstr.h"
+ #include "nscore.h"
+ #include "nsISupports.h"
+ #include "nspr.h"
+@@ -110,6 +111,8 @@
+ // 512K is big enough to allow for some future growth in the registry.
+ #define BIG_REGISTRY_BUFLEN   (512*1024)
+ 
++static PRBool apocRead = PR_FALSE;
++
+ // Common Key Names
+ const char classIDKeyName[]="classID";
+ const char classesKeyName[]="contractID";
+@@ -1089,6 +1092,7 @@
+                  PRUint32 number,
+                  void *arg)
+ {
++    static char apocCIDString[UID_STRING_LENGTH] = "{833fbe65-5a14-4634-8387-fcf47e24c9ca}";
+     char *contractID   = ((nsContractIDTableEntry*)hdr)->mContractID;
+     nsFactoryEntry *factoryEntry = ((nsContractIDTableEntry*)hdr)->mFactoryEntry;
+ 
+@@ -1103,7 +1107,22 @@
+ 
+     char cidString[UID_STRING_LENGTH];
+     GetIDString(factoryEntry->mCid, cidString);
+-    PR_fprintf(fd, "%s,%s\n", contractID, cidString); // what if this fails?
++
++    // cid,contract_id,type,class_name,inproc_server
++    // Because libmozapoc.so shares a same contractID (@mozilla.org/preferences-service;1)
++    // with libpref.so. To prevent libpref.so from bundling to that contractID
++    // do the following tricky operation.
++    const char* location = factoryEntry->mLocationKey;
++
++    if (apocRead && contractID && location
++        && !strcmp(contractID,"@mozilla.org/preferences-service;1")
++        && !strcmp(location,"rel:libpref.so"))
++    {
++        PR_fprintf(fd, "%s,%s\n", contractID, apocCIDString);
++    } else {
++        PR_fprintf(fd, "%s,%s\n", contractID, cidString); // what if this fails?
++    }
++
+     return PL_DHASH_NEXT;
+ }
+ 
+@@ -1113,6 +1132,9 @@
+               PRUint32 number,
+               void *arg)
+ {
++    static char apocCIDString[UID_STRING_LENGTH] = "{833fbe65-5a14-4634-8387-fcf47e24c9ca}";
++    static PRBool prefRead = PR_FALSE;
++
+     nsFactoryEntry *factoryEntry = ((nsFactoryTableEntry*)hdr)->mFactoryEntry;
+     PRFileDesc* fd = ((PersistentWriterArgs*)arg)->mFD;
+     nsTArray<nsLoaderdata> *loaderData = ((PersistentWriterArgs*)arg)->mLoaderData;
+@@ -1154,6 +1176,22 @@
+     const char* location = factoryEntry->mLocationKey;
+ 
+     // cid,contract_id,type,class_name,inproc_server
++    // Because libmozapoc.so shares a same contractID (@mozilla.org/preferences-service;1)
++    // with libpref.so. To prevent libpref.so from bundling to that contractID 
++    // do the following tricky operation.
++    if (location
++        && !strcmp(location,"rel:libmozapoc.so"))
++    {
++        apocRead = PR_TRUE;
++        if (!prefRead) {
++            if (contractID)
++                PR_Free(contractID);
++            if (className)
++                PR_Free(className);
++            return PL_DHASH_NEXT;
++        }
++    }
++
+     PR_fprintf(fd,
+                "%s,%s,%s,%s,%s\n",
+                cidString,
+@@ -1162,6 +1200,16 @@
+                (className  ? className  : ""),
+                (location   ? location   : ""));
+ 
++    if (contractID && location 
++        && !strcmp(contractID,"@mozilla.org/preferences-service;1")
++        && !strcmp(location,"rel:libpref.so"))
++    {
++        prefRead = PR_TRUE;
++        if (apocRead)
++             PR_fprintf(fd, "%s,%s,%s,%s,%s\n", 
++               apocCIDString, (contractID ? contractID : ""), "", "", "rel:libmozapoc.so"); 
++    }
++
+     if (contractID)
+         PR_Free(contractID);
+     if (className)