Switched to use the category manager for registration

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

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

@ -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<nsICategoryManager> 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);
}