зеркало из https://github.com/mozilla/gecko-dev.git
add idl files for change listener and announcer
This commit is contained in:
Родитель
a3b121f531
Коммит
fcb9a5a95c
|
@ -23,5 +23,4 @@ nsImapMailDatabase.h
|
|||
nsNewsDatabase.h
|
||||
nsDBFolderInfo.h
|
||||
nsMsgHdr.h
|
||||
nsIDBChangeListener.h
|
||||
nsMsgThread.h
|
||||
|
|
|
@ -32,12 +32,13 @@ EXPORTS= \
|
|||
nsImapMailDatabase.h \
|
||||
nsNewsDatabase.h \
|
||||
nsDBFolderInfo.h \
|
||||
nsIDBChangeListener.h \
|
||||
nsMsgThread.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIDBFolderInfo.idl \
|
||||
nsIDBChangeListener.idl \
|
||||
nsIDBChangeAnnouncer.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
|
|
@ -20,6 +20,8 @@ MODULE=msgdb
|
|||
|
||||
XPIDLSRCS = \
|
||||
.\nsIDBFolderInfo.idl \
|
||||
.\nsIDBChangeListener.idl \
|
||||
.\nsIDBChangeAnnouncer.idl \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
|
@ -33,8 +35,6 @@ EXPORTS = \
|
|||
nsNewsDatabase.h \
|
||||
nsDBFolderInfo.h \
|
||||
nsMsgHdr.h \
|
||||
nsIDBChangeListener.h \
|
||||
nsIDBFolderInfo.h \
|
||||
nsMsgThread.h \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
// change listener interface
|
||||
#ifndef _nsIDBChangeListener_h
|
||||
#define _nsIDBChangeListener_h
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_IDBCHANGELISTENER_IID \
|
||||
{ 0xad0f7f90, 0xbaff, 0x11d2, { 0x8d, 0x67, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0x17}}
|
||||
|
||||
|
||||
class nsIDBChangeListener : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& IID(void) { static nsIID iid = NS_IDBCHANGELISTENER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD OnKeyChange(nsMsgKey aKeyChanged, PRUint32 aOldFlags, PRUint32 aNewFlags,
|
||||
nsIDBChangeListener * aInstigator) = 0;
|
||||
NS_IMETHOD OnKeyDeleted(nsMsgKey aKeyChanged, PRInt32 aFlags,
|
||||
nsIDBChangeListener * aInstigator) = 0;
|
||||
NS_IMETHOD OnKeyAdded(nsMsgKey aKeyChanged, PRInt32 aFlags,
|
||||
nsIDBChangeListener * aInstigator) = 0;
|
||||
NS_IMETHOD OnAnnouncerGoingAway(nsIDBChangeAnnouncer * instigator) = 0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
class nsIMsgDBHdr;
|
||||
class nsIDBChangeListener;
|
||||
|
||||
#include "nsIDBChangeAnnouncer.h"
|
||||
|
||||
class nsIEnumerator;
|
||||
class nsThreadMessageHdr; // XXX where's the public interface to this?
|
||||
class nsMsgKeyArray;
|
||||
|
@ -38,38 +41,6 @@ enum nsMsgDBCommitType {
|
|||
kCompressCommit
|
||||
};
|
||||
|
||||
struct nsMsgHdrStruct {
|
||||
nsMsgKey m_threadId;
|
||||
nsMsgKey m_messageKey;
|
||||
nsString m_subject; // should be nsCString when it's impl
|
||||
nsString m_author; // should be nsCString when it's impl
|
||||
nsString m_messageId; // should be nsCString when it's impl
|
||||
nsString m_references; // should be nsCString when it's impl
|
||||
nsString m_recipients; // should be nsCString when it's impl
|
||||
time_t m_date; // is there some sort of PR type I should use for this?
|
||||
PRUint32 m_messageSize; // lines for news articles, bytes for local mail and imap messages
|
||||
PRUint32 m_flags;
|
||||
PRInt16 m_numChildren; // for top-level threads
|
||||
PRInt16 m_numNewChildren; // for top-level threads
|
||||
nsMsgPriority m_priority;
|
||||
};
|
||||
|
||||
class nsIDBChangeAnnouncer : public nsISupports {
|
||||
public:
|
||||
|
||||
// these 2 calls return NS_OK on success, NS_COMFALSE on failure
|
||||
NS_IMETHOD AddListener(nsIDBChangeListener *listener) = 0;
|
||||
NS_IMETHOD RemoveListener(nsIDBChangeListener *listener) = 0;
|
||||
|
||||
NS_IMETHOD NotifyKeyChangeAll(nsMsgKey keyChanged, PRUint32 aOldFlags, PRUint32 aNewFlags,
|
||||
nsIDBChangeListener *instigator) = 0;
|
||||
NS_IMETHOD NotifyKeyAddedAll(nsMsgKey keyAdded, PRInt32 flags,
|
||||
nsIDBChangeListener *instigator) = 0;
|
||||
NS_IMETHOD NotifyKeyDeletedAll(nsMsgKey keyDeleted, PRInt32 flags,
|
||||
nsIDBChangeListener *instigator) = 0;
|
||||
NS_IMETHOD NotifyAnnouncerGoingAway(void) = 0;
|
||||
};
|
||||
|
||||
class nsIMsgDatabase : public nsIDBChangeAnnouncer {
|
||||
public:
|
||||
// open local folder...
|
||||
|
@ -88,22 +59,12 @@ public:
|
|||
//Returns whether or not this database contains the given key
|
||||
NS_IMETHOD ContainsKey(nsMsgKey key, PRBool *containsKey) = 0;
|
||||
|
||||
// create a new message header from a hdrStruct. Caller must release resulting header,
|
||||
// after adding any extra properties they want.
|
||||
NS_IMETHOD CreateNewHdrAndAddToDB(PRBool *newThread,
|
||||
nsMsgHdrStruct *hdrStruct,
|
||||
nsIMsgDBHdr **newHdr,
|
||||
PRBool notify) = 0;
|
||||
|
||||
// Must call AddNewHdrToDB after creating. The idea is that you create
|
||||
// a new header, fill in its properties, and then call AddNewHdrToDB.
|
||||
// AddNewHdrToDB will send notifications to any listeners.
|
||||
NS_IMETHOD CreateNewHdr(nsMsgKey key, nsIMsgDBHdr **newHdr) = 0;
|
||||
|
||||
NS_IMETHOD AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify) = 0;
|
||||
// extract info from an nsIMsgDBHdr into a nsMsgHdrStruct
|
||||
NS_IMETHOD GetMsgHdrStructFromnsMsgHdr(nsIMsgDBHdr *msgHdr,
|
||||
nsMsgHdrStruct *hdrStruct) = 0;
|
||||
|
||||
NS_IMETHOD CopyHdrFromExistingHdr(nsMsgKey key, nsIMsgDBHdr *existingHdr, nsIMsgDBHdr **newHdr) = 0;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIDBChangeListener.h"
|
||||
#include "nsIDBChangeAnnouncer.h"
|
||||
#include "nsMsgMessageFlags.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsDBFolderInfo.h"
|
||||
|
@ -75,12 +76,6 @@ public:
|
|||
//Returns whether or not this database contains the given key
|
||||
NS_IMETHOD ContainsKey(nsMsgKey key, PRBool *containsKey);
|
||||
|
||||
// create a new message header from a hdrStruct. Caller must release resulting header,
|
||||
// after adding any extra properties they want.
|
||||
NS_IMETHOD CreateNewHdrAndAddToDB(PRBool *newThread,
|
||||
nsMsgHdrStruct *hdrStruct,
|
||||
nsIMsgDBHdr **newHdr,
|
||||
PRBool notify);
|
||||
// Must call AddNewHdrToDB after creating. The idea is that you create
|
||||
// a new header, fill in its properties, and then call AddNewHdrToDB.
|
||||
// AddNewHdrToDB will send notifications to any listeners.
|
||||
|
@ -89,9 +84,6 @@ public:
|
|||
|
||||
NS_IMETHOD CopyHdrFromExistingHdr(nsMsgKey key, nsIMsgDBHdr *existingHdr, nsIMsgDBHdr **newHdr);
|
||||
NS_IMETHOD AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify);
|
||||
// extract info from an nsIMsgDBHdr into a nsMsgHdrStruct
|
||||
NS_IMETHOD GetMsgHdrStructFromnsMsgHdr(nsIMsgDBHdr *msgHdr,
|
||||
nsMsgHdrStruct *hdrStruct);
|
||||
|
||||
#if HAVE_INT_ENUMERATORS
|
||||
NS_IMETHOD EnumerateKeys(nsIEnumerator* *outputKeys);
|
||||
|
|
|
@ -1868,92 +1868,6 @@ NS_IMETHODIMP nsMsgDatabase::AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify)
|
|||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::CreateNewHdrAndAddToDB(PRBool *newThread, nsMsgHdrStruct *hdrStruct,
|
||||
nsIMsgDBHdr **pnewHdr, PRBool notify /* = FALSE */)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
nsIMdbRow *hdrRow;
|
||||
struct mdbOid allMsgHdrsTableOID;
|
||||
|
||||
if (!pnewHdr || !m_mdbAllMsgHeadersTable)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
allMsgHdrsTableOID.mOid_Scope = m_hdrRowScopeToken;
|
||||
allMsgHdrsTableOID.mOid_Id = hdrStruct->m_messageKey;
|
||||
|
||||
err = GetStore()->NewRowWithOid(GetEnv(),
|
||||
&allMsgHdrsTableOID, &hdrRow);
|
||||
|
||||
// add the row to the singleton table.
|
||||
if (NS_SUCCEEDED(err) && hdrRow)
|
||||
{
|
||||
struct mdbYarn yarn;
|
||||
char int32StrBuf[20];
|
||||
|
||||
yarn.mYarn_Grow = NULL;
|
||||
hdrRow->AddColumn(GetEnv(), m_subjectColumnToken, nsStringToYarn(&yarn, &hdrStruct->m_subject));
|
||||
delete[] yarn.mYarn_Buf; // won't need this when we have nsCString
|
||||
|
||||
hdrRow->AddColumn(GetEnv(), m_senderColumnToken, nsStringToYarn(&yarn, &hdrStruct->m_author));
|
||||
delete[] yarn.mYarn_Buf; // won't need this when we have nsCString
|
||||
|
||||
hdrRow->AddColumn(GetEnv(), m_messageIdColumnToken, nsStringToYarn(&yarn, &hdrStruct->m_messageId));
|
||||
delete[] yarn.mYarn_Buf; // won't need this when we have nsCString
|
||||
|
||||
hdrRow->AddColumn(GetEnv(), m_referencesColumnToken, nsStringToYarn(&yarn, &hdrStruct->m_references));
|
||||
delete[] yarn.mYarn_Buf; // won't need this when we have nsCString
|
||||
|
||||
hdrRow->AddColumn(GetEnv(), m_recipientsColumnToken, nsStringToYarn(&yarn, &hdrStruct->m_recipients));
|
||||
delete[] yarn.mYarn_Buf; // won't need this when we have nsCString
|
||||
|
||||
yarn.mYarn_Buf = int32StrBuf;
|
||||
yarn.mYarn_Size = sizeof(int32StrBuf);
|
||||
yarn.mYarn_Fill = sizeof(int32StrBuf);
|
||||
|
||||
hdrRow->AddColumn(GetEnv(), m_dateColumnToken, UInt32ToYarn(&yarn, hdrStruct->m_date));
|
||||
|
||||
hdrRow->AddColumn(GetEnv(), m_messageSizeColumnToken, UInt32ToYarn(&yarn, hdrStruct->m_messageSize));
|
||||
|
||||
hdrRow->AddColumn(GetEnv(), m_flagsColumnToken, UInt32ToYarn(&yarn, hdrStruct->m_flags));
|
||||
|
||||
hdrRow->AddColumn(GetEnv(), m_priorityColumnToken, UInt32ToYarn(&yarn, hdrStruct->m_priority));
|
||||
|
||||
err = m_mdbAllMsgHeadersTable->AddRow(GetEnv(), hdrRow);
|
||||
}
|
||||
if (NS_FAILED(err)) return err;
|
||||
|
||||
err = CreateMsgHdr(hdrRow, hdrStruct->m_messageKey, pnewHdr);
|
||||
if (NS_SUCCEEDED(err))
|
||||
err = AddNewHdrToDB(*pnewHdr, notify);
|
||||
return err;
|
||||
}
|
||||
|
||||
// extract info from an nsMsgHdr into a MessageHdrStruct
|
||||
NS_IMETHODIMP nsMsgDatabase::GetMsgHdrStructFromnsMsgHdr(nsIMsgDBHdr *msg, nsMsgHdrStruct *hdrStruct)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
nsMsgHdr* msgHdr = NS_STATIC_CAST(nsMsgHdr*, msg); // closed system, cast ok
|
||||
|
||||
if (msgHdr)
|
||||
{
|
||||
PRUint32 uint32Value = 0;
|
||||
err = RowCellColumnTonsString(msgHdr->GetMDBRow(), m_subjectColumnToken, hdrStruct->m_subject);
|
||||
err = RowCellColumnTonsString(msgHdr->GetMDBRow(), m_senderColumnToken, hdrStruct->m_author);
|
||||
err = RowCellColumnTonsString(msgHdr->GetMDBRow(), m_messageIdColumnToken, hdrStruct->m_messageId);
|
||||
err = RowCellColumnTonsString(msgHdr->GetMDBRow(), m_referencesColumnToken, hdrStruct->m_references);
|
||||
err = RowCellColumnTonsString(msgHdr->GetMDBRow(), m_recipientsColumnToken, hdrStruct->m_recipients);
|
||||
err = RowCellColumnToUInt32(msgHdr->GetMDBRow(), m_messageSizeColumnToken, &hdrStruct->m_messageSize);
|
||||
err = RowCellColumnToUInt32(msgHdr->GetMDBRow(), m_flagsColumnToken, &hdrStruct->m_flags);
|
||||
err = RowCellColumnToUInt32(msgHdr->GetMDBRow(), m_dateColumnToken, &uint32Value);
|
||||
hdrStruct->m_date = uint32Value;
|
||||
|
||||
nsMsgKey key;
|
||||
(void)msgHdr->GetMessageKey(&key);
|
||||
hdrStruct->m_messageKey = key;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::CopyHdrFromExistingHdr(nsMsgKey key, nsIMsgDBHdr *existingHdr, nsIMsgDBHdr **newHdr)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
|
|
|
@ -154,6 +154,72 @@ NS_IMETHODIMP nsMsgThread::GetNumUnreadChildren (PRUint32 *result)
|
|||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
PRBool nsMsgThread::::TryReferenceThreading(nsIMsgDBHdr *newHeader)
|
||||
{
|
||||
// start at end of references to find immediate parent in thread
|
||||
PRBool addedChild = PR_FALSE;
|
||||
PRBool done = PR_FALSE;
|
||||
|
||||
for (int32 refIndex = newHeader->GetNumReferences() - 1; !done && refIndex >= 0; refIndex--)
|
||||
{
|
||||
nsCOMPtr <nsIMsgDBHdr> refHdr;
|
||||
refHdr = messageDB->GetNeoMessageHdrForHashMessageID(newHeader->GetReferenceId(refIndex));
|
||||
if (refHdr)
|
||||
{
|
||||
// position iterator at child pos.
|
||||
childIterator.reset();
|
||||
while (TRUE)
|
||||
{
|
||||
MessageKey curMsgId = childIterator.currentID();
|
||||
if (curMsgId == 0)
|
||||
break;
|
||||
if (curMsgId == refHdr->fID)
|
||||
break;
|
||||
childIterator.nextID();
|
||||
}
|
||||
// new header is a reply to header at child index. Its level
|
||||
// is the childIndex header + 1. We need
|
||||
// to put it in the m_children array with the other children of
|
||||
// the document we are a reply to, in date order.
|
||||
newHeader->SetLevel(refHdr->GetLevel() + 1);
|
||||
while (childIterator.currentID() != 0 && !done)
|
||||
{
|
||||
MessageKey msgId = childIterator.currentID();
|
||||
if (msgId != 0)
|
||||
{
|
||||
nsIMsgDBHdr *childHdr = (nsIMsgDBHdr *) childIterator.currentObject();
|
||||
if (childHdr != NULL)
|
||||
{
|
||||
// If the current header is at a equal or higher level, we've reached the end
|
||||
// of the current level, so insert here.
|
||||
// If the current header is at the desired level, and is later than
|
||||
// the new header, put the new header before the current header.
|
||||
// Or if we're at the end, insert here.
|
||||
if ((childHdr != refHdr && childHdr->GetLevel() <= refHdr->GetLevel())
|
||||
|| (childHdr->GetLevel() == newHeader->GetLevel()
|
||||
&& newHeader->GetDate() < childHdr->GetDate())
|
||||
|| childIterator.nextID() == 0) // evil side effect - advance cursor
|
||||
{
|
||||
messageDB->AddNeoHdr(newHeader);
|
||||
// it seems if we get to the end, addHere sticks object at
|
||||
// beginning of parts list. That's not what we want.
|
||||
if (childIterator.currentID() != 0)
|
||||
childIterator.addHere(newHeader, TRUE /* insert before cursor */);
|
||||
else
|
||||
childIterator.addObject(newHeader);
|
||||
newHeader->unrefer(); // adding a newHeader to a part mgr adds a reference
|
||||
done = PR_TRUE;
|
||||
addedChild = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
refHdr->unrefer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return addedChild;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgThread::AddChild(nsIMsgDBHdr *child, PRBool threadInThread)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче