зеркало из https://github.com/mozilla/pjs.git
Implement date&time support in reply-headers, like:
"On <date & time>, <author> wrote:" For now, this is optional (set mailnews.reply_header_type to '2' in prefs.js), we will default to only show "<author> wrote:", as usual. This is due to some l10n issues which are part of bug 75377. The date&time format is hard-coded to be en-US if set, again, bug 75377. bug 23615. r=disttsc@bart.nl, sr=sspitzer@netscape.com Fix a bunch of leaks (15 of them) in addressbook, addressbook-sync and import-mail code. None of the callers to GetUserProfileDirectory() deallocated their nsFileSpec. bug 75332. r=chuang@netscape.com, sr=bienvenu@netscape.com
This commit is contained in:
Родитель
1980a24ebe
Коммит
d08c78b365
|
@ -731,7 +731,9 @@ nsAbSync::OpenAB(char *aAbName, nsIAddrDatabase **aDatabase)
|
|||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
delete dbPath;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -191,7 +191,9 @@ NS_IMETHODIMP nsAbBSDirectory::GetChildNodes(nsIEnumerator* *result)
|
|||
{
|
||||
listDatabase->GetMailingListsFromDB(childDir);
|
||||
}
|
||||
}
|
||||
|
||||
delete dbPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,9 @@ NS_IMETHODIMP nsAbDirectory::GetChildNodes(nsIEnumerator* *result)
|
|||
{
|
||||
listDatabase->GetMailingListsFromDB(childDir);
|
||||
}
|
||||
}
|
||||
|
||||
delete dbPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -561,6 +563,8 @@ nsresult nsAbDirectory::DeleteDirectoryCards(nsIAbDirectory* directory, DIR_Serv
|
|||
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
rv = addrDBFactory->Open(dbPath, PR_FALSE, getter_AddRefs(database), PR_TRUE);
|
||||
|
||||
delete dbPath;
|
||||
}
|
||||
|
||||
/* delete cards */
|
||||
|
|
|
@ -391,6 +391,8 @@ nsresult nsAbMDBDirectory::DeleteDirectoryCards(nsIAbDirectory* directory, DIR_S
|
|||
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
rv = addrDBFactory->Open(dbPath, PR_FALSE, getter_AddRefs(database), PR_TRUE);
|
||||
|
||||
delete dbPath;
|
||||
}
|
||||
|
||||
/* delete cards */
|
||||
|
|
|
@ -109,6 +109,8 @@ nsresult nsAbMDBRDFResource::GetAbDatabase()
|
|||
if (mDatabase)
|
||||
mDatabase->AddListener(this);
|
||||
|
||||
delete dbPath;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (!mDatabase)
|
||||
|
|
|
@ -109,6 +109,8 @@ nsresult nsAbRDFResource::GetAbDatabase()
|
|||
if (mDatabase)
|
||||
mDatabase->AddListener(this);
|
||||
|
||||
delete dbPath;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
if (!mDatabase)
|
||||
|
|
|
@ -262,6 +262,8 @@ nsAddbookProtocolHandler::OpenAB(char *aAbName, nsIAddrDatabase **aDatabase)
|
|||
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
rv = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(aDatabase), PR_TRUE);
|
||||
|
||||
delete dbPath;
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
|
|
@ -767,8 +767,10 @@ NS_IMETHODIMP nsAddrDatabase::OpenAnonymousDB(nsIAddrDatabase **pCardDB)
|
|||
|
||||
Open(dbPath, PR_TRUE, getter_AddRefs(database), PR_TRUE);
|
||||
|
||||
*pCardDB = database;
|
||||
*pCardDB = database;
|
||||
NS_IF_ADDREF(*pCardDB);
|
||||
|
||||
delete dbPath;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -315,6 +315,9 @@ NS_IMETHODIMP nsAddressBook::GetAbDatabaseFromURI(const char *uri, nsIAddrDataba
|
|||
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
rv = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(database), PR_TRUE);
|
||||
|
||||
delete dbPath;
|
||||
|
||||
if (NS_SUCCEEDED(rv) && database)
|
||||
{
|
||||
*db = database;
|
||||
|
@ -344,6 +347,9 @@ nsresult nsAddressBook::GetAbDatabaseFromFile(char* pDbFile, nsIAddrDatabase **d
|
|||
NS_WITH_SERVICE(nsIAddrDatabase, addrDBFactory, kAddressBookDBCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
rv = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(database), PR_TRUE);
|
||||
|
||||
delete dbPath;
|
||||
|
||||
if (NS_SUCCEEDED(rv) && database)
|
||||
{
|
||||
*db = database;
|
||||
|
@ -513,6 +519,8 @@ nsresult AddressBookParser::ParseFile()
|
|||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
delete dbPath;
|
||||
|
||||
NS_WITH_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIRDFResource> parentResource;
|
||||
|
|
|
@ -1999,6 +1999,8 @@ nsresult DIR_DeleteServerFromList(DIR_Server *server)
|
|||
dbPath->Delete(PR_FALSE);
|
||||
}
|
||||
|
||||
delete dbPath;
|
||||
|
||||
nsVoidArray *dirList = DIR_GetDirectories();
|
||||
DIR_SetServerPosition(dirList, server, DIR_POS_DELETE);
|
||||
DIR_DeleteServer(server);
|
||||
|
@ -2814,6 +2816,8 @@ void DIR_SetFileName(char** fileName, const char* defaultName)
|
|||
*fileName = PL_strdup(file);
|
||||
if (file)
|
||||
nsCRT::free(file);
|
||||
|
||||
delete dbPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Contributor(s):
|
||||
* Jean-Francois Ducarroz <ducarroz@netscaape.com>
|
||||
* Ben Bucksch <mozilla@bucksch.org>
|
||||
* Håkan Waara <hwaara@chello.se>
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
|
||||
|
@ -76,6 +77,12 @@
|
|||
#include "nsMsgBaseCID.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsMsgMimeCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsILocale.h"
|
||||
|
||||
|
||||
#include "nsMsgComposeService.h"
|
||||
#include "nsMsgUtils.h"
|
||||
|
@ -85,14 +92,24 @@ static NS_DEFINE_CID(kHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
|||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kCMimeConverterCID, NS_MIME_CONVERTER_CID);
|
||||
static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
|
||||
|
||||
static PRInt32 GetReplyOnTop()
|
||||
{
|
||||
PRInt32 reply_on_top = 1;
|
||||
nsCOMPtr<nsIPref> prefs (do_GetService(NS_PREF_CONTRACTID));
|
||||
PRInt32 reply_on_top = 1;
|
||||
nsCOMPtr<nsIPref> prefs (do_GetService(NS_PREF_CONTRACTID));
|
||||
if (prefs)
|
||||
prefs->GetIntPref("mailnews.reply_on_top", &reply_on_top);
|
||||
return reply_on_top;
|
||||
prefs->GetIntPref("mailnews.reply_on_top", &reply_on_top);
|
||||
return reply_on_top;
|
||||
}
|
||||
|
||||
static PRInt32 GetReplyHeaderType()
|
||||
{
|
||||
PRInt32 reply_header_type = 1;
|
||||
nsCOMPtr<nsIPref> prefs (do_GetService(NS_PREF_CONTRACTID));
|
||||
if (prefs)
|
||||
prefs->GetIntPref("mailnews.reply_header_type", &reply_header_type);
|
||||
return reply_header_type;
|
||||
}
|
||||
|
||||
static nsresult RemoveDuplicateAddresses(const char * addresses, const char * anothersAddresses, PRBool removeAliasesToMe, char** newAddress)
|
||||
|
@ -992,7 +1009,7 @@ nsresult nsMsgCompose::CreateMessage(const char * originalMsgURI,
|
|||
mQuotingToFollow = PR_TRUE;
|
||||
|
||||
// HACK: if we are replying to a message and that message used a charset over ride
|
||||
// (as speciifed in the top most window (assuming the reply originated from that window)
|
||||
// (as specified in the top most window (assuming the reply originated from that window)
|
||||
// then use that over ride charset instead of the charset specified in the message
|
||||
nsCOMPtr <nsIMsgMailSession> mailSession (do_GetService(NS_MSGMAILSESSION_CONTRACTID));
|
||||
if (mailSession)
|
||||
|
@ -1159,6 +1176,68 @@ QuotingOutputStreamListener::QuotingOutputStreamListener(const char * originalMs
|
|||
if (GetReplyOnTop() == 1)
|
||||
mCitePrefix += NS_LITERAL_STRING("<br><br>");
|
||||
|
||||
|
||||
PRBool header, headerDate;
|
||||
|
||||
switch(GetReplyHeaderType())
|
||||
{
|
||||
case 0: // No reply header at all
|
||||
header=PR_FALSE;
|
||||
headerDate=PR_FALSE;
|
||||
break;
|
||||
|
||||
case 2: // Insert both the original author and date in the reply header
|
||||
header=PR_TRUE;
|
||||
headerDate=PR_TRUE;
|
||||
break;
|
||||
|
||||
case 3: // XXX implement user specified header
|
||||
case 1: // Default is to only view the author. We will reconsider this decision when bug 75377 is fixed.
|
||||
default:
|
||||
header=PR_TRUE;
|
||||
headerDate=PR_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (header)
|
||||
{
|
||||
if (headerDate)
|
||||
{
|
||||
nsCOMPtr<nsIDateTimeFormat> dateFormatter = do_CreateInstance(kDateTimeFormatCID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
PRTime originalMsgDate;
|
||||
rv = originalMsgHdr->GetDate(&originalMsgDate);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsAutoString formattedDateString;
|
||||
nsCOMPtr<nsILocale> locale;
|
||||
nsCOMPtr<nsILocaleService> localeService(do_GetService(NS_LOCALESERVICE_CONTRACTID));
|
||||
|
||||
// We can't have this date localizable since we don't know if the recipent understands
|
||||
// the samelanguage as the sender, so we will have to fallback on en-US until bug 75377
|
||||
// is fixed - which will make this (and the other hard-coded strings) localizable!
|
||||
localeService->NewLocale(NS_LITERAL_STRING("en-US").get(), getter_AddRefs(locale));
|
||||
|
||||
rv = dateFormatter->FormatPRTime(locale,
|
||||
kDateFormatShort,
|
||||
kTimeFormatNoSeconds,
|
||||
originalMsgDate,
|
||||
formattedDateString);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
mCitePrefix += NS_LITERAL_STRING("On ") + // XXX see bug 75377 or read above, for why we hardcode this.
|
||||
formattedDateString +
|
||||
NS_LITERAL_STRING(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsXPIDLString author;
|
||||
rv = originalMsgHdr->GetMime2DecodedAuthor(getter_Copies(author));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -1184,13 +1263,17 @@ QuotingOutputStreamListener::QuotingOutputStreamListener(const char * originalMs
|
|||
mCitePrefix.Append(authorStr);
|
||||
else
|
||||
mCitePrefix.Append(author);
|
||||
mCitePrefix.Append(NS_LITERAL_STRING(" wrote:<br><html>")); //XXX I18n?
|
||||
|
||||
mCitePrefix.Append(NS_LITERAL_STRING(" wrote:<br><html>"));// XXX see bug bug 75377 for why we hardcode this.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mCitePrefix.IsEmpty())
|
||||
mCitePrefix.Append(NS_LITERAL_STRING("<br><br>--- Original Message ---<br><html>")); //XXX I18n?
|
||||
mCitePrefix.Append(NS_LITERAL_STRING("<br><br>--- Original Message ---<br><html>"));
|
||||
}
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
|
|
|
@ -839,6 +839,8 @@ nsIAddrDatabase *GetAddressBook( const PRUnichar *name, PRBool makeNew)
|
|||
|
||||
parentDir->CreateNewDirectory((unsigned int )prefCount, (const char** )prefNames, (const PRUnichar** )prefValues);
|
||||
|
||||
delete dbPath;
|
||||
|
||||
if (fileName)
|
||||
nsCRT::free(fileName);
|
||||
if (prefNames[0])
|
||||
|
|
|
@ -116,9 +116,11 @@ pref("mailnews.wraplength", 72);
|
|||
|
||||
pref("mailnews.reply_on_top", 0); // 0=bottom 1=top 2=select+bottom 3=select+top
|
||||
|
||||
// 0=no header, 1="<author> wrote:", 2="On <date> <author> wrote:", 3=user specified
|
||||
pref("mailnews.reply_header_type", 1);
|
||||
|
||||
pref("mail.purge_threshhold", 100);
|
||||
pref("mail.prompt_purge_threshhold", false);
|
||||
|
||||
pref("mailnews.force_ascii_search", false);
|
||||
pref("mailnews.autolookup_unknown_mime_types", true);
|
||||
|
||||
|
|
|
@ -116,9 +116,11 @@ pref("mailnews.wraplength", 72);
|
|||
|
||||
pref("mailnews.reply_on_top", 0); // 0=bottom 1=top 2=select+bottom 3=select+top
|
||||
|
||||
// 0=no header, 1="<author> wrote:", 2="On <date> <author> wrote:", 3=user specified
|
||||
pref("mailnews.reply_header_type", 1);
|
||||
|
||||
pref("mail.purge_threshhold", 100);
|
||||
pref("mail.prompt_purge_threshhold", false);
|
||||
|
||||
pref("mailnews.force_ascii_search", false);
|
||||
pref("mailnews.autolookup_unknown_mime_types", true);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче