add new notifications, char set as string new method to create hdr and add to db

This commit is contained in:
bienvenu%netscape.com 1999-02-23 03:34:02 +00:00
Родитель 6817465add
Коммит 0f40cb68c4
6 изменённых файлов: 62 добавлений и 5 удалений

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

@ -18,6 +18,10 @@ public:
}
NS_IMETHOD OnKeyChange(nsMsgKey aKeyChanged, int32 aFlags,
nsIDBChangeListener * aInstigator) = 0;
NS_IMETHOD OnKeyDeleted(nsMsgKey aKeyChanged, int32 aFlags,
nsIDBChangeListener * aInstigator) = 0;
NS_IMETHOD OnKeyAdded(nsMsgKey aKeyChanged, int32 aFlags,
nsIDBChangeListener * aInstigator) = 0;
NS_IMETHOD OnAnnouncerGoingAway(nsDBChangeAnnouncer * instigator) ;
};

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

@ -52,6 +52,10 @@ public:
// convenience routines to notify all our ChangeListeners
void NotifyKeyChangeAll(nsMsgKey keyChanged, PRInt32 flags,
nsIDBChangeListener *instigator);
void NotifyKeyAddedAll(nsMsgKey keyAdded, PRInt32 flags,
nsIDBChangeListener *instigator);
void NotifyKeyDeletedAll(nsMsgKey keyDeleted, PRInt32 flags,
nsIDBChangeListener *instigator);
void NotifyAnnouncerGoingAway(nsDBChangeAnnouncer *instigator);
};
@ -109,8 +113,13 @@ public:
virtual nsresult GetMsgHdrForKey(nsMsgKey key, nsMsgHdr **msgHdr);
// create a new message header from a hdrStruct. Caller must release resulting header,
// after adding any extra properties they want.
virtual nsresult CreateNewHdr(PRBool *newThread, MessageHdrStruct *hdrStruct, nsMsgHdr **newHdr, PRBool notify = FALSE);
virtual nsresult CreateNewHdrAndAddToDB(PRBool *newThread, MessageHdrStruct *hdrStruct, nsMsgHdr **newHdr, PRBool notify = FALSE);
// 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.
virtual nsresult CreateNewHdr(nsMsgKey key, nsMsgHdr **newHdr);
virtual nsresult AddNewHdrToDB(nsMsgHdr *newHdr, PRBool notify);
// extract info from an nsMsgHdr into a MessageHdrStruct
virtual nsresult GetMsgHdrStructFromnsMsgHdr(nsMsgHdr *msgHdr, MessageHdrStruct &hdrStruct);

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

@ -98,6 +98,7 @@ protected:
PRUint32 m_flags;
PRUint16 m_numReferences; // x-ref header for threading
PRInt16 m_csID; // cs id of message
nsString m_charSet; // OK, charset of headers, since cs id's aren't supported.
nsMsgPriority m_priority;
// nsMsgHdrs will have to know what db and row they belong to, since they are really

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

@ -37,7 +37,7 @@ CPP_OBJS= .\$(OBJDIR)\nsMsgDatabase.obj \
.\$(OBJDIR)\nsDBFolderInfo.obj\
.\$(OBJDIR)\nsMailDatabase.obj\
.\$(OBJDIR)\nsMsgHdr.obj\
.\$(OBJDIR)\mdbstubs.obj\
# .\$(OBJDIR)\mdbstubs.obj\
$(NULL)

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

@ -468,24 +468,28 @@ nsresult nsMailDatabase::PrePopulate()
newHdr->SetSubject("Why the Lakers suck");
newHdr->SetDate(resDate);
newHdr->SetRecipients("riley@heat.com (Pat Riley)", FALSE);
AddNewHdrToDB (newHdr, PR_TRUE);
newHdr->Release();
res = CreateNewHdr(2, &newHdr);
newHdr->SetAuthor("shaq@brick.com (Shaquille O'Neal)");
newHdr->SetSubject("Anyone here know how to shoot free throws?");
newHdr->SetDate(resDate);
AddNewHdrToDB (newHdr, PR_TRUE);
newHdr->Release();
res = CreateNewHdr(3, &newHdr);
newHdr->SetAuthor("dj@celtics.com (Dennis Johnson)");
newHdr->SetSubject("Has anyone seen my jump shot?");
newHdr->SetDate(resDate);
AddNewHdrToDB (newHdr, PR_TRUE);
newHdr->Release();
res = CreateNewHdr(4, &newHdr);
newHdr->SetAuthor("sichting@celtics.com (Jerry Sichting)");
newHdr->SetSubject("Tips for fighting 7' 4\" guys");
newHdr->SetDate(resDate);
AddNewHdrToDB (newHdr, PR_TRUE);
newHdr->Release();
return NS_OK;
}

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

@ -79,6 +79,29 @@ void nsDBChangeAnnouncer::NotifyKeyChangeAll(nsMsgKey keyChanged, PRInt32 flags,
}
}
void nsDBChangeAnnouncer::NotifyKeyDeletedAll(nsMsgKey keyDeleted, PRInt32 flags,
nsIDBChangeListener *instigator)
{
for (int i = 0; i < Count(); i++)
{
nsIDBChangeListener *changeListener = (nsIDBChangeListener *) ElementAt(i);
changeListener->OnKeyDeleted(keyDeleted, flags, instigator);
}
}
void nsDBChangeAnnouncer::NotifyKeyAddedAll(nsMsgKey keyAdded, PRInt32 flags,
nsIDBChangeListener *instigator)
{
for (int i = 0; i < Count(); i++)
{
nsIDBChangeListener *changeListener = (nsIDBChangeListener *) ElementAt(i);
changeListener->OnKeyAdded(keyAdded, flags, instigator);
}
}
void nsDBChangeAnnouncer::NotifyAnnouncerGoingAway(nsDBChangeAnnouncer *instigator)
{
if (instigator == NULL)
@ -582,7 +605,7 @@ nsresult nsMsgDatabase::DeleteHeader(nsMsgHdr *msgHdr, nsIDBChangeListener *inst
if (notify) {
PRUint32 flags;
(void)msgHdr->GetFlags(&flags);
NotifyKeyChangeAll(key, flags, instigator); // tell listeners
NotifyKeyDeletedAll(key, flags, instigator); // tell listeners
}
// if (!onlyRemoveFromThread) // to speed up expiration, try this. But really need to do this in RemoveHeaderFromDB
@ -1179,14 +1202,30 @@ nsresult nsMsgDatabase::CreateNewHdr(nsMsgKey key, nsMsgHdr **pnewHdr)
&allMsgHdrsTableOID, &hdrRow);
if (err == NS_OK)
{
err = m_mdbAllMsgHeadersTable->AddRow(GetEnv(), hdrRow);
*pnewHdr = new nsMsgHdr(this, hdrRow);
(*pnewHdr)->AddRef();
}
return err;
}
nsresult nsMsgDatabase::CreateNewHdr(PRBool *newThread, MessageHdrStruct *hdrStruct, nsMsgHdr **pnewHdr, PRBool notify /* = FALSE */)
nsresult nsMsgDatabase::AddNewHdrToDB(nsMsgHdr *newHdr, PRBool notify)
{
nsresult err = m_mdbAllMsgHeadersTable->AddRow(GetEnv(), newHdr->GetMDBRow());
if (notify)
{
nsMsgKey key;
PRUint32 flags;
newHdr->GetMessageKey(&key);
newHdr->GetFlags(&flags);
NotifyKeyAddedAll(key, flags, NULL);
}
return err;
}
nsresult nsMsgDatabase::CreateNewHdrAndAddToDB(PRBool *newThread, MessageHdrStruct *hdrStruct, nsMsgHdr **pnewHdr, PRBool notify /* = FALSE */)
{
nsresult err = NS_OK;
nsIMdbRow *hdrRow;