start hooking up mdb calls
git-svn-id: svn://10.0.0.236/trunk@19132 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -25,6 +25,10 @@ include $(DEPTH)/config/autoconf.mk
|
||||
EXPORTS= \
|
||||
nsMsgHdr.h \
|
||||
nsMsgDatabase.h \
|
||||
nsMailDatabase.h \
|
||||
nsImapMailDatabase.h \
|
||||
nsNewsDatabase.h \
|
||||
nsDBFolderInfo.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
@@ -27,6 +27,7 @@ EXPORTS = \
|
||||
nsMailDatabase.h \
|
||||
nsImapMailDatabase.h \
|
||||
nsNewsDatabase.h \
|
||||
nsDBFolderInfo.h \
|
||||
nsMsgHdr.h \
|
||||
$(NULL)
|
||||
|
||||
|
||||
142
mozilla/mailnews/db/msgdb/public/nsDBFolderInfo.h
Normal file
142
mozilla/mailnews/db/msgdb/public/nsDBFolderInfo.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* This class encapsulates the global information about a folder stored in the
|
||||
summary file.
|
||||
*/
|
||||
#ifndef _nsDBFolderInfo_H
|
||||
#define _nsDBFolderInfo_H
|
||||
|
||||
#include "nsString.h"
|
||||
#include "MailNewsTypes.h"
|
||||
#include "xp.h"
|
||||
#include "mdb.h"
|
||||
#include "nsMsgKeyArray.h"
|
||||
|
||||
class nsMsgDatabase;
|
||||
|
||||
// again, this could inherit from nsISupports, but I don't see the need as of yet.
|
||||
// I'm not sure it needs to be ref-counted (but I think it does).
|
||||
|
||||
// I think these getters and setters really need to go through mdb and not rely on the object
|
||||
// caching the values. If this somehow turns out to be prohibitively expensive, we can invent
|
||||
// some sort of dirty mechanism, but I think it turns out that these values will be cached by
|
||||
// the MSG_FolderInfo's anyway.
|
||||
class nsDBFolderInfo
|
||||
{
|
||||
public:
|
||||
nsDBFolderInfo(nsMsgDatabase *mdb);
|
||||
virtual ~nsDBFolderInfo();
|
||||
nsrefcnt AddRef(void);
|
||||
nsrefcnt Release(void);
|
||||
|
||||
// create the appropriate table and row in a new db.
|
||||
nsresult AddToNewMDB();
|
||||
// initialize from appropriate table and row in existing db.
|
||||
nsresult InitFromExistingDB();
|
||||
void SetHighWater(MessageKey highWater, PRBool force = FALSE) ;
|
||||
MessageKey GetHighWater() ;
|
||||
void SetExpiredMark(MessageKey expiredKey);
|
||||
int GetDiskVersion();
|
||||
|
||||
PRBool AddLaterKey(MessageKey key, time_t until);
|
||||
PRInt32 GetNumLatered();
|
||||
MessageKey GetLateredAt(PRInt32 laterIndex, time_t *pUntil);
|
||||
void RemoveLateredAt(PRInt32 laterIndex);
|
||||
|
||||
virtual void SetMailboxName(const char *newBoxName);
|
||||
virtual void GetMailboxName(nsString &boxName);
|
||||
|
||||
void SetViewType(PRInt32 viewType);
|
||||
PRInt32 GetViewType();
|
||||
// we would like to just store the property name we're sorted by
|
||||
void SetSortInfo(nsMsgSortType, nsMsgSortOrder);
|
||||
void GetSortInfo(nsMsgSortType *, nsMsgSortOrder *);
|
||||
PRInt32 ChangeNumNewMessages(PRInt32 delta);
|
||||
PRInt32 ChangeNumMessages(PRInt32 delta);
|
||||
PRInt32 ChangeNumVisibleMessages(PRInt32 delta);
|
||||
PRInt32 GetNumNewMessages() ;
|
||||
PRInt32 GetNumMessages() ;
|
||||
PRInt32 GetNumVisibleMessages() ;
|
||||
PRInt32 GetFlags();
|
||||
void SetFlags(PRInt32 flags);
|
||||
void OrFlags(PRInt32 flags);
|
||||
void AndFlags(PRInt32 flags);
|
||||
PRBool TestFlag(PRInt32 flags);
|
||||
PRInt16 GetCSID() ;
|
||||
void SetCSID(PRInt16 csid) ;
|
||||
PRInt16 GetIMAPHierarchySeparator() ;
|
||||
void SetIMAPHierarchySeparator(PRInt16 hierarchySeparator) ;
|
||||
PRInt32 GetImapTotalPendingMessages() ;
|
||||
void ChangeImapTotalPendingMessages(PRInt32 delta);
|
||||
PRInt32 GetImapUnreadPendingMessages() ;
|
||||
void ChangeImapUnreadPendingMessages(PRInt32 delta) ;
|
||||
|
||||
PRInt32 GetImapUidValidity() ;
|
||||
void SetImapUidValidity(PRInt32 uidValidity) ;
|
||||
|
||||
MessageKey GetLastMessageLoaded();
|
||||
void SetLastMessageLoaded(MessageKey lastLoaded);
|
||||
// get arbitrary property, aka row cell value.
|
||||
nsresult GetProperty(const char *propertyName, nsString &resultProperty);
|
||||
|
||||
PRUint16 m_version; // for upgrading...
|
||||
PRInt32 m_sortType; // the last sort type open on this db.
|
||||
PRInt16 m_csid; // default csid for these messages
|
||||
PRInt16 m_IMAPHierarchySeparator; // imap path separator
|
||||
PRInt8 m_sortOrder; // the last sort order (up or down
|
||||
// mail only (for now)
|
||||
PRInt32 m_folderSize;
|
||||
PRInt32 m_expunged_bytes; // sum of size of deleted messages in folder
|
||||
time_t m_folderDate;
|
||||
|
||||
// IMAP only
|
||||
PRInt32 m_LastMessageUID;
|
||||
PRInt32 m_ImapUidValidity;
|
||||
PRInt32 m_TotalPendingMessages;
|
||||
PRInt32 m_UnreadPendingMessages;
|
||||
|
||||
// news only (for now)
|
||||
MessageKey m_articleNumHighWater; // largest article number whose header we've seen
|
||||
MessageKey m_expiredMark; // Highest invalid article number in group - for expiring
|
||||
PRInt32 m_viewType; // for news, the last view type open on this db.
|
||||
|
||||
nsMsgKeyArray m_lateredKeys; // list of latered messages
|
||||
|
||||
protected:
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
nsString m_mailboxName; // name presented to the user, will match imap server name
|
||||
PRInt32 m_numVisibleMessages; // doesn't include expunged or ignored messages (but does include collapsed).
|
||||
PRInt32 m_numNewMessages;
|
||||
PRInt32 m_numMessages; // includes expunged and ignored messages
|
||||
PRInt32 m_flags; // folder specific flags. This holds things like re-use thread pane,
|
||||
// configured for off-line use, use default retrieval, purge article/header options
|
||||
MessageKey m_lastMessageLoaded; // set by the FE's to remember the last loaded message
|
||||
|
||||
// the db folder info will have to know what db and row it belongs to, since it is really
|
||||
// just a wrapper around the singleton folder info row in the mdb.
|
||||
nsMsgDatabase *m_mdb;
|
||||
mdbTable *m_mdbTable; // singleton table in db
|
||||
mdbRow *m_mdbRow; // singleton row in table;
|
||||
mdb_token m_rowScopeToken;
|
||||
mdb_token m_tableKindToken;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -26,13 +26,20 @@
|
||||
class nsOfflineImapOperation;
|
||||
class nsMsgKeyArray;
|
||||
class ChangeListener;
|
||||
class MSG_Master;
|
||||
class MSG_FolderInfo;
|
||||
|
||||
// this is the version number for the mail db. If the file format changes, we
|
||||
// just reparse the mail folder.
|
||||
const int kMailDBVersion = 1;
|
||||
|
||||
class nsMailDatabase : public nsMsgDatabase
|
||||
{
|
||||
public:
|
||||
nsMailDatabase();
|
||||
virtual ~nsMailDatabase();
|
||||
static nsresult Open(nsFilePath &dbName, PRBool create, nsMailDatabase** pMessageDB);
|
||||
static nsresult Open(nsFilePath &dbName, PRBool create, nsMailDatabase** pMessageDB,
|
||||
XP_Bool upgrading = FALSE);
|
||||
|
||||
static nsresult CloneInvalidDBInfoIntoNewDB(nsFilePath &pathName, nsMailDatabase** pMailDB);
|
||||
|
||||
@@ -42,12 +49,13 @@ public:
|
||||
|
||||
// virtual int GetCurVersion() {return kMailDBVersion;}
|
||||
static nsresult SetFolderInfoValid(nsFilePath &pathname, int num, int numunread);
|
||||
virtual const char *GetFolderName() {return m_folderName;}
|
||||
nsresult GetFolderName(nsString &folderName);
|
||||
virtual nsMailDatabase *GetMailDB() {return this;}
|
||||
// MSG_Master *GetMaster() {return m_master;}
|
||||
// void SetMaster(MSG_Master *master) {m_master = master;}
|
||||
MSG_Master *GetMaster() {return m_master;}
|
||||
void SetMaster(MSG_Master *master) {m_master = master;}
|
||||
|
||||
// virtual MSG_FolderInfo *GetFolderInfo();
|
||||
virtual int GetCurVersion() {return kMailDBVersion;}
|
||||
virtual MSG_FolderInfo *GetFolderInfo();
|
||||
|
||||
// for offline imap queued operations
|
||||
// these are in the base mail class (presumably) because offline moves between online and offline
|
||||
@@ -70,6 +78,7 @@ protected:
|
||||
MsgFlags flag, PRFileDesc *fid);
|
||||
virtual void SetReparse(PRBool reparse);
|
||||
|
||||
MSG_Master *m_master;
|
||||
XP_Bool m_reparse;
|
||||
char *m_folderName;
|
||||
PRFileDesc *m_folderFile; /* this is a cache for loops which want file left open */
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
class ListContext;
|
||||
|
||||
class nsDBFolderInfo;
|
||||
|
||||
// used to cache open db's.
|
||||
class nsMsgDatabaseArray : public XPPtrArray
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
|
||||
nsrefcnt AddRef(void);
|
||||
nsrefcnt Release(void);
|
||||
virtual nsresult Close(PRBool forceCommit = TRUE);
|
||||
virtual nsresult OpenMDB(const char *dbName, PRBool create);
|
||||
virtual nsresult CloseMDB(PRBool commit = TRUE);
|
||||
// Force closed is evil, and we should see if we can do without it.
|
||||
@@ -87,6 +88,9 @@ public:
|
||||
nsresult ListNext(ListContext *pContext, nsMsgHdr **pResult);
|
||||
nsresult ListDone(ListContext *pContext);
|
||||
static mdbFactory *GetMDBFactory();
|
||||
nsDBFolderInfo *GetDBFolderInfo() {return m_dbFolderInfo;}
|
||||
mdbEnv *GetEnv() {return m_mdbEnv;}
|
||||
mdbStore *GetStore() {return m_mdbStore;}
|
||||
|
||||
static nsMsgDatabase* FindInCache(nsFilePath &dbName);
|
||||
static void CleanupCache();
|
||||
@@ -95,10 +99,12 @@ public:
|
||||
static void DumpCache();
|
||||
#endif
|
||||
protected:
|
||||
mdbEnv *m_mdbEnv; // to be used in all the db calls.
|
||||
mdbStore *m_mdbStore;
|
||||
nsFilePath m_dbName;
|
||||
nsrefcnt mRefCnt;
|
||||
nsDBFolderInfo *m_dbFolderInfo;
|
||||
mdbEnv *m_mdbEnv; // to be used in all the db calls.
|
||||
mdbStore *m_mdbStore;
|
||||
nsFilePath m_dbName;
|
||||
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
static void AddToCache(nsMsgDatabase* pMessageDB)
|
||||
{GetDBCache()->Add(pMessageDB);}
|
||||
@@ -107,6 +113,14 @@ protected:
|
||||
PRBool MatchDbName(nsFilePath &dbName); // returns TRUE if they match
|
||||
static nsMsgDatabaseArray* GetDBCache();
|
||||
static nsMsgDatabaseArray *m_dbCache;
|
||||
|
||||
// mdb bookkeeping stuff
|
||||
nsresult InitMDBInfo();
|
||||
PRBool m_mdbTokensInitialized;
|
||||
|
||||
mdb_token m_hdrRowScopeToken;
|
||||
mdb_token m_hdrTableKindToken;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,6 +31,8 @@ EXPORTS = \
|
||||
|
||||
CPPSRCS = \
|
||||
nsMsgDatabase.cpp\
|
||||
nsDBFolderInfo.cpp\
|
||||
nsMsgHdr.cpp\
|
||||
nsMailDatabase.cpp\
|
||||
$(NULL)
|
||||
|
||||
|
||||
@@ -27,11 +27,13 @@ REQUIRES=rdf
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= nsMsgDatabase.cpp\
|
||||
nsDBFolderInfo.cpp\
|
||||
nsMailDatabase.cpp\
|
||||
nsMsgHdr.cpp\
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= .\$(OBJDIR)\nsMsgDatabase.obj \
|
||||
.\$(OBJDIR)\nsDBFolderInfo.obj\
|
||||
.\$(OBJDIR)\nsMailDatabase.obj\
|
||||
.\$(OBJDIR)\nsMsgHdr.obj\
|
||||
$(NULL)
|
||||
|
||||
306
mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp
Normal file
306
mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp
Normal file
@@ -0,0 +1,306 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsDBFolderInfo.h"
|
||||
#include "nsMsgDatabase.h"
|
||||
|
||||
const char *kDBFolderInfoScope = "ns:msg:db:row:scope:dbfolderinfo:all";
|
||||
const char *kDBFolderInfoTableKind = "ns:msg:db:table:kind:dbfolderinfo";
|
||||
struct mdbOid gDBFolderInfoOID;
|
||||
|
||||
nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
|
||||
{
|
||||
m_mdbTable = NULL;
|
||||
m_mdbRow = NULL;
|
||||
|
||||
if (mdb)
|
||||
{
|
||||
mdb_err err;
|
||||
|
||||
mdb->AddRef();
|
||||
m_mdb = mdb;
|
||||
err = m_mdb->GetStore()->StringToToken(mdb->GetEnv(), kDBFolderInfoScope, &m_rowScopeToken);
|
||||
if (err == NS_OK)
|
||||
{
|
||||
err = m_mdb->GetStore()->StringToToken(mdb->GetEnv(), kDBFolderInfoTableKind, &m_tableKindToken);
|
||||
if (err == NS_OK)
|
||||
{
|
||||
gDBFolderInfoOID.mOid_Scope = m_rowScopeToken;
|
||||
gDBFolderInfoOID.mOid_Scope = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsDBFolderInfo::~nsDBFolderInfo()
|
||||
{
|
||||
if (m_mdb)
|
||||
{
|
||||
if (m_mdbTable)
|
||||
m_mdbTable->CutStrongRef(m_mdb->GetEnv());
|
||||
if (m_mdbRow)
|
||||
m_mdbRow->CutStrongRef(m_mdb->GetEnv());
|
||||
m_mdb->Release();
|
||||
}
|
||||
}
|
||||
|
||||
// ref counting methods - if we inherit from nsISupports, we won't need these,
|
||||
// and we can take advantage of the nsISupports ref-counting tracing methods
|
||||
nsrefcnt nsDBFolderInfo::AddRef(void)
|
||||
{
|
||||
return ++mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt nsDBFolderInfo::Release(void)
|
||||
{
|
||||
NS_PRECONDITION(0 != mRefCnt, "dup release");
|
||||
if (--mRefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
// this routine sets up a new db to know about the dbFolderInfo stuff...
|
||||
nsresult nsDBFolderInfo::AddToNewMDB()
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
if (m_mdb && m_mdb->GetStore())
|
||||
{
|
||||
mdbStore *store = m_mdb->GetStore();
|
||||
// create the unique table for the dbFolderInfo.
|
||||
mdb_err err = store->NewTable(m_mdb->GetEnv(), m_rowScopeToken,
|
||||
m_tableKindToken, PR_TRUE, &m_mdbTable);
|
||||
|
||||
// create the singleton row for the dbFolderInfo.
|
||||
err = store->NewRowWithOid(m_mdb->GetEnv(), m_rowScopeToken,
|
||||
&gDBFolderInfoOID, &m_mdbRow);
|
||||
|
||||
// add the row to the singleton table.
|
||||
if (NS_SUCCEEDED(err))
|
||||
{
|
||||
err = m_mdbTable->AddRow(m_mdb->GetEnv(), m_mdbRow);
|
||||
}
|
||||
|
||||
ret = err; // what are we going to do about mdb_err's?
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult nsDBFolderInfo::InitFromExistingDB()
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
if (m_mdb && m_mdb->GetStore())
|
||||
{
|
||||
mdbStore *store = m_mdb->GetStore();
|
||||
if (store)
|
||||
{
|
||||
mdb_count outTableCount; // current number of such tables
|
||||
mdb_bool mustBeUnique, // whether port can hold only one of these
|
||||
ret = store->GetTableKind(m_mdb->GetEnv(), m_rowScopeToken, m_tableKindToken, &outTableCount,
|
||||
&mustBeUnique, &m_mdbTable);
|
||||
PR_ASSERT(mustBeUnique && outTableCount == 1);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetHighWater(MessageKey highWater, PRBool force /* = FALSE */)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MessageKey nsDBFolderInfo::GetHighWater()
|
||||
{
|
||||
return m_articleNumHighWater;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetExpiredMark(MessageKey expiredKey)
|
||||
{
|
||||
}
|
||||
|
||||
int nsDBFolderInfo::GetDiskVersion()
|
||||
{
|
||||
return m_version;
|
||||
}
|
||||
|
||||
PRBool nsDBFolderInfo::AddLaterKey(MessageKey key, time_t until)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::GetNumLatered()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MessageKey nsDBFolderInfo::GetLateredAt(PRInt32 laterIndex, time_t *pUntil)
|
||||
{
|
||||
return MSG_MESSAGEKEYNONE;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::RemoveLateredAt(PRInt32 laterIndex)
|
||||
{
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetMailboxName(const char *newBoxName)
|
||||
{
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::GetMailboxName(nsString &boxName)
|
||||
{
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetViewType(PRInt32 viewType)
|
||||
{
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::GetViewType()
|
||||
{
|
||||
return m_viewType;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetSortInfo(nsMsgSortType type, nsMsgSortOrder order)
|
||||
{
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::GetSortInfo(nsMsgSortType *type, nsMsgSortOrder *orde)
|
||||
{
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::ChangeNumNewMessages(PRInt32 delta)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::ChangeNumMessages(PRInt32 delta)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::ChangeNumVisibleMessages(PRInt32 delta)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::GetNumNewMessages()
|
||||
{
|
||||
return m_numNewMessages;
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::GetNumMessages()
|
||||
{
|
||||
return m_numMessages;
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::GetNumVisibleMessages()
|
||||
{
|
||||
return m_numVisibleMessages;
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::GetFlags()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetFlags(PRInt32 flags)
|
||||
{
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::OrFlags(PRInt32 flags)
|
||||
{
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::AndFlags(PRInt32 flags)
|
||||
{
|
||||
}
|
||||
|
||||
PRBool nsDBFolderInfo::TestFlag(PRInt32 flags)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRInt16 nsDBFolderInfo::GetCSID()
|
||||
{
|
||||
return m_csid;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetCSID(PRInt16 csid)
|
||||
{
|
||||
m_csid = csid;
|
||||
}
|
||||
|
||||
PRInt16 nsDBFolderInfo::GetIMAPHierarchySeparator()
|
||||
{
|
||||
return m_IMAPHierarchySeparator;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetIMAPHierarchySeparator(PRInt16 hierarchySeparator)
|
||||
{
|
||||
m_IMAPHierarchySeparator = hierarchySeparator;
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::GetImapTotalPendingMessages()
|
||||
{
|
||||
return m_TotalPendingMessages;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::ChangeImapTotalPendingMessages(PRInt32 delta)
|
||||
{
|
||||
m_TotalPendingMessages+=delta;
|
||||
}
|
||||
|
||||
PRInt32 nsDBFolderInfo::GetImapUnreadPendingMessages()
|
||||
{
|
||||
return m_UnreadPendingMessages;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::ChangeImapUnreadPendingMessages(PRInt32 delta)
|
||||
{
|
||||
m_UnreadPendingMessages+=delta;
|
||||
}
|
||||
|
||||
|
||||
PRInt32 nsDBFolderInfo::GetImapUidValidity()
|
||||
{
|
||||
return m_ImapUidValidity;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetImapUidValidity(PRInt32 uidValidity)
|
||||
{
|
||||
m_ImapUidValidity=uidValidity;
|
||||
}
|
||||
|
||||
MessageKey nsDBFolderInfo::GetLastMessageLoaded()
|
||||
{
|
||||
return m_lastMessageLoaded;
|
||||
}
|
||||
|
||||
void nsDBFolderInfo::SetLastMessageLoaded(MessageKey lastLoaded)
|
||||
{
|
||||
m_lastMessageLoaded = lastLoaded;
|
||||
}
|
||||
|
||||
// get arbitrary property, aka row cell value.
|
||||
|
||||
nsresult nsDBFolderInfo::GetProperty(const char *propertyName, nsString &resultProperty)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "nsMailDatabase.h"
|
||||
#include "nsDBFolderInfo.h"
|
||||
|
||||
nsMailDatabase::nsMailDatabase()
|
||||
{
|
||||
@@ -27,12 +28,14 @@ nsMailDatabase::~nsMailDatabase()
|
||||
}
|
||||
|
||||
|
||||
/* static */ nsresult nsMailDatabase::Open(nsFilePath &dbName, PRBool create, nsMailDatabase** pMessageDB)
|
||||
/* static */ nsresult nsMailDatabase::Open(nsFilePath &dbName, PRBool create, nsMailDatabase** pMessageDB,
|
||||
XP_Bool upgrading /*=FALSE*/)
|
||||
{
|
||||
nsMailDatabase *mailDB;
|
||||
int statResult;
|
||||
XP_StatStruct st;
|
||||
XP_Bool newFile = FALSE;
|
||||
nsDBFolderInfo *folderInfo = NULL;
|
||||
|
||||
// OK, dbName is probably folder name, since I can't figure out how nsFilePath interacts
|
||||
// with xpFileTypes and its related routines.
|
||||
@@ -55,12 +58,13 @@ nsMailDatabase::~nsMailDatabase()
|
||||
mailDB = new nsMailDatabase;
|
||||
|
||||
if (!mailDB)
|
||||
return(eOUT_OF_MEMORY);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mailDB->m_folderName = XP_STRDUP(folderName);
|
||||
|
||||
dbName = WH_FileName(folderName, xpMailFolderSummary);
|
||||
if (!dbName) return eOUT_OF_MEMORY;
|
||||
if (!dbName)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
// stat file before we open the db, because if we've latered
|
||||
// any messages, handling latered will change time stamp on
|
||||
// folder file.
|
||||
@@ -71,88 +75,88 @@ nsMailDatabase::~nsMailDatabase()
|
||||
|
||||
if (NS_SUCCEEDED(err))
|
||||
{
|
||||
// folderInfo = mailDB->GetDBFolderInfo();
|
||||
// if (folderInfo == NULL)
|
||||
// {
|
||||
// err = eOldSummaryFile;
|
||||
// }
|
||||
// else
|
||||
folderInfo = mailDB->GetDBFolderInfo();
|
||||
if (folderInfo == NULL)
|
||||
{
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if opening existing file, make sure summary file is up to date.
|
||||
// if caller is upgrading, don't return eOldSummaryFile so the caller
|
||||
// if caller is upgrading, don't return NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE so the caller
|
||||
// can pull out the transfer info for the new db.
|
||||
if (!newFile && !statResult && !upgrading)
|
||||
{
|
||||
if (folderInfo->m_folderSize != st.st_size ||
|
||||
folderInfo->m_folderDate != st.st_mtime || folderInfo->GetNumNewMessages() < 0)
|
||||
err = eOldSummaryFile;
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
|
||||
}
|
||||
// compare current version of db versus filed out version info.
|
||||
if (mailDB->GetCurVersion() != folderInfo->GetDiskVersion())
|
||||
err = eOldSummaryFile;
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
|
||||
}
|
||||
if (err != eSUCCESS)
|
||||
if (err != NS_OK)
|
||||
{
|
||||
mailDB->Close();
|
||||
mailDB = NULL;
|
||||
}
|
||||
}
|
||||
if (err != eSUCCESS || newFile)
|
||||
if (err != NS_OK || newFile)
|
||||
{
|
||||
// if we couldn't open file, or we have a blank one, and we're supposed
|
||||
// to upgrade, updgrade it.
|
||||
if (newFile && !upgrading) // caller is upgrading, and we have empty summary file,
|
||||
{ // leave db around and open so caller can upgrade it.
|
||||
err = eNoSummaryFile;
|
||||
err = NS_MSG_ERROR_FOLDER_SUMMARY_MISSING;
|
||||
}
|
||||
else if (err != eSUCCESS)
|
||||
else if (err != NS_OK)
|
||||
{
|
||||
*pMessageDB = NULL;
|
||||
delete mailDB;
|
||||
}
|
||||
}
|
||||
if (err == eSUCCESS || err == eNoSummaryFile)
|
||||
if (err == NS_OK || err == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING)
|
||||
{
|
||||
*pMessageDB = mailDB;
|
||||
if (m_cacheEnabled)
|
||||
GetDBCache()->Add(mailDB);
|
||||
if (err == eSUCCESS)
|
||||
mailDB->HandleLatered();
|
||||
GetDBCache()->Add(mailDB);
|
||||
// if (err == NS_OK)
|
||||
// mailDB->HandleLatered();
|
||||
|
||||
}
|
||||
return(err);
|
||||
nsresult ret = OpenMDB(dbName, create);
|
||||
if (NS_MSG_SUCCEEDED(ret)
|
||||
{
|
||||
}
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
static nsresult nsMailDatabase::CloneInvalidDBInfoIntoNewDB(nsFilePath &pathName, nsMailDatabase** pMailDB)
|
||||
/* static */ nsresult nsMailDatabase::CloneInvalidDBInfoIntoNewDB(nsFilePath &pathName, nsMailDatabase** pMailDB)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult nsMailDatabase::OnNewPath (nsFilePath &newPath)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult nsMailDatabase::DeleteMessages(IDArray &messageKeys, ChangeListener *instigator)
|
||||
nsresult nsMailDatabase::DeleteMessages(nsMsgKeyArray &messageKeys, ChangeListener *instigator)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int nsMailDatabase::GetCurVersion() {return kMailDBVersion;}
|
||||
|
||||
static nsresult nsMailDatabase::SetFolderInfoValid(nsFilePath &pathname, int num, int numunread)
|
||||
/* static */ nsresult nsMailDatabase::SetFolderInfoValid(nsFilePath &pathname, int num, int numunread)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult nsMailDatabase::GetFolderName(nsString &folderName)
|
||||
{
|
||||
folderName = m_folderName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsMailDatabase *nsMailDatabase::GetMailDB() {return this;}
|
||||
|
||||
// The master is needed to find the folder info corresponding to the db.
|
||||
// Perhaps if we passed in the folder info when we opened the db,
|
||||
@@ -160,42 +164,59 @@ nsMailDatabase *nsMailDatabase::GetMailDB() {return this;}
|
||||
// get from the db to the folder info, but it's probably something like
|
||||
// some poor soul who has a db pointer but no folderInfo.
|
||||
|
||||
MSG_Master *nsMailDatabase::GetMaster() {return m_master;}
|
||||
void nsMailDatabase::SetMaster(MSG_Master *master) {m_master = master;}
|
||||
|
||||
MSG_FolderInfo *nsMailDatabase::GetFolderInfo()
|
||||
{
|
||||
PR_ASSERT(PR_FALSE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// for offline imap queued operations
|
||||
// these are in the base mail class (presumably) because offline moves between online and offline
|
||||
// folders can cause these operations to be stored in local mail folders.
|
||||
nsresult nsMailDatabase::ListAllOfflineOpIds(IDArray &outputIds)
|
||||
nsresult nsMailDatabase::ListAllOfflineOpIds(nsMsgKeyArray &outputIds)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
int nsMailDatabase::ListAllOfflineDeletes(IDArray &outputIds)
|
||||
|
||||
int nsMailDatabase::ListAllOfflineDeletes(nsMsgKeyArray &outputIds)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
nsresult nsMailDatabase::GetOfflineOpForKey(MessageKey opKey, PRBool create, nsOfflineImapOperation **)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult nsMailDatabase::AddOfflineOp(nsOfflineImapOperation *op)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult DeleteOfflineOp(MessageKey opKey)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult SetSourceMailbox(nsOfflineImapOperation *op, const char *mailbox, MessageKey key)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult nsMailDatabase::SetSummaryValid(PRBool valid = TRUE)
|
||||
nsresult nsMailDatabase::SetSummaryValid(PRBool valid /* = TRUE */)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult nsMailDatabase::GetIdsWithNoBodies (IDArray &bodylessIds)
|
||||
nsresult nsMailDatabase::GetIdsWithNoBodies (nsMsgKeyArray &bodylessIds)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
// this file implements the nsMsgDatabase interface using the MDB Interface.
|
||||
|
||||
|
||||
#include "nsMsgDatabase.h"
|
||||
|
||||
#ifdef WE_HAVE_MDBINTERFACES
|
||||
@@ -151,6 +152,7 @@ nsMsgDatabase::nsMsgDatabase() : m_dbName("")
|
||||
{
|
||||
m_mdbEnv = NULL;
|
||||
m_mdbStore = NULL;
|
||||
m_mdbTokensInitialized = FALSE;
|
||||
}
|
||||
|
||||
nsMsgDatabase::~nsMsgDatabase()
|
||||
@@ -264,3 +266,37 @@ nsresult nsMsgDatabase::ForceClosed()
|
||||
return err;
|
||||
}
|
||||
|
||||
const char *kMsgHdrsScope = "ns:msg:db:row:scope:msgs:all";
|
||||
const char *kMsgHdrsTableKind = "ns:msg:db:table:kind:msgs";
|
||||
struct mdbOid gMsgHdrsOID;
|
||||
|
||||
// initialize the various tokens in our db's env
|
||||
nsresult nsMsgDatabase::InitMDBInfo()
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
|
||||
if (!m_mdbTokensInitialized && GetStore())
|
||||
{
|
||||
m_mdbTokensInitialized = TRUE;
|
||||
err = GetStore()->StringToToken(GetEnv(), kMsgHdrsScope, &m_hdrRowScopeToken);
|
||||
if (err == NS_OK)
|
||||
{
|
||||
err = GetStore()->StringToToken(GetEnv(), kMsgHdrsTableKind, &m_hdrTableKindToken);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
// get a message header for the given key. Caller must release()!
|
||||
nsresult nsMsgDatabase::GetMsgHdrForKey(MessageKey messageKey, nsMsgHdr **msgHdr)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
return err;
|
||||
}
|
||||
|
||||
nsresult nsMsgDatabase::CreateNewHdr(PRBool *newThread, nsMsgHdr **newHdr, PRBool notify /* = FALSE */)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,17 +16,26 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsmsghdr.h"
|
||||
#include "nsMsgHdr.h"
|
||||
#include "nsMsgDatabase.h"
|
||||
|
||||
nsMsgHdr::nsMsgHdr()
|
||||
{
|
||||
NS_INIT_REFCNT;
|
||||
m_db = NULL;
|
||||
mRefCnt = 0;
|
||||
m_mdb = NULL;
|
||||
m_mdbRow = NULL;
|
||||
}
|
||||
|
||||
nsMsgHdr::~nsMsgHdr()
|
||||
{
|
||||
if (m_mdbRow)
|
||||
{
|
||||
if (m_mdb)
|
||||
{ // presumably, acquiring a row increments strong ref count
|
||||
m_mdbRow->CutStrongRef(m_mdb->GetEnv());
|
||||
m_mdb->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ref counting methods - if we inherit from nsISupports, we won't need these,
|
||||
|
||||
Reference in New Issue
Block a user