Closed Bug 433405 Opened 18 years ago Closed 18 years ago

itemAdded event not called when a message is sent or draft is saved

Categories

(MailNews Core :: Backend, defect)

defect
Not set
minor

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9

People

(Reporter: rain1, Assigned: rain1)

References

Details

Attachments

(1 file, 1 obsolete file)

(local folders) Whenever a message is sent or a draft is saved, only nsIMsgFolderListener::itemMoveCopyCompleted() is called, not itemAdded(). itemAdded() should be called, because a new message has been added to the database. Both these use the CopyFileMessage() function to copy messages from a temporary file into the local folder. All that needs to be done is to put in a simple check in nsMsgLocalMailFolder::EndCopy() to call itemAdded() after itemDeleted(), when the CopyFileMessage() function is used. Reproducible: Always
Attachment #320602 - Flags: superreview?(bienvenu)
Attachment #320602 - Flags: review?(bienvenu)
Status: NEW → ASSIGNED
Comment on attachment 320602 [details] [diff] [review] patch to call itemAdded in EndCopy() a couple nits: + PRBool isCopyFileMessage = (mCopyState->m_message) ? PR_FALSE : PR_TRUE; you can just say PRBool isCopyFileMessage = ! mCopyState->m_message; and here, can you move the brace down on its own line, like the rest of the file? + if (isCopyFileMessage) { but other than that, it looks good.
Attachment #320602 - Flags: superreview?(bienvenu)
Attachment #320602 - Flags: superreview+
Attachment #320602 - Flags: review?(bienvenu)
Attachment #320602 - Flags: review+
Comment on attachment 320602 [details] [diff] [review] patch to call itemAdded in EndCopy() Index: mailnews/local/src/nsLocalMailFolder.cpp =================================================================== RCS file: /cvsroot/mozilla/mailnews/local/src/nsLocalMailFolder.cpp,v retrieving revision 1.578 diff -u -8 -p -r1.578 nsLocalMailFolder.cpp --- mailnews/local/src/nsLocalMailFolder.cpp 8 May 2008 19:05:56 -0000 1.578 +++ mailnews/local/src/nsLocalMailFolder.cpp 14 May 2008 21:58:03 -0000 @@ -2462,21 +2462,21 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndC { PRUint32 bytesWritten; seekableStream->Seek(nsISeekableStream::NS_SEEK_END, 0); mCopyState->m_fileStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &bytesWritten); if (mCopyState->m_parseMsgState) mCopyState->m_parseMsgState->ParseAFolderLine(CRLF, MSG_LINEBREAK_LEN); } + nsCOMPtr<nsIMsgDBHdr> newHdr; // CopyFileMessage() and CopyMessages() from servers other than mailbox if (mCopyState->m_parseMsgState) { nsCOMPtr<nsIMsgDatabase> msgDb; - nsCOMPtr<nsIMsgDBHdr> newHdr; mCopyState->m_parseMsgState->FinishHeader(); GetDatabaseWOReparse(getter_AddRefs(msgDb)); if (msgDb) { nsresult result = mCopyState->m_parseMsgState->GetNewMsgHdr(getter_AddRefs(newHdr)); if (NS_SUCCEEDED(result) && newHdr) { // need to copy junk score and label from mCopyState->m_message to newHdr. @@ -2559,16 +2559,18 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndC { PRBool hasListeners; notifier->GetHasListeners(&hasListeners); if (hasListeners) notifier->NotifyItemMoveCopyCompleted(mCopyState->m_isMove, mCopyState->m_messages, this); } } + // Store whether the message is CopyMessages() or CopyFileMessage() + PRBool isCopyFileMessage = ! mCopyState->m_message; if(!mCopyState->m_isMove) { if (multipleCopiesFinished) { nsCOMPtr<nsIMsgFolder> srcFolder; srcFolder = do_QueryInterface(mCopyState->m_srcSupport); if (mCopyState->m_isFolder) CopyAllSubFolders(srcFolder, nsnull, nsnull); //Copy all subfolders then notify completion @@ -2583,16 +2585,23 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndC if (srcFolder && !mCopyState->m_isFolder) srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom); (void) OnCopyCompleted(mCopyState->m_srcSupport, PR_TRUE); // enable the dest folder EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_FALSE /*dbBatching*/); //dest folder doesn't need db batching } } + // if CopyFileMessage() then notify that an item has been added + if (isCopyFileMessage) + { + nsCOMPtr <nsIMsgFolderNotificationService> notifier = do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID); + if (notifier) + notifier->NotifyItemAdded(newHdr); + } } return rv; } static PRBool gGotGlobalPrefs; static PRBool gDeleteFromServerOnMove; PRBool nsMsgLocalMailFolder::GetDeleteFromServerOnMove()
Updated patch, continuing r/sr+ from bienvenu. (and sorry for the whole comment with the new patch, I'm just a bugzilla n00b. Lesson learned.)
Attachment #320602 - Attachment is obsolete: true
Attachment #320991 - Flags: superreview+
Attachment #320991 - Flags: review+
Keywords: checkin-needed
Checking in mailnews/local/src/nsLocalMailFolder.cpp; /cvsroot/mozilla/mailnews/local/src/nsLocalMailFolder.cpp,v <-- nsLocalMailFolder.cpp new revision: 1.579; previous revision: 1.578 done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: