Switched to use the category manager for registration

This commit is contained in:
tonyr%fbdesigns.com 2000-02-11 03:35:24 +00:00
Родитель b9facfc045
Коммит 0add89cc34
1 изменённых файлов: 13 добавлений и 59 удалений

Просмотреть файл

@ -28,45 +28,19 @@
#include "nsIModule.h" #include "nsIModule.h"
#include "nsIGenericFactory.h" #include "nsIGenericFactory.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsIRegistry.h"
#include "nsIImportService.h" #include "nsIImportService.h"
#include "nsOutlookImport.h" #include "nsOutlookImport.h"
#include "nsCRT.h"
#include "nsICategoryManager.h"
#include "nsXPIDLString.h"
#include "OutlookDebugLog.h" #include "OutlookDebugLog.h"
static NS_DEFINE_CID(kOutlookImportCID, NS_OUTLOOKIMPORT_CID); 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, NS_METHOD OutlookRegister(nsIComponentManager *aCompMgr,
nsIFile *aPath, nsIFile *aPath,
@ -75,37 +49,17 @@ NS_METHOD OutlookRegister(nsIComponentManager *aCompMgr,
{ {
nsresult rv; nsresult rv;
NS_WITH_SERVICE( nsIRegistry, reg, kRegistryCID, &rv); nsCOMPtr<nsICategoryManager> catMan = do_GetService( NS_CATEGORYMANAGER_PROGID, &rv);
if (NS_FAILED(rv)) { if (NS_SUCCEEDED( rv)) {
IMPORT_LOG0( "*** Import Outlook, ERROR GETTING THE Registry\n"); nsXPIDLCString replace;
return rv; char *theCID = kOutlookImportCID.ToString();
} rv = catMan->AddCategoryEntry( "mailnewsimport", theCID, kOutlookSupportsString, PR_TRUE, PR_TRUE, getter_Copies( replace));
nsCRT::free( theCID);
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);
if (NS_FAILED( rv)) {
IMPORT_LOG0( "*** Import Outlook, ERROR getting Netscape/Import registry key\n");
return( rv);
} }
nsRegistryKey key; if (NS_FAILED( rv)) {
rv = reg->AddSubtree( importKey, "Outlook", &key); IMPORT_LOG0( "*** ERROR: Problem registering Outlook component in the category manager\n");
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);
return( rv); return( rv);
} }