fix for bug #40248. I was using the category manager incorrectly.

thanks to bruce@cubik.org for pointing it out.
This commit is contained in:
sspitzer%netscape.com 2000-06-01 04:14:34 +00:00
parent 221780c317
commit f46ad05a0b
7 changed files with 34 additions and 17 deletions

View File

@ -65,7 +65,7 @@ NS_METHOD nsCookieHTTPNotify::RegisterProc(nsIComponentManager *aCompMgr,
nsCID cid = NS_COOKIEHTTPNOTIFY_CID; nsCID cid = NS_COOKIEHTTPNOTIFY_CID;
char *cidString = cid.ToString(); char *cidString = cid.ToString();
nsXPIDLCString prevEntry; nsXPIDLCString prevEntry;
rv = catman->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY, cidString, "Http Cookie Notify", rv = catman->AddCategoryEntry(NS_HTTP_STARTUP_CATEGORY, "Http Cookie Notify", cidString,
PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); PR_TRUE, PR_TRUE, getter_Copies(prevEntry));
nsAllocator::Free(cidString); nsAllocator::Free(cidString);

View File

@ -52,7 +52,7 @@ function (compMgr, fileSpec, location, type)
true, true, type); true, true, type);
catman = Components.classes["mozilla.categorymanager.1"].getService(nsICategoryManager); catman = Components.classes["mozilla.categorymanager.1"].getService(nsICategoryManager);
catman.addCategoryEntry("command-line-argument-handlers",CHATZILLASERVICE_PROGID, "chatzilla command line handler", true, true); catman.addCategoryEntry("command-line-argument-handlers","chatzilla command line handler",CHATZILLASERVICE_PROGID, true, true);
} }
chatzillaModule.unregisterSelf = chatzillaModule.unregisterSelf =

View File

@ -48,6 +48,10 @@
#include "nsICategoryManager.h" #include "nsICategoryManager.h"
#include "nsISupportsPrimitives.h" #include "nsISupportsPrimitives.h"
#if defined(DEBUG_dp) || defined(DEBUG_sspitzer) || defined(DEBUG_seth)
#define DEBUG_HTTP_STARTUP_CATEGORY 1
#endif
#include "nsHTTPRequest.h" #include "nsHTTPRequest.h"
#ifdef DEBUG_gagan #ifdef DEBUG_gagan
#include "nsIWebFilters.h" #include "nsIWebFilters.h"
@ -139,31 +143,39 @@ CategoryCreateService( const char *category )
nFailed++; nFailed++;
continue; continue;
} }
nsXPIDLCString cidString; nsXPIDLCString entryString;
rv = catEntry->GetData(getter_Copies(cidString)); rv = catEntry->GetData(getter_Copies(entryString));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
{ {
nFailed++; nFailed++;
continue; continue;
} }
nsXPIDLCString cidString;
rv = categoryManager->GetCategoryEntry(category,(const char *)entryString, getter_Copies(cidString));
if (NS_FAILED(rv))
{
nFailed++;
continue;
}
nsCID cid; nsCID cid;
rv = cid.Parse(cidString); rv = cid.Parse(cidString);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
#ifdef DEBUG_dp #ifdef DEBUG_HTTP_STARTUP_CATEGORY
printf("CategoryCreateInstance: Instantiating cid: %s \ printf("CategoryCreateInstance: Instantiating cid: %s \
in category %s.\n", in category %s.\n",
(const char *)cidString, category); (const char *)cidString, category);
#endif /* DEBUG_dp */ #endif /* DEBUG_HTTP_STARTUP_CATEGORY */
// Create a service from the cid // Create a service from the cid
nsCOMPtr<nsISupports> instance = do_GetService(cid, &rv); nsCOMPtr<nsISupports> instance = do_GetService(cid, &rv);
} }
else else
{ {
#ifdef DEBUG_dp #ifdef DEBUG_HTTP_STARTUP_CATEGORY
printf("HTTP Handler: Instantiating progid %s \ printf("HTTP Handler: Instantiating progid %s \
in http startup category.\n", (const char *)cidString); in http startup category.\n", (const char *)cidString);
#endif /* DEBUG_dp */ #endif /* DEBUG_HTTP_STARTUP_CATEGORY */
// This might be a progid. Try that too. // This might be a progid. Try that too.
nsCOMPtr<nsISupports> instance = do_GetService(cidString, &rv); nsCOMPtr<nsISupports> instance = do_GetService(cidString, &rv);
} }

View File

@ -93,7 +93,7 @@ NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPat
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv); \ nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv); \
if (NS_FAILED(rv)) return rv; \ if (NS_FAILED(rv)) return rv; \
nsXPIDLCString prevEntry; \ nsXPIDLCString prevEntry; \
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_progid, macro_pretty_name, PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); \ rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_pretty_name, macro_progid, PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); \
return NS_OK; \ return NS_OK; \
} \ } \
NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation) \ NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation) \

View File

@ -289,12 +289,17 @@ static void DumpArbitraryHelp()
rv = catman->EnumerateCategory(COMMAND_LINE_ARGUMENT_HANDLERS, getter_AddRefs(e)); rv = catman->EnumerateCategory(COMMAND_LINE_ARGUMENT_HANDLERS, getter_AddRefs(e));
if(NS_SUCCEEDED(rv) && e) { if(NS_SUCCEEDED(rv) && e) {
while (PR_TRUE) { while (PR_TRUE) {
nsCOMPtr<nsISupportsString> progid; nsCOMPtr<nsISupportsString> catEntry;
rv = e->GetNext(getter_AddRefs(progid)); rv = e->GetNext(getter_AddRefs(catEntry));
if (NS_FAILED(rv) || !progid) break; if (NS_FAILED(rv) || !catEntry) break;
nsXPIDLCString entryString;
rv = catEntry->GetData(getter_Copies(entryString));
if (NS_FAILED(rv) || !((const char *)entryString)) break;
nsXPIDLCString progidString; nsXPIDLCString progidString;
progid->ToString (getter_Copies(progidString)); rv = catman->GetCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS,(const char *)entryString, getter_Copies(progidString));
if (NS_FAILED(rv) || !((const char *)progidString)) break;
#ifdef DEBUG_CMD_LINE #ifdef DEBUG_CMD_LINE
printf("cmd line handler progid = %s\n", (const char *)progidString); printf("cmd line handler progid = %s\n", (const char *)progidString);

View File

@ -64,8 +64,8 @@ var jsConsoleHandlerModule = {
location, true, true, type); location, true, true, type);
var catman = Components.classes["mozilla.categorymanager.1"] var catman = Components.classes["mozilla.categorymanager.1"]
.getService(Components.interfaces.nsICategoryManager); .getService(Components.interfaces.nsICategoryManager);
catman.addCategoryEntry("command-line-argument-handlers", catman.addCategoryEntry("command-line-argument-handlers", "jsconsole command line handler",
JSCONSOLEHANDLER_PROGID, "jsconsole command line handler", JSCONSOLEHANDLER_PROGID,
true, true); true, true);
}, },

View File

@ -93,7 +93,7 @@ NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPat
nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv); \ nsCOMPtr<nsICategoryManager> catman = do_GetService("mozilla.categorymanager.1", &rv); \
if (NS_FAILED(rv)) return rv; \ if (NS_FAILED(rv)) return rv; \
nsXPIDLCString prevEntry; \ nsXPIDLCString prevEntry; \
rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_progid, macro_pretty_name, PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); \ rv = catman->AddCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, macro_pretty_name, macro_progid, PR_TRUE, PR_TRUE, getter_Copies(prevEntry)); \
return NS_OK; \ return NS_OK; \
} \ } \
NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation) \ NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation) \