Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
nsMailDatabase Class Reference

#include <nsMailDatabase.h>

Inheritance diagram for nsMailDatabase:
Inheritance graph
[legend]
Collaboration diagram for nsMailDatabase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsMailDatabase ()
virtual ~nsMailDatabase ()
NS_IMETHOD Open (nsIFileSpec *aFolderName, PRBool create, PRBool upgrading)
NS_IMETHOD ForceClosed ()
NS_IMETHOD DeleteMessages (nsMsgKeyArray *nsMsgKeys, nsIDBChangeListener *instigator)
NS_IMETHOD StartBatch ()
NS_IMETHOD EndBatch ()
nsresult GetFolderName (nsString &folderName)
virtual nsMailDatabaseGetMailDB ()
virtual PRUint32 GetCurVersion ()
NS_IMETHOD GetOfflineOpForKey (nsMsgKey opKey, PRBool create, nsIMsgOfflineImapOperation **op)
NS_IMETHOD RemoveOfflineOp (nsIMsgOfflineImapOperation *op)
NS_IMETHOD SetSummaryValid (PRBool valid)
NS_IMETHOD GetSummaryValid (PRBool *valid)
NS_IMETHOD EnumerateOfflineOps (nsISimpleEnumerator **enumerator)
NS_IMETHOD ListAllOfflineOpIds (nsMsgKeyArray *offlineOpIds)
NS_IMETHOD ListAllOfflineDeletes (nsMsgKeyArray *offlineDeletes)
NS_IMETHOD SetFolderStream (nsIOFileStream *aFileStream)
NS_IMETHOD GetFolderStream (nsIOFileStream **aFileStream)
NS_DECL_ISUPPORTS
NS_DECL_NSIDBCHANGEANNOUNCER
virtual NS_DECL_NSIMSGDATABASE
nsresult 
IsHeaderRead (nsIMsgDBHdr *hdr, PRBool *pRead)
virtual nsresult MarkHdrReadInDB (nsIMsgDBHdr *msgHdr, PRBool bRead, nsIDBChangeListener *instigator)
virtual nsresult OpenMDB (const char *dbName, PRBool create)
virtual nsresult CloseMDB (PRBool commit)
virtual nsresult CreateMsgHdr (nsIMdbRow *hdrRow, nsMsgKey key, nsIMsgDBHdr **result)
virtual nsresult GetThreadForMsgKey (nsMsgKey msgKey, nsIMsgThread **result)
virtual nsresult EnumerateMessagesWithFlag (nsISimpleEnumerator **result, PRUint32 *pFlag)
nsresult GetSearchResultsTable (const char *searchFolderUri, PRBool createIfMissing, nsIMdbTable **table)
nsresult ListAllThreads (nsMsgKeyArray *threadIds)
nsIMdbEnvGetEnv ()
nsIMdbStoreGetStore ()
nsIMsgHeaderParserGetHeaderParser ()
nsresult GetCollationKeyGenerator ()
nsIMimeConverterGetMimeConverter ()
nsresult GetTableCreateIfMissing (const char *scope, const char *kind, nsIMdbTable **table, mdb_token &scopeToken, mdb_token &kindToken)
nsresult RowCellColumnTonsString (nsIMdbRow *row, mdb_token columnToken, nsAString &resultStr)
nsresult RowCellColumnToUInt32 (nsIMdbRow *row, mdb_token columnToken, PRUint32 *uint32Result, PRUint32 defaultValue=0)
nsresult RowCellColumnToUInt32 (nsIMdbRow *row, mdb_token columnToken, PRUint32 &uint32Result, PRUint32 defaultValue=0)
nsresult RowCellColumnToMime2DecodedString (nsIMdbRow *row, mdb_token columnToken, PRUnichar **)
nsresult RowCellColumnToCollationKey (nsIMdbRow *row, mdb_token columnToken, PRUint8 **result, PRUint32 *len)
nsresult RowCellColumnToConstCharPtr (nsIMdbRow *row, mdb_token columnToken, const char **ptr)
nsresult RowCellColumnToAddressCollationKey (nsIMdbRow *row, mdb_token colToken, PRUint8 **result, PRUint32 *len)
nsresult GetProperty (nsIMdbRow *row, const char *propertyName, char **result)
nsresult SetProperty (nsIMdbRow *row, const char *propertyName, const char *propertyVal)
nsresult GetPropertyAsNSString (nsIMdbRow *row, const char *propertyName, nsAString &result)
nsresult SetPropertyFromNSString (nsIMdbRow *row, const char *propertyName, const nsAString &propertyVal)
nsresult GetUint32Property (nsIMdbRow *row, const char *propertyName, PRUint32 *result, PRUint32 defaultValue=0)
nsresult SetUint32Property (nsIMdbRow *row, const char *propertyName, PRUint32 propertyVal)
nsresult SetNSStringPropertyWithToken (nsIMdbRow *row, mdb_token aProperty, const nsAString &propertyStr)
nsresult UInt32ToRowCellColumn (nsIMdbRow *row, mdb_token columnToken, PRUint32 value)
nsresult CharPtrToRowCellColumn (nsIMdbRow *row, mdb_token columnToken, const char *charPtr)
nsresult RowCellColumnToCharPtr (nsIMdbRow *row, mdb_token columnToken, char **result)
void Open (in nsIFileSpec aFolderName, in boolean aCreate, in boolean aLeaveInvalidDB)
void forceFolderDBClosed (in nsIMsgFolder aFolder)
void Close (in boolean aForceCommit)
void Commit (in nsMsgDBCommit commitType)
void clearCachedHdrs ()
void resetHdrCacheSize (in unsigned long size)
nsIMsgDBHdr GetMsgHdrForKey (in nsMsgKey key)
nsIMsgDBHdr getMsgHdrForMessageID (in string messageID)
boolean ContainsKey (in nsMsgKey key)
nsIMsgDBHdr CreateNewHdr (in nsMsgKey key)
void AddNewHdrToDB (in nsIMsgDBHdr newHdr, in boolean notify)
nsIMsgDBHdr CopyHdrFromExistingHdr (in nsMsgKey key, in nsIMsgDBHdr existingHdr, in boolean addHdrToDB)
void ListAllKeys (in nsMsgKeyArrayRef outputKeys)
nsISimpleEnumerator EnumerateMessages ()
nsISimpleEnumerator EnumerateThreads ()
void syncCounts ()
nsIMsgThread GetThreadContainingMsgHdr (in nsIMsgDBHdr msgHdr)
void MarkHdrRead (in nsIMsgDBHdr msgHdr, in boolean bRead, in nsIDBChangeListener instigator)
void MarkHdrReplied (in nsIMsgDBHdr msgHdr, in boolean bReplied, in nsIDBChangeListener instigator)
void MarkHdrMarked (in nsIMsgDBHdr msgHdr, in boolean mark, in nsIDBChangeListener instigator)
void MarkMDNNeeded (in nsMsgKey key, in boolean bNeeded, in nsIDBChangeListener instigator)
boolean IsMDNNeeded (in nsMsgKey key)
void MarkMDNSent (in nsMsgKey key, in boolean bNeeded, in nsIDBChangeListener instigator)
boolean IsMDNSent (in nsMsgKey key)
void MarkRead (in nsMsgKey key, in boolean bRead, in nsIDBChangeListener instigator)
void MarkReplied (in nsMsgKey key, in boolean bReplied, in nsIDBChangeListener instigator)
void MarkForwarded (in nsMsgKey key, in boolean bForwarded, in nsIDBChangeListener instigator)
void MarkHasAttachments (in nsMsgKey key, in boolean bHasAttachments, in nsIDBChangeListener instigator)
void MarkThreadRead (in nsIMsgThread thread, in nsIDBChangeListener instigator, in nsMsgKeyArrayPtr thoseMarked)
void MarkThreadIgnored (in nsIMsgThread thread, in nsMsgKey threadKey, in boolean bIgnored, in nsIDBChangeListener instigator)
void MarkThreadWatched (in nsIMsgThread thread, in nsMsgKey threadKey, in boolean bWatched, in nsIDBChangeListener instigator)
boolean IsRead (in nsMsgKey key)
boolean IsIgnored (in nsMsgKey key)
boolean IsMarked (in nsMsgKey key)
boolean HasAttachments (in nsMsgKey key)
void MarkAllRead (in nsMsgKeyArrayPtr thoseMarked)
void MarkReadByDate (in PRTime startDate, in PRTime endDate, in nsMsgKeyArrayPtr markedIds)
void DeleteMessages (in nsMsgKeyArrayPtr nsMsgKeys, in nsIDBChangeListener instigator)
void DeleteMessage (in nsMsgKey key, in nsIDBChangeListener instigator, in boolean commit)
void DeleteHeader (in nsIMsgDBHdr msgHdr, in nsIDBChangeListener instigator, in boolean commit, in boolean notify)
void RemoveHeaderMdbRow (in nsIMsgDBHdr msgHdr)
void UndoDelete (in nsIMsgDBHdr msgHdr)
void MarkMarked (in nsMsgKey key, in boolean mark, in nsIDBChangeListener instigator)
void MarkOffline (in nsMsgKey key, in boolean offline, in nsIDBChangeListener instigator)
void SetLabel (in nsMsgKey key, in nsMsgLabelValue label)
void setStringProperty (in nsMsgKey aKey, in string aProperty, in string aValue)
void MarkImapDeleted (in nsMsgKey key, in boolean deleted, in nsIDBChangeListener instigator)
void applyRetentionSettings (in nsIMsgRetentionSettings aMsgRetentionSettings, in boolean aDeleteViaFolder)
boolean HasNew ()
void ClearNewList (in boolean notify)
void AddToNewList (in nsMsgKey key)
nsIMsgOfflineImapOperation GetOfflineOpForKey (in nsMsgKey messageKey, in boolean create)
void RemoveOfflineOp (in nsIMsgOfflineImapOperation op)
nsISimpleEnumerator EnumerateOfflineOps ()
void ListAllOfflineOpIds (in nsMsgKeyArrayPtr offlineOpIds)
void ListAllOfflineDeletes (in nsMsgKeyArrayPtr offlineDeletes)
void ListAllOfflineMsgs (in nsMsgKeyArrayPtr offlineMsgs)
void setAttributesOnPendingHdr (in nsIMsgDBHdr pendingHdr, in string property, in string propertyVal, in long flags)
void createCollationKey (in AString sourceString, out octetPtr key, out unsigned long len)
long compareCollationKeys (in octetPtr key1, in unsigned long len1, in octetPtr key2, in unsigned long len2)
void getNewList (out unsigned long count,[array, size_is(count)] out nsMsgKey newKeys)
 The list of messages currently in the NEW state.
nsISimpleEnumerator getCachedHits (in string aSearchFolderUri)
void refreshCache (in string aSearchFolderUri, in unsigned long aNumKeys,[array, size_is(aNumKeys)] in nsMsgKey aNewHits, out unsigned long aNumBadHits,[array, size_is(aNumBadHits)] out nsMsgKey aStaleHits)
void updateHdrInCache (in string aSearchFolderUri, in nsIMsgDBHdr aHdr, in boolean aAdd)
boolean hdrIsInCache (in string aSearchFolderUri, in nsIMsgDBHdr aHdr)
void AddListener (in nsIDBChangeListener listener)
void RemoveListener (in nsIDBChangeListener listener)
void NotifyHdrChangeAll (in nsIMsgDBHdr aHdrChanged, in unsigned long aOldFlags, in unsigned long aNewFlags, in nsIDBChangeListener instigator)
void NotifyHdrAddedAll (in nsIMsgDBHdr aHdrAdded, in nsMsgKey parentKey, in long flags, in nsIDBChangeListener instigator)
void NotifyHdrDeletedAll (in nsIMsgDBHdr aHdrDeleted, in nsMsgKey parentKey, in long flags, in nsIDBChangeListener instigator)
void NotifyParentChangedAll (in nsMsgKey keyReparented, in nsMsgKey oldParent, in nsMsgKey newParent, in nsIDBChangeListener instigator)
void NotifyReadChanged (in nsIDBChangeListener instigator)
void NotifyJunkScoreChanged (in nsIDBChangeListener aInstigator)
void NotifyAnnouncerGoingAway ()

Static Public Member Functions

static nsresult SetFolderInfoValid (nsFileSpec *folderSpec, int num, int numunread)
static nsIMdbFactoryGetMDBFactory ()
static nsMsgDatabaseFindInCache (nsFileSpec &dbName)
static nsIMsgDatabaseFindInCache (nsIMsgFolder *folder)
static struct mdbYarnnsStringToYarn (struct mdbYarn *yarn, const nsAString &str)
static struct mdbYarnUInt32ToYarn (struct mdbYarn *yarn, PRUint32 i)
static void YarnTonsString (struct mdbYarn *yarn, nsAString &str)
static void YarnTonsCString (struct mdbYarn *yarn, nsACString &str)
static void YarnToUInt32 (struct mdbYarn *yarn, PRUint32 *i)
static void CleanupCache ()

Public Attributes

readonly attribute nsIDBFolderInfo dBFolderInfo
readonly attribute nsMsgKey FirstNew
attribute nsIMsgRetentionSettings msgRetentionSettings
attribute nsIMsgDownloadSettings msgDownloadSettings
attribute boolean summaryValid
readonly attribute nsMsgKey lowWaterArticleNum
readonly attribute nsMsgKey highWaterArticleNum
attribute nsMsgKey nextPseudoMsgKey
readonly attribute nsMsgKey nextFakeOfflineMsgKey
readonly attribute
nsMsgViewFlagsTypeValue 
defaultViewFlags
readonly attribute
nsMsgViewSortTypeValue 
defaultSortType
readonly attribute
nsMsgViewSortOrderValue 
defaultSortOrder
attribute unsigned long msgHdrCacheSize
attribute nsIOFileStream folderStream

Protected Member Functions

nsresult GetAllOfflineOpsTable ()
PRUint32 GetMailboxModDate ()
virtual PRBool SetHdrFlag (nsIMsgDBHdr *, PRBool bSet, MsgFlags flag)
virtual void UpdateFolderFlag (nsIMsgDBHdr *msgHdr, PRBool bSet, MsgFlags flag, nsIOFileStream **ppFileStream)
virtual void SetReparse (PRBool reparse)
virtual void GetGlobalPrefs ()
nsresult GetBoolPref (const char *prefName, PRBool *result)
nsresult GetIntPref (const char *prefName, PRInt32 *result)
nsIMsgThreadGetThreadForReference (nsCString &msgID, nsIMsgDBHdr **pMsgHdr)
nsIMsgThreadGetThreadForSubject (nsCString &subject)
nsIMsgThreadGetThreadForThreadId (nsMsgKey threadId)
nsMsgHdrGetMsgHdrForReference (nsCString &reference)
nsIMsgDBHdrGetMsgHdrForSubject (nsCString &msgID)
virtual nsresult CreateNewThread (nsMsgKey key, const char *subject, nsMsgThread **newThread)
virtual PRBool ThreadBySubjectWithoutRe ()
virtual PRBool UseStrictThreading ()
virtual nsresult ThreadNewHdr (nsMsgHdr *hdr, PRBool &newThread)
virtual nsresult AddNewThread (nsMsgHdr *msgHdr)
virtual nsresult AddToThread (nsMsgHdr *newHdr, nsIMsgThread *thread, nsIMsgDBHdr *pMsgHdr, PRBool threadInThread)
PRBool MatchDbName (nsFileSpec &dbName)
virtual nsresult SetKeyFlag (nsMsgKey key, PRBool set, PRUint32 flag, nsIDBChangeListener *instigator=NULL)
virtual nsresult SetMsgHdrFlag (nsIMsgDBHdr *msgHdr, PRBool set, PRUint32 flag, nsIDBChangeListener *instigator)
virtual PRBool SetHdrReadFlag (nsIMsgDBHdr *, PRBool pRead)
virtual PRUint32 GetStatusFlags (nsIMsgDBHdr *msgHdr, PRUint32 origFlags)
virtual nsresult RemoveHeaderFromDB (nsMsgHdr *msgHdr)
virtual nsresult RemoveHeaderFromThread (nsMsgHdr *msgHdr)
virtual nsresult AdjustExpungedBytesOnDelete (nsIMsgDBHdr *msgHdr)
nsresult PurgeMessagesOlderThan (PRUint32 daysToKeepHdrs, PRBool keepUnreadMessagesOnly, nsISupportsArray *hdrsToDelete)
nsresult PurgeExcessMessages (PRUint32 numHeadersToKeep, PRBool keepUnreadMessagesOnly, nsISupportsArray *hdrsToDelete)
virtual nsresult InitExistingDB ()
virtual nsresult InitNewDB ()
virtual nsresult InitMDBInfo ()
nsresult GetHdrFromCache (nsMsgKey key, nsIMsgDBHdr **result)
nsresult AddHdrToCache (nsIMsgDBHdr *hdr, nsMsgKey key)
nsresult ClearHdrCache (PRBool reInit)
nsresult RemoveHdrFromCache (nsIMsgDBHdr *hdr, nsMsgKey key)
nsresult GetHdrFromUseCache (nsMsgKey key, nsIMsgDBHdr **result)
nsresult AddHdrToUseCache (nsIMsgDBHdr *hdr, nsMsgKey key)
nsresult ClearUseHdrCache ()
nsresult RemoveHdrFromUseCache (nsIMsgDBHdr *hdr, nsMsgKey key)
mdb_pos FindInsertIndexInSortedTable (nsIMdbTable *table, mdb_id idToInsert)
void ClearCachedObjects (PRBool dbGoingAway)

Static Protected Member Functions

static int FindInCache (nsMsgDatabase *pMessageDB)
static void AddToCache (nsMsgDatabase *pMessageDB)
static void RemoveFromCache (nsMsgDatabase *pMessageDB)
static nsVoidArrayGetDBCache ()
static const void *PR_CALLBACK GetKey (PLDHashTable *aTable, PLDHashEntryHdr *aEntry)
static PLDHashNumber PR_CALLBACK HashKey (PLDHashTable *aTable, const void *aKey)
static PRBool PR_CALLBACK MatchEntry (PLDHashTable *aTable, const PLDHashEntryHdr *aEntry, const void *aKey)
static void PR_CALLBACK MoveEntry (PLDHashTable *aTable, const PLDHashEntryHdr *aFrom, PLDHashEntryHdr *aTo)
static void PR_CALLBACK ClearEntry (PLDHashTable *aTable, PLDHashEntryHdr *aEntry)
static PLDHashOperator PR_CALLBACK HeaderEnumerator (PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 number, void *arg)
static PLDHashOperator PR_CALLBACK ClearHeaderEnumerator (PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 number, void *arg)

Protected Attributes

nsCOMPtr< nsIMdbTablem_mdbAllOfflineOpsTable
mdb_token m_offlineOpsRowScopeToken
mdb_token m_offlineOpsTableKindToken
PRBool m_reparse
nsFileSpecm_folderSpec
nsIOFileStreamm_folderStream
PRBool m_ownFolderStream
nsCOMPtr< nsICollationm_collationKeyGenerator
nsCOMPtr< nsIMimeConverterm_mimeConverter
nsCOMPtr< nsIMsgRetentionSettingsm_retentionSettings
nsCOMPtr< nsIMsgDownloadSettingsm_downloadSettings
nsCOMPtr< nsIMsgFolderm_folder
nsDBFolderInfom_dbFolderInfo
nsMsgKey m_nextPseudoMsgKey
nsIMdbEnvm_mdbEnv
nsIMdbStorem_mdbStore
nsIMdbTablem_mdbAllMsgHeadersTable
nsIMdbTablem_mdbAllThreadsTable
nsFileSpec m_dbName
nsMsgKeyArray m_newSet
PRBool m_mdbTokensInitialized
nsCOMPtr< nsISupportsArraym_ChangeListeners
mdb_token m_hdrRowScopeToken
mdb_token m_threadRowScopeToken
mdb_token m_hdrTableKindToken
mdb_token m_threadTableKindToken
mdb_token m_allThreadsTableKindToken
mdb_token m_subjectColumnToken
mdb_token m_senderColumnToken
mdb_token m_messageIdColumnToken
mdb_token m_referencesColumnToken
mdb_token m_recipientsColumnToken
mdb_token m_dateColumnToken
mdb_token m_messageSizeColumnToken
mdb_token m_flagsColumnToken
mdb_token m_priorityColumnToken
mdb_token m_labelColumnToken
mdb_token m_statusOffsetColumnToken
mdb_token m_numLinesColumnToken
mdb_token m_ccListColumnToken
mdb_token m_threadFlagsColumnToken
mdb_token m_threadIdColumnToken
mdb_token m_threadChildrenColumnToken
mdb_token m_threadUnreadChildrenColumnToken
mdb_token m_messageThreadIdColumnToken
mdb_token m_threadSubjectColumnToken
mdb_token m_numReferencesColumnToken
mdb_token m_messageCharSetColumnToken
mdb_token m_threadParentColumnToken
mdb_token m_threadRootKeyColumnToken
mdb_token m_threadNewestMsgDateColumnToken
mdb_token m_offlineMsgOffsetColumnToken
mdb_token m_offlineMessageSizeColumnToken
nsIMsgHeaderParserm_HeaderParser
PLDHashTablem_headersInUse
PLDHashTablem_cachedHeaders
PRBool m_bCacheHeaders
nsMsgKey m_cachedThreadId
nsCOMPtr< nsIMsgThreadm_cachedThread

Static Protected Attributes

static nsVoidArraym_dbCache = NULL
static PLDHashTableOps gMsgDBHashTableOps

Friends

class nsMsgOfflineOpEnumerator
class nsMsgDBService
class nsMsgHdr
class nsMsgThread
class nsMsgDBEnumerator
class nsMsgDBThreadEnumerator

Detailed Description

Definition at line 50 of file nsMailDatabase.h.


Constructor & Destructor Documentation

Definition at line 63 of file nsMailDatabase.cpp.

Here is the caller graph for this function:

Definition at line 69 of file nsMailDatabase.cpp.

{
  delete m_folderSpec;
}

Member Function Documentation

nsresult nsMsgDatabase::AddHdrToCache ( nsIMsgDBHdr hdr,
nsMsgKey  key 
) [protected, inherited]

Definition at line 283 of file nsMsgDatabase.cpp.

{
  if (m_bCacheHeaders)
  {
    if (!m_cachedHeaders)
      m_cachedHeaders = PL_NewDHashTable(&gMsgDBHashTableOps, (void *) nsnull, sizeof(struct MsgHdrHashElement), m_cacheSize );
    if (m_cachedHeaders)
    {
      if (key == nsMsgKey_None)
        hdr->GetMessageKey(&key);
      if (m_cachedHeaders->entryCount > m_cacheSize)
        ClearHdrCache(PR_TRUE);
      PLDHashEntryHdr *entry = PL_DHashTableOperate(m_cachedHeaders, (void *) key, PL_DHASH_ADD);
      if (!entry)
        return NS_ERROR_OUT_OF_MEMORY; // XXX out of memory
      
      MsgHdrHashElement* element = NS_REINTERPRET_CAST(MsgHdrHashElement*, entry);
      element->mHdr = hdr;  
      element->mKey = key;
      NS_ADDREF(hdr);     // make the cache hold onto the header
      return NS_OK;
    }
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::AddHdrToUseCache ( nsIMsgDBHdr hdr,
nsMsgKey  key 
) [protected, inherited]

Definition at line 503 of file nsMsgDatabase.cpp.

{
  if (!m_headersInUse)
  {
    mdb_count numHdrs = MSG_HASH_SIZE;
    if (m_mdbAllMsgHeadersTable)
      m_mdbAllMsgHeadersTable->GetCount(GetEnv(), &numHdrs);
    m_headersInUse = PL_NewDHashTable(&gMsgDBHashTableOps, (void *) nsnull, sizeof(struct MsgHdrHashElement), PR_MAX(MSG_HASH_SIZE, numHdrs));
  }
  if (m_headersInUse)
  {
    if (key == nsMsgKey_None)
      hdr->GetMessageKey(&key);
    PLDHashEntryHdr *entry = PL_DHashTableOperate(m_headersInUse, (void *) key, PL_DHASH_ADD);
    if (!entry)
      return NS_ERROR_OUT_OF_MEMORY; // XXX out of memory

    MsgHdrHashElement* element = NS_REINTERPRET_CAST(MsgHdrHashElement*, entry);
    element->mHdr = hdr;  
    element->mKey = key;
    // the hash table won't add ref, we'll do it ourselves
    // stand for the addref that CreateMsgHdr normally does.
    NS_ADDREF(hdr);
    return NS_OK;
  }

  return NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

void nsIMsgDatabase::AddNewHdrToDB ( in nsIMsgDBHdr  newHdr,
in boolean  notify 
) [inherited]
nsresult nsMsgDatabase::AddNewThread ( nsMsgHdr msgHdr) [protected, virtual, inherited]

Definition at line 4020 of file nsMsgDatabase.cpp.

{
  
  if (!msgHdr)
    return NS_ERROR_NULL_POINTER;
  
  nsMsgThread *threadHdr = nsnull;
  
  nsXPIDLCString subject;
  nsMsgKey threadKey = msgHdr->m_messageKey;
  // 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 == 1)
    threadKey = kTableKeyForThreadOne;

  nsresult err = msgHdr->GetSubject(getter_Copies(subject));
  
  err = CreateNewThread(threadKey, subject, &threadHdr);
  msgHdr->SetThreadId(threadKey);
  if (threadHdr)
  {
    //        nsCString subject;
    
    threadHdr->AddRef();
    //        err = msgHdr->GetSubject(subject);
    //        threadHdr->SetThreadKey(msgHdr->m_messageKey);
    //        threadHdr->SetSubject(subject.get());
    
    // need to add the thread table to the db.
    AddToThread(msgHdr, threadHdr, nsnull, PR_FALSE);
    
    threadHdr->Release();
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMsgDatabase::AddToCache ( nsMsgDatabase pMessageDB) [inline, static, protected, inherited]

Definition at line 189 of file nsMsgDatabase.h.

  {GetDBCache()->AppendElement(pMessageDB);}

Here is the call graph for this function:

nsresult nsMsgDatabase::AddToThread ( nsMsgHdr newHdr,
nsIMsgThread thread,
nsIMsgDBHdr pMsgHdr,
PRBool  threadInThread 
) [protected, virtual, inherited]

Definition at line 3866 of file nsMsgDatabase.cpp.

{
  // don't worry about real threading yet.
  nsCOMPtr <nsIDBChangeAnnouncer> announcer = do_QueryInterface(this);
  
  return thread->AddChild(newHdr, inReplyTo, threadInThread, announcer);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::AdjustExpungedBytesOnDelete ( nsIMsgDBHdr msgHdr) [protected, virtual, inherited]

Reimplemented in nsNewsDatabase, and nsImapMailDatabase.

Definition at line 1856 of file nsMsgDatabase.cpp.

{
  PRUint32 size = 0;
  (void)msgHdr->GetMessageSize(&size);
  return m_dbFolderInfo->ChangeExpungedBytes (size);
}

Here is the call graph for this function:

void nsIMsgDatabase::applyRetentionSettings ( in nsIMsgRetentionSettings  aMsgRetentionSettings,
in boolean  aDeleteViaFolder 
) [inherited]
nsresult nsMsgDatabase::CharPtrToRowCellColumn ( nsIMdbRow row,
mdb_token  columnToken,
const char *  charPtr 
) [inherited]

Definition at line 3393 of file nsMsgDatabase.cpp.

{
  if (!row)
    return NS_ERROR_NULL_POINTER;

  struct mdbYarn yarn;
  yarn.mYarn_Buf = (void *) charPtr;
  yarn.mYarn_Size = PL_strlen((const char *) yarn.mYarn_Buf) + 1;
  yarn.mYarn_Fill = yarn.mYarn_Size - 1;
  yarn.mYarn_Form = 0;      // what to do with this? we're storing csid in the msg hdr...
  
  return row->AddColumn(GetEnv(),  columnToken, &yarn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsMsgDatabase::CleanupCache ( ) [static, inherited]

Definition at line 765 of file nsMsgDatabase.cpp.

{
  if (m_dbCache) // clean up memory leak (needed because some destructors
                 // have user-visible effects, which they shouldn't)
  {
    for (PRInt32 i = 0; i < GetDBCache()->Count(); i++)
    {
      nsMsgDatabase* pMessageDB = NS_STATIC_CAST(nsMsgDatabase*, GetDBCache()->ElementAt(i));
      if (pMessageDB)
      {
        // hold onto the db until we're finished closing it.
        pMessageDB->AddRef();
        // break cycle with folder -> parse msg state -> db
        pMessageDB->m_folder = nsnull;
        pMessageDB->ForceClosed();
        nsrefcnt refcount = pMessageDB->Release();

        // ForceClosed may have caused the last reference (other than
        // this function's) to go away by breaking a cycle
        if (refcount != 0)
        {
          // The destructor may cause the remaining references to be
          // released, so stabilize the refcount and then manually
          // delete.
          ++pMessageDB->mRefCnt;
          delete pMessageDB;
        }
        i--;  // back up array index, since closing removes db from cache.
      }
    }
    NS_ASSERTION(GetNumInCache() == 0, "some msg dbs left open");     // better not be any open db's.
    delete m_dbCache;
  }
  m_dbCache = nsnull; // Need to reset to NULL since it's a
  // static global ptr and maybe referenced 
  // again in other places.
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsMsgDatabase::ClearCachedObjects ( PRBool  dbGoingAway) [protected, inherited]

Definition at line 361 of file nsMsgDatabase.cpp.

{
  ClearHdrCache(PR_FALSE);
#ifdef DEBUG_bienvenu1
  if (m_headersInUse && m_headersInUse->entryCount > 0)
  {
        NS_ASSERTION(PR_FALSE, "leaking headers");
    printf("leaking %d headers in %s\n", m_headersInUse->entryCount, (const char *) m_dbName);
  }
#endif
  // We should only clear the use hdr cache when the db is going away, or we could
  // end up with multiple copies of the same logical msg hdr, which will lead to 
  // ref-counting problems.
  if (dbGoingAway)
    ClearUseHdrCache();
  m_cachedThread = nsnull;
  m_cachedThreadId = nsMsgKey_None;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PR_CALLBACK nsMsgDatabase::ClearEntry ( PLDHashTable aTable,
PLDHashEntryHdr aEntry 
) [static, protected, inherited]

Definition at line 495 of file nsMsgDatabase.cpp.

{
  MsgHdrHashElement* element = NS_REINTERPRET_CAST(MsgHdrHashElement*, aEntry);
  element->mHdr = nsnull; // eh? Need to release this or not?
  element->mKey = nsMsgKey_None; // eh?
}
nsresult nsMsgDatabase::ClearHdrCache ( PRBool  reInit) [protected, inherited]

Definition at line 380 of file nsMsgDatabase.cpp.

{
  if (m_cachedHeaders)
  {
    // save this away in case we renter this code.
    PLDHashTable  *saveCachedHeaders = m_cachedHeaders;
    m_cachedHeaders = nsnull;
    PL_DHashTableEnumerate(saveCachedHeaders, HeaderEnumerator, nsnull);
    
    if (reInit)
    {
      PL_DHashTableFinish(saveCachedHeaders);
      PL_DHashTableInit(saveCachedHeaders, &gMsgDBHashTableOps, nsnull, sizeof(struct MsgHdrHashElement), m_cacheSize);
      m_cachedHeaders = saveCachedHeaders;
      
    }
    else
    {
      PL_DHashTableDestroy(saveCachedHeaders);
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PLDHashOperator PR_CALLBACK nsMsgDatabase::ClearHeaderEnumerator ( PLDHashTable table,
PLDHashEntryHdr hdr,
PRUint32  number,
void arg 
) [static, protected, inherited]

Definition at line 319 of file nsMsgDatabase.cpp.

{

  MsgHdrHashElement* element = NS_REINTERPRET_CAST(MsgHdrHashElement*, hdr);
  if (element && element->mHdr)
  {
    nsMsgHdr* msgHdr = NS_STATIC_CAST(nsMsgHdr*, element->mHdr);  // closed system, so this is ok
    // clear out m_mdbRow member variable - the db is going away, which means that this member
    // variable might very well point to a mork db that is gone.
    msgHdr->m_mdbRow = nsnull;
  }
  return PL_DHASH_NEXT;
}

Here is the caller graph for this function:

void nsIMsgDatabase::ClearNewList ( in boolean  notify) [inherited]
nsresult nsMsgDatabase::ClearUseHdrCache ( ) [protected, inherited]

Definition at line 532 of file nsMsgDatabase.cpp.

{
  if (m_headersInUse)
  {
    // clear mdb row pointers of any headers still in use, because the
    // underlying db is going away.
    PL_DHashTableEnumerate(m_headersInUse, ClearHeaderEnumerator, nsnull);
    PL_DHashTableDestroy(m_headersInUse);
    m_headersInUse = nsnull;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMsgDatabase::Close ( in boolean  aForceCommit) [inherited]

Here is the caller graph for this function:

nsresult nsMsgDatabase::CloseMDB ( PRBool  commit) [virtual, inherited]

Definition at line 1301 of file nsMsgDatabase.cpp.

{
  if (commit)
    Commit(nsMsgDBCommitType::kSessionCommit);
  return(NS_OK);
}

Here is the call graph for this function:

void nsIMsgDatabase::Commit ( in nsMsgDBCommit  commitType) [inherited]

Here is the caller graph for this function:

long nsIMsgDatabase::compareCollationKeys ( in octetPtr  key1,
in unsigned long  len1,
in octetPtr  key2,
in unsigned long  len2 
) [inherited]

Here is the caller graph for this function:

nsIMsgDBHdr nsIMsgDatabase::CopyHdrFromExistingHdr ( in nsMsgKey  key,
in nsIMsgDBHdr  existingHdr,
in boolean  addHdrToDB 
) [inherited]
void nsIMsgDatabase::createCollationKey ( in AString  sourceString,
out octetPtr  key,
out unsigned long  len 
) [inherited]
nsresult nsMsgDatabase::CreateMsgHdr ( nsIMdbRow hdrRow,
nsMsgKey  key,
nsIMsgDBHdr **  result 
) [virtual, inherited]

Definition at line 559 of file nsMsgDatabase.cpp.

{
  nsresult rv = GetHdrFromUseCache(key, result);
  if (NS_SUCCEEDED(rv) && *result)
  {
    hdrRow->Release();
    return rv;
  }
  
  nsMsgHdr *msgHdr = new nsMsgHdr(this, hdrRow);
  if(!msgHdr)
    return NS_ERROR_OUT_OF_MEMORY;
  msgHdr->SetMessageKey(key);
  // don't need to addref here; GetHdrFromUseCache addrefs.
  *result = msgHdr;
  
  AddHdrToCache(msgHdr, key);  
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::CreateNewThread ( nsMsgKey  key,
const char *  subject,
nsMsgThread **  newThread 
) [protected, virtual, inherited]

Definition at line 3636 of file nsMsgDatabase.cpp.

{
  nsresult    err = NS_OK;
  nsIMdbTable        *threadTable;
  struct mdbOid threadTableOID;
  struct mdbOid allThreadsTableOID;
  
  if (!pnewThread || !m_mdbStore)
    return NS_ERROR_NULL_POINTER;
  
  threadTableOID.mOid_Scope = m_hdrRowScopeToken;
  threadTableOID.mOid_Id = threadId;
  
  err  = GetStore()->NewTableWithOid(GetEnv(), &threadTableOID, m_threadTableKindToken, 
    PR_FALSE, nsnull, &threadTable);
  if (NS_FAILED(err)) 
    return err;
  
  allThreadsTableOID.mOid_Scope = m_threadRowScopeToken;
  allThreadsTableOID.mOid_Id = threadId;  
  
  // add a row for this thread in the table of all threads that we'll use
  // to do our mapping between subject strings and threads.
  nsIMdbRow *threadRow = nsnull;
  
  err = m_mdbStore->GetRow(GetEnv(), &allThreadsTableOID, &threadRow);
  if (!threadRow)    
  {
    err  = m_mdbStore->NewRowWithOid(GetEnv(), &allThreadsTableOID, &threadRow);
    if (NS_SUCCEEDED(err) && threadRow)
    {
      if (m_mdbAllThreadsTable)
        m_mdbAllThreadsTable->AddRow(GetEnv(), threadRow);
      err = CharPtrToRowCellColumn(threadRow, m_threadSubjectColumnToken, subject);
      threadRow->Release();
    }
  }
  
  *pnewThread = new nsMsgThread(this, threadTable);
  if (*pnewThread)
    (*pnewThread)->SetThreadKey(threadId);
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMsgDatabase::DeleteHeader ( in nsIMsgDBHdr  msgHdr,
in nsIDBChangeListener  instigator,
in boolean  commit,
in boolean  notify 
) [inherited]
void nsIMsgDatabase::DeleteMessage ( in nsMsgKey  key,
in nsIDBChangeListener  instigator,
in boolean  commit 
) [inherited]
NS_IMETHODIMP nsMailDatabase::DeleteMessages ( nsMsgKeyArray *  nsMsgKeys,
nsIDBChangeListener instigator 
)

Reimplemented in nsImapMailDatabase.

Definition at line 172 of file nsMailDatabase.cpp.

{
  if (!m_folderStream && m_folder)
  {
    PRBool isLocked;
    m_folder->GetLocked(&isLocked);
    if (isLocked)
    {
      NS_ASSERTION(PR_FALSE, "Some other operation is in progress");
      return NS_MSG_FOLDER_BUSY;
    }
    m_folderStream = new nsIOFileStream(nsFileSpec(*m_folderSpec));
    m_ownFolderStream = PR_TRUE;
  }

  nsresult rv = nsMsgDatabase::DeleteMessages(nsMsgKeys, instigator);
  if (m_ownFolderStream)//only if we own the stream, then we should close it
  {
    if (m_folderStream)
    {
      m_folderStream->flush(); // this does a sync
      m_folderStream->close();
      delete m_folderStream;
    }
    m_folderStream = nsnull;
    m_ownFolderStream = PR_FALSE;
  }

  SetFolderInfoValid(m_folderSpec, 0, 0);
  return rv;
}

Here is the call graph for this function:

void nsIMsgDatabase::DeleteMessages ( in nsMsgKeyArrayPtr  nsMsgKeys,
in nsIDBChangeListener  instigator 
) [inherited]

Here is the caller graph for this function:

Implements nsIMsgDatabase.

Reimplemented in nsImapMailDatabase.

Definition at line 155 of file nsMailDatabase.cpp.

{
  if (m_ownFolderStream)   //only if we own the stream, then we should close it
  {
    if (m_folderStream)
    {
      m_folderStream->flush();
      m_folderStream->close();  
      delete m_folderStream;
    }
    m_folderStream = nsnull;
    m_ownFolderStream = PR_FALSE;
  }
  SetSummaryValid(PR_TRUE);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::EnumerateMessagesWithFlag ( nsISimpleEnumerator **  result,
PRUint32 pFlag 
) [virtual, inherited]

Definition at line 3027 of file nsMsgDatabase.cpp.

Here is the call graph for this function:

Definition at line 597 of file nsMailDatabase.cpp.

{
  NS_ASSERTION(PR_FALSE, "not impl yet");
  return NS_ERROR_NOT_IMPLEMENTED;
}

Here is the caller graph for this function:

nsMsgDatabase * nsMsgDatabase::FindInCache ( nsFileSpec dbName) [static, inherited]

Definition at line 806 of file nsMsgDatabase.cpp.

{
  for (PRInt32 i = 0; i < GetDBCache()->Count(); i++)
  {
    nsMsgDatabase* pMessageDB = NS_STATIC_CAST(nsMsgDatabase*, GetDBCache()->ElementAt(i));
    if (pMessageDB->MatchDbName(dbName))
    {
      if (pMessageDB->m_mdbStore)  // don't return db without store
      {
        NS_ADDREF(pMessageDB);
        return pMessageDB;
      }
    }
  }
  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIMsgDatabase * nsMsgDatabase::FindInCache ( nsIMsgFolder folder) [static, inherited]

Definition at line 826 of file nsMsgDatabase.cpp.

{
  nsCOMPtr <nsIFileSpec> folderPath;
  nsFileSpec  folderName;
  nsresult rv = folder->GetPath(getter_AddRefs(folderPath));
  NS_ENSURE_SUCCESS(rv, nsnull);
  folderPath->GetFileSpec(&folderName);
  nsLocalFolderSummarySpec summarySpec(folderName);

  nsFileSpec dbPath(summarySpec);
  return (nsIMsgDatabase *) FindInCache(dbPath);
}

Here is the call graph for this function:

int nsMsgDatabase::FindInCache ( nsMsgDatabase pMessageDB) [static, protected, inherited]

Definition at line 842 of file nsMsgDatabase.cpp.

{
  for (PRInt32 i = 0; i < GetDBCache()->Count(); i++)
  {
    if (GetDBCache()->ElementAt(i) == pMessageDB)
      return(i);
  }
  return(-1);
}

Here is the call graph for this function:

mdb_pos nsMsgDatabase::FindInsertIndexInSortedTable ( nsIMdbTable table,
mdb_id  idToInsert 
) [protected, inherited]

Definition at line 5024 of file nsMsgDatabase.cpp.

{
  mdb_pos searchPos = 0;
  PRUint32 rowCount;
  table->GetCount(GetEnv(), &rowCount);
  mdb_pos hi = rowCount;
  mdb_pos lo = 0;
  
  while (hi > lo)
  {
    mdbOid outOid;
    searchPos = (lo + hi - 1) / 2;
    table->PosToOid(GetEnv(), searchPos, &outOid);
    if (outOid.mOid_Id == idToInsert)
    {
      NS_ASSERTION(PR_FALSE, "id shouldn't be in table");
      return hi;
    }
    if (outOid.mOid_Id > idToInsert)
      hi = searchPos;
    else // if (outOid.mOid_Id <  idToInsert)
      lo = searchPos + 1;
  }
  return hi;
}

Here is the call graph for this function:

Implements nsIMsgDatabase.

Reimplemented in nsImapMailDatabase.

Definition at line 119 of file nsMailDatabase.cpp.

Definition at line 127 of file nsMailDatabase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::GetBoolPref ( const char *  prefName,
PRBool result 
) [protected, inherited]

Definition at line 4056 of file nsMsgDatabase.cpp.

{
  PRBool prefValue = PR_FALSE;
  nsresult rv;
  nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
  if (pPrefBranch)
  {
    rv = pPrefBranch->GetBoolPref(prefName, &prefValue);
    *result = prefValue;
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsISimpleEnumerator nsIMsgDatabase::getCachedHits ( in string  aSearchFolderUri) [inherited]

Definition at line 3257 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  if (!m_collationKeyGenerator)
  {
    nsCOMPtr <nsILocale> locale; 
    nsAutoString localeName; 
    
    // get a locale service 
    nsCOMPtr <nsILocaleService> localeService = do_GetService(NS_LOCALESERVICE_CONTRACTID, &err);
    if (NS_SUCCEEDED(err))
    {
      // do this for a new db if no UI to be provided for locale selection 
      err = localeService->GetApplicationLocale(getter_AddRefs(locale)); 
      
      if (locale)
      {
        // or generate a locale from a stored locale name ("en_US", "fr_FR") 
        //err = localeFactory->NewLocale(&localeName, &locale); 
        
        nsCOMPtr <nsICollationFactory> f = do_CreateInstance(kCollationFactoryCID, &err);
        if (NS_SUCCEEDED(err) && f)
        {
          // get a collation interface instance 
          err = f->CreateCollation(locale, getter_AddRefs(m_collationKeyGenerator));
        }
      }
    }
  }
  return err;
}

Here is the call graph for this function:

virtual PRUint32 nsMailDatabase::GetCurVersion ( ) [inline, virtual]

Reimplemented from nsMsgDatabase.

Definition at line 66 of file nsMailDatabase.h.

{return kMsgDBVersion;}

Here is the caller graph for this function:

nsVoidArray * nsMsgDatabase::GetDBCache ( ) [static, protected, inherited]

Definition at line 755 of file nsMsgDatabase.cpp.

{
  if (!m_dbCache)
    m_dbCache = new nsVoidArray();
  
  return m_dbCache;
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIMdbEnv* nsMsgDatabase::GetEnv ( ) [inline, inherited]

Definition at line 109 of file nsMsgDatabase.h.

{return m_mdbEnv;}

Definition at line 513 of file nsMailDatabase.cpp.

{
       folderName.AssignWithConversion(NS_STATIC_CAST(const char*, *m_folderSpec));
       return NS_OK;
}

Reimplemented in nsImapMailDatabase.

Definition at line 82 of file nsMailDatabase.cpp.

{
  NS_ENSURE_ARG_POINTER(aFileStream);
  if (!m_folderStream)
  {
    m_folderStream = new nsIOFileStream(nsFileSpec(*m_folderSpec));
    m_ownFolderStream = PR_TRUE;
  }
  // N.B. - not a ref-counted interface pointer
  *aFileStream = m_folderStream;
  return NS_OK;
}

Here is the call graph for this function:

void nsMailDatabase::GetGlobalPrefs ( ) [protected, virtual]

Reimplemented from nsMsgDatabase.

Definition at line 98 of file nsMailDatabase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::GetHdrFromCache ( nsMsgKey  key,
nsIMsgDBHdr **  result 
) [protected, inherited]

Definition at line 255 of file nsMsgDatabase.cpp.

{
  if (!result)
    return NS_ERROR_NULL_POINTER;
  
  nsresult rv = NS_ERROR_FAILURE;
  
  *result = nsnull;
  if (m_bCacheHeaders && m_cachedHeaders)
  {
    PLDHashEntryHdr *entry;
    entry = PL_DHashTableOperate(m_cachedHeaders, (const void *) key, PL_DHASH_LOOKUP);
    if (PL_DHASH_ENTRY_IS_BUSY(entry))
    {
      MsgHdrHashElement* element = NS_REINTERPRET_CAST(MsgHdrHashElement*, entry);
      *result = element->mHdr;
      // need to do our own add ref because the PL_DHashTable doesn't addref.
      if (*result)
      {
        NS_ADDREF(*result);
        rv = NS_OK;
      }
    }    
    
  }
  return rv;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::GetHdrFromUseCache ( nsMsgKey  key,
nsIMsgDBHdr **  result 
) [protected, inherited]

Definition at line 423 of file nsMsgDatabase.cpp.

{
  if (!result)
    return NS_ERROR_NULL_POINTER;
  
  nsresult rv = NS_ERROR_FAILURE;
  
  *result = nsnull;
  
  if (m_headersInUse)
  {
    PLDHashEntryHdr *entry;
    entry = PL_DHashTableOperate(m_headersInUse, (const void *) key, PL_DHASH_LOOKUP);
    if (PL_DHASH_ENTRY_IS_BUSY(entry))
    {
      MsgHdrHashElement* element = NS_REINTERPRET_CAST(MsgHdrHashElement*, entry);
      *result = element->mHdr;
    }    
    if (*result)
    {
      NS_ADDREF(*result);
      rv = NS_OK;
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3345 of file nsMsgDatabase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::GetIntPref ( const char *  prefName,
PRInt32 result 
) [protected, inherited]

Definition at line 4069 of file nsMsgDatabase.cpp.

{
  PRInt32 prefValue = 0;
  nsresult rv;
  nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
  if (pPrefBranch)
  {
    rv = pPrefBranch->GetIntPref(prefName, &prefValue);
    *result = prefValue;
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const void *PR_CALLBACK nsMsgDatabase::GetKey ( PLDHashTable aTable,
PLDHashEntryHdr aEntry 
) [static, protected, inherited]

Definition at line 464 of file nsMsgDatabase.cpp.

{
  MsgHdrHashElement* hdr = NS_REINTERPRET_CAST(MsgHdrHashElement*, aEntry);
  return (const void *) hdr->mKey;
}

Definition at line 390 of file nsMailDatabase.cpp.

{
  PRUint32 retModTime = 0;
  nsCOMPtr <nsILocalFile> localFile;
  PRInt64 lastModTime;
  nsresult rv = NS_FileSpecToIFile(m_folderSpec, getter_AddRefs(localFile));
  if (NS_SUCCEEDED(rv))
  {
    rv = localFile->GetLastModifiedTime(&lastModTime);
    if (NS_SUCCEEDED(rv))
    {

      PRTime  temp64;
      PRInt64 thousand;
      LL_I2L(thousand, PR_MSEC_PER_SEC);
      LL_DIV(temp64, lastModTime, thousand);
      LL_L2UI(retModTime, temp64);
    }
  }
  if (!retModTime)
    m_folderSpec->GetModDate(retModTime) ;

  return retModTime;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual nsMailDatabase* nsMailDatabase::GetMailDB ( ) [inline, virtual]

Definition at line 64 of file nsMailDatabase.h.

{return this;}
nsIMdbFactory * nsMsgDatabase::GetMDBFactory ( ) [static, inherited]

Definition at line 994 of file nsMsgDatabase.cpp.

{
  static nsIMdbFactory *gMDBFactory = nsnull;
  if (!gMDBFactory)
  {
    nsCOMPtr <nsIMdbFactoryFactory> factoryfactory = do_CreateInstance(kCMorkFactory);
    if (factoryfactory)
      factoryfactory->GetMdbFactory(&gMDBFactory);
  }
  return gMDBFactory;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3167 of file nsMsgDatabase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

nsMsgHdr * nsMsgDatabase::GetMsgHdrForReference ( nsCString reference) [protected, inherited]

Definition at line 3874 of file nsMsgDatabase.cpp.

{
  NS_ASSERTION(PR_FALSE, "not implemented yet.");
  return nsnull;
}
nsIMsgDBHdr * nsMsgDatabase::GetMsgHdrForSubject ( nsCString msgID) [protected, inherited]

Definition at line 3914 of file nsMsgDatabase.cpp.

{
  nsIMsgDBHdr *msgHdr = nsnull;
  nsresult rv = NS_OK;
  mdbYarn     subjectYarn;
  
  subjectYarn.mYarn_Buf = (void*)subject.get();
  subjectYarn.mYarn_Fill = PL_strlen(subject.get());
  subjectYarn.mYarn_Form = 0;
  subjectYarn.mYarn_Size = subjectYarn.mYarn_Fill;
  
  nsIMdbRow   *hdrRow;
  mdbOid             outRowId;
  mdb_err result = GetStore()->FindRow(GetEnv(), m_hdrRowScopeToken,
    m_subjectColumnToken, &subjectYarn,  &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;
}

Here is the call graph for this function:

void nsIMsgDatabase::getNewList ( out unsigned long  count,
[array, size_is(count)] out nsMsgKey  newKeys 
) [inherited]

The list of messages currently in the NEW state.

If there are no such messages, a null pointer may be returned. the caller should free when done using nsMemory::Free.

Definition at line 535 of file nsMailDatabase.cpp.

{
  mdb_bool    hasOid;
  mdbOid             rowObjectId;
  mdb_err   err;
  
  if (!IMAPOffline)
    IMAPOffline = PR_NewLogModule("IMAPOFFLINE");
  nsresult rv = GetAllOfflineOpsTable();
  NS_ENSURE_SUCCESS(rv, rv);
  
  if (!offlineOp || !m_mdbAllOfflineOpsTable)
    return NS_ERROR_NULL_POINTER;
  
  *offlineOp = NULL;
  
  rowObjectId.mOid_Id = msgKey;
  rowObjectId.mOid_Scope = m_offlineOpsRowScopeToken;
  err = m_mdbAllOfflineOpsTable->HasOid(GetEnv(), &rowObjectId, &hasOid);
  if (err == NS_OK && m_mdbStore && (hasOid  || create))
  {
    nsCOMPtr <nsIMdbRow> offlineOpRow;
    err = m_mdbStore->GetRow(GetEnv(), &rowObjectId, getter_AddRefs(offlineOpRow));
    
    if (create)
    {
      if (!offlineOpRow)
      {
        err  = m_mdbStore->NewRowWithOid(GetEnv(), &rowObjectId, getter_AddRefs(offlineOpRow));
        NS_ENSURE_SUCCESS(err, err);
      }
      if (offlineOpRow && !hasOid)
        m_mdbAllOfflineOpsTable->AddRow(GetEnv(), offlineOpRow);
    }
    
    if (err == NS_OK && offlineOpRow)
    {
      *offlineOp = new nsMsgOfflineImapOperation(this, offlineOpRow);
      if (*offlineOp)
        (*offlineOp)->SetMessageKey(msgKey);
      NS_IF_ADDREF(*offlineOp);
    }
    if (!hasOid && m_dbFolderInfo)
    {
      // set initial value for flags so we don't lose them.
      nsCOMPtr <nsIMsgDBHdr> msgHdr;
      GetMsgHdrForKey(msgKey, getter_AddRefs(msgHdr));
      if (msgHdr)
      {
        PRUint32 flags;
        msgHdr->GetFlags(&flags);
        (*offlineOp)->SetNewFlags(flags);
      }
      PRInt32 newFlags;
      m_dbFolderInfo->OrFlags(MSG_FOLDER_FLAG_OFFLINEEVENTS, &newFlags);
    }
  }
  
  return (err == 0) ? NS_OK : NS_ERROR_FAILURE;

}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::GetProperty ( nsIMdbRow row,
const char *  propertyName,
char **  result 
) [inherited]

Definition at line 3498 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  mdb_token   property_token;
  
  if (m_mdbStore)
    err = m_mdbStore->StringToToken(GetEnv(),  propertyName, &property_token);
  else
    err = NS_ERROR_NULL_POINTER;
  if (err == NS_OK)
    err = RowCellColumnToCharPtr(row, property_token, result);
  
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::GetPropertyAsNSString ( nsIMdbRow row,
const char *  propertyName,
nsAString &  result 
) [inherited]

Definition at line 3524 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  mdb_token   property_token;
  
  err = m_mdbStore->StringToToken(GetEnv(),  propertyName, &property_token);
  if (err == NS_OK)
    err = RowCellColumnTonsString(row, property_token, result);
  
  return err;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::GetSearchResultsTable ( const char *  searchFolderUri,
PRBool  createIfMissing,
nsIMdbTable **  table 
) [inherited]

Definition at line 4892 of file nsMsgDatabase.cpp.

{
  mdb_kind kindToken;
  mdb_count numTables;
  mdb_bool mustBeUnique;
  mdb_err err = m_mdbStore->StringToToken(GetEnv(), searchFolderUri, &kindToken); 
  err = m_mdbStore->GetTableKind(GetEnv(), m_hdrRowScopeToken,  kindToken, 
                                  &numTables, &mustBeUnique, table);
  if ((!*table || NS_FAILED(err)) && createIfMissing)
    err = m_mdbStore->NewTable(GetEnv(), m_hdrRowScopeToken, kindToken, PR_TRUE, nsnull, table);

  return *table ? err : NS_ERROR_FAILURE;
}

Here is the call graph for this function:

PRUint32 nsMsgDatabase::GetStatusFlags ( nsIMsgDBHdr msgHdr,
PRUint32  origFlags 
) [protected, virtual, inherited]

Definition at line 1973 of file nsMsgDatabase.cpp.

{
  PRUint32    statusFlags = origFlags;
  PRBool      isRead = PR_TRUE;
  
  nsMsgKey key;
  (void)msgHdr->GetMessageKey(&key);
  if (m_newSet.GetSize() > 0 && m_newSet.GetAt(m_newSet.GetSize() - 1) == key || m_newSet.IndexOfSorted(key) != kNotFound)
    statusFlags |= MSG_FLAG_NEW;
  else
    statusFlags &= ~MSG_FLAG_NEW;
  if (IsHeaderRead(msgHdr, &isRead) == NS_OK && isRead)
    statusFlags |= MSG_FLAG_READ;
  return statusFlags;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIMdbStore* nsMsgDatabase::GetStore ( ) [inline, inherited]

Definition at line 110 of file nsMsgDatabase.h.

{return m_mdbStore;}

Here is the caller graph for this function:

Reimplemented in nsImapMailDatabase.

Definition at line 415 of file nsMailDatabase.cpp.

{
  NS_ENSURE_ARG_POINTER(aResult);
  PRUint32 folderSize;
  PRUint32  folderDate;
  nsFileSpec::TimeStamp actualFolderTimeStamp;
  PRInt32 numUnreadMessages;
  nsAutoString errorMsg;

        
  *aResult = PR_FALSE;
  
  if (m_folderSpec && m_dbFolderInfo)
  {
    actualFolderTimeStamp = GetMailboxModDate();
  
    m_dbFolderInfo->GetNumUnreadMessages(&numUnreadMessages);
    m_dbFolderInfo->GetFolderSize(&folderSize);
    m_dbFolderInfo->GetFolderDate(&folderDate);

    // compare current version of db versus filed out version info, 
    // and file size in db vs file size on disk.
    PRUint32 version;

    m_dbFolderInfo->GetVersion(&version);
    if (folderSize == m_folderSpec->GetFileSize() &&
        numUnreadMessages >= 0 && GetCurVersion() == version)
    {
      GetGlobalPrefs();
      // if those values are ok, check time stamp
      if (gTimeStampLeeway == 0)
        *aResult = folderDate == actualFolderTimeStamp;
      else
        *aResult = PR_ABS((PRInt32) (actualFolderTimeStamp - folderDate)) <= gTimeStampLeeway;
#ifndef PUTUP_ALERT_ON_INVALID_DB
    }
  }
#else
      if (!*aResult)
      {
        errorMsg.AppendLiteral("time stamp didn't match delta = ");
        errorMsg.AppendInt(actualFolderTimeStamp - folderDate);
        errorMsg.AppendLiteral(" leeway = ");
        errorMsg.AppendInt(gTimeStampLeeway);
      }
    }
    else if (folderSize != m_folderSpec->GetFileSize())
    {
      errorMsg.AppendLiteral("folder size didn't match db size = ");
      errorMsg.AppendInt(folderSize);
      errorMsg.AppendLiteral(" actual size = ");
      errorMsg.AppendInt(m_folderSpec->GetFileSize());
    }
    else if (numUnreadMessages < 0)
    {
      errorMsg.AppendLiteral("numUnreadMessages < 0");
    }
  }
  if (errorMsg.Length())
  {
    nsCOMPtr<nsIPrompt> dialog;

    nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
    if (wwatch)
      wwatch->GetNewPrompter(0, getter_AddRefs(dialog));
    if (dialog)
      dialog->Alert(nsnull, errorMsg.get());
  }
#endif // PUTUP_ALERT_ON_INVALID_DB
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::GetTableCreateIfMissing ( const char *  scope,
const char *  kind,
nsIMdbTable **  table,
mdb_token scopeToken,
mdb_token kindToken 
) [inherited]

Definition at line 1564 of file nsMsgDatabase.cpp.

{
  struct mdbOid tableOID;

  mdb_err err = GetStore()->StringToToken(GetEnv(), scope, &scopeToken); 
  err = GetStore()->StringToToken(GetEnv(), kind, &kindToken); 
  tableOID.mOid_Scope = scopeToken;
  tableOID.mOid_Id = 1;
  
  nsresult rv = GetStore()->GetTable(GetEnv(), &tableOID, table);
  if (rv != NS_OK)
    rv = NS_ERROR_FAILURE;
  
  // create new all all offline ops table, if it doesn't exist.
  if (NS_SUCCEEDED(rv) && !*table)
  {
    nsIMdbStore *store = GetStore();
    err = (nsresult) store->NewTable(GetEnv(), scopeToken,kindToken, 
                                    PR_FALSE, nsnull, table);
    if (err != NS_OK || !*table)
      rv = NS_ERROR_FAILURE;
  }
  NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't create offline ops table");
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::GetThreadForMsgKey ( nsMsgKey  msgKey,
nsIMsgThread **  result 
) [virtual, inherited]

Definition at line 3972 of file nsMsgDatabase.cpp.

Here is the call graph for this function:

nsIMsgThread * nsMsgDatabase::GetThreadForReference ( nsCString msgID,
nsIMsgDBHdr **  pMsgHdr 
) [protected, inherited]

Definition at line 3681 of file nsMsgDatabase.cpp.

{
  nsIMsgDBHdr *msgHdr = nsnull;
  GetMsgHdrForMessageID(msgID.get(), &msgHdr);  
  nsIMsgThread *thread = NULL;
  
  if (msgHdr != NULL)
  {
    nsMsgKey threadId;
    if (NS_SUCCEEDED(msgHdr->GetThreadId(&threadId)))
    {
      // find thread header for header whose message id we matched.
      thread = GetThreadForThreadId(threadId);
    }
    if (pMsgHdr)
      *pMsgHdr = msgHdr;
    else
      msgHdr->Release();
  }
  return thread;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIMsgThread * nsMsgDatabase::GetThreadForSubject ( nsCString subject) [protected, inherited]

Definition at line 3703 of file nsMsgDatabase.cpp.

{
  nsIMsgThread *thread = nsnull;
  
  mdbYarn     subjectYarn;
  
  subjectYarn.mYarn_Buf = (void*)subject.get();
  subjectYarn.mYarn_Fill = PL_strlen(subject.get());
  subjectYarn.mYarn_Form = 0;
  subjectYarn.mYarn_Size = subjectYarn.mYarn_Fill;
  
  nsCOMPtr <nsIMdbRow>      threadRow;
  mdbOid             outRowId;
  if (m_mdbStore)
  {
    mdb_err result = m_mdbStore->FindRow(GetEnv(), m_threadRowScopeToken,
      m_threadSubjectColumnToken, &subjectYarn,  &outRowId, getter_AddRefs(threadRow));
    if (NS_SUCCEEDED(result) && threadRow)
    {
      //Get key from row
      mdbOid outOid;
      nsMsgKey key = 0;
      if (threadRow->GetOid(GetEnv(), &outOid) == NS_OK)
        key = outOid.mOid_Id;
      // find thread header for header whose message id we matched.
      thread = GetThreadForThreadId(key);
    }
#ifdef DEBUG_bienvenu1
    else
    {
      nsresult       rv;
      nsMsgThread *pThread;
      
      nsCOMPtr <nsIMdbPortTableCursor> tableCursor;
      m_mdbStore->GetPortTableCursor(GetEnv(),   m_hdrRowScopeToken, m_threadTableKindToken,
        getter_AddRefs(tableCursor));
      
      
        nsIMdbTable *table;
        
        while (PR_TRUE) 
        {
          rv = tableCursor->NextTable(GetEnv(), &table);
          if (!table) 
            break;
          if (NS_FAILED(rv)) 
            break;
          
          pThread = new nsMsgThread(this, table);
          if(pThread)
          {
            // thread object assumes ref for table.
            NS_ADDREF(pThread);
            nsXPIDLCString curSubject;
            (void)pThread->GetSubject(getter_Copies(curSubject));
            if (subject.Equals(curSubject))
            {
              NS_ASSERTION(PR_FALSE, "thread with subject exists, but FindRow didn't find it\n");
              break;
            }
            NS_IF_RELEASE (pThread);
          }
          else
            break;
        }
      }
#endif
  }
  return thread;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIMsgThread * nsMsgDatabase::GetThreadForThreadId ( nsMsgKey  threadId) [protected, inherited]

Definition at line 3986 of file nsMsgDatabase.cpp.

{
  
  if (threadId == m_cachedThreadId && m_cachedThread)
  {
    nsIMsgThread *retThread = m_cachedThread;
    NS_ADDREF(retThread);
    return retThread;
  }
  nsMsgThread *pThread = nsnull;
  if (m_mdbStore)
  {
    mdbOid tableId;
    tableId.mOid_Id = threadId;
    tableId.mOid_Scope = m_hdrRowScopeToken;
    
    nsIMdbTable *threadTable;
    mdb_err res = m_mdbStore->GetTable(GetEnv(), &tableId, &threadTable);
    
    if (NS_SUCCEEDED(res) && threadTable)
    {
      pThread = new nsMsgThread(this, threadTable);
      if(pThread)
      {
        NS_ADDREF(pThread);
        m_cachedThread = pThread;
        m_cachedThreadId = threadId;
      }
    }
  }
  return pThread;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::GetUint32Property ( nsIMdbRow row,
const char *  propertyName,
PRUint32 result,
PRUint32  defaultValue = 0 
) [inherited]

Definition at line 3549 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  mdb_token   property_token;
  
  err = m_mdbStore->StringToToken(GetEnv(),  propertyName, &property_token);
  if (err == NS_OK)
    err = RowCellColumnToUInt32(row, property_token, result, defaultValue);
  
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PLDHashNumber PR_CALLBACK nsMsgDatabase::HashKey ( PLDHashTable aTable,
const void aKey 
) [static, protected, inherited]

Definition at line 473 of file nsMsgDatabase.cpp.

{
  return PLDHashNumber(NS_PTR_TO_INT32(aKey));
}
boolean nsIMsgDatabase::hdrIsInCache ( in string  aSearchFolderUri,
in nsIMsgDBHdr  aHdr 
) [inherited]
PLDHashOperator PR_CALLBACK nsMsgDatabase::HeaderEnumerator ( PLDHashTable table,
PLDHashEntryHdr hdr,
PRUint32  number,
void arg 
) [static, protected, inherited]

Definition at line 310 of file nsMsgDatabase.cpp.

{

  MsgHdrHashElement* element = NS_REINTERPRET_CAST(MsgHdrHashElement*, hdr);
  NS_IF_RELEASE(element->mHdr); 
  return PL_DHASH_NEXT;
}

Here is the caller graph for this function:

nsresult nsMsgDatabase::InitExistingDB ( ) [protected, virtual, inherited]

Definition at line 1591 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  
  err = InitMDBInfo();
  if (err == NS_OK)
  {
    err = GetStore()->GetTable(GetEnv(), &gAllMsgHdrsTableOID, &m_mdbAllMsgHeadersTable);
    if (err == NS_OK)
    {
      m_dbFolderInfo = new nsDBFolderInfo(this);
      if (m_dbFolderInfo)
      {
        NS_ADDREF(m_dbFolderInfo); 
        err = m_dbFolderInfo->InitFromExistingDB();
      }
    }
    else
      err = NS_ERROR_FAILURE;
    
    NS_ASSERTION(NS_SUCCEEDED(err), "failed initing existing db");
    NS_ENSURE_SUCCESS(err, err);
    // create new all msg hdrs table, if it doesn't exist.
    if (NS_SUCCEEDED(err) && !m_mdbAllMsgHeadersTable)
    {
      struct mdbOid allMsgHdrsTableOID;
      allMsgHdrsTableOID.mOid_Scope = m_hdrRowScopeToken;
      allMsgHdrsTableOID.mOid_Id = kAllMsgHdrsTableKey;
      
      mdb_err mdberr  = GetStore()->NewTableWithOid(GetEnv(), &allMsgHdrsTableOID, m_hdrTableKindToken, 
        PR_FALSE, nsnull, &m_mdbAllMsgHeadersTable);
      if (mdberr != NS_OK || !m_mdbAllMsgHeadersTable)
        err = NS_ERROR_FAILURE;
    }
    struct mdbOid allThreadsTableOID;
    allThreadsTableOID.mOid_Scope = m_threadRowScopeToken;
    allThreadsTableOID.mOid_Id = kAllThreadsTableKey;
    err = GetStore()->GetTable(GetEnv(), &gAllThreadsTableOID, &m_mdbAllThreadsTable);
    if (!m_mdbAllThreadsTable)
    {
      
      mdb_err mdberr  = GetStore()->NewTableWithOid(GetEnv(), &allThreadsTableOID, m_allThreadsTableKindToken, 
        PR_FALSE, nsnull, &m_mdbAllThreadsTable);
      if (mdberr != NS_OK || !m_mdbAllThreadsTable)
        err = NS_ERROR_FAILURE;
    }
  }
  if (NS_SUCCEEDED(err) && m_dbFolderInfo)
  {
    PRBool fixedBadRefThreading;
    m_dbFolderInfo->GetBooleanProperty(kFixedBadRefThreadingProp, PR_FALSE, &fixedBadRefThreading);
    if (!fixedBadRefThreading)
    {
      nsCOMPtr <nsISimpleEnumerator> enumerator;
      err = EnumerateMessages(getter_AddRefs(enumerator));
      if (NS_SUCCEEDED(err) && enumerator)
      {
        PRBool hasMore;
        
        while (NS_SUCCEEDED(err = enumerator->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE)) 
        {
          nsCOMPtr <nsIMsgDBHdr> msgHdr;
          err = enumerator->GetNext(getter_AddRefs(msgHdr));
          NS_ASSERTION(NS_SUCCEEDED(err), "nsMsgDBEnumerator broken");
          if (msgHdr && NS_SUCCEEDED(err))
          {
            nsXPIDLCString messageId;
            nsCAutoString firstReference;
            msgHdr->GetMessageId(getter_Copies(messageId));
            msgHdr->GetStringReference(0, firstReference);
            if (messageId.Equals(firstReference))
            {
              err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
              break;
            }
          }
        }
      }
            
      m_dbFolderInfo->SetBooleanProperty(kFixedBadRefThreadingProp, PR_TRUE);
    }
    
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::InitMDBInfo ( ) [protected, virtual, inherited]

Definition at line 1678 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  
  if (!m_mdbTokensInitialized && GetStore())
  {
    m_mdbTokensInitialized = PR_TRUE;
    err       = GetStore()->StringToToken(GetEnv(), kMsgHdrsScope, &m_hdrRowScopeToken); 
    if (err == NS_OK)
    {
      GetStore()->StringToToken(GetEnv(),  kSubjectColumnName, &m_subjectColumnToken);
      GetStore()->StringToToken(GetEnv(),  kSenderColumnName, &m_senderColumnToken);
      GetStore()->StringToToken(GetEnv(),  kMessageIdColumnName, &m_messageIdColumnToken);
      // if we just store references as a string, we won't get any savings from the
      // fact there's a lot of duplication. So we may want to break them up into
      // multiple columns, r1, r2, etc.
      GetStore()->StringToToken(GetEnv(),  kReferencesColumnName, &m_referencesColumnToken);
      // similarly, recipients could be tokenized properties
      GetStore()->StringToToken(GetEnv(),  kRecipientsColumnName, &m_recipientsColumnToken);
      GetStore()->StringToToken(GetEnv(),  kDateColumnName, &m_dateColumnToken);
      GetStore()->StringToToken(GetEnv(),  kMessageSizeColumnName, &m_messageSizeColumnToken);
      GetStore()->StringToToken(GetEnv(),  kFlagsColumnName, &m_flagsColumnToken);
      GetStore()->StringToToken(GetEnv(),  kPriorityColumnName, &m_priorityColumnToken);
      GetStore()->StringToToken(GetEnv(),  kLabelColumnName, &m_labelColumnToken);
      GetStore()->StringToToken(GetEnv(),  kStatusOffsetColumnName, &m_statusOffsetColumnToken);
      GetStore()->StringToToken(GetEnv(),  kNumLinesColumnName, &m_numLinesColumnToken);
      GetStore()->StringToToken(GetEnv(),  kCCListColumnName, &m_ccListColumnToken);
      GetStore()->StringToToken(GetEnv(),  kMessageThreadIdColumnName, &m_messageThreadIdColumnToken);
      GetStore()->StringToToken(GetEnv(),  kThreadIdColumnName, &m_threadIdColumnToken);
      GetStore()->StringToToken(GetEnv(),  kThreadFlagsColumnName, &m_threadFlagsColumnToken);
      GetStore()->StringToToken(GetEnv(),  kThreadNewestMsgDateColumnName, &m_threadNewestMsgDateColumnToken);
      GetStore()->StringToToken(GetEnv(),  kThreadChildrenColumnName, &m_threadChildrenColumnToken);
      GetStore()->StringToToken(GetEnv(),  kThreadUnreadChildrenColumnName, &m_threadUnreadChildrenColumnToken);
      GetStore()->StringToToken(GetEnv(),  kThreadSubjectColumnName, &m_threadSubjectColumnToken);
      GetStore()->StringToToken(GetEnv(),  kNumReferencesColumnName, &m_numReferencesColumnToken);
      GetStore()->StringToToken(GetEnv(),  kMessageCharSetColumnName, &m_messageCharSetColumnToken);
      err = GetStore()->StringToToken(GetEnv(), kMsgHdrsTableKind, &m_hdrTableKindToken); 
      if (err == NS_OK)
        err = GetStore()->StringToToken(GetEnv(), kThreadTableKind, &m_threadTableKindToken);
      err = GetStore()->StringToToken(GetEnv(), kAllThreadsTableKind, &m_allThreadsTableKindToken); 
      err     = GetStore()->StringToToken(GetEnv(), kThreadHdrsScope, &m_threadRowScopeToken); 
      err     = GetStore()->StringToToken(GetEnv(), kThreadParentColumnName, &m_threadParentColumnToken);
      err     = GetStore()->StringToToken(GetEnv(), kThreadRootColumnName, &m_threadRootKeyColumnToken);
      err = GetStore()->StringToToken(GetEnv(), kOfflineMsgOffsetColumnName, &m_offlineMsgOffsetColumnToken);
      err = GetStore()->StringToToken(GetEnv(), kOfflineMsgSizeColumnName, &m_offlineMessageSizeColumnToken);
      
      if (err == NS_OK)
      {
        // The table of all message hdrs will have table id 1.
        gAllMsgHdrsTableOID.mOid_Scope = m_hdrRowScopeToken;
        gAllMsgHdrsTableOID.mOid_Id = kAllMsgHdrsTableKey;
        gAllThreadsTableOID.mOid_Scope = m_threadRowScopeToken;
        gAllThreadsTableOID.mOid_Id = kAllThreadsTableKey;
        
      }
    }
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::InitNewDB ( ) [protected, virtual, inherited]

Definition at line 1521 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  
  err = InitMDBInfo();
  if (err == NS_OK)
  {
    nsDBFolderInfo *dbFolderInfo = new nsDBFolderInfo(this); 
    if (dbFolderInfo)
    {
      NS_ADDREF(dbFolderInfo); 
      err = dbFolderInfo->AddToNewMDB();
      dbFolderInfo->SetVersion(GetCurVersion());
      dbFolderInfo->SetBooleanProperty(kFixedBadRefThreadingProp, PR_TRUE);
      nsIMdbStore *store = GetStore();
      // create the unique table for the dbFolderInfo.
      mdb_err mdberr;
      struct mdbOid allMsgHdrsTableOID;
      struct mdbOid allThreadsTableOID;
      if (!store)
        return NS_ERROR_NULL_POINTER;
      
      allMsgHdrsTableOID.mOid_Scope = m_hdrRowScopeToken;
      allMsgHdrsTableOID.mOid_Id = kAllMsgHdrsTableKey;
      allThreadsTableOID.mOid_Scope = m_threadRowScopeToken;
      allThreadsTableOID.mOid_Id = kAllThreadsTableKey;
      
      mdberr  = store->NewTableWithOid(GetEnv(), &allMsgHdrsTableOID, m_hdrTableKindToken, 
        PR_FALSE, nsnull, &m_mdbAllMsgHeadersTable);
      
      // error here is not fatal.
      store->NewTableWithOid(GetEnv(), &allThreadsTableOID, m_allThreadsTableKindToken, 
        PR_FALSE, nsnull, &m_mdbAllThreadsTable);

      m_dbFolderInfo = dbFolderInfo;
      
    }
    else
      err = NS_ERROR_OUT_OF_MEMORY;
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::IsHeaderRead ( nsIMsgDBHdr hdr,
PRBool pRead 
) [virtual, inherited]

Reimplemented in nsNewsDatabase.

Definition at line 1989 of file nsMsgDatabase.cpp.

{
  if (!msgHdr)
    return NS_MSG_MESSAGE_NOT_FOUND;
  
  nsMsgHdr* hdr = NS_STATIC_CAST(nsMsgHdr*, msgHdr);          // closed system, cast ok
  // can't call GetFlags, because it will be recursive.
  PRUint32 flags;
  hdr->GetRawFlags(&flags);
  *pRead = (flags & MSG_FLAG_READ) != 0;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsIMsgDatabase::IsRead ( in nsMsgKey  key) [inherited]
void nsIMsgDatabase::ListAllKeys ( in nsMsgKeyArrayRef  outputKeys) [inherited]

Here is the caller graph for this function:

NS_IMETHODIMP nsMailDatabase::ListAllOfflineDeletes ( nsMsgKeyArray *  offlineDeletes)

Definition at line 651 of file nsMailDatabase.cpp.

{
  if (!offlineDeletes)
    return NS_ERROR_NULL_POINTER;
  
  nsresult rv = GetAllOfflineOpsTable();
  NS_ENSURE_SUCCESS(rv, rv);
  nsIMdbTableRowCursor *rowCursor;
  if (m_mdbAllOfflineOpsTable)
  {
    nsresult err = m_mdbAllOfflineOpsTable->GetTableRowCursor(GetEnv(), -1, &rowCursor);
    while (err == NS_OK && rowCursor)
    {
      mdbOid outOid;
      mdb_pos outPos;
      nsIMdbRow* offlineOpRow;
      
      err = rowCursor->NextRow(GetEnv(), &offlineOpRow, &outPos);
      // is this right? Mork is returning a 0 id, but that should valid.
      if (outPos < 0 || offlineOpRow == nsnull)  
        break;
      if (err == NS_OK)
      {
        offlineOpRow->GetOid(GetEnv(), &outOid);
        nsIMsgOfflineImapOperation *offlineOp = new nsMsgOfflineImapOperation(this, offlineOpRow);
        if (offlineOp)
        {
          NS_ADDREF(offlineOp);
          imapMessageFlagsType newFlags;
          nsOfflineImapOperationType opType;
          
          offlineOp->GetOperation(&opType);
          offlineOp->GetNewFlags(&newFlags);
          if (opType & nsIMsgOfflineImapOperation::kMsgMoved || 
            ((opType & nsIMsgOfflineImapOperation::kFlagsChanged) 
            && (newFlags & nsIMsgOfflineImapOperation::kMsgMarkedDeleted)))
            offlineDeletes->Add(outOid.mOid_Id);
          NS_RELEASE(offlineOp);
        }
        offlineOpRow->Release();
      }
    }
    rv = (err == NS_OK) ? NS_OK : NS_ERROR_FAILURE;
    rowCursor->Release();
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsMailDatabase::ListAllOfflineOpIds ( nsMsgKeyArray *  offlineOpIds)

Definition at line 604 of file nsMailDatabase.cpp.

{
  NS_ENSURE_ARG(offlineOpIds);
  nsresult rv = GetAllOfflineOpsTable();
  NS_ENSURE_SUCCESS(rv, rv);
  nsIMdbTableRowCursor *rowCursor;
  if (!IMAPOffline)
    IMAPOffline = PR_NewLogModule("IMAPOFFLINE");

  if (m_mdbAllOfflineOpsTable)
  {
    nsresult err = m_mdbAllOfflineOpsTable->GetTableRowCursor(GetEnv(), -1, &rowCursor);
    while (err == NS_OK && rowCursor)
    {
      mdbOid outOid;
      mdb_pos outPos;
      
      err = rowCursor->NextRowOid(GetEnv(), &outOid, &outPos);
      // is this right? Mork is returning a 0 id, but that should valid.
      if (outPos < 0 || outOid.mOid_Id == (mdb_id) -1)  
        break;
      if (err == NS_OK)
      {
        offlineOpIds->Add(outOid.mOid_Id);
        if (PR_LOG_TEST(IMAPOffline, PR_LOG_ALWAYS))
        {
          nsCOMPtr <nsIMsgOfflineImapOperation> offlineOp;
          GetOfflineOpForKey(outOid.mOid_Id, PR_FALSE, getter_AddRefs(offlineOp));
          if (offlineOp)
          {
            nsMsgOfflineImapOperation *logOp = NS_STATIC_CAST(nsMsgOfflineImapOperation *, 
              NS_STATIC_CAST(nsIMsgOfflineImapOperation *, offlineOp.get()));
            if (logOp)
              logOp->Log(IMAPOffline);

          }
        }
      }
    }
    rv = (err == NS_OK) ? NS_OK : NS_ERROR_FAILURE;
    rowCursor->Release();
  }
  
  offlineOpIds->QuickSort();
  return rv;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::ListAllThreads ( nsMsgKeyArray *  threadIds) [inherited]

Definition at line 4083 of file nsMsgDatabase.cpp.

{
  nsresult           rv;
  nsMsgThread        *pThread;
  
  nsCOMPtr <nsISimpleEnumerator> threads;
  rv = EnumerateThreads(getter_AddRefs(threads));
  if (NS_FAILED(rv)) return rv;
  PRBool hasMore = PR_FALSE;
  
  while (NS_SUCCEEDED(rv = threads->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE)) 
  {
    rv = threads->GetNext((nsISupports**)&pThread);
    NS_ENSURE_SUCCESS(rv,rv);
    
    if (threadIds) {
      nsMsgKey key;
      (void)pThread->GetThreadKey(&key);
      threadIds->Add(key);
    }
    //        NS_RELEASE(pThread);
    pThread = nsnull;
  }
  return rv;
}

Here is the call graph for this function:

void nsIMsgDatabase::MarkAllRead ( in nsMsgKeyArrayPtr  thoseMarked) [inherited]
void nsIMsgDatabase::MarkForwarded ( in nsMsgKey  key,
in boolean  bForwarded,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkHasAttachments ( in nsMsgKey  key,
in boolean  bHasAttachments,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkHdrMarked ( in nsIMsgDBHdr  msgHdr,
in boolean  mark,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkHdrRead ( in nsIMsgDBHdr  msgHdr,
in boolean  bRead,
in nsIDBChangeListener  instigator 
) [inherited]

Here is the caller graph for this function:

nsresult nsMsgDatabase::MarkHdrReadInDB ( nsIMsgDBHdr msgHdr,
PRBool  bRead,
nsIDBChangeListener instigator 
) [virtual, inherited]

Definition at line 2056 of file nsMsgDatabase.cpp.

{
  nsresult rv;
  nsMsgKey key;
  PRUint32 oldFlags;
  PRBool   hdrInDB;
  (void)msgHdr->GetMessageKey(&key);
  msgHdr->GetFlags(&oldFlags);
  
  m_newSet.RemoveElement(key);
  (void) ContainsKey(key, &hdrInDB);
  if (hdrInDB && m_dbFolderInfo)
  {
    if (bRead)
      m_dbFolderInfo->ChangeNumUnreadMessages(-1);
    else
      m_dbFolderInfo->ChangeNumUnreadMessages(1);
  }
  
  SetHdrReadFlag(msgHdr, bRead); // this will cause a commit, at least for local mail, so do it after we change
  // the folder counts above, so they will get committed too.
  PRUint32 flags;
  rv = msgHdr->GetFlags(&flags);
  flags &= ~MSG_FLAG_NEW;
  msgHdr->SetFlags(flags);
  if (NS_FAILED(rv)) return rv;
  
  if (oldFlags == flags)
    return NS_OK;
  
  return NotifyHdrChangeAll(msgHdr, oldFlags, flags, instigator);
}

Here is the call graph for this function:

void nsIMsgDatabase::MarkHdrReplied ( in nsIMsgDBHdr  msgHdr,
in boolean  bReplied,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkImapDeleted ( in nsMsgKey  key,
in boolean  deleted,
in nsIDBChangeListener  instigator 
) [inherited]

Here is the caller graph for this function:

void nsIMsgDatabase::MarkMarked ( in nsMsgKey  key,
in boolean  mark,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkMDNNeeded ( in nsMsgKey  key,
in boolean  bNeeded,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkMDNSent ( in nsMsgKey  key,
in boolean  bNeeded,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkOffline ( in nsMsgKey  key,
in boolean  offline,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkRead ( in nsMsgKey  key,
in boolean  bRead,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkReadByDate ( in PRTime  startDate,
in PRTime  endDate,
in nsMsgKeyArrayPtr  markedIds 
) [inherited]
void nsIMsgDatabase::MarkReplied ( in nsMsgKey  key,
in boolean  bReplied,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkThreadIgnored ( in nsIMsgThread  thread,
in nsMsgKey  threadKey,
in boolean  bIgnored,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIMsgDatabase::MarkThreadRead ( in nsIMsgThread  thread,
in nsIDBChangeListener  instigator,
in nsMsgKeyArrayPtr  thoseMarked 
) [inherited]
void nsIMsgDatabase::MarkThreadWatched ( in nsIMsgThread  thread,
in nsMsgKey  threadKey,
in boolean  bWatched,
in nsIDBChangeListener  instigator 
) [inherited]
PRBool nsMsgDatabase::MatchDbName ( nsFileSpec dbName) [protected, inherited]

Definition at line 852 of file nsMsgDatabase.cpp.

{
  return (m_dbName == dbName); 
}

Here is the caller graph for this function:

PRBool PR_CALLBACK nsMsgDatabase::MatchEntry ( PLDHashTable aTable,
const PLDHashEntryHdr aEntry,
const void aKey 
) [static, protected, inherited]

Definition at line 479 of file nsMsgDatabase.cpp.

{
  const MsgHdrHashElement* hdr = NS_REINTERPRET_CAST(const MsgHdrHashElement*, aEntry);
  return aKey == (const void *) hdr->mKey; // ### or get the key from the hdr...
}
void PR_CALLBACK nsMsgDatabase::MoveEntry ( PLDHashTable aTable,
const PLDHashEntryHdr aFrom,
PLDHashEntryHdr aTo 
) [static, protected, inherited]

Definition at line 486 of file nsMsgDatabase.cpp.

{
  const MsgHdrHashElement* from = NS_REINTERPRET_CAST(const MsgHdrHashElement*, aFrom);
  MsgHdrHashElement* to = NS_REINTERPRET_CAST(MsgHdrHashElement*, aTo);
  // ### eh? Why is this needed? I don't think we have a copy operator?
  *to = *from;
}

Here is the caller graph for this function:

void nsIDBChangeAnnouncer::NotifyHdrAddedAll ( in nsIMsgDBHdr  aHdrAdded,
in nsMsgKey  parentKey,
in long  flags,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIDBChangeAnnouncer::NotifyHdrChangeAll ( in nsIMsgDBHdr  aHdrChanged,
in unsigned long  aOldFlags,
in unsigned long  aNewFlags,
in nsIDBChangeListener  instigator 
) [inherited]

Here is the caller graph for this function:

void nsIDBChangeAnnouncer::NotifyHdrDeletedAll ( in nsIMsgDBHdr  aHdrDeleted,
in nsMsgKey  parentKey,
in long  flags,
in nsIDBChangeListener  instigator 
) [inherited]
void nsIDBChangeAnnouncer::NotifyParentChangedAll ( in nsMsgKey  keyReparented,
in nsMsgKey  oldParent,
in nsMsgKey  newParent,
in nsIDBChangeListener  instigator 
) [inherited]

Here is the caller graph for this function:

Here is the caller graph for this function:

struct mdbYarn * nsMsgDatabase::nsStringToYarn ( struct mdbYarn yarn,
const nsAString &  str 
) [static, read, inherited]

Definition at line 3436 of file nsMsgDatabase.cpp.

{
  yarn->mYarn_Buf = ToNewCString(str);
  yarn->mYarn_Size = str.Length() + 1;
  yarn->mYarn_Fill = yarn->mYarn_Size - 1;
  yarn->mYarn_Form = 0;     // what to do with this? we're storing csid in the msg hdr...
  return yarn;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsMailDatabase::Open ( nsIFileSpec aFolderName,
PRBool  create,
PRBool  upgrading 
)

Definition at line 110 of file nsMailDatabase.cpp.

{
  nsFileSpec  folderName;
  aFolderName->GetFileSpec(&folderName);
  m_folderSpec = new nsFileSpec(folderName);
  nsresult rv = nsMsgDatabase::Open(aFolderName, aCreate, aUpgrading);
  return rv;
}

Here is the call graph for this function:

void nsIMsgDatabase::Open ( in nsIFileSpec  aFolderName,
in boolean  aCreate,
in boolean  aLeaveInvalidDB 
) [inherited]
nsresult nsMsgDatabase::OpenMDB ( const char *  dbName,
PRBool  create 
) [virtual, inherited]

Definition at line 1183 of file nsMsgDatabase.cpp.

{
  nsresult ret = NS_OK;
  nsIMdbFactory *myMDBFactory = GetMDBFactory();
  if (myMDBFactory)
  {
    ret = myMDBFactory->MakeEnv(NULL, &m_mdbEnv);
    if (NS_SUCCEEDED(ret))
    {
      nsIMdbThumb *thumb = nsnull;
      struct stat st;
      char    *nativeFileName = nsCRT::strdup(dbName);
      nsIMdbHeap* dbHeap = 0;
      mdb_bool dbFrozen = mdbBool_kFalse; // not readonly, we want modifiable
      
      if (!nativeFileName)
        return NS_ERROR_OUT_OF_MEMORY;
      
      if (m_mdbEnv)
        m_mdbEnv->SetAutoClear(PR_TRUE);
      m_dbName = dbName;
#if defined(XP_WIN) || defined(XP_OS2) || defined(XP_MAC)
      UnixToNative(nativeFileName);
#endif
      if (stat(nativeFileName, &st)) 
        ret = NS_MSG_ERROR_FOLDER_SUMMARY_MISSING;
      else
      {
        mdbOpenPolicy inOpenPolicy;
        mdb_bool     canOpen;
        mdbYarn             outFormatVersion;
        
        nsIMdbFile* oldFile = 0;
        ret = myMDBFactory->OpenOldFile(m_mdbEnv, dbHeap, nativeFileName,
          dbFrozen, &oldFile);
        if ( oldFile )
        {
          if ( ret == NS_OK )
          {
            ret = myMDBFactory->CanOpenFilePort(m_mdbEnv, oldFile, // the file to investigate
              &canOpen, &outFormatVersion);
            if (ret == 0 && canOpen)
            {
              inOpenPolicy.mOpenPolicy_ScopePlan.mScopeStringSet_Count = 0;
              inOpenPolicy.mOpenPolicy_MinMemory = 0;
              inOpenPolicy.mOpenPolicy_MaxLazy = 0;
              
              ret = myMDBFactory->OpenFileStore(m_mdbEnv, dbHeap,
                oldFile, &inOpenPolicy, &thumb); 
            }
            else
              ret = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
          }
          NS_RELEASE(oldFile); // always release our file ref, store has own
        }
      }
      if (NS_SUCCEEDED(ret) && thumb)
      {
        mdb_count outTotal;    // total somethings to do in operation
        mdb_count outCurrent;  // subportion of total completed so far
        mdb_bool outDone = PR_FALSE;      // is operation finished?
        mdb_bool outBroken;     // is operation irreparably dead and broken?
        do
        {
          ret = thumb->DoMore(m_mdbEnv, &outTotal, &outCurrent, &outDone, &outBroken);
          if (ret != 0)
          {// mork isn't really doing NS erorrs yet.
            outDone = PR_TRUE;
            break;
          }
        }
        while (NS_SUCCEEDED(ret) && !outBroken && !outDone);
        //                         m_mdbEnv->ClearErrors(); // ### temporary...
        // only 0 is a non-error return.
        if (ret == 0 && outDone)
        {
          ret = myMDBFactory->ThumbToOpenStore(m_mdbEnv, thumb, &m_mdbStore);
          if (ret == NS_OK)
            ret = (m_mdbStore) ? InitExistingDB() : NS_ERROR_FAILURE;
        }
#ifdef DEBUG_bienvenu1
        DumpContents();
#endif
      }
      else if (create)      // ### need error code saying why open file store failed
      {
        nsIMdbFile* newFile = 0;
        ret = myMDBFactory->CreateNewFile(m_mdbEnv, dbHeap, dbName, &newFile);
        if (NS_FAILED(ret))
          ret = NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
        if ( newFile )
        {
          if (ret == NS_OK)
          {
            mdbOpenPolicy inOpenPolicy;
            
            inOpenPolicy.mOpenPolicy_ScopePlan.mScopeStringSet_Count = 0;
            inOpenPolicy.mOpenPolicy_MinMemory = 0;
            inOpenPolicy.mOpenPolicy_MaxLazy = 0;
            
            ret = myMDBFactory->CreateNewFileStore(m_mdbEnv, dbHeap,
              newFile, &inOpenPolicy, &m_mdbStore);
            if (ret == NS_OK)
              ret = (m_mdbStore) ? InitNewDB() : NS_ERROR_FAILURE;
          }
          NS_RELEASE(newFile); // always release our file ref, store has own
        }
      }
      NS_IF_RELEASE(thumb);
      nsCRT::free(nativeFileName);
    }
  }
#ifdef DEBUG_David_Bienvenu
//  NS_ASSERTION(NS_SUCCEEDED(ret), "failed opening mdb");
#endif
  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::PurgeExcessMessages ( PRUint32  numHeadersToKeep,
PRBool  keepUnreadMessagesOnly,
nsISupportsArray hdrsToDelete 
) [protected, inherited]

Definition at line 4576 of file nsMsgDatabase.cpp.

{
  nsresult rv = NS_OK;
  nsMsgHdr           *pHeader;
  nsCOMPtr <nsISimpleEnumerator> hdrs;
  rv = EnumerateMessages(getter_AddRefs(hdrs));
  if (NS_FAILED(rv))
    return rv;
  PRBool hasMore = PR_FALSE;
  nsMsgKeyArray keysToDelete;
  
  mdb_count numHdrs = 0;
  if (m_mdbAllMsgHeadersTable)
    m_mdbAllMsgHeadersTable->GetCount(GetEnv(), &numHdrs);
  else
    return NS_ERROR_NULL_POINTER;
  
  while (NS_SUCCEEDED(rv = hdrs->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE)) 
  {
    PRBool purgeHdr = PR_FALSE;
    rv = hdrs->GetNext((nsISupports**)&pHeader);
    NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
    if (NS_FAILED(rv)) 
      break;
    
    if (keepUnreadMessagesOnly)
    {
      PRBool isRead;
      IsHeaderRead(pHeader, &isRead);
      if (isRead)
        purgeHdr = PR_TRUE;
      
    }
    // this isn't quite right - we want to prefer unread messages (keep all of those we can)
    if (numHdrs > numHeadersToKeep)
      purgeHdr = PR_TRUE;
    
    if (purgeHdr)
    {
      nsMsgKey msgKey;
      pHeader->GetMessageKey(&msgKey);
      keysToDelete.Add(msgKey);
      numHdrs--;
      if (hdrsToDelete)
        hdrsToDelete->AppendElement(pHeader);
    }
    NS_RELEASE(pHeader);
  }
  
  if (!hdrsToDelete)
  {
    PRInt32 numKeysToDelete = keysToDelete.GetSize();
    if (numKeysToDelete > 0)
    {
      DeleteMessages(&keysToDelete, nsnull);
      if (numKeysToDelete > 10)    // compress commit if we deleted more than 10
        Commit(nsMsgDBCommitType::kCompressCommit);
      else
        Commit(nsMsgDBCommitType::kLargeCommit);
    }
  }
  return rv;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::PurgeMessagesOlderThan ( PRUint32  daysToKeepHdrs,
PRBool  keepUnreadMessagesOnly,
nsISupportsArray hdrsToDelete 
) [protected, inherited]

Definition at line 4504 of file nsMsgDatabase.cpp.

{
  nsresult rv = NS_OK;
  nsMsgHdr           *pHeader;
  nsCOMPtr <nsISimpleEnumerator> hdrs;
  rv = EnumerateMessages(getter_AddRefs(hdrs));
  nsMsgKeyArray keysToDelete;
  
  if (NS_FAILED(rv))
    return rv;
  PRBool hasMore = PR_FALSE;
  
  PRTime now = PR_Now();
  PRTime cutOffDay;
  
  PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInDay;
  
  LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
  LL_UI2L(secondsInDays, 60 * 60 * 24 * daysToKeepHdrs);
  LL_MUL(microSecondsInDay, secondsInDays, microSecondsPerSecond);
  
  LL_SUB(cutOffDay, now, microSecondsInDay); // = now - term->m_value.u.age * 60 * 60 * 24; 
  // so now cutOffDay is the PRTime cut-off point. Any msg with a date less than that will get purged.
  while (NS_SUCCEEDED(rv = hdrs->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE)) 
  {
    PRBool purgeHdr = PR_FALSE;
    
    rv = hdrs->GetNext((nsISupports**)&pHeader);
    NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
    if (NS_FAILED(rv)) 
      break;
    
    if (keepUnreadMessagesOnly)
    {
      PRBool isRead;
      IsHeaderRead(pHeader, &isRead);
      if (isRead)
        purgeHdr = PR_TRUE;
      
    }
    if (!purgeHdr)
    {
      PRTime date;
      pHeader->GetDate(&date);
      if (LL_CMP(date, <, cutOffDay))
        purgeHdr = PR_TRUE;
    }
    if (purgeHdr)
    {
      nsMsgKey msgKey;
      pHeader->GetMessageKey(&msgKey);
      keysToDelete.Add(msgKey);
      if (hdrsToDelete)
        hdrsToDelete->AppendElement(pHeader);
    }
    NS_RELEASE(pHeader);
  }
  
  if (!hdrsToDelete)
  {
    DeleteMessages(&keysToDelete, nsnull);
  
    if (keysToDelete.GetSize() > 10)      // compress commit if we deleted more than 10
      Commit(nsMsgDBCommitType::kCompressCommit);
    else if (keysToDelete.GetSize() > 0)
      Commit(nsMsgDBCommitType::kLargeCommit);
  }
  return rv;
}

Here is the call graph for this function:

void nsIMsgDatabase::refreshCache ( in string  aSearchFolderUri,
in unsigned long  aNumKeys,
[array, size_is(aNumKeys)] in nsMsgKey  aNewHits,
out unsigned long  aNumBadHits,
[array, size_is(aNumBadHits)] out nsMsgKey  aStaleHits 
) [inherited]
void nsMsgDatabase::RemoveFromCache ( nsMsgDatabase pMessageDB) [static, protected, inherited]

Definition at line 860 of file nsMsgDatabase.cpp.

{
  int i = FindInCache(pMessageDB);
  if (i != -1)
    GetDBCache()->RemoveElementAt(i);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::RemoveHdrFromCache ( nsIMsgDBHdr hdr,
nsMsgKey  key 
) [protected, inherited]

Definition at line 404 of file nsMsgDatabase.cpp.

{
  if (m_cachedHeaders)
  {
    if (key == nsMsgKey_None)
      hdr->GetMessageKey(&key);
    
    PLDHashEntryHdr *entry = PL_DHashTableOperate(m_cachedHeaders, (const void *) key, PL_DHASH_LOOKUP);
    if (PL_DHASH_ENTRY_IS_BUSY(entry))
    {
      PL_DHashTableOperate(m_cachedHeaders, (void *) key, PL_DHASH_REMOVE);
      NS_RELEASE(hdr); // get rid of extra ref the cache was holding.
    }
    
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::RemoveHdrFromUseCache ( nsIMsgDBHdr hdr,
nsMsgKey  key 
) [protected, inherited]

Definition at line 545 of file nsMsgDatabase.cpp.

{
  if (m_headersInUse)
  {
    if (key == nsMsgKey_None)
      hdr->GetMessageKey(&key);
    
    PL_DHashTableOperate(m_headersInUse, (void *) key, PL_DHASH_REMOVE);
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::RemoveHeaderFromDB ( nsMsgHdr msgHdr) [protected, virtual, inherited]

Definition at line 1948 of file nsMsgDatabase.cpp.

{
  if (!msgHdr)
    return NS_ERROR_NULL_POINTER;
  nsresult ret = NS_OK;
  
  RemoveHdrFromCache(msgHdr, nsMsgKey_None);
  nsIMdbRow* row = msgHdr->GetMDBRow();
  ret = m_mdbAllMsgHeadersTable->CutRow(GetEnv(), row);
  row->CutAllColumns(GetEnv());
  msgHdr->m_initedValues = 0; // invalidate cached values.
  return ret;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::RemoveHeaderFromThread ( nsMsgHdr msgHdr) [protected, virtual, inherited]

Definition at line 1922 of file nsMsgDatabase.cpp.

{
  if (!msgHdr)
    return NS_ERROR_NULL_POINTER;
  nsresult ret = NS_OK;
  nsCOMPtr <nsIMsgThread> thread ;
  ret = GetThreadContainingMsgHdr(msgHdr, getter_AddRefs(thread));
  if (NS_SUCCEEDED(ret) && thread)
  {
    nsCOMPtr <nsIDBChangeAnnouncer> announcer = do_QueryInterface(this);
    ret = thread->RemoveChildHdr(msgHdr, announcer);
  }
  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 520 of file nsMailDatabase.cpp.

{
  
  nsresult rv = GetAllOfflineOpsTable();
  NS_ENSURE_SUCCESS(rv, rv);
  
  if (!op || !m_mdbAllOfflineOpsTable)
    return NS_ERROR_NULL_POINTER;
  nsMsgOfflineImapOperation* offlineOp = NS_STATIC_CAST(nsMsgOfflineImapOperation*, op);  // closed system, so this is ok
  nsIMdbRow* row = offlineOp->GetMDBRow();
  rv = m_mdbAllOfflineOpsTable->CutRow(GetEnv(), row);
  row->CutAllColumns(GetEnv());
  return rv;
}

Here is the call graph for this function:

void nsIMsgDatabase::resetHdrCacheSize ( in unsigned long  size) [inherited]
nsresult nsMsgDatabase::RowCellColumnToAddressCollationKey ( nsIMdbRow row,
mdb_token  colToken,
PRUint8 **  result,
PRUint32 len 
) [inherited]

Definition at line 3206 of file nsMsgDatabase.cpp.

{
  const char *cSender;
  nsXPIDLCString name;
  
  nsresult ret = RowCellColumnToConstCharPtr(row, colToken, &cSender);
  if (NS_SUCCEEDED(ret))
  {
    nsIMsgHeaderParser *headerParser = GetHeaderParser();
    if (headerParser)
    {
      // apply mime decode
      nsIMimeConverter *converter = GetMimeConverter();
      
      if (NS_SUCCEEDED(ret) && nsnull != converter) 
      {
        char *resultStr = nsnull;
        char *charset;
        PRBool characterSetOverride;
        m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
        ret = RowCellColumnToCharPtr(row, m_messageCharSetColumnToken, &charset);
        if (NS_FAILED(ret) || !*charset || !PL_strcasecmp(charset, "us-ascii") ||
            characterSetOverride)
        {
          PR_Free(charset);
          m_dbFolderInfo->GetCharPtrCharacterSet(&charset);
        }

        ret = converter->DecodeMimeHeader(cSender, &resultStr,
          charset, characterSetOverride);
        if (NS_SUCCEEDED(ret) && resultStr)
        {
          ret = headerParser->ExtractHeaderAddressName ("UTF-8", resultStr, getter_Copies(name));
        }
        else {
          ret = headerParser->ExtractHeaderAddressName ("UTF-8", cSender, getter_Copies(name));
        }
        PR_FREEIF(resultStr);
        PR_FREEIF(charset);
      }
      
    }
  }
  if (NS_SUCCEEDED(ret))
  {
    ret = CreateCollationKey(NS_ConvertUTF8toUCS2(name), result, len);
  }
  
  return ret;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::RowCellColumnToCharPtr ( nsIMdbRow row,
mdb_token  columnToken,
char **  result 
) [inherited]

Definition at line 3408 of file nsMsgDatabase.cpp.

{
  nsresult    err = NS_ERROR_NULL_POINTER;
  
  if (row && result)
  {
    struct mdbYarn yarn;
    err = row->AliasCellYarn(GetEnv(), columnToken, &yarn);
    if (err == NS_OK)
    {
      *result = (char *) PR_CALLOC(yarn.mYarn_Fill + 1);
      if (*result)
      {
        if (yarn.mYarn_Fill > 0)
          memcpy(*result, yarn.mYarn_Buf, yarn.mYarn_Fill);
        else
          **result = 0;
      }
      else
        err = NS_ERROR_OUT_OF_MEMORY;
      
    }
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::RowCellColumnToCollationKey ( nsIMdbRow row,
mdb_token  columnToken,
PRUint8 **  result,
PRUint32 len 
) [inherited]

Definition at line 3289 of file nsMsgDatabase.cpp.

{
  const char *nakedString = nsnull;
  nsresult err;
  
  err = RowCellColumnToConstCharPtr(row, columnToken, &nakedString);
  if (NS_SUCCEEDED(err))
  {
    GetMimeConverter();
    if (m_mimeConverter) 
    {
      nsXPIDLCString decodedStr;
      char *charSet;
      PRBool characterSetOverride;
      m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
      err = RowCellColumnToCharPtr(row, m_messageCharSetColumnToken, &charSet);
      if (NS_FAILED(err) || !*charSet || !PL_strcasecmp(charSet, "us-ascii") ||
          characterSetOverride)
      {
        PR_Free(charSet);
        m_dbFolderInfo->GetCharPtrCharacterSet(&charSet);
      }
      
      err = m_mimeConverter->DecodeMimeHeader(nakedString, getter_Copies(decodedStr), charSet, characterSetOverride);
      if (NS_SUCCEEDED(err))
        err = CreateCollationKey(NS_ConvertUTF8toUCS2(decodedStr), result, len);
      PR_Free(charSet);
    }
  }
  return err;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::RowCellColumnToConstCharPtr ( nsIMdbRow row,
mdb_token  columnToken,
const char **  ptr 
) [inherited]

Definition at line 3153 of file nsMsgDatabase.cpp.

{
  nsresult    err = NS_OK;
  
  if (hdrRow) // ### probably should be an error if hdrRow is NULL...
  {
    struct mdbYarn yarn;
    err = hdrRow->AliasCellYarn(GetEnv(), columnToken, &yarn);
    if (err == NS_OK)
      *ptr = (const char*)yarn.mYarn_Buf;
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::RowCellColumnToMime2DecodedString ( nsIMdbRow row,
mdb_token  columnToken,
PRUnichar **  resultStr 
) [inherited]

Definition at line 3177 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  const char *nakedString = nsnull;
  err = RowCellColumnToConstCharPtr(row, columnToken, &nakedString);
  if (NS_SUCCEEDED(err) && nakedString && strlen(nakedString))
  {
    GetMimeConverter();
    if (m_mimeConverter) 
    {
      nsAutoString decodedStr;
      char *charSet;
      PRBool characterSetOverride;
      m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
      err = RowCellColumnToCharPtr(row, m_messageCharSetColumnToken, &charSet);
      if (NS_FAILED(err) || !*charSet || !PL_strcasecmp(charSet, "us-ascii") ||
          characterSetOverride)
      {
        PR_Free(charSet);
        m_dbFolderInfo->GetCharPtrCharacterSet(&charSet);
      }

      err = m_mimeConverter->DecodeMimeHeader(nakedString, resultStr, charSet, characterSetOverride);
      PR_Free(charSet);
    }
  }
  return err;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::RowCellColumnTonsString ( nsIMdbRow row,
mdb_token  columnToken,
nsAString &  resultStr 
) [inherited]

Definition at line 3137 of file nsMsgDatabase.cpp.

{
  nsresult    err = NS_OK;
  
  if (hdrRow) // ### probably should be an error if hdrRow is NULL...
  {
    struct mdbYarn yarn;
    err = hdrRow->AliasCellYarn(GetEnv(), columnToken, &yarn);
    if (err == NS_OK)
      YarnTonsString(&yarn, resultStr);
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::RowCellColumnToUInt32 ( nsIMdbRow row,
mdb_token  columnToken,
PRUint32 uint32Result,
PRUint32  defaultValue = 0 
) [inherited]

Definition at line 3361 of file nsMsgDatabase.cpp.

{
  nsresult    err = NS_OK;
  
  if (uint32Result)
    *uint32Result = defaultValue;
  if (hdrRow) // ### probably should be an error if hdrRow is NULL...
  {
    struct mdbYarn yarn;
    err = hdrRow->AliasCellYarn(GetEnv(), columnToken, &yarn);
    if (err == NS_OK)
      YarnToUInt32(&yarn, uint32Result);
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::RowCellColumnToUInt32 ( nsIMdbRow row,
mdb_token  columnToken,
PRUint32 uint32Result,
PRUint32  defaultValue = 0 
) [inherited]

Definition at line 3356 of file nsMsgDatabase.cpp.

{
  return RowCellColumnToUInt32(hdrRow, columnToken, &uint32Result, defaultValue);
}

Here is the call graph for this function:

void nsIMsgDatabase::setAttributesOnPendingHdr ( in nsIMsgDBHdr  pendingHdr,
in string  property,
in string  propertyVal,
in long  flags 
) [inherited]
nsresult nsMailDatabase::SetFolderInfoValid ( nsFileSpec folderSpec,
int  num,
int  numunread 
) [static]

Definition at line 700 of file nsMailDatabase.cpp.

{
  nsLocalFolderSummarySpec  summarySpec(*folderName);
  nsFileSpec                              summaryPath(summarySpec);
  nsresult           err = NS_OK;
  PRBool                    bOpenedDB = PR_FALSE;
  
  if (!folderName->Exists())
    return NS_MSG_ERROR_FOLDER_SUMMARY_MISSING;
  
  // should we have type safe downcast methods again?
  nsMailDatabase *pMessageDB = (nsMailDatabase *) nsMailDatabase::FindInCache(summaryPath);
  if (pMessageDB == nsnull)
  {
    pMessageDB = new nsMailDatabase();
    if(!pMessageDB)
      return NS_ERROR_OUT_OF_MEMORY;
    
    pMessageDB->m_folderSpec = new nsLocalFolderSummarySpec();
    if(!pMessageDB->m_folderSpec)
    {
      delete pMessageDB;
      return NS_ERROR_OUT_OF_MEMORY;
    }
    
    *(pMessageDB->m_folderSpec) = summarySpec;
    // ### this does later stuff (marks latered messages unread), which may be a problem
    err = pMessageDB->OpenMDB(summaryPath, PR_FALSE);
    if (err != NS_OK)
    {
      delete pMessageDB;
      pMessageDB = nsnull;
    }
    bOpenedDB = PR_TRUE;
  }
  
  if (pMessageDB == nsnull)
  {
#ifdef DEBUG
    printf("Exception opening summary file\n");
#endif
    return NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
  }
  
  {
    pMessageDB->m_folderSpec = folderName;
    nsFileSpec::TimeStamp actualFolderTimeStamp = pMessageDB->GetMailboxModDate();
    pMessageDB->m_dbFolderInfo->SetFolderSize(folderName->GetFileSize());
    pMessageDB->m_dbFolderInfo->SetFolderDate(actualFolderTimeStamp);
    pMessageDB->m_dbFolderInfo->ChangeNumUnreadMessages(numunread);
    pMessageDB->m_dbFolderInfo->ChangeNumMessages(num);
  }
  // if we opened the db, then we'd better close it. Otherwise, we found it in the cache,
  // so just commit and release.
  if (bOpenedDB)
  {
    pMessageDB->Close(PR_TRUE);
  }
  else if (pMessageDB)
  { 
    err = pMessageDB->Commit(nsMsgDBCommitType::kLargeCommit);
    pMessageDB->Release();
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in nsImapMailDatabase.

Definition at line 74 of file nsMailDatabase.cpp.

{
  NS_ASSERTION(!m_folderStream || !aFileStream, "m_folderStream is not null and we are assigning a non null stream to it");
  m_folderStream = aFileStream; //m_folderStream is set externally, so m_ownFolderStream is false
  m_ownFolderStream = PR_FALSE;
  return NS_OK;
}
PRBool nsMailDatabase::SetHdrFlag ( nsIMsgDBHdr msgHdr,
PRBool  bSet,
MsgFlags  flag 
) [protected, virtual]

Reimplemented from nsMsgDatabase.

Reimplemented in nsImapMailDatabase.

Definition at line 205 of file nsMailDatabase.cpp.

{
  nsIOFileStream *fileStream = nsnull;
  PRBool ret = PR_FALSE;

  if (!m_folderStream && m_folder)  //we are going to create a stream, bail out if someone else has lock
  {
    PRBool isLocked;
    m_folder->GetLocked(&isLocked);
    if (isLocked)
    {
      NS_ASSERTION(PR_FALSE, "Some other operation is in progress");
      return PR_FALSE;
    }
  }
  if (nsMsgDatabase::SetHdrFlag(msgHdr, bSet, flag))
  {
    UpdateFolderFlag(msgHdr, bSet, flag, &fileStream);
    if (fileStream)
    {
      fileStream->flush();
      fileStream->close();
      delete fileStream;
      SetFolderInfoValid(m_folderSpec, 0, 0);
    }
    ret = PR_TRUE;
  }

  return ret;
}

Here is the call graph for this function:

PRBool nsMsgDatabase::SetHdrReadFlag ( nsIMsgDBHdr msgHdr,
PRBool  pRead 
) [protected, virtual, inherited]

Reimplemented in nsNewsDatabase.

Definition at line 2051 of file nsMsgDatabase.cpp.

{
  return SetHdrFlag(msgHdr, bRead, MSG_FLAG_READ);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::SetKeyFlag ( nsMsgKey  key,
PRBool  set,
PRUint32  flag,
nsIDBChangeListener instigator = NULL 
) [protected, virtual, inherited]

Definition at line 2317 of file nsMsgDatabase.cpp.

{
  nsresult rv;
  nsCOMPtr <nsIMsgDBHdr> msgHdr;
              
  rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr));
  if (NS_FAILED(rv) || !msgHdr) 
    return NS_MSG_MESSAGE_NOT_FOUND; // XXX return rv?
  
  PRUint32 oldFlags;
  msgHdr->GetFlags(&oldFlags);
  
  SetHdrFlag(msgHdr, set, flag);
  
  PRUint32 flags;
  (void)msgHdr->GetFlags(&flags);
  
  if (oldFlags == flags)
    return NS_OK;

  return NotifyHdrChangeAll(msgHdr, oldFlags, flags, instigator);
}

Here is the call graph for this function:

void nsIMsgDatabase::SetLabel ( in nsMsgKey  key,
in nsMsgLabelValue  label 
) [inherited]
nsresult nsMsgDatabase::SetMsgHdrFlag ( nsIMsgDBHdr msgHdr,
PRBool  set,
PRUint32  flag,
nsIDBChangeListener instigator 
) [protected, virtual, inherited]

Definition at line 2341 of file nsMsgDatabase.cpp.

{
  PRUint32 oldFlags;
  msgHdr->GetFlags(&oldFlags);

  SetHdrFlag(msgHdr, set, flag);

  PRUint32 flags;
  (void)msgHdr->GetFlags(&flags);

  if (oldFlags == flags)
    return NS_OK;

  return NotifyHdrChangeAll(msgHdr, oldFlags, flags, instigator);
}

Here is the call graph for this function:

nsresult nsMsgDatabase::SetNSStringPropertyWithToken ( nsIMdbRow row,
mdb_token  aProperty,
const nsAString &  propertyStr 
) [inherited]

Definition at line 3583 of file nsMsgDatabase.cpp.

{
  NS_ENSURE_ARG(row);
  struct mdbYarn yarn;
  
  yarn.mYarn_Grow = NULL;
  nsresult err = row->AddColumn(GetEnv(), aProperty, nsStringToYarn(&yarn, propertyStr));
  nsMemory::Free((char *)yarn.mYarn_Buf); // won't need this when we have nsCString
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::SetProperty ( nsIMdbRow row,
const char *  propertyName,
const char *  propertyVal 
) [inherited]

Definition at line 3513 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  mdb_token   property_token;
  
  err = m_mdbStore->StringToToken(GetEnv(),  propertyName, &property_token);
  if (err == NS_OK)
    CharPtrToRowCellColumn(row, property_token, propertyVal);
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::SetPropertyFromNSString ( nsIMdbRow row,
const char *  propertyName,
const nsAString &  propertyVal 
) [inherited]

Definition at line 3536 of file nsMsgDatabase.cpp.

{
  nsresult err = NS_OK;
  mdb_token   property_token;
  
  err = m_mdbStore->StringToToken(GetEnv(),  propertyName, &property_token);
  if (err == NS_OK)
    return SetNSStringPropertyWithToken(row, property_token, propertyVal);
  
  return err;
}

Here is the call graph for this function:

void nsMailDatabase::SetReparse ( PRBool  reparse) [protected, virtual]

Definition at line 769 of file nsMailDatabase.cpp.

{
  m_reparse = reparse;
}

Here is the caller graph for this function:

void nsIMsgDatabase::setStringProperty ( in nsMsgKey  aKey,
in string  aProperty,
in string  aValue 
) [inherited]

Reimplemented in nsImapMailDatabase.

Definition at line 487 of file nsMailDatabase.cpp.

{
  nsresult ret = NS_OK;
  
  if (!m_folderSpec->Exists()) 
    return NS_MSG_ERROR_FOLDER_MISSING;
  
  if (m_dbFolderInfo)
  {
    if (valid)
    {
      nsFileSpec::TimeStamp actualFolderTimeStamp = GetMailboxModDate();
      
      m_dbFolderInfo->SetFolderSize(m_folderSpec->GetFileSize());
      m_dbFolderInfo->SetFolderDate(actualFolderTimeStamp);
      m_dbFolderInfo->SetVersion(GetCurVersion());
    }
    else
    {
      m_dbFolderInfo->SetVersion(0);      // that ought to do the trick.
    }
  }
  Commit(nsMsgDBCommitType::kLargeCommit);
  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::SetUint32Property ( nsIMdbRow row,
const char *  propertyName,
PRUint32  propertyVal 
) [inherited]

Definition at line 3561 of file nsMsgDatabase.cpp.

{
  struct mdbYarn yarn;
  char int32StrBuf[20];
  yarn.mYarn_Buf = int32StrBuf;
  yarn.mYarn_Size = sizeof(int32StrBuf);
  yarn.mYarn_Fill = sizeof(int32StrBuf);

  if (!row)
    return NS_ERROR_NULL_POINTER;

  mdb_token   property_token;
  
  nsresult err = m_mdbStore->StringToToken(GetEnv(),  propertyName, &property_token);
  if (err == NS_OK)
  {
    UInt32ToYarn(&yarn, propertyVal);
    err = row->AddColumn(GetEnv(), property_token, &yarn);
  }
  return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIMsgDatabase.

Reimplemented in nsImapMailDatabase.

Definition at line 137 of file nsMailDatabase.cpp.

{
  if (!m_folderStream && m_folder)  //only if we create a stream, set m_ownFolderStream to true.
  {
    PRBool isLocked;
    m_folder->GetLocked(&isLocked);
    if (isLocked)
    {
      NS_ASSERTION(PR_FALSE, "Some other operation is in progress");
      return NS_MSG_FOLDER_BUSY;
    }
    m_folderStream = new nsIOFileStream(nsFileSpec(*m_folderSpec));
    m_ownFolderStream = PR_TRUE;
  }

  return NS_OK;
}

Here is the call graph for this function:

PRBool nsMsgDatabase::ThreadBySubjectWithoutRe ( ) [protected, virtual, inherited]

Definition at line 3623 of file nsMsgDatabase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMsgDatabase::ThreadNewHdr ( nsMsgHdr hdr,
PRBool newThread 
) [protected, virtual, inherited]

Definition at line 3774 of file nsMsgDatabase.cpp.

{
  nsresult result=NS_ERROR_UNEXPECTED;
  nsCOMPtr <nsIMsgThread> thread;
  nsCOMPtr <nsIMsgDBHdr> replyToHdr;
  nsMsgKey threadId = nsMsgKey_None, newHdrKey;
  
  if (!newHdr)
    return NS_ERROR_NULL_POINTER;
  
  newHdr->SetThreadParent(nsMsgKey_None); // if we're undoing, could have a thread parent
  PRUint16 numReferences = 0;
  PRUint32 newHdrFlags = 0;
  
  // use raw flags instead of GetFlags, because GetFlags will
  // pay attention to what's in m_newSet, and this new hdr isn't
  // in m_newSet yet.
  newHdr->GetRawFlags(&newHdrFlags);
  newHdr->GetNumReferences(&numReferences);
  newHdr->GetMessageKey(&newHdrKey);
  
  // try reference threading first
  for (PRInt32 i = numReferences - 1; i >= 0;  i--)
  {
    nsCAutoString reference;
    
    newHdr->GetStringReference(i, reference);
    // first reference we have hdr for is best top-level hdr.
    // but we have to handle case of promoting new header to top-level
    // in case the top-level header comes after a reply.
    
    if (reference.IsEmpty())
      break;
    
    thread = getter_AddRefs(GetThreadForReference(reference, getter_AddRefs(replyToHdr))) ;
    if (thread)
    {
      if (replyToHdr)
      {
        nsMsgKey replyToKey;
        replyToHdr->GetMessageKey(&replyToKey);
        // message claims to be a reply to itself - ignore that since it leads to corrupt threading.
        if (replyToKey == newHdrKey)
        {
          // bad references - throw them all away.
          newHdr->SetMessageId("");
          thread = nsnull;
          break;
        }
      }
      thread->GetThreadKey(&threadId);
      newHdr->SetThreadId(threadId);
      result = AddToThread(newHdr, thread, replyToHdr, PR_TRUE);
      break;
    }
  }
  // if user hasn't said "only thread by ref headers", thread by subject
  if (!UseStrictThreading())
  {
    // try subject threading if we couldn't find a reference and the subject starts with Re:
    nsXPIDLCString subject;
  
    newHdr->GetSubject(getter_Copies(subject));
    if ((ThreadBySubjectWithoutRe() || (newHdrFlags & MSG_FLAG_HAS_RE)) && (!thread))
    {
      nsCAutoString cSubject(subject);
      thread = getter_AddRefs(GetThreadForSubject(cSubject));
      if(thread)
      {
        thread->GetThreadKey(&threadId);
        newHdr->SetThreadId(threadId);
        //TRACE("threading based on subject %s\n", (const char *) msgHdr->m_subject);
        // if we move this and do subject threading after, ref threading, 
        // don't thread within children, since we know it won't work. But for now, pass TRUE.
        result = AddToThread(newHdr, thread, nsnull, PR_TRUE);     
      }
    }
  }
  
  if (!thread)
  {
    // couldn't find any parent articles - msgHdr is top-level thread, for now
    result = AddNewThread(newHdr);
    newThread = PR_TRUE;
  }
  else
  {
    newThread = PR_FALSE;
  }
  return result;
}

Here is the call graph for this function:

nsresult nsMsgDatabase::UInt32ToRowCellColumn ( nsIMdbRow row,
mdb_token  columnToken,
PRUint32  value 
) [inherited]

Definition at line 3377 of file nsMsgDatabase.cpp.

{
  struct mdbYarn yarn;
  char yarnBuf[100];
  
  if (!row)
    return NS_ERROR_NULL_POINTER;

  yarn.mYarn_Buf = (void *) yarnBuf;
  yarn.mYarn_Size = sizeof(yarnBuf);
  yarn.mYarn_Fill = yarn.mYarn_Size;
  yarn.mYarn_Form = 0;
  yarn.mYarn_Grow = NULL;
  return row->AddColumn(GetEnv(),  columnToken, UInt32ToYarn(&yarn, value));
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct mdbYarn * nsMsgDatabase::UInt32ToYarn ( struct mdbYarn yarn,
PRUint32  i 
) [static, read, inherited]

Definition at line 3445 of file nsMsgDatabase.cpp.

{
  PR_snprintf((char *) yarn->mYarn_Buf, yarn->mYarn_Size, "%lx", i);
  yarn->mYarn_Fill = PL_strlen((const char *) yarn->mYarn_Buf);
  yarn->mYarn_Form = 0;     // what to do with this? Should be parsed out of the mime2 header?
  return yarn;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMsgDatabase::UndoDelete ( in nsIMsgDBHdr  msgHdr) [inherited]
void nsMailDatabase::UpdateFolderFlag ( nsIMsgDBHdr msgHdr,
PRBool  bSet,
MsgFlags  flag,
nsIOFileStream **  ppFileStream 
) [protected, virtual]

Reimplemented in nsImapMailDatabase.

Definition at line 254 of file nsMailDatabase.cpp.

{
  static char buf[50];
  PRInt32 folderStreamPos = 0; //saves the folderStream pos in case we are sharing the stream with other code
  nsIOFileStream *fileStream = (m_folderStream) ? m_folderStream : *ppFileStream;
  //#ifdef GET_FILE_STUFF_TOGETHER
#ifdef XP_MAC
  /* ducarroz: Do we still need this ??
  // This is a horrible hack and we should make sure we don't need it anymore.
  // It has to do with multiple people having the same file open, I believe, but the
  // mac file system only has one handle, and they compete for the file position.
  // Prevent closing the file from under the incorporate stuff. #82785.
  int32 savedPosition = -1;
  if (!fid && gIncorporatePath && !strcmp(m_folderSpec, gIncorporatePath))
  {
              fid = gIncorporateFID;
                savedPosition = ftell(gIncorporateFID); // so we can restore it.
                }
  */
#endif // XP_MAC
  PRUint32 offset;
  (void)mailHdr->GetStatusOffset(&offset);
  if (offset > 0) 
  {
    
    if (fileStream == NULL) 
    {
      fileStream = new nsIOFileStream(nsFileSpec(*m_folderSpec));
    }
    else if (!m_ownFolderStream)
    {
      m_folderStream->flush();
      folderStreamPos = m_folderStream->tell();
    }
    if (fileStream) 
    {
      PRUint32 msgOffset;
      (void)mailHdr->GetMessageOffset(&msgOffset);
      PRUint32 statusPos = offset + msgOffset;
      PR_ASSERT(offset < 10000);
      fileStream->seek(PR_SEEK_SET, statusPos);
      buf[0] = '\0';
      if (fileStream->readline(buf, sizeof(buf))) 
      {
        if (strncmp(buf, X_MOZILLA_STATUS, X_MOZILLA_STATUS_LEN) == 0 &&
          strncmp(buf + X_MOZILLA_STATUS_LEN, ": ", 2) == 0 &&
          strlen(buf) >= X_MOZILLA_STATUS_LEN + 6) 
        {
          PRUint32 flags;
          (void)mailHdr->GetFlags(&flags);
          if (!(flags & MSG_FLAG_EXPUNGED))
          {
            int i;
            char *p = buf + X_MOZILLA_STATUS_LEN + 2;
            
            for (i=0, flags = 0; i<4; i++, p++)
            {
              flags = (flags << 4) | msg_UnHex(*p);
            }
            
            PRUint32 curFlags;
            (void)mailHdr->GetFlags(&curFlags);
            flags = (flags & MSG_FLAG_QUEUED) |
              (curFlags & ~MSG_FLAG_RUNTIME_ONLY);
          }
          else
          {
            flags &= ~MSG_FLAG_RUNTIME_ONLY;
          }
          fileStream->seek(statusPos);
          // We are filing out x-mozilla-status flags here
          PR_snprintf(buf, sizeof(buf), X_MOZILLA_STATUS_FORMAT,
            flags & 0x0000FFFF);
          PRInt32 lineLen = PL_strlen(buf);
          PRUint32 status2Pos = statusPos + lineLen + MSG_LINEBREAK_LEN;
          fileStream->write(buf, lineLen);
          
          // time to upate x-mozilla-status2
          fileStream->seek(status2Pos);
          if (fileStream->readline(buf, sizeof(buf))) 
          {
            if (strncmp(buf, X_MOZILLA_STATUS2, X_MOZILLA_STATUS2_LEN) == 0 &&
              strncmp(buf + X_MOZILLA_STATUS2_LEN, ": ", 2) == 0 &&
              strlen(buf) >= X_MOZILLA_STATUS2_LEN + 10) 
            {
              PRUint32 dbFlags;
              (void)mailHdr->GetFlags(&dbFlags);
              dbFlags &= 0xFFFF0000;
              fileStream->seek(status2Pos);
              PR_snprintf(buf, sizeof(buf), X_MOZILLA_STATUS2_FORMAT, dbFlags);
              fileStream->write(buf, PL_strlen(buf));
            }
          }
        } else 
        {
#ifdef DEBUG
          printf("Didn't find %s where expected at position %ld\n"
            "instead, found %s.\n",
            X_MOZILLA_STATUS, (long) statusPos, buf);
#endif
          SetReparse(PR_TRUE);
        }                   
      } 
      else 
      {
#ifdef DEBUG
        printf("Couldn't read old status line at all at position %ld\n",
          (long) statusPos);
#endif
        SetReparse(PR_TRUE);
      }
#ifdef XP_MAC
      /* ducarroz: Do we still need this ??
      // Restore the file position
      if (savedPosition >= 0)
      XP_FileSeek(fid, savedPosition, SEEK_SET);
      */
#endif
    }
    else
    {
#ifdef DEBUG
      printf("Couldn't open mail folder for update%s!\n",
        (const char*)m_folderSpec);
#endif
      PR_ASSERT(PR_FALSE);
    }
  }
  //#endif // GET_FILE_STUFF_TOGETHER
  if (!m_folderStream)
    *ppFileStream = fileStream; // This tells the caller that we opened the file, and please to close it.
  else if (!m_ownFolderStream)
    m_folderStream->seek(PR_SEEK_SET, folderStreamPos);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMsgDatabase::updateHdrInCache ( in string  aSearchFolderUri,
in nsIMsgDBHdr  aHdr,
in boolean  aAdd 
) [inherited]
PRBool nsMsgDatabase::UseStrictThreading ( ) [protected, virtual, inherited]

Definition at line 3629 of file nsMsgDatabase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsMsgDatabase::YarnTonsCString ( struct mdbYarn yarn,
nsACString &  str 
) [static, inherited]

Definition at line 3462 of file nsMsgDatabase.cpp.

{
    const char* buf = (const char*)yarn->mYarn_Buf;
    if (buf)
        str.Assign(buf, yarn->mYarn_Fill);
    else
        str.Truncate();
}

Here is the call graph for this function:

void nsMsgDatabase::YarnTonsString ( struct mdbYarn yarn,
nsAString &  str 
) [static, inherited]

Definition at line 3453 of file nsMsgDatabase.cpp.

{
  const char* buf = (const char*)yarn->mYarn_Buf;
  if (buf)
    CopyASCIItoUTF16(Substring(buf, buf + yarn->mYarn_Fill), str);
  else
    str.Truncate();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsMsgDatabase::YarnToUInt32 ( struct mdbYarn yarn,
PRUint32 i 
) [static, inherited]

Definition at line 3473 of file nsMsgDatabase.cpp.

{
  PRUint32 result;
  char *p = (char *) yarn->mYarn_Buf;
  PRInt32 numChars = PR_MIN(8, yarn->mYarn_Fill);
  PRInt32 i;
  
  if (numChars > 0)
  {
    for (i=0, result = 0; i<numChars; i++, p++)
    {
      char C = *p;
      
      PRInt8 unhex = ((C >= '0' && C <= '9') ? C - '0' :
      ((C >= 'A' && C <= 'F') ? C - 'A' + 10 :
                        ((C >= 'a' && C <= 'f') ? C - 'a' + 10 : -1)));
       if (unhex < 0)
         break;
       result = (result << 4) | unhex;
    }
    
    *pResult = result;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsMsgDBEnumerator [friend, inherited]

Definition at line 166 of file nsMsgDatabase.h.

friend class nsMsgDBService [friend, inherited]

Definition at line 84 of file nsMsgDatabase.h.

friend class nsMsgDBThreadEnumerator [friend, inherited]

Definition at line 167 of file nsMsgDatabase.h.

friend class nsMsgHdr [friend, inherited]

Definition at line 164 of file nsMsgDatabase.h.

friend class nsMsgOfflineOpEnumerator [friend]

Definition at line 81 of file nsMailDatabase.h.

friend class nsMsgThread [friend, inherited]

Definition at line 165 of file nsMsgDatabase.h.


Member Data Documentation

Definition at line 135 of file nsIMsgDatabase.idl.

Definition at line 290 of file nsIMsgDatabase.idl.

Definition at line 289 of file nsIMsgDatabase.idl.

Definition at line 288 of file nsIMsgDatabase.idl.

Definition at line 239 of file nsIMsgDatabase.idl.

Definition at line 297 of file nsIMsgDatabase.idl.

PLDHashTableOps nsMsgDatabase::gMsgDBHashTableOps [static, protected, inherited]

Definition at line 278 of file nsIMsgDatabase.idl.

Definition at line 277 of file nsIMsgDatabase.idl.

Definition at line 248 of file nsMsgDatabase.h.

PRBool nsMsgDatabase::m_bCacheHeaders [protected, inherited]

Definition at line 310 of file nsMsgDatabase.h.

Definition at line 309 of file nsMsgDatabase.h.

Definition at line 312 of file nsMsgDatabase.h.

nsMsgKey nsMsgDatabase::m_cachedThreadId [protected, inherited]

Definition at line 311 of file nsMsgDatabase.h.

Definition at line 261 of file nsMsgDatabase.h.

Definition at line 243 of file nsMsgDatabase.h.

Definition at line 218 of file nsMsgDatabase.h.

Definition at line 254 of file nsMsgDatabase.h.

nsVoidArray * nsMsgDatabase::m_dbCache = NULL [static, protected, inherited]

Definition at line 216 of file nsMsgDatabase.h.

Definition at line 234 of file nsMsgDatabase.h.

nsFileSpec nsMsgDatabase::m_dbName [protected, inherited]

Definition at line 240 of file nsMsgDatabase.h.

Definition at line 221 of file nsMsgDatabase.h.

Definition at line 256 of file nsMsgDatabase.h.

Definition at line 233 of file nsMsgDatabase.h.

Definition at line 100 of file nsMailDatabase.h.

Definition at line 101 of file nsMailDatabase.h.

Definition at line 244 of file nsMsgDatabase.h.

Definition at line 246 of file nsMsgDatabase.h.

Definition at line 275 of file nsMsgDatabase.h.

Definition at line 293 of file nsMsgDatabase.h.

Definition at line 258 of file nsMsgDatabase.h.

Definition at line 238 of file nsMsgDatabase.h.

Definition at line 87 of file nsMailDatabase.h.

Definition at line 239 of file nsMsgDatabase.h.

nsIMdbEnv* nsMsgDatabase::m_mdbEnv [protected, inherited]

Definition at line 236 of file nsMsgDatabase.h.

nsIMdbStore* nsMsgDatabase::m_mdbStore [protected, inherited]

Definition at line 237 of file nsMsgDatabase.h.

Definition at line 242 of file nsMsgDatabase.h.

Definition at line 269 of file nsMsgDatabase.h.

Definition at line 251 of file nsMsgDatabase.h.

Definition at line 255 of file nsMsgDatabase.h.

Definition at line 266 of file nsMsgDatabase.h.

Definition at line 219 of file nsMsgDatabase.h.

nsMsgKeyArray nsMsgDatabase::m_newSet [protected, inherited]

Definition at line 241 of file nsMsgDatabase.h.

Definition at line 235 of file nsMsgDatabase.h.

Definition at line 260 of file nsMsgDatabase.h.

Definition at line 268 of file nsMsgDatabase.h.

Definition at line 274 of file nsMsgDatabase.h.

Definition at line 273 of file nsMsgDatabase.h.

Definition at line 88 of file nsMailDatabase.h.

Definition at line 89 of file nsMailDatabase.h.

Definition at line 102 of file nsMailDatabase.h.

Definition at line 257 of file nsMsgDatabase.h.

Definition at line 253 of file nsMsgDatabase.h.

Definition at line 252 of file nsMsgDatabase.h.

Definition at line 99 of file nsMailDatabase.h.

Definition at line 220 of file nsMsgDatabase.h.

Definition at line 250 of file nsMsgDatabase.h.

Definition at line 259 of file nsMsgDatabase.h.

Definition at line 249 of file nsMsgDatabase.h.

Definition at line 264 of file nsMsgDatabase.h.

Definition at line 262 of file nsMsgDatabase.h.

Definition at line 263 of file nsMsgDatabase.h.

Definition at line 272 of file nsMsgDatabase.h.

Definition at line 270 of file nsMsgDatabase.h.

Definition at line 271 of file nsMsgDatabase.h.

Definition at line 245 of file nsMsgDatabase.h.

Definition at line 267 of file nsMsgDatabase.h.

Definition at line 247 of file nsMsgDatabase.h.

Definition at line 265 of file nsMsgDatabase.h.

Definition at line 248 of file nsIMsgDatabase.idl.

Definition at line 293 of file nsIMsgDatabase.idl.

Definition at line 241 of file nsIMsgDatabase.idl.

Definition at line 280 of file nsIMsgDatabase.idl.

Definition at line 279 of file nsIMsgDatabase.idl.

Definition at line 259 of file nsIMsgDatabase.idl.


The documentation for this class was generated from the following files: