- add generic interface to access mail filter lists in both servers and folders. in the base class, folders just forward to their root server.

- expose event notifications through nsIFolder so that non-folders can trigger notifications on individual folders
- add generic OnItemEvent to nsIFolderListener, and implement in base classes
This commit is contained in:
alecf%netscape.com 2000-03-28 04:58:05 +00:00
Родитель f2a99e4c3e
Коммит 8a771fc719
11 изменённых файлов: 216 добавлений и 31 удалений

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
@ -41,6 +41,32 @@ interface nsIFolder : nsICollection {
void RemoveFolderListener(in nsIFolderListener listener);
nsIFolder FindSubFolder(in string subFolderName);
void NotifyPropertyChanged(in nsIAtom property,
in string oldValue,
in string newValue);
void NotifyIntPropertyChanged(in nsIAtom property,
in long oldValue,
in long newValue);
void NotifyBoolPropertyChanged(in nsIAtom property,
in boolean oldValue,
in boolean newValue);
void NotifyPropertyFlagChanged(in nsISupports item,
in nsIAtom property,
in unsigned long oldValue,
in unsigned long newValue);
void NotifyUnicharPropertyChanged(in nsIAtom property,
in wstring oldValue,
in wstring newValue);
void NotifyItemAdded(in nsISupports parentItem, in nsISupports item, in string viewString);
void NotifyItemDeleted(in nsISupports parentItem, in nsISupports item, in string viewString);
void NotifyFolderEvent(in nsIAtom event);
void NotifyFolderLoaded();
void NotifyDeleteOrMoveMessagesCompleted(in nsIFolder folder);
void Shutdown(in boolean shutdownChildren);
};

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

@ -28,15 +28,41 @@ interface nsIFolder;
[scriptable, uuid(1c5ef9f0-d1c0-11d2-94CA-006097222B83)] /* XXX regenerate */
interface nsIFolderListener : nsISupports {
void OnItemAdded(in nsISupports parentItem, in nsISupports item, in string viewString);
void OnItemRemoved(in nsISupports parentItem, in nsISupports item, in string viewString);
void OnItemAdded(in nsISupports parentItem,
in nsISupports item,
in string viewString);
void OnItemRemoved(in nsISupports parentItem,
in nsISupports item,
in string viewString);
void OnItemPropertyChanged(in nsISupports item,
in nsIAtom property,
in string oldValue,
in string newValue);
void OnItemIntPropertyChanged(in nsISupports item,
in nsIAtom property,
in long oldValue,
in long newValue);
void OnItemBoolPropertyChanged(in nsISupports item,
in nsIAtom property,
in boolean oldValue,
in boolean newValue);
void OnItemUnicharPropertyChanged(in nsISupports item,
in nsIAtom property,
in wstring oldValue,
in wstring newValue);
void OnItemPropertyFlagChanged(in nsISupports item,
in nsIAtom property,
in unsigned long oldFlag,
in unsigned long newFlag);
void OnItemEvent(in nsIFolder item, in nsIAtom event);
void OnItemPropertyChanged(in nsISupports item, in nsIAtom property, in string oldValue, in string newValue);
void OnItemIntPropertyChanged(in nsISupports item, in nsIAtom property, in long oldValue, in long newValue);
void OnItemBoolPropertyChanged(in nsISupports item, in nsIAtom property, in boolean oldValue, in boolean newValue);
void OnItemUnicharPropertyChanged(in nsISupports item, in nsIAtom property, in wstring oldValue, in wstring newValue);
void OnItemPropertyFlagChanged(in nsISupports item, in nsIAtom property, in unsigned long oldFlag,
in unsigned long newFlag);
void OnFolderLoaded(in nsIFolder aFolder);
void OnDeleteOrMoveMessagesCompleted(in nsIFolder aFolder);
};

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

@ -38,6 +38,7 @@ interface nsIMsgWindow;
interface nsIMsgDatabase;
interface nsIDBFolderInfo;
interface nsMsgKeyArray;
interface nsIMsgFilterList;
interface nsIMsgFolderCacheElement;
interface nsAutoString;
@ -115,6 +116,9 @@ interface nsIMsgFolder : nsIFolder {
* the phantom server folder
*/
readonly attribute nsIMsgFolder rootFolder;
/* filter for this folder */
readonly attribute nsIMsgFilterList filterList;
void ForceDBClosed ();
void Delete ();

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

@ -26,6 +26,8 @@
interface nsIFolder;
interface nsIMsgFolderCache;
interface nsIMsgWindow;
interface nsIMsgFilterList;
/*
* Interface for incoming mail/news host
* this is the base interface for all mail server types (imap, pop, nntp, etc)
@ -111,8 +113,14 @@ interface nsIMsgIncomingServer : nsISupports {
going off at the same time. */
attribute boolean serverBusy;
/* should we use a secure channel? */
attribute boolean isSecure;
/* what kind of logon redirector to use for this server, if any */
attribute string redirectorType;
readonly attribute nsIMsgFilterList filterList;
/* we use this to set the default local path. we use this when migrating prefs */
void SetDefaultLocalPath(in nsIFileSpec aDefaultLocalPath);
@ -157,8 +165,6 @@ interface nsIMsgIncomingServer : nsISupports {
wstring toString();
attribute boolean isSecure;
/* used for comparing nsIMsgIncomingServers */
boolean equals(in nsIMsgIncomingServer server);
};

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

@ -875,6 +875,13 @@ nsMsgFolderDataSource::OnItemPropertyFlagChanged(nsISupports *item,
}
NS_IMETHODIMP
nsMsgFolderDataSource::OnItemEvent(nsIFolder *aFolder, nsIAtom *aEvent)
{
return NS_OK;
}
NS_IMETHODIMP nsMsgFolderDataSource::OnFolderLoaded(nsIFolder *folder)
{
nsresult rv = NS_OK;

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

@ -606,6 +606,7 @@ NS_IMETHODIMP nsMsgMessageDataSource::OnItemRemoved(nsISupports *parentItem, nsI
return OnItemAddedOrRemoved(parentItem, item, viewString, PR_FALSE);
}
nsresult nsMsgMessageDataSource::OnItemAddedOrRemoved(nsISupports *parentItem, nsISupports *item, const char *viewString, PRBool added)
{
@ -726,6 +727,12 @@ nsMsgMessageDataSource::OnItemPropertyFlagChanged(nsISupports *item,
return rv;
}
NS_IMETHODIMP
nsMsgMessageDataSource::OnItemEvent(nsIFolder *aFolder, nsIAtom *aEvent)
{
return NS_OK;
}
NS_IMETHODIMP nsMsgMessageDataSource::OnFolderLoaded(nsIFolder *folder)
{
nsresult rv = NS_OK;
@ -893,7 +900,6 @@ nsMsgMessageDataSource::createMessageNode(nsIMessage *message,
return rv;
}
nsresult
nsMsgMessageDataSource::createMessageNameNode(nsIMessage *message,
PRBool sort,

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

@ -248,6 +248,13 @@ nsMsgNotificationManager::OnItemPropertyFlagChanged(nsISupports *item,
return rv;
}
NS_IMETHODIMP
nsMsgNotificationManager::OnItemEvent(nsIFolder *folder, nsIAtom *aEvent)
{
return NS_OK;
}
NS_IMETHODIMP nsMsgNotificationManager::OnFolderLoaded(nsIFolder *folder)
{
nsresult rv = NS_OK;

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

@ -44,6 +44,7 @@
#include "nsIAllocator.h"
#include "nsIURL.h"
#include "nsMsgUtils.h" // for NS_MsgHashIfNecessary()
#include "nsIIOService.h"
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
@ -107,10 +108,12 @@ nsMsgFolder::nsMsgFolder(void)
nsMsgFolder::~nsMsgFolder(void)
{
nsresult rv;
if(mSubFolders)
{
PRUint32 count;
nsresult rv = mSubFolders->Count(&count);
rv = mSubFolders->Count(&count);
NS_ASSERTION(NS_SUCCEEDED(rv), "Count failed");
for (int i = count - 1; i >= 0; i--)
@ -350,6 +353,26 @@ NS_IMETHODIMP nsMsgFolder::RemoveFolderListener(nsIFolderListener * listener)
NS_IMETHODIMP nsMsgFolder::SetParent(nsIFolder *aParent)
{
mParent = getter_AddRefs(NS_GetWeakReference(aParent));
if (aParent) {
nsresult rv;
nsCOMPtr<nsIMsgFolder> parentMsgFolder =
do_QueryInterface(aParent, &rv);
if (NS_SUCCEEDED(rv)) {
// servers do not have parents, so we must not be a server
mIsServer = PR_FALSE;
mIsServerIsValid = PR_TRUE;
// also set the server itself while we're here.
nsCOMPtr<nsIMsgIncomingServer> server;
nsresult rv = parentMsgFolder->GetServer(getter_AddRefs(server));
if (NS_SUCCEEDED(rv) && server)
mServer = getter_AddRefs(NS_GetWeakReference(server));
}
}
return NS_OK;
}
@ -2038,7 +2061,7 @@ nsMsgFolder::SetDeleteIsMoveToTrash(PRBool bVal)
nsresult
nsMsgFolder::NotifyPropertyChanged(nsIAtom *property,
char *oldValue, char* newValue)
const char *oldValue, const char* newValue)
{
nsCOMPtr<nsISupports> supports;
if(NS_SUCCEEDED(QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(supports))))
@ -2245,6 +2268,24 @@ nsresult nsMsgFolder::NotifyDeleteOrMoveMessagesCompleted(nsIFolder *folder)
return NS_OK;
}
nsresult nsMsgFolder::NotifyFolderEvent(nsIAtom* aEvent)
{
PRInt32 i;
for(i = 0; i < mListeners->Count(); i++)
{
//Folderlistener's aren't refcounted.
nsIFolderListener *listener = (nsIFolderListener*)mListeners->ElementAt(i);
listener->OnItemEvent(this, aEvent);
}
//Notify listeners who listen to every folder
nsresult rv;
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
if(NS_SUCCEEDED(rv))
mailSession->NotifyFolderEvent(this, aEvent);
return NS_OK;
}
nsresult
nsGetMailFolderSeparator(nsString& result)
{
@ -2276,3 +2317,24 @@ nsMsgFolder::RecursiveSetDeleteIsMoveToTrash(PRBool bVal)
}
return SetDeleteIsMoveToTrash(bVal);
}
NS_IMETHODIMP
nsMsgFolder::GetFilterList(nsIMsgFilterList **aResult)
{
nsresult rv;
// only get filters for root folders in the base class
#ifdef NS_DEBUG
PRBool isServer=PR_FALSE;
rv = GetIsServer(&isServer);
NS_ASSERTION(NS_SUCCEEDED(rv), "error getting serverness");
NS_ASSERTION(isServer, "Getting filter for non-server?");
#endif
nsCOMPtr<nsIMsgIncomingServer> server;
rv = GetServer(getter_AddRefs(server));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(server, NS_ERROR_FAILURE);
return server->GetFilterList(aResult);
}

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

@ -38,6 +38,7 @@
#include "nsCOMPtr.h"
#include "nsIURL.h"
#include "nsWeakReference.h"
#include "nsIMsgFilterList.h"
/*
* MsgFolder
@ -84,6 +85,7 @@ public:
NS_IMETHOD GetCanFileMessages(PRBool *aCanFileMessages);
NS_IMETHOD GetCanCreateSubfolders(PRBool *aCanCreateSubfolders);
NS_IMETHOD GetCanRename(PRBool *aCanRename);
NS_IMETHOD GetFilterList(nsIMsgFilterList **aFilterList);
NS_IMETHOD ForceDBClosed(void);
NS_IMETHOD Delete(void);
NS_IMETHOD DeleteSubFolders(nsISupportsArray *folders, nsIMsgWindow *msgWindow);
@ -225,20 +227,7 @@ public:
protected:
nsresult NotifyPropertyChanged(nsIAtom *property, char* oldValue, char* newValue);
nsresult NotifyIntPropertyChanged(nsIAtom *property, PRInt32 oldValue, PRInt32 newValue);
nsresult NotifyBoolPropertyChanged(nsIAtom *property, PRBool oldValue, PRBool newValue);
nsresult NotifyUnicharPropertyChanged(nsIAtom *property, const PRUnichar* oldValue, const PRUnichar* newValue);
nsresult NotifyPropertyFlagChanged(nsISupports *item, nsIAtom *property, PRUint32 oldValue,
PRUint32 newValue);
nsresult NotifyItemAdded(nsISupports *parentItem, nsISupports *item, const char *viewString);
nsresult NotifyItemDeleted(nsISupports *parentItem, nsISupports *item, const char* viewString);
nsresult NotifyFolderLoaded();
nsresult NotifyDeleteOrMoveMessagesCompleted(nsIFolder *folder);
// 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
@ -290,8 +279,8 @@ protected:
PRBool mIsServer;
nsString mName;
nsCOMPtr<nsIFileSpec> mPath;
char * mBaseMessageURI; //The uri with the message scheme
PRBool mDeleteIsMoveToTrash;
char * mBaseMessageURI; //The uri with the message scheme
// static stuff for cross-instance objects like atoms
static PRInt32 gInstanceCount;

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

@ -29,19 +29,24 @@
#include "prprf.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsMsgBaseCID.h"
#include "nsIMsgFolder.h"
#include "nsIMsgFolderCache.h"
#include "nsIMsgFolderCacheElement.h"
#include "nsIMsgWindow.h"
#include "nsIMsgFilterService.h"
#include "nsIMsgProtocolInfo.h"
#include "nsIPref.h"
#include "nsIWebShell.h"
#include "nsIWebShellWindow.h"
#include "nsINetPrompt.h"
#include "nsIWalletService.h"
#include "nsXPIDLString.h"
#include "nsIRDFService.h"
#include "nsIMsgProtocolInfo.h"
#include "nsIAppShellService.h"
#include "nsAppShellCIDs.h"
#include "nsIXULWindow.h"
@ -55,6 +60,7 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kWalletServiceCID, NS_WALLETSERVICE_CID);
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
static NS_DEFINE_CID(kMsgFilterServiceCID, NS_MSGFILTERSERVICE_CID);
MOZ_DECL_CTOR_COUNTER(nsMsgIncomingServer);
@ -70,6 +76,13 @@ nsMsgIncomingServer::nsMsgIncomingServer():
nsMsgIncomingServer::~nsMsgIncomingServer()
{
nsresult rv;
if (mFilterList) {
nsCOMPtr<nsIMsgFilterService> filterService =
do_GetService(kMsgFilterServiceCID, &rv);
if (NS_SUCCEEDED(rv))
rv = filterService->CloseFilterList(mFilterList);
}
if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID,
m_prefs,
nsnull);
@ -862,6 +875,43 @@ nsMsgIncomingServer::clearPrefEnum(const char *aPref, void *aClosure)
prefs->ClearUserPref(aPref);
}
nsresult
nsMsgIncomingServer::GetFilterList(nsIMsgFilterList **aResult)
{
nsresult rv;
if (!mFilterList) {
nsCOMPtr<nsIFolder> folder;
rv = GetRootFolder(getter_AddRefs(folder));
nsCOMPtr<nsIMsgFolder> msgFolder(do_QueryInterface(folder, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFileSpec> thisFolder;
rv = msgFolder->GetPath(getter_AddRefs(thisFolder));
NS_ENSURE_SUCCESS(rv, rv);
nsFileSpec filterFile;
rv = thisFolder->GetFileSpec(&filterFile);
NS_ENSURE_SUCCESS(rv, rv);
filterFile += "rules.dat";
nsCOMPtr<nsIMsgFilterService> filterService =
do_GetService(kMsgFilterServiceCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = filterService->OpenFilterList(&filterFile, getter_AddRefs(mFilterList));
NS_ENSURE_SUCCESS(rv, rv);
}
*aResult = mFilterList;
NS_IF_ADDREF(*aResult);
}
// use the convenience macros to implement the accessors
NS_IMPL_SERVERPREF_STR(nsMsgIncomingServer, HostName, "hostname");

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

@ -25,6 +25,7 @@
#include "nsIMsgIncomingServer.h"
#include "nsIPref.h"
#include "nsIMsgFilterList.h"
#include "msgCore.h"
#include "nsIFolder.h"
#include "nsCOMPtr.h"
@ -74,6 +75,7 @@ protected:
nsresult CreateRootFolder();
nsresult StorePassword(); // stuff the password in the single signon database
nsCOMPtr<nsIMsgFilterList> mFilterList;
// pref callback to clear the user prefs
static void clearPrefEnum(const char *aPref, void *aClosure);
};