1999-03-20 01:55:08 +03:00
|
|
|
/* -*- Mode: C++; 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.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "msgCore.h" // precompiled header...
|
|
|
|
|
|
|
|
#include "nsMsgFolder.h"
|
|
|
|
#include "nsMsgFolderFlags.h"
|
|
|
|
#include "prprf.h"
|
|
|
|
#include "nsMsgKeyArray.h"
|
|
|
|
#include "nsMsgDatabase.h"
|
1999-03-24 03:17:23 +03:00
|
|
|
#include "nsIDBFolderInfo.h"
|
1999-03-20 01:55:08 +03:00
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsIPref.h"
|
1999-04-07 06:50:25 +04:00
|
|
|
#include "nsIRDFService.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsRDFCID.h"
|
|
|
|
#include "nsXPIDLString.h"
|
1999-05-05 02:34:35 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-05-14 04:45:25 +04:00
|
|
|
#include "nsIMsgMailSession.h"
|
1999-05-27 01:59:45 +04:00
|
|
|
#include "nsMsgBaseCID.h"
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-04-07 06:50:25 +04:00
|
|
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
1999-05-14 04:45:25 +04:00
|
|
|
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
1999-04-07 02:47:12 +04:00
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
|
|
|
|
// that doesn't allow you to call ::nsISupports::GetIID() inside of a class
|
|
|
|
// that multiply inherits from nsISupports
|
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
|
|
|
|
nsMsgFolder::nsMsgFolder(void)
|
1999-05-05 06:42:12 +04:00
|
|
|
: nsRDFResource(),
|
|
|
|
mName(""),
|
|
|
|
mFlags(0),
|
1999-05-16 08:13:37 +04:00
|
|
|
mParent(nsnull),
|
1999-05-27 03:47:01 +04:00
|
|
|
mNumUnreadMessages(-1),
|
|
|
|
mNumTotalMessages(-1),
|
1999-03-20 01:55:08 +03:00
|
|
|
mDepth(0),
|
1999-06-12 02:10:42 +04:00
|
|
|
mPrefFlags(0),
|
|
|
|
mBiffState(nsMsgBiffState_NoMail),
|
|
|
|
mNumNewBiffMessages(0)
|
1999-05-16 08:13:37 +04:00
|
|
|
{
|
1999-03-20 01:55:08 +03:00
|
|
|
// NS_INIT_REFCNT(); done by superclass
|
|
|
|
|
|
|
|
|
|
|
|
mSemaphoreHolder = NULL;
|
|
|
|
|
|
|
|
#ifdef HAVE_DB
|
|
|
|
mLastMessageLoaded = nsMsgKey_None;
|
|
|
|
#endif
|
|
|
|
mNumPendingUnreadMessages = 0;
|
|
|
|
mNumPendingTotalMessages = 0;
|
1999-05-05 02:34:35 +04:00
|
|
|
NS_NewISupportsArray(getter_AddRefs(mSubFolders));
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
mIsCachable = TRUE;
|
1999-04-21 02:24:21 +04:00
|
|
|
|
1999-05-14 04:45:25 +04:00
|
|
|
mListeners = new nsVoidArray();
|
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsMsgFolder::~nsMsgFolder(void)
|
|
|
|
{
|
|
|
|
if(mSubFolders)
|
|
|
|
{
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 count;
|
|
|
|
nsresult rv = mSubFolders->Count(&count);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Count failed");
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
for (int i = count - 1; i >= 0; i--)
|
|
|
|
mSubFolders->RemoveElementAt(i);
|
|
|
|
}
|
|
|
|
|
1999-05-13 08:56:04 +04:00
|
|
|
delete mListeners;
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-05-08 00:21:47 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsMsgFolder, nsRDFResource)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsMsgFolder, nsRDFResource)
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (!aInstancePtr) return NS_ERROR_NULL_POINTER;
|
|
|
|
*aInstancePtr = nsnull;
|
|
|
|
if (aIID.Equals(nsIMsgFolder::GetIID()) || aIID.Equals(nsIFolder::GetIID()))
|
|
|
|
{
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIMsgFolder*, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*aInstancePtr)
|
|
|
|
{
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsRDFResource::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
typedef PRBool
|
|
|
|
(*nsArrayFilter)(nsISupports* element, void* data);
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
nsFilterBy(nsISupportsArray* array, nsArrayFilter filter, void* data,
|
|
|
|
nsISupportsArray* *result)
|
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
nsCOMPtr<nsISupportsArray> f;
|
|
|
|
nsresult rv = NS_NewISupportsArray(getter_AddRefs(f));
|
1999-03-20 01:55:08 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 cnt;
|
|
|
|
rv = array->Count(&cnt);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
for (PRUint32 i = 0; i < cnt; i++) {
|
1999-06-02 03:10:12 +04:00
|
|
|
nsCOMPtr<nsISupports> element = getter_AddRefs(array->ElementAt(i));
|
1999-03-20 01:55:08 +03:00
|
|
|
if (filter(element, data)) {
|
1999-05-05 06:42:12 +04:00
|
|
|
rv = f->AppendElement(element);
|
1999-03-20 01:55:08 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*result = f;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::AddUnique(nsISupports* element)
|
|
|
|
{
|
|
|
|
// XXX fix this
|
|
|
|
return mSubFolders->AppendElement(element);
|
|
|
|
}
|
|
|
|
|
1999-05-05 06:42:12 +04:00
|
|
|
// I'm assuming this means "Replace Subfolder"?
|
1999-03-20 01:55:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::ReplaceElement(nsISupports* element, nsISupports* newElement)
|
|
|
|
{
|
1999-05-05 06:42:12 +04:00
|
|
|
PRBool success=PR_FALSE;
|
|
|
|
PRInt32 location = mSubFolders->IndexOf(element);
|
|
|
|
if (location>0)
|
|
|
|
success = mSubFolders->ReplaceElementAt(newElement, location);
|
|
|
|
|
|
|
|
return success ? NS_OK : NS_ERROR_UNEXPECTED;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetSubFolders(nsIEnumerator* *result)
|
|
|
|
{
|
|
|
|
return mSubFolders->Enumerate(result);
|
|
|
|
}
|
|
|
|
|
1999-05-27 03:56:21 +04:00
|
|
|
NS_IMETHODIMP
|
1999-06-16 03:18:57 +04:00
|
|
|
nsMsgFolder::FindSubFolder(const char *subFolderName, nsIFolder **aFolder)
|
1999-05-27 03:56:21 +04:00
|
|
|
{
|
1999-06-16 03:18:57 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
|
|
|
|
|
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsString2 uri(eOneByte);
|
|
|
|
uri.Append(mURI);
|
|
|
|
uri.Append('/');
|
|
|
|
|
|
|
|
uri.Append(subFolderName);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRDFResource> res;
|
|
|
|
rv = rdf->GetResource(uri.GetBuffer(), getter_AddRefs(res));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFolder> folder(do_QueryInterface(res, &rv));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
if (aFolder)
|
|
|
|
{
|
|
|
|
*aFolder = folder;
|
|
|
|
NS_ADDREF(*aFolder);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-05-27 03:56:21 +04:00
|
|
|
}
|
|
|
|
|
1999-05-12 07:24:36 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetHasSubFolders(PRBool *_retval)
|
|
|
|
{
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 cnt;
|
|
|
|
nsresult rv = mSubFolders->Count(&cnt);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
*_retval = (cnt > 0);
|
1999-05-12 07:24:36 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::AddFolderListener(nsIFolderListener * listener)
|
|
|
|
{
|
1999-05-14 04:45:25 +04:00
|
|
|
mListeners->AppendElement(listener);
|
|
|
|
return NS_OK;
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::RemoveFolderListener(nsIFolderListener * listener)
|
|
|
|
{
|
1999-05-14 04:45:25 +04:00
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
mListeners->RemoveElement(listener);
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-05-08 00:21:47 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::SetParent(nsIFolder *parent)
|
|
|
|
{
|
|
|
|
//Don't addref due to ownership issues.
|
|
|
|
mParent = parent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetParent(nsIFolder **parent)
|
|
|
|
{
|
|
|
|
if(!parent)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*parent = mParent;
|
|
|
|
NS_IF_ADDREF(*parent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetMessages(nsIEnumerator* *result)
|
|
|
|
{
|
|
|
|
// XXX should this return an empty enumeration?
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-04-07 04:03:26 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetThreads(nsIEnumerator ** threadEnumerator)
|
|
|
|
{
|
|
|
|
// XXX should this return an empty enumeration?
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-04-07 06:50:25 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetThreadForMessage(nsIMessage *message, nsIMsgThread **thread)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-05-07 04:33:06 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::HasMessage(nsIMessage *message, PRBool *hasMessage)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::BuildFolderURL(char **url)
|
|
|
|
{
|
|
|
|
if(*url)
|
|
|
|
{
|
|
|
|
*url = NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_DB
|
|
|
|
// this class doesn't have a url
|
|
|
|
NS_IMETHODIMP nsMsgFolder::BuildUrl(nsMsgDatabase *db, nsMsgKey key, char ** url)
|
|
|
|
{
|
|
|
|
if(*url)
|
|
|
|
{
|
|
|
|
*url = NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-05-16 01:03:02 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetServer(nsIMsgIncomingServer ** aServer)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (!m_server) // if we haven't fetched the server yet....
|
|
|
|
{
|
|
|
|
NS_WITH_SERVICE(nsIMsgMailSession, session, kMsgMailSessionCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMsgAccountManager> accountManager;
|
|
|
|
rv = session->GetAccountManager(getter_AddRefs(accountManager));
|
|
|
|
if(NS_FAILED(rv)) return rv;
|
|
|
|
|
1999-06-22 07:03:48 +04:00
|
|
|
char * hostname = nsnull;
|
|
|
|
rv = GetHostname(&hostname);
|
1999-05-16 01:03:02 +04:00
|
|
|
if(NS_FAILED(rv)) return rv;
|
|
|
|
|
1999-06-22 07:03:48 +04:00
|
|
|
char * username = nsnull;
|
|
|
|
rv = GetUsername(&username);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsIMsgIncomingServer *server;
|
|
|
|
rv = accountManager->FindServer(username,
|
|
|
|
hostname,
|
|
|
|
GetIncomingServerType(),
|
|
|
|
&server);
|
|
|
|
PR_FREEIF(username);
|
1999-05-16 01:03:02 +04:00
|
|
|
PR_FREEIF(hostname);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-06-22 07:03:48 +04:00
|
|
|
|
|
|
|
m_server = server;
|
1999-05-16 01:03:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aServer)
|
|
|
|
{
|
|
|
|
*aServer = m_server;
|
|
|
|
NS_IF_ADDREF(*aServer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetPrettyName(char ** name)
|
|
|
|
{
|
|
|
|
char *cmName = mName.ToNewCString();
|
1999-05-05 02:34:35 +04:00
|
|
|
if(cmName)
|
|
|
|
{
|
|
|
|
if (name) *name = PL_strdup(cmName);
|
|
|
|
delete[] cmName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetPrettyName(char *name)
|
|
|
|
{
|
|
|
|
mName = name;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetName(char **name)
|
|
|
|
{
|
|
|
|
char *cmName = mName.ToNewCString();
|
1999-05-05 02:34:35 +04:00
|
|
|
if(cmName)
|
|
|
|
{
|
|
|
|
if (name) *name = PL_strdup(cmName);
|
|
|
|
delete[] cmName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetName(char * name)
|
|
|
|
{
|
|
|
|
mName = name;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-18 02:50:04 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetChildNamed(const char *name, nsISupports ** aChild)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-18 02:50:04 +04:00
|
|
|
NS_ASSERTION(aChild, "NULL child");
|
|
|
|
nsresult rv;
|
|
|
|
// will return nsnull if we can't find it
|
|
|
|
*aChild = nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder;
|
|
|
|
|
|
|
|
PRUint32 count;
|
|
|
|
rv = mSubFolders->Count(&count);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
for (PRUint32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
|
|
|
|
folder = do_QueryInterface(supports, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
{
|
|
|
|
char *folderName;
|
|
|
|
|
|
|
|
folder->GetName(&folderName);
|
|
|
|
// case-insensitive compare is probably LCD across OS filesystems
|
|
|
|
if (folderName && PL_strcasecmp(name, folderName)!=0)
|
|
|
|
{
|
|
|
|
*aChild = folder;
|
|
|
|
delete[] folderName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
delete[] folderName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetPrettiestName(char **name)
|
|
|
|
{
|
|
|
|
if (NS_SUCCEEDED(GetPrettyName(name)))
|
|
|
|
return NS_OK;
|
|
|
|
return GetName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PRBool
|
|
|
|
nsCanBeInFolderPane(nsISupports* element, void* data)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_PANE
|
|
|
|
nsIMsgFolder* subFolder = NS_STATIC_CAST(nsIMsgFolder*, element);
|
|
|
|
return subFolder->CanBeInFolderPane();
|
|
|
|
#else
|
|
|
|
return PR_TRUE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetVisibleSubFolders(nsIEnumerator* *result)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-05-05 02:34:35 +04:00
|
|
|
nsCOMPtr<nsISupportsArray> vFolders;
|
|
|
|
rv = nsFilterBy(mSubFolders, nsCanBeInFolderPane, nsnull, getter_AddRefs(vFolders));
|
1999-03-20 01:55:08 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
rv = vFolders->Enumerate(result);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_ADMINURL
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetAdminUrl(MWContext *context, MSG_AdminURLType type)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::HaveAdminUrl(MSG_AdminURLType type, PRBool *haveAdminUrl)
|
|
|
|
{
|
|
|
|
if(haveAdminUrl)
|
|
|
|
{
|
|
|
|
*haveAdminUrl = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return
|
|
|
|
NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetDeleteIsMoveToTrash(PRBool *deleteIsMoveToTrash)
|
|
|
|
{
|
|
|
|
if(deleteIsMoveToTrash)
|
|
|
|
{
|
|
|
|
*deleteIsMoveToTrash = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return
|
|
|
|
NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetShowDeletedMessages(PRBool *showDeletedMessages)
|
|
|
|
{
|
|
|
|
if(showDeletedMessages)
|
|
|
|
{
|
|
|
|
*showDeletedMessages = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return
|
|
|
|
NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::OnCloseFolder ()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::Delete ()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-27 03:47:01 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::DeleteSubFolders(nsISupportsArray *folders)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
PRUint32 count;
|
|
|
|
rv = folders->Count(&count);
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder;
|
|
|
|
for(PRUint32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(folders->ElementAt(i));
|
|
|
|
folder = do_QueryInterface(supports);
|
|
|
|
if(folder)
|
|
|
|
PropagateDelete(folder, PR_TRUE);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::PropagateDelete(nsIMsgFolder *folder, PRBool deleteStorage)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
nsresult status = NS_OK;
|
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
nsCOMPtr<nsIMsgFolder> child;
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
// first, find the folder we're looking to delete
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 cnt;
|
1999-05-27 03:47:01 +04:00
|
|
|
nsresult rv = mSubFolders->Count(&cnt);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
for (PRUint32 i = 0; i < cnt; i++)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
|
|
|
|
child = do_QueryInterface(supports, &status);
|
|
|
|
if(NS_SUCCEEDED(status))
|
1999-05-27 03:47:01 +04:00
|
|
|
{
|
|
|
|
if (folder == child.get())
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-27 03:47:01 +04:00
|
|
|
// maybe delete disk storage for it, and its subfolders
|
|
|
|
status = child->RecursiveDelete(deleteStorage);
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-05-27 03:47:01 +04:00
|
|
|
if (status == NS_OK)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-27 03:47:01 +04:00
|
|
|
|
|
|
|
//Remove from list of subfolders.
|
|
|
|
mSubFolders->RemoveElement(child);
|
|
|
|
//Remove self as parent
|
|
|
|
child->SetParent(nsnull);
|
|
|
|
nsCOMPtr<nsISupports> childSupports(do_QueryInterface(child));
|
|
|
|
if(childSupports)
|
|
|
|
NotifyItemDeleted(childSupports);
|
|
|
|
break;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
}
|
1999-05-27 03:47:01 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
status = child->PropagateDelete (folder, deleteStorage);
|
|
|
|
}
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::RecursiveDelete(PRBool deleteStorage)
|
|
|
|
{
|
|
|
|
// If deleteStorage is TRUE, recursively deletes disk storage for this folder
|
|
|
|
// and all its subfolders.
|
|
|
|
// Regardless of deleteStorage, always unlinks them from the children lists and
|
|
|
|
// frees memory for the subfolders but NOT for _this_
|
|
|
|
|
|
|
|
nsresult status = NS_OK;
|
|
|
|
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 cnt;
|
|
|
|
nsresult rv = mSubFolders->Count(&cnt);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
while (cnt > 0)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(0));
|
|
|
|
nsCOMPtr<nsIMsgFolder> child(do_QueryInterface(supports, &status));
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
if(NS_SUCCEEDED(status))
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
status = child->RecursiveDelete(deleteStorage); // recur
|
|
|
|
mSubFolders->RemoveElement(child); // unlink it from this's child list
|
1999-05-27 03:47:01 +04:00
|
|
|
child->SetParent(nsnull);
|
|
|
|
nsCOMPtr<nsISupports> childSupports(do_QueryInterface(child));
|
|
|
|
if(childSupports)
|
|
|
|
NotifyItemDeleted(childSupports);
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
1999-05-27 03:47:01 +04:00
|
|
|
cnt--;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// now delete the disk storage for _this_
|
|
|
|
if (deleteStorage && (status == NS_OK))
|
|
|
|
status = Delete();
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
1999-04-16 01:12:10 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::CreateSubfolder(const char *folderName)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::Rename(const char *name)
|
|
|
|
{
|
|
|
|
nsresult status = NS_OK;
|
|
|
|
status = SetName((char*)name);
|
|
|
|
//After doing a SetName we need to make sure that broadcasting this message causes a
|
|
|
|
//new sort to happen.
|
|
|
|
#ifdef HAVE_MASTER
|
|
|
|
if (m_master)
|
|
|
|
m_master->BroadcastFolderChanged(this);
|
|
|
|
#endif
|
|
|
|
return status;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::Adopt(nsIMsgFolder *srcFolder, PRUint32* outPos)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::ContainsChildNamed(const char *name, PRBool* containsChild)
|
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
nsCOMPtr<nsISupports> child;
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
if(containsChild)
|
|
|
|
{
|
|
|
|
*containsChild = PR_FALSE;
|
1999-05-05 02:34:35 +04:00
|
|
|
if(NS_SUCCEEDED(GetChildNamed(name, getter_AddRefs(child))))
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
*containsChild = child != nsnull;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-05-08 00:21:47 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::IsAncestorOf(nsIMsgFolder *child, PRBool *isAncestor)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-08 00:21:47 +04:00
|
|
|
if(!isAncestor)
|
1999-03-20 01:55:08 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-05-05 02:34:35 +04:00
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 count;
|
|
|
|
rv = mSubFolders->Count(&count);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
for (PRUint32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(supports, &rv));
|
|
|
|
if(NS_SUCCEEDED(rv))
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
if (folder.get() == child )
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-08 00:21:47 +04:00
|
|
|
*isAncestor = PR_TRUE;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
1999-05-08 00:21:47 +04:00
|
|
|
else
|
|
|
|
folder->IsAncestorOf(child, isAncestor);
|
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
1999-05-08 00:21:47 +04:00
|
|
|
if(*isAncestor)
|
1999-03-20 01:55:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-05-08 00:21:47 +04:00
|
|
|
*isAncestor = PR_FALSE;
|
1999-05-05 02:34:35 +04:00
|
|
|
return rv;
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GenerateUniqueSubfolderName(const char *prefix, nsIMsgFolder *otherFolder,
|
|
|
|
char **name)
|
|
|
|
{
|
|
|
|
if(!name)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
/* only try 256 times */
|
|
|
|
for (int count = 0; (count < 256); count++)
|
|
|
|
{
|
|
|
|
PRUint32 prefixSize = PL_strlen(prefix);
|
|
|
|
|
|
|
|
//allocate string big enough for prefix, 256, and '\0'
|
|
|
|
char *uniqueName = (char*)PR_MALLOC(prefixSize + 4);
|
1999-05-05 02:34:35 +04:00
|
|
|
if(!uniqueName)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-03-20 01:55:08 +03:00
|
|
|
PR_snprintf(uniqueName, prefixSize + 4, "%s%d",prefix,count);
|
|
|
|
PRBool containsChild;
|
|
|
|
PRBool otherContainsChild = PR_FALSE;
|
|
|
|
|
|
|
|
ContainsChildNamed(uniqueName, &containsChild);
|
|
|
|
if(otherFolder)
|
|
|
|
{
|
|
|
|
((nsIMsgFolder*)otherFolder)->ContainsChildNamed(uniqueName, &otherContainsChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!containsChild && !otherContainsChild)
|
|
|
|
{
|
|
|
|
*name = uniqueName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
PR_FREEIF(uniqueName);
|
|
|
|
}
|
|
|
|
*name = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetDepth(PRUint32 *depth)
|
|
|
|
{
|
|
|
|
if(!depth)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
*depth = mDepth;
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetDepth(PRUint32 depth)
|
|
|
|
{
|
|
|
|
mDepth = depth;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::UpdateSummaryTotals()
|
|
|
|
{
|
|
|
|
//We don't support this
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SummaryChanged()
|
|
|
|
{
|
|
|
|
UpdateSummaryTotals();
|
|
|
|
#ifdef HAVE_MASTER
|
|
|
|
if (mMaster)
|
|
|
|
mMaster->BroadcastFolderChanged(this);
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-05 06:42:12 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetNumUnread(PRBool deep, PRInt32 *numUnread)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
if(!numUnread)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
nsresult rv;
|
1999-03-20 01:55:08 +03:00
|
|
|
PRUint32 total = mNumUnreadMessages;
|
1999-05-05 02:34:35 +04:00
|
|
|
if (deep)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder;
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 count;
|
|
|
|
rv = mSubFolders->Count(&count);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
|
|
|
|
for (PRUint32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
|
|
|
|
folder = do_QueryInterface(supports, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
{
|
|
|
|
PRInt32 num;
|
|
|
|
folder->GetNumUnread(deep, &num);
|
|
|
|
if (num >= 0) // it's legal for counts to be negative if we don't know
|
|
|
|
total += num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
*numUnread = total;
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-05-05 06:42:12 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetTotalMessages(PRBool deep, PRInt32 *totalMessages)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
if(!totalMessages)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
nsresult rv;
|
1999-05-27 03:47:01 +04:00
|
|
|
PRInt32 total = mNumTotalMessages;
|
1999-05-05 02:34:35 +04:00
|
|
|
if (deep)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder;
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 count;
|
|
|
|
rv = mSubFolders->Count(&count);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
|
|
|
|
for (PRUint32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
|
|
|
|
folder = do_QueryInterface(supports, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
{
|
|
|
|
PRInt32 num;
|
|
|
|
folder->GetTotalMessages (deep, &num);
|
|
|
|
if (num >= 0) // it's legal for counts to be negative if we don't know
|
|
|
|
total += num;
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*totalMessages = total;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_DB
|
|
|
|
NS_IMETHOD GetTotalMessagesInDB(PRUint32 *totalMessages) const; // How many messages in database.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_PANE
|
|
|
|
virtual void MarkAllRead(MSG_Pane *pane, PRBool deep);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_DB
|
|
|
|
// 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
|
|
|
|
int32 GetNumPendingUnread(PRBool deep = FALSE) const;
|
|
|
|
int32 GetNumPendingTotalMessages(PRBool deep = FALSE) const;
|
|
|
|
|
|
|
|
void ChangeNumPendingUnread(int32 delta);
|
|
|
|
void ChangeNumPendingTotalMessages(int32 delta);
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetFolderPrefFlags(PRUint32 flags)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetFolderPrefFlags(PRUint32 *flags)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetLastMessageLoaded(nsMsgKey lastMessageLoaded)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetLastMessageLoaded()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetFlag(PRUint32 flag)
|
|
|
|
{
|
|
|
|
// OnFlagChange can be expensive, so don't call it if we don't need to
|
|
|
|
PRBool flagSet;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
if(!NS_SUCCEEDED(rv = GetFlag(flag, &flagSet)))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
if (!flagSet)
|
|
|
|
{
|
|
|
|
mFlags |= flag;
|
|
|
|
OnFlagChange(flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::ClearFlag(PRUint32 flag)
|
|
|
|
{
|
|
|
|
// OnFlagChange can be expensive, so don't call it if we don't need to
|
|
|
|
PRBool flagSet;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
if(!NS_SUCCEEDED(rv = GetFlag(flag, &flagSet)))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
if (!flagSet)
|
|
|
|
{
|
|
|
|
mFlags &= ~flag;
|
|
|
|
OnFlagChange (flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetFlag(PRUint32 flag, PRBool *_retval)
|
|
|
|
{
|
|
|
|
*_retval = ((mFlags & flag) != 0);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::ToggleFlag(PRUint32 flag)
|
|
|
|
{
|
|
|
|
mFlags ^= flag;
|
|
|
|
OnFlagChange (flag);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::OnFlagChange(PRUint32 flag)
|
|
|
|
{
|
|
|
|
//Still need to implement
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetFlags(PRUint32 *_retval)
|
|
|
|
{
|
|
|
|
*_retval = mFlags;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetFoldersWithFlag(PRUint32 flags, nsIMsgFolder **result,
|
1999-05-05 02:34:35 +04:00
|
|
|
PRUint32 resultsize, PRUint32 *numFolders)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
PRUint32 num = 0;
|
|
|
|
if ((flags & mFlags) == flags) {
|
|
|
|
if (result && (num < resultsize)) {
|
|
|
|
result[num] = this;
|
1999-06-22 03:24:29 +04:00
|
|
|
NS_IF_ADDREF(result[num]);
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
num++;
|
1999-05-05 02:34:35 +04:00
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder;
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 cnt;
|
|
|
|
rv = mSubFolders->Count(&cnt);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
for (PRUint32 i=0; i < cnt; i++) {
|
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
|
|
|
|
folder = do_QueryInterface(supports, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
{
|
|
|
|
// CAREFUL! if NULL is passed in for result then the caller
|
|
|
|
// still wants the full count! Otherwise, the result should be at most the
|
|
|
|
// number that the caller asked for.
|
|
|
|
PRUint32 numSubFolders;
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
folder->GetFoldersWithFlag(flags, NULL, 0, &numSubFolders);
|
|
|
|
num += numSubFolders;
|
|
|
|
}
|
|
|
|
else if (num < resultsize)
|
|
|
|
{
|
|
|
|
folder->GetFoldersWithFlag(flags, result + num, resultsize - num, &numSubFolders);
|
|
|
|
num += numSubFolders;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-05-05 02:34:35 +04:00
|
|
|
*numFolders = num;
|
1999-03-20 01:55:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetExpansionArray(nsISupportsArray *expansionArray)
|
|
|
|
{
|
|
|
|
// the application of flags in GetExpansionArray is subtly different
|
|
|
|
// than in GetFoldersWithFlag
|
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
nsresult rv;
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 cnt;
|
|
|
|
rv = mSubFolders->Count(&cnt);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
for (PRUint32 i = 0; i < cnt; i++)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-16 08:13:37 +04:00
|
|
|
PRUint32 cnt2;
|
|
|
|
rv = expansionArray->Count(&cnt2);
|
1999-05-13 08:56:04 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-05-16 08:13:37 +04:00
|
|
|
expansionArray->InsertElementAt(folder, cnt2);
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 flags;
|
|
|
|
folder->GetFlags(&flags);
|
|
|
|
if (!(flags & MSG_FOLDER_FLAG_ELIDED))
|
|
|
|
folder->GetExpansionArray(expansionArray);
|
|
|
|
}
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_PANE
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetFlagInAllFolderPanes(PRUInt32 which)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NET
|
|
|
|
NS_IMETHODIMP nsMsgFolder::EscapeMessageId(const char *messageId, const char **escapeMessageID)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetExpungedBytesCount(PRUint32 *count)
|
|
|
|
{
|
|
|
|
if(!count)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*count = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetDeletable(PRBool *deletable)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!deletable)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*deletable = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetCanCreateChildren(PRBool *canCreateChildren)
|
|
|
|
{
|
|
|
|
if(!canCreateChildren)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*canCreateChildren = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetCanBeRenamed(PRBool *canBeRenamed)
|
|
|
|
{
|
|
|
|
if(!canBeRenamed)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*canBeRenamed = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetRequiresCleanup(PRBool *requiredCleanup)
|
|
|
|
{
|
|
|
|
if(!requiredCleanup)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*requiredCleanup = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::ClearRequiresCleanup()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_PANE
|
|
|
|
NS_IMETHODIMP nsMsgFolder::CanBeInFolderPane(PRBool *canBeInFolderPane)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetKnowsSearchNntpExtension(PRBool *knowsExtension)
|
|
|
|
{
|
|
|
|
if(!knowsExtension)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*knowsExtension = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetAllowsPosting(PRBool *allowsPosting)
|
|
|
|
{
|
|
|
|
if(!allowsPosting)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*allowsPosting = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::DisplayRecipients(PRBool *displayRecipients)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
*displayRecipients = PR_FALSE;
|
|
|
|
|
|
|
|
if (mFlags & MSG_FOLDER_FLAG_SENTMAIL && !(mFlags & MSG_FOLDER_FLAG_INBOX))
|
|
|
|
*displayRecipients = PR_TRUE;
|
|
|
|
else if (mFlags & MSG_FOLDER_FLAG_QUEUE)
|
|
|
|
*displayRecipients = PR_TRUE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Only mail folders can be FCC folders
|
|
|
|
if (mFlags & MSG_FOLDER_FLAG_MAIL || mFlags & MSG_FOLDER_FLAG_IMAPBOX)
|
|
|
|
{
|
|
|
|
// There's one FCC folder for sent mail, and one for sent news
|
|
|
|
nsIMsgFolder *fccFolders[2];
|
|
|
|
int numFccFolders = 0;
|
|
|
|
#ifdef HAVE_MASTER
|
|
|
|
m_master->GetFolderTree()->GetFoldersWithFlag (MSG_FOLDER_FLAG_SENTMAIL, fccFolders, 2, &numFccFolders);
|
|
|
|
#endif
|
|
|
|
for (int i = 0; i < numFccFolders; i++)
|
|
|
|
{
|
1999-05-08 00:21:47 +04:00
|
|
|
PRBool isAncestor;
|
|
|
|
if(NS_SUCCEEDED(rv = fccFolders[i]->IsAncestorOf(this, &isAncestor)))
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-05-08 00:21:47 +04:00
|
|
|
if (isAncestor)
|
1999-03-20 01:55:08 +03:00
|
|
|
*displayRecipients = PR_TRUE;
|
|
|
|
}
|
|
|
|
NS_RELEASE(fccFolders[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-03-24 02:19:58 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::AcquireSemaphore(nsISupports *semHolder)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-03-24 02:19:58 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
if (mSemaphoreHolder == NULL)
|
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
mSemaphoreHolder = semHolder; //Don't AddRef due to ownership issues.
|
1999-03-24 02:19:58 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rv = NS_MSG_FOLDER_BUSY;
|
|
|
|
|
|
|
|
return rv;
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-03-24 02:19:58 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::ReleaseSemaphore(nsISupports *semHolder)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-03-24 02:19:58 +03:00
|
|
|
if (!mSemaphoreHolder || mSemaphoreHolder == semHolder)
|
|
|
|
{
|
|
|
|
mSemaphoreHolder = NULL;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
1999-03-24 02:19:58 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::TestSemaphore(nsISupports *semHolder, PRBool *result)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-03-24 02:19:58 +03:00
|
|
|
if(!result)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*result = (mSemaphoreHolder == semHolder);
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-03-24 02:19:58 +03:00
|
|
|
return NS_OK;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::IsLocked(PRBool *isLocked)
|
|
|
|
{
|
|
|
|
*isLocked = mSemaphoreHolder != NULL;
|
1999-03-24 02:19:58 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
#ifdef HAVE_PANE
|
|
|
|
MWContext *GetFolderPaneContext();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_MASTER
|
|
|
|
MSG_Master *GetMaster() {return m_master;}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CACHE
|
|
|
|
NS_IMETHODIMP nsMsgFolder::WriteToCache(XP_File)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::ReadFromCache(char *)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::IsCachable(PRBool *isCachable)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SkipCacheTokens(char **ppBuf, int numTokens)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetRelativePathName(char **pathName)
|
|
|
|
{
|
|
|
|
if(!pathName)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*pathName = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetSizeOnDisk(PRUint32 *size)
|
|
|
|
{
|
|
|
|
if(!size)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*size = 0;
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_NET
|
|
|
|
NS_IMETHODIMP nsMsgFolder::ShouldPerformOperationOffline(PRBool *performOffline)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DOES_FOLDEROPERATIONS
|
|
|
|
NS_IMETHODIMP nsMsgFolder::DownloadToTempFileAndUpload(MessageCopyInfo *copyInfo,
|
|
|
|
nsMsgKeyArray &keysToSave,
|
|
|
|
MSG_FolderInfo *dstFolder,
|
|
|
|
nsMsgDatabase *sourceDB)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::UpdateMoveCopyStatus(MWContext *context, PRBool isMove, int32 curMsgCount, int32 totMessages)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::RememberPassword(const char *password)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetRememberedPassword(char ** password)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!password)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*password = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *needsAuthenticate)
|
|
|
|
{
|
|
|
|
if(!needsAuthenticate)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*needsAuthenticate = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-22 07:03:48 +04:00
|
|
|
#if 0
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetUsername(char **userName)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
if(!userName)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*userName = "";
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-22 07:03:48 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetHostname(char **hostName)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
if(!hostName)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*hostName = "";
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-06-22 07:03:48 +04:00
|
|
|
#endif
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-05-07 04:33:06 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetNewMessages()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-06-12 02:10:42 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetBiffState(PRUint32 *aBiffState)
|
|
|
|
{
|
|
|
|
if(!aBiffState)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
*aBiffState = mBiffState;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetBiffState(PRUint32 aBiffState)
|
|
|
|
{
|
|
|
|
if(mBiffState != aBiffState)
|
|
|
|
{
|
|
|
|
PRUint32 oldBiffState = mBiffState;
|
|
|
|
mBiffState = aBiffState;
|
|
|
|
nsCOMPtr<nsISupports> supports;
|
|
|
|
if(NS_SUCCEEDED(QueryInterface(kISupportsIID, getter_AddRefs(supports))))
|
|
|
|
NotifyPropertyFlagChanged(supports, "BiffState", oldBiffState, mBiffState);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetNumNewMessages(PRInt32 *aNumNewMessages)
|
|
|
|
{
|
|
|
|
if(!aNumNewMessages)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*aNumNewMessages = mNumNewBiffMessages;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetNumNewMessages(PRInt32 aNumNewMessages)
|
|
|
|
{
|
|
|
|
if(aNumNewMessages != mNumNewBiffMessages)
|
|
|
|
{
|
|
|
|
PRInt32 oldNumMessages = mNumNewBiffMessages;
|
|
|
|
mNumNewBiffMessages = aNumNewMessages;
|
|
|
|
|
|
|
|
char *oldNumMessagesStr = PR_smprintf("%d", oldNumMessages);
|
|
|
|
char *newNumMessagesStr = PR_smprintf("%d",aNumNewMessages);
|
|
|
|
NotifyPropertyChanged("NumNewBiffMessages", oldNumMessagesStr, newNumMessagesStr);
|
|
|
|
PR_smprintf_free(oldNumMessagesStr);
|
|
|
|
PR_smprintf_free(newNumMessagesStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetNewMessagesNotificationDescription(PRUnichar * *aDescription)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsString description("");
|
|
|
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
|
|
|
rv = GetServer(getter_AddRefs(server));
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
{
|
|
|
|
char *serverName = nsnull;
|
|
|
|
rv = server->GetPrettyName(&serverName);
|
|
|
|
if(NS_SUCCEEDED(rv) && PL_strcmp(serverName, ""))
|
|
|
|
description = serverName;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(serverName)
|
|
|
|
PR_Free(serverName);
|
|
|
|
rv = server->GetHostName(&serverName);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
description = serverName;
|
|
|
|
}
|
|
|
|
if(serverName)
|
|
|
|
PR_Free(serverName);
|
|
|
|
|
|
|
|
}
|
|
|
|
*aDescription = description.ToNewUnicode();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-15 02:22:51 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetRootFolder(nsIMsgFolder * *aRootFolder)
|
|
|
|
{
|
|
|
|
if(!aRootFolder)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
|
|
|
rv = GetServer(getter_AddRefs(server));
|
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFolder> aRoot;
|
|
|
|
rv = server->GetRootFolder(getter_AddRefs(aRoot));
|
|
|
|
|
|
|
|
if(NS_FAILED(rv) || !aRoot)
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
return aRoot->QueryInterface(nsIMsgFolder::GetIID(), (void**)aRootFolder);
|
|
|
|
}
|
|
|
|
|
1999-06-22 02:56:18 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetMsgDatabase(nsIMsgDatabase** aMsgDatabase)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-06-25 07:56:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetPath(nsIFileSpec * *aPath)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-06-26 22:22:55 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::CopyMessages(nsIMsgFolder* srcFolder,
|
|
|
|
nsISupportsArray *messages,
|
|
|
|
PRBool isMove,
|
|
|
|
nsITransactionManager* txnMgr)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::CopyFileMessage(nsIFileSpec* fileSpec,
|
|
|
|
nsIMessage* messageToReplace,
|
|
|
|
PRBool isDraft,
|
|
|
|
nsISupports* aSupport,
|
|
|
|
nsITransactionManager* txnMgr)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-04-21 02:24:21 +04:00
|
|
|
nsresult nsMsgFolder::NotifyPropertyChanged(char *property, char *oldValue, char* newValue)
|
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
nsCOMPtr<nsISupports> supports;
|
|
|
|
if(NS_SUCCEEDED(QueryInterface(kISupportsIID, getter_AddRefs(supports))))
|
1999-04-21 02:24:21 +04:00
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
PRInt32 i;
|
1999-04-21 02:24:21 +04:00
|
|
|
for(i = 0; i < mListeners->Count(); i++)
|
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
//Folderlistener's aren't refcounted.
|
|
|
|
nsIFolderListener* listener =(nsIFolderListener*)mListeners->ElementAt(i);
|
1999-04-21 02:24:21 +04:00
|
|
|
listener->OnItemPropertyChanged(supports, property, oldValue, newValue);
|
|
|
|
}
|
1999-05-14 04:45:25 +04:00
|
|
|
|
|
|
|
//Notify listeners who listen to every folder
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
mailSession->NotifyFolderItemPropertyChanged(supports, property, oldValue, newValue);
|
|
|
|
|
1999-04-21 02:24:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-05-14 04:45:25 +04:00
|
|
|
nsresult nsMsgFolder::NotifyPropertyFlagChanged(nsISupports *item, char *property, PRUint32 oldValue,
|
|
|
|
PRUint32 newValue)
|
|
|
|
{
|
|
|
|
PRInt32 i;
|
|
|
|
for(i = 0; i < mListeners->Count(); i++)
|
|
|
|
{
|
|
|
|
//Folderlistener's aren't refcounted.
|
|
|
|
nsIFolderListener *listener = (nsIFolderListener*)mListeners->ElementAt(i);
|
|
|
|
listener->OnItemPropertyFlagChanged(item, property, oldValue, newValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Notify listeners who listen to every folder
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
mailSession->NotifyFolderItemPropertyFlagChanged(item, property, oldValue, newValue);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-21 02:24:21 +04:00
|
|
|
nsresult nsMsgFolder::NotifyItemAdded(nsISupports *item)
|
|
|
|
{
|
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
PRInt32 i;
|
1999-04-21 02:24:21 +04:00
|
|
|
for(i = 0; i < mListeners->Count(); i++)
|
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
//Folderlistener's aren't refcounted.
|
1999-04-21 02:24:21 +04:00
|
|
|
nsIFolderListener *listener = (nsIFolderListener*)mListeners->ElementAt(i);
|
|
|
|
listener->OnItemAdded(this, item);
|
|
|
|
}
|
|
|
|
|
1999-05-14 04:45:25 +04:00
|
|
|
//Notify listeners who listen to every folder
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
mailSession->NotifyFolderItemAdded(this, item);
|
|
|
|
|
1999-04-21 02:24:21 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsMsgFolder::NotifyItemDeleted(nsISupports *item)
|
|
|
|
{
|
|
|
|
|
1999-05-05 02:34:35 +04:00
|
|
|
PRInt32 i;
|
1999-04-21 02:24:21 +04:00
|
|
|
for(i = 0; i < mListeners->Count(); i++)
|
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
//Folderlistener's aren't refcounted.
|
1999-04-21 02:24:21 +04:00
|
|
|
nsIFolderListener *listener = (nsIFolderListener*)mListeners->ElementAt(i);
|
|
|
|
listener->OnItemRemoved(this, item);
|
|
|
|
}
|
1999-05-14 04:45:25 +04:00
|
|
|
//Notify listeners who listen to every folder
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
mailSession->NotifyFolderItemDeleted(this, item);
|
1999-04-21 02:24:21 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-04-20 01:39:29 +04:00
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
nsresult
|
|
|
|
nsGetMailFolderSeparator(nsString& result)
|
|
|
|
{
|
|
|
|
static char* gMailFolderSep = nsnull; // never freed
|
|
|
|
|
|
|
|
if (gMailFolderSep == nsnull) {
|
|
|
|
gMailFolderSep = PR_smprintf(".sbd");
|
|
|
|
if (gMailFolderSep == nsnull)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
result = gMailFolderSep;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|