cleanup unused mailnews methods r/sr=mscott 218888

This commit is contained in:
bienvenu%nventure.com 2003-09-11 13:36:46 +00:00
Родитель 5f50ab557c
Коммит 7f964c5b7b
15 изменённых файлов: 592 добавлений и 802 удалений

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

@ -60,10 +60,6 @@ interface nsIMessenger : nsISupports {
readonly attribute nsITransactionManager transactionManager; readonly attribute nsITransactionManager transactionManager;
void SetWindow(in nsIDOMWindowInternal ptr, in nsIMsgWindow msgWindow); void SetWindow(in nsIDOMWindowInternal ptr, in nsIMsgWindow msgWindow);
void DeleteMessages(in nsIRDFCompositeDataSource database,
in nsIRDFResource srcFolderResource,
in nsISupportsArray messages,
in boolean reallyDelete);
void DeleteFolders(in nsIRDFCompositeDataSource db, void DeleteFolders(in nsIRDFCompositeDataSource db,
in nsIRDFResource parentFolder, in nsIRDFResource parentFolder,

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

@ -227,7 +227,6 @@ interface nsMsgNavigationType
const nsMsgNavigationTypeValue nextUnreadFolder = 11; const nsMsgNavigationTypeValue nextUnreadFolder = 11;
const nsMsgNavigationTypeValue nextFolder = 12; const nsMsgNavigationTypeValue nextFolder = 12;
const nsMsgNavigationTypeValue readMore = 13; const nsMsgNavigationTypeValue readMore = 13;
const nsMsgNavigationTypeValue laterMessage = 14;
/** /**
* Go back to the previous visited message * Go back to the previous visited message
*/ */

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

@ -66,6 +66,5 @@ interface nsIMsgThread : nsISupports {
nsIMsgDBHdr GetFirstUnreadChild(); nsIMsgDBHdr GetFirstUnreadChild();
nsISimpleEnumerator EnumerateMessages(in nsMsgKey parent); nsISimpleEnumerator EnumerateMessages(in nsMsgKey parent);
nsISimpleEnumerator EnumerateUnreadMessages(in nsMsgKey parent);
}; };

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

@ -63,19 +63,18 @@ interface nsIMsgMessagePaneController : nsISupports {
[scriptable, uuid(BD85A416-5433-11d3-8AC5-0060B0FC04D2)] [scriptable, uuid(BD85A416-5433-11d3-8AC5-0060B0FC04D2)]
interface nsIMsgWindow : nsISupports { interface nsIMsgWindow : nsISupports {
attribute nsIMsgMessagePaneController messagePaneController; attribute nsIMsgMessagePaneController messagePaneController;
attribute nsIMsgStatusFeedback statusFeedback; attribute nsIMsgStatusFeedback statusFeedback;
attribute nsIMsgHeaderSink msgHeaderSink; attribute nsIMsgHeaderSink msgHeaderSink;
attribute nsITransactionManager transactionManager; attribute nsITransactionManager transactionManager;
attribute nsIMsgFolder openFolder; attribute nsIMsgFolder openFolder;
attribute nsIDocShell rootDocShell; attribute nsIDocShell rootDocShell;
void displayHTMLInMessagePane(in wstring title, in wstring body); void displayHTMLInMessagePane(in wstring title, in wstring body);
readonly attribute nsIPrompt promptDialog; readonly attribute nsIPrompt promptDialog;
readonly attribute nsIAuthPrompt authPromptDialog; attribute string mailCharacterSet;
attribute string mailCharacterSet; // Remember the message's charaset was overridden, so it can be inherited (e.g for quoting).
// Remember the message's charaset was overridden, so it can be inherited (e.g for quoting). attribute boolean charsetOverride;
attribute boolean charsetOverride;
/* has a running url been stopped? If you care about checking /* has a running url been stopped? If you care about checking
this flag, you need to clear it before you start your operation since this flag, you need to clear it before you start your operation since

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

@ -331,80 +331,80 @@ nsMessenger::SetWindow(nsIDOMWindowInternal *aWin, nsIMsgWindow *aMsgWindow)
if (prefBranch) if (prefBranch)
pbi = do_QueryInterface(prefBranch); pbi = do_QueryInterface(prefBranch);
} }
if(!aWin) if(!aWin)
{ {
// it isn't an error to pass in null for aWin, in fact it means we are shutting // it isn't an error to pass in null for aWin, in fact it means we are shutting
// down and we should start cleaning things up... // down and we should start cleaning things up...
if (mMsgWindow) if (mMsgWindow)
{ {
nsCOMPtr<nsIMsgStatusFeedback> aStatusFeedback; nsCOMPtr<nsIMsgStatusFeedback> aStatusFeedback;
mMsgWindow->GetStatusFeedback(getter_AddRefs(aStatusFeedback)); mMsgWindow->GetStatusFeedback(getter_AddRefs(aStatusFeedback));
if (aStatusFeedback) if (aStatusFeedback)
aStatusFeedback->SetDocShell(nsnull, nsnull); aStatusFeedback->SetDocShell(nsnull, nsnull);
// Remove pref observer // Remove pref observer
if (pbi) if (pbi)
pbi->RemoveObserver(MAILNEWS_ALLOW_PLUGINS_PREF_NAME, this); pbi->RemoveObserver(MAILNEWS_ALLOW_PLUGINS_PREF_NAME, this);
} }
return NS_OK; return NS_OK;
} }
mMsgWindow = aMsgWindow; mMsgWindow = aMsgWindow;
NS_IF_RELEASE(mWindow); NS_IF_RELEASE(mWindow);
mWindow = aWin; mWindow = aWin;
NS_ADDREF(aWin); NS_ADDREF(aWin);
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(aWin) ); nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(aWin) );
NS_ENSURE_TRUE(globalObj, NS_ERROR_FAILURE); NS_ENSURE_TRUE(globalObj, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShell> docShell; nsCOMPtr<nsIDocShell> docShell;
globalObj->GetDocShell(getter_AddRefs(docShell)); globalObj->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell)); nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE); NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> rootDocShellAsItem; nsCOMPtr<nsIDocShellTreeItem> rootDocShellAsItem;
docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootDocShellAsItem)); docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootDocShellAsItem));
nsCOMPtr<nsIDocShellTreeNode> nsCOMPtr<nsIDocShellTreeNode>
rootDocShellAsNode(do_QueryInterface(rootDocShellAsItem)); rootDocShellAsNode(do_QueryInterface(rootDocShellAsItem));
if (rootDocShellAsNode) if (rootDocShellAsNode)
{ {
nsCOMPtr<nsIDocShellTreeItem> childAsItem; nsCOMPtr<nsIDocShellTreeItem> childAsItem;
nsresult rv = rootDocShellAsNode->FindChildWithName(NS_LITERAL_STRING("messagepane").get(), nsresult rv = rootDocShellAsNode->FindChildWithName(NS_LITERAL_STRING("messagepane").get(),
PR_TRUE, PR_FALSE, nsnull, getter_AddRefs(childAsItem)); PR_TRUE, PR_FALSE, nsnull, getter_AddRefs(childAsItem));
mDocShell = do_QueryInterface(childAsItem); mDocShell = do_QueryInterface(childAsItem);
if (NS_SUCCEEDED(rv) && mDocShell) { if (NS_SUCCEEDED(rv) && mDocShell) {
if (aMsgWindow)
{
nsCOMPtr<nsIMsgStatusFeedback> aStatusFeedback;
aMsgWindow->GetStatusFeedback(getter_AddRefs(aStatusFeedback));
if (aStatusFeedback)
aStatusFeedback->SetDocShell(mDocShell, mWindow);
if (aMsgWindow) { aMsgWindow->GetTransactionManager(getter_AddRefs(mTxnMgr));
nsCOMPtr<nsIMsgStatusFeedback> aStatusFeedback;
// Add pref observer
aMsgWindow->GetStatusFeedback(getter_AddRefs(aStatusFeedback)); if (pbi)
if (aStatusFeedback) pbi->AddObserver(MAILNEWS_ALLOW_PLUGINS_PREF_NAME, this, PR_TRUE);
{ SetDisplayProperties();
aStatusFeedback->SetDocShell(mDocShell, mWindow); }
}
aMsgWindow->GetTransactionManager(getter_AddRefs(mTxnMgr));
// Add pref observer
if (pbi)
pbi->AddObserver(MAILNEWS_ALLOW_PLUGINS_PREF_NAME, this, PR_TRUE);
SetDisplayProperties();
}
} }
} }
// we don't always have a message pane, like in the addressbook // we don't always have a message pane, like in the addressbook
// so if we don't havea docshell, use the one for the xul window. // so if we don't havea docshell, use the one for the xul window.
// we do this so OpenURL() will work. // we do this so OpenURL() will work.
if (!mDocShell) if (!mDocShell)
mDocShell = docShell; mDocShell = docShell;
return NS_OK; return NS_OK;
} }
@ -421,11 +421,9 @@ NS_IMETHODIMP nsMessenger::SetDisplayCharset(const char * aCharset)
if (cv) if (cv)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(cv); nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(cv);
if (muDV) { if (muDV)
muDV->SetForceCharacterSet(nsDependentCString(aCharset)); muDV->SetForceCharacterSet(nsDependentCString(aCharset));
}
mCurrentDisplayCharset = aCharset; mCurrentDisplayCharset = aCharset;
} }
} }
@ -1194,36 +1192,6 @@ nsMessenger::DoCommand(nsIRDFCompositeDataSource* db, const nsACString& command,
} }
NS_IMETHODIMP
nsMessenger::DeleteMessages(nsIRDFCompositeDataSource *database,
nsIRDFResource *srcFolderResource,
nsISupportsArray *resourceArray,
PRBool reallyDelete)
{
nsresult rv;
if(!database || !srcFolderResource || !resourceArray)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsISupportsArray> folderArray;
rv = NS_NewISupportsArray(getter_AddRefs(folderArray));
if(NS_FAILED(rv))
{
return NS_ERROR_OUT_OF_MEMORY;
}
folderArray->AppendElement(srcFolderResource);
if(reallyDelete)
rv = DoCommand(database, NS_LITERAL_CSTRING(NC_RDF_REALLY_DELETE), folderArray, resourceArray);
else
rv = DoCommand(database, NS_LITERAL_CSTRING(NC_RDF_DELETE), folderArray, resourceArray);
return rv;
}
NS_IMETHODIMP nsMessenger::DeleteFolders(nsIRDFCompositeDataSource *db, NS_IMETHODIMP nsMessenger::DeleteFolders(nsIRDFCompositeDataSource *db,
nsIRDFResource *parentResource, nsIRDFResource *parentResource,
nsIRDFResource *deletedFolderResource) nsIRDFResource *deletedFolderResource)

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

@ -525,26 +525,6 @@ NS_IMETHODIMP nsMsgWindow::GetPromptDialog(nsIPrompt **aPrompt)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
} }
NS_IMETHODIMP nsMsgWindow::GetAuthPromptDialog(nsIAuthPrompt **aPrompt)
{
nsresult rv = NS_OK;
NS_ENSURE_ARG_POINTER(aPrompt);
nsCOMPtr<nsIDocShell> rootShell(do_QueryReferent(mRootDocShellWeak));
if (rootShell)
{
nsCOMPtr<nsIAuthPrompt> dialog;
dialog = do_GetInterface(rootShell, &rv);
if (dialog)
{
*aPrompt = dialog;
NS_ADDREF(*aPrompt);
}
return rv;
}
else
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP NS_IMETHODIMP
nsMsgWindow::DisplayHTMLInMessagePane(const PRUnichar *title, const PRUnichar *body) nsMsgWindow::DisplayHTMLInMessagePane(const PRUnichar *title, const PRUnichar *body)
{ {

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

@ -60,103 +60,96 @@ class nsMsgDatabase;
class nsDBFolderInfo : public nsIDBFolderInfo class nsDBFolderInfo : public nsIDBFolderInfo
{ {
public: public:
friend class nsMsgDatabase; friend class nsMsgDatabase;
nsDBFolderInfo(nsMsgDatabase *mdb); nsDBFolderInfo(nsMsgDatabase *mdb);
virtual ~nsDBFolderInfo(); virtual ~nsDBFolderInfo();
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
// interface methods. // interface methods.
NS_DECL_NSIDBFOLDERINFO NS_DECL_NSIDBFOLDERINFO
// create the appropriate table and row in a new db. // create the appropriate table and row in a new db.
nsresult AddToNewMDB(); nsresult AddToNewMDB();
// accessor methods. // accessor methods.
PRBool AddLaterKey(nsMsgKey key, PRTime until); PRBool TestFlag(PRInt32 flags);
PRInt32 GetNumLatered(); PRInt16 GetIMAPHierarchySeparator() ;
nsMsgKey GetLateredAt(PRInt32 laterIndex, PRTime pUntil); void SetIMAPHierarchySeparator(PRInt16 hierarchySeparator) ;
void RemoveLateredAt(PRInt32 laterIndex); void ChangeImapTotalPendingMessages(PRInt32 delta);
void ChangeImapUnreadPendingMessages(PRInt32 delta) ;
PRBool TestFlag(PRInt32 flags);
PRInt16 GetIMAPHierarchySeparator() ; nsresult InitFromExistingDB();
void SetIMAPHierarchySeparator(PRInt16 hierarchySeparator) ; // get and set arbitrary property, aka row cell value.
void ChangeImapTotalPendingMessages(PRInt32 delta); nsresult SetPropertyWithToken(mdb_token aProperty, nsString *propertyStr);
void ChangeImapUnreadPendingMessages(PRInt32 delta) ; nsresult SetUint32PropertyWithToken(mdb_token aProperty, PRUint32 propertyValue);
nsresult SetInt32PropertyWithToken(mdb_token aProperty, PRInt32 propertyValue);
nsresult InitFromExistingDB(); nsresult GetPropertyWithToken(mdb_token aProperty, nsString *resultProperty);
// get and set arbitrary property, aka row cell value. nsresult GetUint32PropertyWithToken(mdb_token aProperty, PRUint32 &propertyValue, PRUint32 defaultValue = 0);
nsresult SetPropertyWithToken(mdb_token aProperty, nsString *propertyStr); nsresult GetInt32PropertyWithToken(mdb_token aProperty, PRInt32 &propertyValue, PRInt32 defaultValue = 0);
nsresult SetUint32PropertyWithToken(mdb_token aProperty, PRUint32 propertyValue); nsresult GetConstCharPtrCharacterSet(const char**result);
nsresult SetInt32PropertyWithToken(mdb_token aProperty, PRInt32 propertyValue);
nsresult GetPropertyWithToken(mdb_token aProperty, nsString *resultProperty);
nsresult GetUint32PropertyWithToken(mdb_token aProperty, PRUint32 &propertyValue, PRUint32 defaultValue = 0); nsMsgKeyArray m_lateredKeys; // list of latered messages
nsresult GetInt32PropertyWithToken(mdb_token aProperty, PRInt32 &propertyValue, PRInt32 defaultValue = 0);
nsresult GetConstCharPtrCharacterSet(const char**result);
nsMsgKeyArray m_lateredKeys; // list of latered messages
protected: protected:
// initialize from appropriate table and row in existing db. // initialize from appropriate table and row in existing db.
nsresult InitMDBInfo(); nsresult InitMDBInfo();
nsresult LoadMemberVariables(); nsresult LoadMemberVariables();
void ReleaseExternalReferences(); // let go of any references to other objects. void ReleaseExternalReferences(); // let go of any references to other objects.
PRInt32 m_folderSize; PRInt32 m_folderSize;
PRInt32 m_expungedBytes; // sum of size of deleted messages in folder PRInt32 m_expungedBytes; // sum of size of deleted messages in folder
PRUint32 m_folderDate; PRUint32 m_folderDate;
nsMsgKey m_highWaterMessageKey; // largest news article number or imap uid whose header we've seen nsMsgKey m_highWaterMessageKey; // largest news article number or imap uid whose header we've seen
// m_numVisibleMessages, m_numNewMessages and m_numMessages can never be negative. 0 means 'no msgs'. // m_numNewMessages and m_numMessages can never be negative. 0 means 'no msgs'.
PRInt32 m_numVisibleMessages; // doesn't include expunged or ignored messages (but does include collapsed). PRInt32 m_numNewMessages;
PRInt32 m_numNewMessages; PRInt32 m_numMessages; // includes expunged and ignored messages
PRInt32 m_numMessages; // includes expunged and ignored messages
PRInt32 m_flags; // folder specific flags. This holds things like re-use thread pane,
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
// configured for off-line use, use default retrieval, purge article/header options
PRUint16 m_version; // for upgrading...
PRUint16 m_version; // for upgrading... PRInt16 m_IMAPHierarchySeparator; // imap path separator
PRInt16 m_IMAPHierarchySeparator; // imap path separator
// mail only (for now)
// mail only (for now)
// IMAP only
// IMAP only PRInt32 m_ImapUidValidity;
PRInt32 m_ImapUidValidity; PRInt32 m_totalPendingMessages;
PRInt32 m_totalPendingMessages; PRInt32 m_unreadPendingMessages;
PRInt32 m_unreadPendingMessages;
// news only (for now)
// news only (for now) nsMsgKey m_expiredMark; // Highest invalid article number in group - for expiring
nsMsgKey m_expiredMark; // Highest invalid article number in group - for expiring // the db folder info will have to know what db and row it belongs to, since it is really
// 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.
// just a wrapper around the singleton folder info row in the mdb. nsMsgDatabase *m_mdb;
nsMsgDatabase *m_mdb; nsIMdbTable *m_mdbTable; // singleton table in db
nsIMdbTable *m_mdbTable; // singleton table in db nsIMdbRow *m_mdbRow; // singleton row in table;
nsIMdbRow *m_mdbRow; // singleton row in table;
nsCString m_charSet;
nsCString m_charSet; PRBool m_charSetOverride;
PRBool m_charSetOverride; PRBool m_mdbTokensInitialized;
PRBool m_mdbTokensInitialized;
mdb_token m_rowScopeToken;
mdb_token m_rowScopeToken; mdb_token m_tableKindToken;
mdb_token m_tableKindToken; // tokens for the pre-set columns - we cache these for speed, which may be silly
// tokens for the pre-set columns - we cache these for speed, which may be silly mdb_token m_mailboxNameColumnToken;
mdb_token m_mailboxNameColumnToken; mdb_token m_numMessagesColumnToken;
mdb_token m_numVisibleMessagesColumnToken; mdb_token m_numNewMessagesColumnToken;
mdb_token m_numMessagesColumnToken; mdb_token m_flagsColumnToken;
mdb_token m_numNewMessagesColumnToken; mdb_token m_folderSizeColumnToken;
mdb_token m_flagsColumnToken; mdb_token m_expungedBytesColumnToken;
mdb_token m_folderSizeColumnToken; mdb_token m_folderDateColumnToken;
mdb_token m_expungedBytesColumnToken; mdb_token m_highWaterMessageKeyColumnToken;
mdb_token m_folderDateColumnToken;
mdb_token m_highWaterMessageKeyColumnToken; mdb_token m_imapUidValidityColumnToken;
mdb_token m_totalPendingMessagesColumnToken;
mdb_token m_imapUidValidityColumnToken; mdb_token m_unreadPendingMessagesColumnToken;
mdb_token m_totalPendingMessagesColumnToken; mdb_token m_expiredMarkColumnToken;
mdb_token m_unreadPendingMessagesColumnToken; mdb_token m_versionColumnToken;
mdb_token m_expiredMarkColumnToken;
mdb_token m_versionColumnToken;
}; };
#endif #endif

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

@ -56,13 +56,11 @@ interface nsIDBFolderInfo : nsISupports {
void ChangeNumNewMessages(in long delta); void ChangeNumNewMessages(in long delta);
void ChangeNumMessages(in long delta); void ChangeNumMessages(in long delta);
// ChangeNumVisibleMessages, NumNewMessages and NumMessages will never return negative numbers. 0 means 'no msgs'. // NumNewMessages and NumMessages will never return negative numbers. 0 means 'no msgs'.
void ChangeNumVisibleMessages(in long delta);
attribute long NumNewMessages; attribute long NumNewMessages;
attribute long NumMessages; attribute long NumMessages;
attribute long expungedBytes; attribute long expungedBytes;
attribute long NumVisibleMessages;
attribute long ImapUidValidity; attribute long ImapUidValidity;
attribute unsigned long Version; attribute unsigned long Version;
attribute long ImapTotalPendingMessages; attribute long ImapTotalPendingMessages;

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

@ -211,7 +211,6 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
void UndoDelete(in nsIMsgDBHdr msgHdr); void UndoDelete(in nsIMsgDBHdr msgHdr);
void MarkLater(in nsMsgKey key, in PRTime until);
void MarkMarked(in nsMsgKey key, in boolean mark, void MarkMarked(in nsMsgKey key, in boolean mark,
in nsIDBChangeListener instigator); in nsIDBChangeListener instigator);
void MarkOffline(in nsMsgKey key, in boolean offline, void MarkOffline(in nsMsgKey key, in boolean offline,
@ -255,6 +254,9 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
[noscript] void ListAllOfflineDeletes(in nsMsgKeyArrayPtr offlineDeletes); [noscript] void ListAllOfflineDeletes(in nsMsgKeyArrayPtr offlineDeletes);
[noscript] void ListAllOfflineMsgs(in nsMsgKeyArrayPtr offlineMsgs); [noscript] void ListAllOfflineMsgs(in nsMsgKeyArrayPtr offlineMsgs);
void setAttributesOnPendingHdr(in nsIMsgDBHdr pendingHdr, in string property,
in string propertyVal, in long flags);
readonly attribute nsMsgKey lowWaterArticleNum; readonly attribute nsMsgKey lowWaterArticleNum;
readonly attribute nsMsgKey highWaterArticleNum; readonly attribute nsMsgKey highWaterArticleNum;
attribute nsMsgKey nextPseudoMsgKey; //for undo-redo of move pop->imap attribute nsMsgKey nextPseudoMsgKey; //for undo-redo of move pop->imap

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

@ -50,36 +50,28 @@ class nsOfflineImapOperation;
class nsMailDatabase : public nsMsgDatabase class nsMailDatabase : public nsMsgDatabase
{ {
public: public:
nsMailDatabase(); nsMailDatabase();
virtual ~nsMailDatabase(); virtual ~nsMailDatabase();
NS_IMETHOD Open(nsIFileSpec *aFolderName, PRBool create, PRBool upgrading, nsIMsgDatabase** pMessageDB); NS_IMETHOD Open(nsIFileSpec *aFolderName, PRBool create, PRBool upgrading, nsIMsgDatabase** pMessageDB);
NS_IMETHOD ForceClosed(); NS_IMETHOD ForceClosed();
NS_IMETHOD DeleteMessages(nsMsgKeyArray* nsMsgKeys, nsIDBChangeListener *instigator);
static nsresult CloneInvalidDBInfoIntoNewDB(nsFileSpec &pathName, nsMailDatabase** pMailDB);
NS_IMETHOD OnNewPath(nsFileSpec &newPath);
NS_IMETHOD DeleteMessages(nsMsgKeyArray* nsMsgKeys, nsIDBChangeListener *instigator);
NS_IMETHOD StartBatch(); NS_IMETHOD StartBatch();
NS_IMETHOD EndBatch(); NS_IMETHOD EndBatch();
static nsresult SetFolderInfoValid(nsFileSpec *folderSpec, int num, int numunread); static nsresult SetFolderInfoValid(nsFileSpec *folderSpec, int num, int numunread);
nsresult GetFolderName(nsString &folderName); nsresult GetFolderName(nsString &folderName);
virtual nsMailDatabase *GetMailDB() {return this;} virtual nsMailDatabase *GetMailDB() {return this;}
virtual PRUint32 GetCurVersion() {return kMsgDBVersion;} virtual PRUint32 GetCurVersion() {return kMsgDBVersion;}
NS_IMETHOD GetOfflineOpForKey(nsMsgKey opKey, PRBool create, nsIMsgOfflineImapOperation **op); NS_IMETHOD GetOfflineOpForKey(nsMsgKey opKey, PRBool create, nsIMsgOfflineImapOperation **op);
NS_IMETHOD RemoveOfflineOp(nsIMsgOfflineImapOperation *op); NS_IMETHOD RemoveOfflineOp(nsIMsgOfflineImapOperation *op);
nsresult SetSourceMailbox(nsOfflineImapOperation *op, const char *mailbox, nsMsgKey key);
NS_IMETHOD SetSummaryValid(PRBool valid); NS_IMETHOD SetSummaryValid(PRBool valid);
NS_IMETHOD GetSummaryValid(PRBool *valid); NS_IMETHOD GetSummaryValid(PRBool *valid);
NS_IMETHOD EnumerateOfflineOps(nsISimpleEnumerator **enumerator); NS_IMETHOD EnumerateOfflineOps(nsISimpleEnumerator **enumerator);
nsresult GetIdsWithNoBodies (nsMsgKeyArray &bodylessIds);
NS_IMETHOD ListAllOfflineOpIds(nsMsgKeyArray *offlineOpIds); NS_IMETHOD ListAllOfflineOpIds(nsMsgKeyArray *offlineOpIds);
NS_IMETHOD ListAllOfflineDeletes(nsMsgKeyArray *offlineDeletes); NS_IMETHOD ListAllOfflineDeletes(nsMsgKeyArray *offlineDeletes);
@ -90,7 +82,7 @@ protected:
nsresult GetAllOfflineOpsTable(); // get this on demand nsresult GetAllOfflineOpsTable(); // get this on demand
nsIMdbTable *m_mdbAllOfflineOpsTable; nsCOMPtr <nsIMdbTable> m_mdbAllOfflineOpsTable;
mdb_token m_offlineOpsRowScopeToken; mdb_token m_offlineOpsRowScopeToken;
mdb_token m_offlineOpsTableKindToken; mdb_token m_offlineOpsTableKindToken;

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

@ -77,36 +77,37 @@ public:
virtual nsresult CloseMDB(PRBool commit); virtual nsresult CloseMDB(PRBool commit);
virtual nsresult CreateMsgHdr(nsIMdbRow* hdrRow, nsMsgKey key, nsIMsgDBHdr **result); virtual nsresult CreateMsgHdr(nsIMdbRow* hdrRow, nsMsgKey key, nsIMsgDBHdr **result);
virtual nsresult GetThreadForMsgKey(nsMsgKey msgKey, nsIMsgThread **result); virtual nsresult GetThreadForMsgKey(nsMsgKey msgKey, nsIMsgThread **result);
virtual nsresult EnumerateUnreadMessages(nsISimpleEnumerator* *result);
virtual nsresult EnumerateReadMessages(nsISimpleEnumerator* *result);
virtual nsresult EnumerateMessagesWithFlag(nsISimpleEnumerator* *result, PRUint32 *pFlag); virtual nsresult EnumerateMessagesWithFlag(nsISimpleEnumerator* *result, PRUint32 *pFlag);
// this might just be for debugging - we'll see. // this might just be for debugging - we'll see.
nsresult ListAllThreads(nsMsgKeyArray *threadIds); nsresult ListAllThreads(nsMsgKeyArray *threadIds);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// nsMsgDatabase methods: // nsMsgDatabase methods:
nsMsgDatabase(); nsMsgDatabase();
virtual ~nsMsgDatabase(); virtual ~nsMsgDatabase();
static nsIMdbFactory *GetMDBFactory(); static nsIMdbFactory *GetMDBFactory();
nsIMdbEnv *GetEnv() {return m_mdbEnv;} nsIMdbEnv *GetEnv() {return m_mdbEnv;}
nsIMdbStore *GetStore() {return m_mdbStore;} nsIMdbStore *GetStore() {return m_mdbStore;}
virtual PRUint32 GetCurVersion(); virtual PRUint32 GetCurVersion();
nsIMsgHeaderParser *GetHeaderParser(); nsIMsgHeaderParser *GetHeaderParser();
nsresult GetCollationKeyGenerator(); nsresult GetCollationKeyGenerator();
nsIMimeConverter * GetMimeConverter(); nsIMimeConverter * GetMimeConverter();
static nsMsgDatabase* FindInCache(nsFileSpec &dbName); nsresult GetTableCreateIfMissing(const char *scope, const char *kind, nsIMdbTable **table,
mdb_token &scopeToken, mdb_token &kindToken);
//helper function to fill in nsStrings from hdr row cell contents. static nsMsgDatabase* FindInCache(nsFileSpec &dbName);
nsresult RowCellColumnTonsString(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr);
nsresult RowCellColumnToUInt32(nsIMdbRow *row, mdb_token columnToken, PRUint32 *uint32Result, PRUint32 defaultValue = 0); //helper function to fill in nsStrings from hdr row cell contents.
nsresult RowCellColumnToUInt32(nsIMdbRow *row, mdb_token columnToken, PRUint32 &uint32Result, PRUint32 defaultValue = 0); nsresult RowCellColumnTonsString(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr);
nsresult RowCellColumnToMime2DecodedString(nsIMdbRow *row, mdb_token columnToken, PRUnichar **); nsresult RowCellColumnToUInt32(nsIMdbRow *row, mdb_token columnToken, PRUint32 *uint32Result, PRUint32 defaultValue = 0);
nsresult RowCellColumnToCollationKey(nsIMdbRow *row, mdb_token columnToken, PRUint8 **result, PRUint32 *len); nsresult RowCellColumnToUInt32(nsIMdbRow *row, mdb_token columnToken, PRUint32 &uint32Result, PRUint32 defaultValue = 0);
nsresult RowCellColumnToConstCharPtr(nsIMdbRow *row, mdb_token columnToken, const char **ptr); nsresult RowCellColumnToMime2DecodedString(nsIMdbRow *row, mdb_token columnToken, PRUnichar **);
nsresult RowCellColumnToAddressCollationKey(nsIMdbRow *row, mdb_token colToken, PRUint8 **result, PRUint32 *len); 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);
// these methods take the property name as a string, not a token. // these methods take the property name as a string, not a token.
// they should be used when the properties aren't accessed a lot // they should be used when the properties aren't accessed a lot
@ -120,27 +121,27 @@ public:
nsresult SetNSStringPropertyWithToken(nsIMdbRow *row, mdb_token aProperty, nsString *propertyStr); nsresult SetNSStringPropertyWithToken(nsIMdbRow *row, mdb_token aProperty, nsString *propertyStr);
// helper functions to put values in cells for the passed-in row // helper functions to put values in cells for the passed-in row
nsresult UInt32ToRowCellColumn(nsIMdbRow *row, mdb_token columnToken, PRUint32 value); nsresult UInt32ToRowCellColumn(nsIMdbRow *row, mdb_token columnToken, PRUint32 value);
nsresult CharPtrToRowCellColumn(nsIMdbRow *row, mdb_token columnToken, const char *charPtr); nsresult CharPtrToRowCellColumn(nsIMdbRow *row, mdb_token columnToken, const char *charPtr);
nsresult RowCellColumnToCharPtr(nsIMdbRow *row, mdb_token columnToken, char **result); nsresult RowCellColumnToCharPtr(nsIMdbRow *row, mdb_token columnToken, char **result);
// helper functions to copy an nsString to a yarn, int32 to yarn, and vice versa. // helper functions to copy an nsString to a yarn, int32 to yarn, and vice versa.
static struct mdbYarn *nsStringToYarn(struct mdbYarn *yarn, nsString *str); static struct mdbYarn *nsStringToYarn(struct mdbYarn *yarn, nsString *str);
static struct mdbYarn *UInt32ToYarn(struct mdbYarn *yarn, PRUint32 i); static struct mdbYarn *UInt32ToYarn(struct mdbYarn *yarn, PRUint32 i);
static void YarnTonsString(struct mdbYarn *yarn, nsString *str); static void YarnTonsString(struct mdbYarn *yarn, nsString *str);
static void YarnTonsCString(struct mdbYarn *yarn, nsCString *str); static void YarnTonsCString(struct mdbYarn *yarn, nsCString *str);
static void YarnToUInt32(struct mdbYarn *yarn, PRUint32 *i); static void YarnToUInt32(struct mdbYarn *yarn, PRUint32 *i);
// helper functions to convert a 64bits PRTime into a 32bits value (compatible time_t) and vice versa. // helper functions to convert a 64bits PRTime into a 32bits value (compatible time_t) and vice versa.
static void PRTime2Seconds(PRTime prTime, PRUint32 *seconds); static void PRTime2Seconds(PRTime prTime, PRUint32 *seconds);
static void Seconds2PRTime(PRUint32 seconds, PRTime *prTime); static void Seconds2PRTime(PRUint32 seconds, PRTime *prTime);
static void CleanupCache(); static void CleanupCache();
#ifdef DEBUG #ifdef DEBUG
static int GetNumInCache(void) {return(GetDBCache()->Count());} static int GetNumInCache(void) {return(GetDBCache()->Count());}
static void DumpCache(); static void DumpCache();
virtual nsresult DumpContents(); virtual nsresult DumpContents();
nsresult DumpThread(nsMsgKey threadId); nsresult DumpThread(nsMsgKey threadId);
nsresult DumpMsgChildren(nsIMsgDBHdr *msgHdr); nsresult DumpMsgChildren(nsIMsgDBHdr *msgHdr);
@ -155,14 +156,14 @@ protected:
nsresult GetBoolPref(const char *prefName, PRBool *result); nsresult GetBoolPref(const char *prefName, PRBool *result);
nsresult GetIntPref(const char *prefName, PRInt32 *result); nsresult GetIntPref(const char *prefName, PRInt32 *result);
// retrieval methods // retrieval methods
nsIMsgThread * GetThreadForReference(nsCString &msgID, nsIMsgDBHdr **pMsgHdr); nsIMsgThread * GetThreadForReference(nsCString &msgID, nsIMsgDBHdr **pMsgHdr);
nsIMsgThread * GetThreadForSubject(nsCString &subject); nsIMsgThread * GetThreadForSubject(nsCString &subject);
nsIMsgThread * GetThreadForThreadId(nsMsgKey threadId); nsIMsgThread * GetThreadForThreadId(nsMsgKey threadId);
nsMsgHdr * GetMsgHdrForReference(nsCString &reference); nsMsgHdr * GetMsgHdrForReference(nsCString &reference);
nsIMsgDBHdr * GetMsgHdrForSubject(nsCString &msgID); nsIMsgDBHdr * GetMsgHdrForSubject(nsCString &msgID);
// threading interfaces // threading interfaces
virtual nsresult CreateNewThread(nsMsgKey key, const char *subject, nsMsgThread **newThread); virtual nsresult CreateNewThread(nsMsgKey key, const char *subject, nsMsgThread **newThread);
virtual PRBool ThreadBySubjectWithoutRe(); virtual PRBool ThreadBySubjectWithoutRe();
virtual nsresult ThreadNewHdr(nsMsgHdr* hdr, PRBool &newThread); virtual nsresult ThreadNewHdr(nsMsgHdr* hdr, PRBool &newThread);
virtual nsresult AddNewThread(nsMsgHdr *msgHdr); virtual nsresult AddNewThread(nsMsgHdr *msgHdr);
virtual nsresult AddToThread(nsMsgHdr *newHdr, nsIMsgThread *thread, nsIMsgDBHdr *pMsgHdr, PRBool threadInThread); virtual nsresult AddToThread(nsMsgHdr *newHdr, nsIMsgThread *thread, nsIMsgDBHdr *pMsgHdr, PRBool threadInThread);
@ -181,17 +182,17 @@ protected:
// Flag handling routines // Flag handling routines
virtual nsresult SetKeyFlag(nsMsgKey key, PRBool set, PRUint32 flag, virtual nsresult SetKeyFlag(nsMsgKey key, PRBool set, PRUint32 flag,
nsIDBChangeListener *instigator = NULL); nsIDBChangeListener *instigator = NULL);
virtual nsresult SetMsgHdrFlag(nsIMsgDBHdr *msgHdr, PRBool set, PRUint32 flag, virtual nsresult SetMsgHdrFlag(nsIMsgDBHdr *msgHdr, PRBool set, PRUint32 flag,
nsIDBChangeListener *instigator); nsIDBChangeListener *instigator);
virtual PRBool SetHdrFlag(nsIMsgDBHdr *, PRBool bSet, MsgFlags flag); virtual PRBool SetHdrFlag(nsIMsgDBHdr *, PRBool bSet, MsgFlags flag);
virtual PRBool SetHdrReadFlag(nsIMsgDBHdr *, PRBool pRead); virtual PRBool SetHdrReadFlag(nsIMsgDBHdr *, PRBool pRead);
virtual PRUint32 GetStatusFlags(nsIMsgDBHdr *msgHdr, PRUint32 origFlags); virtual PRUint32 GetStatusFlags(nsIMsgDBHdr *msgHdr, PRUint32 origFlags);
// helper function which doesn't involve thread object // helper function which doesn't involve thread object
virtual nsresult RemoveHeaderFromDB(nsMsgHdr *msgHdr); virtual nsresult RemoveHeaderFromDB(nsMsgHdr *msgHdr);
virtual nsresult RemoveHeaderFromThread(nsMsgHdr *msgHdr); virtual nsresult RemoveHeaderFromThread(nsMsgHdr *msgHdr);
virtual nsresult AdjustExpungedBytesOnDelete(nsIMsgDBHdr *msgHdr); virtual nsresult AdjustExpungedBytesOnDelete(nsIMsgDBHdr *msgHdr);
@ -205,69 +206,69 @@ protected:
nsresult PurgeMessagesOlderThan(PRUint32 daysToKeepHdrs, PRBool keepUnreadMessagesOnly); nsresult PurgeMessagesOlderThan(PRUint32 daysToKeepHdrs, PRBool keepUnreadMessagesOnly);
nsresult PurgeExcessMessages(PRUint32 numHeadersToKeep, PRBool keepUnreadMessagesOnly); nsresult PurgeExcessMessages(PRUint32 numHeadersToKeep, PRBool keepUnreadMessagesOnly);
// mdb bookkeeping stuff // mdb bookkeeping stuff
virtual nsresult InitExistingDB(); virtual nsresult InitExistingDB();
virtual nsresult InitNewDB(); virtual nsresult InitNewDB();
virtual nsresult InitMDBInfo(); virtual nsresult InitMDBInfo();
nsCOMPtr <nsIMsgFolder> m_folder; nsCOMPtr <nsIMsgFolder> m_folder;
nsDBFolderInfo *m_dbFolderInfo; nsDBFolderInfo *m_dbFolderInfo;
nsMsgKey m_nextPseudoMsgKey; nsMsgKey m_nextPseudoMsgKey;
nsIMdbEnv *m_mdbEnv; // to be used in all the db calls. nsIMdbEnv *m_mdbEnv; // to be used in all the db calls.
nsIMdbStore *m_mdbStore; nsIMdbStore *m_mdbStore;
nsIMdbTable *m_mdbAllMsgHeadersTable; nsIMdbTable *m_mdbAllMsgHeadersTable;
nsIMdbTable *m_mdbAllThreadsTable; nsIMdbTable *m_mdbAllThreadsTable;
nsFileSpec m_dbName; nsFileSpec m_dbName;
nsMsgKeySet *m_newSet; // new messages since last open. nsMsgKeySet *m_newSet; // new messages since last open.
PRBool m_mdbTokensInitialized; PRBool m_mdbTokensInitialized;
nsCOMPtr <nsISupportsArray> m_ChangeListeners; nsCOMPtr <nsISupportsArray> m_ChangeListeners;
mdb_token m_hdrRowScopeToken; mdb_token m_hdrRowScopeToken;
mdb_token m_threadRowScopeToken; mdb_token m_threadRowScopeToken;
mdb_token m_hdrTableKindToken; mdb_token m_hdrTableKindToken;
mdb_token m_threadTableKindToken; mdb_token m_threadTableKindToken;
mdb_token m_allThreadsTableKindToken; mdb_token m_allThreadsTableKindToken;
mdb_token m_subjectColumnToken; mdb_token m_subjectColumnToken;
mdb_token m_senderColumnToken; mdb_token m_senderColumnToken;
mdb_token m_messageIdColumnToken; mdb_token m_messageIdColumnToken;
mdb_token m_referencesColumnToken; mdb_token m_referencesColumnToken;
mdb_token m_recipientsColumnToken; mdb_token m_recipientsColumnToken;
mdb_token m_dateColumnToken; mdb_token m_dateColumnToken;
mdb_token m_messageSizeColumnToken; mdb_token m_messageSizeColumnToken;
mdb_token m_flagsColumnToken; mdb_token m_flagsColumnToken;
mdb_token m_priorityColumnToken; mdb_token m_priorityColumnToken;
mdb_token m_labelColumnToken; mdb_token m_labelColumnToken;
mdb_token m_statusOffsetColumnToken; mdb_token m_statusOffsetColumnToken;
mdb_token m_numLinesColumnToken; mdb_token m_numLinesColumnToken;
mdb_token m_ccListColumnToken; mdb_token m_ccListColumnToken;
mdb_token m_threadFlagsColumnToken; mdb_token m_threadFlagsColumnToken;
mdb_token m_threadIdColumnToken; mdb_token m_threadIdColumnToken;
mdb_token m_threadChildrenColumnToken; mdb_token m_threadChildrenColumnToken;
mdb_token m_threadUnreadChildrenColumnToken; mdb_token m_threadUnreadChildrenColumnToken;
mdb_token m_messageThreadIdColumnToken; mdb_token m_messageThreadIdColumnToken;
mdb_token m_threadSubjectColumnToken; mdb_token m_threadSubjectColumnToken;
mdb_token m_numReferencesColumnToken; mdb_token m_numReferencesColumnToken;
mdb_token m_messageCharSetColumnToken; mdb_token m_messageCharSetColumnToken;
mdb_token m_threadParentColumnToken; mdb_token m_threadParentColumnToken;
mdb_token m_threadRootKeyColumnToken; mdb_token m_threadRootKeyColumnToken;
mdb_token m_offlineMsgOffsetColumnToken; mdb_token m_offlineMsgOffsetColumnToken;
mdb_token m_offlineMessageSizeColumnToken; mdb_token m_offlineMessageSizeColumnToken;
nsIMsgHeaderParser *m_HeaderParser; nsIMsgHeaderParser *m_HeaderParser;
// header caching stuff - MRU headers, keeps them around in memory // header caching stuff - MRU headers, keeps them around in memory
nsresult GetHdrFromCache(nsMsgKey key, nsIMsgDBHdr* *result); nsresult GetHdrFromCache(nsMsgKey key, nsIMsgDBHdr* *result);
nsresult AddHdrToCache(nsIMsgDBHdr *hdr, nsMsgKey key); nsresult AddHdrToCache(nsIMsgDBHdr *hdr, nsMsgKey key);
nsresult ClearHdrCache(PRBool reInit); nsresult ClearHdrCache(PRBool reInit);
nsresult RemoveHdrFromCache(nsIMsgDBHdr *hdr, nsMsgKey key); nsresult RemoveHdrFromCache(nsIMsgDBHdr *hdr, nsMsgKey key);
// all headers currently instantiated, doesn't hold refs // all headers currently instantiated, doesn't hold refs
// these get added when msg hdrs get constructed, and removed when they get destroyed. // these get added when msg hdrs get constructed, and removed when they get destroyed.
nsresult GetHdrFromUseCache(nsMsgKey key, nsIMsgDBHdr* *result); nsresult GetHdrFromUseCache(nsMsgKey key, nsIMsgDBHdr* *result);
nsresult AddHdrToUseCache(nsIMsgDBHdr *hdr, nsMsgKey key); nsresult AddHdrToUseCache(nsIMsgDBHdr *hdr, nsMsgKey key);
nsresult ClearUseHdrCache(); nsresult ClearUseHdrCache();
nsresult RemoveHdrFromUseCache(nsIMsgDBHdr *hdr, nsMsgKey key); nsresult RemoveHdrFromUseCache(nsIMsgDBHdr *hdr, nsMsgKey key);
void ClearCachedObjects(PRBool dbGoingAway); void ClearCachedObjects(PRBool dbGoingAway);
// all instantiated headers, but doesn't hold refs. // all instantiated headers, but doesn't hold refs.
PLDHashTable *m_headersInUse; PLDHashTable *m_headersInUse;
static const void* PR_CALLBACK GetKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry); static const void* PR_CALLBACK GetKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
static PLDHashNumber PR_CALLBACK HashKey(PLDHashTable* aTable, const void* aKey); static PLDHashNumber PR_CALLBACK HashKey(PLDHashTable* aTable, const void* aKey);
@ -322,9 +323,9 @@ public:
NS_DECL_NSIMSGDOWNLOADSETTINGS NS_DECL_NSIMSGDOWNLOADSETTINGS
protected: protected:
PRBool m_useServerDefaults; PRBool m_useServerDefaults;
PRBool m_downloadUnreadOnly; PRBool m_downloadUnreadOnly;
PRBool m_downloadByDate; PRBool m_downloadByDate;
PRInt32 m_ageLimitOfMsgsToDownload; PRInt32 m_ageLimitOfMsgsToDownload;
}; };
#endif #endif

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

@ -55,18 +55,17 @@ static const char *kDBFolderInfoTableKind = "ns:msg:db:table:kind:dbfolderinfo";
struct mdbOid gDBFolderInfoOID; struct mdbOid gDBFolderInfoOID;
static const char * kNumVisibleMessagesColumnName = "numVisMsgs"; static const char * kNumMessagesColumnName ="numMsgs";
static const char * kNumMessagesColumnName ="numMsgs"; static const char * kNumNewMessagesColumnName = "numNewMsgs";
static const char * kNumNewMessagesColumnName = "numNewMsgs"; static const char * kFlagsColumnName = "flags";
static const char * kFlagsColumnName = "flags"; static const char * kFolderSizeColumnName = "folderSize";
static const char * kFolderSizeColumnName = "folderSize"; static const char * kExpungedBytesColumnName = "expungedBytes";
static const char * kExpungedBytesColumnName = "expungedBytes"; static const char * kFolderDateColumnName = "folderDate";
static const char * kFolderDateColumnName = "folderDate"; static const char * kHighWaterMessageKeyColumnName = "highWaterKey";
static const char * kHighWaterMessageKeyColumnName = "highWaterKey";
static const char * kImapUidValidityColumnName = "UIDValidity"; static const char * kImapUidValidityColumnName = "UIDValidity";
static const char * kTotalPendingMessagesColumnName = "totPendingMsgs"; static const char * kTotalPendingMessagesColumnName = "totPendingMsgs";
static const char * kUnreadPendingMessagesColumnName = "unreadPendingMsgs"; static const char * kUnreadPendingMessagesColumnName = "unreadPendingMsgs";
static const char * kMailboxNameColumnName = "mailboxName"; static const char * kMailboxNameColumnName = "mailboxName";
static const char * kKnownArtsSetColumnName = "knownArts"; static const char * kKnownArtsSetColumnName = "knownArts";
static const char * kExpiredMarkColumnName = "expiredMark"; static const char * kExpiredMarkColumnName = "expiredMark";
@ -117,7 +116,8 @@ NS_IMETHODIMP nsFolderCharsetObserver::Observe(nsISupports *aSubject, const char
nsCOMPtr<nsIPrefLocalizedString> pls; nsCOMPtr<nsIPrefLocalizedString> pls;
rv = prefBranch->GetComplexValue(kMAILNEWS_VIEW_DEFAULT_CHARSET, rv = prefBranch->GetComplexValue(kMAILNEWS_VIEW_DEFAULT_CHARSET,
NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(pls)); NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(pls));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv))
{
nsXPIDLString ucsval; nsXPIDLString ucsval;
pls->ToString(getter_Copies(ucsval)); pls->ToString(getter_Copies(ucsval));
if (ucsval) if (ucsval)
@ -132,7 +132,8 @@ NS_IMETHODIMP nsFolderCharsetObserver::Observe(nsISupports *aSubject, const char
else if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) else if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
{ {
nsCOMPtr<nsIPrefBranchInternal> pbi = do_QueryInterface(prefBranch); nsCOMPtr<nsIPrefBranchInternal> pbi = do_QueryInterface(prefBranch);
if (pbi) { if (pbi)
{
rv = pbi->RemoveObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, this); rv = pbi->RemoveObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, this);
rv = pbi->RemoveObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, this); rv = pbi->RemoveObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, this);
} }
@ -149,25 +150,25 @@ NS_IMPL_RELEASE(nsDBFolderInfo)
NS_IMETHODIMP NS_IMETHODIMP
nsDBFolderInfo::QueryInterface(REFNSIID iid, void** result) nsDBFolderInfo::QueryInterface(REFNSIID iid, void** result)
{ {
if (! result) if (! result)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*result = nsnull; *result = nsnull;
if(iid.Equals(NS_GET_IID(nsIDBFolderInfo)) || if(iid.Equals(NS_GET_IID(nsIDBFolderInfo)) ||
iid.Equals(NS_GET_IID(nsISupports))) { iid.Equals(NS_GET_IID(nsISupports)))
*result = NS_STATIC_CAST(nsIDBFolderInfo*, this); {
AddRef(); *result = NS_STATIC_CAST(nsIDBFolderInfo*, this);
return NS_OK; AddRef();
} return NS_OK;
return NS_NOINTERFACE; }
return NS_NOINTERFACE;
} }
nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb) nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
: m_flags(0), : m_flags(0),
m_expiredMark(0), m_expiredMark(0),
m_numVisibleMessagesColumnToken(0), m_expiredMarkColumnToken(0)
m_expiredMarkColumnToken(0)
{ {
m_mdbTable = NULL; m_mdbTable = NULL;
m_mdbRow = NULL; m_mdbRow = NULL;
@ -181,7 +182,6 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
m_numNewMessages = 0; m_numNewMessages = 0;
m_numMessages = 0; m_numMessages = 0;
m_numVisibleMessages = 0;
// IMAP only // IMAP only
m_ImapUidValidity = 0; m_ImapUidValidity = 0;
m_totalPendingMessages =0; m_totalPendingMessages =0;
@ -189,7 +189,7 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
m_mdbTokensInitialized = PR_FALSE; m_mdbTokensInitialized = PR_FALSE;
m_charSetOverride = PR_FALSE; m_charSetOverride = PR_FALSE;
if (!gInitializeObserver) if (!gInitializeObserver)
{ {
gInitializeObserver = PR_TRUE; gInitializeObserver = PR_TRUE;
@ -204,18 +204,19 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
{ {
nsCOMPtr<nsIPrefLocalizedString> pls; nsCOMPtr<nsIPrefLocalizedString> pls;
rv = prefBranch->GetComplexValue(kMAILNEWS_VIEW_DEFAULT_CHARSET, rv = prefBranch->GetComplexValue(kMAILNEWS_VIEW_DEFAULT_CHARSET,
NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(pls)); NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(pls));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv))
{
nsXPIDLString ucsval; nsXPIDLString ucsval;
pls->ToString(getter_Copies(ucsval)); pls->ToString(getter_Copies(ucsval));
if (ucsval) if (ucsval)
gDefaultCharacterSet.AssignWithConversion(ucsval.get()); gDefaultCharacterSet.AssignWithConversion(ucsval.get());
} }
rv = prefBranch->GetBoolPref(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, &gDefaultCharacterOverride); rv = prefBranch->GetBoolPref(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, &gDefaultCharacterOverride);
gFolderCharsetObserver = new nsFolderCharsetObserver(); gFolderCharsetObserver = new nsFolderCharsetObserver();
NS_ASSERTION(gFolderCharsetObserver, "failed to create observer"); NS_ASSERTION(gFolderCharsetObserver, "failed to create observer");
// register prefs callbacks // register prefs callbacks
if (gFolderCharsetObserver) if (gFolderCharsetObserver)
{ {
@ -225,7 +226,7 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
rv = pbi->AddObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, gFolderCharsetObserver, PR_FALSE); rv = pbi->AddObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, gFolderCharsetObserver, PR_FALSE);
rv = pbi->AddObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, gFolderCharsetObserver, PR_FALSE); rv = pbi->AddObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, gFolderCharsetObserver, PR_FALSE);
} }
// also register for shutdown // also register for shutdown
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv); nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
@ -235,25 +236,25 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgDatabase *mdb)
} }
} }
} }
m_mdb = mdb; m_mdb = mdb;
if (mdb) if (mdb)
{ {
mdb_err err; mdb_err err;
// mdb->AddRef(); // mdb->AddRef();
err = m_mdb->GetStore()->StringToToken(mdb->GetEnv(), kDBFolderInfoScope, &m_rowScopeToken); err = m_mdb->GetStore()->StringToToken(mdb->GetEnv(), kDBFolderInfoScope, &m_rowScopeToken);
if (err == NS_OK) if (err == NS_OK)
{ {
err = m_mdb->GetStore()->StringToToken(mdb->GetEnv(), kDBFolderInfoTableKind, &m_tableKindToken); err = m_mdb->GetStore()->StringToToken(mdb->GetEnv(), kDBFolderInfoTableKind, &m_tableKindToken);
if (err == NS_OK) if (err == NS_OK)
{ {
gDBFolderInfoOID.mOid_Scope = m_rowScopeToken; gDBFolderInfoOID.mOid_Scope = m_rowScopeToken;
gDBFolderInfoOID.mOid_Id = 1; gDBFolderInfoOID.mOid_Id = 1;
} }
} }
InitMDBInfo(); InitMDBInfo();
} }
} }
nsDBFolderInfo::~nsDBFolderInfo() nsDBFolderInfo::~nsDBFolderInfo()
@ -267,9 +268,8 @@ nsDBFolderInfo::~nsDBFolderInfo()
void nsDBFolderInfo::ReleaseExternalReferences() void nsDBFolderInfo::ReleaseExternalReferences()
{ {
if (gReleaseObserver) if (gReleaseObserver)
{
NS_IF_RELEASE(gFolderCharsetObserver); NS_IF_RELEASE(gFolderCharsetObserver);
}
if (m_mdb) if (m_mdb)
{ {
@ -290,111 +290,109 @@ void nsDBFolderInfo::ReleaseExternalReferences()
// this routine sets up a new db to know about the dbFolderInfo stuff... // this routine sets up a new db to know about the dbFolderInfo stuff...
nsresult nsDBFolderInfo::AddToNewMDB() nsresult nsDBFolderInfo::AddToNewMDB()
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;
if (m_mdb && m_mdb->GetStore()) if (m_mdb && m_mdb->GetStore())
{ {
nsIMdbStore *store = m_mdb->GetStore(); nsIMdbStore *store = m_mdb->GetStore();
// create the unique table for the dbFolderInfo. // create the unique table for the dbFolderInfo.
mdb_err err = store->NewTable(m_mdb->GetEnv(), m_rowScopeToken, mdb_err err = store->NewTable(m_mdb->GetEnv(), m_rowScopeToken,
m_tableKindToken, PR_TRUE, nsnull, &m_mdbTable); m_tableKindToken, PR_TRUE, nsnull, &m_mdbTable);
// make sure the oid of the table is 1. // make sure the oid of the table is 1.
struct mdbOid folderInfoTableOID; struct mdbOid folderInfoTableOID;
folderInfoTableOID.mOid_Id = 1; folderInfoTableOID.mOid_Id = 1;
folderInfoTableOID.mOid_Scope = m_rowScopeToken; folderInfoTableOID.mOid_Scope = m_rowScopeToken;
// m_mdbTable->BecomeContent(m_mdb->GetEnv(), &folderInfoTableOID); // m_mdbTable->BecomeContent(m_mdb->GetEnv(), &folderInfoTableOID);
// create the singleton row for the dbFolderInfo. // create the singleton row for the dbFolderInfo.
err = store->NewRowWithOid(m_mdb->GetEnv(), err = store->NewRowWithOid(m_mdb->GetEnv(),
&gDBFolderInfoOID, &m_mdbRow); &gDBFolderInfoOID, &m_mdbRow);
// add the row to the singleton table. // add the row to the singleton table.
if (m_mdbRow && NS_SUCCEEDED(err)) if (m_mdbRow && NS_SUCCEEDED(err))
{ {
err = m_mdbTable->AddRow(m_mdb->GetEnv(), m_mdbRow); err = m_mdbTable->AddRow(m_mdb->GetEnv(), m_mdbRow);
} }
ret = err; // what are we going to do about mdb_err's? ret = err; // what are we going to do about mdb_err's?
} }
return ret; return ret;
} }
nsresult nsDBFolderInfo::InitFromExistingDB() nsresult nsDBFolderInfo::InitFromExistingDB()
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;
if (m_mdb && m_mdb->GetStore()) if (m_mdb && m_mdb->GetStore())
{ {
nsIMdbStore *store = m_mdb->GetStore(); nsIMdbStore *store = m_mdb->GetStore();
if (store) if (store)
{ {
mdb_pos rowPos; mdb_pos rowPos;
mdb_count outTableCount; // current number of such tables mdb_count outTableCount; // current number of such tables
mdb_bool mustBeUnique; // whether port can hold only one of these mdb_bool mustBeUnique; // whether port can hold only one of these
mdb_bool hasOid; mdb_bool hasOid;
ret = store->GetTableKind(m_mdb->GetEnv(), m_rowScopeToken, m_tableKindToken, &outTableCount, ret = store->GetTableKind(m_mdb->GetEnv(), m_rowScopeToken, m_tableKindToken, &outTableCount,
&mustBeUnique, &m_mdbTable); &mustBeUnique, &m_mdbTable);
// NS_ASSERTION(mustBeUnique && outTableCount == 1, "only one global db info allowed"); // NS_ASSERTION(mustBeUnique && outTableCount == 1, "only one global db info allowed");
if (m_mdbTable) if (m_mdbTable)
{ {
// find singleton row for global info. // find singleton row for global info.
ret = m_mdbTable->HasOid(m_mdb->GetEnv(), &gDBFolderInfoOID, &hasOid); ret = m_mdbTable->HasOid(m_mdb->GetEnv(), &gDBFolderInfoOID, &hasOid);
if (ret == NS_OK) if (ret == NS_OK)
{ {
nsIMdbTableRowCursor *rowCursor; nsIMdbTableRowCursor *rowCursor;
rowPos = -1; rowPos = -1;
ret= m_mdbTable->GetTableRowCursor(m_mdb->GetEnv(), rowPos, &rowCursor); ret= m_mdbTable->GetTableRowCursor(m_mdb->GetEnv(), rowPos, &rowCursor);
if (ret == NS_OK) if (ret == NS_OK)
{ {
ret = rowCursor->NextRow(m_mdb->GetEnv(), &m_mdbRow, &rowPos); ret = rowCursor->NextRow(m_mdb->GetEnv(), &m_mdbRow, &rowPos);
NS_RELEASE(rowCursor); NS_RELEASE(rowCursor);
if (ret == NS_OK && m_mdbRow) if (ret == NS_OK && m_mdbRow)
{ {
LoadMemberVariables(); LoadMemberVariables();
} }
} }
} }
} }
} }
} }
return ret; return ret;
} }
nsresult nsDBFolderInfo::InitMDBInfo() nsresult nsDBFolderInfo::InitMDBInfo()
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;
if (!m_mdbTokensInitialized && m_mdb && m_mdb->GetStore()) if (!m_mdbTokensInitialized && m_mdb && m_mdb->GetStore())
{ {
nsIMdbStore *store = m_mdb->GetStore(); nsIMdbStore *store = m_mdb->GetStore();
nsIMdbEnv *env = m_mdb->GetEnv(); nsIMdbEnv *env = m_mdb->GetEnv();
store->StringToToken(env, kNumVisibleMessagesColumnName, &m_numVisibleMessagesColumnToken); store->StringToToken(env, kNumMessagesColumnName, &m_numMessagesColumnToken);
store->StringToToken(env, kNumMessagesColumnName, &m_numMessagesColumnToken); store->StringToToken(env, kNumNewMessagesColumnName, &m_numNewMessagesColumnToken);
store->StringToToken(env, kNumNewMessagesColumnName, &m_numNewMessagesColumnToken); store->StringToToken(env, kFlagsColumnName, &m_flagsColumnToken);
store->StringToToken(env, kFlagsColumnName, &m_flagsColumnToken); store->StringToToken(env, kFolderSizeColumnName, &m_folderSizeColumnToken);
store->StringToToken(env, kFolderSizeColumnName, &m_folderSizeColumnToken); store->StringToToken(env, kExpungedBytesColumnName, &m_expungedBytesColumnToken);
store->StringToToken(env, kExpungedBytesColumnName, &m_expungedBytesColumnToken); store->StringToToken(env, kFolderDateColumnName, &m_folderDateColumnToken);
store->StringToToken(env, kFolderDateColumnName, &m_folderDateColumnToken);
store->StringToToken(env, kHighWaterMessageKeyColumnName, &m_highWaterMessageKeyColumnToken);
store->StringToToken(env, kHighWaterMessageKeyColumnName, &m_highWaterMessageKeyColumnToken); store->StringToToken(env, kMailboxNameColumnName, &m_mailboxNameColumnToken);
store->StringToToken(env, kMailboxNameColumnName, &m_mailboxNameColumnToken);
store->StringToToken(env, kImapUidValidityColumnName, &m_imapUidValidityColumnToken);
store->StringToToken(env, kImapUidValidityColumnName, &m_imapUidValidityColumnToken); store->StringToToken(env, kTotalPendingMessagesColumnName, &m_totalPendingMessagesColumnToken);
store->StringToToken(env, kTotalPendingMessagesColumnName, &m_totalPendingMessagesColumnToken); store->StringToToken(env, kUnreadPendingMessagesColumnName, &m_unreadPendingMessagesColumnToken);
store->StringToToken(env, kUnreadPendingMessagesColumnName, &m_unreadPendingMessagesColumnToken); store->StringToToken(env, kExpiredMarkColumnName, &m_expiredMarkColumnToken);
store->StringToToken(env, kExpiredMarkColumnName, &m_expiredMarkColumnToken); store->StringToToken(env, kVersionColumnName, &m_versionColumnToken);
store->StringToToken(env, kVersionColumnName, &m_versionColumnToken); m_mdbTokensInitialized = PR_TRUE;
m_mdbTokensInitialized = PR_TRUE; }
} return ret;
return ret;
} }
nsresult nsDBFolderInfo::LoadMemberVariables() nsresult nsDBFolderInfo::LoadMemberVariables()
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;
// it's really not an error for these properties to not exist... // it's really not an error for these properties to not exist...
GetInt32PropertyWithToken(m_numVisibleMessagesColumnToken, m_numVisibleMessages);
GetInt32PropertyWithToken(m_numMessagesColumnToken, m_numMessages); GetInt32PropertyWithToken(m_numMessagesColumnToken, m_numMessages);
GetInt32PropertyWithToken(m_numNewMessagesColumnToken, m_numNewMessages); GetInt32PropertyWithToken(m_numNewMessagesColumnToken, m_numNewMessages);
GetInt32PropertyWithToken(m_flagsColumnToken, m_flags); GetInt32PropertyWithToken(m_flagsColumnToken, m_flags);
@ -444,7 +442,7 @@ NS_IMETHODIMP nsDBFolderInfo::SetHighWater(nsMsgKey highWater, PRBool force)
NS_IMETHODIMP nsDBFolderInfo::SetHighWater(nsMsgKey highWater) NS_IMETHODIMP nsDBFolderInfo::SetHighWater(nsMsgKey highWater)
{ {
return SetHighWater(highWater, PR_TRUE); return SetHighWater(highWater, PR_TRUE);
} }
@ -452,49 +450,49 @@ NS_IMETHODIMP
nsDBFolderInfo::GetFolderSize(PRUint32 *size) nsDBFolderInfo::GetFolderSize(PRUint32 *size)
{ {
if (!size) if (!size)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*size = m_folderSize; *size = m_folderSize;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetFolderSize(PRUint32 size) NS_IMETHODIMP nsDBFolderInfo::SetFolderSize(PRUint32 size)
{ {
m_folderSize = size; m_folderSize = size;
return SetUint32PropertyWithToken(m_folderSizeColumnToken, m_folderSize); return SetUint32PropertyWithToken(m_folderSizeColumnToken, m_folderSize);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDBFolderInfo::GetFolderDate(PRUint32 *folderDate) nsDBFolderInfo::GetFolderDate(PRUint32 *folderDate)
{ {
if (!folderDate) if (!folderDate)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*folderDate = m_folderDate; *folderDate = m_folderDate;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetFolderDate(PRUint32 folderDate) NS_IMETHODIMP nsDBFolderInfo::SetFolderDate(PRUint32 folderDate)
{ {
m_folderDate = folderDate; m_folderDate = folderDate;
return SetUint32PropertyWithToken(m_folderDateColumnToken, folderDate); return SetUint32PropertyWithToken(m_folderDateColumnToken, folderDate);
} }
NS_IMETHODIMP nsDBFolderInfo::GetHighWater(nsMsgKey *result) NS_IMETHODIMP nsDBFolderInfo::GetHighWater(nsMsgKey *result)
{ {
*result = m_highWaterMessageKey; *result = m_highWaterMessageKey;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetExpiredMark(nsMsgKey expiredKey) NS_IMETHODIMP nsDBFolderInfo::SetExpiredMark(nsMsgKey expiredKey)
{ {
m_expiredMark = expiredKey; m_expiredMark = expiredKey;
return SetUint32PropertyWithToken(m_expiredMarkColumnToken, expiredKey); return SetUint32PropertyWithToken(m_expiredMarkColumnToken, expiredKey);
} }
NS_IMETHODIMP nsDBFolderInfo::GetExpiredMark(nsMsgKey *result) NS_IMETHODIMP nsDBFolderInfo::GetExpiredMark(nsMsgKey *result)
{ {
*result = m_expiredMark; *result = m_expiredMark;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -503,196 +501,146 @@ nsDBFolderInfo::ChangeExpungedBytes(PRInt32 delta)
return SetExpungedBytes(m_expungedBytes + delta); return SetExpungedBytes(m_expungedBytes + delta);
} }
PRBool nsDBFolderInfo::AddLaterKey(nsMsgKey key, PRTime until)
{
//ducarroz: if until represente a folder time stamp,
// therefore it should be declared as a PRInt32.
// Else, it should be a PRTime.
return PR_FALSE;
}
PRInt32 nsDBFolderInfo::GetNumLatered()
{
return 0;
}
nsMsgKey nsDBFolderInfo::GetLateredAt(PRInt32 laterIndex, PRTime pUntil)
{
//ducarroz: if until represente a folder time stamp,
// therefore it should be declared as a PRInt32.
// Else, it should be a PRTime.
return nsMsgKey_None;
}
void nsDBFolderInfo::RemoveLateredAt(PRInt32 laterIndex)
{
}
NS_IMETHODIMP nsDBFolderInfo::SetMailboxName(nsString *newBoxName) NS_IMETHODIMP nsDBFolderInfo::SetMailboxName(nsString *newBoxName)
{ {
return SetPropertyWithToken(m_mailboxNameColumnToken, newBoxName); return SetPropertyWithToken(m_mailboxNameColumnToken, newBoxName);
} }
NS_IMETHODIMP nsDBFolderInfo::GetMailboxName(nsString *boxName) NS_IMETHODIMP nsDBFolderInfo::GetMailboxName(nsString *boxName)
{ {
return GetPropertyWithToken(m_mailboxNameColumnToken, boxName); return GetPropertyWithToken(m_mailboxNameColumnToken, boxName);
} }
NS_IMETHODIMP nsDBFolderInfo::ChangeNumNewMessages(PRInt32 delta) NS_IMETHODIMP nsDBFolderInfo::ChangeNumNewMessages(PRInt32 delta)
{ {
m_numNewMessages += delta; m_numNewMessages += delta;
// m_numNewMessages can never be set to negative. // m_numNewMessages can never be set to negative.
if (m_numNewMessages < 0) if (m_numNewMessages < 0)
{ {
#ifdef DEBUG_bienvenu1 #ifdef DEBUG_bienvenu1
NS_ASSERTION(PR_FALSE, "Hardcoded assertion"); NS_ASSERTION(PR_FALSE, "Hardcoded assertion");
#endif #endif
m_numNewMessages = 0; m_numNewMessages = 0;
} }
return SetUint32PropertyWithToken(m_numNewMessagesColumnToken, m_numNewMessages); return SetUint32PropertyWithToken(m_numNewMessagesColumnToken, m_numNewMessages);
} }
NS_IMETHODIMP nsDBFolderInfo::ChangeNumMessages(PRInt32 delta) NS_IMETHODIMP nsDBFolderInfo::ChangeNumMessages(PRInt32 delta)
{ {
m_numMessages += delta; m_numMessages += delta;
// m_numMessages can never be set to negative. // m_numMessages can never be set to negative.
if (m_numMessages < 0) if (m_numMessages < 0)
{ {
#ifdef DEBUG_bienvenu #ifdef DEBUG_bienvenu
NS_ASSERTION(PR_FALSE, "num messages can't be < 0"); NS_ASSERTION(PR_FALSE, "num messages can't be < 0");
#endif #endif
m_numMessages = 0; m_numMessages = 0;
} }
return SetUint32PropertyWithToken(m_numMessagesColumnToken, m_numMessages); return SetUint32PropertyWithToken(m_numMessagesColumnToken, m_numMessages);
} }
NS_IMETHODIMP nsDBFolderInfo::ChangeNumVisibleMessages(PRInt32 delta)
{
m_numVisibleMessages += delta;
// m_numVisibleMessages can never be set to negative.
if (m_numVisibleMessages < 0)
{
#ifdef DEBUG_bienvenu
NS_ASSERTION(PR_FALSE, "num visible messages can't be < 0");
#endif
m_numVisibleMessages = 0;
}
return SetUint32PropertyWithToken(m_numVisibleMessagesColumnToken, m_numVisibleMessages);
}
NS_IMETHODIMP nsDBFolderInfo::GetNumNewMessages(PRInt32 *result) NS_IMETHODIMP nsDBFolderInfo::GetNumNewMessages(PRInt32 *result)
{ {
*result = m_numNewMessages; *result = m_numNewMessages;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetNumNewMessages(PRInt32 numNewMessages) NS_IMETHODIMP nsDBFolderInfo::SetNumNewMessages(PRInt32 numNewMessages)
{ {
m_numNewMessages = numNewMessages; m_numNewMessages = numNewMessages;
return SetUint32PropertyWithToken(m_numNewMessagesColumnToken, m_numNewMessages); return SetUint32PropertyWithToken(m_numNewMessagesColumnToken, m_numNewMessages);
} }
NS_IMETHODIMP nsDBFolderInfo::GetNumMessages(PRInt32 *result) NS_IMETHODIMP nsDBFolderInfo::GetNumMessages(PRInt32 *result)
{ {
*result = m_numMessages; *result = m_numMessages;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetNumMessages(PRInt32 numMessages) NS_IMETHODIMP nsDBFolderInfo::SetNumMessages(PRInt32 numMessages)
{ {
m_numMessages = numMessages; m_numMessages = numMessages;
return SetUint32PropertyWithToken(m_numMessagesColumnToken, m_numMessages); return SetUint32PropertyWithToken(m_numMessagesColumnToken, m_numMessages);
}
NS_IMETHODIMP nsDBFolderInfo::GetNumVisibleMessages(PRInt32 *result)
{
*result = m_numVisibleMessages;
return NS_OK;
}
NS_IMETHODIMP nsDBFolderInfo::SetNumVisibleMessages(PRInt32 numVisibleMessages)
{
m_numVisibleMessages = numVisibleMessages;
return SetUint32PropertyWithToken(m_numVisibleMessagesColumnToken, m_numVisibleMessages);
} }
NS_IMETHODIMP nsDBFolderInfo::GetExpungedBytes(PRInt32 *result) NS_IMETHODIMP nsDBFolderInfo::GetExpungedBytes(PRInt32 *result)
{ {
*result = m_expungedBytes; *result = m_expungedBytes;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetExpungedBytes(PRInt32 expungedBytes) NS_IMETHODIMP nsDBFolderInfo::SetExpungedBytes(PRInt32 expungedBytes)
{ {
m_expungedBytes = expungedBytes; m_expungedBytes = expungedBytes;
return SetUint32PropertyWithToken(m_expungedBytesColumnToken, m_expungedBytes); return SetUint32PropertyWithToken(m_expungedBytesColumnToken, m_expungedBytes);
} }
NS_IMETHODIMP nsDBFolderInfo::GetFlags(PRInt32 *result) NS_IMETHODIMP nsDBFolderInfo::GetFlags(PRInt32 *result)
{ {
*result = m_flags; *result = m_flags;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetFlags(PRInt32 flags) NS_IMETHODIMP nsDBFolderInfo::SetFlags(PRInt32 flags)
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;
if (m_flags != flags) if (m_flags != flags)
{ {
NS_ASSERTION((m_flags & MSG_FOLDER_FLAG_INBOX) == 0 || (flags & MSG_FOLDER_FLAG_INBOX) != 0, "lost inbox flag"); NS_ASSERTION((m_flags & MSG_FOLDER_FLAG_INBOX) == 0 || (flags & MSG_FOLDER_FLAG_INBOX) != 0, "lost inbox flag");
m_flags = flags; m_flags = flags;
ret = SetInt32PropertyWithToken(m_flagsColumnToken, m_flags); ret = SetInt32PropertyWithToken(m_flagsColumnToken, m_flags);
} }
return ret; return ret;
} }
NS_IMETHODIMP nsDBFolderInfo::OrFlags(PRInt32 flags, PRInt32 *result) NS_IMETHODIMP nsDBFolderInfo::OrFlags(PRInt32 flags, PRInt32 *result)
{ {
m_flags |= flags; m_flags |= flags;
*result = m_flags; *result = m_flags;
return SetInt32PropertyWithToken(m_flagsColumnToken, m_flags); return SetInt32PropertyWithToken(m_flagsColumnToken, m_flags);
} }
NS_IMETHODIMP nsDBFolderInfo::AndFlags(PRInt32 flags, PRInt32 *result) NS_IMETHODIMP nsDBFolderInfo::AndFlags(PRInt32 flags, PRInt32 *result)
{ {
m_flags &= flags; m_flags &= flags;
*result = m_flags; *result = m_flags;
return SetInt32PropertyWithToken(m_flagsColumnToken, m_flags); return SetInt32PropertyWithToken(m_flagsColumnToken, m_flags);
} }
NS_IMETHODIMP nsDBFolderInfo::GetImapUidValidity(PRInt32 *result) NS_IMETHODIMP nsDBFolderInfo::GetImapUidValidity(PRInt32 *result)
{ {
*result = m_ImapUidValidity; *result = m_ImapUidValidity;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetImapUidValidity(PRInt32 uidValidity) NS_IMETHODIMP nsDBFolderInfo::SetImapUidValidity(PRInt32 uidValidity)
{ {
m_ImapUidValidity = uidValidity; m_ImapUidValidity = uidValidity;
return SetUint32PropertyWithToken(m_imapUidValidityColumnToken, m_ImapUidValidity); return SetUint32PropertyWithToken(m_imapUidValidityColumnToken, m_ImapUidValidity);
} }
PRBool nsDBFolderInfo::TestFlag(PRInt32 flags) PRBool nsDBFolderInfo::TestFlag(PRInt32 flags)
{ {
return (m_flags & flags) != 0; return (m_flags & flags) != 0;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDBFolderInfo::GetCharacterSet(nsString *result, PRBool *usedDefault) nsDBFolderInfo::GetCharacterSet(nsString *result, PRBool *usedDefault)
{ {
nsresult rv = GetProperty(kCharacterSetColumnName, result); nsresult rv = GetProperty(kCharacterSetColumnName, result);
*usedDefault = PR_FALSE; *usedDefault = PR_FALSE;
if (NS_SUCCEEDED(rv) && result->IsEmpty()) if (NS_SUCCEEDED(rv) && result->IsEmpty())
{ {
result->AssignWithConversion(gDefaultCharacterSet.get()); result->AssignWithConversion(gDefaultCharacterSet.get());
*usedDefault = PR_TRUE; *usedDefault = PR_TRUE;
} }
return rv; return rv;
} }
nsresult nsDBFolderInfo::GetConstCharPtrCharacterSet(const char**result) nsresult nsDBFolderInfo::GetConstCharPtrCharacterSet(const char**result)
@ -710,10 +658,10 @@ nsDBFolderInfo::GetCharPtrCharacterSet(char **result)
*result = ToNewCString(m_charSet); *result = ToNewCString(m_charSet);
if ((*result == nsnull || **result == '\0')) if ((*result == nsnull || **result == '\0'))
{ {
PR_FREEIF(*result); PR_Free(*result);
*result = ToNewCString(gDefaultCharacterSet); *result = ToNewCString(gDefaultCharacterSet);
} }
return (*result) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; return (*result) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
} }
@ -739,72 +687,72 @@ NS_IMETHODIMP nsDBFolderInfo::SetCharacterSetOverride(PRBool characterSetOverrid
NS_IMETHODIMP NS_IMETHODIMP
nsDBFolderInfo::GetLocale(nsString *result) nsDBFolderInfo::GetLocale(nsString *result)
{ {
GetProperty(kLocaleColumnName, result); GetProperty(kLocaleColumnName, result);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetLocale(nsString *locale) NS_IMETHODIMP nsDBFolderInfo::SetLocale(nsString *locale)
{ {
return SetProperty(kLocaleColumnName, locale); return SetProperty(kLocaleColumnName, locale);
} }
NS_IMETHODIMP nsDBFolderInfo::GetIMAPHierarchySeparator(PRUnichar *hierarchySeparator) NS_IMETHODIMP nsDBFolderInfo::GetIMAPHierarchySeparator(PRUnichar *hierarchySeparator)
{ {
if (!hierarchySeparator) if (!hierarchySeparator)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*hierarchySeparator = m_IMAPHierarchySeparator; *hierarchySeparator = m_IMAPHierarchySeparator;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetIMAPHierarchySeparator(PRUnichar hierarchySeparator) NS_IMETHODIMP nsDBFolderInfo::SetIMAPHierarchySeparator(PRUnichar hierarchySeparator)
{ {
m_IMAPHierarchySeparator = hierarchySeparator; m_IMAPHierarchySeparator = hierarchySeparator;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDBFolderInfo::GetImapTotalPendingMessages(PRInt32 *result) nsDBFolderInfo::GetImapTotalPendingMessages(PRInt32 *result)
{ {
if (!result) if (!result)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*result = m_totalPendingMessages; *result = m_totalPendingMessages;
return NS_OK; return NS_OK;
} }
void nsDBFolderInfo::ChangeImapTotalPendingMessages(PRInt32 delta) void nsDBFolderInfo::ChangeImapTotalPendingMessages(PRInt32 delta)
{ {
m_totalPendingMessages+=delta; m_totalPendingMessages+=delta;
SetInt32PropertyWithToken(m_totalPendingMessagesColumnToken, m_totalPendingMessages); SetInt32PropertyWithToken(m_totalPendingMessagesColumnToken, m_totalPendingMessages);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDBFolderInfo::GetImapUnreadPendingMessages(PRInt32 *result) nsDBFolderInfo::GetImapUnreadPendingMessages(PRInt32 *result)
{ {
if (!result) if (!result)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*result = m_unreadPendingMessages; *result = m_unreadPendingMessages;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDBFolderInfo::SetImapUnreadPendingMessages(PRInt32 numUnreadPendingMessages) NS_IMETHODIMP nsDBFolderInfo::SetImapUnreadPendingMessages(PRInt32 numUnreadPendingMessages)
{ {
m_unreadPendingMessages = numUnreadPendingMessages; m_unreadPendingMessages = numUnreadPendingMessages;
return SetUint32PropertyWithToken(m_unreadPendingMessagesColumnToken, m_unreadPendingMessages); return SetUint32PropertyWithToken(m_unreadPendingMessagesColumnToken, m_unreadPendingMessages);
} }
NS_IMETHODIMP nsDBFolderInfo::SetImapTotalPendingMessages(PRInt32 numTotalPendingMessages) NS_IMETHODIMP nsDBFolderInfo::SetImapTotalPendingMessages(PRInt32 numTotalPendingMessages)
{ {
m_totalPendingMessages = numTotalPendingMessages; m_totalPendingMessages = numTotalPendingMessages;
return SetUint32PropertyWithToken(m_totalPendingMessagesColumnToken, m_totalPendingMessages); return SetUint32PropertyWithToken(m_totalPendingMessagesColumnToken, m_totalPendingMessages);
} }
void nsDBFolderInfo::ChangeImapUnreadPendingMessages(PRInt32 delta) void nsDBFolderInfo::ChangeImapUnreadPendingMessages(PRInt32 delta)
{ {
m_unreadPendingMessages+=delta; m_unreadPendingMessages+=delta;
SetInt32PropertyWithToken(m_unreadPendingMessagesColumnToken, m_unreadPendingMessages); SetInt32PropertyWithToken(m_unreadPendingMessagesColumnToken, m_unreadPendingMessages);
} }
/* attribute nsMsgViewTypeValue viewType; */ /* attribute nsMsgViewTypeValue viewType; */
@ -879,26 +827,25 @@ NS_IMETHODIMP nsDBFolderInfo::GetKnownArtsSet(char **newsArtSet)
return m_mdb->GetProperty(m_mdbRow, kKnownArtsSetColumnName, newsArtSet); return m_mdb->GetProperty(m_mdbRow, kKnownArtsSetColumnName, newsArtSet);
} }
// get arbitrary property, aka row cell value. // get arbitrary property, aka row cell value.
NS_IMETHODIMP nsDBFolderInfo::GetProperty(const char *propertyName, nsString *resultProperty)
NS_IMETHODIMP nsDBFolderInfo::GetProperty(const char *propertyName, nsString *resultProperty)
{ {
return m_mdb->GetPropertyAsNSString(m_mdbRow, propertyName, resultProperty); return m_mdb->GetPropertyAsNSString(m_mdbRow, propertyName, resultProperty);
} }
NS_IMETHODIMP nsDBFolderInfo::SetCharPtrProperty(const char *aPropertyName, const char *aPropertyValue) NS_IMETHODIMP nsDBFolderInfo::SetCharPtrProperty(const char *aPropertyName, const char *aPropertyValue)
{ {
return m_mdb->SetProperty(m_mdbRow, aPropertyName, aPropertyValue); return m_mdb->SetProperty(m_mdbRow, aPropertyName, aPropertyValue);
} }
// Caller must PR_FREEIF resultProperty. // Caller must PR_Free resultProperty.
NS_IMETHODIMP nsDBFolderInfo::GetCharPtrProperty(const char *propertyName, char **resultProperty) NS_IMETHODIMP nsDBFolderInfo::GetCharPtrProperty(const char *propertyName, char **resultProperty)
{ {
return m_mdb->GetProperty(m_mdbRow, propertyName, resultProperty); return m_mdb->GetProperty(m_mdbRow, propertyName, resultProperty);
} }
NS_IMETHODIMP nsDBFolderInfo::SetUint32Property(const char *propertyName, PRUint32 propertyValue) NS_IMETHODIMP nsDBFolderInfo::SetUint32Property(const char *propertyName, PRUint32 propertyValue)
{ {
return m_mdb->SetUint32Property(m_mdbRow, propertyName, propertyValue); return m_mdb->SetUint32Property(m_mdbRow, propertyName, propertyValue);
} }
@ -913,33 +860,33 @@ nsresult nsDBFolderInfo::SetPropertyWithToken(mdb_token aProperty, nsString *pro
return m_mdb->SetNSStringPropertyWithToken(m_mdbRow, aProperty, propertyStr); return m_mdb->SetNSStringPropertyWithToken(m_mdbRow, aProperty, propertyStr);
} }
nsresult nsDBFolderInfo::SetUint32PropertyWithToken(mdb_token aProperty, PRUint32 propertyValue) nsresult nsDBFolderInfo::SetUint32PropertyWithToken(mdb_token aProperty, PRUint32 propertyValue)
{ {
return m_mdb->UInt32ToRowCellColumn(m_mdbRow, aProperty, propertyValue); return m_mdb->UInt32ToRowCellColumn(m_mdbRow, aProperty, propertyValue);
} }
nsresult nsDBFolderInfo::SetInt32PropertyWithToken(mdb_token aProperty, PRInt32 propertyValue) nsresult nsDBFolderInfo::SetInt32PropertyWithToken(mdb_token aProperty, PRInt32 propertyValue)
{ {
nsString propertyStr; nsString propertyStr;
propertyStr.AppendInt(propertyValue, 16); propertyStr.AppendInt(propertyValue, 16);
return SetPropertyWithToken(aProperty, &propertyStr); return SetPropertyWithToken(aProperty, &propertyStr);
} }
nsresult nsDBFolderInfo::GetPropertyWithToken(mdb_token aProperty, nsString *resultProperty) nsresult nsDBFolderInfo::GetPropertyWithToken(mdb_token aProperty, nsString *resultProperty)
{ {
if (!resultProperty) if (!resultProperty)
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
return m_mdb->RowCellColumnTonsString(m_mdbRow, aProperty, *resultProperty); return m_mdb->RowCellColumnTonsString(m_mdbRow, aProperty, *resultProperty);
} }
nsresult nsDBFolderInfo::GetUint32PropertyWithToken(mdb_token aProperty, PRUint32 &propertyValue, PRUint32 defaultValue) nsresult nsDBFolderInfo::GetUint32PropertyWithToken(mdb_token aProperty, PRUint32 &propertyValue, PRUint32 defaultValue)
{ {
return m_mdb->RowCellColumnToUInt32(m_mdbRow, aProperty, propertyValue, defaultValue); return m_mdb->RowCellColumnToUInt32(m_mdbRow, aProperty, propertyValue, defaultValue);
} }
nsresult nsDBFolderInfo::GetInt32PropertyWithToken(mdb_token aProperty, PRInt32 &propertyValue, PRInt32 defaultValue) nsresult nsDBFolderInfo::GetInt32PropertyWithToken(mdb_token aProperty, PRInt32 &propertyValue, PRInt32 defaultValue)
{ {
return m_mdb->RowCellColumnToUInt32(m_mdbRow, aProperty, (PRUint32 &) propertyValue, defaultValue); return m_mdb->RowCellColumnToUInt32(m_mdbRow, aProperty, (PRUint32 &) propertyValue, defaultValue);
} }
NS_IMETHODIMP nsDBFolderInfo::GetUint32Property(const char *propertyName, PRUint32 *propertyValue, PRUint32 defaultValue) NS_IMETHODIMP nsDBFolderInfo::GetUint32Property(const char *propertyName, PRUint32 *propertyValue, PRUint32 defaultValue)

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

@ -67,8 +67,6 @@ nsMailDatabase::~nsMailDatabase()
{ {
if(m_folderSpec) if(m_folderSpec)
delete m_folderSpec; delete m_folderSpec;
if (m_mdbAllOfflineOpsTable)
m_mdbAllOfflineOpsTable->Release();
} }
NS_IMETHODIMP nsMailDatabase::SetFolderStream(nsIOFileStream *aFileStream) NS_IMETHODIMP nsMailDatabase::SetFolderStream(nsIOFileStream *aFileStream)
@ -203,11 +201,7 @@ NS_IMETHODIMP nsMailDatabase::Open(nsIFileSpec *aFolderName, PRBool create, PRBo
NS_IMETHODIMP nsMailDatabase::ForceClosed() NS_IMETHODIMP nsMailDatabase::ForceClosed()
{ {
if (m_mdbAllOfflineOpsTable) m_mdbAllOfflineOpsTable = nsnull;
{
m_mdbAllOfflineOpsTable->Release();
m_mdbAllOfflineOpsTable = nsnull;
}
return nsMsgDatabase::ForceClosed(); return nsMsgDatabase::ForceClosed();
} }
@ -217,42 +211,11 @@ nsresult nsMailDatabase::GetAllOfflineOpsTable()
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (!m_mdbAllOfflineOpsTable) if (!m_mdbAllOfflineOpsTable)
{ rv = GetTableCreateIfMissing(kOfflineOpsScope, kOfflineOpsTableKind, getter_AddRefs(m_mdbAllOfflineOpsTable),
mdb_err err = GetStore()->StringToToken(GetEnv(), kOfflineOpsScope, &m_offlineOpsRowScopeToken); m_offlineOpsRowScopeToken, m_offlineOpsTableKindToken) ;
err = GetStore()->StringToToken(GetEnv(), kOfflineOpsTableKind, &m_offlineOpsTableKindToken);
gAllOfflineOpsTableOID.mOid_Scope = m_offlineOpsRowScopeToken;
gAllOfflineOpsTableOID.mOid_Id = 1;
rv = GetStore()->GetTable(GetEnv(), &gAllOfflineOpsTableOID, &m_mdbAllOfflineOpsTable);
if (rv != NS_OK)
rv = NS_ERROR_FAILURE;
// create new all msg hdrs table, if it doesn't exist.
if (NS_SUCCEEDED(rv) && !m_mdbAllOfflineOpsTable)
{
nsIMdbStore *store = GetStore();
mdb_err mdberr = (nsresult) store->NewTable(GetEnv(), m_offlineOpsRowScopeToken,
m_offlineOpsTableKindToken, PR_FALSE, nsnull, &m_mdbAllOfflineOpsTable);
if (mdberr != NS_OK || !m_mdbAllOfflineOpsTable)
rv = NS_ERROR_FAILURE;
}
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't create offline ops table");
}
return rv; return rv;
} }
/* static */ nsresult nsMailDatabase::CloneInvalidDBInfoIntoNewDB(nsFileSpec &pathName, nsMailDatabase** pMailDB)
{
nsresult ret = NS_OK;
return ret;
}
nsresult nsMailDatabase::OnNewPath (nsFileSpec &newPath)
{
nsresult ret = NS_OK;
return ret;
}
// cache m_folderStream to make updating mozilla status flags fast // cache m_folderStream to make updating mozilla status flags fast
NS_IMETHODIMP nsMailDatabase::StartBatch() NS_IMETHODIMP nsMailDatabase::StartBatch()
{ {
@ -624,22 +587,8 @@ NS_IMETHODIMP nsMailDatabase::RemoveOfflineOp(nsIMsgOfflineImapOperation *op)
return rv; return rv;
} }
nsresult SetSourceMailbox(nsOfflineImapOperation *op, const char *mailbox, nsMsgKey key)
{
nsresult ret = NS_OK;
return ret;
}
nsresult nsMailDatabase::GetIdsWithNoBodies (nsMsgKeyArray &bodylessIds)
{
nsresult ret = NS_OK;
return ret;
}
NS_IMETHODIMP nsMailDatabase::GetOfflineOpForKey(nsMsgKey msgKey, PRBool create, nsIMsgOfflineImapOperation **offlineOp) NS_IMETHODIMP nsMailDatabase::GetOfflineOpForKey(nsMsgKey msgKey, PRBool create, nsIMsgOfflineImapOperation **offlineOp)
{ {
PRBool newOp = PR_FALSE;
mdb_bool hasOid; mdb_bool hasOid;
mdbOid rowObjectId; mdbOid rowObjectId;
mdb_err err; mdb_err err;
@ -668,10 +617,7 @@ NS_IMETHODIMP nsMailDatabase::GetOfflineOpForKey(nsMsgKey msgKey, PRBool create,
NS_ENSURE_SUCCESS(err, err); NS_ENSURE_SUCCESS(err, err);
} }
if (offlineOpRow && !hasOid) if (offlineOpRow && !hasOid)
{
m_mdbAllOfflineOpsTable->AddRow(GetEnv(), offlineOpRow); m_mdbAllOfflineOpsTable->AddRow(GetEnv(), offlineOpRow);
newOp = PR_TRUE;
}
} }
if (err == NS_OK && offlineOpRow) if (err == NS_OK && offlineOpRow)
@ -854,7 +800,6 @@ nsresult nsMailDatabase::SetFolderInfoValid(nsFileSpec *folderName, int num, int
pMessageDB->m_dbFolderInfo->SetFolderSize(folderName->GetFileSize()); pMessageDB->m_dbFolderInfo->SetFolderSize(folderName->GetFileSize());
pMessageDB->m_dbFolderInfo->SetFolderDate(actualFolderTimeStamp); pMessageDB->m_dbFolderInfo->SetFolderDate(actualFolderTimeStamp);
pMessageDB->m_dbFolderInfo->ChangeNumVisibleMessages(num);
pMessageDB->m_dbFolderInfo->ChangeNumNewMessages(numunread); pMessageDB->m_dbFolderInfo->ChangeNumNewMessages(numunread);
pMessageDB->m_dbFolderInfo->ChangeNumMessages(num); pMessageDB->m_dbFolderInfo->ChangeNumMessages(num);
} }
@ -877,7 +822,7 @@ nsresult nsMailDatabase::SetFolderInfoValid(nsFileSpec *folderName, int num, int
// and needs to be regenerated. // and needs to be regenerated.
void nsMailDatabase::SetReparse(PRBool reparse) void nsMailDatabase::SetReparse(PRBool reparse)
{ {
m_reparse = reparse; m_reparse = reparse;
} }
@ -886,7 +831,7 @@ void nsMailDatabase::SetReparse(PRBool reparse)
PRBool nsMailDatabase::ThreadBySubjectWithoutRe() PRBool nsMailDatabase::ThreadBySubjectWithoutRe()
{ {
GetGlobalPrefs(); GetGlobalPrefs();
return gThreadWithoutRe; return gThreadWithoutRe;
} }
class nsMsgOfflineOpEnumerator : public nsISimpleEnumerator { class nsMsgOfflineOpEnumerator : public nsISimpleEnumerator {

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

@ -516,8 +516,8 @@ NS_IMETHODIMP nsMsgDatabase::NotifyKeyDeletedAll(nsMsgKey keyDeleted, nsMsgKey p
return NS_OK; return NS_OK;
PRUint32 count; PRUint32 count;
m_ChangeListeners->Count(&count); m_ChangeListeners->Count(&count);
for (PRUint32 i = 0; i < count; i++) for (PRUint32 i = 0; i < count; i++)
{ {
nsCOMPtr<nsIDBChangeListener> changeListener; nsCOMPtr<nsIDBChangeListener> changeListener;
m_ChangeListeners->QueryElementAt(i, NS_GET_IID(nsIDBChangeListener), (void **) getter_AddRefs(changeListener)); m_ChangeListeners->QueryElementAt(i, NS_GET_IID(nsIDBChangeListener), (void **) getter_AddRefs(changeListener));
nsresult rv = changeListener->OnKeyDeleted(keyDeleted, parentKey, flags, instigator); nsresult rv = changeListener->OnKeyDeleted(keyDeleted, parentKey, flags, instigator);
@ -607,11 +607,11 @@ nsVoidArray *nsMsgDatabase::m_dbCache = NULL;
nsVoidArray/*<nsMsgDatabase>*/* nsVoidArray/*<nsMsgDatabase>*/*
nsMsgDatabase::GetDBCache() nsMsgDatabase::GetDBCache()
{ {
if (!m_dbCache) if (!m_dbCache)
m_dbCache = new nsVoidArray(); m_dbCache = new nsVoidArray();
return m_dbCache; return m_dbCache;
} }
void void
@ -680,9 +680,7 @@ int nsMsgDatabase::FindInCache(nsMsgDatabase* pMessageDB)
for (PRInt32 i = 0; i < GetDBCache()->Count(); i++) for (PRInt32 i = 0; i < GetDBCache()->Count(); i++)
{ {
if (GetDBCache()->ElementAt(i) == pMessageDB) if (GetDBCache()->ElementAt(i) == pMessageDB)
{
return(i); return(i);
}
} }
return(-1); return(-1);
} }
@ -699,9 +697,7 @@ void nsMsgDatabase::RemoveFromCache(nsMsgDatabase* pMessageDB)
{ {
int i = FindInCache(pMessageDB); int i = FindInCache(pMessageDB);
if (i != -1) if (i != -1)
{
GetDBCache()->RemoveElementAt(i); GetDBCache()->RemoveElementAt(i);
}
} }
@ -774,6 +770,11 @@ nsMsgDatabase::~nsMsgDatabase()
DumpCache(); DumpCache();
} }
#endif #endif
// if the db folder info refers to the mdb db, we must clear it because
// the reference will be a dangling one soon.
if (m_dbFolderInfo)
m_dbFolderInfo->ReleaseExternalReferences();
NS_IF_RELEASE(m_dbFolderInfo); NS_IF_RELEASE(m_dbFolderInfo);
if (m_HeaderParser) if (m_HeaderParser)
{ {
@ -803,11 +804,13 @@ nsMsgDatabase::~nsMsgDatabase()
m_ChangeListeners = nsnull; m_ChangeListeners = nsnull;
} }
if (m_newSet) { if (m_newSet)
{
#ifdef DEBUG_MSGKEYSET #ifdef DEBUG_MSGKEYSET
char *str = nsnull; char *str = nsnull;
nsresult rv = m_newSet->Output(&str); nsresult rv = m_newSet->Output(&str);
if (NS_SUCCEEDED(rv) && str) { if (NS_SUCCEEDED(rv) && str)
{
printf("setStr = %s on destroy\n",str); printf("setStr = %s on destroy\n",str);
nsMemory::Free(str); nsMemory::Free(str);
str = nsnull; str = nsnull;
@ -1300,6 +1303,33 @@ nsresult nsMsgDatabase::InitNewDB()
return err; return err;
} }
nsresult nsMsgDatabase::GetTableCreateIfMissing(const char *scope, const char *kind, nsIMdbTable **table,
mdb_token &scopeToken, mdb_token &kindToken)
{
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;
}
nsresult nsMsgDatabase::InitExistingDB() nsresult nsMsgDatabase::InitExistingDB()
{ {
nsresult err = NS_OK; nsresult err = NS_OK;
@ -1485,14 +1515,14 @@ NS_IMETHODIMP nsMsgDatabase::EndBatch()
NS_IMETHODIMP nsMsgDatabase::DeleteMessage(nsMsgKey key, nsIDBChangeListener *instigator, PRBool commit) NS_IMETHODIMP nsMsgDatabase::DeleteMessage(nsMsgKey key, nsIDBChangeListener *instigator, PRBool commit)
{ {
nsCOMPtr <nsIMsgDBHdr> msgHdr; nsCOMPtr <nsIMsgDBHdr> msgHdr;
nsresult rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr)); nsresult rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr));
if (!msgHdr) if (!msgHdr)
return NS_MSG_MESSAGE_NOT_FOUND; return NS_MSG_MESSAGE_NOT_FOUND;
rv = DeleteHeader(msgHdr, instigator, commit, PR_TRUE); rv = DeleteHeader(msgHdr, instigator, commit, PR_TRUE);
return rv; return rv;
} }
@ -1548,7 +1578,6 @@ NS_IMETHODIMP nsMsgDatabase::DeleteHeader(nsIMsgDBHdr *msg, nsIDBChangeListener
{ {
PRBool isRead; PRBool isRead;
m_dbFolderInfo->ChangeNumMessages(-1); m_dbFolderInfo->ChangeNumMessages(-1);
m_dbFolderInfo->ChangeNumVisibleMessages(-1);
IsRead(key, &isRead); IsRead(key, &isRead);
if (!isRead) if (!isRead)
m_dbFolderInfo->ChangeNumNewMessages(-1); m_dbFolderInfo->ChangeNumNewMessages(-1);
@ -1920,14 +1949,11 @@ NS_IMETHODIMP nsMsgDatabase::SetLabel(nsMsgKey key, nsMsgLabelValue label)
rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr)); rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr));
if (NS_FAILED(rv) || !msgHdr) if (NS_FAILED(rv) || !msgHdr)
return NS_MSG_MESSAGE_NOT_FOUND; // XXX return rv? return NS_MSG_MESSAGE_NOT_FOUND;
msgHdr->SetLabel(label); msgHdr->SetLabel(label);
// set the flag in the x-mozilla-status2 line. // set the flag in the x-mozilla-status2 line.
return SetKeyFlag(key, PR_TRUE, label << 25, nsnull); return SetKeyFlag(key, PR_TRUE, label << 25, nsnull);
// ### dmb need to use persistent flags in x-mozilla-status2 for this.
// so that we don't lose the labels when we reparse the folder.
// return SetKeyFlag(key, offline, MSG_FLAG_OFFLINE, instigator);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -2221,15 +2247,6 @@ NS_IMETHODIMP nsMsgDatabase::MarkReadByDate (PRTime startDate, PRTime endDate, n
return rv; return rv;
} }
NS_IMETHODIMP nsMsgDatabase::MarkLater(nsMsgKey key, PRTime until)
{
PR_ASSERT(m_dbFolderInfo);
if (m_dbFolderInfo != NULL)
{
m_dbFolderInfo->AddLaterKey(key, until);
}
return NS_OK;
}
NS_IMETHODIMP nsMsgDatabase::AddToNewList(nsMsgKey key) NS_IMETHODIMP nsMsgDatabase::AddToNewList(nsMsgKey key)
{ {
@ -2293,13 +2310,10 @@ NS_IMETHODIMP nsMsgDatabase::HasNew(PRBool *_retval)
NS_IMETHODIMP nsMsgDatabase::GetFirstNew(nsMsgKey *result) NS_IMETHODIMP nsMsgDatabase::GetFirstNew(nsMsgKey *result)
{ {
// even though getLength is supposedly for debugging only, it's the only
// way I can tell if the set is empty (as opposed to having a member 0.
PRBool hasnew; PRBool hasnew;
nsresult rv = HasNew(&hasnew); nsresult rv = HasNew(&hasnew);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (hasnew) *result = (hasnew) ? m_newSet->GetFirstMember() : nsMsgKey_None;
*result = (hasnew) ? m_newSet->GetFirstMember() : nsMsgKey_None;
return NS_OK; return NS_OK;
} }
@ -2653,28 +2667,6 @@ nsMsgFlagSetFilter(nsIMsgDBHdr *msg, void *closure)
return (msgFlags & desiredFlags) ? NS_OK : NS_ERROR_FAILURE; return (msgFlags & desiredFlags) ? NS_OK : NS_ERROR_FAILURE;
} }
static nsresult
nsMsgUnreadFilter(nsIMsgDBHdr* msg, void* closure)
{
nsMsgDatabase* db = (nsMsgDatabase*)closure;
PRBool wasRead = PR_TRUE;
nsresult rv = db->IsHeaderRead(msg, &wasRead);
if (NS_FAILED(rv))
return rv;
return !wasRead ? NS_OK : NS_ERROR_FAILURE;
}
nsresult
nsMsgDatabase::EnumerateUnreadMessages(nsISimpleEnumerator* *result)
{
nsMsgDBEnumerator* e = new nsMsgDBEnumerator(this, nsMsgUnreadFilter, this);
if (e == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(e);
*result = e;
return NS_OK;
}
nsresult nsresult
nsMsgDatabase::EnumerateMessagesWithFlag(nsISimpleEnumerator* *result, PRUint32 *pFlag) nsMsgDatabase::EnumerateMessagesWithFlag(nsISimpleEnumerator* *result, PRUint32 *pFlag)
{ {
@ -2697,19 +2689,6 @@ nsMsgReadFilter(nsIMsgDBHdr* msg, void* closure)
return wasRead ? NS_OK : NS_ERROR_FAILURE; return wasRead ? NS_OK : NS_ERROR_FAILURE;
} }
// note that we can't just use EnumerateMessagesWithFlag(MSG_FLAG_READ) because we need
// to call IsHeaderRead.
nsresult
nsMsgDatabase::EnumerateReadMessages(nsISimpleEnumerator* *result)
{
nsMsgDBEnumerator* e = new nsMsgDBEnumerator(this, nsMsgReadFilter, this);
if (e == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(e);
*result = e;
return NS_OK;
}
NS_IMETHODIMP nsMsgDatabase::CreateNewHdr(nsMsgKey key, nsIMsgDBHdr **pnewHdr) NS_IMETHODIMP nsMsgDatabase::CreateNewHdr(nsMsgKey key, nsIMsgDBHdr **pnewHdr)
{ {
nsresult err = NS_OK; nsresult err = NS_OK;
@ -2761,7 +2740,6 @@ NS_IMETHODIMP nsMsgDatabase::AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify)
if (m_dbFolderInfo != NULL) if (m_dbFolderInfo != NULL)
{ {
m_dbFolderInfo->ChangeNumMessages(1); m_dbFolderInfo->ChangeNumMessages(1);
m_dbFolderInfo->ChangeNumVisibleMessages(1);
PRBool isRead = PR_TRUE; PRBool isRead = PR_TRUE;
IsHeaderRead(newHdr, &isRead); IsHeaderRead(newHdr, &isRead);
if (!isRead) if (!isRead)
@ -3741,6 +3719,12 @@ nsresult nsMsgDatabase::ListAllThreads(nsMsgKeyArray *threadIds)
return rv; return rv;
} }
NS_IMETHODIMP nsMsgDatabase::SetAttributesOnPendingHdr(nsIMsgDBHdr *pendingHdr, const char *property,
const char *propertyVal, PRInt32 flags)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgDatabase::GetOfflineOpForKey(nsMsgKey msgKey, PRBool create, nsIMsgOfflineImapOperation **offlineOp) NS_IMETHODIMP nsMsgDatabase::GetOfflineOpForKey(nsMsgKey msgKey, PRBool create, nsIMsgOfflineImapOperation **offlineOp)
{ {
NS_ASSERTION(PR_FALSE, "overridden by nsMailDatabase"); NS_ASSERTION(PR_FALSE, "overridden by nsMailDatabase");

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

@ -240,7 +240,7 @@ nsresult nsMsgThread::RerootThread(nsIMsgDBHdr *newParentOfOldRoot, nsIMsgDBHdr
} }
NS_IMETHODIMP nsMsgThread::AddChild(nsIMsgDBHdr *child, nsIMsgDBHdr *inReplyTo, PRBool threadInThread, NS_IMETHODIMP nsMsgThread::AddChild(nsIMsgDBHdr *child, nsIMsgDBHdr *inReplyTo, PRBool threadInThread,
nsIDBChangeAnnouncer *announcer) nsIDBChangeAnnouncer *announcer)
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;
nsMsgHdr* hdr = NS_STATIC_CAST(nsMsgHdr*, child); // closed system, cast ok nsMsgHdr* hdr = NS_STATIC_CAST(nsMsgHdr*, child); // closed system, cast ok
@ -865,19 +865,6 @@ nsMsgThreadUnreadFilter(nsIMsgDBHdr* msg, void* closure)
return !wasRead ? NS_OK : NS_ERROR_FAILURE; return !wasRead ? NS_OK : NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsMsgThread::EnumerateUnreadMessages(nsMsgKey parentKey, nsISimpleEnumerator* *result)
{
nsresult ret = NS_OK;
nsMsgThreadEnumerator* e = new nsMsgThreadEnumerator(this, parentKey, nsMsgThreadUnreadFilter, m_mdbDB);
if (e == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(e);
*result = e;
return NS_OK;
return ret;
}
NS_IMETHODIMP nsMsgThread::EnumerateMessages(nsMsgKey parentKey, nsISimpleEnumerator* *result) NS_IMETHODIMP nsMsgThread::EnumerateMessages(nsMsgKey parentKey, nsISimpleEnumerator* *result)
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;