1999-03-20 01:55:08 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03: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-20 01:55:08 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03: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-20 01:55:08 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-03-20 01:55:08 +03:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-02-06 06:18:27 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
1999-03-20 01:55:08 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "msgCore.h" // precompiled header...
|
|
|
|
|
|
|
|
#include "prprf.h"
|
2000-05-25 07:49:10 +04:00
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
#include "nsISupportsArray.h"
|
1999-04-07 06:50:25 +04:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsXPIDLString.h"
|
1999-05-05 02:34:35 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2000-05-25 07:49:10 +04:00
|
|
|
#include "nsAutoLock.h"
|
2000-06-03 13:46:12 +04:00
|
|
|
#include "nsMemory.h"
|
2000-05-25 07:49:10 +04:00
|
|
|
#include "nsIStringBundle.h"
|
|
|
|
|
|
|
|
#include "nsMsgFolder.h"
|
|
|
|
#include "nsMsgFolderFlags.h"
|
|
|
|
#include "nsIMessage.h"
|
|
|
|
#include "nsMsgKeyArray.h"
|
|
|
|
#include "nsMsgDatabase.h"
|
|
|
|
#include "nsIDBFolderInfo.h"
|
2000-01-08 06:38:45 +03:00
|
|
|
#include "nsIMsgAccountManager.h"
|
2000-03-14 16:37:54 +03:00
|
|
|
#include "nsIMsgIdentity.h"
|
1999-05-27 01:59:45 +04:00
|
|
|
#include "nsMsgBaseCID.h"
|
2000-01-05 01:25:28 +03:00
|
|
|
#include "nsMsgUtils.h" // for NS_MsgHashIfNecessary()
|
2000-03-28 08:58:05 +04:00
|
|
|
|
2000-05-25 07:49:10 +04:00
|
|
|
#include "nsIPref.h"
|
|
|
|
|
|
|
|
#include "nsIRDFService.h"
|
|
|
|
#include "nsRDFCID.h"
|
|
|
|
|
2000-02-03 06:44:22 +03:00
|
|
|
#include "nsIIOService.h"
|
2000-05-25 07:49:10 +04:00
|
|
|
#include "nsIURL.h"
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-10-13 08:12:06 +04:00
|
|
|
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
|
|
|
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
2000-03-31 02:50:54 +04:00
|
|
|
static NS_DEFINE_CID(kMsgFolderListenerManagerCID, NS_MSGMAILSESSION_CID);
|
2000-02-03 06:44:22 +03:00
|
|
|
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
2000-05-25 07:49:10 +04:00
|
|
|
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
|
|
|
|
|
|
|
nsrefcnt nsMsgFolder::gInstanceCount = 0;
|
1999-04-07 02:47:12 +04:00
|
|
|
|
2000-05-25 07:49:10 +04:00
|
|
|
PRUnichar *nsMsgFolder::kInboxName = 0;
|
|
|
|
PRUnichar *nsMsgFolder::kTrashName = 0;
|
|
|
|
PRUnichar *nsMsgFolder::kSentName = 0;
|
|
|
|
PRUnichar *nsMsgFolder::kDraftsName = 0;
|
|
|
|
PRUnichar *nsMsgFolder::kTemplatesName = 0;
|
2000-05-25 08:53:24 +04:00
|
|
|
PRUnichar *nsMsgFolder::kUnsentName = 0;
|
2000-01-14 12:01:39 +03:00
|
|
|
|
|
|
|
nsIAtom * nsMsgFolder::kTotalMessagesAtom = nsnull;
|
|
|
|
nsIAtom * nsMsgFolder::kBiffStateAtom = nsnull;
|
2000-06-23 07:19:17 +04:00
|
|
|
nsIAtom * nsMsgFolder::kNewMessagesAtom = nsnull;
|
2000-01-26 04:21:24 +03:00
|
|
|
nsIAtom * nsMsgFolder::kNumNewBiffMessagesAtom = nsnull;
|
2000-01-14 12:01:39 +03:00
|
|
|
nsIAtom * nsMsgFolder::kTotalUnreadMessagesAtom = nsnull;
|
|
|
|
nsIAtom * nsMsgFolder::kFlaggedAtom = nsnull;
|
|
|
|
nsIAtom * nsMsgFolder::kStatusAtom = nsnull;
|
2000-01-26 04:21:24 +03:00
|
|
|
nsIAtom * nsMsgFolder::kNameAtom = nsnull;
|
1999-03-20 01:55:08 +03:00
|
|
|
|
2000-05-25 07:49:10 +04:00
|
|
|
#ifdef MSG_FASTER_URI_PARSING
|
|
|
|
nsCOMPtr<nsIURL> nsMsgFolder::mParsingURL;
|
|
|
|
PRBool nsMsgFolder::mParsingURLInUse=PR_FALSE;
|
|
|
|
#endif
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
nsMsgFolder::nsMsgFolder(void)
|
1999-05-05 06:42:12 +04:00
|
|
|
: nsRDFResource(),
|
|
|
|
mFlags(0),
|
1999-05-27 03:47:01 +04:00
|
|
|
mNumUnreadMessages(-1),
|
|
|
|
mNumTotalMessages(-1),
|
2000-05-15 18:55:22 +04:00
|
|
|
mExpungedBytes(0),
|
2000-03-15 09:26:31 +03:00
|
|
|
mInitializedFromCache(PR_FALSE),
|
1999-08-21 02:41:38 +04:00
|
|
|
mBiffState(nsMsgBiffState_NoMail),
|
|
|
|
mNumNewBiffMessages(0),
|
2000-01-26 04:21:24 +03:00
|
|
|
mHaveParsedURI(PR_FALSE),
|
1999-12-04 06:00:22 +03:00
|
|
|
mIsServerIsValid(PR_FALSE),
|
2000-02-16 03:39:23 +03:00
|
|
|
mIsServer(PR_FALSE),
|
2000-03-31 02:50:54 +04:00
|
|
|
mDeleteIsMoveToTrash(PR_TRUE),
|
|
|
|
mBaseMessageURI(nsnull)
|
1999-05-16 08:13:37 +04:00
|
|
|
{
|
1999-03-20 01:55:08 +03:00
|
|
|
// NS_INIT_REFCNT(); done by superclass
|
|
|
|
|
|
|
|
mSemaphoreHolder = NULL;
|
|
|
|
|
|
|
|
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
|
|
|
|
1999-09-08 07:08:27 +04:00
|
|
|
mIsCachable = PR_TRUE;
|
1999-04-21 02:24:21 +04:00
|
|
|
|
1999-05-14 04:45:25 +04:00
|
|
|
mListeners = new nsVoidArray();
|
2000-01-05 01:25:28 +03:00
|
|
|
|
2000-01-14 12:01:39 +03:00
|
|
|
if (gInstanceCount == 0) {
|
|
|
|
kBiffStateAtom = NS_NewAtom("BiffState");
|
2000-06-23 07:19:17 +04:00
|
|
|
kNewMessagesAtom = NS_NewAtom("NewMessages");
|
2000-01-14 12:01:39 +03:00
|
|
|
kNumNewBiffMessagesAtom = NS_NewAtom("NumNewBiffMessages");
|
2000-01-26 04:21:24 +03:00
|
|
|
kNameAtom = NS_NewAtom("Name");
|
2000-01-14 12:01:39 +03:00
|
|
|
kTotalUnreadMessagesAtom = NS_NewAtom("TotalUnreadMessages");
|
|
|
|
kTotalMessagesAtom = NS_NewAtom("TotalMessages");
|
|
|
|
kStatusAtom = NS_NewAtom("Status");
|
|
|
|
kFlaggedAtom = NS_NewAtom("Flagged");
|
|
|
|
|
2000-05-25 07:49:10 +04:00
|
|
|
initializeStrings();
|
|
|
|
|
|
|
|
#ifdef MSG_FASTER_URI_PARSING
|
|
|
|
mParsingURL = do_CreateInstance(kStandardUrlCID);
|
|
|
|
#endif
|
2000-01-14 12:01:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
gInstanceCount++;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsMsgFolder::~nsMsgFolder(void)
|
|
|
|
{
|
2000-03-28 08:58:05 +04:00
|
|
|
nsresult rv;
|
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
if(mSubFolders)
|
|
|
|
{
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 count;
|
2000-03-28 08:58:05 +04:00
|
|
|
rv = mSubFolders->Count(&count);
|
1999-05-13 08:56:04 +04:00
|
|
|
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
|
|
|
|
2000-02-16 03:39:23 +03:00
|
|
|
if(mBaseMessageURI)
|
|
|
|
nsCRT::free(mBaseMessageURI);
|
|
|
|
|
2000-01-14 12:01:39 +03:00
|
|
|
gInstanceCount--;
|
|
|
|
if (gInstanceCount <= 0) {
|
2000-01-26 04:21:24 +03:00
|
|
|
NS_IF_RELEASE(kTotalMessagesAtom);
|
2000-01-14 12:01:39 +03:00
|
|
|
NS_IF_RELEASE(kBiffStateAtom);
|
2000-06-23 07:19:17 +04:00
|
|
|
NS_IF_RELEASE(kNewMessagesAtom);
|
2000-01-14 12:01:39 +03:00
|
|
|
NS_IF_RELEASE(kNumNewBiffMessagesAtom);
|
2000-01-26 04:21:24 +03:00
|
|
|
NS_IF_RELEASE(kTotalUnreadMessagesAtom);
|
|
|
|
NS_IF_RELEASE(kFlaggedAtom);
|
|
|
|
NS_IF_RELEASE(kStatusAtom);
|
|
|
|
NS_IF_RELEASE(kNameAtom);
|
2000-05-25 07:49:10 +04:00
|
|
|
|
|
|
|
CRTFREEIF(kInboxName);
|
|
|
|
CRTFREEIF(kTrashName);
|
|
|
|
CRTFREEIF(kSentName);
|
|
|
|
CRTFREEIF(kDraftsName);
|
|
|
|
CRTFREEIF(kTemplatesName);
|
2000-05-25 08:53:24 +04:00
|
|
|
CRTFREEIF(kUnsentName);
|
2000-05-25 07:49:10 +04:00
|
|
|
|
|
|
|
#ifdef MSG_FASTER_URI_PARSING
|
|
|
|
mParsingURL = nsnull;
|
|
|
|
#endif
|
2000-01-14 12:01:39 +03:00
|
|
|
}
|
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)
|
|
|
|
|
2000-05-15 03:16:25 +04:00
|
|
|
NS_IMPL_QUERY_INTERFACE_INHERITED3(nsMsgFolder, nsRDFResource,
|
|
|
|
nsIMsgFolder,
|
|
|
|
nsIFolder,
|
|
|
|
nsISupportsWeakReference)
|
1999-03-20 01:55:08 +03:00
|
|
|
|
2000-05-25 07:49:10 +04:00
|
|
|
nsresult
|
|
|
|
nsMsgFolder::initializeStrings()
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIStringBundleService> bundleService =
|
|
|
|
do_GetService(kStringBundleServiceCID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> bundle;
|
|
|
|
rv = bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
|
|
|
|
nsnull,
|
|
|
|
getter_AddRefs(bundle));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
bundle->GetStringFromName(NS_ConvertASCIItoUCS2("inboxFolderName").GetUnicode(),
|
|
|
|
&kInboxName);
|
|
|
|
bundle->GetStringFromName(NS_ConvertASCIItoUCS2("trashFolderName").GetUnicode(),
|
|
|
|
&kTrashName);
|
|
|
|
bundle->GetStringFromName(NS_ConvertASCIItoUCS2("sentFolderName").GetUnicode(),
|
|
|
|
&kSentName);
|
|
|
|
bundle->GetStringFromName(NS_ConvertASCIItoUCS2("draftsFolderName").GetUnicode(),
|
|
|
|
&kDraftsName);
|
|
|
|
bundle->GetStringFromName(NS_ConvertASCIItoUCS2("templatesFolderName").GetUnicode(),
|
|
|
|
&kTemplatesName);
|
2000-05-25 08:53:24 +04:00
|
|
|
bundle->GetStringFromName(NS_ConvertASCIItoUCS2("unsentFolderName").GetUnicode(),
|
|
|
|
&kUnsentName);
|
2000-05-25 07:49:10 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-21 02:41:38 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::Init(const char* aURI)
|
|
|
|
{
|
1999-10-22 05:02:08 +04:00
|
|
|
// for now, just initialize everything during Init()
|
1999-08-21 02:41:38 +04:00
|
|
|
|
1999-10-22 05:02:08 +04:00
|
|
|
nsresult rv;
|
1999-08-21 02:41:38 +04:00
|
|
|
|
1999-10-22 05:02:08 +04:00
|
|
|
rv = nsRDFResource::Init(aURI);
|
2000-02-16 03:39:23 +03:00
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
rv = CreateBaseMessageURI(aURI);
|
1999-08-21 02:41:38 +04:00
|
|
|
|
1999-10-22 05:02:08 +04:00
|
|
|
return NS_OK;
|
1999-08-21 02:41:38 +04:00
|
|
|
}
|
|
|
|
|
2000-02-16 03:39:23 +03:00
|
|
|
nsresult nsMsgFolder::CreateBaseMessageURI(const char *aURI)
|
|
|
|
{
|
|
|
|
//Each folder needs to implement this.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-14 23:36:22 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::Shutdown(PRBool shutdownChildren)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-10-21 01:58:21 +04:00
|
|
|
|
|
|
|
// nsICollection methods:
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::Count(PRUint32 *result) {
|
|
|
|
return mSubFolders->Count(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetElementAt(PRUint32 i, nsISupports* *result) {
|
|
|
|
return mSubFolders->GetElementAt(i, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::QueryElementAt(PRUint32 i, const nsIID & iid, void * *result) {
|
|
|
|
return mSubFolders->QueryElementAt(i, iid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::SetElementAt(PRUint32 i, nsISupports* value) {
|
|
|
|
return mSubFolders->SetElementAt(i, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::AppendElement(nsISupports *aElement) {
|
|
|
|
return mSubFolders->AppendElement(aElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::RemoveElement(nsISupports *aElement) {
|
|
|
|
return mSubFolders->RemoveElement(aElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::Enumerate(nsIEnumerator* *result) {
|
|
|
|
// nsMsgFolders only have subfolders, no message elements
|
|
|
|
return mSubFolders->Enumerate(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::Clear(void) {
|
|
|
|
return mSubFolders->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetURI(char* *name) {
|
|
|
|
return nsRDFResource::GetValue(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
1999-10-22 05:02:08 +04:00
|
|
|
// XXX use necko here
|
2000-05-16 06:17:46 +04:00
|
|
|
nsCAutoString uri;
|
1999-06-16 03:18:57 +04:00
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-01-27 01:53:55 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::SetParent(nsIFolder *aParent)
|
1999-05-08 00:21:47 +04:00
|
|
|
{
|
2000-03-25 23:41:26 +03:00
|
|
|
mParent = getter_AddRefs(NS_GetWeakReference(aParent));
|
2000-03-28 08:58:05 +04:00
|
|
|
|
|
|
|
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;
|
2000-03-31 02:50:54 +04:00
|
|
|
rv = parentMsgFolder->GetServer(getter_AddRefs(server));
|
2000-03-28 08:58:05 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && server)
|
|
|
|
mServer = getter_AddRefs(NS_GetWeakReference(server));
|
|
|
|
}
|
|
|
|
}
|
2000-03-25 23:41:26 +03:00
|
|
|
|
1999-05-08 00:21:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-27 01:53:55 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetParent(nsIFolder **aParent)
|
1999-05-08 00:21:47 +04:00
|
|
|
{
|
2000-01-27 01:53:55 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aParent);
|
1999-05-08 00:21:47 +04:00
|
|
|
|
2000-01-27 01:53:55 +03:00
|
|
|
nsCOMPtr<nsIFolder> parent = do_QueryReferent(mParent);
|
|
|
|
|
|
|
|
*aParent = parent;
|
|
|
|
NS_IF_ADDREF(*aParent);
|
1999-05-08 00:21:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-01-28 04:22:33 +03:00
|
|
|
nsMsgFolder::GetMessages(nsIMsgWindow *aMsgWindow, nsISimpleEnumerator* *result)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
// XXX should this return an empty enumeration?
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-09-18 03:12:44 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::StartFolderLoading(void)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::EndFolderLoading(void)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-14 08:02:34 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-03 06:16:26 +03:00
|
|
|
nsMsgFolder::UpdateFolder(nsIMsgWindow *)
|
1999-09-14 08:02:34 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-07 04:03:26 +04:00
|
|
|
NS_IMETHODIMP
|
2000-01-28 04:22:33 +03:00
|
|
|
nsMsgFolder::GetThreads(nsIMsgWindow *aMsgWindow, nsISimpleEnumerator ** threadEnumerator)
|
1999-04-07 04:03:26 +04:00
|
|
|
{
|
|
|
|
// 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
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1999-10-21 01:58:21 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetFolderURL(char **url)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
if(*url)
|
|
|
|
{
|
|
|
|
*url = NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-16 01:03:02 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetServer(nsIMsgIncomingServer ** aServer)
|
|
|
|
{
|
1999-10-29 00:19:57 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aServer);
|
1999-12-04 06:00:22 +03:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// short circut the server if we have it.
|
2000-01-27 01:53:55 +03:00
|
|
|
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryReferent(mServer, &rv);
|
|
|
|
if (NS_FAILED(rv) || !server) {
|
|
|
|
// try again after parsing the URI
|
|
|
|
rv = parseURI(PR_TRUE);
|
|
|
|
server = do_QueryReferent(mServer);
|
1999-12-04 06:00:22 +03:00
|
|
|
}
|
|
|
|
|
2000-01-27 01:53:55 +03:00
|
|
|
*aServer = server;
|
1999-10-29 00:19:57 +04:00
|
|
|
NS_IF_ADDREF(*aServer);
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-05-16 01:03:02 +04:00
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
2000-05-25 07:49:10 +04:00
|
|
|
#ifdef MSG_FASTER_URI_PARSING
|
|
|
|
class nsMsgAutoBool {
|
|
|
|
public:
|
|
|
|
nsMsgAutoBool() : mValue(nsnull) {}
|
|
|
|
void autoReset(PRBool *aValue) { mValue = aValue; }
|
|
|
|
~nsMsgAutoBool() { if (mValue) *mValue = PR_FALSE; }
|
|
|
|
private:
|
|
|
|
PRBool *mValue;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1999-12-04 06:00:22 +03:00
|
|
|
nsresult
|
|
|
|
nsMsgFolder::parseURI(PRBool needServer)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIURL> url;
|
2000-05-25 07:49:10 +04:00
|
|
|
|
|
|
|
#ifdef MSG_FASTER_URI_PARSING
|
|
|
|
nsMsgAutoBool parsingUrlState;
|
|
|
|
if (mParsingURLInUse) {
|
|
|
|
url = do_CreateInstance(kStandardUrlCID, &rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
url = mParsingURL;
|
|
|
|
mParsingURLInUse = PR_TRUE;
|
|
|
|
parsingUrlState.autoReset(&mParsingURLInUse);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
1999-12-04 06:00:22 +03:00
|
|
|
rv = nsComponentManager::CreateInstance(kStandardUrlCID, nsnull,
|
|
|
|
NS_GET_IID(nsIURL),
|
|
|
|
(void **)getter_AddRefs(url));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-05-25 07:49:10 +04:00
|
|
|
#endif
|
1999-12-04 06:00:22 +03:00
|
|
|
|
|
|
|
rv = url->SetSpec(mURI);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2000-02-03 06:44:22 +03:00
|
|
|
NS_WITH_SERVICE(nsIIOService, ioServ, kIOServiceCID, &rv);
|
|
|
|
|
1999-12-04 06:00:22 +03:00
|
|
|
//
|
|
|
|
// pull some info out of the URI
|
|
|
|
//
|
|
|
|
|
|
|
|
// empty path tells us it's a server.
|
|
|
|
if (!mIsServerIsValid) {
|
|
|
|
nsXPIDLCString path;
|
|
|
|
rv = url->GetPath(getter_Copies(path));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
if (!nsCRT::strcmp(path, "/"))
|
|
|
|
mIsServer = PR_TRUE;
|
|
|
|
else
|
|
|
|
mIsServer = PR_FALSE;
|
|
|
|
}
|
|
|
|
mIsServerIsValid = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// grab the name off the leaf of the server
|
|
|
|
if (mName.IsEmpty()) {
|
|
|
|
// mName:
|
|
|
|
// the name is the trailing directory in the path
|
|
|
|
nsXPIDLCString fileName;
|
|
|
|
rv = url->GetFileName(getter_Copies(fileName));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// XXX conversion to unicode here? is fileName in UTF8?
|
2000-02-23 23:49:09 +03:00
|
|
|
// yes, let's say it is in utf8
|
2000-02-03 06:44:22 +03:00
|
|
|
|
2000-05-25 07:49:10 +04:00
|
|
|
nsXPIDLCString result;
|
|
|
|
rv = ioServ->Unescape(fileName, getter_Copies(result));
|
|
|
|
mName.AssignWithConversion(result);
|
1999-12-04 06:00:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// grab the server by parsing the URI and looking it up
|
|
|
|
// in the account manager...
|
|
|
|
// But avoid this extra work by first asking the parent, if any
|
|
|
|
|
2000-01-27 01:53:55 +03:00
|
|
|
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryReferent(mServer, &rv);
|
|
|
|
if (NS_FAILED(rv) || !server) {
|
1999-12-04 06:00:22 +03:00
|
|
|
|
|
|
|
// first try asking the parent instead of the URI
|
|
|
|
nsCOMPtr<nsIFolder> parent;
|
|
|
|
rv = GetParent(getter_AddRefs(parent));
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && parent) {
|
|
|
|
nsCOMPtr<nsIMsgFolder> parentMsgFolder =
|
|
|
|
do_QueryInterface(parent, &rv);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
rv = parentMsgFolder->GetServer(getter_AddRefs(server));
|
|
|
|
}
|
|
|
|
|
1999-12-18 04:09:51 +03:00
|
|
|
// no parent. do the extra work of asking
|
1999-12-04 06:00:22 +03:00
|
|
|
if (!server && needServer) {
|
|
|
|
// Get username and hostname so we can get the server
|
|
|
|
nsXPIDLCString userName;
|
2000-01-15 01:51:53 +03:00
|
|
|
rv = url->GetPreHost(getter_Copies(userName));
|
1999-12-04 06:00:22 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && (const char*)userName)
|
|
|
|
nsUnescape(NS_CONST_CAST(char*,(const char*)userName));
|
|
|
|
|
|
|
|
nsXPIDLCString hostName;
|
|
|
|
rv = url->GetHost(getter_Copies(hostName));
|
|
|
|
if (NS_SUCCEEDED(rv) && (const char*)hostName)
|
|
|
|
nsUnescape(NS_CONST_CAST(char*,(const char*)hostName));
|
|
|
|
|
|
|
|
// turn it back into a server:
|
|
|
|
|
|
|
|
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager,
|
|
|
|
NS_MSGACCOUNTMANAGER_PROGID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
#ifdef DEBUG_alecf
|
|
|
|
// this is a failing case, and it would be nice if this
|
|
|
|
// was never called
|
|
|
|
// (we should ALWAYS handle this case, but try to design
|
|
|
|
// the code so we have a parent wherever possible)
|
|
|
|
printf("No parent->");
|
|
|
|
#endif
|
|
|
|
rv = accountManager->FindServer(userName,
|
|
|
|
hostName,
|
|
|
|
GetIncomingServerType(),
|
|
|
|
getter_AddRefs(server));
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
}
|
1999-12-18 04:09:51 +03:00
|
|
|
|
2000-03-25 23:41:26 +03:00
|
|
|
mServer = getter_AddRefs(NS_GetWeakReference(server));
|
1999-12-18 04:09:51 +03:00
|
|
|
|
2000-01-27 01:53:55 +03:00
|
|
|
} /* !mServer */
|
1999-12-04 06:00:22 +03:00
|
|
|
|
1999-12-18 04:09:51 +03:00
|
|
|
// now try to find the local path for this folder
|
2000-01-27 01:53:55 +03:00
|
|
|
if (server) {
|
1999-12-18 04:09:51 +03:00
|
|
|
|
|
|
|
nsXPIDLCString urlPath;
|
|
|
|
url->GetFilePath(getter_Copies(urlPath));
|
|
|
|
|
2000-05-25 07:49:10 +04:00
|
|
|
nsXPIDLCString result;
|
|
|
|
rv = ioServ->Unescape(urlPath, getter_Copies(result));
|
2000-02-03 06:44:22 +03:00
|
|
|
|
1999-12-18 04:09:51 +03:00
|
|
|
// transform the filepath from the URI, such as
|
|
|
|
// "/folder1/folder2/foldern"
|
|
|
|
// to
|
|
|
|
// "folder1.sbd/folder2.sbd/foldern"
|
|
|
|
// (remove leading / and add .sbd to first n-1 folders)
|
|
|
|
// to be appended onto the server's path
|
|
|
|
|
2000-05-16 06:17:46 +04:00
|
|
|
nsCAutoString newPath;
|
2000-02-26 23:46:39 +03:00
|
|
|
NS_MsgCreatePathStringFromFolderURI(result, newPath);
|
1999-12-18 04:09:51 +03:00
|
|
|
|
|
|
|
// now append munged path onto server path
|
|
|
|
nsCOMPtr<nsIFileSpec> serverPath;
|
2000-01-27 01:53:55 +03:00
|
|
|
rv = server->GetLocalPath(getter_AddRefs(serverPath));
|
1999-12-18 04:09:51 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
if (serverPath) {
|
2000-01-05 01:25:28 +03:00
|
|
|
rv = serverPath->AppendRelativeUnixPath(newPath.GetBuffer());
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to append to the serverPath");
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mPath = null_nsCOMPtr();
|
|
|
|
return rv;
|
|
|
|
}
|
1999-12-18 04:09:51 +03:00
|
|
|
mPath = serverPath;
|
|
|
|
}
|
2000-01-26 04:21:24 +03:00
|
|
|
|
|
|
|
// URI is completely parsed when we've attempted to get the server
|
|
|
|
mHaveParsedURI=PR_TRUE;
|
1999-12-18 04:09:51 +03:00
|
|
|
}
|
|
|
|
|
1999-12-04 06:00:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-21 02:41:38 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetIsServer(PRBool *aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
1999-12-04 06:00:22 +03:00
|
|
|
|
|
|
|
// make sure we've parsed the URI
|
|
|
|
if (!mIsServerIsValid) {
|
|
|
|
nsresult rv = parseURI();
|
|
|
|
if (NS_FAILED(rv) || !mIsServerIsValid)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-08-21 02:41:38 +04:00
|
|
|
*aResult = mIsServer;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-14 16:37:54 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetNoSelect(PRBool *aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
*aResult = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
fix for #17402, stationary -> stationery.
r=alecf
major fixes for the new folder / rename folder / subscribe dialogs.
we no longer use an html select for the folder picker.
now we use cascading menu popups, like the copy and move menus.
this fixes a lot of bugs, and allows pre-flighting to finally work.
our folder data source has some new properies:
CanFileMessages, CanSubscribe, CanRename, and CanCreateSubfolders
we use these to determine what cascading menu to build, what to disable, etc.
also, nsMessenger::NewFolder() and nsMessenger::RenameFolder() were changes to
take a nsIRDFResource instead of a nsIDOMXULElement. Before we were
passing through to the back end the selected xul element, now we pass
the resource in.
other cool side effects:
in the copy & move menus, you don't get the choice to file or copy to a server, on folders
in the rename dialog, you can't pick a server, on a folder
in the new folder dialog, you can't pick the imap inbox. (* more needs to be done here.)
bugs fixed: #14773, #14254, #20599, #20646
r=alecf
a couple bullet proofing fixes to prevent some crashes reported on fullcircle
r=bienvenu
1999-12-03 11:10:09 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetCanSubscribe(PRBool *aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
// by default, you can't subscribe.
|
|
|
|
// if otherwise, override it.
|
|
|
|
*aResult = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetCanFileMessages(PRBool *aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
|
|
|
|
PRBool isServer = PR_FALSE;
|
|
|
|
nsresult rv = GetIsServer(&isServer);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// by default, you can't file messages into servers, only to folders
|
|
|
|
// if otherwise, override it.
|
|
|
|
*aResult = !isServer;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetCanCreateSubfolders(PRBool *aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
// by default, you can create subfolders on server and folders
|
|
|
|
// if otherwise, override it.
|
|
|
|
*aResult = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetCanRename(PRBool *aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
|
|
|
|
PRBool isServer = PR_FALSE;
|
|
|
|
nsresult rv = GetIsServer(&isServer);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-12-04 22:56:06 +03:00
|
|
|
|
fix for #17402, stationary -> stationery.
r=alecf
major fixes for the new folder / rename folder / subscribe dialogs.
we no longer use an html select for the folder picker.
now we use cascading menu popups, like the copy and move menus.
this fixes a lot of bugs, and allows pre-flighting to finally work.
our folder data source has some new properies:
CanFileMessages, CanSubscribe, CanRename, and CanCreateSubfolders
we use these to determine what cascading menu to build, what to disable, etc.
also, nsMessenger::NewFolder() and nsMessenger::RenameFolder() were changes to
take a nsIRDFResource instead of a nsIDOMXULElement. Before we were
passing through to the back end the selected xul element, now we pass
the resource in.
other cool side effects:
in the copy & move menus, you don't get the choice to file or copy to a server, on folders
in the rename dialog, you can't pick a server, on a folder
in the new folder dialog, you can't pick the imap inbox. (* more needs to be done here.)
bugs fixed: #14773, #14254, #20599, #20646
r=alecf
a couple bullet proofing fixes to prevent some crashes reported on fullcircle
r=bienvenu
1999-12-03 11:10:09 +03:00
|
|
|
// by default, you can't rename servers, only folders
|
|
|
|
// if otherwise, override it.
|
1999-12-04 22:56:06 +03:00
|
|
|
if (isServer) {
|
|
|
|
*aResult = PR_FALSE;
|
|
|
|
}
|
|
|
|
// old comment, from the 4.x code base:
|
|
|
|
// Here's a weird case necessitated because we don't have a separate
|
|
|
|
// preference for any folder name except the FCC folder (Sent). Others
|
|
|
|
// are known by name, and as such, can't be renamed. I guess.
|
|
|
|
//
|
|
|
|
// new comment:
|
|
|
|
// we have prefs for drafts and templates now, can we remove those
|
|
|
|
// parts of this case?
|
|
|
|
else if (mFlags & MSG_FOLDER_FLAG_TRASH ||
|
|
|
|
mFlags & MSG_FOLDER_FLAG_DRAFTS ||
|
|
|
|
mFlags & MSG_FOLDER_FLAG_QUEUE ||
|
|
|
|
mFlags & MSG_FOLDER_FLAG_INBOX ||
|
|
|
|
mFlags & MSG_FOLDER_FLAG_TEMPLATES) {
|
|
|
|
*aResult = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aResult = PR_TRUE;
|
|
|
|
}
|
fix for #17402, stationary -> stationery.
r=alecf
major fixes for the new folder / rename folder / subscribe dialogs.
we no longer use an html select for the folder picker.
now we use cascading menu popups, like the copy and move menus.
this fixes a lot of bugs, and allows pre-flighting to finally work.
our folder data source has some new properies:
CanFileMessages, CanSubscribe, CanRename, and CanCreateSubfolders
we use these to determine what cascading menu to build, what to disable, etc.
also, nsMessenger::NewFolder() and nsMessenger::RenameFolder() were changes to
take a nsIRDFResource instead of a nsIDOMXULElement. Before we were
passing through to the back end the selected xul element, now we pass
the resource in.
other cool side effects:
in the copy & move menus, you don't get the choice to file or copy to a server, on folders
in the rename dialog, you can't pick a server, on a folder
in the new folder dialog, you can't pick the imap inbox. (* more needs to be done here.)
bugs fixed: #14773, #14254, #20599, #20646
r=alecf
a couple bullet proofing fixes to prevent some crashes reported on fullcircle
r=bienvenu
1999-12-03 11:10:09 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-06-29 01:56:33 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetPrettyName(PRUnichar ** name)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
2000-01-26 04:21:24 +03:00
|
|
|
return GetName(name);
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
1999-09-20 03:46:35 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::SetPrettyName(const PRUnichar *name)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
2000-01-26 04:21:24 +03:00
|
|
|
return SetName(name);
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
1999-06-29 01:56:33 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetName(PRUnichar **name)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
2000-01-26 04:21:24 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(name);
|
1999-12-04 06:00:22 +03:00
|
|
|
|
|
|
|
nsresult rv;
|
2000-01-26 04:21:24 +03:00
|
|
|
if (!mHaveParsedURI && mName.IsEmpty()) {
|
1999-12-04 06:00:22 +03:00
|
|
|
rv = parseURI();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
1999-08-10 04:03:46 +04:00
|
|
|
|
2000-01-26 04:21:24 +03:00
|
|
|
// if it's a server, just forward the call
|
|
|
|
if (mIsServer) {
|
|
|
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
|
|
|
rv = GetServer(getter_AddRefs(server));
|
|
|
|
if (NS_SUCCEEDED(rv) && server)
|
|
|
|
return server->GetPrettyName(name);
|
|
|
|
}
|
|
|
|
|
1999-08-10 04:03:46 +04:00
|
|
|
*name = mName.ToNewUnicode();
|
|
|
|
|
|
|
|
if (!(*name)) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
return NS_OK;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
1999-09-20 03:46:35 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::SetName(const PRUnichar * name)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-08-10 04:03:46 +04:00
|
|
|
// override the URI-generated name
|
2000-04-28 01:32:39 +04:00
|
|
|
if (!mName.EqualsWithConversion(name))
|
2000-02-08 04:20:00 +03:00
|
|
|
{
|
|
|
|
mName = name;
|
2000-01-26 04:21:24 +03:00
|
|
|
|
|
|
|
// old/new value doesn't matter here
|
2000-02-08 04:20:00 +03:00
|
|
|
NotifyUnicharPropertyChanged(kNameAtom, name, name);
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-30 00:46:15 +04:00
|
|
|
//For default, just return name
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetAbbreviatedName(PRUnichar * *aAbbreviatedName)
|
|
|
|
{
|
|
|
|
return GetName(aAbbreviatedName);
|
|
|
|
}
|
|
|
|
|
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;
|
1999-07-23 08:33:20 +04:00
|
|
|
rv = mSubFolders->Count(&count);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-05-18 02:50:04 +04:00
|
|
|
|
|
|
|
for (PRUint32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
|
|
|
|
folder = do_QueryInterface(supports, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
{
|
1999-12-21 04:18:47 +03:00
|
|
|
PRUnichar *folderName = nsnull;
|
1999-05-18 02:50:04 +04:00
|
|
|
|
|
|
|
folder->GetName(&folderName);
|
|
|
|
// case-insensitive compare is probably LCD across OS filesystems
|
1999-07-23 08:33:20 +04:00
|
|
|
if (folderName && nsCRT::strcasecmp(folderName, name)==0)
|
1999-05-18 02:50:04 +04:00
|
|
|
{
|
|
|
|
*aChild = folder;
|
1999-10-13 08:12:06 +04:00
|
|
|
NS_ADDREF(*aChild);
|
1999-05-18 02:50:04 +04:00
|
|
|
delete[] folderName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-07-27 09:15:44 +04:00
|
|
|
delete[] folderName;
|
1999-05-18 02:50:04 +04:00
|
|
|
}
|
1999-07-27 09:15:44 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
1999-07-23 08:33:20 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetChildWithURI(const char *uri, PRBool deep, nsIMsgFolder ** child)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(child, "NULL child");
|
|
|
|
nsresult rv;
|
|
|
|
// will return nsnull if we can't find it
|
|
|
|
*child = nsnull;
|
|
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
nsCOMPtr<nsIRDFResource> folderResource = do_QueryInterface(supports);
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports);
|
|
|
|
if(folderResource && folder)
|
|
|
|
{
|
1999-12-21 04:18:47 +03:00
|
|
|
char *folderURI =nsnull;
|
1999-07-23 08:33:20 +04:00
|
|
|
rv = folderResource->GetValue(&folderURI);
|
1999-10-13 08:12:06 +04:00
|
|
|
if(NS_FAILED(rv)) return rv;
|
1999-07-23 08:33:20 +04:00
|
|
|
|
|
|
|
// case-insensitive compare is probably LCD across OS filesystems
|
|
|
|
PRBool equal = (folderURI && nsCRT::strcasecmp(folderURI, uri)==0);
|
2000-06-03 13:46:12 +04:00
|
|
|
nsMemory::Free(folderURI);
|
1999-07-23 08:33:20 +04:00
|
|
|
if (equal)
|
|
|
|
{
|
|
|
|
*child = folder;
|
1999-07-27 22:18:52 +04:00
|
|
|
NS_ADDREF(*child);
|
1999-07-23 08:33:20 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else if(deep)
|
|
|
|
{
|
|
|
|
rv = folder->GetChildWithURI(uri, deep, child);
|
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
if(*child)
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-10-13 08:12:06 +04:00
|
|
|
|
1999-07-23 08:33:20 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-06-29 01:56:33 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetPrettiestName(PRUnichar **name)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2000-03-24 17:58:32 +03:00
|
|
|
*deleteIsMoveToTrash = mDeleteIsMoveToTrash;
|
1999-03-20 01:55:08 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-28 18:34:13 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::ForceDBClosed ()
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::Delete ()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-24 17:58:32 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::DeleteSubFolders(nsISupportsArray *folders,
|
|
|
|
nsIMsgWindow *msgWindow)
|
1999-05-27 03:47:01 +04:00
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2000-02-29 04:16:55 +03:00
|
|
|
//Remove self as parent
|
|
|
|
child->SetParent(nsnull);
|
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.
|
1999-08-21 02:47:55 +04:00
|
|
|
mSubFolders->RemoveElement(supports);
|
1999-05-27 03:47:01 +04:00
|
|
|
nsCOMPtr<nsISupports> childSupports(do_QueryInterface(child));
|
1999-11-11 03:23:29 +03:00
|
|
|
nsCOMPtr<nsISupports> folderSupports;
|
2000-02-06 06:18:27 +03:00
|
|
|
rv = QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(folderSupports));
|
1999-11-11 03:23:29 +03:00
|
|
|
if(childSupports && NS_SUCCEEDED(rv))
|
|
|
|
NotifyItemDeleted(folderSupports, childSupports, "folderView");
|
1999-05-27 03:47:01 +04:00
|
|
|
break;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
2000-02-29 04:16:55 +03:00
|
|
|
else
|
|
|
|
{ // setting parent back if we failed
|
|
|
|
child->SetParent(this);
|
|
|
|
}
|
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)
|
|
|
|
{
|
1999-09-08 07:08:27 +04:00
|
|
|
// If deleteStorage is PR_TRUE, recursively deletes disk storage for this folder
|
1999-03-20 01:55:08 +03:00
|
|
|
// 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
|
|
|
{
|
1999-05-27 03:47:01 +04:00
|
|
|
child->SetParent(nsnull);
|
2000-02-29 04:16:55 +03:00
|
|
|
status = child->RecursiveDelete(deleteStorage); // recur
|
|
|
|
if (NS_SUCCEEDED(status))
|
|
|
|
{
|
|
|
|
mSubFolders->RemoveElement(child); // unlink it from this's child list
|
|
|
|
nsCOMPtr<nsISupports> childSupports(do_QueryInterface(child));
|
|
|
|
nsCOMPtr<nsISupports> folderSupports;
|
|
|
|
rv = QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(folderSupports));
|
|
|
|
if(childSupports && NS_SUCCEEDED(rv))
|
|
|
|
NotifyItemDeleted(folderSupports, childSupports, "folderView");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // setting parent back if we failed for some reason
|
|
|
|
child->SetParent(this);
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2000-02-07 03:20:37 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::CreateSubfolder(const PRUnichar *folderName)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-11-19 17:35:31 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
1999-11-19 17:35:31 +03:00
|
|
|
nsresult nsMsgFolder::AddSubfolder(nsAutoString *folderName,
|
|
|
|
nsIMsgFolder** newFolder)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
1999-08-06 17:40:08 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::Compact()
|
|
|
|
{
|
1999-08-06 22:24:39 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2000-05-15 18:55:22 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::EmptyTrash(nsIMsgWindow *msgWindow, nsIUrlListener *aListener)
|
1999-08-06 22:24:39 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1999-08-06 17:40:08 +04:00
|
|
|
}
|
1999-03-20 01:55:08 +03:00
|
|
|
|
2000-02-08 04:20:00 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::Rename(const PRUnichar *name)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
nsresult status = NS_OK;
|
2000-03-27 10:48:32 +04:00
|
|
|
nsAutoString unicharString(name);
|
1999-06-29 01:56:33 +04:00
|
|
|
status = SetName((PRUnichar *) unicharString.GetUnicode());
|
1999-03-20 01:55:08 +03:00
|
|
|
//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;
|
|
|
|
}
|
|
|
|
|
1999-07-18 00:33:15 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::UpdateSummaryTotals(PRBool /* force */)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
//We don't support this
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SummaryChanged()
|
|
|
|
{
|
1999-07-18 00:33:15 +04:00
|
|
|
UpdateSummaryTotals(PR_FALSE);
|
1999-03-20 01:55:08 +03:00
|
|
|
#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-11-01 04:06:29 +03:00
|
|
|
PRUint32 total = mNumUnreadMessages + mNumPendingUnreadMessages;
|
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-11-01 04:06:29 +03:00
|
|
|
PRInt32 total = mNumTotalMessages + mNumPendingTotalMessages;
|
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;
|
|
|
|
}
|
|
|
|
|
1999-11-01 04:06:29 +03:00
|
|
|
PRInt32 nsMsgFolder::GetNumPendingUnread()
|
|
|
|
{
|
|
|
|
return mNumPendingUnreadMessages;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsMsgFolder::GetNumPendingTotalMessages()
|
|
|
|
{
|
|
|
|
return mNumPendingTotalMessages;
|
|
|
|
}
|
|
|
|
|
2000-06-23 07:19:17 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetHasNewMessages(PRBool *hasNewMessages)
|
|
|
|
{
|
|
|
|
//we don't support this
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetHasNewMessages(PRBool hasNewMessages)
|
2000-01-29 02:25:17 +03:00
|
|
|
{
|
|
|
|
//we don't support this
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetFirstNewMessage(nsIMessage **firstNewMessage)
|
|
|
|
{
|
|
|
|
//we don't support this
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::ClearNewMessages()
|
|
|
|
{
|
|
|
|
//we don't support this
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-01 04:06:29 +03:00
|
|
|
|
|
|
|
void nsMsgFolder::ChangeNumPendingUnread(PRInt32 delta)
|
|
|
|
{
|
1999-11-23 01:08:23 +03:00
|
|
|
if(delta)
|
1999-11-18 05:36:22 +03:00
|
|
|
{
|
1999-11-23 01:08:23 +03:00
|
|
|
PRInt32 oldUnreadMessages = mNumUnreadMessages + mNumPendingUnreadMessages;
|
1999-11-18 05:36:22 +03:00
|
|
|
mNumPendingUnreadMessages += delta;
|
1999-11-23 01:08:23 +03:00
|
|
|
PRInt32 newUnreadMessages = mNumUnreadMessages + mNumPendingUnreadMessages;
|
|
|
|
|
2000-01-14 12:01:39 +03:00
|
|
|
NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, newUnreadMessages);
|
1999-11-18 05:36:22 +03:00
|
|
|
}
|
1999-11-01 04:06:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsMsgFolder::ChangeNumPendingTotalMessages(PRInt32 delta)
|
|
|
|
{
|
1999-11-23 01:08:23 +03:00
|
|
|
if(delta)
|
1999-11-18 05:36:22 +03:00
|
|
|
{
|
1999-11-23 01:08:23 +03:00
|
|
|
PRInt32 oldTotalMessages = mNumTotalMessages + mNumPendingTotalMessages;
|
1999-11-18 05:36:22 +03:00
|
|
|
mNumPendingTotalMessages += delta;
|
1999-11-23 01:08:23 +03:00
|
|
|
PRInt32 newTotalMessages = mNumTotalMessages + mNumPendingTotalMessages;
|
|
|
|
|
2000-01-14 12:01:39 +03:00
|
|
|
NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, newTotalMessages);
|
1999-11-18 05:36:22 +03:00
|
|
|
}
|
1999-11-23 01:08:23 +03:00
|
|
|
|
1999-11-01 04:06:29 +03:00
|
|
|
}
|
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
|
2000-03-14 16:37:54 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::SetPrefFlag()
|
|
|
|
{
|
|
|
|
// *** Note: this method should only be called when we done with the folder
|
|
|
|
// discovery. GetResource() may return a node which is not in the folder
|
|
|
|
// tree hierarchy but in the rdf cache in case of the non-existing default
|
|
|
|
// Sent, Drafts, and Templates folders. The resouce will be eventually
|
|
|
|
// released when rdf service shutting downs. When we create the defaul
|
|
|
|
// folders later on on the imap server, the subsequent GetResouce() of the
|
|
|
|
// same uri will get us the cached rdf resouce which should have the folder
|
|
|
|
// flag set appropriately.
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager,
|
|
|
|
NS_MSGACCOUNTMANAGER_PROGID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
|
|
|
|
|
|
|
|
if(NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
|
|
|
rv = GetServer(getter_AddRefs(server));
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsArray> identities;
|
|
|
|
rv = accountManager->GetIdentitiesForServer(server,
|
|
|
|
getter_AddRefs(identities));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMsgIdentity> identity;
|
|
|
|
|
|
|
|
rv = identities->QueryElementAt(0, NS_GET_IID(nsIMsgIdentity),
|
|
|
|
(void **)getter_AddRefs(identity));
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && identity)
|
|
|
|
{
|
|
|
|
nsXPIDLCString folderUri;
|
|
|
|
nsCOMPtr<nsIRDFResource> res;
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder;
|
|
|
|
identity->GetFccFolder(getter_Copies(folderUri));
|
|
|
|
if (folderUri && NS_SUCCEEDED(rdf->GetResource(folderUri, getter_AddRefs(res))))
|
|
|
|
{
|
|
|
|
folder = do_QueryInterface(res, &rv);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
rv = folder->SetFlag(MSG_FOLDER_FLAG_SENTMAIL);
|
|
|
|
}
|
|
|
|
identity->GetDraftFolder(getter_Copies(folderUri));
|
|
|
|
if (folderUri && NS_SUCCEEDED(rdf->GetResource(folderUri, getter_AddRefs(res))))
|
|
|
|
{
|
|
|
|
folder = do_QueryInterface(res, &rv);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
rv = folder->SetFlag(MSG_FOLDER_FLAG_DRAFTS);
|
|
|
|
}
|
|
|
|
identity->GetStationeryFolder(getter_Copies(folderUri));
|
|
|
|
if (folderUri && NS_SUCCEEDED(rdf->GetResource(folderUri, getter_AddRefs(res))))
|
|
|
|
{
|
|
|
|
folder = do_QueryInterface(res, &rv);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
rv = folder->SetFlag(MSG_FOLDER_FLAG_TEMPLATES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
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;
|
|
|
|
|
2000-04-13 09:55:48 +04:00
|
|
|
if (flagSet)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2000-03-14 16:37:54 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIMsgDatabase> db;
|
|
|
|
nsCOMPtr<nsIDBFolderInfo> folderInfo;
|
|
|
|
rv = GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(db));
|
|
|
|
if (NS_SUCCEEDED(rv) && folderInfo)
|
|
|
|
{
|
2000-04-14 10:54:19 +04:00
|
|
|
nsXPIDLString name;
|
|
|
|
rv = GetName(getter_Copies(name));
|
2000-03-14 16:37:54 +03:00
|
|
|
folderInfo->SetFlags((PRInt32) mFlags);
|
2000-03-21 06:28:03 +03:00
|
|
|
if (db)
|
|
|
|
db->Commit(nsMsgDBCommitType::kLargeCommit);
|
2000-03-14 16:37:54 +03:00
|
|
|
}
|
|
|
|
folderInfo = null_nsCOMPtr();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::SetFlags(PRUint32 aFlags)
|
|
|
|
{
|
2000-03-20 01:37:32 +03:00
|
|
|
if (mFlags != aFlags)
|
|
|
|
{
|
|
|
|
mFlags = aFlags;
|
|
|
|
OnFlagChange(mFlags);
|
|
|
|
}
|
2000-03-14 16:37:54 +03:00
|
|
|
return NS_OK;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
2000-01-11 11:01:37 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetFoldersWithFlag(PRUint32 flags, PRUint32 resultsize, PRUint32 *numFolders, nsIMsgFolder **result)
|
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)) {
|
1999-07-04 01:25:49 +04:00
|
|
|
for (PRUint32 i=0; i < cnt; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
|
|
|
|
folder = do_QueryInterface(supports, &rv);
|
|
|
|
if(NS_SUCCEEDED(rv) && folder)
|
1999-05-13 08:56:04 +04:00
|
|
|
{
|
|
|
|
// 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)
|
|
|
|
{
|
2000-01-11 11:01:37 +03:00
|
|
|
folder->GetFoldersWithFlag(flags, 0, &numSubFolders, NULL);
|
1999-05-13 08:56:04 +04:00
|
|
|
num += numSubFolders;
|
|
|
|
}
|
|
|
|
else if (num < resultsize)
|
|
|
|
{
|
2000-01-11 11:01:37 +03:00
|
|
|
folder->GetFoldersWithFlag(flags, resultsize - num, &numSubFolders, result+num);
|
1999-05-13 08:56:04 +04:00
|
|
|
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
|
|
|
|
|
2000-05-15 18:55:22 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetExpungedBytes(PRUint32 *count)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
if(!count)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
2000-05-15 18:55:22 +04:00
|
|
|
*count = 0;
|
1999-03-20 01:55:08 +03:00
|
|
|
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::GetRequiresCleanup(PRBool *requiredCleanup)
|
|
|
|
{
|
|
|
|
if(!requiredCleanup)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*requiredCleanup = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::ClearRequiresCleanup()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-14 01:36:02 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::ManyHeadersToDownload(PRBool *_retval)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-09-14 01:36:02 +04:00
|
|
|
if (!_retval)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
*_retval = PR_FALSE;
|
|
|
|
return NS_OK;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
1999-09-14 01:36:02 +04:00
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-10-21 01:58:21 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetDisplayRecipients(PRBool *displayRecipients)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-10-21 01:58:21 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetLocked(PRBool *isLocked)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
|
|
|
*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
|
|
|
|
|
|
|
|
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
|
|
|
NS_IMETHODIMP nsMsgFolder::GetUsername(char **userName)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-10-22 05:02:08 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(userName);
|
1999-12-04 06:00:22 +03:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr <nsIMsgIncomingServer> server;
|
1999-10-29 00:19:57 +04:00
|
|
|
|
1999-12-04 06:00:22 +03:00
|
|
|
rv = GetServer(getter_AddRefs(server));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
if (server)
|
|
|
|
return server->GetUsername(userName);
|
|
|
|
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
1999-06-22 07:03:48 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetHostname(char **hostName)
|
1999-03-20 01:55:08 +03:00
|
|
|
{
|
1999-10-22 05:02:08 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(hostName);
|
1999-12-04 06:00:22 +03:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
|
|
|
rv = GetServer(getter_AddRefs(server));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
if (server)
|
|
|
|
return server->GetHostName(hostName);
|
1999-10-29 00:19:57 +04:00
|
|
|
|
1999-12-04 06:00:22 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
1999-03-20 01:55:08 +03:00
|
|
|
}
|
|
|
|
|
1999-11-03 06:16:26 +03:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetNewMessages(nsIMsgWindow *)
|
1999-05-07 04:33:06 +04:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2000-06-23 07:19:17 +04:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// this optimization isn't working with filters...
|
|
|
|
// so commenting out the optimization
|
|
|
|
// need to figure out why and fix it !!!
|
|
|
|
|
|
|
|
//if(mBiffState != aBiffState)
|
|
|
|
//{
|
1999-06-12 02:10:42 +04:00
|
|
|
PRUint32 oldBiffState = mBiffState;
|
|
|
|
mBiffState = aBiffState;
|
|
|
|
nsCOMPtr<nsISupports> supports;
|
2000-06-23 07:19:17 +04:00
|
|
|
|
|
|
|
// Get the server and notify it and not inbox.
|
|
|
|
nsCOMPtr<nsIMsgIncomingServer> aServer;
|
|
|
|
nsCOMPtr<nsIFolder> aRootFolder;
|
|
|
|
|
|
|
|
rv = GetServer(getter_AddRefs(aServer));
|
|
|
|
rv = aServer->GetRootFolder(getter_AddRefs(aRootFolder));
|
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
if(NS_SUCCEEDED(aRootFolder->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(supports))))
|
|
|
|
(aRootFolder)->NotifyPropertyFlagChanged(supports, kBiffStateAtom, oldBiffState, mBiffState);
|
|
|
|
//}
|
1999-06-12 02:10:42 +04:00
|
|
|
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;
|
|
|
|
|
2000-01-14 12:01:39 +03:00
|
|
|
nsCAutoString oldNumMessagesStr;
|
2000-04-22 12:43:34 +04:00
|
|
|
oldNumMessagesStr.AppendInt(oldNumMessages);
|
2000-01-14 12:01:39 +03:00
|
|
|
nsCAutoString newNumMessagesStr;
|
2000-04-22 12:43:34 +04:00
|
|
|
newNumMessagesStr.AppendInt(aNumNewMessages);
|
2000-01-14 12:01:39 +03:00
|
|
|
NotifyPropertyChanged(kNumNewBiffMessagesAtom, oldNumMessagesStr, newNumMessagesStr);
|
1999-06-12 02:10:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsMsgFolder::GetNewMessagesNotificationDescription(PRUnichar * *aDescription)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-04-22 12:43:34 +04:00
|
|
|
nsAutoString description;
|
1999-06-12 02:10:42 +04:00
|
|
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
|
|
|
rv = GetServer(getter_AddRefs(server));
|
1999-08-10 08:39:22 +04:00
|
|
|
|
1999-06-12 02:10:42 +04:00
|
|
|
if(NS_SUCCEEDED(rv))
|
|
|
|
{
|
1999-08-03 01:33:00 +04:00
|
|
|
if (!(mFlags & MSG_FOLDER_FLAG_INBOX))
|
|
|
|
{
|
1999-08-10 08:39:22 +04:00
|
|
|
nsXPIDLString folderName;
|
|
|
|
rv = GetPrettyName(getter_Copies(folderName));
|
1999-08-03 01:33:00 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && folderName)
|
2000-03-26 16:14:14 +04:00
|
|
|
description.Assign(folderName);
|
1999-08-03 01:33:00 +04:00
|
|
|
}
|
1999-06-12 02:10:42 +04:00
|
|
|
|
1999-08-10 08:39:22 +04:00
|
|
|
// append the server name
|
|
|
|
nsXPIDLString serverName;
|
|
|
|
rv = server->GetPrettyName(getter_Copies(serverName));
|
|
|
|
if(NS_SUCCEEDED(rv)) {
|
|
|
|
// put this test here because we don't want to just put "folder name on"
|
|
|
|
// in case the above failed
|
|
|
|
if (!(mFlags & MSG_FOLDER_FLAG_INBOX))
|
2000-04-22 12:43:34 +04:00
|
|
|
description.AppendWithConversion(" on ");
|
2000-03-26 16:14:14 +04:00
|
|
|
description.Append(serverName);
|
1999-08-10 08:39:22 +04:00
|
|
|
}
|
1999-06-12 02:10:42 +04:00
|
|
|
}
|
|
|
|
*aDescription = description.ToNewUnicode();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-15 02:22:51 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::GetRootFolder(nsIMsgFolder * *aRootFolder)
|
|
|
|
{
|
fix for #17402, stationary -> stationery.
r=alecf
major fixes for the new folder / rename folder / subscribe dialogs.
we no longer use an html select for the folder picker.
now we use cascading menu popups, like the copy and move menus.
this fixes a lot of bugs, and allows pre-flighting to finally work.
our folder data source has some new properies:
CanFileMessages, CanSubscribe, CanRename, and CanCreateSubfolders
we use these to determine what cascading menu to build, what to disable, etc.
also, nsMessenger::NewFolder() and nsMessenger::RenameFolder() were changes to
take a nsIRDFResource instead of a nsIDOMXULElement. Before we were
passing through to the back end the selected xul element, now we pass
the resource in.
other cool side effects:
in the copy & move menus, you don't get the choice to file or copy to a server, on folders
in the rename dialog, you can't pick a server, on a folder
in the new folder dialog, you can't pick the imap inbox. (* more needs to be done here.)
bugs fixed: #14773, #14254, #20599, #20646
r=alecf
a couple bullet proofing fixes to prevent some crashes reported on fullcircle
r=bienvenu
1999-12-03 11:10:09 +03:00
|
|
|
if (!aRootFolder) return NS_ERROR_NULL_POINTER;
|
1999-06-15 02:22:51 +04:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIMsgIncomingServer> server;
|
|
|
|
rv = GetServer(getter_AddRefs(server));
|
fix for #17402, stationary -> stationery.
r=alecf
major fixes for the new folder / rename folder / subscribe dialogs.
we no longer use an html select for the folder picker.
now we use cascading menu popups, like the copy and move menus.
this fixes a lot of bugs, and allows pre-flighting to finally work.
our folder data source has some new properies:
CanFileMessages, CanSubscribe, CanRename, and CanCreateSubfolders
we use these to determine what cascading menu to build, what to disable, etc.
also, nsMessenger::NewFolder() and nsMessenger::RenameFolder() were changes to
take a nsIRDFResource instead of a nsIDOMXULElement. Before we were
passing through to the back end the selected xul element, now we pass
the resource in.
other cool side effects:
in the copy & move menus, you don't get the choice to file or copy to a server, on folders
in the rename dialog, you can't pick a server, on a folder
in the new folder dialog, you can't pick the imap inbox. (* more needs to be done here.)
bugs fixed: #14773, #14254, #20599, #20646
r=alecf
a couple bullet proofing fixes to prevent some crashes reported on fullcircle
r=bienvenu
1999-12-03 11:10:09 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
NS_ASSERTION(server, "server is null");
|
|
|
|
// if this happens, bail.
|
|
|
|
if (!server) return NS_ERROR_NULL_POINTER;
|
1999-06-15 02:22:51 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIFolder> aRoot;
|
|
|
|
rv = server->GetRootFolder(getter_AddRefs(aRoot));
|
|
|
|
|
fix for #17402, stationary -> stationery.
r=alecf
major fixes for the new folder / rename folder / subscribe dialogs.
we no longer use an html select for the folder picker.
now we use cascading menu popups, like the copy and move menus.
this fixes a lot of bugs, and allows pre-flighting to finally work.
our folder data source has some new properies:
CanFileMessages, CanSubscribe, CanRename, and CanCreateSubfolders
we use these to determine what cascading menu to build, what to disable, etc.
also, nsMessenger::NewFolder() and nsMessenger::RenameFolder() were changes to
take a nsIRDFResource instead of a nsIDOMXULElement. Before we were
passing through to the back end the selected xul element, now we pass
the resource in.
other cool side effects:
in the copy & move menus, you don't get the choice to file or copy to a server, on folders
in the rename dialog, you can't pick a server, on a folder
in the new folder dialog, you can't pick the imap inbox. (* more needs to be done here.)
bugs fixed: #14773, #14254, #20599, #20646
r=alecf
a couple bullet proofing fixes to prevent some crashes reported on fullcircle
r=bienvenu
1999-12-03 11:10:09 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
if (!aRoot) return NS_ERROR_NULL_POINTER;
|
1999-06-15 02:22:51 +04:00
|
|
|
|
2000-02-06 06:18:27 +03:00
|
|
|
return aRoot->QueryInterface(NS_GET_IID(nsIMsgFolder), (void**)aRootFolder);
|
1999-06-15 02:22:51 +04:00
|
|
|
}
|
|
|
|
|
1999-06-22 02:56:18 +04:00
|
|
|
NS_IMETHODIMP
|
2000-02-04 02:40:09 +03:00
|
|
|
nsMsgFolder::GetMsgDatabase(nsIMsgWindow *aMsgWindow,
|
|
|
|
nsIMsgDatabase** aMsgDatabase)
|
1999-06-22 02:56:18 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-06-25 07:56:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::GetPath(nsIFileSpec * *aPath)
|
|
|
|
{
|
1999-12-18 04:09:51 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aPath);
|
|
|
|
nsresult rv=NS_OK;
|
1999-12-04 06:00:22 +03:00
|
|
|
|
1999-12-18 04:09:51 +03:00
|
|
|
if (!mPath)
|
|
|
|
rv = parseURI(PR_TRUE);
|
|
|
|
|
|
|
|
*aPath = mPath;
|
|
|
|
NS_IF_ADDREF(*aPath);
|
|
|
|
|
1999-12-07 08:51:53 +03:00
|
|
|
return rv;
|
|
|
|
}
|
1999-12-04 06:00:22 +03:00
|
|
|
|
1999-12-07 08:51:53 +03:00
|
|
|
NS_IMETHODIMP
|
1999-12-18 04:09:51 +03:00
|
|
|
nsMsgFolder::SetPath(nsIFileSpec *aPath)
|
1999-12-07 08:51:53 +03:00
|
|
|
{
|
1999-12-18 04:09:51 +03:00
|
|
|
// XXX - make a local copy!
|
|
|
|
mPath = aPath;
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-06-25 07:56:02 +04:00
|
|
|
}
|
|
|
|
|
1999-07-23 08:33:20 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::MarkMessagesRead(nsISupportsArray *messages, PRBool markRead)
|
|
|
|
{
|
|
|
|
PRUint32 count;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = messages->Count(&count);
|
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
for(PRUint32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(messages->ElementAt(i));
|
|
|
|
nsCOMPtr<nsIMessage> message = do_QueryInterface(msgSupports);
|
|
|
|
|
|
|
|
if(message)
|
|
|
|
rv = message->MarkRead(markRead);
|
|
|
|
|
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-25 01:47:22 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::MarkMessagesFlagged(nsISupportsArray *messages, PRBool markFlagged)
|
|
|
|
{
|
|
|
|
PRUint32 count;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = messages->Count(&count);
|
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
for(PRUint32 i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(messages->ElementAt(i));
|
|
|
|
nsCOMPtr<nsIMessage> message = do_QueryInterface(msgSupports);
|
|
|
|
|
|
|
|
if(message)
|
|
|
|
rv = message->MarkFlagged(markFlagged);
|
|
|
|
|
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-23 08:33:20 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::MarkAllMessagesRead(void)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2000-03-14 08:34:42 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::MarkThreadRead(nsIMsgThread *thread)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-06-26 22:22:55 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::CopyMessages(nsIMsgFolder* srcFolder,
|
|
|
|
nsISupportsArray *messages,
|
|
|
|
PRBool isMove,
|
1999-10-29 08:39:06 +04:00
|
|
|
nsIMsgWindow *window,
|
1999-07-14 00:07:32 +04:00
|
|
|
nsIMsgCopyServiceListener* listener)
|
1999-06-26 22:22:55 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::CopyFileMessage(nsIFileSpec* fileSpec,
|
|
|
|
nsIMessage* messageToReplace,
|
1999-07-14 00:07:32 +04:00
|
|
|
PRBool isDraftOrTemplate,
|
1999-10-29 08:39:06 +04:00
|
|
|
nsIMsgWindow *window,
|
1999-07-14 00:07:32 +04:00
|
|
|
nsIMsgCopyServiceListener* listener)
|
1999-06-26 22:22:55 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1999-07-27 09:15:44 +04:00
|
|
|
NS_IMETHODIMP nsMsgFolder::MatchName(nsString *name, PRBool *matches)
|
|
|
|
{
|
|
|
|
if (!matches)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
*matches = mName.EqualsIgnoreCase(*name);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-24 17:58:32 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::SetDeleteIsMoveToTrash(PRBool bVal)
|
|
|
|
{
|
|
|
|
mDeleteIsMoveToTrash = bVal;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-14 12:01:39 +03:00
|
|
|
nsresult
|
|
|
|
nsMsgFolder::NotifyPropertyChanged(nsIAtom *property,
|
2000-03-28 08:58:05 +04:00
|
|
|
const char *oldValue, const char* newValue)
|
1999-04-21 02:24:21 +04:00
|
|
|
{
|
1999-05-05 02:34:35 +04:00
|
|
|
nsCOMPtr<nsISupports> supports;
|
2000-02-06 06:18:27 +03:00
|
|
|
if(NS_SUCCEEDED(QueryInterface(NS_GET_IID(nsISupports), 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;
|
2000-03-31 02:50:54 +04:00
|
|
|
NS_WITH_SERVICE(nsIFolderListener, folderListenerManager, kMsgFolderListenerManagerCID, &rv);
|
1999-05-14 04:45:25 +04:00
|
|
|
if(NS_SUCCEEDED(rv))
|
2000-03-31 02:50:54 +04:00
|
|
|
folderListenerManager->OnItemPropertyChanged(supports, property, oldValue, newValue);
|
1999-05-14 04:45:25 +04:00
|
|
|
|
1999-04-21 02:24:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-01-14 12:01:39 +03:00
|
|
|
nsresult
|
|
|
|
nsMsgFolder::NotifyUnicharPropertyChanged(nsIAtom *property,
|
|
|
|
const PRUnichar* oldValue,
|
|
|
|
const PRUnichar *newValue)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsISupports> supports;
|
|
|
|
rv = QueryInterface(NS_GET_IID(nsISupports),
|
|
|
|
(void **)getter_AddRefs(supports));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
PRInt32 i;
|
|
|
|
for (i=0; i<mListeners->Count(); i++) {
|
|
|
|
// folderlisteners arent refcounted in the array
|
|
|
|
nsIFolderListener* listener=(nsIFolderListener*)mListeners->ElementAt(i);
|
|
|
|
listener->OnItemUnicharPropertyChanged(supports, property, oldValue, newValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notify listeners who listen to every folder
|
2000-03-31 02:50:54 +04:00
|
|
|
NS_WITH_SERVICE(nsIFolderListener, folderListenerManager, kMsgFolderListenerManagerCID, &rv);
|
2000-01-14 12:01:39 +03:00
|
|
|
if (NS_SUCCEEDED(rv))
|
2000-03-31 02:50:54 +04:00
|
|
|
rv = folderListenerManager->OnItemUnicharPropertyChanged(supports,
|
|
|
|
property,
|
|
|
|
oldValue,
|
|
|
|
newValue);
|
2000-01-14 12:01:39 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsMsgFolder::NotifyIntPropertyChanged(nsIAtom *property, PRInt32 oldValue, PRInt32 newValue)
|
1999-11-23 01:08:23 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> supports;
|
2000-02-06 06:18:27 +03:00
|
|
|
if(NS_SUCCEEDED(QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(supports))))
|
1999-11-23 01:08:23 +03:00
|
|
|
{
|
|
|
|
PRInt32 i;
|
|
|
|
for(i = 0; i < mListeners->Count(); i++)
|
|
|
|
{
|
|
|
|
//Folderlistener's aren't refcounted.
|
|
|
|
nsIFolderListener* listener =(nsIFolderListener*)mListeners->ElementAt(i);
|
|
|
|
listener->OnItemIntPropertyChanged(supports, property, oldValue, newValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Notify listeners who listen to every folder
|
|
|
|
nsresult rv;
|
2000-03-31 02:50:54 +04:00
|
|
|
NS_WITH_SERVICE(nsIFolderListener, folderListenerManager, kMsgFolderListenerManagerCID, &rv);
|
1999-11-23 01:08:23 +03:00
|
|
|
if(NS_SUCCEEDED(rv))
|
2000-03-31 02:50:54 +04:00
|
|
|
folderListenerManager->OnItemIntPropertyChanged(supports, property, oldValue, newValue);
|
1999-11-23 01:08:23 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-01-14 12:01:39 +03:00
|
|
|
nsresult
|
|
|
|
nsMsgFolder::NotifyBoolPropertyChanged(nsIAtom* property,
|
|
|
|
PRBool oldValue, PRBool newValue)
|
1999-11-23 01:08:23 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> supports;
|
2000-02-06 06:18:27 +03:00
|
|
|
if(NS_SUCCEEDED(QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(supports))))
|
1999-11-23 01:08:23 +03:00
|
|
|
{
|
|
|
|
PRInt32 i;
|
|
|
|
for(i = 0; i < mListeners->Count(); i++)
|
|
|
|
{
|
|
|
|
//Folderlistener's aren't refcounted.
|
|
|
|
nsIFolderListener* listener =(nsIFolderListener*)mListeners->ElementAt(i);
|
|
|
|
listener->OnItemBoolPropertyChanged(supports, property, oldValue, newValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Notify listeners who listen to every folder
|
|
|
|
nsresult rv;
|
2000-03-31 02:50:54 +04:00
|
|
|
NS_WITH_SERVICE(nsIFolderListener, folderListenerManager, kMsgFolderListenerManagerCID, &rv);
|
1999-11-23 01:08:23 +03:00
|
|
|
if(NS_SUCCEEDED(rv))
|
2000-03-31 02:50:54 +04:00
|
|
|
folderListenerManager->OnItemBoolPropertyChanged(supports, property, oldValue, newValue);
|
1999-11-23 01:08:23 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-01-14 12:01:39 +03:00
|
|
|
nsresult
|
|
|
|
nsMsgFolder::NotifyPropertyFlagChanged(nsISupports *item, nsIAtom *property,
|
|
|
|
PRUint32 oldValue, PRUint32 newValue)
|
1999-05-14 04:45:25 +04:00
|
|
|
{
|
|
|
|
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;
|
2000-03-31 02:50:54 +04:00
|
|
|
NS_WITH_SERVICE(nsIFolderListener, folderListenerManager, kMsgFolderListenerManagerCID, &rv);
|
1999-05-14 04:45:25 +04:00
|
|
|
if(NS_SUCCEEDED(rv))
|
2000-03-31 02:50:54 +04:00
|
|
|
folderListenerManager->OnItemPropertyFlagChanged(item, property, oldValue, newValue);
|
1999-05-14 04:45:25 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-11 03:23:29 +03:00
|
|
|
nsresult nsMsgFolder::NotifyItemAdded(nsISupports *parentItem, nsISupports *item, const char* viewString)
|
1999-04-21 02:24:21 +04:00
|
|
|
{
|
1999-09-13 01:36:51 +04:00
|
|
|
static PRBool notify = PR_TRUE;
|
|
|
|
|
|
|
|
if (!notify)
|
|
|
|
return NS_OK;
|
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.
|
1999-04-21 02:24:21 +04:00
|
|
|
nsIFolderListener *listener = (nsIFolderListener*)mListeners->ElementAt(i);
|
1999-11-11 03:23:29 +03:00
|
|
|
listener->OnItemAdded(parentItem, item, viewString);
|
1999-04-21 02:24:21 +04:00
|
|
|
}
|
|
|
|
|
1999-05-14 04:45:25 +04:00
|
|
|
//Notify listeners who listen to every folder
|
|
|
|
nsresult rv;
|
2000-03-31 02:50:54 +04:00
|
|
|
NS_WITH_SERVICE(nsIFolderListener, folderListenerManager, kMsgFolderListenerManagerCID, &rv);
|
1999-05-14 04:45:25 +04:00
|
|
|
if(NS_SUCCEEDED(rv))
|
2000-03-31 02:50:54 +04:00
|
|
|
folderListenerManager->OnItemAdded(parentItem, item, viewString);
|
1999-05-14 04:45:25 +04:00
|
|
|
|
1999-04-21 02:24:21 +04:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-11-11 03:23:29 +03:00
|
|
|
nsresult nsMsgFolder::NotifyItemDeleted(nsISupports *parentItem, nsISupports *item, const char* viewString)
|
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.
|
1999-04-21 02:24:21 +04:00
|
|
|
nsIFolderListener *listener = (nsIFolderListener*)mListeners->ElementAt(i);
|
1999-11-11 03:23:29 +03:00
|
|
|
listener->OnItemRemoved(parentItem, item, viewString);
|
1999-04-21 02:24:21 +04:00
|
|
|
}
|
1999-05-14 04:45:25 +04:00
|
|
|
//Notify listeners who listen to every folder
|
|
|
|
nsresult rv;
|
2000-03-31 02:50:54 +04:00
|
|
|
NS_WITH_SERVICE(nsIFolderListener, folderListenerManager, kMsgFolderListenerManagerCID, &rv);
|
1999-05-14 04:45:25 +04:00
|
|
|
if(NS_SUCCEEDED(rv))
|
2000-03-31 02:50:54 +04:00
|
|
|
folderListenerManager->OnItemRemoved(parentItem, item, viewString);
|
1999-04-21 02:24:21 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-02-16 03:39:23 +03:00
|
|
|
|
2000-03-28 08:58:05 +04:00
|
|
|
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;
|
2000-03-31 02:50:54 +04:00
|
|
|
NS_WITH_SERVICE(nsIFolderListener, folderListenerManager, kMsgFolderListenerManagerCID, &rv);
|
2000-03-28 08:58:05 +04:00
|
|
|
if(NS_SUCCEEDED(rv))
|
2000-03-31 02:50:54 +04:00
|
|
|
folderListenerManager->OnItemEvent(this, aEvent);
|
2000-03-28 08:58:05 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-20 01:55:08 +03:00
|
|
|
nsresult
|
|
|
|
nsGetMailFolderSeparator(nsString& result)
|
|
|
|
{
|
2000-04-22 12:43:34 +04:00
|
|
|
result.AssignWithConversion(".sbd");
|
1999-03-20 01:55:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-24 17:58:32 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsMsgFolder::RecursiveSetDeleteIsMoveToTrash(PRBool bVal)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
if (mSubFolders)
|
|
|
|
{
|
|
|
|
PRUint32 cnt = 0, i;
|
|
|
|
rv = mSubFolders->Count(&cnt);
|
|
|
|
for (i=0; i < cnt; i++)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> aSupport;
|
|
|
|
rv = GetElementAt(i, getter_AddRefs(aSupport));
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIMsgFolder> folder;
|
|
|
|
folder = do_QueryInterface(aSupport);
|
|
|
|
if (folder)
|
|
|
|
folder->RecursiveSetDeleteIsMoveToTrash(bVal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return SetDeleteIsMoveToTrash(bVal);
|
|
|
|
}
|
2000-03-28 08:58:05 +04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|