This commit is contained in:
putterman%netscape.com 1999-02-25 02:56:13 +00:00
Родитель 2a9ab47da1
Коммит 7278882750
4 изменённых файлов: 67 добавлений и 17 удалений

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

@ -26,6 +26,7 @@ class nsIMsgFolder : public nsIFolder {
return iid;
}
// XXX should these 2 go on nsIFolder or nsICollection?
NS_IMETHOD AddUnique(nsISupports* element) = 0;
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement) = 0;
@ -126,6 +127,8 @@ class nsIMsgFolder : public nsIFolder {
/* <IDL> */
NS_IMETHOD DisplayRecipients(PRBool *_retval) = 0;
NS_IMETHOD ReadDBFolderInfo(PRBool force) = 0;
/* <IDL> */
NS_IMETHOD GetRelativePathName(char * *aRelativePathName) = 0;
@ -142,7 +145,7 @@ class nsIMsgFolder : public nsIFolder {
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *_retval) = 0;
/* <IDL> */
NS_IMETHOD GetUserName(char **_retval) = 0;
NS_IMETHOD GetUsersName(char **_retval) = 0;
/* <IDL> */
NS_IMETHOD GetHostName(char **_retval) = 0;

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

@ -47,7 +47,7 @@ interface nsIMsgFolder : nsISupports {
boolean HasMessages();
unsigned long GetNumMessages() ;
unsigned long GetNumMessagesToDisplay();
nsIMsgFolder GetMessage(in unsigned long which) ;
nsIMsgFolder GetAMessage(in unsigned long which) ;
nsISupportsArray GetMessages();
void AddMessage(in nsIMsg msg);
void RemoveMessage(in nsIMsg msg);
@ -93,13 +93,15 @@ interface nsIMsgFolder : nsISupports {
boolean DisplayRecipients();
void ReadDBFolderInfo(in boolean force);
readonly attribute string relativePathName;
readonly attribute unsigned long sizeOnDisk;
void RememberPassword(in string password);
string GetRememberedPassword();
boolean UserNeedsToAuthenticateForFolder(in boolean displayOnly);
string GetUserName();
string GetUsersName();
string GetHostName();
void AddSubfolderIfUnique(in nsIMsgFolder newSubfolder);

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

@ -22,11 +22,10 @@
#include "nsMsgFolderFlags.h"
#include "prprf.h"
#include "nsMsgKeyArray.h"
#include "nsMsgDataBase.h"
#include "nsDBFolderInfo.h"
#include "nsISupportsArray.h"
#ifdef HAVE_DB
#include "nsMsgDatabase.h"
#endif
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
// that doesn't allow you to call ::nsISupports::IID() inside of a class
@ -50,14 +49,12 @@ nsMsgFolder::nsMsgFolder(const char* uri)
#ifdef HAVE_DB
mLastMessageLoaded = nsMsgKey_None;
#endif
mNumPendingUnreadMessages = 0;
mNumPendingTotalMessages = 0;
#endif
NS_NewISupportsArray(&mSubFolders);
#ifdef HAVE_CACHE
mIsCachable = TRUE;
#endif
}
nsMsgFolder::~nsMsgFolder()
@ -389,6 +386,7 @@ NS_IMETHODIMP nsMsgFolder::RemoveElement(nsISupports *aElement)
return mSubFolders->RemoveElement(aElement);
}
NS_IMETHODIMP nsMsgFolder::Enumerate(nsIEnumerator* *result)
{
// nsMsgFolders only have subfolders, no message elements
@ -1154,6 +1152,46 @@ NS_IMETHODIMP nsMsgFolder::DisplayRecipients(PRBool *displayRecipients)
return NS_OK;
}
NS_IMETHODIMP nsMsgFolder::ReadDBFolderInfo(PRBool force)
{
// Since it turns out to be pretty expensive to open and close
// the DBs all the time, if we have to open it once, get everything
// we might need while we're here
nsresult result= NS_OK;
if (force || !(mPrefFlags & MSG_FOLDER_PREF_CACHED))
{
nsDBFolderInfo *folderInfo;
nsMsgDatabase *db;
if(result = NS_SUCCEEDED(GetDBFolderInfoAndDB(&folderInfo, &db)))
{
mIsCachable = TRUE;
if (folderInfo)
{
folderInfo->GetFlags(&mPrefFlags);
mPrefFlags |= MSG_FOLDER_PREF_CACHED;
folderInfo->SetFlags(mPrefFlags);
folderInfo->GetNumMessages(&mNumTotalMessages);
folderInfo->GetNumNewMessages(&mNumUnreadMessages);
mNumPendingTotalMessages = folderInfo->GetImapTotalPendingMessages();
mNumPendingUnreadMessages = folderInfo->GetImapUnreadPendingMessages();
mCsid = folderInfo->GetCSID();
if (db && !db->HasNew() && mNumPendingUnreadMessages <= 0)
ClearFlag(MSG_FOLDER_FLAG_GOT_NEW);
}
if (db)
db->Close(FALSE);
}
}
return result;
}
#ifdef HAVE_SEMAPHORE
NS_IMETHODIMP nsMsgFolder::AcquireSemaphore(void *semHolder)
{
@ -1274,7 +1312,7 @@ NS_IMETHODIMP nsMsgFolder::UserNeedsToAuthenticateForFolder(PRBool displayOnly,
return NS_OK;
}
NS_IMETHODIMP nsMsgFolder::GetUserName(char **userName)
NS_IMETHODIMP nsMsgFolder::GetUsersName(char **userName)
{
if(!userName)
return NS_ERROR_NULL_POINTER;
@ -1293,3 +1331,4 @@ NS_IMETHODIMP nsMsgFolder::GetHostName(char **hostName)
}
////////////////////////////////////////////////////////////////////////////////

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

@ -29,6 +29,8 @@
#include "nsIMsgFolder.h" /* include the interface we are going to support */
#include "nsRDFResource.h"
#include "nsIRDFResourceFactory.h"
#include "nsDBFolderInfo.h"
#include "nsMsgDataBase.h"
/*
* MsgFolder
@ -118,6 +120,7 @@ public:
NS_IMETHOD BuildFolderURL(char ** url);
NS_IMETHOD GetPrettiestName(nsString& name);
#ifdef HAVE_ADMINURL
@ -224,6 +227,9 @@ public:
NS_IMETHOD DisplayRecipients(PRBool *displayRecipients);
NS_IMETHOD ReadDBFolderInfo(PRBool force);
#ifdef HAVE_SEMAPHORE
nsresult AcquireSemaphore(void *semHolder);
void ReleaseSemaphore(void *semHolder);
@ -263,16 +269,18 @@ public:
NS_IMETHOD RememberPassword(const char *password);
NS_IMETHOD GetRememberedPassword(char ** password);
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *needsAuthenticate);
NS_IMETHOD GetUserName(char **userName);
NS_IMETHOD GetUsersName(char **userName);
NS_IMETHOD GetHostName(char **hostName);
virtual nsresult GetDBFolderInfoAndDB(nsDBFolderInfo **folderInfo, nsMsgDatabase **db) = 0;
protected:
nsString mName;
PRUint32 mFlags;
PRUint32 mNumUnreadMessages; /* count of unread messages (-1 means
PRInt32 mNumUnreadMessages; /* count of unread messages (-1 means
unknown; -2 means unknown but we already
tried to find out.) */
PRUint32 mNumTotalMessages; /* count of existing messages. */
PRInt32 mNumTotalMessages; /* count of existing messages. */
nsISupportsArray *mSubFolders;
#ifdef HAVE_MASTER
MSG_Master *mMaster;
@ -280,23 +288,21 @@ protected:
PRInt16 mCsid; // default csid for folder/newsgroup - maintained by fe.
PRUint8 mDepth;
PRUint32 mPrefFlags; // prefs like MSG_PREF_OFFLINE, MSG_PREF_ONE_PANE, etc
PRInt32 mPrefFlags; // prefs like MSG_PREF_OFFLINE, MSG_PREF_ONE_PANE, etc
#ifdef HAVE_SEMAPHORE
void *mSemaphoreHolder; // set when the folder is being written to
#endif
#ifdef HAVE_DB
nsMsgKey m_lastMessageLoaded;
#endif
// These values are used for tricking the front end into thinking that we have more
// messages than are really in the DB. This is usually after and IMAP message copy where
// we don't want to do an expensive select until the user actually opens that folder
PRUint32 mNumPendingUnreadMessages;
PRUint32 mNumPendingTotalMessages;
#endif
#ifdef HAVE_CACHE
PRBool mIsCachable;
#endif
};