diff options
author | Matt A. Tobin <email@mattatobin.com> | 2019-11-11 00:00:30 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2019-11-11 00:00:30 -0500 |
commit | 31fea2bc2b99c1c5008a41c02c78f921d3fa1c62 (patch) | |
tree | 87c6436ad39590985f175cba9f3b7c0d64c3bbad /mailnews/db/msgdb/src/nsMsgDatabase.cpp | |
parent | 3d9db9cb381f7e4461708d844cc958cb65a04e56 (diff) | |
download | UXP-31fea2bc2b99c1c5008a41c02c78f921d3fa1c62.tar UXP-31fea2bc2b99c1c5008a41c02c78f921d3fa1c62.tar.gz UXP-31fea2bc2b99c1c5008a41c02c78f921d3fa1c62.tar.lz UXP-31fea2bc2b99c1c5008a41c02c78f921d3fa1c62.tar.xz UXP-31fea2bc2b99c1c5008a41c02c78f921d3fa1c62.zip |
Bug 1508054 - reduce exposed API of nsMsgHdr.
Tag #1273
Diffstat (limited to 'mailnews/db/msgdb/src/nsMsgDatabase.cpp')
-rw-r--r-- | mailnews/db/msgdb/src/nsMsgDatabase.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mailnews/db/msgdb/src/nsMsgDatabase.cpp index 0b422b31d..31da7bc5e 100644 --- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -2029,14 +2029,14 @@ NS_IMETHODIMP nsMsgDatabase::DeleteHeader(nsIMsgDBHdr *msg, nsIDBChangeListener NS_IMETHODIMP nsMsgDatabase::UndoDelete(nsIMsgDBHdr *aMsgHdr) { - if (aMsgHdr) - { - nsMsgHdr* msgHdr = static_cast<nsMsgHdr*>(aMsgHdr); // closed system, so this is ok - // force deleted flag, so SetHdrFlag won't bail out because deleted flag isn't set - msgHdr->m_flags |= nsMsgMessageFlags::Expunged; - SetHdrFlag(msgHdr, false, nsMsgMessageFlags::Expunged); // clear deleted flag in db - } - return NS_OK; + if (aMsgHdr) + { + // Force deleted flag, so SetHdrFlag won't bail out because deleted flag isn't set. + uint32_t result; + aMsgHdr->OrFlags(nsMsgMessageFlags::Expunged, &result); + SetHdrFlag(aMsgHdr, false, nsMsgMessageFlags::Expunged); // Clear deleted flag in db. + } + return NS_OK; } nsresult nsMsgDatabase::RemoveHeaderFromThread(nsMsgHdr *msgHdr) @@ -2080,7 +2080,7 @@ nsresult nsMsgDatabase::RemoveHeaderFromDB(nsMsgHdr *msgHdr) ret = m_mdbAllMsgHeadersTable->CutRow(GetEnv(), row); row->CutAllColumns(GetEnv()); } - msgHdr->m_initedValues = 0; // invalidate cached values. + msgHdr->ClearCachedValues(); return ret; } @@ -3497,8 +3497,10 @@ NS_IMETHODIMP nsMsgDatabase::AddNewHdrToDB(nsIMsgDBHdr *newHdr, bool notify) NS_ENSURE_ARG_POINTER(newHdr); nsMsgHdr* hdr = static_cast<nsMsgHdr*>(newHdr); // closed system, cast ok bool newThread; - bool hasKey; - ContainsKey(hdr->m_messageKey, &hasKey); + bool hasKey = false; + nsMsgKey msgKey = nsMsgKey_None; + (void)hdr->GetMessageKey(&msgKey); + (void)ContainsKey(msgKey, &hasKey); if (hasKey) { NS_ERROR("adding hdr that already exists"); @@ -3573,7 +3575,7 @@ NS_IMETHODIMP nsMsgDatabase::CopyHdrFromExistingHdr(nsMsgKey key, nsIMsgDBHdr *e { // we may have gotten the header from a cache - calling SetRow // basically invalidates any cached values, so invalidate them. - destMsgHdr->m_initedValues = 0; + destMsgHdr->ClearCachedValues(); if(addHdrToDB) err = AddNewHdrToDB(destMsgHdr, true); if (NS_SUCCEEDED(err) && newHdr) @@ -4831,7 +4833,8 @@ nsresult nsMsgDatabase::AddNewThread(nsMsgHdr *msgHdr) nsMsgThread *threadHdr = nullptr; nsCString subject; - nsMsgKey threadKey = msgHdr->m_messageKey; + nsMsgKey threadKey; + msgHdr->GetMessageKey(&threadKey); // can't have a thread with key 1 since that's the table id of the all msg hdr table, // so give it kTableKeyForThreadOne (0xfffffffe). if (threadKey == kAllMsgHdrsTableKey) @@ -5060,9 +5063,8 @@ nsresult nsMsgDatabase::DumpContents() keys->GetLength(&numKeys); for (i = 0; i < numKeys; i++) { key = keys->m_keys[i]; - nsIMsgDBHdr *msg = NULL; - rv = GetMsgHdrForKey(key, &msg); - nsMsgHdr* msgHdr = static_cast<nsMsgHdr*>(msg); // closed system, cast ok + nsCOMPtr<nsIMsgDBHdr> msgHdr; + rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr)); if (NS_SUCCEEDED(rv)) { nsCString author; @@ -5072,7 +5074,6 @@ nsresult nsMsgDatabase::DumpContents() msgHdr->GetAuthor(getter_Copies(author)); msgHdr->GetSubject(getter_Copies(subject)); printf("hdr key = %u, author = %s subject = %s\n", key, author.get(), subject.get()); - NS_RELEASE(msgHdr); } } nsTArray<nsMsgKey> threads; @@ -5867,24 +5868,25 @@ nsMsgDatabase::UpdateHdrInCache(const char *aSearchFolderUri, nsIMsgDBHdr *aHdr, nsresult err = GetSearchResultsTable(aSearchFolderUri, true, getter_AddRefs(table)); NS_ENSURE_SUCCESS(err, err); nsMsgKey key; - aHdr->GetMessageKey(&key); + err = aHdr->GetMessageKey(&key); nsMsgHdr* msgHdr = static_cast<nsMsgHdr*>(aHdr); // closed system, so this is ok - if (NS_SUCCEEDED(err) && m_mdbStore && msgHdr->m_mdbRow) + nsIMdbRow* hdrRow = msgHdr->GetMDBRow(); + if (NS_SUCCEEDED(err) && m_mdbStore && hdrRow) { if (!aAdd) { - table->CutRow(m_mdbEnv, msgHdr->m_mdbRow); + table->CutRow(m_mdbEnv, hdrRow); } else { mdbOid rowId; - msgHdr->m_mdbRow->GetOid(m_mdbEnv, &rowId); + hdrRow->GetOid(m_mdbEnv, &rowId); mdb_pos insertPos = FindInsertIndexInSortedTable(table, rowId.mOid_Id); uint32_t rowCount; table->GetCount(m_mdbEnv, &rowCount); - table->AddRow(m_mdbEnv, msgHdr->m_mdbRow); + table->AddRow(m_mdbEnv, hdrRow); mdb_pos newPos; - table->MoveRow(m_mdbEnv, msgHdr->m_mdbRow, rowCount, insertPos, &newPos); + table->MoveRow(m_mdbEnv, hdrRow, rowCount, insertPos, &newPos); } } |