diff --git a/mailnews/absync/src/nsAbSync.cpp b/mailnews/absync/src/nsAbSync.cpp index 11b577a4708..4dae07cea87 100644 --- a/mailnews/absync/src/nsAbSync.cpp +++ b/mailnews/absync/src/nsAbSync.cpp @@ -731,7 +731,9 @@ nsAbSync::OpenAB(char *aAbName, nsIAddrDatabase **aDatabase) else rv = NS_ERROR_FAILURE; - return rv; + delete dbPath; + + return rv; } NS_IMETHODIMP diff --git a/mailnews/addrbook/src/nsAbBSDirectory.cpp b/mailnews/addrbook/src/nsAbBSDirectory.cpp index e678dc03bbe..c3bedf27694 100644 --- a/mailnews/addrbook/src/nsAbBSDirectory.cpp +++ b/mailnews/addrbook/src/nsAbBSDirectory.cpp @@ -191,7 +191,9 @@ NS_IMETHODIMP nsAbBSDirectory::GetChildNodes(nsIEnumerator* *result) { listDatabase->GetMailingListsFromDB(childDir); } - } + + delete dbPath; + } } } diff --git a/mailnews/addrbook/src/nsAbDirectory.cpp b/mailnews/addrbook/src/nsAbDirectory.cpp index d4c7efa73f8..56bcae5cfbf 100644 --- a/mailnews/addrbook/src/nsAbDirectory.cpp +++ b/mailnews/addrbook/src/nsAbDirectory.cpp @@ -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 */ diff --git a/mailnews/addrbook/src/nsAbMDBDirectory.cpp b/mailnews/addrbook/src/nsAbMDBDirectory.cpp index 0d319f46812..bf8e8c704b4 100644 --- a/mailnews/addrbook/src/nsAbMDBDirectory.cpp +++ b/mailnews/addrbook/src/nsAbMDBDirectory.cpp @@ -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 */ diff --git a/mailnews/addrbook/src/nsAbMDBRDFResource.cpp b/mailnews/addrbook/src/nsAbMDBRDFResource.cpp index e54c5d85fb8..4bfe6babddf 100644 --- a/mailnews/addrbook/src/nsAbMDBRDFResource.cpp +++ b/mailnews/addrbook/src/nsAbMDBRDFResource.cpp @@ -109,6 +109,8 @@ nsresult nsAbMDBRDFResource::GetAbDatabase() if (mDatabase) mDatabase->AddListener(this); + delete dbPath; + return NS_OK; } if (!mDatabase) diff --git a/mailnews/addrbook/src/nsAbRDFResource.cpp b/mailnews/addrbook/src/nsAbRDFResource.cpp index 89f27998204..c89ed6b59bb 100644 --- a/mailnews/addrbook/src/nsAbRDFResource.cpp +++ b/mailnews/addrbook/src/nsAbRDFResource.cpp @@ -109,6 +109,8 @@ nsresult nsAbRDFResource::GetAbDatabase() if (mDatabase) mDatabase->AddListener(this); + delete dbPath; + return NS_OK; } if (!mDatabase) diff --git a/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp b/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp index 7a2c628998d..a30845f03bb 100644 --- a/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp +++ b/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp @@ -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; diff --git a/mailnews/addrbook/src/nsAddrDatabase.cpp b/mailnews/addrbook/src/nsAddrDatabase.cpp index ac6cde08036..ebc197372f8 100644 --- a/mailnews/addrbook/src/nsAddrDatabase.cpp +++ b/mailnews/addrbook/src/nsAddrDatabase.cpp @@ -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; } diff --git a/mailnews/addrbook/src/nsAddressBook.cpp b/mailnews/addrbook/src/nsAddressBook.cpp index 5052a52e5fe..49609364471 100644 --- a/mailnews/addrbook/src/nsAddressBook.cpp +++ b/mailnews/addrbook/src/nsAddressBook.cpp @@ -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 parentResource; diff --git a/mailnews/addrbook/src/nsDirPrefs.cpp b/mailnews/addrbook/src/nsDirPrefs.cpp index e52307bb149..c4df7962f20 100644 --- a/mailnews/addrbook/src/nsDirPrefs.cpp +++ b/mailnews/addrbook/src/nsDirPrefs.cpp @@ -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; } } diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index 5dcd569dfc6..165f6709e15 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -20,6 +20,7 @@ * Contributor(s): * Jean-Francois Ducarroz * Ben Bucksch + * Håkan Waara * Pierre Phaneuf */ @@ -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 prefs (do_GetService(NS_PREF_CONTRACTID)); + PRInt32 reply_on_top = 1; + nsCOMPtr 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 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 mailSession (do_GetService(NS_MSGMAILSESSION_CONTRACTID)); if (mailSession) @@ -1159,6 +1176,68 @@ QuotingOutputStreamListener::QuotingOutputStreamListener(const char * originalMs if (GetReplyOnTop() == 1) mCitePrefix += NS_LITERAL_STRING("

"); + + 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 dateFormatter = do_CreateInstance(kDateTimeFormatCID, &rv); + + if (NS_SUCCEEDED(rv)) + { + PRTime originalMsgDate; + rv = originalMsgHdr->GetDate(&originalMsgDate); + + if (NS_SUCCEEDED(rv)) + { + nsAutoString formattedDateString; + nsCOMPtr locale; + nsCOMPtr 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:
")); //XXX I18n? + + mCitePrefix.Append(NS_LITERAL_STRING(" wrote:
"));// XXX see bug bug 75377 for why we hardcode this. + } + + } } } if (mCitePrefix.IsEmpty()) - mCitePrefix.Append(NS_LITERAL_STRING("

--- Original Message ---
")); //XXX I18n? + mCitePrefix.Append(NS_LITERAL_STRING("

--- Original Message ---
")); } NS_INIT_REFCNT(); diff --git a/mailnews/import/src/nsImportAddressBooks.cpp b/mailnews/import/src/nsImportAddressBooks.cpp index 03051f5dbb3..b2eb6aa60ba 100644 --- a/mailnews/import/src/nsImportAddressBooks.cpp +++ b/mailnews/import/src/nsImportAddressBooks.cpp @@ -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]) diff --git a/mailnews/mailnews.js b/mailnews/mailnews.js index 472c3971814..43d0f4bfabe 100644 --- a/mailnews/mailnews.js +++ b/mailnews/mailnews.js @@ -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=" wrote:", 2="On 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); diff --git a/modules/libpref/src/init/mailnews.js b/modules/libpref/src/init/mailnews.js index 472c3971814..43d0f4bfabe 100644 --- a/modules/libpref/src/init/mailnews.js +++ b/modules/libpref/src/init/mailnews.js @@ -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=" wrote:", 2="On 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);