зеркало из https://github.com/mozilla/pjs.git
cache imap string bundle, fix crash deleting messages
This commit is contained in:
Родитель
87b66e4bc8
Коммит
b00666144b
|
@ -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();
|
||||
|
|
|
@ -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<nsISupportsArray> m_connectionCache;
|
||||
nsCOMPtr<nsISupportsArray> m_urlQueue;
|
||||
nsCOMPtr<nsIStringBundle> 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
|
||||
|
|
|
@ -2798,7 +2798,18 @@ NS_IMETHODIMP
|
|||
nsImapMailFolder::ProgressStatus(nsIImapProtocol* aProtocol,
|
||||
PRUint32 aMsgId, const char *extraInfo)
|
||||
{
|
||||
PRUnichar *progressMsg = IMAPGetStringByID(aMsgId);
|
||||
PRUnichar *progressMsg = nsnull;
|
||||
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
nsresult rv = GetServer(getter_AddRefs(server));
|
||||
if (NS_SUCCEEDED(rv) && server)
|
||||
{
|
||||
nsCOMPtr<nsIImapServerSink> serverSink = do_QueryInterface(server);
|
||||
if (serverSink)
|
||||
serverSink->GetImapStringByID(aMsgId, &progressMsg);
|
||||
}
|
||||
if (!progressMsg)
|
||||
progressMsg = IMAPGetStringByID(aMsgId);
|
||||
|
||||
if (aProtocol && progressMsg)
|
||||
{
|
||||
|
|
|
@ -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?
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ IMAPGetStringByID(PRInt32 stringID)
|
|||
NS_WITH_SERVICE(nsIStringBundleService, sBundleService, kStringBundleServiceCID, &res);
|
||||
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
|
||||
{
|
||||
nsCOMPtr<nsIURI> url;
|
||||
nsILocale *locale = nsnull;
|
||||
|
||||
nsIStringBundle* sBundle = nsnull;
|
||||
|
|
|
@ -147,7 +147,7 @@ protected:
|
|||
nsCOMPtr <nsIImapServerSink> m_imapServerSink;
|
||||
|
||||
// online message copy support; i don't have a better solution yet
|
||||
nsISupports* m_copyState; // ** not refcount'd
|
||||
nsCOMPtr <nsISupports> m_copyState; // now, refcounted.
|
||||
nsIFileSpec* m_fileSpec;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче