Update to changed nsIMsgAccountManager interfaces

This commit is contained in:
tonyr%fbdesigns.com 2000-01-09 17:30:18 +00:00
Родитель c08da1493c
Коммит 7804e3805c
8 изменённых файлов: 55 добавлений и 293 удалений

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

@ -682,11 +682,11 @@ PRBool nsEudoraMac::BuildPOPAccount( nsIMsgAccountManager *accMgr, nsCString **p
nsresult rv = accMgr->FindServer( *(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), "pop3", getter_AddRefs( in));
if (NS_FAILED( rv) || (in == nsnull)) {
// Create the incoming server and an account for it?
rv = accMgr->CreateIncomingServer( "pop3", getter_AddRefs( in));
rv = accMgr->CreateIncomingServer( *(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), "pop3", getter_AddRefs( in));
if (NS_SUCCEEDED( rv) && in) {
rv = in->SetType( "pop3");
rv = in->SetHostName( *(pStrs[kPopServerStr]));
rv = in->SetUsername( *(pStrs[kPopAccountNameStr]));
// rv = in->SetHostName( *(pStrs[kPopServerStr]));
// rv = in->SetUsername( *(pStrs[kPopAccountNameStr]));
IMPORT_LOG2( "Created POP3 server named: %s, userName: %s\n", (const char *)(*(pStrs[kPopServerStr])), (const char *)(*(pStrs[kPopAccountNameStr])));
@ -730,11 +730,11 @@ PRBool nsEudoraMac::BuildIMAPAccount( nsIMsgAccountManager *accMgr, nsCString **
nsresult rv = accMgr->FindServer( *(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), "imap", getter_AddRefs( in));
if (NS_FAILED( rv) || (in == nsnull)) {
// Create the incoming server and an account for it?
rv = accMgr->CreateIncomingServer( "imap", getter_AddRefs( in));
rv = accMgr->CreateIncomingServer( *(pStrs[kPopAccountNameStr]), *(pStrs[kPopServerStr]), "imap", getter_AddRefs( in));
if (NS_SUCCEEDED( rv) && in) {
rv = in->SetType( "imap");
rv = in->SetHostName( *(pStrs[kPopServerStr]));
rv = in->SetUsername( *(pStrs[kPopAccountNameStr]));
// rv = in->SetHostName( *(pStrs[kPopServerStr]));
// rv = in->SetUsername( *(pStrs[kPopAccountNameStr]));
IMPORT_LOG2( "Created IMAP server named: %s, userName: %s\n", (const char *)(*(pStrs[kPopServerStr])), (const char *)(*(pStrs[kPopAccountNameStr])));

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

@ -710,11 +710,11 @@ PRBool nsEudoraWin32::BuildPOPAccount( nsIMsgAccountManager *accMgr, const char
nsresult rv = accMgr->FindServer( userName, serverName, "pop3", getter_AddRefs( in));
if (NS_FAILED( rv) || (in == nsnull)) {
// Create the incoming server and an account for it?
rv = accMgr->CreateIncomingServer( "pop3", getter_AddRefs( in));
rv = accMgr->CreateIncomingServer( userName, serverName, "pop3", getter_AddRefs( in));
if (NS_SUCCEEDED( rv) && in) {
rv = in->SetType( "pop3");
rv = in->SetHostName( serverName);
rv = in->SetUsername( userName);
// rv = in->SetHostName( serverName);
// rv = in->SetUsername( userName);
IMPORT_LOG2( "Created POP3 server named: %s, userName: %s\n", (const char *)serverName, (const char *)userName);
@ -766,11 +766,11 @@ PRBool nsEudoraWin32::BuildIMAPAccount( nsIMsgAccountManager *accMgr, const char
nsresult rv = accMgr->FindServer( userName, serverName, "imap", getter_AddRefs( in));
if (NS_FAILED( rv) || (in == nsnull)) {
// Create the incoming server and an account for it?
rv = accMgr->CreateIncomingServer( "imap", getter_AddRefs( in));
rv = accMgr->CreateIncomingServer( userName, serverName, "imap", getter_AddRefs( in));
if (NS_SUCCEEDED( rv) && in) {
rv = in->SetType( "imap");
rv = in->SetHostName( serverName);
rv = in->SetUsername( userName);
// rv = in->SetHostName( serverName);
// rv = in->SetUsername( userName);
IMPORT_LOG2( "Created IMAP server named: %s, userName: %s\n", (const char *)serverName, (const char *)userName);

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

@ -319,11 +319,11 @@ PRBool OESettings::DoIMAPServer( nsIMsgAccountManager *pMgr, HKEY hKey, char *pS
nsresult rv = pMgr->FindServer( (const char *)pBytes, pServerName, "imap", getter_AddRefs( in));
if (NS_FAILED( rv) || (in == nsnull)) {
// Create the incoming server and an account for it?
rv = pMgr->CreateIncomingServer( "imap", getter_AddRefs( in));
rv = pMgr->CreateIncomingServer( (const char *)pBytes, pServerName, "imap", getter_AddRefs( in));
if (NS_SUCCEEDED( rv) && in) {
rv = in->SetType( "imap");
rv = in->SetHostName( pServerName);
rv = in->SetUsername( (char *)pBytes);
// rv = in->SetHostName( pServerName);
// rv = in->SetUsername( (char *)pBytes);
IMPORT_LOG2( "Created IMAP server named: %s, userName: %s\n", pServerName, (char *)pBytes);
@ -384,7 +384,7 @@ PRBool OESettings::DoPOP3Server( nsIMsgAccountManager *pMgr, HKEY hKey, char *pS
nsresult rv = pMgr->FindServer( (const char *)pBytes, pServerName, "pop3", getter_AddRefs( in));
if (NS_FAILED( rv) || (in == nsnull)) {
// Create the incoming server and an account for it?
rv = pMgr->CreateIncomingServer( "pop3", getter_AddRefs( in));
rv = pMgr->CreateIncomingServer( (const char *)pBytes, pServerName, "pop3", getter_AddRefs( in));
if (NS_SUCCEEDED( rv) && in) {
rv = in->SetType( "pop3");
rv = in->SetHostName( pServerName);

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

@ -269,11 +269,11 @@ PRBool OutlookSettings::DoIMAPServer( nsIMsgAccountManager *pMgr, HKEY hKey, cha
nsresult rv = pMgr->FindServer( (const char *)pBytes, pServerName, "imap", getter_AddRefs( in));
if (NS_FAILED( rv) || (in == nsnull)) {
// Create the incoming server and an account for it?
rv = pMgr->CreateIncomingServer( "imap", getter_AddRefs( in));
rv = pMgr->CreateIncomingServer( (const char *)pBytes, pServerName, "imap", getter_AddRefs( in));
if (NS_SUCCEEDED( rv) && in) {
rv = in->SetType( "imap");
rv = in->SetHostName( pServerName);
rv = in->SetUsername( (char *)pBytes);
// rv = in->SetHostName( pServerName);
// rv = in->SetUsername( (char *)pBytes);
IMPORT_LOG2( "Created IMAP server named: %s, userName: %s\n", pServerName, (char *)pBytes);
@ -334,11 +334,11 @@ PRBool OutlookSettings::DoPOP3Server( nsIMsgAccountManager *pMgr, HKEY hKey, cha
nsresult rv = pMgr->FindServer( (const char *)pBytes, pServerName, "pop3", getter_AddRefs( in));
if (NS_FAILED( rv) || (in == nsnull)) {
// Create the incoming server and an account for it?
rv = pMgr->CreateIncomingServer( "pop3", getter_AddRefs( in));
rv = pMgr->CreateIncomingServer( (const char *)pBytes, pServerName, "pop3", getter_AddRefs( in));
if (NS_SUCCEEDED( rv) && in) {
rv = in->SetType( "pop3");
rv = in->SetHostName( pServerName);
rv = in->SetUsername( (char *)pBytes);
// rv = in->SetHostName( pServerName);
// rv = in->SetUsername( (char *)pBytes);
IMPORT_LOG2( "Created POP3 server named: %s, userName: %s\n", pServerName, (char *)pBytes);

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

@ -27,266 +27,26 @@
#include "ImportDebug.h"
static NS_DEFINE_CID(kImportServiceCID, NS_IMPORTSERVICE_CID);
static NS_DEFINE_CID(kImportMimeEncodeCID, NS_IMPORTMIMEENCODE_CID);
extern NS_METHOD NS_NewImportService(nsISupports* aOuter, REFNSIID aIID, void **aResult);
extern nsresult NS_NewImportService(nsIImportService** aImportService);
extern nsresult NS_NewImportMimeEncode( nsIImportMimeEncode **aMimeEncode);
// Module implementation for the import service library
class nsImportServiceModule : public nsIModule
{
public:
nsImportServiceModule();
virtual ~nsImportServiceModule();
NS_DECL_ISUPPORTS
NS_DECL_NSIMODULE
protected:
nsresult Initialize();
void Shutdown();
PRBool mInitialized;
nsCOMPtr<nsIGenericFactory> mFactory;
};
//----------------------------------------------------------------------
// Functions used to create new instances of a given object by the
// generic factory.
#define MAKE_CTOR(_name) \
static NS_IMETHODIMP \
CreateNew##_name(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
{ \
if (!aResult) { \
return NS_ERROR_INVALID_POINTER; \
} \
if (aOuter) { \
*aResult = nsnull; \
return NS_ERROR_NO_AGGREGATION; \
} \
nsI##_name* inst; \
nsresult rv = NS_New##_name(&inst); \
if (NS_FAILED(rv)) { \
*aResult = nsnull; \
return rv; \
} \
rv = inst->QueryInterface(aIID, aResult); \
if (NS_FAILED(rv)) { \
*aResult = nsnull; \
} \
NS_RELEASE(inst); /* get rid of extra refcnt */ \
return rv; \
}
MAKE_CTOR(ImportService)
MAKE_CTOR(ImportMimeEncode)
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIModuleIID, NS_IMODULE_IID);
nsImportServiceModule::nsImportServiceModule()
: mInitialized(PR_FALSE)
{
NS_INIT_ISUPPORTS();
}
nsImportServiceModule::~nsImportServiceModule()
{
Shutdown();
}
NS_IMPL_ISUPPORTS(nsImportServiceModule, kIModuleIID)
// Perform our one-time intialization for this module
nsresult
nsImportServiceModule::Initialize()
{
if (mInitialized) {
return NS_OK;
}
mInitialized = PR_TRUE;
return NS_OK;
}
// Shutdown this module, releasing all of the module resources
void
nsImportServiceModule::Shutdown()
{
// Release the factory object
mFactory = nsnull;
}
// Create a factory object for creating instances of aClass.
NS_IMETHODIMP
nsImportServiceModule::GetClassObject(nsIComponentManager *aCompMgr,
const nsCID& aClass,
const nsIID& aIID,
void** r_classObj)
{
nsresult rv;
// Defensive programming: Initialize *r_classObj in case of error below
if (!r_classObj) {
return NS_ERROR_INVALID_POINTER;
}
*r_classObj = NULL;
// Do one-time-only initialization if necessary
if (!mInitialized) {
rv = Initialize();
if (NS_FAILED(rv)) {
// Initialization failed! yikes!
return rv;
}
}
// Choose the appropriate factory, based on the desired instance
// class type (aClass).
nsCOMPtr<nsIGenericFactory> fact;
if (aClass.Equals(kImportServiceCID)) {
if (!mFactory) {
// Create and save away the factory object for creating
// new instances of Sample. This way if we are called
// again for the factory, we won't need to create a new
// one.
rv = NS_NewGenericFactory(getter_AddRefs(mFactory),
CreateNewImportService);
}
fact = mFactory;
}
else {
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
#ifdef DEBUG
char* cs = aClass.ToString();
printf("+++ nsImportServiceModule: unable to create factory for %s\n", cs);
nsCRT::free(cs);
#endif
}
if (fact) {
rv = fact->QueryInterface(aIID, r_classObj);
}
return rv;
}
//----------------------------------------
struct Components {
const char* mDescription;
const nsID* mCID;
const char* mProgID;
static nsModuleComponentInfo components[] = {
{
"Import Service Component", NS_IMPORTSERVICE_CID,
"component://mozilla/import/import-service", NS_NewImportService
},
{
"Import Mime Encoder", NS_IMPORTMIMEENCODE_CID,
"component://mozilla/import/import-mimeencode", nsIImportMimeEncodeImpl::Create
}
};
// The list of components we register
static Components gComponents[] = {
{ "Import Service Component", &kImportServiceCID,
"component://mozilla/import/import-service", },
{ "Import Mime Encoder", &kImportMimeEncodeCID,
"component://mozilla/import/import-mimeencode"},
};
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]))
NS_IMETHODIMP
nsImportServiceModule::RegisterSelf(nsIComponentManager *aCompMgr,
nsIFileSpec* aPath,
const char* registryLocation,
const char* componentType)
{
nsresult rv = NS_OK;
#ifdef DEBUG
printf("*** Registering ImportService components\n");
#endif
Components* cp = gComponents;
Components* end = cp + NUM_COMPONENTS;
while (cp < end) {
rv = aCompMgr->RegisterComponentSpec(*cp->mCID, cp->mDescription,
cp->mProgID, aPath, PR_TRUE,
PR_TRUE);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsImportServiceModule: unable to register %s component => %x\n",
cp->mDescription, rv);
#endif
break;
}
cp++;
}
return rv;
}
NS_IMETHODIMP
nsImportServiceModule::UnregisterSelf(nsIComponentManager* aCompMgr,
nsIFileSpec* aPath,
const char* registryLocation)
{
#ifdef DEBUG
printf("*** Unregistering ImportService components\n");
#endif
Components* cp = gComponents;
Components* end = cp + NUM_COMPONENTS;
while (cp < end) {
nsresult rv = aCompMgr->UnregisterComponentSpec(*cp->mCID, aPath);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("nsImportServiceModule: unable to unregister %s component => %x\n",
cp->mDescription, rv);
#endif
}
cp++;
}
return NS_OK;
}
NS_IMETHODIMP
nsImportServiceModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
{
if (!okToUnload) {
return NS_ERROR_INVALID_POINTER;
}
*okToUnload = PR_FALSE;
return NS_ERROR_FAILURE;
}
//----------------------------------------------------------------------
static nsImportServiceModule *gModule = NULL;
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
nsIFileSpec* location,
nsIModule** return_cobj)
{
nsresult rv = NS_OK;
NS_ASSERTION(return_cobj, "Null argument");
NS_ASSERTION(gModule == NULL, "nsImportServiceModule: Module already created.");
// Create an initialize the layout module instance
nsImportServiceModule *m = new nsImportServiceModule();
if (!m) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Increase refcnt and store away nsIModule interface to m in return_cobj
rv = m->QueryInterface(nsIModule::GetIID(), (void**)return_cobj);
if (NS_FAILED(rv)) {
delete m;
m = nsnull;
}
gModule = m; // WARNING: Weak Reference
return rv;
}
NS_IMPL_NSGETMODULE( "nsImportServiceModule", components)

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

@ -948,7 +948,7 @@ PRBool nsImportGenericMail::GetAccount( nsIMsgFolder **ppFolder)
return( PR_FALSE);
}
rv = accMgr->CreateIncomingServer( "none", getter_AddRefs( server));
rv = accMgr->CreateIncomingServer( "import", hostName, "none", getter_AddRefs( server));
if (NS_FAILED( rv)) {
IMPORT_LOG0( "*** Failed to create a 'none' incoming server\n");
return( PR_FALSE);
@ -959,8 +959,8 @@ PRBool nsImportGenericMail::GetAccount( nsIMsgFolder **ppFolder)
GetUniquePrettyName( accMgr, prettyName);
server->SetPrettyName( (PRUnichar *) prettyName.GetUnicode());
server->SetHostName( hostName);
server->SetUsername( "import");
// server->SetHostName( hostName);
// server->SetUsername( "import");
// create a new account with the server and identity.

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

@ -455,8 +455,3 @@ NS_METHOD nsIImportMimeEncodeImpl::Initialize(nsIFileSpec *inFile, nsIFileSpec *
return( NS_OK);
}
nsresult NS_NewImportMimeEncode( nsIImportMimeEncode **aEncoder)
{
return( nsIImportMimeEncodeImpl::Create( nsnull, nsIImportMimeEncode::GetIID(), (void **)aEncoder));
}

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

@ -163,27 +163,34 @@ private:
};
////////////////////////////////////////////////////////////////////////
nsresult NS_NewImportService(nsIImportService** aImportService);
nsresult NS_NewImportService(nsIImportService** aImportService)
NS_IMETHODIMP NS_NewImportService( nsISupports* aOuter, REFNSIID aIID, void **aResult)
{
NS_PRECONDITION(aImportService != nsnull, "null ptr");
if (! aImportService)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return( NS_ERROR_NULL_POINTER);
if (aOuter) {
*aResult = nsnull;
return( NS_ERROR_NO_AGGREGATION);
}
if (!gImportService) {
gImportService = new nsImportService();
if (! gImportService)
return NS_ERROR_OUT_OF_MEMORY;
return( NS_ERROR_OUT_OF_MEMORY);
}
NS_ADDREF( gImportService);
*aImportService = gImportService;
return NS_OK;
nsresult rv = gImportService->QueryInterface(aIID, aResult);
if (NS_FAILED(rv)) {
*aResult = nsnull;
}
NS_RELEASE( gImportService);
return( rv);
}
////////////////////////////////////////////////////////////////////////