зеркало из https://github.com/mozilla/gecko-dev.git
changes to support the new "none" incoming server type.
divorce "pop3" from local mail. (more to be done here). general code clean up. fix #12873 and #12801
This commit is contained in:
Родитель
251f18a5f9
Коммит
e40911db58
|
@ -42,7 +42,7 @@ interface nsIMsgIncomingServer : nsISupports {
|
|||
/* userid to log into the server */
|
||||
attribute string username;
|
||||
|
||||
/* server type, i.e. "pop3", "imap", "nntp", etc */
|
||||
/* server type, i.e. "pop3", "imap", "nntp", "none", etc */
|
||||
attribute string type;
|
||||
|
||||
/* should we remember the password? */
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nsIMsgMailSession.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
#include "nsIPop3IncomingServer.h"
|
||||
#include "nsINoIncomingServer.h"
|
||||
#include "nsIMsgMessageService.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "nsIImapIncomingServer.h"
|
||||
// this should eventually be moved to the nntp server for upgrading
|
||||
#include "nsINntpIncomingServer.h"
|
||||
// this should eventually be moved to the no server for upgrading
|
||||
#include "nsINoIncomingServer.h"
|
||||
|
||||
#define BUF_STR_LEN 1024
|
||||
|
||||
|
@ -86,6 +88,9 @@ static NS_DEFINE_CID(kCNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
|
|||
#define DEBUG_CLEAR_PREF 1
|
||||
#endif
|
||||
|
||||
// TODO: this needs to be put into a string bundle
|
||||
#define LOCAL_MAIL_FAKE_HOST_NAME "Local Mail"
|
||||
|
||||
// use this to search for all servers with the given hostname/iid and
|
||||
// put them in "servers"
|
||||
typedef struct _findServerEntry {
|
||||
|
@ -218,7 +223,9 @@ private:
|
|||
nsresult MigrateImapAccount(nsIMsgIdentity *identity, const char *hostname, PRInt32 accountNum);
|
||||
|
||||
PRInt32 MigratePopAccounts(nsIMsgIdentity *identity);
|
||||
|
||||
|
||||
PRInt32 MigrateLocalMailAccounts(nsIMsgIdentity *identity, PRInt32 baseAccountNum);
|
||||
|
||||
PRInt32 MigrateNewsAccounts(nsIMsgIdentity *identity, PRInt32 baseAccountNum);
|
||||
nsresult MigrateNewsAccount(nsIMsgIdentity *identity, const char *hostname, const char *newsrcfile, PRInt32 accountNum);
|
||||
|
||||
|
@ -422,7 +429,7 @@ nsMsgAccountManager::GetIncomingServer(const char* key,
|
|||
const char *serverTypePref =
|
||||
PR_smprintf("mail.server.%s.type", key);
|
||||
|
||||
// serverType is the short server type, like "pop3", "imap", etc
|
||||
// serverType is the short server type, like "pop3","imap","nntp","none", etc
|
||||
nsXPIDLCString serverType;
|
||||
rv = m_prefs->CopyCharPref(serverTypePref, getter_Copies(serverType));
|
||||
|
||||
|
@ -1144,6 +1151,9 @@ nsMsgAccountManager::upgradePrefs()
|
|||
}
|
||||
else if (oldMailType == 1) { // IMAP
|
||||
numAccounts += MigrateImapAccounts(identity);
|
||||
// if they had IMAP, they also had "Local Mail"
|
||||
// we need to migrate that, too.
|
||||
numAccounts += MigrateLocalMailAccounts(identity, numAccounts);
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG_ACCOUNTMANAGER
|
||||
|
@ -1190,6 +1200,126 @@ nsMsgAccountManager::upgradePrefs()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsMsgAccountManager::MigrateLocalMailAccounts(nsIMsgIdentity *identity, PRInt32 baseAccountNum)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 accountNum = baseAccountNum + 1;
|
||||
|
||||
if (baseAccountNum < 1) return NS_ERROR_FAILURE;
|
||||
|
||||
//
|
||||
// create the account
|
||||
//
|
||||
char accountStr[BUF_STR_LEN];
|
||||
PR_snprintf(accountStr,BUF_STR_LEN,"account%d",accountNum);
|
||||
#ifdef DEBUG_ACCOUNTMANAGER
|
||||
printf("account str = %s\n",accountStr);
|
||||
#endif
|
||||
nsCOMPtr<nsIMsgAccount> account;
|
||||
rv = createKeyedAccount(accountStr, getter_AddRefs(account));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
//
|
||||
// create the server
|
||||
//
|
||||
char serverStr[BUF_STR_LEN];
|
||||
PR_snprintf(serverStr,BUF_STR_LEN,"server%d",accountNum);
|
||||
#ifdef DEBUG_ACCOUNTMANAGER
|
||||
printf("server str = %s\n",serverStr);
|
||||
#endif
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
rv = createKeyedServer(serverStr, "none", getter_AddRefs(server));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
//
|
||||
// create the identity
|
||||
//
|
||||
char identityStr[BUF_STR_LEN];
|
||||
PR_snprintf(identityStr,BUF_STR_LEN,"identity%d",accountNum);
|
||||
|
||||
nsCOMPtr<nsIMsgIdentity> copied_identity;
|
||||
rv = createKeyedIdentity(identityStr, getter_AddRefs(copied_identity));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = CopyIdentity(identity,copied_identity);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// the server needs a username, but we never plan to use it.
|
||||
server->SetUsername("nobody");
|
||||
|
||||
//
|
||||
// hook them together
|
||||
//
|
||||
account->SetIncomingServer(server);
|
||||
account->AddIdentity(copied_identity);
|
||||
|
||||
// now upgrade all the prefs
|
||||
nsFileSpec profileDir;
|
||||
|
||||
NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &rv);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = profile->GetCurrentProfileDir(&profileDir);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
// some of this ought to be moved out into the NNTP implementation
|
||||
nsCOMPtr<nsINoIncomingServer> noServer;
|
||||
noServer = do_QueryInterface(server, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// create the directory structure for old 4.x "Local Mail"
|
||||
// under <profile dir>/Mail/Local Mail
|
||||
|
||||
// TODO: heed "mail.directory"?
|
||||
// it may not always be under the profile directory
|
||||
nsCOMPtr <nsIFileSpec> mailDir;
|
||||
nsFileSpec dir(profileDir);
|
||||
PRBool dirExists;
|
||||
|
||||
// turn profileDir into the mail dir.
|
||||
dir += "Mail";
|
||||
if (!dir.Exists()) {
|
||||
dir.CreateDir();
|
||||
}
|
||||
dir += LOCAL_MAIL_FAKE_HOST_NAME;
|
||||
|
||||
rv = NS_NewFileSpecWithSpec(dir, getter_AddRefs(mailDir));
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
rv = mailDir->Exists(&dirExists);
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
if (!dirExists) {
|
||||
mailDir->CreateDir();
|
||||
}
|
||||
|
||||
char *str = nsnull;
|
||||
mailDir->GetNativePath(&str);
|
||||
|
||||
if (str && *str) {
|
||||
server->SetLocalPath(str);
|
||||
PR_FREEIF(str);
|
||||
str = nsnull;
|
||||
}
|
||||
|
||||
rv = mailDir->Exists(&dirExists);
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
if (!dirExists) {
|
||||
mailDir->CreateDir();
|
||||
}
|
||||
|
||||
// "none" is the type we use for migrate Local Mail
|
||||
server->SetType("none");
|
||||
server->SetHostName(LOCAL_MAIL_FAKE_HOST_NAME);
|
||||
|
||||
// we only migrated one account so return 1
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsMsgAccountManager::MigratePopAccounts(nsIMsgIdentity *identity)
|
||||
{
|
||||
|
@ -1342,7 +1472,7 @@ nsMsgAccountManager::MigratePopAccounts(nsIMsgIdentity *identity)
|
|||
}
|
||||
|
||||
// create the files for the special folders.
|
||||
// this needs to be i18N.
|
||||
// TODO: this needs to be internationalized.
|
||||
rv = createSpecialFile(dir,"Inbox");
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
|
@ -1358,7 +1488,7 @@ nsMsgAccountManager::MigratePopAccounts(nsIMsgIdentity *identity)
|
|||
rv = createSpecialFile(dir,"Templates");
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
rv = createSpecialFile(dir,"Unsent Message");
|
||||
rv = createSpecialFile(dir,"Unsent Messages");
|
||||
if (NS_FAILED(rv)) return 0;
|
||||
|
||||
rv = m_prefs->GetBoolPref(PREF_4X_MAIL_LEAVE_ON_SERVER, &oldbool);
|
||||
|
|
|
@ -47,6 +47,17 @@
|
|||
0xd2876e51, 0xe62c, 0x11d2, \
|
||||
{0xb7, 0xfc, 0x0, 0x80, 0x5f, 0x5, 0xff, 0xa5 }}
|
||||
|
||||
//
|
||||
// nsNoIncomingServer
|
||||
//
|
||||
#define NS_NOINCOMINGSERVER_PROGID \
|
||||
"component://netscape/messenger/server&type=none"
|
||||
|
||||
#define NS_NOINCOMINGSERVER_CID \
|
||||
{ /* {ca5ffe7e-5f47-11d3-9a51-004005263078} */ \
|
||||
0xca5ffe7e, 0x5f47, 0x11d3, \
|
||||
{0x9a, 0x51, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78}}
|
||||
|
||||
//
|
||||
// nsMailboxMessageResource
|
||||
//
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "nsParseMailbox.h"
|
||||
#include "nsPop3Service.h"
|
||||
#include "nsPop3IncomingServer.h"
|
||||
#include "nsNoIncomingServer.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsLocalMessage.h"
|
||||
|
||||
|
@ -43,6 +44,7 @@ static NS_DEFINE_CID(kMailboxMessageResourceCID, NS_MAILBOXMESSAGERESOURCE_CID);
|
|||
static NS_DEFINE_CID(kPop3ServiceCID, NS_POP3SERVICE_CID);
|
||||
static NS_DEFINE_CID(kPop3UrlCID, NS_POP3URL_CID);
|
||||
static NS_DEFINE_CID(kPop3IncomingServerCID, NS_POP3INCOMINGSERVER_CID);
|
||||
static NS_DEFINE_CID(kNoIncomingServerCID, NS_NOINCOMINGSERVER_CID);
|
||||
static NS_DEFINE_CID(kParseMailMsgStateCID, NS_PARSEMAILMSGSTATE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -195,6 +197,8 @@ nsresult nsMsgLocalFactory::CreateInstance(nsISupports * /* aOuter */, const nsI
|
|||
rv = NS_NewParseMailMessageState(aIID, aResult);
|
||||
else if (mClassID.Equals(kPop3IncomingServerCID))
|
||||
rv = NS_NewPop3IncomingServer(nsCOMTypeInfo<nsISupports>::GetIID(), aResult);
|
||||
else if (mClassID.Equals(kNoIncomingServerCID))
|
||||
rv = NS_NewNoIncomingServer(nsCOMTypeInfo<nsISupports>::GetIID(), aResult);
|
||||
|
||||
else
|
||||
rv = NS_NOINTERFACE;
|
||||
|
@ -320,9 +324,15 @@ NSRegisterSelf(nsISupports* aServMgr, const char* path)
|
|||
"Pop3 Incoming Server",
|
||||
NS_POP3INCOMINGSERVER_PROGID,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) finalResult = rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kNoIncomingServerCID,
|
||||
"No Incoming Server",
|
||||
NS_NOINCOMINGSERVER_PROGID,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv)) finalResult = rv;
|
||||
rv = compMgr->RegisterComponent(kParseMailMsgStateCID,
|
||||
rv = compMgr->RegisterComponent(kParseMailMsgStateCID,
|
||||
"Parse MailMessage State",
|
||||
NS_PARSEMAILMSGSTATE_PROGID,
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
|
@ -366,6 +376,9 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* path)
|
|||
rv = compMgr->UnregisterComponent(kPop3IncomingServerCID, path);
|
||||
if (NS_FAILED(rv)) finalResult = rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kNoIncomingServerCID, path);
|
||||
if (NS_FAILED(rv)) finalResult = rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kParseMailMsgStateCID, path);
|
||||
if (NS_FAILED(rv)) finalResult = rv;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ XPIDLSRCS = \
|
|||
nsIPop3URL.idl \
|
||||
nsIMailboxUrl.idl \
|
||||
nsIMsgParseMailMsgState.idl \
|
||||
nsINoIncomingServer.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
|
|
@ -29,6 +29,7 @@ XPIDLSRCS = \
|
|||
.\nsIPop3URL.idl \
|
||||
.\nsIMailboxUrl.idl \
|
||||
.\nsIMsgParseMailMsgState.idl \
|
||||
.\nsINoIncomingServer.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
|
|
@ -27,4 +27,5 @@ nsPop3Service.h
|
|||
nsPop3IncomingServer.h
|
||||
nsLocalMessage.h
|
||||
nsLocalStringBundle.h
|
||||
nsNoIncomingServer.h
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ CPPSRCS = \
|
|||
nsLocalUtils.cpp \
|
||||
nsLocalUndoTxn.cpp \
|
||||
nsLocalStringBundle.cpp \
|
||||
nsNoIncomingServer.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS= \
|
||||
|
@ -54,6 +55,7 @@ EXPORTS= \
|
|||
nsPop3IncomingServer.h \
|
||||
nsLocalMessage.h \
|
||||
nsLocalStringBundle.h \
|
||||
nsNoIncomingServer.h \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
|
|
@ -37,6 +37,7 @@ EXPORTS= \
|
|||
nsLocalMailFolder.h \
|
||||
nsLocalUtils.h \
|
||||
nsLocalStringBundle.h \
|
||||
nsNoIncomingServer.h \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
|
@ -59,6 +60,7 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsLocalUtils.obj \
|
||||
.\$(OBJDIR)\nsLocalUndoTxn.obj \
|
||||
.\$(OBJDIR)\nsLocalStringBundle.obj \
|
||||
.\$(OBJDIR)\nsNoIncomingServer.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsMsgUtils.h"
|
||||
#include "nsLocalUtils.h"
|
||||
#include "nsIPop3IncomingServer.h"
|
||||
#include "nsINoIncomingServer.h"
|
||||
#include "nsIPop3Service.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
|
@ -140,6 +141,23 @@ NS_IMETHODIMP nsMsgLocalMailFolder::QueryInterface(REFNSIID aIID, void** aInstan
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static PRBool
|
||||
nsStringEndsWith(nsString& name, const char *ending)
|
||||
{
|
||||
if (!ending) return PR_FALSE;
|
||||
|
||||
PRInt32 len = name.Length();
|
||||
if (len == 0) return PR_FALSE;
|
||||
|
||||
PRInt32 endingLen = PL_strlen(ending);
|
||||
if (len > endingLen && name.RFind(ending, PR_TRUE) == len - endingLen) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static PRBool
|
||||
nsShouldIgnoreFile(nsString& name)
|
||||
{
|
||||
|
@ -150,21 +168,20 @@ nsShouldIgnoreFile(nsString& name)
|
|||
if (name.EqualsIgnoreCase("rules.dat"))
|
||||
return PR_TRUE;
|
||||
|
||||
PRInt32 len = name.Length();
|
||||
|
||||
// don't add summary files to the list of folders;
|
||||
// don't add popstate files to the list either, or rules (sort.dat).
|
||||
if ((len > 4 && name.RFind(".snm", PR_TRUE) == len - 4) ||
|
||||
if (nsStringEndsWith(name, ".snm") ||
|
||||
name.EqualsIgnoreCase("popstate.dat") ||
|
||||
name.EqualsIgnoreCase("sort.dat") ||
|
||||
name.EqualsIgnoreCase("mailfilt.log") ||
|
||||
name.EqualsIgnoreCase("filters.js") ||
|
||||
name.RFind(".toc", PR_TRUE) == len - 4)
|
||||
nsStringEndsWith(name, ".toc"))
|
||||
return PR_TRUE;
|
||||
|
||||
if ((len > 4 && name.RFind(".sbd", PR_TRUE) == len - 4) ||
|
||||
(len > 4 && name.RFind(".msf", PR_TRUE) == len - 4))
|
||||
if (nsStringEndsWith(name,".sbd") || nsStringEndsWith(name,".msf"))
|
||||
return PR_TRUE;
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -364,22 +381,35 @@ nsMsgLocalMailFolder::GetSubFolders(nsIEnumerator* *result)
|
|||
SetFlag(newFlags);
|
||||
PRBool isServer;
|
||||
rv = GetIsServer(&isServer);
|
||||
const char *type = GetIncomingServerType();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && isServer)
|
||||
{
|
||||
// make sure we have all the default mailbox created
|
||||
nsFileSpec fileSpec;
|
||||
fileSpec = path + "Inbox";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Trash";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Sent";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Drafts";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Templates";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Unsent Messages";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
// TODO: move this into the IncomingServer
|
||||
if (PL_strcmp(type, "pop3") == 0) {
|
||||
// make sure we have all the default mailbox created
|
||||
nsFileSpec fileSpec;
|
||||
fileSpec = path + "Inbox";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Trash";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Sent";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Drafts";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Templates";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
fileSpec = path + "Unsent Messages";
|
||||
if (!fileSpec.Exists()) { nsOutputFileStream outStream(fileSpec); }
|
||||
}
|
||||
else if (PL_strcmp(type, "none") == 0) {
|
||||
#ifdef DEBUG_seth
|
||||
printf("don't create any special folders for type=none\n");
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(0,"error, don't know about this server type yet.\n");
|
||||
}
|
||||
}
|
||||
rv = CreateSubFolders(path);
|
||||
}
|
||||
|
@ -786,8 +816,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Adopt(nsIMsgFolder *srcFolder, PRUint32 *out
|
|||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::GetPrettyName(PRUnichar ** prettyName)
|
||||
{
|
||||
return nsMsgFolder::GetPrettyName(prettyName);
|
||||
|
||||
return nsMsgFolder::GetPrettyName(prettyName);
|
||||
}
|
||||
|
||||
nsresult nsMsgLocalMailFolder::GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsIMsgDatabase **db)
|
||||
|
@ -1491,23 +1520,36 @@ nsMsgLocalMailFolder::CreateMessageFromMsgDBHdr(nsIMsgDBHdr *msgDBHdr,
|
|||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::GetNewMessages()
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_WITH_SERVICE(nsIPop3Service, pop3Service, kCPop3ServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// TODO: move this into the IncomingServer
|
||||
const char *type = GetIncomingServerType();
|
||||
if (PL_strcmp(type, "pop3") == 0) {
|
||||
NS_WITH_SERVICE(nsIPop3Service, pop3Service, kCPop3ServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
rv = GetServer(getter_AddRefs(server));
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
rv = GetServer(getter_AddRefs(server));
|
||||
|
||||
nsCOMPtr<nsIPop3IncomingServer> popServer;
|
||||
rv = server->QueryInterface(nsIPop3IncomingServer::GetIID(),
|
||||
(void **)&popServer);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = pop3Service->GetNewMail(nsnull,popServer,nsnull);
|
||||
nsCOMPtr<nsIPop3IncomingServer> popServer;
|
||||
rv = server->QueryInterface(nsIPop3IncomingServer::GetIID(),
|
||||
(void **)&popServer);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = pop3Service->GetNewMail(nsnull,popServer,nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return rv;
|
||||
else if (PL_strcmp(type, "none") == 0) {
|
||||
#ifdef DEBUG_seth
|
||||
printf("none means don't do anything\n");
|
||||
#endif
|
||||
rv = NS_OK;
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(0,"ERROR: how do we get new messages for this incoming server type");
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
if (NS_FAILED(rv)) printf("GetNewMessages failed\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1782,3 +1824,29 @@ nsresult nsMsgLocalMailFolder::CopyMessageTo(nsIMessage *message,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// TODO: once we move certain code into the IncomingServer (search for TODO)
|
||||
// this method will go away.
|
||||
const char *
|
||||
nsMsgLocalMailFolder::GetIncomingServerType()
|
||||
{
|
||||
nsXPIDLCString type;
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
nsresult rv = nsLocalURI2Server(mURI,getter_AddRefs(server));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsLocalURI2Server() failed");
|
||||
if (NS_FAILED(rv)) return "";
|
||||
|
||||
rv = server->GetType(getter_Copies(type));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetType() failed");
|
||||
if (NS_FAILED(rv)) return "";
|
||||
|
||||
if (PL_strcmp(type, "pop3") == 0) {
|
||||
return "pop3";
|
||||
}
|
||||
else if (PL_strcmp(type, "none") == 0) {
|
||||
return "none";
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(0,"server type not known yet.\n");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ protected:
|
|||
nsresult CopyMessageTo(nsIMessage *message, nsIMsgFolder *dstFolder,
|
||||
PRBool isMove);
|
||||
|
||||
virtual const char* GetIncomingServerType() {return "pop3";}
|
||||
virtual const char* GetIncomingServerType();
|
||||
nsresult SetTransactionManager(nsITransactionManager* txnMgr);
|
||||
nsresult InitCopyState(nsISupports* aSupport, nsISupportsArray* messages,
|
||||
PRBool isMove, nsIMsgCopyServiceListener* listener);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "nsIMsgMailSession.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
#include "nsIPop3IncomingServer.h"
|
||||
#include "nsINoIncomingServer.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
|
||||
#include "nsMsgUtils.h"
|
||||
|
@ -49,23 +50,36 @@ nsGetMailboxServer(const char *username, const char *hostname, nsIMsgIncomingSer
|
|||
rv = session->GetAccountManager(getter_AddRefs(accountManager));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// find all pop hosts matching the given hostname
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
// find all local mail "no servers" matching the given hostname
|
||||
nsCOMPtr<nsIMsgIncomingServer> none_server;
|
||||
rv = accountManager->FindServer(username,
|
||||
hostname,
|
||||
"none",
|
||||
getter_AddRefs(none_server));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aResult = none_server;
|
||||
NS_ADDREF(*aResult);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// if that fails, look for the pop hosts matching the given hostname
|
||||
nsCOMPtr<nsIMsgIncomingServer> pop3_server;
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = accountManager->FindServer(username,
|
||||
hostname,
|
||||
"pop3",
|
||||
getter_AddRefs(server));
|
||||
getter_AddRefs(pop3_server));
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aResult = pop3_server;
|
||||
NS_ADDREF(*aResult);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*aResult = server;
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
nsresult
|
||||
nsLocalURI2Server(const char* uriStr,
|
||||
nsIMsgIncomingServer ** aResult)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
|
||||
static const char kMailboxRootURI[] = "mailbox:/";
|
||||
static const char kMailboxMessageRootURI[] = "mailbox_message:/";
|
||||
|
@ -28,12 +29,18 @@ static const char kMailboxMessageRootURI[] = "mailbox_message:/";
|
|||
nsresult
|
||||
nsLocalURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult);
|
||||
|
||||
nsresult
|
||||
nsLocalURI2Server(const char* uriStr, nsIMsgIncomingServer ** aResult);
|
||||
|
||||
nsresult
|
||||
nsParseLocalMessageURI(const char* uri, nsCString& folderURI, PRUint32 *key);
|
||||
|
||||
nsresult nsBuildLocalMessageURI(const char* baseURI, PRUint32 key, char** uri);
|
||||
nsresult
|
||||
nsBuildLocalMessageURI(const char* baseURI, PRUint32 key, char** uri);
|
||||
|
||||
nsresult
|
||||
nsGetMailboxHostName(const char *rootURI, const char *uriStr, char **hostName);
|
||||
|
||||
nsresult nsGetMailboxHostName(const char *rootURI, const char *uriStr, char **hostName);
|
||||
nsresult
|
||||
nsGetMailboxUserName(const char *rootURI, const char *uriStr, char **userName);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче