fix unused var warnings in nsMsgThread.cpp, patch by gautheri@noos.fr, r/sr=me, 217089

This commit is contained in:
bienvenu%nventure.com 2004-05-03 13:55:37 +00:00
Родитель 3d5ea95a77
Коммит 304a7fcba3
1 изменённых файлов: 34 добавлений и 58 удалений

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

@ -125,14 +125,12 @@ nsresult nsMsgThread::InitCachedValues()
NS_IMETHODIMP nsMsgThread::SetThreadKey(nsMsgKey threadKey) NS_IMETHODIMP nsMsgThread::SetThreadKey(nsMsgKey threadKey)
{ {
nsresult ret = NS_OK;
m_threadKey = threadKey; m_threadKey = threadKey;
// by definition, the initial thread key is also the thread root key. // by definition, the initial thread key is also the thread root key.
SetThreadRootKey(threadKey); SetThreadRootKey(threadKey);
ret = m_mdbDB->UInt32ToRowCellColumn(m_metaRow, m_mdbDB->m_threadIdColumnToken, threadKey);
// gotta set column in meta row here. // gotta set column in meta row here.
return ret; return m_mdbDB->UInt32ToRowCellColumn(
m_metaRow, m_mdbDB->m_threadIdColumnToken, threadKey);
} }
NS_IMETHODIMP nsMsgThread::GetThreadKey(nsMsgKey *result) NS_IMETHODIMP nsMsgThread::GetThreadKey(nsMsgKey *result)
@ -161,11 +159,9 @@ NS_IMETHODIMP nsMsgThread::GetFlags(PRUint32 *result)
NS_IMETHODIMP nsMsgThread::SetFlags(PRUint32 flags) NS_IMETHODIMP nsMsgThread::SetFlags(PRUint32 flags)
{ {
nsresult ret = NS_OK;
m_flags = flags; m_flags = flags;
ret = m_mdbDB->UInt32ToRowCellColumn(m_metaRow, m_mdbDB->m_threadFlagsColumnToken, m_flags); return m_mdbDB->UInt32ToRowCellColumn(
return ret; m_metaRow, m_mdbDB->m_threadFlagsColumnToken, m_flags);
} }
NS_IMETHODIMP nsMsgThread::SetSubject(const char *subject) NS_IMETHODIMP nsMsgThread::SetSubject(const char *subject)
@ -177,8 +173,8 @@ NS_IMETHODIMP nsMsgThread::GetSubject(char **result)
{ {
if (!result) if (!result)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
nsresult ret = m_mdbDB->RowCellColumnToCharPtr(m_metaRow, m_mdbDB->m_threadSubjectColumnToken, result); return m_mdbDB->RowCellColumnToCharPtr(
return ret; m_metaRow, m_mdbDB->m_threadSubjectColumnToken, result);
} }
NS_IMETHODIMP nsMsgThread::GetNumChildren(PRUint32 *result) NS_IMETHODIMP nsMsgThread::GetNumChildren(PRUint32 *result)
@ -409,11 +405,11 @@ nsresult nsMsgThread::ReparentNonReferenceChildrenOf(nsIMsgDBHdr *topLevelHdr, n
NS_IMETHODIMP nsMsgThread::GetChildKeyAt(PRInt32 aIndex, nsMsgKey *result) NS_IMETHODIMP nsMsgThread::GetChildKeyAt(PRInt32 aIndex, nsMsgKey *result)
{ {
nsresult ret = NS_OK; nsresult ret;
mdbOid oid;
mdbOid oid;
ret = m_mdbTable->PosToOid( m_mdbDB->GetEnv(), aIndex, &oid); ret = m_mdbTable->PosToOid( m_mdbDB->GetEnv(), aIndex, &oid);
if (ret == 0) if (NS_SUCCEEDED(ret))
*result = oid.mOid_Id; *result = oid.mOid_Id;
return ret; return ret;
@ -421,13 +417,13 @@ NS_IMETHODIMP nsMsgThread::GetChildKeyAt(PRInt32 aIndex, nsMsgKey *result)
NS_IMETHODIMP nsMsgThread::GetChildAt(PRInt32 aIndex, nsIMsgDBHdr **result) NS_IMETHODIMP nsMsgThread::GetChildAt(PRInt32 aIndex, nsIMsgDBHdr **result)
{ {
nsresult ret = NS_OK; nsresult ret;
mdbOid oid; mdbOid oid;
nsIMdbRow *hdrRow = nsnull;
ret = m_mdbTable->PosToOid( m_mdbDB->GetEnv(), aIndex, &oid); ret = m_mdbTable->PosToOid( m_mdbDB->GetEnv(), aIndex, &oid);
if (ret == NS_OK) if (NS_SUCCEEDED(ret))
{ {
nsIMdbRow *hdrRow = nsnull;
//do I have to release hdrRow? //do I have to release hdrRow?
ret = m_mdbTable->PosToRow(m_mdbDB->GetEnv(), aIndex, &hdrRow); ret = m_mdbTable->PosToRow(m_mdbDB->GetEnv(), aIndex, &hdrRow);
if(NS_SUCCEEDED(ret) && hdrRow) if(NS_SUCCEEDED(ret) && hdrRow)
@ -436,17 +432,17 @@ NS_IMETHODIMP nsMsgThread::GetChildAt(PRInt32 aIndex, nsIMsgDBHdr **result)
} }
} }
return (ret == NS_OK) ? NS_OK : NS_MSG_MESSAGE_NOT_FOUND; return (NS_SUCCEEDED(ret)) ? NS_OK : NS_MSG_MESSAGE_NOT_FOUND;
} }
NS_IMETHODIMP nsMsgThread::GetChild(nsMsgKey msgKey, nsIMsgDBHdr **result) NS_IMETHODIMP nsMsgThread::GetChild(nsMsgKey msgKey, nsIMsgDBHdr **result)
{ {
nsresult ret = NS_OK; nsresult ret;
mdb_bool hasOid; mdb_bool hasOid;
mdbOid rowObjectId; mdbOid rowObjectId;
if (!result || !m_mdbTable) if (!result || !m_mdbTable)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -458,18 +454,20 @@ NS_IMETHODIMP nsMsgThread::GetChild(nsMsgKey msgKey, nsIMsgDBHdr **result)
{ {
nsIMdbRow *hdrRow = nsnull; nsIMdbRow *hdrRow = nsnull;
ret = m_mdbDB->m_mdbStore->GetRow(m_mdbDB->GetEnv(), &rowObjectId, &hdrRow); ret = m_mdbDB->m_mdbStore->GetRow(m_mdbDB->GetEnv(), &rowObjectId, &hdrRow);
if (ret == NS_OK && hdrRow && m_mdbDB) if (NS_SUCCEEDED(ret) && hdrRow && m_mdbDB)
{ {
ret = m_mdbDB->CreateMsgHdr(hdrRow, msgKey, result); ret = m_mdbDB->CreateMsgHdr(hdrRow, msgKey, result);
} }
} }
return ret; return ret;
} }
NS_IMETHODIMP nsMsgThread::GetChildHdrAt(PRInt32 aIndex, nsIMsgDBHdr **result) NS_IMETHODIMP nsMsgThread::GetChildHdrAt(PRInt32 aIndex, nsIMsgDBHdr **result)
{ {
nsresult ret = NS_OK; nsresult ret;
nsIMdbRow* resultRow; nsIMdbRow* resultRow;
mdb_pos pos = aIndex - 1; mdb_pos pos = aIndex - 1;
@ -484,8 +482,8 @@ NS_IMETHODIMP nsMsgThread::GetChildHdrAt(PRInt32 aIndex, nsIMsgDBHdr **result)
nsIMdbTableRowCursor *rowCursor; nsIMdbTableRowCursor *rowCursor;
ret = m_mdbTable->GetTableRowCursor(m_mdbDB->GetEnv(), pos, &rowCursor); ret = m_mdbTable->GetTableRowCursor(m_mdbDB->GetEnv(), pos, &rowCursor);
if (ret != 0) if (NS_FAILED(ret))
return NS_ERROR_FAILURE; return ret;
ret = rowCursor->NextRow(m_mdbDB->GetEnv(), &resultRow, &pos); ret = rowCursor->NextRow(m_mdbDB->GetEnv(), &resultRow, &pos);
NS_RELEASE(rowCursor); NS_RELEASE(rowCursor);
@ -498,24 +496,20 @@ NS_IMETHODIMP nsMsgThread::GetChildHdrAt(PRInt32 aIndex, nsIMsgDBHdr **result)
if (resultRow->GetOid(m_mdbDB->GetEnv(), &outOid) == NS_OK) if (resultRow->GetOid(m_mdbDB->GetEnv(), &outOid) == NS_OK)
key = outOid.mOid_Id; key = outOid.mOid_Id;
ret = m_mdbDB->CreateMsgHdr(resultRow, key, result); return m_mdbDB->CreateMsgHdr(resultRow, key, result);
if (NS_FAILED(ret))
return ret;
return ret;
} }
NS_IMETHODIMP nsMsgThread::RemoveChildAt(PRInt32 aIndex) NS_IMETHODIMP nsMsgThread::RemoveChildAt(PRInt32 aIndex)
{ {
nsresult ret = NS_OK; return NS_OK;
return ret;
} }
nsresult nsMsgThread::RemoveChild(nsMsgKey msgKey) nsresult nsMsgThread::RemoveChild(nsMsgKey msgKey)
{ {
nsresult ret = NS_OK; nsresult ret;
mdbOid rowObjectId; mdbOid rowObjectId;
rowObjectId.mOid_Id = msgKey; rowObjectId.mOid_Id = msgKey;
rowObjectId.mOid_Scope = m_mdbDB->m_hdrRowScopeToken; rowObjectId.mOid_Scope = m_mdbDB->m_hdrRowScopeToken;
@ -608,14 +602,8 @@ nsresult nsMsgThread::ReparentChildrenOf(nsMsgKey oldParent, nsMsgKey newParent,
NS_IMETHODIMP nsMsgThread::MarkChildRead(PRBool bRead) NS_IMETHODIMP nsMsgThread::MarkChildRead(PRBool bRead)
{ {
nsresult ret = NS_OK; ChangeUnreadChildCount(bRead ? -1 : 1);
return NS_OK;
if(bRead)
ChangeUnreadChildCount(-1);
else
ChangeUnreadChildCount(1);
return ret;
} }
class nsMsgThreadEnumerator : public nsISimpleEnumerator { class nsMsgThreadEnumerator : public nsISimpleEnumerator {
@ -866,28 +854,15 @@ NS_IMETHODIMP nsMsgThreadEnumerator::HasMoreElements(PRBool *aResult)
return NS_OK; return NS_OK;
} }
static nsresult
nsMsgThreadUnreadFilter(nsIMsgDBHdr* msg, void* closure)
{
nsMsgDatabase* db = (nsMsgDatabase*)closure;
PRBool wasRead = PR_TRUE;
nsresult rv = db->IsHeaderRead(msg, &wasRead);
if (NS_FAILED(rv))
return rv;
return !wasRead ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMsgThread::EnumerateMessages(nsMsgKey parentKey, nsISimpleEnumerator* *result) NS_IMETHODIMP nsMsgThread::EnumerateMessages(nsMsgKey parentKey, nsISimpleEnumerator* *result)
{ {
nsresult ret = NS_OK;
nsMsgThreadEnumerator* e = new nsMsgThreadEnumerator(this, parentKey, nsnull, nsnull); nsMsgThreadEnumerator* e = new nsMsgThreadEnumerator(this, parentKey, nsnull, nsnull);
if (e == nsnull) if (e == nsnull)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(e); NS_ADDREF(e);
*result = e; *result = e;
return NS_OK;
return ret; return NS_OK;
} }
nsresult nsMsgThread::ReparentMsgsWithInvalidParent(PRUint32 numChildren, nsMsgKey threadParentKey) nsresult nsMsgThread::ReparentMsgsWithInvalidParent(PRUint32 numChildren, nsMsgKey threadParentKey)
@ -919,7 +894,6 @@ nsresult nsMsgThread::ReparentMsgsWithInvalidParent(PRUint32 numChildren, nsMsgK
NS_IMETHODIMP nsMsgThread::GetRootHdr(PRInt32 *resultIndex, nsIMsgDBHdr **result) NS_IMETHODIMP nsMsgThread::GetRootHdr(PRInt32 *resultIndex, nsIMsgDBHdr **result)
{ {
nsresult ret;
if (!result) if (!result)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
@ -927,7 +901,7 @@ NS_IMETHODIMP nsMsgThread::GetRootHdr(PRInt32 *resultIndex, nsIMsgDBHdr **result
if (m_threadRootKey != nsMsgKey_None) if (m_threadRootKey != nsMsgKey_None)
{ {
ret = GetChildHdrForKey(m_threadRootKey, result, resultIndex); nsresult ret = GetChildHdrForKey(m_threadRootKey, result, resultIndex);
if (NS_SUCCEEDED(ret) && *result) if (NS_SUCCEEDED(ret) && *result)
return ret; return ret;
else else
@ -976,7 +950,8 @@ NS_IMETHODIMP nsMsgThread::GetRootHdr(PRInt32 *resultIndex, nsIMsgDBHdr **result
nsresult nsMsgThread::ChangeChildCount(PRInt32 delta) nsresult nsMsgThread::ChangeChildCount(PRInt32 delta)
{ {
nsresult ret = NS_OK; nsresult ret;
PRUint32 childCount = 0; PRUint32 childCount = 0;
m_mdbDB->RowCellColumnToUInt32(m_metaRow, m_mdbDB->m_threadChildrenColumnToken, childCount); m_mdbDB->RowCellColumnToUInt32(m_metaRow, m_mdbDB->m_threadChildrenColumnToken, childCount);
@ -994,7 +969,8 @@ nsresult nsMsgThread::ChangeChildCount(PRInt32 delta)
nsresult nsMsgThread::ChangeUnreadChildCount(PRInt32 delta) nsresult nsMsgThread::ChangeUnreadChildCount(PRInt32 delta)
{ {
nsresult ret = NS_OK; nsresult ret;
PRUint32 childCount = 0; PRUint32 childCount = 0;
m_mdbDB->RowCellColumnToUInt32(m_metaRow, m_mdbDB->m_threadUnreadChildrenColumnToken, childCount); m_mdbDB->RowCellColumnToUInt32(m_metaRow, m_mdbDB->m_threadUnreadChildrenColumnToken, childCount);
childCount += delta; childCount += delta;