work on offline disk space mgmt sr=ssptizer for mscott 17217

This commit is contained in:
bienvenu%netscape.com 2001-01-01 22:00:17 +00:00
Родитель c362958cf3
Коммит 8ca4a0377b
13 изменённых файлов: 299 добавлений и 157 удалений

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

@ -350,4 +350,6 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
void enableNotifications(in long notificationType, in boolean enable); void enableNotifications(in long notificationType, in boolean enable);
attribute nsIMsgRetentionSettings retentionSettings;
}; };

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

@ -27,6 +27,7 @@ interface nsIFolder;
interface nsIMsgFolderCache; interface nsIMsgFolderCache;
interface nsIMsgWindow; interface nsIMsgWindow;
interface nsIMsgFilterList; interface nsIMsgFilterList;
interface nsIMsgRetentionSettings;
/* /*
* Interface for incoming mail/news host * Interface for incoming mail/news host
@ -190,6 +191,8 @@ interface nsIMsgIncomingServer : nsISupports {
attribute boolean canDelete; attribute boolean canDelete;
attribute boolean loginAtStartUp; attribute boolean loginAtStartUp;
attribute nsIMsgRetentionSettings retentionSettings;
}; };
%{C++ %{C++

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

@ -1206,6 +1206,43 @@ nsMsgDBFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsMsgDBFolder::GetRetentionSettings(nsIMsgRetentionSettings **settings)
{
NS_ENSURE_ARG_POINTER(settings);
nsresult rv = NS_OK;
if (!m_retentionSettings)
{
GetDatabase(nsnull);
if (mDatabase)
{
// get the settings from the db - if the settings from the db say the folder
// is not overriding the incoming server settings, get the settings from the
// server.
rv = mDatabase->GetMsgRetentionSettings(getter_AddRefs(m_retentionSettings));
if (NS_SUCCEEDED(rv) && m_retentionSettings)
{
nsMsgRetainByPreference retainBy;
m_retentionSettings->GetRetainByPreference(&retainBy);
if (retainBy == nsIMsgRetentionSettings::nsMsgRetainByServerDefaults)
{
nsCOMPtr <nsIMsgIncomingServer> incomingServer;
rv = GetServer(getter_AddRefs(incomingServer));
if (NS_SUCCEEDED(rv) && incomingServer)
incomingServer->GetRetentionSettings(getter_AddRefs(m_retentionSettings));
}
}
}
}
*settings = m_retentionSettings;
return rv;
}
NS_IMETHODIMP nsMsgDBFolder::SetRetentionSettings(nsIMsgRetentionSettings *settings)
{
m_retentionSettings = settings;
return NS_OK;
}
nsresult nsMsgDBFolder::NotifyStoreClosedAllHeaders() nsresult nsMsgDBFolder::NotifyStoreClosedAllHeaders()
{ {

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

@ -92,6 +92,8 @@ public:
NS_IMETHOD GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChannel **aFileChannel); NS_IMETHOD GetOfflineFileChannel(nsMsgKey msgKey, nsIFileChannel **aFileChannel);
NS_IMETHOD HasMsgOffline(nsMsgKey msgKey, PRBool *result); NS_IMETHOD HasMsgOffline(nsMsgKey msgKey, PRBool *result);
NS_IMETHOD DownloadMessagesForOffline(nsISupportsArray *messages); NS_IMETHOD DownloadMessagesForOffline(nsISupportsArray *messages);
NS_IMETHOD GetRetentionSettings(nsIMsgRetentionSettings **settings);
NS_IMETHOD SetRetentionSettings(nsIMsgRetentionSettings *settings);
protected: protected:
virtual nsresult ReadDBFolderInfo(PRBool force); virtual nsresult ReadDBFolderInfo(PRBool force);
@ -126,6 +128,7 @@ protected:
// this is currently used when we do a save as of an imap or news message.. // this is currently used when we do a save as of an imap or news message..
nsCOMPtr<nsIOutputStream> m_tempMessageStream; nsCOMPtr<nsIOutputStream> m_tempMessageStream;
nsCOMPtr <nsIMsgRetentionSettings> m_retentionSettings;
static nsIAtom* mFolderLoadedAtom; static nsIAtom* mFolderLoadedAtom;
static nsIAtom* mDeleteOrMoveMsgCompletedAtom; static nsIAtom* mDeleteOrMoveMsgCompletedAtom;
static nsIAtom* mDeleteOrMoveMsgFailedAtom; static nsIAtom* mDeleteOrMoveMsgFailedAtom;

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

@ -33,6 +33,7 @@
#include "nsXPIDLString.h" #include "nsXPIDLString.h"
#include "nsMsgBaseCID.h" #include "nsMsgBaseCID.h"
#include "nsMsgDBCID.h"
#include "nsIMsgFolder.h" #include "nsIMsgFolder.h"
#include "nsIMsgFolderCache.h" #include "nsIMsgFolderCache.h"
#include "nsIMsgFolderCacheElement.h" #include "nsIMsgFolderCacheElement.h"
@ -1053,6 +1054,27 @@ nsMsgIncomingServer::getProtocolInfo(nsIMsgProtocolInfo **aResult)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsMsgIncomingServer::GetRetentionSettings(nsIMsgRetentionSettings **settings)
{
NS_ENSURE_ARG_POINTER(settings);
if (!m_retentionSettings)
{
m_retentionSettings = do_CreateInstance(NS_MSG_RETENTIONSETTINGS_CONTRACTID);
// Create an empty retention settings object,
// get the settings from the server prefs, and init the object from the prefs.
}
*settings = m_retentionSettings;
return NS_OK;
}
NS_IMETHODIMP nsMsgIncomingServer::SetRetentionSettings(nsIMsgRetentionSettings *settings)
{
m_retentionSettings = settings;
return NS_OK;
}
// use the convenience macros to implement the accessors // use the convenience macros to implement the accessors
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, Username, "userName"); NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, Username, "userName");
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, PrefPassword, "password"); NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, PrefPassword, "password");

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

@ -30,6 +30,7 @@
#include "nsIFolder.h" #include "nsIFolder.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsIMsgDatabase.h"
class nsIMsgFolderCache; class nsIMsgFolderCache;
class nsIMsgProtocolInfo; class nsIMsgProtocolInfo;
@ -68,6 +69,7 @@ protected:
NS_IMETHOD SetPrefPassword(const char * aPassword); NS_IMETHOD SetPrefPassword(const char * aPassword);
nsCOMPtr <nsIFolder> m_rootFolder; nsCOMPtr <nsIFolder> m_rootFolder;
nsCOMPtr <nsIMsgRetentionSettings> m_retentionSettings;
nsresult getDefaultCharPref(const char *pref, char **); nsresult getDefaultCharPref(const char *pref, char **);
nsresult getDefaultUnicharPref(const char *pref, PRUnichar **); nsresult getDefaultUnicharPref(const char *pref, PRUnichar **);
nsresult getDefaultBoolPref(const char *pref, PRBool *); nsresult getDefaultBoolPref(const char *pref, PRBool *);

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

@ -42,4 +42,10 @@
{ 0x9e4b07ee, 0xe980, 0x11d2, \ { 0x9e4b07ee, 0xe980, 0x11d2, \
{ 0xa5, 0x06, 0x00, 0x60, 0xb0, 0xfc, 0x04, 0xb7 } } { 0xa5, 0x06, 0x00, 0x60, 0xb0, 0xfc, 0x04, 0xb7 } }
#define NS_MSG_RETENTIONSETTINGS_CID \
{ 0x1bd976d6, 0xdf44, 0x11d4, \
{0xa5, 0xb6, 0x00, 0x60, 0xb0, 0xfc, 0x04, 0xb7} }
#define NS_MSG_RETENTIONSETTINGS_CONTRACTID \
"@mozilla.org/msgDatabase/retentionSettings;1"
#endif #endif

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

@ -36,10 +36,12 @@ static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID); static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID); static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
static NS_DEFINE_CID(kCImapDB, NS_IMAPDB_CID); static NS_DEFINE_CID(kCImapDB, NS_IMAPDB_CID);
static NS_DEFINE_CID(kCMsgRetentionSettings, NS_MSG_RETENTIONSETTINGS_CID);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMailDatabase) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMailDatabase)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNewsDatabase) NS_GENERIC_FACTORY_CONSTRUCTOR(nsNewsDatabase)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImapMailDatabase) NS_GENERIC_FACTORY_CONSTRUCTOR(nsImapMailDatabase)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgRetentionSettings)
// Module implementation for the msg db library // Module implementation for the msg db library
class nsMsgDBModule : public nsIModule class nsMsgDBModule : public nsIModule
@ -61,6 +63,7 @@ protected:
nsCOMPtr<nsIGenericFactory> mMailDBFactory; nsCOMPtr<nsIGenericFactory> mMailDBFactory;
nsCOMPtr<nsIGenericFactory> mNewsDBFactory; nsCOMPtr<nsIGenericFactory> mNewsDBFactory;
nsCOMPtr<nsIGenericFactory> mImapDBFactory; nsCOMPtr<nsIGenericFactory> mImapDBFactory;
nsCOMPtr<nsIGenericFactory> mMsgRetentionSettingsFactory;
}; };
@ -95,6 +98,7 @@ void nsMsgDBModule::Shutdown()
mMailDBFactory = null_nsCOMPtr(); mMailDBFactory = null_nsCOMPtr();
mNewsDBFactory = null_nsCOMPtr(); mNewsDBFactory = null_nsCOMPtr();
mImapDBFactory = null_nsCOMPtr(); mImapDBFactory = null_nsCOMPtr();
mMsgRetentionSettingsFactory = null_nsCOMPtr();
} }
// Create a factory object for creating instances of aClass. // Create a factory object for creating instances of aClass.
@ -141,6 +145,12 @@ NS_IMETHODIMP nsMsgDBModule::GetClassObject(nsIComponentManager *aCompMgr,
rv = NS_NewGenericFactory(getter_AddRefs(mImapDBFactory), &nsImapMailDatabaseConstructor); rv = NS_NewGenericFactory(getter_AddRefs(mImapDBFactory), &nsImapMailDatabaseConstructor);
fact = mImapDBFactory; fact = mImapDBFactory;
} }
else if (aClass.Equals(kCMsgRetentionSettings))
{
if (!mMsgRetentionSettingsFactory)
rv = NS_NewGenericFactory(getter_AddRefs(mMsgRetentionSettingsFactory), &nsMsgRetentionSettingsConstructor);
fact = mMsgRetentionSettingsFactory;
}
if (fact) if (fact)
rv = fact->QueryInterface(aIID, r_classObj); rv = fact->QueryInterface(aIID, r_classObj);
@ -162,8 +172,10 @@ static Components gComponents[] = {
nsnull }, nsnull },
{ "Imap DB", &kCImapDB, { "Imap DB", &kCImapDB,
nsnull }, nsnull },
{ "Msg Retention Settings", &kCMsgRetentionSettings,
NS_MSG_RETENTIONSETTINGS_CONTRACTID}
}; };
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0])) #define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]))
NS_IMETHODIMP nsMsgDBModule::RegisterSelf(nsIComponentManager *aCompMgr, NS_IMETHODIMP nsMsgDBModule::RegisterSelf(nsIComponentManager *aCompMgr,

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

@ -35,6 +35,30 @@ interface nsISimpleEnumerator;
interface nsIMsgThread; interface nsIMsgThread;
interface nsIDBFolderInfo; interface nsIDBFolderInfo;
typedef unsigned long nsMsgRetainByPreference;
[scriptable, uuid(063bd2ac-de85-11d4-a5b6-0060b0fc04b7)]
interface nsIMsgRetentionSettings : nsISupports
{
const unsigned long nsMsgRetainAll = 0;
const unsigned long nsMsgRetainByServerDefaults = 1;
const unsigned long nsMsgRetainByAge = 2;
const unsigned long nsMsgRetainByNumHeaders = 3;
attribute nsMsgRetainByPreference retainByPreference;
attribute unsigned long daysToKeepHdrs;
attribute unsigned long numHeadersToKeep;
// this is orthogonal to retaining by age or num headers, i.e., if
// it's set, we'll only keep NNN unread messages only, or unread
// messages less than NNN days old.
attribute boolean keepUnreadMessagesOnly;
// this is for keeping offline bodies.
attribute unsigned long daysToKeepBodies;
};
typedef long nsMsgDBCommit; typedef long nsMsgDBCommit;
[scriptable, uuid(aa4d45d0-3956-11d3-8d76-00805f8a6617)] [scriptable, uuid(aa4d45d0-3956-11d3-8d76-00805f8a6617)]
@ -164,6 +188,9 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
in nsIDBChangeListener instigator); in nsIDBChangeListener instigator);
readonly attribute nsMsgKey FirstNew; readonly attribute nsMsgKey FirstNew;
attribute nsIMsgRetentionSettings msgRetentionSettings;
boolean HasNew(); boolean HasNew();
void ClearNewList(in boolean notify); void ClearNewList(in boolean notify);
void AddToNewList(in nsMsgKey key); void AddToNewList(in nsMsgKey key);

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

@ -50,162 +50,25 @@ class nsMsgDatabase : public nsIMsgDatabase
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIDBCHANGEANNOUNCER
////////////////////////////////////////////////////////////////////////////// NS_DECL_NSIMSGDATABASE
// nsIDBChangeAnnouncer methods: virtual nsresult IsHeaderRead(nsIMsgDBHdr *hdr, PRBool *pRead);
NS_IMETHOD AddListener(nsIDBChangeListener *listener); virtual nsresult MarkHdrReadInDB(nsIMsgDBHdr *msgHdr, PRBool bRead,
NS_IMETHOD RemoveListener(nsIDBChangeListener *listener);
NS_IMETHOD NotifyKeyChangeAll(nsMsgKey keyChanged, PRUint32 aOldFlags, PRUint32 aNewFlags,
nsIDBChangeListener *instigator);
NS_IMETHOD NotifyKeyAddedAll(nsMsgKey keyAdded, nsMsgKey parentKey, PRInt32 flags,
nsIDBChangeListener *instigator); nsIDBChangeListener *instigator);
NS_IMETHOD NotifyKeyDeletedAll(nsMsgKey keyDeleted, nsMsgKey parentKey, PRInt32 flags, virtual nsresult OpenMDB(const char *dbName, PRBool create);
nsIDBChangeListener *instigator); virtual nsresult CloseMDB(PRBool commit);
NS_IMETHOD NotifyParentChangedAll(nsMsgKey keyReparented, nsMsgKey oldParent, nsMsgKey newParent, virtual nsresult CreateMsgHdr(nsIMdbRow* hdrRow, nsMsgKey key, nsIMsgDBHdr **result);
nsIDBChangeListener *instigator); virtual nsresult GetThreadForMsgKey(nsMsgKey msgKey, nsIMsgThread **result);
virtual nsresult EnumerateUnreadMessages(nsISimpleEnumerator* *result);
NS_IMETHOD NotifyReadChanged(nsIDBChangeListener *instigator);
NS_IMETHOD NotifyAnnouncerGoingAway(void);
//////////////////////////////////////////////////////////////////////////////
// nsIMsgDatabase methods:
NS_IMETHOD Open(nsIFileSpec *folderName, PRBool create, PRBool upgrading, nsIMsgDatabase** pMessageDB);
NS_IMETHOD Close(PRBool forceCommit);
// argh, these two shouldn't be Interface methods, but I can't diddle the interfaces
// until the idl works on windows. grumble grumble.
NS_IMETHOD OpenMDB(const char *dbName, PRBool create);
NS_IMETHOD CloseMDB(PRBool commit);
NS_IMETHOD Commit(nsMsgDBCommit commitType);
// Force closed is evil, and we should see if we can do without it.
// In 4.x, it was mainly used to remove corrupted databases.
NS_IMETHOD ForceClosed(void);
// get a message header for the given key. Caller must release()!
NS_IMETHOD GetMsgHdrForKey(nsMsgKey key, nsIMsgDBHdr **msg);
//Returns whether or not this database contains the given key
NS_IMETHOD ContainsKey(nsMsgKey key, PRBool *containsKey);
// Must call AddNewHdrToDB after creating. The idea is that you create
// a new header, fill in its properties, and then call AddNewHdrToDB.
// AddNewHdrToDB will send notifications to any listeners.
NS_IMETHOD CreateNewHdr(nsMsgKey key, nsIMsgDBHdr **newHdr);
virtual nsresult CreateMsgHdr(nsIMdbRow* hdrRow, nsMsgKey key, nsIMsgDBHdr **result);
NS_IMETHOD CopyHdrFromExistingHdr(nsMsgKey key, nsIMsgDBHdr *existingHdr, nsIMsgDBHdr **newHdr);
NS_IMETHOD AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify);
NS_IMETHOD ListAllKeys(nsMsgKeyArray &outputKeys);
NS_IMETHOD EnumerateMessages(nsISimpleEnumerator* *result);
NS_IMETHOD EnumerateUnreadMessages(nsISimpleEnumerator* *result);
NS_IMETHOD EnumerateThreads(nsISimpleEnumerator* *result);
// 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);
// helpers for user command functions like delete, mark read, etc.
NS_IMETHOD MarkHdrRead(nsIMsgDBHdr *msgHdr, PRBool bRead,
nsIDBChangeListener *instigator);
NS_IMETHOD MarkHdrReplied(nsIMsgDBHdr *msgHdr, PRBool bReplied,
nsIDBChangeListener *instigator);
NS_IMETHOD MarkHdrMarked(nsIMsgDBHdr *msgHdr, PRBool mark,
nsIDBChangeListener *instigator);
// MDN support
NS_IMETHOD MarkMDNNeeded(nsMsgKey key, PRBool bNeeded,
nsIDBChangeListener *instigator);
// MarkMDNneeded only used when mail server is a POP3 server
// or when the IMAP server does not support user defined
// PERMANENTFLAGS
NS_IMETHOD IsMDNNeeded(nsMsgKey key, PRBool *isNeeded);
NS_IMETHOD MarkMDNSent(nsMsgKey key, PRBool bNeeded,
nsIDBChangeListener *instigator);
NS_IMETHOD IsMDNSent(nsMsgKey key, PRBool *isSent);
// methods to get and set docsets for ids.
NS_IMETHOD MarkRead(nsMsgKey key, PRBool bRead,
nsIDBChangeListener *instigator);
NS_IMETHOD MarkReplied(nsMsgKey key, PRBool bReplied,
nsIDBChangeListener *instigator);
NS_IMETHOD MarkForwarded(nsMsgKey key, PRBool bForwarded,
nsIDBChangeListener *instigator);
NS_IMETHOD MarkHasAttachments(nsMsgKey key, PRBool bHasAttachments,
nsIDBChangeListener *instigator);
NS_IMETHOD MarkThreadRead(nsIMsgThread *thread, nsIDBChangeListener *instigator, nsMsgKeyArray *thoseMarked);
NS_IMETHOD MarkThreadIgnored(nsIMsgThread *thread, nsMsgKey threadKey, PRBool bIgnored,
nsIDBChangeListener *instigator);
NS_IMETHOD MarkThreadWatched(nsIMsgThread *thread, nsMsgKey threadKey, PRBool bWatched,
nsIDBChangeListener *instigator);
NS_IMETHOD IsRead(nsMsgKey key, PRBool *pRead);
NS_IMETHOD IsIgnored(nsMsgKey key, PRBool *pIgnored);
NS_IMETHOD IsMarked(nsMsgKey key, PRBool *pMarked);
NS_IMETHOD HasAttachments(nsMsgKey key, PRBool *pHasThem);
NS_IMETHOD MarkAllRead(nsMsgKeyArray *thoseMarked);
NS_IMETHOD MarkReadByDate (PRTime te, PRTime endDate, nsMsgKeyArray *markedIds);
NS_IMETHOD DeleteMessages(nsMsgKeyArray* nsMsgKeys, nsIDBChangeListener *instigator);
NS_IMETHOD DeleteMessage(nsMsgKey key,
nsIDBChangeListener *instigator,
PRBool commit);
NS_IMETHOD DeleteHeader(nsIMsgDBHdr *msgHdr, nsIDBChangeListener *instigator,
PRBool commit, PRBool notify);
NS_IMETHOD RemoveHeaderMdbRow(nsIMsgDBHdr *msgHdr);
NS_IMETHOD UndoDelete(nsIMsgDBHdr *msgHdr);
NS_IMETHOD MarkLater(nsMsgKey key, PRTime until);
NS_IMETHOD MarkMarked(nsMsgKey key, PRBool mark,
nsIDBChangeListener *instigator);
NS_IMETHOD MarkOffline(nsMsgKey key, PRBool offline,
nsIDBChangeListener *instigator);
NS_IMETHOD AllMsgKeysImapDeleted(nsMsgKeyArray *keys, PRBool *allKeysDeleted);
NS_IMETHOD MarkImapDeleted(nsMsgKey key, PRBool deleted,
nsIDBChangeListener *instigator);
NS_IMETHOD GetFirstNew(nsMsgKey *result);
NS_IMETHOD HasNew(PRBool *_retval);
NS_IMETHOD ClearNewList(PRBool notify);
NS_IMETHOD AddToNewList(nsMsgKey key);
// used mainly to force the timestamp of a local mail folder db to
// match the time stamp of the corresponding berkeley mail folder,
// but also useful to tell the summary to mark itself invalid
NS_IMETHOD SetSummaryValid(PRBool valid);
// offline operations
NS_IMETHOD ListAllOfflineOpIds(nsMsgKeyArray *offlineOpIds);
NS_IMETHOD ListAllOfflineDeletes(nsMsgKeyArray *offlineDeletes);
NS_IMETHOD GetThreadForMsgKey(nsMsgKey msgKey, nsIMsgThread **result);
NS_IMETHOD GetThreadContainingMsgHdr(nsIMsgDBHdr *msgHdr, nsIMsgThread **result) ;
NS_IMETHOD GetHighWaterArticleNum(nsMsgKey *key);
NS_IMETHOD GetLowWaterArticleNum(nsMsgKey *key);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// nsMsgDatabase methods: // nsMsgDatabase methods:
nsMsgDatabase(); nsMsgDatabase();
virtual ~nsMsgDatabase(); virtual ~nsMsgDatabase();
NS_IMETHOD IsHeaderRead(nsIMsgDBHdr *hdr, PRBool *pRead);
static nsIMdbFactory *GetMDBFactory(); static nsIMdbFactory *GetMDBFactory();
NS_IMETHOD GetDBFolderInfo(nsIDBFolderInfo **result);
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();
@ -293,8 +156,6 @@ protected:
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
NS_IMETHOD MarkHdrReadInDB(nsIMsgDBHdr *msgHdr, PRBool bRead,
nsIDBChangeListener *instigator);
virtual nsresult RemoveHeaderFromDB(nsMsgHdr *msgHdr); virtual nsresult RemoveHeaderFromDB(nsMsgHdr *msgHdr);
virtual nsresult RemoveHeaderFromThread(nsMsgHdr *msgHdr); virtual nsresult RemoveHeaderFromThread(nsMsgHdr *msgHdr);
@ -305,6 +166,8 @@ protected:
nsCOMPtr <nsICollation> m_collationKeyGenerator; nsCOMPtr <nsICollation> m_collationKeyGenerator;
nsCOMPtr <nsIMimeConverter> m_mimeConverter; nsCOMPtr <nsIMimeConverter> m_mimeConverter;
nsCOMPtr <nsIMsgRetentionSettings> m_retentionSettings;
// mdb bookkeeping stuff // mdb bookkeeping stuff
nsresult InitExistingDB(); nsresult InitExistingDB();
nsresult InitNewDB(); nsresult InitNewDB();
@ -381,4 +244,21 @@ protected:
}; };
class nsMsgRetentionSettings : public nsIMsgRetentionSettings
{
public:
nsMsgRetentionSettings();
virtual ~nsMsgRetentionSettings();
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGRETENTIONSETTINGS
protected:
nsMsgRetainByPreference m_retainByPreference;
PRUint32 m_daysToKeepHdrs;
PRUint32 m_numHeadersToKeep;
PRUint32 m_keepUnreadMessagesProp;
PRBool m_keepUnreadMessagesOnly;
PRUint32 m_daysToKeepBodies;
};
#endif #endif

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

@ -50,7 +50,7 @@ public:
// methods to get and set docsets for ids. // methods to get and set docsets for ids.
NS_IMETHOD IsRead(nsMsgKey key, PRBool *pRead); NS_IMETHOD IsRead(nsMsgKey key, PRBool *pRead);
NS_IMETHOD IsHeaderRead(nsIMsgDBHdr *msgHdr, PRBool *pRead); virtual nsresult IsHeaderRead(nsIMsgDBHdr *msgHdr, PRBool *pRead);
virtual PRBool IsArticleOffline(nsMsgKey key); virtual PRBool IsArticleOffline(nsMsgKey key);
virtual nsresult AddHdrFromXOver(const char * line, nsMsgKey *msgId); virtual nsresult AddHdrFromXOver(const char * line, nsMsgKey *msgId);

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

@ -812,7 +812,7 @@ NS_IMETHODIMP nsMsgDatabase::Open(nsIFileSpec *folderName, PRBool create, PRBool
// Open the MDB database synchronously. If successful, this routine // Open the MDB database synchronously. If successful, this routine
// will set up the m_mdbStore and m_mdbEnv of the database object // will set up the m_mdbStore and m_mdbEnv of the database object
// so other database calls can work. // so other database calls can work.
NS_IMETHODIMP nsMsgDatabase::OpenMDB(const char *dbName, PRBool create) nsresult nsMsgDatabase::OpenMDB(const char *dbName, PRBool create)
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;
nsIMdbFactory *myMDBFactory = GetMDBFactory(); nsIMdbFactory *myMDBFactory = GetMDBFactory();
@ -928,7 +928,7 @@ NS_IMETHODIMP nsMsgDatabase::OpenMDB(const char *dbName, PRBool create)
return ret; return ret;
} }
NS_IMETHODIMP nsMsgDatabase::CloseMDB(PRBool commit) nsresult nsMsgDatabase::CloseMDB(PRBool commit)
{ {
if (commit) if (commit)
Commit(nsMsgDBCommitType::kSessionCommit); Commit(nsMsgDBCommitType::kSessionCommit);
@ -1467,7 +1467,7 @@ PRUint32 nsMsgDatabase::GetStatusFlags(nsIMsgDBHdr *msgHdr, PRUint32 origFlags)
return statusFlags; return statusFlags;
} }
NS_IMETHODIMP nsMsgDatabase::IsHeaderRead(nsIMsgDBHdr *msgHdr, PRBool *pRead) nsresult nsMsgDatabase::IsHeaderRead(nsIMsgDBHdr *msgHdr, PRBool *pRead)
{ {
if (!msgHdr) if (!msgHdr)
return NS_MSG_MESSAGE_NOT_FOUND; return NS_MSG_MESSAGE_NOT_FOUND;
@ -1541,7 +1541,7 @@ PRBool nsMsgDatabase::SetHdrReadFlag(nsIMsgDBHdr *msgHdr, PRBool bRead)
return SetHdrFlag(msgHdr, bRead, MSG_FLAG_READ); return SetHdrFlag(msgHdr, bRead, MSG_FLAG_READ);
} }
NS_IMETHODIMP nsMsgDatabase::MarkHdrReadInDB(nsIMsgDBHdr *msgHdr, PRBool bRead, nsresult nsMsgDatabase::MarkHdrReadInDB(nsIMsgDBHdr *msgHdr, PRBool bRead,
nsIDBChangeListener *instigator) nsIDBChangeListener *instigator)
{ {
nsresult rv; nsresult rv;
@ -2453,7 +2453,7 @@ nsMsgUnreadFilter(nsIMsgDBHdr* msg, void* closure)
return !wasRead ? NS_OK : NS_COMFALSE; return !wasRead ? NS_OK : NS_COMFALSE;
} }
NS_IMETHODIMP nsresult
nsMsgDatabase::EnumerateUnreadMessages(nsISimpleEnumerator* *result) nsMsgDatabase::EnumerateUnreadMessages(nsISimpleEnumerator* *result)
{ {
nsMsgDBEnumerator* e = new nsMsgDBEnumerator(this, nsMsgUnreadFilter, this); nsMsgDBEnumerator* e = new nsMsgDBEnumerator(this, nsMsgUnreadFilter, this);
@ -3137,7 +3137,7 @@ NS_IMETHODIMP nsMsgDatabase::GetThreadContainingMsgHdr(nsIMsgDBHdr *msgHdr, nsIM
} }
NS_IMETHODIMP nsMsgDatabase::GetThreadForMsgKey(nsMsgKey msgKey, nsIMsgThread **result) nsresult nsMsgDatabase::GetThreadForMsgKey(nsMsgKey msgKey, nsIMsgThread **result)
{ {
nsresult ret = NS_OK; nsresult ret = NS_OK;
if (!result) if (!result)
@ -3372,4 +3372,152 @@ nsresult nsMsgDatabase::DumpThread(nsMsgKey threadId)
} }
#endif /* DEBUG */ #endif /* DEBUG */
NS_IMETHODIMP nsMsgDatabase::SetMsgRetentionSettings(nsIMsgRetentionSettings *retentionSettings)
{
m_retentionSettings = retentionSettings;
if (retentionSettings && m_dbFolderInfo)
{
nsresult rv;
nsMsgRetainByPreference retainByPreference;
PRUint32 daysToKeepHdrs;
PRUint32 numHeadersToKeep;
PRBool keepUnreadMessagesOnly;
PRUint32 daysToKeepBodies;
rv = retentionSettings->GetRetainByPreference(&retainByPreference);
NS_ENSURE_SUCCESS(rv, rv);
rv = retentionSettings->GetDaysToKeepHdrs(&daysToKeepHdrs);
NS_ENSURE_SUCCESS(rv, rv);
rv = retentionSettings->GetNumHeadersToKeep(&numHeadersToKeep);
NS_ENSURE_SUCCESS(rv, rv);
rv = retentionSettings->GetKeepUnreadMessagesOnly(&keepUnreadMessagesOnly);
NS_ENSURE_SUCCESS(rv, rv);
rv = retentionSettings->GetDaysToKeepBodies(&daysToKeepBodies);
NS_ENSURE_SUCCESS(rv, rv);
// need to write this to the db. We'll just use the dbfolderinfo to write properties.
m_dbFolderInfo->SetUint32Property("retainBy", retainByPreference);
m_dbFolderInfo->SetUint32Property("daysToKeepHdrs", daysToKeepHdrs);
m_dbFolderInfo->SetUint32Property("numHdrsToKeep", numHeadersToKeep);
m_dbFolderInfo->SetUint32Property("daysToKeepBodies", daysToKeepBodies);
m_dbFolderInfo->SetUint32Property("keepUnreadOnly", (keepUnreadMessagesOnly) ? 1 : 0);
}
return NS_OK;
}
NS_IMETHODIMP nsMsgDatabase::GetMsgRetentionSettings(nsIMsgRetentionSettings **retentionSettings)
{
NS_ENSURE_ARG_POINTER(retentionSettings);
if (!m_retentionSettings)
{
// create a new one, and initialize it from the db.
m_retentionSettings = new nsMsgRetentionSettings;
if (m_retentionSettings && m_dbFolderInfo)
{
nsresult rv;
nsMsgRetainByPreference retainByPreference;
PRUint32 daysToKeepHdrs = 0;
PRUint32 numHeadersToKeep = 0;
PRUint32 keepUnreadMessagesProp = 0;
PRBool keepUnreadMessagesOnly = PR_FALSE;
PRUint32 daysToKeepBodies = 0;
rv = m_dbFolderInfo->GetUint32Property("retainBy", &retainByPreference);
m_dbFolderInfo->GetUint32Property("daysToKeepHdrs", &daysToKeepHdrs);
m_dbFolderInfo->GetUint32Property("numHdrsToKeep", &numHeadersToKeep);
m_dbFolderInfo->GetUint32Property("daysToKeepBodies", &daysToKeepBodies);
m_dbFolderInfo->GetUint32Property("keepUnreadOnly", &keepUnreadMessagesProp);
keepUnreadMessagesOnly = (keepUnreadMessagesProp == 1);
m_retentionSettings->SetRetainByPreference(retainByPreference);
m_retentionSettings->SetDaysToKeepHdrs(daysToKeepHdrs);
m_retentionSettings->SetNumHeadersToKeep(numHeadersToKeep);
m_retentionSettings->SetKeepUnreadMessagesOnly(keepUnreadMessagesOnly);
m_retentionSettings->SetDaysToKeepBodies(daysToKeepBodies);
}
}
*retentionSettings = m_retentionSettings;
NS_IF_ADDREF(*retentionSettings);
return NS_OK;
}
NS_IMPL_ISUPPORTS1(nsMsgRetentionSettings, nsIMsgRetentionSettings)
nsMsgRetentionSettings::nsMsgRetentionSettings()
{
NS_INIT_ISUPPORTS();
}
nsMsgRetentionSettings::~nsMsgRetentionSettings()
{
}
/* attribute unsigned long retainByPreference */
NS_IMETHODIMP nsMsgRetentionSettings::GetRetainByPreference(nsMsgRetainByPreference *retainByPreference)
{
NS_ENSURE_ARG_POINTER(retainByPreference);
*retainByPreference = m_retainByPreference;
return NS_OK;
}
NS_IMETHODIMP nsMsgRetentionSettings::SetRetainByPreference(nsMsgRetainByPreference retainByPreference)
{
m_retainByPreference = retainByPreference;
return NS_OK;
}
/* attribute long daysToKeepHdrs; */
NS_IMETHODIMP nsMsgRetentionSettings::GetDaysToKeepHdrs(PRUint32 *aDaysToKeepHdrs)
{
NS_ENSURE_ARG_POINTER(aDaysToKeepHdrs);
*aDaysToKeepHdrs = m_daysToKeepHdrs;
return NS_OK;
}
NS_IMETHODIMP nsMsgRetentionSettings::SetDaysToKeepHdrs(PRUint32 aDaysToKeepHdrs)
{
m_daysToKeepHdrs = aDaysToKeepHdrs;
return NS_OK;
}
/* attribute long numHeadersToKeep; */
NS_IMETHODIMP nsMsgRetentionSettings::GetNumHeadersToKeep(PRUint32 *aNumHeadersToKeep)
{
NS_ENSURE_ARG_POINTER(aNumHeadersToKeep);
*aNumHeadersToKeep = m_numHeadersToKeep;
return NS_OK;
}
NS_IMETHODIMP nsMsgRetentionSettings::SetNumHeadersToKeep(PRUint32 aNumHeadersToKeep)
{
m_numHeadersToKeep = aNumHeadersToKeep;
return NS_OK;
}
/* attribute boolean keepUnreadMessagesOnly; */
NS_IMETHODIMP nsMsgRetentionSettings::GetKeepUnreadMessagesOnly(PRBool *aKeepUnreadMessagesOnly)
{
NS_ENSURE_ARG_POINTER(aKeepUnreadMessagesOnly);
*aKeepUnreadMessagesOnly = m_keepUnreadMessagesOnly;
return NS_OK;
}
NS_IMETHODIMP nsMsgRetentionSettings::SetKeepUnreadMessagesOnly(PRBool aKeepUnreadMessagesOnly)
{
m_keepUnreadMessagesOnly = aKeepUnreadMessagesOnly;
return NS_OK;
}
/* attribute long daysToKeepBodies; */
NS_IMETHODIMP nsMsgRetentionSettings::GetDaysToKeepBodies(PRUint32 *aDaysToKeepBodies)
{
NS_ENSURE_ARG_POINTER(aDaysToKeepBodies);
*aDaysToKeepBodies = m_daysToKeepBodies;
return NS_OK;
}
NS_IMETHODIMP nsMsgRetentionSettings::SetDaysToKeepBodies(PRUint32 aDaysToKeepBodies)
{
m_daysToKeepBodies = aDaysToKeepBodies;
return NS_OK;
}

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

@ -173,7 +173,7 @@ NS_IMETHODIMP nsNewsDatabase::IsRead(nsMsgKey key, PRBool *pRead)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsNewsDatabase::IsHeaderRead(nsIMsgDBHdr *msgHdr, PRBool *pRead) nsresult nsNewsDatabase::IsHeaderRead(nsIMsgDBHdr *msgHdr, PRBool *pRead)
{ {
nsresult rv; nsresult rv;
nsMsgKey messageKey; nsMsgKey messageKey;