зеркало из https://github.com/mozilla/pjs.git
fix for #39016 r=mscott
make more strings localization friendly, and use formatStringFromName where appropriate
This commit is contained in:
Родитель
127e7a0bd2
Коммит
5a903519d1
|
@ -32,7 +32,7 @@
|
|||
## @loc None
|
||||
#LOCALIZATION NOTE (4000): Do not translate %s in the following line.
|
||||
# Place the word %s where the name of the mailbox should appear
|
||||
4000=Building summary file for %s...
|
||||
4000=Building summary file for %S...
|
||||
|
||||
# Status - parsing folder
|
||||
## @name LOCAL_STATUS_DOCUMENT_DONE
|
||||
|
@ -46,7 +46,7 @@
|
|||
# Place the word %lu where the number of messages should appear.
|
||||
# The first %lu will receive the number of messages received so far;
|
||||
# the second %lu will receive the total number of messages
|
||||
4002=Receiving: message %lu of %lu
|
||||
4002=Receiving: message %S of %S
|
||||
|
||||
# Status - pop3 server error
|
||||
## @name POP3_SERVER_ERROR
|
||||
|
@ -93,10 +93,9 @@
|
|||
## @loc None
|
||||
# LOCALIZATION NOTE(4010): The following sentence should be translated in this way:
|
||||
# Do not translate "POP3"
|
||||
# Do not translate "%s". Place %s in your translation where the name of the server should appear.
|
||||
# Do not translate "%S". Place %s in your translation where the name of the server should appear.
|
||||
# Do not translate "UIDL"
|
||||
# Do not translate "MOZ_NAME_PRODUCT". Place this tag in your translation where the name of the Mail product should appear.
|
||||
4010=The POP3 server (%s) does not support UIDL, which "MOZ_NAME_PRODUCT" Mail needs to implement the ``Leave on Server'' and ``Maximum Message Size'' options. To download your mail, turn off these options in the Mail Server panel of Preferences.
|
||||
4010=The POP3 server (%S) does not support UIDL, which is needed to implement the ``Leave on Server'' and ``Maximum Message Size'' options. To download your mail, turn off these options in the Mail Server panel of Preferences.
|
||||
|
||||
# Status - the server doesn't support the top command
|
||||
## @name POP3_SERVER_DOES_NOT_SUPPORT_THE_TOP_COMMAND
|
||||
|
|
|
@ -99,10 +99,12 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIChannel * /* aChannel */, ns
|
|||
nsXPIDLCString folderName;
|
||||
rv = url->GetFilePath(getter_Copies(fileName));
|
||||
url->GetFileName(getter_Copies(folderName));
|
||||
char* tempfolder = nsnull;
|
||||
rv = ioServ->Unescape(folderName, &tempfolder);
|
||||
m_folderName = tempfolder;
|
||||
CRTFREEIF(tempfolder);
|
||||
|
||||
nsXPIDLCString tempfolder;
|
||||
rv = ioServ->Unescape(folderName, getter_Copies(tempfolder));
|
||||
|
||||
m_folderName.Assign(NS_ConvertUTF8toUCS2(tempfolder));
|
||||
|
||||
if (fileName)
|
||||
{
|
||||
char* result = nsnull;
|
||||
|
@ -216,33 +218,26 @@ void nsMsgMailboxParser::UpdateStatusText (PRUint32 stringID)
|
|||
{
|
||||
if (m_statusFeedback)
|
||||
{
|
||||
if (!mStringService) // if we haven't gotten the serivce yet...
|
||||
mStringService = do_GetService(NS_MSG_MAILBOXSTRINGSERVICE_PROGID);
|
||||
nsresult rv;
|
||||
if (!mStringService) // if we haven't gotten the serivce yet...
|
||||
mStringService = do_GetService(NS_MSG_MAILBOXSTRINGSERVICE_PROGID);
|
||||
|
||||
PRUnichar * statusString = nsnull;
|
||||
mStringService->GetStringByID(stringID, &statusString);
|
||||
|
||||
nsXPIDLString finalString;
|
||||
if (stringID == LOCAL_STATUS_SELECTING_MAILBOX)
|
||||
{
|
||||
if (statusString)
|
||||
{
|
||||
// all this ugly conversion stuff is necessary because we can't sprintf a value
|
||||
// with a PRUnichar string.
|
||||
nsCAutoString cstr; cstr.AssignWithConversion(statusString);
|
||||
char * finalString = PR_smprintf(cstr.GetBuffer(), (const char *) m_folderName);
|
||||
nsAutoString uniFinalString; uniFinalString.AssignWithConversion(finalString);
|
||||
m_statusFeedback->ShowStatusString(uniFinalString.GetUnicode());
|
||||
PL_strfree(finalString);
|
||||
}
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
mStringService->GetBundle(getter_AddRefs(bundle));
|
||||
const PRUnichar * stringArray[] = { m_folderName.GetUnicode() };
|
||||
rv = bundle->FormatStringFromID(stringID, stringArray, 1,
|
||||
getter_Copies(finalString));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (statusString)
|
||||
m_statusFeedback->ShowStatusString(statusString);
|
||||
}
|
||||
mStringService->GetStringByID(stringID,
|
||||
getter_Copies(finalString));
|
||||
|
||||
nsCRT::free(statusString);
|
||||
}
|
||||
m_statusFeedback->ShowStatusString(finalString);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void nsMsgMailboxParser::UpdateProgressPercent ()
|
||||
|
@ -1718,7 +1713,6 @@ NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, PRBool *
|
|||
filter->GetActionTargetFolderUri(getter_Copies(actionTargetFolderUri));
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr = m_newMsgHdr;
|
||||
PRUint32 msgFlags;
|
||||
nsCAutoString trashNameVal;
|
||||
|
||||
msgHdr->GetFlags(&msgFlags);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
|
@ -189,7 +189,7 @@ protected:
|
|||
void FreeBuffers();
|
||||
|
||||
// data
|
||||
nsXPIDLCString m_folderName;
|
||||
nsString m_folderName;
|
||||
char *m_mailboxName;
|
||||
nsByteArray m_inputStream;
|
||||
PRInt32 m_obuffer_size;
|
||||
|
|
|
@ -268,14 +268,13 @@ net_pop3_write_state(Pop3UidlHost* host, nsIFileSpec *mailDirectory)
|
|||
|
||||
nsOutputFileStream outFileStream(fileSpec, PR_WRONLY | PR_CREATE_FILE |
|
||||
PR_TRUNCATE);
|
||||
char* tmpBuffer = PR_smprintf("%s", "# Netscape POP3 State File" MSG_LINEBREAK
|
||||
"# This is a generated file! Do not edit." MSG_LINEBREAK MSG_LINEBREAK);
|
||||
PR_ASSERT(tmpBuffer);
|
||||
char* tmpBuffer =
|
||||
"# Netscape POP3 State File" MSG_LINEBREAK
|
||||
"# This is a generated file! Do not edit." MSG_LINEBREAK
|
||||
MSG_LINEBREAK;
|
||||
|
||||
outFileStream << tmpBuffer;
|
||||
|
||||
PR_Free(tmpBuffer);
|
||||
|
||||
for (; host && (len >= 0); host = host->next)
|
||||
{
|
||||
if (!hash_empty(host->hash))
|
||||
|
@ -417,6 +416,7 @@ nsresult nsPop3Protocol::Initialize(nsIURI * aURL)
|
|||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
mailnewsUrl->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
|
||||
mailnewsUrl->GetServer(getter_AddRefs(server));
|
||||
NS_ENSURE_TRUE(server, NS_ERROR_FAILURE);
|
||||
m_pop3Server = do_QueryInterface(server);
|
||||
if (m_pop3Server)
|
||||
m_pop3Server->GetPop3CapabilityFlags(&m_pop3ConData->capability_flags);
|
||||
|
@ -479,7 +479,7 @@ void nsPop3Protocol::UpdateStatus(PRInt32 aStatusID)
|
|||
}
|
||||
}
|
||||
|
||||
void nsPop3Protocol::UpdateStatusWithString(PRUnichar * aStatusString)
|
||||
void nsPop3Protocol::UpdateStatusWithString(const PRUnichar * aStatusString)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mProgressEventSink) {
|
||||
|
@ -1308,6 +1308,7 @@ PRInt32 nsPop3Protocol::GetFakeUidlTop(nsIInputStream* inputStream,
|
|||
*/
|
||||
if(!m_pop3ConData->command_succeeded)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
/* UIDL, XTND and TOP are all unsupported for this mail server.
|
||||
Tell the user to join the 20th century.
|
||||
|
@ -1317,26 +1318,37 @@ PRInt32 nsPop3Protocol::GetFakeUidlTop(nsIInputStream* inputStream,
|
|||
`Maximum Message Size' prefs. Some people really get their panties
|
||||
in a bunch if we download their mail anyway. (bug 11561)
|
||||
*/
|
||||
|
||||
PRUnichar * statusTemplate = nsnull;
|
||||
mStringService->GetStringByID(POP3_SERVER_DOES_NOT_SUPPORT_UIDL_ETC, &statusTemplate);
|
||||
if (statusTemplate)
|
||||
{
|
||||
nsXPIDLCString hostName;
|
||||
PRUnichar * statusString = nsnull;
|
||||
m_url->GetHost(getter_Copies(hostName));
|
||||
|
||||
if (hostName)
|
||||
statusString = nsTextFormatter::smprintf(statusTemplate, (const char *) hostName);
|
||||
else
|
||||
statusString = nsTextFormatter::smprintf(statusTemplate, "(null)");
|
||||
UpdateStatusWithString(statusString);
|
||||
nsTextFormatter::smprintf_free(statusString);
|
||||
nsCRT::free(statusTemplate);
|
||||
}
|
||||
|
||||
|
||||
// set up status first, so if the rest fails, state is ok
|
||||
m_pop3ConData->next_state = POP3_ERROR_DONE;
|
||||
m_pop3ConData->pause_for_read = PR_FALSE;
|
||||
|
||||
// get the hostname first, convert to unicode
|
||||
nsXPIDLCString hostName;
|
||||
m_url->GetHost(getter_Copies(hostName));
|
||||
|
||||
nsAutoString hostNameUnicode;
|
||||
hostNameUnicode.AssignWithConversion(hostName);
|
||||
|
||||
const PRUnichar *formatStrings[] =
|
||||
{
|
||||
hostNameUnicode.GetUnicode(),
|
||||
};
|
||||
|
||||
// get the strings for the format
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = mStringService->GetBundle(getter_AddRefs(bundle));
|
||||
NS_ENSURE_SUCCESS(rv, -1);
|
||||
|
||||
nsXPIDLString statusString;
|
||||
rv = bundle->FormatStringFromID(POP3_SERVER_DOES_NOT_SUPPORT_UIDL_ETC,
|
||||
formatStrings, 1,
|
||||
getter_Copies(statusString));
|
||||
NS_ENSURE_SUCCESS(rv, -1);
|
||||
|
||||
|
||||
UpdateStatusWithString(statusString);
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
@ -1988,20 +2000,31 @@ nsPop3Protocol::SendRetr()
|
|||
}
|
||||
else
|
||||
{
|
||||
PRUnichar * statusString = nsnull;
|
||||
mStringService->GetStringByID(LOCAL_STATUS_RECEIVING_MESSAGE_OF, &statusString);
|
||||
if (statusString && m_statusFeedback)
|
||||
{
|
||||
// all this ugly conversion stuff is necessary because we can't sprintf a value
|
||||
// with a PRUnichar string.
|
||||
nsCAutoString cstr; cstr.AssignWithConversion(statusString);
|
||||
char * finalString = PR_smprintf(cstr.GetBuffer(),m_pop3ConData->real_new_counter, m_pop3ConData->really_new_messages);
|
||||
nsAutoString uniFinalString; uniFinalString.AssignWithConversion(finalString);
|
||||
if (m_statusFeedback)
|
||||
m_statusFeedback->ShowStatusString(uniFinalString.GetUnicode());
|
||||
PL_strfree(finalString);
|
||||
}
|
||||
nsCRT::free(statusString);
|
||||
nsresult rv;
|
||||
|
||||
nsAutoString realNewString;
|
||||
realNewString.AppendInt(m_pop3ConData->real_new_counter);
|
||||
|
||||
nsAutoString reallyNewMessages;
|
||||
reallyNewMessages.AppendInt(m_pop3ConData->really_new_messages);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = mStringService->GetBundle(getter_AddRefs(bundle));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't get bundle");
|
||||
|
||||
const PRUnichar *formatStrings[] = {
|
||||
realNewString.GetUnicode(),
|
||||
reallyNewMessages.GetUnicode(),
|
||||
};
|
||||
|
||||
nsXPIDLString finalString;
|
||||
rv = bundle->FormatStringFromID(LOCAL_STATUS_RECEIVING_MESSAGE_OF,
|
||||
formatStrings, 2,
|
||||
getter_Copies(finalString));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't format string");
|
||||
|
||||
m_statusFeedback->ShowStatusString(finalString);
|
||||
|
||||
}
|
||||
|
||||
status = SendData(m_url, cmd);
|
||||
|
|
|
@ -274,7 +274,7 @@ private:
|
|||
// progress state information
|
||||
void UpdateProgressPercent (PRUint32 totalDone, PRUint32 total);
|
||||
void UpdateStatus(PRInt32 aStatusID);
|
||||
void UpdateStatusWithString(PRUnichar * aString);
|
||||
void UpdateStatusWithString(const PRUnichar * aString);
|
||||
|
||||
PRInt32 m_bytesInMsgReceived;
|
||||
PRInt32 m_totalFolderSize;
|
||||
|
|
Загрузка…
Ссылка в новой задаче