mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
add methods to get and set string properties and other hooks part of 161226 mail extensibility hooks r=cavin, sr=sspitzer
This commit is contained in:
parent
7d1a4ea865
commit
994a55ea7c
@ -124,6 +124,7 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
|
||||
// get a message header for the given key. Caller must release()!
|
||||
|
||||
nsIMsgDBHdr GetMsgHdrForKey(in nsMsgKey key);
|
||||
nsIMsgDBHdr getMsgHdrForMessageID(in string messageID);
|
||||
//Returns whether or not this database contains the given key
|
||||
boolean ContainsKey(in nsMsgKey key);
|
||||
|
||||
|
@ -158,7 +158,6 @@ protected:
|
||||
nsIMsgThread * GetThreadForSubject(nsCString &subject);
|
||||
nsIMsgThread * GetThreadForThreadId(nsMsgKey threadId);
|
||||
nsMsgHdr * GetMsgHdrForReference(nsCString &reference);
|
||||
nsIMsgDBHdr * GetMsgHdrForMessageID(nsCString &msgID);
|
||||
nsIMsgDBHdr * GetMsgHdrForSubject(nsCString &msgID);
|
||||
// threading interfaces
|
||||
virtual nsresult CreateNewThread(nsMsgKey key, const char *subject, nsMsgThread **newThread);
|
||||
|
@ -3313,7 +3313,8 @@ nsresult nsMsgDatabase::CreateNewThread(nsMsgKey threadId, const char *subject,
|
||||
|
||||
nsIMsgThread *nsMsgDatabase::GetThreadForReference(nsCString &msgID, nsIMsgDBHdr **pMsgHdr)
|
||||
{
|
||||
nsIMsgDBHdr *msgHdr = GetMsgHdrForMessageID(msgID);
|
||||
nsIMsgDBHdr *msgHdr = nsnull;
|
||||
GetMsgHdrForMessageID(msgID.get(), &msgHdr);
|
||||
nsIMsgThread *thread = NULL;
|
||||
|
||||
if (msgHdr != NULL)
|
||||
@ -3488,37 +3489,38 @@ nsMsgHdr * nsMsgDatabase::GetMsgHdrForReference(nsCString &reference)
|
||||
NS_ASSERTION(PR_FALSE, "not implemented yet.");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIMsgDBHdr *nsMsgDatabase::GetMsgHdrForMessageID(nsCString &msgID)
|
||||
NS_IMETHODIMP nsMsgDatabase::GetMsgHdrForMessageID(const char *msgID, nsIMsgDBHdr **aHdr)
|
||||
{
|
||||
nsIMsgDBHdr *msgHdr = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
mdbYarn messageIdYarn;
|
||||
NS_ENSURE_ARG_POINTER(aHdr);
|
||||
nsIMsgDBHdr *msgHdr = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
mdbYarn messageIdYarn;
|
||||
|
||||
messageIdYarn.mYarn_Buf = (void*)msgID.get();
|
||||
messageIdYarn.mYarn_Fill = PL_strlen(msgID.get());
|
||||
messageIdYarn.mYarn_Form = 0;
|
||||
messageIdYarn.mYarn_Size = messageIdYarn.mYarn_Fill;
|
||||
messageIdYarn.mYarn_Buf = (void *) msgID;
|
||||
messageIdYarn.mYarn_Fill = PL_strlen(msgID);
|
||||
messageIdYarn.mYarn_Form = 0;
|
||||
messageIdYarn.mYarn_Size = messageIdYarn.mYarn_Fill;
|
||||
|
||||
nsIMdbRow *hdrRow;
|
||||
mdbOid outRowId;
|
||||
mdb_err result = GetStore()->FindRow(GetEnv(), m_hdrRowScopeToken,
|
||||
m_messageIdColumnToken, &messageIdYarn, &outRowId,
|
||||
&hdrRow);
|
||||
if (NS_SUCCEEDED(result) && hdrRow)
|
||||
{
|
||||
//Get key from row
|
||||
mdbOid outOid;
|
||||
nsMsgKey key=0;
|
||||
if (hdrRow->GetOid(GetEnv(), &outOid) == NS_OK)
|
||||
key = outOid.mOid_Id;
|
||||
rv = GetHdrFromUseCache(key, &msgHdr);
|
||||
if (NS_SUCCEEDED(rv) && msgHdr)
|
||||
hdrRow->Release();
|
||||
else
|
||||
rv = CreateMsgHdr(hdrRow, key, &msgHdr);
|
||||
}
|
||||
return msgHdr;
|
||||
nsIMdbRow *hdrRow;
|
||||
mdbOid outRowId;
|
||||
mdb_err result = GetStore()->FindRow(GetEnv(), m_hdrRowScopeToken,
|
||||
m_messageIdColumnToken, &messageIdYarn, &outRowId,
|
||||
&hdrRow);
|
||||
if (NS_SUCCEEDED(result) && hdrRow)
|
||||
{
|
||||
//Get key from row
|
||||
mdbOid outOid;
|
||||
nsMsgKey key=0;
|
||||
if (hdrRow->GetOid(GetEnv(), &outOid) == NS_OK)
|
||||
key = outOid.mOid_Id;
|
||||
rv = GetHdrFromUseCache(key, &msgHdr);
|
||||
if (NS_SUCCEEDED(rv) && msgHdr)
|
||||
hdrRow->Release();
|
||||
else
|
||||
rv = CreateMsgHdr(hdrRow, key, &msgHdr);
|
||||
}
|
||||
NS_IF_ADDREF(*aHdr = msgHdr);
|
||||
return NS_OK; // it's not an error not to find a msg hdr.
|
||||
}
|
||||
|
||||
nsIMsgDBHdr *nsMsgDatabase::GetMsgHdrForSubject(nsCString &subject)
|
||||
|
@ -207,11 +207,17 @@ NS_IMETHODIMP nsMsgHdr::GetFlags(PRUint32 *result)
|
||||
*result = m_mdb->GetStatusFlags(this, m_flags);
|
||||
else
|
||||
*result = m_flags;
|
||||
#ifdef DEBUG_bienvenu
|
||||
NS_ASSERTION(! (m_flags & MSG_FLAG_ELIDED), "shouldn't be set in db");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::SetFlags(PRUint32 flags)
|
||||
{
|
||||
#ifdef DEBUG_bienvenu
|
||||
NS_ASSERTION(! (m_flags & MSG_FLAG_ELIDED), "shouldn't set this flag on db");
|
||||
#endif
|
||||
m_flags = flags;
|
||||
// don't write out MSG_FLAG_NEW to MDB.
|
||||
SetUInt32Column(m_flags & ~MSG_FLAG_NEW, m_mdb->m_flagsColumnToken);
|
||||
@ -286,6 +292,16 @@ NS_IMETHODIMP nsMsgHdr::SetProperty(const char *propertyName, nsString &property
|
||||
return m_mdb->SetPropertyFromNSString(m_mdbRow, propertyName, &propertyStr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::SetStringProperty(const char *propertyName, const char *propertyValue)
|
||||
{
|
||||
return m_mdb->SetProperty(m_mdbRow, propertyName, propertyValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::GetStringProperty(const char *propertyName, char **aPropertyValue)
|
||||
{
|
||||
return m_mdb->GetProperty(m_mdbRow, propertyName, aPropertyValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::GetUint32Property(const char *propertyName, PRUint32 *pResult)
|
||||
{
|
||||
return m_mdb->GetUint32Property(GetMDBRow(), propertyName, pResult);
|
||||
@ -316,41 +332,50 @@ nsresult nsMsgHdr::ParseReferences(const char *references)
|
||||
startNextRef = GetNextReference(startNextRef, resultReference);
|
||||
m_references.AppendCString(resultReference);
|
||||
}
|
||||
m_numReferences = m_references.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::GetStringReference(PRInt32 refNum, nsCString &resultReference)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
|
||||
if(!(m_initedValues & REFERENCES_INITED))
|
||||
{
|
||||
const char *references;
|
||||
err = m_mdb->RowCellColumnToConstCharPtr(GetMDBRow(), m_mdb->m_referencesColumnToken, &references);
|
||||
|
||||
if(NS_SUCCEEDED(err))
|
||||
{
|
||||
ParseReferences(references);
|
||||
m_initedValues |= REFERENCES_INITED;
|
||||
}
|
||||
}
|
||||
|
||||
m_references.CStringAt(refNum, resultReference);
|
||||
return err;
|
||||
nsresult err = NS_OK;
|
||||
|
||||
if(!(m_initedValues & REFERENCES_INITED))
|
||||
{
|
||||
const char *references;
|
||||
err = m_mdb->RowCellColumnToConstCharPtr(GetMDBRow(), m_mdb->m_referencesColumnToken, &references);
|
||||
|
||||
if(NS_SUCCEEDED(err))
|
||||
{
|
||||
ParseReferences(references);
|
||||
m_initedValues |= REFERENCES_INITED;
|
||||
}
|
||||
}
|
||||
|
||||
if (refNum < m_numReferences)
|
||||
m_references.CStringAt(refNum, resultReference);
|
||||
return err;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::GetDate(PRTime *result)
|
||||
{
|
||||
if (!(m_initedValues & CACHED_VALUES_INITED))
|
||||
InitCachedValues();
|
||||
|
||||
*result = m_date;
|
||||
return NS_OK;
|
||||
if (!(m_initedValues & CACHED_VALUES_INITED))
|
||||
InitCachedValues();
|
||||
|
||||
*result = m_date;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::SetMessageId(const char *messageId)
|
||||
{
|
||||
return SetStringColumn(messageId, m_mdb->m_messageIdColumnToken);
|
||||
if (messageId && *messageId == '<')
|
||||
{
|
||||
nsCAutoString tempMessageID(messageId + 1);
|
||||
if (tempMessageID.Last() == '>')
|
||||
tempMessageID.SetLength(tempMessageID.Length() - 1);
|
||||
return SetStringColumn(tempMessageID.get(), m_mdb->m_messageIdColumnToken);
|
||||
}
|
||||
return SetStringColumn(messageId, m_mdb->m_messageIdColumnToken);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgHdr::SetSubject(const char *subject)
|
||||
|
Loading…
Reference in New Issue
Block a user