From b0b421d1852428eaefe5fb881a51a9c7c8b67657 Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Wed, 10 May 2000 06:44:06 +0000 Subject: [PATCH] add second parameter to nsISmtpService::FindServer for the datasource git-svn-id: svn://10.0.0.236/trunk@69008 18797224-902f-48f8-a5cc-f745e15eee43 --- .../compose/public/nsISmtpService.idl | 2 +- .../mailnews/compose/src/nsSmtpService.cpp | 20 ++++++++++++++----- .../mailnews/import/oexpress/nsOESettings.cpp | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/mozilla/mailnews/compose/public/nsISmtpService.idl b/mozilla/mailnews/compose/public/nsISmtpService.idl index e20922fc9d2..9d65dc7ca4e 100644 --- a/mozilla/mailnews/compose/public/nsISmtpService.idl +++ b/mozilla/mailnews/compose/public/nsISmtpService.idl @@ -82,7 +82,7 @@ interface nsISmtpService : nsISupports { * @param hostname the hostname of the server * @returns null if no server is found */ - nsISmtpServer findServer(in string hostname); + nsISmtpServer findServer(in string username, in string hostname); /** * look up the server with the given key diff --git a/mozilla/mailnews/compose/src/nsSmtpService.cpp b/mozilla/mailnews/compose/src/nsSmtpService.cpp index fba4b11d25b..508433df30c 100644 --- a/mozilla/mailnews/compose/src/nsSmtpService.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpService.cpp @@ -46,6 +46,7 @@ typedef struct _findServerByKeyEntry { typedef struct _findServerByHostnameEntry { const char *hostname; + const char *username; nsISmtpServer *server; } findServerByHostnameEntry; @@ -836,8 +837,15 @@ nsSmtpService::findServerByHostname(nsISupports *element, void *aData) rv = server->GetHostname(getter_Copies(hostname)); if (NS_FAILED(rv)) return PR_TRUE; - if (((const char*)hostname) && - nsCRT::strcmp(hostname, entry->hostname) == 0) { + nsXPIDLCString username; + rv = server->GetUsername(getter_Copies(username)); + if (NS_FAILED(rv)) return PR_TRUE; + + PRBool checkHostname = PL_strcmp(entry->hostname, ""); + PRBool checkUsername = PL_strcmp(entry->username, ""); + + if ((!checkHostname || (PL_strcasecmp(entry->hostname, hostname)==0)) && + (!checkUsername || (PL_strcmp(entry->username, username)==0))) { entry->server = server; return PR_FALSE; // stop when found } @@ -845,13 +853,15 @@ nsSmtpService::findServerByHostname(nsISupports *element, void *aData) } NS_IMETHODIMP -nsSmtpService::FindServer(const char *hostname, nsISmtpServer ** aResult) +nsSmtpService::FindServer(const char *aUsername, + const char *aHostname, nsISmtpServer ** aResult) { - if (!aResult) return NS_ERROR_NULL_POINTER; + NS_ENSURE_ARG_POINTER(aResult); findServerByHostnameEntry entry; entry.server=nsnull; - entry.hostname = hostname; + entry.hostname = aHostname; + entry.username = aUsername; mSmtpServers->EnumerateForwards(findServerByHostname, (void *)&entry); diff --git a/mozilla/mailnews/import/oexpress/nsOESettings.cpp b/mozilla/mailnews/import/oexpress/nsOESettings.cpp index 6cd91682004..88015512088 100644 --- a/mozilla/mailnews/import/oexpress/nsOESettings.cpp +++ b/mozilla/mailnews/import/oexpress/nsOESettings.cpp @@ -528,7 +528,7 @@ void OESettings::SetSmtpServer( nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, if (NS_SUCCEEDED(rv) && smtpService) { nsCOMPtr foundServer; - rv = smtpService->FindServer( pServer, getter_AddRefs( foundServer)); + rv = smtpService->FindServer( pUser, pServer, getter_AddRefs( foundServer)); if (NS_SUCCEEDED( rv) && foundServer) { IMPORT_LOG1( "SMTP server already exists: %s\n", pServer); return;