From 1006885608fa543fa074db7dfe11dfca75bd7e4a Mon Sep 17 00:00:00 2001 From: "jefft%netscape.com" Date: Fri, 23 Apr 1999 13:55:53 +0000 Subject: [PATCH] getting imap root folder directory from prefs instead of hard coded string git-svn-id: svn://10.0.0.236/trunk@28828 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/base/util/nsMsgFolder.cpp | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/mozilla/mailnews/base/util/nsMsgFolder.cpp b/mozilla/mailnews/base/util/nsMsgFolder.cpp index 0718a67b517..e48c0cb05be 100644 --- a/mozilla/mailnews/base/util/nsMsgFolder.cpp +++ b/mozilla/mailnews/base/util/nsMsgFolder.cpp @@ -36,6 +36,7 @@ #include "nsIMsgIncomingServer.h" #include "nsIPop3IncomingServer.h" #include "nsINntpIncomingServer.h" +#include "nsIImapIncomingServer.h" static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); @@ -1483,7 +1484,7 @@ nsresult nsMsgFolder::NotifyItemDeleted(nsISupports *item) static char *gMailboxRoot = nsnull; static char *gNewsRoot = nsnull; -static const char *gImapRoot = nsnull; +static char *gImapRoot = nsnull; nsresult nsGetNewsRoot(nsFileSpec &result) @@ -1528,7 +1529,30 @@ nsGetImapRoot(nsFileSpec &result) // temporary stuff. for now - should get everything from the mail session if (gImapRoot == nsnull) { - gImapRoot = PL_strdup("/tmp"); + nsIMsgMailSession *session; + rv = nsServiceManager::GetService(kMsgMailSessionCID, + nsIMsgMailSession::GetIID(), + (nsISupports **)&session); + + if (NS_SUCCEEDED(rv)) { + nsIMsgIncomingServer *server; + rv = session->GetCurrentServer(&server); + if (NS_FAILED(rv)) printf("nsGetImapRoot: Couldn't get current server\n"); + if (NS_SUCCEEDED(rv)) { + nsIImapIncomingServer *imapServer; + rv = server->QueryInterface(nsIImapIncomingServer::GetIID(), + (void **)&imapServer); + if (NS_FAILED(rv)) printf("nsGetImapRoot: Couldn't get imap server\n"); + if (NS_SUCCEEDED(rv)) { + rv = imapServer->GetRootFolderPath(&gImapRoot); + if (NS_FAILED(rv)) printf("nsGetImapRoot: Couldn't get root\n"); + NS_RELEASE(imapServer); + } + NS_RELEASE(server); + + } + nsServiceManager::ReleaseService(kMsgMailSessionCID, session); + } } result = gImapRoot; return rv;