Commit ff1de194 authored by jefft%netscape.com's avatar jefft%netscape.com
Browse files

getting imap root folder directory from prefs instead of hard coded string

parent ba4f36c0
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -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;