diff --git a/mozilla/mailnews/base/public/nsIMsgMailNewsUrl.idl b/mozilla/mailnews/base/public/nsIMsgMailNewsUrl.idl index 886f4cae97e..100bace7568 100644 --- a/mozilla/mailnews/base/public/nsIMsgMailNewsUrl.idl +++ b/mozilla/mailnews/base/public/nsIMsgMailNewsUrl.idl @@ -21,6 +21,7 @@ interface nsIUrlListener; interface nsIMsgStatusFeedback; +interface nsIMsgIncomingServer; [scriptable, uuid(6CFFCEB0-CB8C-11d2-8065-006008128C4E)] interface nsIMsgMailNewsUrl : nsIURL { @@ -43,6 +44,8 @@ interface nsIMsgMailNewsUrl : nsIURL { void SetUrlState(in boolean runningUrl, in nsresult aStatusCode); void GetUrlState(out boolean runningUrl); + void GetServer(out nsIMsgIncomingServer aIncomingServer); + // the ownership model for msg feedback void SetStatusFeedback(in nsIMsgStatusFeedback aMsgFeedback); void GetStatusFeedback(out nsIMsgStatusFeedback aMsgFeedback); diff --git a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp index 36e93ccf039..3cdf5e7cfde 100644 --- a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp +++ b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp @@ -20,6 +20,7 @@ #include "nsMsgMailNewsUrl.h" #include "nsMsgBaseCID.h" #include "nsIMsgMailSession.h" +#include "nsXPIDLString.h" static NS_DEFINE_CID(kUrlListenerManagerCID, NS_URLLISTENERMANAGER_CID); static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID); @@ -150,6 +151,37 @@ nsresult nsMsgMailNewsUrl::GetErrorMessage (char ** errorMessage) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP nsMsgMailNewsUrl::GetServer(nsIMsgIncomingServer ** aIncomingServer) +{ + // mscott --> we could cache a copy of the server here....but if we did, we run + // the risk of leaking the server if any single url gets leaked....of course that + // shouldn't happen...but it could. so i'm going to look it up every time and + // we can look at caching it later. + + nsXPIDLCString host; + nsXPIDLCString scheme; + + nsresult rv = GetHost(getter_Copies(host)); + rv = GetScheme(getter_Copies(scheme)); + if (NS_SUCCEEDED(rv)) + { + NS_WITH_SERVICE(nsIMsgMailSession, session, kMsgMailSessionCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr accountManager; + rv = session->GetAccountManager(getter_AddRefs(accountManager)); + if(NS_FAILED(rv)) return rv; + + nsCOMPtr server; + rv = accountManager->FindServer(GetUserName(), + host, + scheme, + aIncomingServer); + } + + return rv; +} + NS_IMETHODIMP nsMsgMailNewsUrl::SetStatusFeedback(nsIMsgStatusFeedback *aMsgFeedback) { if (aMsgFeedback) diff --git a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.h b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.h index 354302d9a7f..23b14c8f07a 100644 --- a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.h +++ b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.h @@ -65,6 +65,10 @@ public: NS_IMETHOD SetStatusFeedback(nsIMsgStatusFeedback *aMsgFeedback); NS_IMETHOD GetStatusFeedback(nsIMsgStatusFeedback **aMsgFeedback); + // This is just a stub implementation. It is the responsibility of derived + // url classes to over-ride this method. + NS_IMETHOD GetServer(nsIMsgIncomingServer ** aIncomingServer); + // if you really want to know what the current state of the url is (running or not // running) you should look into becoming a urlListener... NS_IMETHOD SetUrlState(PRBool runningUrl, nsresult aStatusCode); @@ -125,6 +129,9 @@ public: protected: virtual ~nsMsgMailNewsUrl(); + // a helper function I needed from derived urls... + virtual const char * GetUserName() = 0; + nsCOMPtr m_baseURL; nsCOMPtr m_statusFeedback; char *m_errorMessage;