From 0add89cc34d3668da0b026e8643e1adda34763b6 Mon Sep 17 00:00:00 2001 From: "tonyr%fbdesigns.com" Date: Fri, 11 Feb 2000 03:35:24 +0000 Subject: [PATCH] Switched to use the category manager for registration --- .../import/outlook/src/nsOutlookFactory.cpp | 72 ++++--------------- 1 file changed, 13 insertions(+), 59 deletions(-) diff --git a/mailnews/import/outlook/src/nsOutlookFactory.cpp b/mailnews/import/outlook/src/nsOutlookFactory.cpp index b2e2b6834be..fc26376e81e 100644 --- a/mailnews/import/outlook/src/nsOutlookFactory.cpp +++ b/mailnews/import/outlook/src/nsOutlookFactory.cpp @@ -28,45 +28,19 @@ #include "nsIModule.h" #include "nsIGenericFactory.h" #include "nsIServiceManager.h" -#include "nsIRegistry.h" #include "nsIImportService.h" #include "nsOutlookImport.h" +#include "nsCRT.h" +#include "nsICategoryManager.h" +#include "nsXPIDLString.h" #include "OutlookDebugLog.h" static NS_DEFINE_CID(kOutlookImportCID, NS_OUTLOOKIMPORT_CID); -static NS_DEFINE_CID(kImportServiceCID, NS_IMPORTSERVICE_CID); -static NS_DEFINE_CID(kRegistryCID, NS_REGISTRY_CID); //////////////////////////////////////////////////////////////////////////// -nsresult GetImportModulesRegKey( nsIRegistry *reg, nsRegistryKey *pKey) -{ - nsRegistryKey nScapeKey; - nsresult rv = reg->GetSubtree( nsIRegistry::Common, "Netscape", &nScapeKey); - if (NS_FAILED(rv)) { - rv = reg->AddSubtree( nsIRegistry::Common, "Netscape", &nScapeKey); - } - if (NS_FAILED( rv)) - return( rv); - - nsRegistryKey iKey; - rv = reg->GetSubtree( nScapeKey, "Import", &iKey); - if (NS_FAILED( rv)) { - rv = reg->AddSubtree( nScapeKey, "Import", &iKey); - } - - if (NS_FAILED( rv)) - return( rv); - - rv = reg->GetSubtree( iKey, "Modules", pKey); - if (NS_FAILED( rv)) { - rv = reg->AddSubtree( iKey, "Modules", pKey); - } - - return( rv); -} NS_METHOD OutlookRegister(nsIComponentManager *aCompMgr, nsIFile *aPath, @@ -74,38 +48,18 @@ NS_METHOD OutlookRegister(nsIComponentManager *aCompMgr, const char *componentType) { nsresult rv; - - NS_WITH_SERVICE( nsIRegistry, reg, kRegistryCID, &rv); - if (NS_FAILED(rv)) { - IMPORT_LOG0( "*** Import Outlook, ERROR GETTING THE Registry\n"); - return rv; - } - - rv = reg->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry); - - if (NS_FAILED(rv)) { - IMPORT_LOG0( "*** Import Outlook, ERROR OPENING THE REGISTRY\n"); - return( rv); - } - - nsRegistryKey importKey; - rv = GetImportModulesRegKey( reg, &importKey); + nsCOMPtr catMan = do_GetService( NS_CATEGORYMANAGER_PROGID, &rv); + if (NS_SUCCEEDED( rv)) { + nsXPIDLCString replace; + char *theCID = kOutlookImportCID.ToString(); + rv = catMan->AddCategoryEntry( "mailnewsimport", theCID, kOutlookSupportsString, PR_TRUE, PR_TRUE, getter_Copies( replace)); + nsCRT::free( theCID); + } + if (NS_FAILED( rv)) { - IMPORT_LOG0( "*** Import Outlook, ERROR getting Netscape/Import registry key\n"); - return( rv); - } - - nsRegistryKey key; - rv = reg->AddSubtree( importKey, "Outlook", &key); - if (NS_FAILED(rv)) return( rv); - - rv = reg->SetString( key, "Supports", kOutlookSupportsString); - if (NS_FAILED(rv)) return( rv); - char *myCID = kOutlookImportCID.ToString(); - rv = reg->SetString( key, "CLSID", myCID); - delete [] myCID; - if (NS_FAILED(rv)) return( rv); + IMPORT_LOG0( "*** ERROR: Problem registering Outlook component in the category manager\n"); + } return( rv); }