switch over to nsIDBFolderInfo from nsDBFolderInfo to reduce library dependancies

Added new API to nsIDBFolderInfo
This commit is contained in:
alecf%netscape.com 1999-03-24 00:17:23 +00:00
Родитель 0d544b6239
Коммит 25923cad03
11 изменённых файлов: 114 добавлений и 55 удалений

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

@ -23,7 +23,7 @@
#include "prprf.h"
#include "nsMsgKeyArray.h"
#include "nsMsgDatabase.h"
#include "nsDBFolderInfo.h"
#include "nsIDBFolderInfo.h"
#include "nsISupportsArray.h"
#include "nsIPref.h"
@ -36,11 +36,11 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
nsMsgFolder::nsMsgFolder(void)
: nsRDFResource(), mFlags(0),
mNumUnreadMessages(-1), mNumTotalMessages(0),
mNumUnreadMessages(0), mNumTotalMessages(0),
mListeners(nsnull),
mCsid(0),
mDepth(0),
mPrefFlags(0),
mListeners(nsnull)
mPrefFlags(0)
{
// NS_INIT_REFCNT(); done by superclass
@ -1187,7 +1187,7 @@ NS_IMETHODIMP nsMsgFolder::ReadDBFolderInfo(PRBool force)
nsresult result= NS_OK;
if (force || !(mPrefFlags & MSG_FOLDER_PREF_CACHED))
{
nsDBFolderInfo *folderInfo;
nsIDBFolderInfo *folderInfo;
nsMsgDatabase *db;
if((result = NS_SUCCEEDED(GetDBFolderInfoAndDB(&folderInfo, &db))))
{
@ -1201,12 +1201,13 @@ NS_IMETHODIMP nsMsgFolder::ReadDBFolderInfo(PRBool force)
folderInfo->GetNumMessages(&mNumTotalMessages);
folderInfo->GetNumNewMessages(&mNumUnreadMessages);
//These should be put in IMAP folder only.
// mNumPendingTotalMessages = folderInfo->GetImapTotalPendingMessages();
// mNumPendingUnreadMessages = folderInfo->GetImapUnreadPendingMessages();
// mCsid = folderInfo->GetCSID();
//These should be put in IMAP folder only.
//folderInfo->GetImapTotalPendingMessages(&mNumPendingTotalMessages);
//folderInfo->GetImapUnreadPendingMessages(&mNumPendingUnreadMessages);
// folderInfo->GetCSID(&mCsid);
if (db && !db->HasNew() && mNumPendingUnreadMessages <= 0)
ClearFlag(MSG_FOLDER_FLAG_GOT_NEW);
}
@ -1474,8 +1475,8 @@ nsURI2Path(const char* rootURI, char* uriStr, nsFileSpec& pathResult)
if (pos < 0)
pos = uriLen;
PRInt32 cnt = uri.Left(folderName, pos);
NS_ASSERTION(cnt == pos, "something wrong with nsString");
NS_ASSERTION(uri.Left(folderName, pos) == pos,
"something wrong with nsString");
path += sep;
@ -1539,8 +1540,8 @@ nsPath2URI(const char* rootURI, nsFileSpec& spec, char* *uri)
if (pos < 0)
pos = pathStrLen;
PRInt32 cnt = pathStr.Left(folderName, pos);
NS_ASSERTION(cnt == pos, "something wrong with nsString");
NS_ASSERTION(pathStr.Left(folderName, pos) == pos,
"something wrong with nsString");
pathStr.Cut(0, pos + sepLen);
pathStrLen -= pos + sepLen;

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

@ -29,7 +29,7 @@
#include "nsIMsgFolder.h" /* include the interface we are going to support */
#include "nsRDFResource.h"
#include "nsIRDFResourceFactory.h"
#include "nsDBFolderInfo.h"
#include "nsIDBFolderInfo.h"
#include "nsMsgDatabase.h"
/*
@ -274,7 +274,7 @@ public:
NS_IMETHOD GetUsersName(char **userName);
NS_IMETHOD GetHostName(char **hostName);
virtual nsresult GetDBFolderInfoAndDB(nsDBFolderInfo **folderInfo, nsMsgDatabase **db) = 0;
virtual nsresult GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsMsgDatabase **db) = 0;
NS_IMETHOD DeleteMessage(nsIMessage *message) = 0;
@ -302,8 +302,8 @@ protected:
// These values are used for tricking the front end into thinking that we have more
// messages than are really in the DB. This is usually after and IMAP message copy where
// we don't want to do an expensive select until the user actually opens that folder
PRUint32 mNumPendingUnreadMessages;
PRUint32 mNumPendingTotalMessages;
PRInt32 mNumPendingUnreadMessages;
PRInt32 mNumPendingTotalMessages;
PRBool mIsCachable;

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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
@ -63,6 +63,9 @@ public:
NS_IMETHOD GetNumVisibleMessages(PRInt32 *result) ;
NS_IMETHOD GetImapUidValidity(PRInt32 *result) ;
NS_IMETHOD SetImapUidValidity(PRInt32 uidValidity) ;
NS_IMETHOD GetImapTotalPendingMessages(PRInt32 *result) ;
NS_IMETHOD GetImapUnreadPendingMessages(PRInt32 *result) ;
NS_IMETHOD GetCSID(PRInt16 *result) ;
NS_IMETHOD SetVersion(PRUint32 version) ;
NS_IMETHOD GetVersion(PRUint32 *result);
@ -70,9 +73,15 @@ public:
NS_IMETHOD GetLastMessageLoaded(nsMsgKey *result);
NS_IMETHOD SetLastMessageLoaded(nsMsgKey lastLoaded);
NS_IMETHOD GetFolderSize(PRUint32 *size);
NS_IMETHOD SetFolderSize(PRUint32 size);
NS_IMETHOD GetFolderDate(time_t *date);
NS_IMETHOD SetFolderDate(time_t date);
NS_IMETHOD GetDiskVersion(int *version);
NS_IMETHOD ChangeExpungedBytes(PRInt32 delta);
NS_IMETHOD GetProperty(const char *propertyName, nsString &resultProperty);
NS_IMETHOD SetProperty(const char *propertyName, nsString &propertyStr);
NS_IMETHOD SetUint32Property(const char *propertyName, PRUint32 propertyValue);
@ -80,7 +89,6 @@ public:
// create the appropriate table and row in a new db.
nsresult AddToNewMDB();
// accessor methods.
int GetDiskVersion();
PRBool AddLaterKey(nsMsgKey key, time_t *until);
PRInt32 GetNumLatered();
@ -96,13 +104,10 @@ public:
void SetSortInfo(nsMsgSortType, nsMsgSortOrder);
void GetSortInfo(nsMsgSortType *, nsMsgSortOrder *);
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) ;

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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
@ -49,16 +49,25 @@ public:
NS_IMETHOD GetNumVisibleMessages(PRInt32 *result) = 0;
NS_IMETHOD GetImapUidValidity(PRInt32 *result) = 0;
NS_IMETHOD SetImapUidValidity(PRInt32 uidValidity) = 0;
NS_IMETHOD GetImapTotalPendingMessages(PRInt32 *result) = 0;
NS_IMETHOD GetImapUnreadPendingMessages(PRInt32 *result) = 0;
NS_IMETHOD GetCSID(PRInt16 *result) = 0;
NS_IMETHOD SetVersion(PRUint32 version) = 0;
NS_IMETHOD GetVersion(PRUint32 *result) = 0;
NS_IMETHOD GetLastMessageLoaded(nsMsgKey *result) = 0;
NS_IMETHOD SetLastMessageLoaded(nsMsgKey lastLoaded) = 0;
NS_IMETHOD GetFolderSize(PRUint32 *size) = 0;
NS_IMETHOD SetFolderSize(PRUint32 size) = 0;
NS_IMETHOD GetFolderDate(time_t *date) = 0;
NS_IMETHOD SetFolderDate(time_t date) = 0;
NS_IMETHOD GetDiskVersion(int *version) = 0;
NS_IMETHOD ChangeExpungedBytes(PRInt32 delta) = 0;
NS_IMETHOD GetProperty(const char *propertyName, nsString &resultProperty) = 0;
NS_IMETHOD SetProperty(const char *propertyName, nsString &propertyStr) = 0;
NS_IMETHOD SetUint32Property(const char *propertyName, PRUint32 propertyValue) = 0;

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

@ -27,10 +27,10 @@
#include "nsIDBChangeListener.h"
#include "nsMsgMessageFlags.h"
#include "nsISupportsArray.h"
#include "nsDBFolderInfo.h"
class nsThreadMessageHdr;
class ListContext;
class nsDBFolderInfo;
class nsMsgKeyArray;
class nsNewsSet;
@ -168,7 +168,7 @@ public:
NS_IMETHOD IsHeaderRead(nsIMessage *hdr, PRBool *pRead);
static nsIMdbFactory *GetMDBFactory();
nsDBFolderInfo *GetDBFolderInfo() {return m_dbFolderInfo;}
nsIDBFolderInfo *GetDBFolderInfo() {return m_dbFolderInfo;}
nsIMdbEnv *GetEnv() {return m_mdbEnv;}
nsIMdbStore *GetStore() {return m_mdbStore;}
virtual PRUint32 GetCurVersion();

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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
@ -69,12 +69,12 @@ nsDBFolderInfo::QueryInterface(REFNSIID iid, void** result)
nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
: m_expiredMarkColumnToken(0),
m_expiredMark(0),
: m_expiredMark(0),
m_viewType(0),
m_numVisibleMessagesColumnToken(0),
m_flags(0),
m_lastMessageLoaded(0)
m_lastMessageLoaded(0),
m_numVisibleMessagesColumnToken(0),
m_expiredMarkColumnToken(0)
{
NS_INIT_REFCNT();
m_mdbTable = NULL;
@ -272,12 +272,28 @@ NS_IMETHODIMP nsDBFolderInfo::SetHighWater(nsMsgKey highWater, PRBool force /* =
return NS_OK;
}
NS_IMETHODIMP
nsDBFolderInfo::GetFolderSize(PRUint32 *size)
{
if (!size) return NS_ERROR_NULL_POINTER;
*size = m_folderSize;
return NS_OK;
}
NS_IMETHODIMP nsDBFolderInfo::SetFolderSize(PRUint32 size)
{
m_folderSize = size;
return SetUint32PropertyWithToken(m_folderSizeColumnToken, m_folderSize);
}
NS_IMETHODIMP
nsDBFolderInfo::GetFolderDate(time_t *folderDate)
{
if (!folderDate) return NS_ERROR_NULL_POINTER;
*folderDate = m_folderDate;
return NS_OK;
}
NS_IMETHODIMP nsDBFolderInfo::SetFolderDate(time_t folderDate)
{
m_folderDate = folderDate;
@ -297,9 +313,18 @@ NS_IMETHODIMP nsDBFolderInfo::SetExpiredMark(nsMsgKey expiredKey)
return SetUint32PropertyWithToken(m_expiredMarkColumnToken, expiredKey);
}
int nsDBFolderInfo::GetDiskVersion()
NS_IMETHODIMP nsDBFolderInfo::GetDiskVersion(int *version)
{
return m_version;
if (!version) return NS_ERROR_NULL_POINTER;
*version = m_version;
return NS_OK;
}
NS_IMETHODIMP
nsDBFolderInfo::ChangeExpungedBytes(PRInt32 delta)
{
m_expungedBytes += delta;
return NS_OK;
}
PRBool nsDBFolderInfo::AddLaterKey(nsMsgKey key, time_t *until)
@ -469,9 +494,12 @@ PRBool nsDBFolderInfo::TestFlag(PRInt32 flags)
return (m_flags & flags) != 0;
}
PRInt16 nsDBFolderInfo::GetCSID()
NS_IMETHODIMP
nsDBFolderInfo::GetCSID(PRInt16 *result)
{
return m_csid;
if (!result) return NS_ERROR_NULL_POINTER;
*result = m_csid;
return NS_OK;
}
void nsDBFolderInfo::SetCSID(PRInt16 csid)
@ -489,9 +517,12 @@ void nsDBFolderInfo::SetIMAPHierarchySeparator(PRInt16 hierarchySeparator)
m_IMAPHierarchySeparator = hierarchySeparator;
}
PRInt32 nsDBFolderInfo::GetImapTotalPendingMessages()
NS_IMETHODIMP
nsDBFolderInfo::GetImapTotalPendingMessages(PRInt32 *result)
{
return m_totalPendingMessages;
if (!result) return NS_ERROR_NULL_POINTER;
*result = m_totalPendingMessages;
return NS_OK;
}
void nsDBFolderInfo::ChangeImapTotalPendingMessages(PRInt32 delta)
@ -500,9 +531,12 @@ void nsDBFolderInfo::ChangeImapTotalPendingMessages(PRInt32 delta)
SetInt32PropertyWithToken(m_totalPendingMessagesColumnToken, m_totalPendingMessages);
}
PRInt32 nsDBFolderInfo::GetImapUnreadPendingMessages()
NS_IMETHODIMP
nsDBFolderInfo::GetImapUnreadPendingMessages(PRInt32 *result)
{
return m_unreadPendingMessages;
if (!result) return NS_ERROR_NULL_POINTER;
*result = m_unreadPendingMessages;
return NS_OK;
}
void nsDBFolderInfo::ChangeImapUnreadPendingMessages(PRInt32 delta)

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

@ -44,7 +44,7 @@ nsMailDatabase::~nsMailDatabase()
PRBool newFile = PR_FALSE;
nsLocalFolderSummarySpec summarySpec(folderName);
nsDBFolderInfo *folderInfo = NULL;
nsIDBFolderInfo *folderInfo = NULL;
*pMessageDB = NULL;
@ -99,15 +99,21 @@ nsMailDatabase::~nsMailDatabase()
if (!newFile && summaryFileExists && !upgrading)
{
PRInt32 numNewMessages;
PRUint32 folderSize;
time_t folderDate;
folderInfo->GetNumNewMessages(&numNewMessages);
if (folderInfo->m_folderSize != st.st_size ||
folderInfo->m_folderDate != st.st_mtime || numNewMessages < 0)
folderInfo->GetFolderSize(&folderSize);
folderInfo->GetFolderDate(&folderDate);
if (folderSize != st.st_size ||
folderDate != st.st_mtime ||
numNewMessages < 0)
err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
}
// compare current version of db versus filed out version info.
if (mailDB->GetCurVersion() != folderInfo->GetDiskVersion())
int version;
folderInfo->GetDiskVersion(&version);
if (mailDB->GetCurVersion() != version)
err = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
}
if (err != NS_OK)
@ -314,7 +320,8 @@ void nsMailDatabase::UpdateFolderFlag(nsIMessage *mailHdr, PRBool bSet,
}
else
{
printf("Couldn't open mail folder for update%s!\n", m_folderName);
printf("Couldn't open mail folder for update%s!\n",
(const char*)m_folderName);
PR_ASSERT(PR_FALSE);
}
}

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

@ -351,6 +351,9 @@ extern nsIMdbFactory *NS_NewIMdbFactory();
if (!gMDBFactory)
{
gMDBFactory = MakeMdbFactory(); //new nsIMdbFactory;
#if 0
nsComponentManager::CreateInstance(
#endif
}
return gMDBFactory;
}

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

@ -692,7 +692,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetPrettyName(nsString& prettyName)
return NS_OK;
}
nsresult nsMsgLocalMailFolder::GetDBFolderInfoAndDB(nsDBFolderInfo **folderInfo, nsMsgDatabase **db)
nsresult nsMsgLocalMailFolder::GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsMsgDatabase **db)
{
nsMailDatabase *mailDB;

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

@ -101,7 +101,7 @@ public:
NS_IMETHOD RememberPassword(char *password);
NS_IMETHOD GetRememberedPassword(char ** password);
virtual nsresult GetDBFolderInfoAndDB(nsDBFolderInfo **folderInfo, nsMsgDatabase **db);
virtual nsresult GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsMsgDatabase **db);
NS_IMETHOD DeleteMessage(nsIMessage *message);

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

@ -20,7 +20,7 @@
#include "nsParseMailbox.h"
#include "nsIMessage.h"
#include "nsMailDatabase.h"
#include "nsDBFolderInfo.h"
#include "nsIDBFolderInfo.h"
#include "nsIByteBuffer.h"
#include "nsIInputStream.h"
#include "nsMsgLocalFolderHdrs.h"
@ -229,7 +229,7 @@ void nsMsgMailboxParser::UpdateDBFolderInfo()
// update folder info in db so we know not to reparse.
void nsMsgMailboxParser::UpdateDBFolderInfo(nsMailDatabase *mailDB, const char *mailboxName)
{
nsDBFolderInfo *folderInfo = mailDB->GetDBFolderInfo();
nsIDBFolderInfo *folderInfo = mailDB->GetDBFolderInfo();
// ### wrong - use method on db.
mailDB->SetSummaryValid(PR_TRUE);
@ -254,10 +254,10 @@ PRInt32 nsMsgMailboxParser::PublishMsgHeader()
(void)m_newMsgHdr->GetFlags(&flags);
if (flags & MSG_FLAG_EXPUNGED)
{
nsDBFolderInfo *folderInfo = m_mailDB->GetDBFolderInfo();
nsIDBFolderInfo *folderInfo = m_mailDB->GetDBFolderInfo();
PRUint32 size;
(void)m_newMsgHdr->GetMessageSize(&size);
folderInfo->m_expungedBytes += size;
folderInfo->ChangeExpungedBytes(size);
if (m_newMsgHdr)
{
m_newMsgHdr->Release();;
@ -276,9 +276,9 @@ PRInt32 nsMsgMailboxParser::PublishMsgHeader()
}
else if (m_mailDB)
{
nsDBFolderInfo *folderInfo = m_mailDB->GetDBFolderInfo();
nsIDBFolderInfo *folderInfo = m_mailDB->GetDBFolderInfo();
if (folderInfo)
folderInfo->m_expungedBytes += m_position - m_envelope_pos;
folderInfo->ChangeExpungedBytes(m_position - m_envelope_pos);
}
return 0;
}
@ -1356,7 +1356,7 @@ nsParseNewMailState::Init(MSG_Master *master, nsFileSpec &folder)
}
}
}
#endif DOING_MDN
#endif // DOING_MDN
m_usingTempDB = FALSE;
m_tmpdbName = NULL;
m_disableFilters = FALSE;