зеркало из https://github.com/mozilla/pjs.git
fix for bug #44494
remember the decision the user makes in the askSendFormat dialog so that we don't ask again. fix for bug #242991 export addressbook is broken (fall out from bug #240723) r/sr=bienvenu
This commit is contained in:
Родитель
97ef1062e9
Коммит
e779717f97
|
@ -42,14 +42,13 @@ interface nsIAbCard;
|
|||
|
||||
[scriptable, uuid(fe04c8e6-501e-11d3-a527-0060b0fc04b7)]
|
||||
interface nsIAbAddressCollecter : nsISupports {
|
||||
[noscript] void collectAddress(in string address, in boolean aCreateCard);
|
||||
|
||||
void collectAddress(in string aAddress, in boolean aCreateCard, in unsigned long aSendFormat);
|
||||
/* CollectUnicodeAddress is the most I18N friendly
|
||||
of the two methods to call. If you just take a char * address
|
||||
as used by CollectAddress then you don't know what char set
|
||||
the address is in (UTF-8??).
|
||||
*/
|
||||
void collectUnicodeAddress(in wstring address, in boolean aCreateCard);
|
||||
void collectUnicodeAddress(in wstring aAddress, in boolean aCreateCard, in unsigned long aSendFormat);
|
||||
|
||||
// get the first card with this name / value in the collected ab,
|
||||
// which is determined by the mail.collect_addressbook pref
|
||||
|
|
|
@ -51,8 +51,7 @@ interface nsIAddressBook : nsISupports
|
|||
void newAddressBook(in nsIAbDirectoryProperties aProperties);
|
||||
void modifyAddressBook(in nsIRDFDataSource aDS, in nsIAbDirectory aParentDir, in nsIAbDirectory aDirectory, in nsIAbDirectoryProperties aProperties);
|
||||
void deleteAddressBooks(in nsIRDFDataSource aDS, in nsISupportsArray aParentDir, in nsISupportsArray aResourceArray);
|
||||
void setDocShellWindow(in nsIDOMWindowInternal win);
|
||||
void exportAddressBook(in nsIAbDirectory aDirectory);
|
||||
void exportAddressBook(in nsIDOMWindowInternal aParentWin, in nsIAbDirectory aDirectory);
|
||||
void convertLDIFtoMAB(in nsIFileSpec fileSpec, in boolean migrating, in nsIAddrDatabase db, in boolean bStoreLocAsHome, in boolean bImportingComm4x);
|
||||
void convertNA2toLDIF(in nsIFileSpec srcFileSpec, in nsIFileSpec dstFileSpec);
|
||||
nsIAddrDatabase getAbDatabaseFromURI(in string URI);
|
||||
|
|
|
@ -504,7 +504,7 @@ function AbExport()
|
|||
if (!selectedABURI) return;
|
||||
|
||||
var directory = GetDirectoryFromURI(selectedABURI);
|
||||
addressbook.exportAddressBook(directory);
|
||||
addressbook.exportAddressBook(window, directory);
|
||||
}
|
||||
catch (ex) {
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
||||
|
|
|
@ -71,11 +71,11 @@ nsAbAddressCollecter::~nsAbAddressCollecter()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbAddressCollecter::CollectUnicodeAddress(const PRUnichar * aAddress, PRBool aCreateCard)
|
||||
NS_IMETHODIMP nsAbAddressCollecter::CollectUnicodeAddress(const PRUnichar *aAddress, PRBool aCreateCard, PRUint32 aSendFormat)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAddress);
|
||||
// convert the unicode string to UTF-8...
|
||||
nsresult rv = CollectAddress(NS_ConvertUCS2toUTF8(aAddress).get(), aCreateCard);
|
||||
nsresult rv = CollectAddress(NS_ConvertUCS2toUTF8(aAddress).get(), aCreateCard, aSendFormat);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return rv;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ NS_IMETHODIMP nsAbAddressCollecter::GetCardFromAttribute(const char *aName, cons
|
|||
return m_database->GetCardFromAttribute(m_directory, aName, aValue, PR_FALSE /* retain case */, aCard);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address, PRBool aCreateCard)
|
||||
NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *aAddress, PRBool aCreateCard, PRUint32 aSendFormat)
|
||||
{
|
||||
// note that we're now setting the whole recipient list,
|
||||
// not just the pretty name of the first recipient.
|
||||
|
@ -98,7 +98,7 @@ NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address, PRBool a
|
|||
nsCOMPtr<nsIMsgHeaderParser> pHeader = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = pHeader->ParseHeaderAddresses(nsnull, address, &names, &addresses, &numAddresses);
|
||||
rv = pHeader->ParseHeaderAddresses(nsnull, aAddress, &names, &addresses, &numAddresses);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to parse, so can't collect");
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
@ -136,21 +136,43 @@ NS_IMETHODIMP nsAbAddressCollecter::CollectAddress(const char *address, PRBool a
|
|||
rv = senderCard->SetPrimaryEmail(NS_ConvertASCIItoUCS2(curAddress).get());
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to set email");
|
||||
|
||||
if (aSendFormat != nsIAbPreferMailFormat::unknown)
|
||||
{
|
||||
rv = senderCard->SetPreferMailFormat(aSendFormat);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to remember preferred mail format");
|
||||
}
|
||||
|
||||
rv = AddCardToAddressBook(senderCard);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to add card");
|
||||
}
|
||||
}
|
||||
else if (existingCard) {
|
||||
// address is already in the AB, so update the names
|
||||
PRBool setNames;
|
||||
PRBool setNames = PR_FALSE;
|
||||
rv = SetNamesForCard(existingCard, unquotedName.get(), &setNames);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to set names");
|
||||
|
||||
PRBool setScreenName;
|
||||
PRBool setScreenName = PR_FALSE;
|
||||
rv = AutoCollectScreenName(existingCard, curAddress, &setScreenName);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to set screen name");
|
||||
|
||||
if (setScreenName || setNames)
|
||||
PRBool setPreferMailFormat = PR_FALSE;
|
||||
if (aSendFormat != nsIAbPreferMailFormat::unknown)
|
||||
{
|
||||
PRUint32 currentFormat;
|
||||
rv = existingCard->GetPreferMailFormat(¤tFormat);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get preferred mail format");
|
||||
|
||||
// we only want to update the AB if the current format is unknown
|
||||
if (currentFormat == nsIAbPreferMailFormat::unknown)
|
||||
{
|
||||
rv = existingCard->SetPreferMailFormat(aSendFormat);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to remember preferred mail format");
|
||||
setPreferMailFormat = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (setScreenName || setNames || setPreferMailFormat)
|
||||
existingCard->EditCardToDatabase(m_abURI.get());
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
||||
// according to RFC 2849
|
||||
// SEP = (CR LF / LF)
|
||||
|
@ -166,7 +167,6 @@ const ExportAttributesTableStruct EXPORT_ATTRIBUTES_TABLE[EXPORT_ATTRIBUTES_TABL
|
|||
//
|
||||
nsAddressBook::nsAddressBook()
|
||||
{
|
||||
mDocShell = nsnull;
|
||||
}
|
||||
|
||||
nsAddressBook::~nsAddressBook()
|
||||
|
@ -260,25 +260,6 @@ nsresult nsAddressBook::DoCommand(nsIRDFDataSource* db,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddressBook::SetDocShellWindow(nsIDOMWindowInternal *aWin)
|
||||
{
|
||||
NS_PRECONDITION(aWin != nsnull, "null ptr");
|
||||
if (!aWin)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(aWin) );
|
||||
if (!globalObj) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// mDocShell is a weak reference
|
||||
mDocShell = globalObj->GetDocShell();
|
||||
if (!mDocShell)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddressBook::GetAbDatabaseFromURI(const char *aURI, nsIAddrDatabase **aDB)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
|
@ -1262,6 +1243,8 @@ void AddressBookParser::AddLdifColToDatabase(nsIMdbRow* newRow, char* typeSlot,
|
|||
ToLowerCase(column);
|
||||
if (kNotFound != column.Find("true"))
|
||||
mDatabase->AddPreferMailFormat(newRow, nsIAbPreferMailFormat::html);
|
||||
else if (kNotFound != column.Find("false"))
|
||||
mDatabase->AddPreferMailFormat(newRow, nsIAbPreferMailFormat::plaintext);
|
||||
else
|
||||
mDatabase->AddPreferMailFormat(newRow, nsIAbPreferMailFormat::unknown);
|
||||
}
|
||||
|
@ -1348,10 +1331,11 @@ enum ADDRESSBOOK_EXPORT_FILE_TYPE
|
|||
TAB_EXPORT_TYPE = 2
|
||||
};
|
||||
|
||||
NS_IMETHODIMP nsAddressBook::ExportAddressBook(nsIAbDirectory *aDirectory)
|
||||
NS_IMETHODIMP nsAddressBook::ExportAddressBook(nsIDOMWindowInternal *aParentWin, nsIAbDirectory *aDirectory)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aParentWin);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -1360,8 +1344,17 @@ NS_IMETHODIMP nsAddressBook::ExportAddressBook(nsIAbDirectory *aDirectory)
|
|||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = bundleService->CreateBundle("chrome://messenger/locale/addressbook/addressBook.properties", getter_AddRefs(bundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj = do_QueryInterface(aParentWin, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> parentWindow = do_GetInterface(mDocShell);
|
||||
nsCOMPtr<nsIDocShell> docShell = globalObj->GetDocShell();
|
||||
if (!docShell)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> parentWindow = do_GetInterface(docShell);
|
||||
if (!parentWindow)
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
nsXPIDLString title;
|
||||
rv = bundle->GetStringFromName(NS_LITERAL_STRING("ExportAddressBookTitle").get(), getter_Copies(title));
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "nsIAbCard.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsICmdLineHandler.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
@ -103,7 +102,6 @@ protected:
|
|||
nsresult GetAbDatabaseFromFile(char* pDbFile, nsIAddrDatabase **db);
|
||||
|
||||
private:
|
||||
nsIDocShell *mDocShell; // weak reference
|
||||
nsresult ExportDirectoryToDelimitedText(nsIAbDirectory *aDirectory, const char *aDelim, PRUint32 aDelimLen, nsILocalFile *aLocalFile);
|
||||
nsresult ExportDirectoryToLDIF(nsIAbDirectory *aDirectory, nsILocalFile *aLocalFile);
|
||||
nsresult AppendLDIFForMailList(nsIAbCard *aCard, nsACString &aResult);
|
||||
|
|
|
@ -356,14 +356,14 @@ var messageHeaderSink = {
|
|||
(gCollectNewsgroup && dontCollectAddress))
|
||||
{
|
||||
gCollectAddress = foo.headerValue;
|
||||
// collect, and add card if doesn't exist
|
||||
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, true);', 2000);
|
||||
// collect, and add card if doesn't exist, unknown preferred send format
|
||||
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, true, Components.interfaces.nsIAbPreferMailFormat.unknown);', 2000);
|
||||
}
|
||||
else if (gCollectOutgoing)
|
||||
{
|
||||
// collect, but only update existing cards
|
||||
// collect, but only update existing cards, unknown preferred send format
|
||||
gCollectAddress = foo.headerValue;
|
||||
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, false);', 2000);
|
||||
gCollectAddressTimer = setTimeout('abAddressCollector.collectUnicodeAddress(gCollectAddress, false, Components.interfaces.nsIAbPreferMailFormat.unknown);', 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,17 +161,12 @@ interface nsIMsgCompose : nsISupports {
|
|||
AUTF8String AttachmentPrettyName(in string url, in string charset);
|
||||
|
||||
/*
|
||||
CheckAndPopulateRecipients will perform several task:
|
||||
CheckAndPopulateRecipients will perform several tasks:
|
||||
1) if populateMailList is true, it will populate mailing presents in the compose field
|
||||
2) if returnNoHTMLRecipients is true, build a list of non HTML recipient
|
||||
3) return the lowest common format preferred by recipients (unknow, plaintext or html)
|
||||
*/
|
||||
unsigned long CheckAndPopulateRecipients(in boolean populateMailList, in boolean returnNonHTMLRecipients, out wstring nonHTMLRecipients);
|
||||
|
||||
/* GetNoHtmlNewsgroups: if null is passed as recipient, the function will automatically
|
||||
looks for newsgroups stored in compose fields
|
||||
*/
|
||||
string GetNoHtmlNewsgroups(in string newsgroups);
|
||||
|
||||
/* bodyConvertible: The level of "convertibility" to plaintext
|
||||
* @return a value from nsIMsgCompConvertible.
|
||||
|
|
|
@ -1714,6 +1714,12 @@ function GenericSendMessage( msgType )
|
|||
return;
|
||||
action = result2.action;
|
||||
}
|
||||
|
||||
// we will remember the users "send format" decision
|
||||
// in the address collector code (see nsAbAddressCollecter::CollectAddress())
|
||||
// by using msgCompFields.forcePlainText and msgCompFields.useMultipartAlternative
|
||||
// to determine the nsIAbPreferMailFormat (unknown, plaintext, or html)
|
||||
// if the user sends both, we remember html.
|
||||
switch (action)
|
||||
{
|
||||
case nsIMsgCompSendFormat.PlainText:
|
||||
|
@ -2469,13 +2475,8 @@ function DetermineHTMLAction(convertible)
|
|||
dump("DetermineHTMLAction: preferFormat = " + preferFormat + ", noHtmlRecipients are " + noHtmlRecipients + "\n");
|
||||
|
||||
//Check newsgroups now...
|
||||
try {
|
||||
noHtmlnewsgroups = gMsgCompose.GetNoHtmlNewsgroups(null);
|
||||
} catch(ex)
|
||||
{
|
||||
noHtmlnewsgroups = gMsgCompose.compFields.newsgroups;
|
||||
}
|
||||
|
||||
noHtmlnewsgroups = gMsgCompose.compFields.newsgroups;
|
||||
|
||||
if (noHtmlRecipients != "" || noHtmlnewsgroups != "")
|
||||
{
|
||||
if (convertible == nsIMsgCompConvertible.Plain)
|
||||
|
|
|
@ -3819,6 +3819,7 @@ nsresult nsMsgCompose::GetMailListAddresses(nsString& name, nsISupportsArray* ma
|
|||
}
|
||||
|
||||
|
||||
// 3 = To, Cc, Bcc
|
||||
#define MAX_OF_RECIPIENT_ARRAY 3
|
||||
|
||||
NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList, PRBool returnNonHTMLRecipients, PRUnichar **nonHTMLRecipients, PRUint32 *_retval)
|
||||
|
@ -4115,11 +4116,11 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
|
|||
/* setup return value */
|
||||
switch (recipient->mPreferFormat)
|
||||
{
|
||||
case nsIAbPreferMailFormat::html :
|
||||
case nsIAbPreferMailFormat::html:
|
||||
// nothing to do
|
||||
break;
|
||||
|
||||
case nsIAbPreferMailFormat::plaintext :
|
||||
case nsIAbPreferMailFormat::plaintext:
|
||||
if (*_retval == nsIAbPreferMailFormat::html)
|
||||
*_retval = nsIAbPreferMailFormat::plaintext;
|
||||
break;
|
||||
|
@ -4163,14 +4164,6 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::GetNoHtmlNewsgroups(const char *newsgroups, char **_retval)
|
||||
{
|
||||
//FIX ME: write me
|
||||
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
*_retval = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Decides which tags trigger which convertible mode, i.e. here is the logic
|
||||
for BodyConvertible */
|
||||
// Helper function. Parameters are not checked.
|
||||
|
|
|
@ -111,6 +111,7 @@
|
|||
#include "nsRDFCID.h"
|
||||
#include "nsIMsgAccountManager.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsIAbCard.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
|
@ -3401,45 +3402,48 @@ nsMsgComposeAndSend::DeliverFileAsMail()
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
PRBool collectOutgoingAddresses = PR_TRUE;
|
||||
nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (pPrefBranch)
|
||||
pPrefBranch->GetBoolPref(PREF_MAIL_COLLECT_EMAIL_ADDRESS_OUTGOING, &collectOutgoingAddresses);
|
||||
|
||||
|
||||
nsCOMPtr<nsIAbAddressCollecter> addressCollecter =
|
||||
do_GetService(NS_ABADDRESSCOLLECTER_CONTRACTID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
addressCollecter = nsnull;
|
||||
do_GetService(NS_ABADDRESSCOLLECTER_CONTRACTID);
|
||||
|
||||
PRBool collectAddresses = (collectOutgoingAddresses && addressCollecter);
|
||||
PRBool forcePlainText = mCompFields->GetForcePlainText();
|
||||
PRBool useMultipartAlternative = mCompFields->GetUseMultipartAlternative();
|
||||
PRUint32 sendFormat = nsIAbPreferMailFormat::unknown;
|
||||
|
||||
// see GenericSendMessage() in MsgComposeCommands.js for the reverse logic
|
||||
// if we choose to send both (html and plain) remember html.
|
||||
if (forcePlainText && !useMultipartAlternative)
|
||||
sendFormat = nsIAbPreferMailFormat::plaintext;
|
||||
else if (!forcePlainText)
|
||||
sendFormat = nsIAbPreferMailFormat::html;
|
||||
else
|
||||
NS_ASSERTION(0,"unknown send format, should not happen");
|
||||
|
||||
PL_strcpy (buf, "");
|
||||
buf2 = buf + PL_strlen (buf);
|
||||
if (mCompFields->GetTo() && *mCompFields->GetTo())
|
||||
{
|
||||
PL_strcat (buf2, mCompFields->GetTo());
|
||||
if (collectAddresses)
|
||||
addressCollecter->CollectAddress(mCompFields->GetTo(), PR_TRUE);
|
||||
addressCollecter->CollectAddress(mCompFields->GetTo(), collectAddresses /* create card if one doesn't exist */, sendFormat);
|
||||
}
|
||||
if (mCompFields->GetCc() && *mCompFields->GetCc()) {
|
||||
if (*buf2) PL_strcat (buf2, ",");
|
||||
PL_strcat (buf2, mCompFields->GetCc());
|
||||
if (collectAddresses)
|
||||
addressCollecter->CollectAddress(mCompFields->GetCc(), PR_TRUE);
|
||||
addressCollecter->CollectAddress(mCompFields->GetCc(), collectAddresses /* create card if one doesn't exist */, sendFormat);
|
||||
}
|
||||
if (mCompFields->GetBcc() && *mCompFields->GetBcc()) {
|
||||
if (*buf2) PL_strcat (buf2, ",");
|
||||
PL_strcat (buf2, mCompFields->GetBcc());
|
||||
if (collectAddresses)
|
||||
addressCollecter->CollectAddress(mCompFields->GetBcc(), PR_TRUE);
|
||||
addressCollecter->CollectAddress(mCompFields->GetBcc(), collectAddresses /* create card if one doesn't exist */, sendFormat);
|
||||
}
|
||||
|
||||
// We need undo groups to keep only the addresses
|
||||
rv = StripOutGroupNames(buf);
|
||||
nsresult rv = StripOutGroupNames(buf);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Ok, now MIME II encode this to prevent 8bit problems...
|
||||
|
|
Загрузка…
Ссылка в новой задаче