From dc4536cee9d33f48f9c8e5f053a3120827020abe Mon Sep 17 00:00:00 2001 From: "neil%parkwaycc.co.uk" Date: Mon, 21 Jan 2008 23:47:56 +0000 Subject: [PATCH] Make command-line handlers work in nonstatic mail builds b=329021 r=Standard8 --- mailnews/addrbook/build/nsAbFactory.cpp | 32 +++++++++++++++++++- mailnews/base/build/nsMsgFactory.cpp | 33 +++++++++++++++++++-- mailnews/compose/build/nsMsgCompFactory.cpp | 32 +++++++++++++++++++- mailnews/news/build/nsMsgNewsFactory.cpp | 32 +++++++++++++++++++- 4 files changed, 124 insertions(+), 5 deletions(-) diff --git a/mailnews/addrbook/build/nsAbFactory.cpp b/mailnews/addrbook/build/nsAbFactory.cpp index 380685df3bd..bed5ab0e7ac 100644 --- a/mailnews/addrbook/build/nsAbFactory.cpp +++ b/mailnews/addrbook/build/nsAbFactory.cpp @@ -42,6 +42,7 @@ #include "nsAbBaseCID.h" #include "pratom.h" +#include "nsICategoryManager.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "rdf.h" @@ -155,6 +156,33 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbView) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgVCardService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDIFService) +static NS_METHOD +RegisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, + const char *location, const char *type, + const nsModuleComponentInfo *info) +{ + nsCOMPtr catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); + NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); + + return catMan->AddCategoryEntry("command-line-handler", "m-addressbook", + NS_ABMANAGERSTARTUPHANDLER_CONTRACTID, + PR_TRUE, PR_TRUE, nsnull); +} + +static NS_METHOD +UnregisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, + const char *location, + const nsModuleComponentInfo *info) +{ + nsCOMPtr catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); + NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); + + catMan->DeleteCategoryEntry("command-line-handler", "m-addressbook", + PR_TRUE); + + return NS_OK; +} + static const nsModuleComponentInfo components[] = { { "Address Book Manager", @@ -165,7 +193,9 @@ static const nsModuleComponentInfo components[] = { "Address Book Manager Startup Handler", NS_ABMANAGER_CID, NS_ABMANAGERSTARTUPHANDLER_CONTRACTID, - nsAbManagerConstructor }, + nsAbManagerConstructor, + RegisterCommandLineHandler, + UnregisterCommandLineHandler }, { "Address Book Directory Datasource", NS_ABDIRECTORYDATASOURCE_CID, diff --git a/mailnews/base/build/nsMsgFactory.cpp b/mailnews/base/build/nsMsgFactory.cpp index 366935c9761..21cc7f6b598 100644 --- a/mailnews/base/build/nsMsgFactory.cpp +++ b/mailnews/base/build/nsMsgFactory.cpp @@ -45,8 +45,8 @@ #include "nsIGenericFactory.h" #include "nsMsgBaseCID.h" #include "pratom.h" -#include "nsIComponentManager.h" #include "nsICategoryManager.h" +#include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "rdf.h" #include "nsCOMPtr.h" @@ -222,6 +222,33 @@ UnregisterMailnewsContentPolicy(nsIComponentManager *aCompMgr, nsIFile *aPath, PR_TRUE); } +static NS_METHOD +RegisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, + const char *location, const char *type, + const nsModuleComponentInfo *info) +{ + nsCOMPtr catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); + NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); + + return catMan->AddCategoryEntry("command-line-handler", "m-mail", + NS_MAILSTARTUPHANDLER_CONTRACTID, + PR_TRUE, PR_TRUE, nsnull); +} + +static NS_METHOD +UnregisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, + const char *location, + const nsModuleComponentInfo *info) +{ + nsCOMPtr catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); + NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); + + catMan->DeleteCategoryEntry("command-line-handler", "m-mail", + PR_TRUE); + + return NS_OK; +} + // The list of components we register static const nsModuleComponentInfo gComponents[] = { @@ -235,7 +262,9 @@ static const nsModuleComponentInfo gComponents[] = { }, { "Mail Startup Handler", NS_MESSENGERBOOTSTRAP_CID, NS_MAILSTARTUPHANDLER_CONTRACTID, - nsMessengerBootstrapConstructor + nsMessengerBootstrapConstructor, + RegisterCommandLineHandler, + UnregisterCommandLineHandler, }, { "UrlListenerManager", NS_URLLISTENERMANAGER_CID, NS_URLLISTENERMANAGER_CONTRACTID, diff --git a/mailnews/compose/build/nsMsgCompFactory.cpp b/mailnews/compose/build/nsMsgCompFactory.cpp index e4d8465ee7e..5669a909335 100644 --- a/mailnews/compose/build/nsMsgCompFactory.cpp +++ b/mailnews/compose/build/nsMsgCompFactory.cpp @@ -41,6 +41,7 @@ #include "nsCOMPtr.h" #include "nsIFactory.h" +#include "nsICategoryManager.h" #include "nsIGenericFactory.h" #include "nsIServiceManager.h" #include "nsIModule.h" @@ -90,6 +91,33 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSmtpDelegateFactory) NS_GENERIC_FACTORY_CONSTRUCTOR(nsURLFetcher) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgCompUtils) +static NS_METHOD +RegisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, + const char *location, const char *type, + const nsModuleComponentInfo *info) +{ + nsCOMPtr catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); + NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); + + return catMan->AddCategoryEntry("command-line-handler", "m-compose", + NS_MSGCOMPOSESTARTUPHANDLER_CONTRACTID, + PR_TRUE, PR_TRUE, nsnull); +} + +static NS_METHOD +UnregisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, + const char *location, + const nsModuleComponentInfo *info) +{ + nsCOMPtr catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); + NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); + + catMan->DeleteCategoryEntry("command-line-handler", "m-compose", + PR_TRUE); + + return NS_OK; +} + //////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////// @@ -107,7 +135,9 @@ static const nsModuleComponentInfo components[] = { "Msg Compose Startup Handler", NS_MSGCOMPOSESERVICE_CID, NS_MSGCOMPOSESTARTUPHANDLER_CONTRACTID, - nsMsgComposeServiceConstructor }, + nsMsgComposeServiceConstructor, + RegisterCommandLineHandler, + UnregisterCommandLineHandler }, { "mailto content handler", NS_MSGCOMPOSECONTENTHANDLER_CID, NS_MSGCOMPOSECONTENTHANDLER_CONTRACTID, diff --git a/mailnews/news/build/nsMsgNewsFactory.cpp b/mailnews/news/build/nsMsgNewsFactory.cpp index 82ebfcc24ca..efb158e92d4 100644 --- a/mailnews/news/build/nsMsgNewsFactory.cpp +++ b/mailnews/news/build/nsMsgNewsFactory.cpp @@ -42,6 +42,7 @@ #include "msgCore.h" #include "pratom.h" +#include "nsICategoryManager.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsCOMPtr.h" @@ -68,6 +69,33 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsNNTPNewsgroupList) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgNewsFolder) NS_GENERIC_FACTORY_CONSTRUCTOR(nsNewsDownloadDialogArgs) +static NS_METHOD +RegisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, + const char *location, const char *type, + const nsModuleComponentInfo *info) +{ + nsCOMPtr catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); + NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); + + return catMan->AddCategoryEntry("command-line-handler", "m-news", + NS_NEWSSTARTUPHANDLER_CONTRACTID, + PR_TRUE, PR_TRUE, nsnull); +} + +static NS_METHOD +UnregisterCommandLineHandler(nsIComponentManager* compMgr, nsIFile* path, + const char *location, + const nsModuleComponentInfo *info) +{ + nsCOMPtr catMan (do_GetService(NS_CATEGORYMANAGER_CONTRACTID)); + NS_ENSURE_TRUE(catMan, NS_ERROR_FAILURE); + + catMan->DeleteCategoryEntry("command-line-handler", "m-news", + PR_TRUE); + + return NS_OK; +} + static const nsModuleComponentInfo components[] = { { "NNTP URL", @@ -81,7 +109,9 @@ static const nsModuleComponentInfo components[] = { "News Startup Handler", NS_NNTPSERVICE_CID, NS_NEWSSTARTUPHANDLER_CONTRACTID, - nsNntpServiceConstructor }, + nsNntpServiceConstructor, + RegisterCommandLineHandler, + UnregisterCommandLineHandler }, { "NNTP Protocol Info", NS_NNTPSERVICE_CID, NS_NNTPPROTOCOLINFO_CONTRACTID,