diff --git a/mailnews/imap/public/nsIImapServerSink.idl b/mailnews/imap/public/nsIImapServerSink.idl index fa79d18eafe..999f22834f5 100644 --- a/mailnews/imap/public/nsIImapServerSink.idl +++ b/mailnews/imap/public/nsIImapServerSink.idl @@ -34,6 +34,7 @@ interface nsIImapServerSink : nsISupports { void SetCapability(in unsigned long capability); + void GetImapStringByID(in long aMsgId, out wstring aString); void FEAlert(in wstring aString); void FEAlertFromServer(in string aString); void CommitNamespaces(); diff --git a/mailnews/imap/src/nsImapIncomingServer.cpp b/mailnews/imap/src/nsImapIncomingServer.cpp index 0d0e90be3d9..f58f920e15a 100644 --- a/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mailnews/imap/src/nsImapIncomingServer.cpp @@ -46,6 +46,7 @@ #include "nsRDFCID.h" #include "nsINetSupportDialogService.h" #include "nsEnumeratorUtils.h" +#include "nsIStringBundle.h" static NS_DEFINE_CID(kCImapHostSessionList, NS_IIMAPHOSTSESSIONLIST_CID); static NS_DEFINE_CID(kImapProtocolCID, NS_IMAPPROTOCOL_CID); @@ -89,6 +90,7 @@ private: PRBool ConnectionTimeOut(nsIImapProtocol* aImapConnection); nsCOMPtr m_connectionCache; nsCOMPtr m_urlQueue; + nsCOMPtr m_stringBundle; nsVoidArray m_urlConsumers; PRUint32 m_capability; nsCString m_manageMailAccountUrl; @@ -1155,7 +1157,8 @@ NS_IMETHODIMP nsImapIncomingServer::FEAlertFromServer(const char *aString) if (whereRealMessage) whereRealMessage++; - PRUnichar *serverSaidPrefix = IMAPGetStringByID(IMAP_SERVER_SAID); + PRUnichar *serverSaidPrefix = nsnull; + GetImapStringByID(IMAP_SERVER_SAID, &serverSaidPrefix); if (serverSaidPrefix) { nsAutoString message(serverSaidPrefix); @@ -1169,6 +1172,56 @@ NS_IMETHODIMP nsImapIncomingServer::FEAlertFromServer(const char *aString) return rv; } +/* This is the next generation string retrieval call */ +static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); + +#define IMAP_MSGS_URL "resource:/chrome/messenger/locale/en-US/imapMsgs_en-US.properties" + +NS_IMETHODIMP nsImapIncomingServer::GetImapStringByID(PRInt32 aMsgId, PRUnichar **aString) +{ + nsAutoString resultString = "???"; + nsresult res = NS_OK; + + if (!m_stringBundle) + { + char* propertyURL = NULL; + + propertyURL = IMAP_MSGS_URL; + + NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res); + if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) + { + nsILocale *locale = nsnull; + + res = sBundleService->CreateBundle(propertyURL, locale, getter_AddRefs(m_stringBundle)); + } + } + if (m_stringBundle) + { + PRUnichar *ptrv = nsnull; + res = m_stringBundle->GetStringFromID(aMsgId, &ptrv); + + if (NS_FAILED(res)) + { + resultString = "[StringID"; + resultString.Append(aMsgId, 10); + resultString += "?]"; + *aString = resultString.ToNewUnicode(); + } + else + { + *aString = ptrv; + } + } + else + { + res = NS_OK; + *aString = resultString.ToNewUnicode(); + } + return res; +} + + nsresult nsImapIncomingServer::GetUnverifiedFolders(nsISupportsArray *aFoldersArray, PRInt32 *aNumUnverifiedFolders) { // can't have both be null, but one null is OK, since the caller diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 022435910b8..0d016753c37 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -2798,7 +2798,18 @@ NS_IMETHODIMP nsImapMailFolder::ProgressStatus(nsIImapProtocol* aProtocol, PRUint32 aMsgId, const char *extraInfo) { - PRUnichar *progressMsg = IMAPGetStringByID(aMsgId); + PRUnichar *progressMsg = nsnull; + + nsCOMPtr server; + nsresult rv = GetServer(getter_AddRefs(server)); + if (NS_SUCCEEDED(rv) && server) + { + nsCOMPtr serverSink = do_QueryInterface(server); + if (serverSink) + serverSink->GetImapStringByID(aMsgId, &progressMsg); + } + if (!progressMsg) + progressMsg = IMAPGetStringByID(aMsgId); if (aProtocol && progressMsg) { diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp index 07f7290b049..0dda2003804 100644 --- a/mailnews/imap/src/nsImapProtocol.cpp +++ b/mailnews/imap/src/nsImapProtocol.cpp @@ -3696,9 +3696,11 @@ nsImapProtocol::AlertUserEventUsingId(PRUint32 aMessageId) { if (m_imapServerSink) { - PRUnichar *progressString = IMAPGetStringByID(aMessageId); + PRUnichar *progressString = nsnull; + m_imapServerSink->GetImapStringByID(aMessageId, &progressString); m_imapServerSink->FEAlert(progressString); + PR_FREEIF(progressString); } } @@ -3732,7 +3734,8 @@ nsImapProtocol::ShowProgress() if (m_progressStringId) { PRUnichar *progressString = NULL; - progressString = IMAPGetStringByID(m_progressStringId); + if (m_imapServerSink) + m_imapServerSink->GetImapStringByID(m_progressStringId, &progressString); if (progressString) { // lossy if localized string has non-8-bit chars, but we're @@ -3782,7 +3785,7 @@ void nsImapProtocol::PercentProgressUpdateEvent(PRUnichar *message, PRInt32 percent) { - int64 nowMS; + PRInt64 nowMS; if (percent == m_lastPercent) return; // hasn't changed, right? So just return. Do we need to clear this anywhere? diff --git a/mailnews/imap/src/nsImapStringBundle.cpp b/mailnews/imap/src/nsImapStringBundle.cpp index 9d55a6ce5c7..d16b31c3715 100644 --- a/mailnews/imap/src/nsImapStringBundle.cpp +++ b/mailnews/imap/src/nsImapStringBundle.cpp @@ -41,7 +41,6 @@ IMAPGetStringByID(PRInt32 stringID) NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res); if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) { - nsCOMPtr url; nsILocale *locale = nsnull; nsIStringBundle* sBundle = nsnull; diff --git a/mailnews/imap/src/nsImapUrl.h b/mailnews/imap/src/nsImapUrl.h index fb69a6e3454..e830b6369ac 100644 --- a/mailnews/imap/src/nsImapUrl.h +++ b/mailnews/imap/src/nsImapUrl.h @@ -147,7 +147,7 @@ protected: nsCOMPtr m_imapServerSink; // online message copy support; i don't have a better solution yet - nsISupports* m_copyState; // ** not refcount'd + nsCOMPtr m_copyState; // now, refcounted. nsIFileSpec* m_fileSpec; };