138342 r=cavin sr=bienvenu fixing undo of moving msgs from imap to local

This commit is contained in:
naving%netscape.com 2002-05-14 23:18:33 +00:00
Родитель df3886396d
Коммит 4d96ee8438
1 изменённых файлов: 18 добавлений и 6 удалений

Просмотреть файл

@ -105,17 +105,29 @@ nsMsgTxn::SetTransactionType(PRUint32 txnType)
return NS_OK;
}
//none of the callers pass null aFolder
/*none of the callers pass null aFolder,
we always initialize aResult (before we pass in) for the case where the key is not in the db*/
nsresult
nsMsgTxn::CheckForToggleDelete(nsIMsgFolder *aFolder, const nsMsgKey &aMsgKey, PRBool *aResult)
{
nsresult rv;
NS_ENSURE_ARG(aResult);
nsCOMPtr<nsIMsgDBHdr> message;
nsresult rv = aFolder->GetMessageHeader(aMsgKey, getter_AddRefs(message));
PRUint32 flags;
if (NS_SUCCEEDED(rv) && message)
nsCOMPtr<nsIMsgDatabase> db;
aFolder->GetMsgDatabase(nsnull,getter_AddRefs(db));
if (db)
{
message->GetFlags(&flags);
*aResult = (flags & MSG_FLAG_IMAP_DELETED) != 0;
PRBool containsKey;
rv = db->ContainsKey(aMsgKey, &containsKey);
if (NS_FAILED(rv) || !containsKey) // the message has been deleted from db, so we cannot do toggle here
return NS_OK;
rv = db->GetMsgHdrForKey(aMsgKey, getter_AddRefs(message));
PRUint32 flags;
if (NS_SUCCEEDED(rv) && message)
{
message->GetFlags(&flags);
*aResult = (flags & MSG_FLAG_IMAP_DELETED) != 0;
}
}
return rv;
}