From 29557d33cce342b7d4a9406ee7a9fce857bdf8ba Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Mon, 13 Sep 1999 23:04:24 +0000 Subject: [PATCH] implement the new nsIMsgProtocolInfo in nsPop3Service git-svn-id: svn://10.0.0.236/trunk@47198 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/local/src/nsPop3Service.cpp | 55 +++++++++++++------- mozilla/mailnews/local/src/nsPop3Service.h | 6 ++- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/mozilla/mailnews/local/src/nsPop3Service.cpp b/mozilla/mailnews/local/src/nsPop3Service.cpp index 0b05f8e9f04..22ff0183e42 100644 --- a/mozilla/mailnews/local/src/nsPop3Service.cpp +++ b/mozilla/mailnews/local/src/nsPop3Service.cpp @@ -22,6 +22,10 @@ #include "nsIMsgIncomingServer.h" #include "nsIPop3IncomingServer.h" #include "nsIMsgMailSession.h" + +#include "nsIProfile.h" +#include "nsIPref.h" + #include "nsPop3URL.h" #include "nsPop3Sink.h" #include "nsPop3Protocol.h" @@ -32,7 +36,8 @@ #define POP3_PORT 110 // The IANA port for Pop3 -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); +static NS_DEFINE_CID(kProfileCID, NS_PROFILE_CID); static NS_DEFINE_CID(kPop3UrlCID, NS_POP3URL_CID); static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID); @@ -46,25 +51,10 @@ nsPop3Service::~nsPop3Service() NS_IMPL_THREADSAFE_ADDREF(nsPop3Service); NS_IMPL_THREADSAFE_RELEASE(nsPop3Service); - -nsresult nsPop3Service::QueryInterface(const nsIID &aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) - return NS_ERROR_NULL_POINTER; - if (aIID.Equals(NS_GET_IID(nsIPop3Service)) || aIID.Equals(NS_GET_IID(nsISupports))) - { - *aInstancePtr = (void*) ((nsIPop3Service*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsIProtocolHandler))) - { - *aInstancePtr = (void *) ((nsIProtocolHandler*) this); - NS_ADDREF_THIS(); - return NS_OK; - } - return NS_NOINTERFACE; -} +NS_IMPL_QUERY_INTERFACE3(nsPop3Service, + nsIPop3Service, + nsIProtocolHandler, + nsIMsgProtocolInfo) NS_IMETHODIMP nsPop3Service::CheckForNewMail(nsIUrlListener * aUrlListener, nsIMsgFolder *inbox, @@ -278,3 +268,28 @@ NS_IMETHODIMP nsPop3Service::NewChannel(const char *verb, nsIURI *aURI, nsILoadG // the necko team in more detail later on. return NS_ERROR_NOT_IMPLEMENTED; } + +NS_IMETHODIMP +nsPop3Service::GetDefaultLocalPath(nsIFileSpec ** aResult) +{ + nsresult rv; + NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv); + if (NS_FAILED(rv)) return rv; + + rv = prefs->GetFilePref("mail.root.pop3", aResult); + if (NS_SUCCEEDED(rv)) return rv; + + NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsFileSpec dir; + rv = profile->GetCurrentProfileDir(&dir); + if (NS_FAILED(rv)) return rv; + + dir += "Mail"; + + rv = NS_NewFileSpecWithSpec(dir, aResult); + + return rv; +} + diff --git a/mozilla/mailnews/local/src/nsPop3Service.h b/mozilla/mailnews/local/src/nsPop3Service.h index 82954ea6935..6c4e33d738f 100644 --- a/mozilla/mailnews/local/src/nsPop3Service.h +++ b/mozilla/mailnews/local/src/nsPop3Service.h @@ -27,9 +27,12 @@ #include "nsIStreamListener.h" #include "nsFileSpec.h" #include "nsIProtocolHandler.h" +#include "nsIMsgProtocolInfo.h" -class nsPop3Service : public nsIPop3Service, nsIProtocolHandler +class nsPop3Service : public nsIPop3Service, + public nsIProtocolHandler, + public nsIMsgProtocolInfo { public: @@ -39,6 +42,7 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIPOP3SERVICE NS_DECL_NSIPROTOCOLHANDLER + NS_DECL_NSIMSGPROTOCOLINFO protected: // convience function to make constructing of the pop3 url easier...