1 --- mozilla/xpcom/components/nsComponentManager.cpp.old 2007-01-18 15:56:15.059579000 +0800 2 +++ mozilla/xpcom/components/nsComponentManager.cpp 2007-01-18 16:00:53.028417000 +0800 3 @@ -47,6 +47,7 @@ 4 * 04/20/2000 IBM Corp. Added PR_CALLBACK for Optlink use in OS2 5 */ 6 #include <stdlib.h> 7 +#include "plstr.h" 8 #include "nscore.h" 9 #include "nsISupports.h" 10 #include "nspr.h" 11 @@ -111,6 +112,8 @@ 12 // 512K is big enough to allow for some future growth in the registry. 13 #define BIG_REGISTRY_BUFLEN (512*1024) 14 15 +static PRBool apocRead = PR_FALSE; 16 + 17 // Common Key Names 18 const char classIDKeyName[]="classID"; 19 const char classesKeyName[]="contractID"; 20 @@ -1328,6 +1331,7 @@ 21 PRUint32 number, 22 void *arg) 23 { 24 + static char apocCIDString[UID_STRING_LENGTH] = "{833fbe65-5a14-4634-8387-fcf47e24c9ca}"; 25 char *contractID = ((nsContractIDTableEntry*)hdr)->mContractID; 26 nsFactoryEntry *factoryEntry = ((nsContractIDTableEntry*)hdr)->mFactoryEntry; 27 28 @@ -1342,7 +1346,22 @@ 29 30 char cidString[UID_STRING_LENGTH]; 31 GetIDString(factoryEntry->mCid, cidString); 32 - PR_fprintf(fd, "%s,%s\n", contractID, cidString); // what if this fails? 33 + 34 + // cid,contract_id,type,class_name,inproc_server 35 + // Because libmozapoc.so shares a same contractID (@mozilla.org/preferences-service;1) 36 + // with libpref.so. To prevent libpref.so from bundling to that contractID 37 + // do the following tricky operation. 38 + char* location = factoryEntry->mLocation; 39 + 40 + if (apocRead && contractID && location 41 + && !strcmp(contractID,"@mozilla.org/preferences-service;1") 42 + && !strcmp(location,"rel:libpref.so")) 43 + { 44 + PR_fprintf(fd, "%s,%s\n", contractID, apocCIDString); 45 + } else { 46 + PR_fprintf(fd, "%s,%s\n", contractID, cidString); // what if this fails? 47 + } 48 + 49 return PL_DHASH_NEXT; 50 } 51 52 @@ -1352,6 +1371,8 @@ 53 PRUint32 number, 54 void *arg) 55 { 56 + static char apocCIDString[UID_STRING_LENGTH] = "{833fbe65-5a14-4634-8387-fcf47e24c9ca}"; 57 + static PRBool prefRead = PR_FALSE; 58 nsFactoryEntry *factoryEntry = ((nsFactoryTableEntry*)hdr)->mFactoryEntry; 59 PRFileDesc* fd = ((PersistentWriterArgs*)arg)->mFD; 60 nsLoaderdata *loaderData = ((PersistentWriterArgs*)arg)->mLoaderData; 61 @@ -1383,6 +1404,22 @@ 62 char* location = factoryEntry->mLocation; 63 64 // cid,contract_id,type,class_name,inproc_server 65 + // Because libmozapoc.so shares a same contractID (@mozilla.org/preferences-service;1) 66 + // with libpref.so. To prevent libpref.so from bundling to that contractID 67 + // do the following tricky operation. 68 + if (location 69 + && !strcmp(location,"rel:libmozapoc.so")) 70 + { 71 + apocRead = PR_TRUE; 72 + if (!prefRead) { 73 + if (contractID) 74 + PR_Free(contractID); 75 + if (className) 76 + PR_Free(className); 77 + return PL_DHASH_NEXT; 78 + } 79 + } 80 + 81 PR_fprintf(fd, 82 "%s,%s,%s,%s,%s\n", 83 cidString, 84 @@ -1391,6 +1428,16 @@ 85 (className ? className : ""), 86 (location ? location : "")); 87 88 + if (contractID && location 89 + && !strcmp(contractID,"@mozilla.org/preferences-service;1") 90 + && !strcmp(location,"rel:libpref.so")) 91 + { 92 + prefRead = PR_TRUE; 93 + if (apocRead) 94 + PR_fprintf(fd, "%s,%s,%s,%s,%s\n", 95 + apocCIDString, (contractID ? contractID : ""), "", "", "rel:libmozapoc.so"); 96 + } 97 + 98 if (contractID) 99 PR_Free(contractID); 100 if (className) 101