зеркало из https://github.com/mozilla/pjs.git
fix for #11387. save as draft on an existing should remove the old draft.
fix by cavin@netscape.com r=ducarroz, bienvenu. sr=sspitzer.
This commit is contained in:
Родитель
bea42689a3
Коммит
fbec1a2767
|
@ -331,6 +331,8 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
|
|||
|
||||
readonly attribute string baseMessageURI;
|
||||
|
||||
string generateMessageURI(in nsMsgKey msgKey);
|
||||
|
||||
const nsMsgDispositionState nsMsgDispositionState_Replied = 0;
|
||||
const nsMsgDispositionState nsMsgDispositionState_Forwarded = 1;
|
||||
void addMessageDispositionState(in nsIMsgDBHdr aMessage, in nsMsgDispositionState aDispositionFlag);
|
||||
|
|
|
@ -469,17 +469,7 @@ nsresult nsMsgDBView::RestoreSelection(nsMsgKeyArray * aMsgKeyArray)
|
|||
nsresult nsMsgDBView::GenerateURIForMsgKey(nsMsgKey aMsgKey, nsIMsgFolder *folder, char ** aURI)
|
||||
{
|
||||
NS_ENSURE_ARG(folder);
|
||||
nsXPIDLCString baseURI;
|
||||
folder->GetBaseMessageURI(getter_Copies(baseURI));
|
||||
nsCAutoString uri;
|
||||
uri.Assign(baseURI);
|
||||
|
||||
// append a "#" followed by the message key.
|
||||
uri.Append('#');
|
||||
uri.AppendInt(aMsgKey);
|
||||
|
||||
*aURI = uri.ToNewCString();
|
||||
return NS_OK;
|
||||
return(folder->GenerateMessageURI(aMsgKey, aURI));
|
||||
}
|
||||
|
||||
nsresult nsMsgDBView::CycleThreadedColumn(nsIDOMElement * aElement)
|
||||
|
|
|
@ -2529,3 +2529,24 @@ NS_IMETHODIMP nsMsgFolder::GetUriForMsg(nsIMsgDBHdr *msgHdr, char **aURI)
|
|||
*aURI = uri.ToNewCString();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::GenerateMessageURI(nsMsgKey msgKey, char **aURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
nsXPIDLCString baseURI;
|
||||
|
||||
nsresult rv = GetBaseMessageURI(getter_Copies(baseURI));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCAutoString uri;
|
||||
uri.Assign(baseURI);
|
||||
|
||||
// append a "#" followed by the message key.
|
||||
uri.Append('#');
|
||||
uri.AppendInt(msgKey);
|
||||
|
||||
*aURI = uri.ToNewCString();
|
||||
if (! *aURI)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -214,6 +214,8 @@ public:
|
|||
|
||||
NS_IMETHOD MatchName(nsString *name, PRBool *matches);
|
||||
|
||||
NS_IMETHOD GenerateMessageURI(nsMsgKey msgKey, char **aURI);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ interface nsIMsgCompose : nsISupports {
|
|||
readonly attribute boolean composeHTML;
|
||||
|
||||
/* ... */
|
||||
readonly attribute MSG_ComposeType type;
|
||||
attribute MSG_ComposeType type;
|
||||
|
||||
/* ... */
|
||||
readonly attribute long wrapLength;
|
||||
|
@ -192,7 +192,7 @@ interface nsIMsgCompose : nsISupports {
|
|||
[noscript] void setCiteReference(in nsString citeReference);
|
||||
|
||||
/* Set the URI of the folder where the message has been saved */
|
||||
[noscript] void setSavedFoldeURI(in string folderURI);
|
||||
[noscript] attribute string savedFolderURI;
|
||||
|
||||
/* Append the signature defined in the identity to the msgBody */
|
||||
[noscript] void processSignature(in nsIMsgIdentity identity, inout nsString aMsgBody);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "nsIMsgComposeProgress.idl"
|
||||
#include "domstubs.idl"
|
||||
#include "nsIPrompt.idl"
|
||||
#include "MailNewsTypes2.idl"
|
||||
|
||||
%{C++
|
||||
#include "nsIURL.h"
|
||||
|
@ -213,8 +214,8 @@ interface nsIMsgSend : nsISupports
|
|||
[noscript] void notifyListenerOnStartCopy();
|
||||
[noscript] void notifyListenerOnProgressCopy(in unsigned long aProgress, in unsigned long aProgressMax);
|
||||
[noscript] void notifyListenerOnStopCopy(in nsresult aStatus);
|
||||
[noscript] void setMessageKey(in unsigned long aMessageKey);
|
||||
[noscript] void getMessageId(in nsCString messageID);
|
||||
[noscript] attribute nsMsgKey messageKey;
|
||||
|
||||
[noscript] nsIPrompt getDefaultPrompt();
|
||||
|
||||
|
|
|
@ -89,7 +89,6 @@
|
|||
|
||||
// Defines....
|
||||
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);
|
||||
|
@ -1123,12 +1122,19 @@ NS_IMETHODIMP nsMsgCompose::SetCiteReference(nsString citeReference)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgCompose::SetSavedFoldeURI(const char *folderURI)
|
||||
NS_IMETHODIMP nsMsgCompose::SetSavedFolderURI(const char *folderURI)
|
||||
{
|
||||
m_folderName = folderURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgCompose::GetSavedFolderURI(char ** folderURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(folderURI);
|
||||
*folderURI = m_folderName.ToNewCString();
|
||||
return (*folderURI) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// THIS IS THE CLASS THAT IS THE STREAM CONSUMER OF THE HTML OUPUT
|
||||
|
@ -1549,7 +1555,14 @@ NS_IMPL_ISUPPORTS1(QuotingOutputStreamListener, nsIStreamListener)
|
|||
// END OF QUOTING LISTENER
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* readonly attribute MSG_ComposeType type; */
|
||||
/* attribute MSG_ComposeType type; */
|
||||
NS_IMETHODIMP nsMsgCompose::SetType(MSG_ComposeType aType)
|
||||
{
|
||||
|
||||
mType = aType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgCompose::GetType(MSG_ComposeType *aType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aType);
|
||||
|
@ -1813,6 +1826,11 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS
|
|||
// windows hanging around to prevent the app from exiting.
|
||||
}
|
||||
|
||||
// Remove the current draft msg when sending draft is done.
|
||||
MSG_ComposeType compType = nsIMsgCompType::Draft;
|
||||
compose->GetType(&compType);
|
||||
if (compType == nsIMsgCompType::Draft)
|
||||
RemoveCurrentDraftMessage(compose, PR_FALSE);
|
||||
NS_IF_RELEASE(compFields);
|
||||
}
|
||||
else
|
||||
|
@ -1834,7 +1852,7 @@ nsMsgComposeSendListener::OnGetDraftFolderURI(const char *aFolderURI)
|
|||
{
|
||||
nsCOMPtr<nsIMsgCompose>compose = do_QueryReferent(mWeakComposeObj);
|
||||
if (compose)
|
||||
compose->SetSavedFoldeURI(aFolderURI);
|
||||
compose->SetSavedFolderURI(aFolderURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1887,6 +1905,15 @@ nsMsgComposeSendListener::OnStopCopy(nsresult aStatus)
|
|||
if ( (mDeliverMode != nsIMsgSend::nsMsgSaveAsDraft) &&
|
||||
(mDeliverMode != nsIMsgSend::nsMsgSaveAsTemplate) )
|
||||
compose->CloseWindow();
|
||||
else
|
||||
if (mDeliverMode == nsIMsgSend::nsMsgSaveAsDraft)
|
||||
{
|
||||
// Remove the current draft msg when saving to draft is done. Also,
|
||||
// if it was a NEW comp type, it's now DRAFT comp type. Otherwise
|
||||
// if the msg is then sent we won't be able to remove the saved msg.
|
||||
compose->SetType(nsIMsgCompType::Draft);
|
||||
RemoveCurrentDraftMessage(compose, PR_TRUE);
|
||||
}
|
||||
}
|
||||
#ifdef NS_DEBUG
|
||||
else
|
||||
|
@ -1897,6 +1924,99 @@ nsMsgComposeSendListener::OnStopCopy(nsresult aStatus)
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgComposeSendListener::RemoveCurrentDraftMessage(nsIMsgCompose *compObj, PRBool calledByCopy)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIMsgCompFields> compFields = nsnull;
|
||||
|
||||
rv = compObj->GetCompFields(getter_AddRefs(compFields));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't get compose fields");
|
||||
if (NS_FAILED(rv) || !compFields)
|
||||
return rv;
|
||||
|
||||
nsXPIDLCString curDraftIdURL;
|
||||
nsMsgKey newUid = 0;
|
||||
nsXPIDLCString newDraftIdURL;
|
||||
nsCOMPtr<nsIMsgFolder> msgFolder;
|
||||
|
||||
rv = compFields->GetDraftId(getter_Copies(curDraftIdURL));
|
||||
NS_ASSERTION((NS_SUCCEEDED(rv) && (curDraftIdURL)), "RemoveCurrentDraftMessage can't get draft id");
|
||||
|
||||
// Skip if no draft id (probably a new draft msg).
|
||||
if (NS_SUCCEEDED(rv) && curDraftIdURL.get() && nsCRT::strlen(curDraftIdURL.get()))
|
||||
{
|
||||
nsCOMPtr <nsIMsgDBHdr> msgDBHdr;
|
||||
rv = GetMsgDBHdrFromURI(curDraftIdURL, getter_AddRefs(msgDBHdr));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't get msg header DB interface pointer.");
|
||||
if (NS_SUCCEEDED(rv) && msgDBHdr)
|
||||
{ // get the folder for the message resource
|
||||
msgDBHdr->GetFolder(getter_AddRefs(msgFolder));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't get msg folder interface pointer.");
|
||||
if (NS_SUCCEEDED(rv) && msgFolder)
|
||||
{ // build the msg arrary
|
||||
nsCOMPtr<nsISupportsArray> messageArray;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(messageArray));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't allocate support array.");
|
||||
|
||||
//nsCOMPtr<nsISupports> msgSupport = do_QueryInterface(msgDBHdr, &rv);
|
||||
//NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't get msg header interface pointer.");
|
||||
if (NS_SUCCEEDED(rv) && messageArray)
|
||||
{ // ready to delete the msg
|
||||
rv = messageArray->AppendElement(msgDBHdr);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't append msg header to array.");
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = msgFolder->DeleteMessages(messageArray, nsnull, PR_TRUE, PR_FALSE, nsnull);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't delete message.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Now get the new uid so that next save will remove the right msg
|
||||
// regardless whether or not the exiting msg can be deleted.
|
||||
if (calledByCopy)
|
||||
{
|
||||
nsCOMPtr<nsIMsgSend> msgSend;
|
||||
rv = compObj->GetMessageSend(getter_AddRefs(msgSend));
|
||||
NS_ASSERTION(msgSend, "RemoveCurrentDraftMessage msgSend is null.");
|
||||
if (NS_FAILED(rv) || !msgSend)
|
||||
return rv;
|
||||
|
||||
rv = msgSend->GetMessageKey(&newUid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Make sure we have a folder interface pointer
|
||||
if (!msgFolder)
|
||||
{
|
||||
nsXPIDLCString folderUri;
|
||||
rv = compObj->GetSavedFolderURI(getter_Copies(folderUri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRDFService> rdfService (do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr <nsIRDFResource> resource;
|
||||
rv = rdfService->GetResource(folderUri, getter_AddRefs(resource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
msgFolder = do_QueryInterface(resource, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Reset draft (uid) url with the new uid.
|
||||
if (msgFolder && newUid)
|
||||
{
|
||||
rv = msgFolder->GenerateMessageURI(newUid, getter_Copies(newDraftIdURL));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
compFields->SetDraftId(newDraftIdURL.get());
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgComposeSendListener::SetMessageKey(PRUint32 aMessageKey)
|
||||
{
|
||||
|
@ -2457,7 +2577,7 @@ static nsresult OpenAddressBook(const char * dbUri, nsIAddrDatabase** aDatabase,
|
|||
if (addresBook)
|
||||
rv = addresBook->GetAbDatabaseFromURI(dbUri, aDatabase);
|
||||
|
||||
nsCOMPtr<nsIRDFService> rdfService (do_GetService(kRDFServiceCID, &rv));
|
||||
nsCOMPtr<nsIRDFService> rdfService (do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -2478,7 +2598,7 @@ nsresult nsMsgCompose::GetABDirectories(const char * dirUri, nsISupportsArray* d
|
|||
collectedAddressbookFound = PR_FALSE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIRDFService> rdfService (do_GetService(kRDFServiceCID, &rv));
|
||||
nsCOMPtr<nsIRDFService> rdfService (do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr <nsIRDFResource> resource;
|
||||
|
|
|
@ -184,6 +184,8 @@ public:
|
|||
// nsIWebProgressListener interface
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
nsresult RemoveCurrentDraftMessage(nsIMsgCompose *compObj, PRBool calledByCopy);
|
||||
|
||||
private:
|
||||
nsWeakPtr mWeakComposeObj;
|
||||
MSG_DeliverMode mDeliverMode;
|
||||
|
|
|
@ -3236,6 +3236,13 @@ nsMsgComposeAndSend::SetMessageKey(PRUint32 aMessageKey)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgComposeAndSend::GetMessageKey(PRUint32 *aMessageKey)
|
||||
{
|
||||
*aMessageKey = m_messageKey;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgComposeAndSend::GetMessageId(nsCString* aMessageId)
|
||||
{
|
||||
|
|
|
@ -4801,6 +4801,9 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec,
|
|||
command = "SEARCH SEEN HEADER Message-ID ";
|
||||
command.Append(messageId);
|
||||
|
||||
// Clean up result sequence before issuing the cmd.
|
||||
GetServerStateParser().ResetSearchResultSequence();
|
||||
|
||||
Search(command, PR_TRUE, PR_FALSE);
|
||||
if (GetServerStateParser().LastCommandSuccessful())
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче