1999-03-19 22:55:08 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1999-03-19 22:55:08 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-03-19 22:55:08 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-03-19 22:55:08 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:43:54 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-03-19 22:55:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/********************************************************************************************************
|
|
|
|
|
|
|
|
Interface for representing Messenger folders.
|
|
|
|
|
|
|
|
*********************************************************************************************************/
|
|
|
|
|
|
|
|
#ifndef nsMsgFolder_h__
|
|
|
|
#define nsMsgFolder_h__
|
|
|
|
|
|
|
|
#include "msgCore.h"
|
|
|
|
#include "nsIMsgFolder.h" /* include the interface we are going to support */
|
|
|
|
#include "nsRDFResource.h"
|
1999-03-24 00:17:23 +00:00
|
|
|
#include "nsIDBFolderInfo.h"
|
1999-04-15 21:12:10 +00:00
|
|
|
#include "nsIMsgDatabase.h"
|
1999-05-15 21:03:02 +00:00
|
|
|
#include "nsIMsgIncomingServer.h"
|
1999-05-04 22:34:35 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-10-22 01:02:08 +00:00
|
|
|
#include "nsIURL.h"
|
1999-03-19 22:55:08 +00:00
|
|
|
/*
|
|
|
|
* MsgFolder
|
|
|
|
*/
|
|
|
|
|
1999-05-18 23:55:39 +00:00
|
|
|
class NS_MSG_BASE nsMsgFolder: public nsRDFResource, public nsIMsgFolder
|
1999-03-19 22:55:08 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsMsgFolder(void);
|
|
|
|
virtual ~nsMsgFolder(void);
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
1999-10-20 21:58:21 +00:00
|
|
|
NS_DECL_NSICOLLECTION
|
|
|
|
NS_DECL_NSIFOLDER
|
|
|
|
// eventually this will be an instantiable class, and we should
|
|
|
|
// use this macro:
|
|
|
|
// NS_DECL_NSIMSGFOLDER
|
|
|
|
|
|
|
|
// right now a few of these methods are left abstract, and
|
|
|
|
// are commented out below
|
|
|
|
|
|
|
|
// begin NS_DECL_NSIMSGFOLDER
|
|
|
|
NS_IMETHOD AddUnique(nsISupports *element);
|
|
|
|
NS_IMETHOD ReplaceElement(nsISupports *element, nsISupports *newElement);
|
|
|
|
NS_IMETHOD GetMessages(nsISimpleEnumerator **_retval);
|
|
|
|
NS_IMETHOD GetThreads(nsISimpleEnumerator **_retval);
|
|
|
|
NS_IMETHOD StartFolderLoading(void);
|
|
|
|
NS_IMETHOD EndFolderLoading(void);
|
1999-11-03 03:16:26 +00:00
|
|
|
NS_IMETHOD UpdateFolder(nsIMsgWindow *window);
|
1999-10-20 21:58:21 +00:00
|
|
|
NS_IMETHOD GetThreadForMessage(nsIMessage *message, nsIMsgThread **_retval);
|
|
|
|
NS_IMETHOD HasMessage(nsIMessage *message, PRBool *_retval);
|
|
|
|
NS_IMETHOD GetVisibleSubFolders(nsIEnumerator **_retval);
|
|
|
|
NS_IMETHOD GetPrettiestName(PRUnichar * *aPrettiestName);
|
|
|
|
NS_IMETHOD GetFolderURL(char * *aFolderURL);
|
|
|
|
NS_IMETHOD GetDeleteIsMoveToTrash(PRBool *aDeleteIsMoveToTrash);
|
|
|
|
NS_IMETHOD GetShowDeletedMessages(PRBool *aShowDeletedMessages);
|
|
|
|
NS_IMETHOD GetServer(nsIMsgIncomingServer * *aServer);
|
|
|
|
NS_IMETHOD GetIsServer(PRBool *aIsServer);
|
|
|
|
NS_IMETHOD OnCloseFolder(void);
|
|
|
|
NS_IMETHOD Delete(void);
|
|
|
|
NS_IMETHOD DeleteSubFolders(nsISupportsArray *folders);
|
|
|
|
NS_IMETHOD PropagateDelete(nsIMsgFolder *folder, PRBool deleteStorage);
|
|
|
|
NS_IMETHOD RecursiveDelete(PRBool deleteStorage);
|
|
|
|
NS_IMETHOD CreateSubfolder(const char *folderName);
|
1999-11-19 14:35:31 +00:00
|
|
|
NS_IMETHOD AddSubfolder(nsAutoString *folderName, nsIMsgFolder **newFolder);
|
1999-10-20 21:58:21 +00:00
|
|
|
NS_IMETHOD Compact(void);
|
|
|
|
NS_IMETHOD EmptyTrash(void);
|
|
|
|
NS_IMETHOD Rename(const char *name);
|
|
|
|
NS_IMETHOD Adopt(nsIMsgFolder *srcFolder, PRUint32 *outPos);
|
|
|
|
NS_IMETHOD ContainsChildNamed(const char *name, PRBool *_retval);
|
|
|
|
NS_IMETHOD IsAncestorOf(nsIMsgFolder *folder, PRBool *_retval);
|
|
|
|
NS_IMETHOD GenerateUniqueSubfolderName(const char *prefix, nsIMsgFolder *otherFolder, char **_retval);
|
|
|
|
NS_IMETHOD UpdateSummaryTotals(PRBool force);
|
|
|
|
NS_IMETHOD SummaryChanged(void);
|
|
|
|
NS_IMETHOD GetNumUnread(PRBool deep, PRInt32 *_retval);
|
|
|
|
NS_IMETHOD GetTotalMessages(PRBool deep, PRInt32 *_retval);
|
|
|
|
NS_IMETHOD GetExpungedBytesCount(PRUint32 *aExpungedBytesCount);
|
|
|
|
NS_IMETHOD GetDeletable(PRBool *aDeletable);
|
|
|
|
NS_IMETHOD GetCanCreateChildren(PRBool *aCanCreateChildren);
|
|
|
|
NS_IMETHOD GetCanBeRenamed(PRBool *aCanBeRenamed);
|
|
|
|
NS_IMETHOD GetRequiresCleanup(PRBool *aRequiresCleanup);
|
|
|
|
NS_IMETHOD ClearRequiresCleanup(void);
|
|
|
|
NS_IMETHOD ManyHeadersToDownload(PRBool *_retval);
|
|
|
|
NS_IMETHOD GetKnowsSearchNntpExtension(PRBool *aKnowsSearchNntpExtension);
|
|
|
|
NS_IMETHOD GetAllowsPosting(PRBool *aAllowsPosting);
|
|
|
|
NS_IMETHOD GetDisplayRecipients(PRBool *aDisplayRecipients);
|
|
|
|
NS_IMETHOD GetRelativePathName(char * *aRelativePathName);
|
|
|
|
NS_IMETHOD GetSizeOnDisk(PRUint32 *aSizeOnDisk);
|
|
|
|
NS_IMETHOD RememberPassword(const char *password);
|
|
|
|
NS_IMETHOD GetRememberedPassword(char * *aRememberedPassword);
|
|
|
|
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *_retval);
|
1999-10-22 01:02:08 +00:00
|
|
|
NS_IMETHOD GetUsername(char * *aUsername);
|
|
|
|
NS_IMETHOD GetHostname(char * *aHostname);
|
1999-10-20 21:58:21 +00:00
|
|
|
NS_IMETHOD SetFlag(PRUint32 flag);
|
|
|
|
NS_IMETHOD ClearFlag(PRUint32 flag);
|
|
|
|
NS_IMETHOD GetFlag(PRUint32 flag, PRBool *_retval);
|
|
|
|
NS_IMETHOD ToggleFlag(PRUint32 flag);
|
|
|
|
NS_IMETHOD OnFlagChange(PRUint32 flag);
|
|
|
|
NS_IMETHOD GetFlags(PRUint32 *aFlags);
|
|
|
|
NS_IMETHOD GetFoldersWithFlag(PRUint32 flags, nsIMsgFolder **result, PRUint32 resultsize, PRUint32 *numFolders);
|
|
|
|
NS_IMETHOD GetExpansionArray(nsISupportsArray *expansionArray);
|
|
|
|
// NS_IMETHOD DeleteMessages(nsISupportsArray *message, nsITransactionManager *txnMgr, PRBool deleteStorage);
|
1999-10-29 04:39:06 +00:00
|
|
|
NS_IMETHOD CopyMessages(nsIMsgFolder *srcFolder, nsISupportsArray *messages, PRBool isMove, nsIMsgWindow *window, nsIMsgCopyServiceListener *listener);
|
|
|
|
NS_IMETHOD CopyFileMessage(nsIFileSpec *fileSpec, nsIMessage *msgToReplace, PRBool isDraft, nsIMsgWindow *window, nsIMsgCopyServiceListener *listener);
|
1999-10-20 21:58:21 +00:00
|
|
|
NS_IMETHOD AcquireSemaphore(nsISupports *semHolder);
|
|
|
|
NS_IMETHOD ReleaseSemaphore(nsISupports *semHolder);
|
|
|
|
NS_IMETHOD TestSemaphore(nsISupports *semHolder, PRBool *_retval);
|
|
|
|
NS_IMETHOD GetLocked(PRBool *aLocked);
|
|
|
|
// NS_IMETHOD CreateMessageFromMsgDBHdr(nsIMsgDBHdr *msgDBHdr, nsIMessage **_retval);
|
1999-11-03 03:16:26 +00:00
|
|
|
NS_IMETHOD GetNewMessages(nsIMsgWindow *window);
|
1999-10-20 21:58:21 +00:00
|
|
|
// NS_IMETHOD WriteToFolderCache(nsIMsgFolderCache *folderCache);
|
|
|
|
// NS_IMETHOD GetCharset(PRUnichar * *aCharset);
|
|
|
|
// NS_IMETHOD SetCharset(const PRUnichar * aCharset);
|
|
|
|
NS_IMETHOD GetBiffState(PRUint32 *aBiffState);
|
|
|
|
NS_IMETHOD SetBiffState(PRUint32 aBiffState);
|
|
|
|
NS_IMETHOD GetNumNewMessages(PRInt32 *aNumNewMessages);
|
|
|
|
NS_IMETHOD SetNumNewMessages(PRInt32 aNumNewMessages);
|
|
|
|
NS_IMETHOD GetNewMessagesNotificationDescription(PRUnichar * *aNewMessagesNotificationDescription);
|
|
|
|
NS_IMETHOD GetRootFolder(nsIMsgFolder * *aRootFolder);
|
|
|
|
NS_IMETHOD GetMsgDatabase(nsIMsgDatabase * *aMsgDatabase);
|
|
|
|
NS_IMETHOD GetPath(nsIFileSpec * *aPath);
|
|
|
|
NS_IMETHOD MarkMessagesRead(nsISupportsArray *messages, PRBool markRead);
|
|
|
|
NS_IMETHOD MarkAllMessagesRead(void);
|
|
|
|
NS_IMETHOD MarkMessagesFlagged(nsISupportsArray *messages, PRBool markFlagged);
|
|
|
|
NS_IMETHOD GetChildWithURI(const char *uri, PRBool deep, nsIMsgFolder **_retval);
|
|
|
|
|
|
|
|
// end NS_DECL_NSIMSGFOLDER
|
|
|
|
|
|
|
|
// nsRDFResource overrides
|
|
|
|
NS_IMETHOD Init(const char* aURI);
|
1999-08-20 22:41:38 +00:00
|
|
|
|
1999-03-19 22:55:08 +00:00
|
|
|
#if 0
|
|
|
|
static nsresult GetRoot(nsIMsgFolder* *result);
|
|
|
|
#endif
|
|
|
|
// Gets the URL that represents the given message. Returns a newly
|
|
|
|
// created string that must be free'd using XP_FREE().
|
|
|
|
// If the db is NULL, then returns a URL that represents the entire
|
|
|
|
// folder as a whole.
|
|
|
|
// These functions 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
|
|
|
|
// These functions are called when MSG_Master::GetFolderLineById is populating a MSG_FolderLine
|
|
|
|
// struct used by the FE
|
1999-11-01 01:06:29 +00:00
|
|
|
PRInt32 GetNumPendingUnread();
|
|
|
|
PRInt32 GetNumPendingTotalMessages();
|
1999-03-19 22:55:08 +00:00
|
|
|
|
1999-11-01 01:06:29 +00:00
|
|
|
void ChangeNumPendingUnread(PRInt32 delta);
|
|
|
|
void ChangeNumPendingTotalMessages(PRInt32 delta);
|
1999-03-19 22:55:08 +00:00
|
|
|
|
|
|
|
|
1999-11-01 01:06:29 +00:00
|
|
|
#ifdef HAVE_DB
|
|
|
|
NS_IMETHOD BuildUrl(nsMsgDatabase *db, nsMsgKey key, char ** url);
|
|
|
|
|
|
|
|
// updates num messages and num unread - should be pure virtual
|
|
|
|
// when I get around to implementing in all subclasses?
|
|
|
|
NS_IMETHOD GetTotalMessagesInDB(PRUint32 *totalMessages) const; // How many messages in database.
|
1999-03-19 22:55:08 +00:00
|
|
|
NS_IMETHOD SetFolderPrefFlags(PRUint32 flags);
|
|
|
|
NS_IMETHOD GetFolderPrefFlags(PRUint32 *flags);
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHOD SetLastMessageLoaded(nsMsgKey lastMessageLoaded);
|
|
|
|
NS_IMETHOD GetLastMessageLoaded();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-10-20 21:58:21 +00:00
|
|
|
#ifdef HAVE_ADMINURL
|
|
|
|
NS_IMETHOD GetAdminUrl(MWContext *context, MSG_AdminURLType type);
|
|
|
|
NS_IMETHOD HaveAdminUrl(MSG_AdminURLType type, PRBool *hadAdminUrl);
|
|
|
|
#endif
|
|
|
|
|
1999-03-19 22:55:08 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_PANE
|
1999-10-20 21:58:21 +00:00
|
|
|
NS_IMETHOD MarkAllRead(MSG_Pane *pane, PRBool deep);
|
1999-03-19 22:55:08 +00:00
|
|
|
NS_IMETHOD SetFlagInAllFolderPanes(PRUint32 which);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NET
|
|
|
|
NS_IMETHOD EscapeMessageId(const char *messageId, const char **escapeMessageID);
|
1999-10-20 21:58:21 +00:00
|
|
|
NS_IMETHOD ShouldPerformOperationOffline(PRBool *performOffline);
|
1999-03-19 22:55:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CACHE
|
|
|
|
virtual nsresult WriteToCache(XP_File);
|
|
|
|
virtual nsresult ReadFromCache(char *);
|
|
|
|
virtual PRBool IsCachable();
|
|
|
|
void SkipCacheTokens(char **ppBuf, int numTokens);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DOES_FOLDEROPERATIONS
|
|
|
|
int DownloadToTempFileAndUpload(MessageCopyInfo *copyInfo, nsMsgKeyArray &keysToSave, MSG_FolderInfo *dstFolder, nsMsgDatabase *sourceDB);
|
|
|
|
void UpdateMoveCopyStatus(MWContext *context, PRBool isMove, int32 curMsgCount, int32 totMessages);
|
|
|
|
#endif
|
|
|
|
|
1999-05-07 00:33:06 +00:00
|
|
|
virtual nsresult GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsIMsgDatabase **db) = 0;
|
1999-06-26 18:22:55 +00:00
|
|
|
|
1999-03-19 22:55:08 +00:00
|
|
|
|
1999-07-27 05:15:44 +00:00
|
|
|
NS_IMETHOD MatchName(nsString *name, PRBool *matches);
|
1999-07-23 04:33:20 +00:00
|
|
|
|
|
|
|
|
1999-04-20 22:24:21 +00:00
|
|
|
protected:
|
|
|
|
nsresult NotifyPropertyChanged(char *property, char* oldValue, char* newValue);
|
1999-11-22 22:08:23 +00:00
|
|
|
nsresult NotifyIntPropertyChanged(char *property, PRInt32 oldValue, PRInt32 newValue);
|
|
|
|
nsresult NotifyBoolPropertyChanged(char *property, PRBool oldValue, PRBool newValue);
|
1999-05-14 00:45:25 +00:00
|
|
|
nsresult NotifyPropertyFlagChanged(nsISupports *item, char *property, PRUint32 oldValue,
|
|
|
|
PRUint32 newValue);
|
1999-11-11 00:23:29 +00:00
|
|
|
nsresult NotifyItemAdded(nsISupports *parentItem, nsISupports *item, const char *viewString);
|
|
|
|
nsresult NotifyItemDeleted(nsISupports *parentItem, nsISupports *item, const char* viewString);
|
1999-03-19 22:55:08 +00:00
|
|
|
|
1999-09-16 21:07:56 +00:00
|
|
|
nsresult NotifyFolderLoaded();
|
1999-05-15 21:03:02 +00:00
|
|
|
// this is a little helper function that is not part of the public interface.
|
|
|
|
// we use it to get the IID of the incoming server for the derived folder.
|
|
|
|
// w/out a function like this we would have to implement GetServer in each
|
|
|
|
// derived folder class.
|
1999-06-22 03:03:48 +00:00
|
|
|
virtual const char* GetIncomingServerType() = 0;
|
1999-05-07 20:21:47 +00:00
|
|
|
|
1999-03-19 22:55:08 +00:00
|
|
|
protected:
|
|
|
|
PRUint32 mFlags;
|
1999-05-07 20:21:47 +00:00
|
|
|
nsIFolder *mParent; //This won't be refcounted for ownership reasons.
|
1999-03-19 22:55:08 +00:00
|
|
|
PRInt32 mNumUnreadMessages; /* count of unread messages (-1 means
|
|
|
|
unknown; -2 means unknown but we already
|
|
|
|
tried to find out.) */
|
|
|
|
PRInt32 mNumTotalMessages; /* count of existing messages. */
|
1999-05-04 22:34:35 +00:00
|
|
|
nsCOMPtr<nsISupportsArray> mSubFolders;
|
1999-05-15 21:03:02 +00:00
|
|
|
nsVoidArray *mListeners; //This can't be an nsISupportsArray because due to
|
1999-05-04 22:34:35 +00:00
|
|
|
//ownership issues, listeners can't be AddRef'd
|
1999-03-19 22:55:08 +00:00
|
|
|
|
|
|
|
PRInt32 mPrefFlags; // prefs like MSG_PREF_OFFLINE, MSG_PREF_ONE_PANE, etc
|
1999-03-23 23:19:58 +00:00
|
|
|
nsISupports *mSemaphoreHolder; // set when the folder is being written to
|
1999-05-07 20:21:47 +00:00
|
|
|
//Due to ownership issues, this won't be AddRef'd.
|
1999-03-19 22:55:08 +00:00
|
|
|
|
1999-07-20 03:55:23 +00:00
|
|
|
nsIMsgIncomingServer* m_server; //this won't be addrefed....ownership issue here
|
1999-05-15 21:03:02 +00:00
|
|
|
|
1999-03-19 22:55:08 +00:00
|
|
|
#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
|
1999-03-24 00:17:23 +00:00
|
|
|
PRInt32 mNumPendingUnreadMessages;
|
|
|
|
PRInt32 mNumPendingTotalMessages;
|
1999-03-19 22:55:08 +00:00
|
|
|
|
1999-06-11 22:10:42 +00:00
|
|
|
PRUint32 mBiffState;
|
|
|
|
PRInt32 mNumNewBiffMessages;
|
|
|
|
|
1999-05-15 21:03:02 +00:00
|
|
|
PRBool mIsCachable;
|
1999-10-22 01:02:08 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// stuff from the uri
|
|
|
|
//
|
|
|
|
|
1999-08-20 22:41:38 +00:00
|
|
|
PRBool mIsServer;
|
1999-10-22 01:02:08 +00:00
|
|
|
nsString mName;
|
|
|
|
|
1999-03-19 22:55:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|