# HG changeset patch # User aceman # Date 1515075540 -3600 # Node ID 298602f444343d7680cdbecaf962f8727be53112 # Parent 91d6fb3996135cb11b9fae9dfbb35cbf0b1dc908 Bug 464710 - remove RDF datasources nsMsgFolderDataSource.cpp and nsMsgAccountManagerDS.cpp. r=mkmelin,frg rs=bustage-fix diff --git a/mailnews/base/public/nsMsgBaseCID.h b/mailnews/base/public/nsMsgBaseCID.h --- a/mailnews/base/public/nsMsgBaseCID.h +++ b/mailnews/base/public/nsMsgBaseCID.h @@ -6,63 +6,16 @@ #ifndef nsMessageBaseCID_h__ #define nsMessageBaseCID_h__ #include "nsISupports.h" #include "nsIFactory.h" #include "nsIComponentManager.h" // -// nsMsgFolderDataSource -// -#define NS_MAILNEWSFOLDERDATASOURCE_CONTRACTID \ - NS_RDF_DATASOURCE_CONTRACTID_PREFIX "mailnewsfolders" - -#define NS_MAILNEWSFOLDERDATASOURCE_CID \ -{ /* 2B8ED4A4-F684-11d2-8A5D-0060B0FC04D2 */ \ - 0x2b8ed4a4, \ - 0xf684, \ - 0x11d2, \ - {0x8a, 0x5d, 0x0, 0x60, 0xb0, 0xfc, 0x4, 0xd2} \ -} - -#define NS_MAILNEWSUNREADFOLDERDATASOURCE_CONTRACTID \ - NS_RDF_DATASOURCE_CONTRACTID_PREFIX "mailnewsunreadfolders" - -#define NS_MAILNEWSUNREADFOLDERDATASOURCE_CID \ -{ /* 39b6b638-5b9d-45aa-b645-77fe56bbddb7 */ \ - 0x39b6b638, \ - 0x5b9d, \ - 0x45aa, \ - {0xb6, 0x45, 0x77, 0xfe, 0x56, 0xbb, 0xdd, 0xb7} \ -} - -#define NS_MAILNEWSFAVORITEFOLDERDATASOURCE_CONTRACTID \ - NS_RDF_DATASOURCE_CONTRACTID_PREFIX "mailnewsfavefolders" - -#define NS_MAILNEWSFAVORITEFOLDERDATASOURCE_CID \ -{ /* dfdedc28-1b0c-4b7a-bbff-c98808034242 */ \ - 0xdfdedc28, \ - 0x1b0c, \ - 0x4b7a, \ - {0xbb, 0xff, 0xc9, 0x88, 0x08, 0x03, 0x42, 0x42} \ -} - -#define NS_MAILNEWSRECENTFOLDERDATASOURCE_CONTRACTID \ - NS_RDF_DATASOURCE_CONTRACTID_PREFIX "mailnewsrecentfolders" - -#define NS_MAILNEWSRECENTFOLDERDATASOURCE_CID \ -{ /* 64921b82-24bb-4473-ada9-dc89426129a6 */ \ - 0x64921b82, \ - 0x24bb, \ - 0x4473, \ - {0xad, 0xa9, 0xdc, 0x89, 0x42, 0x61, 0x29, 0xa6} \ -} - -// // nsMsgAccountManager // #define NS_MSGACCOUNTMANAGER_CONTRACTID \ "@mozilla.org/messenger/account-manager;1" #define NS_MSGACCOUNTMANAGER_CID \ { /* D2876E50-E62C-11d2-B7FC-00805F05FFA5 */ \ 0xd2876e50, 0xe62c, 0x11d2, \ diff --git a/mailnews/base/src/moz.build b/mailnews/base/src/moz.build --- a/mailnews/base/src/moz.build +++ b/mailnews/base/src/moz.build @@ -15,25 +15,23 @@ SOURCES += [ 'nsCidProtocolHandler.cpp', 'nsCopyMessageStreamListener.cpp', 'nsMailDirProvider.cpp', 'nsMessenger.cpp', 'nsMessengerBootstrap.cpp', 'nsMessengerContentHandler.cpp', 'nsMsgAccount.cpp', 'nsMsgAccountManager.cpp', - 'nsMsgAccountManagerDS.cpp', 'nsMsgBiffManager.cpp', 'nsMsgContentPolicy.cpp', 'nsMsgCopyService.cpp', 'nsMsgDBView.cpp', 'nsMsgFolderCache.cpp', 'nsMsgFolderCacheElement.cpp', 'nsMsgFolderCompactor.cpp', - 'nsMsgFolderDataSource.cpp', 'nsMsgFolderNotificationService.cpp', 'nsMsgGroupThread.cpp', 'nsMsgGroupView.cpp', 'nsMsgMailSession.cpp', 'nsMsgOfflineManager.cpp', 'nsMsgProgress.cpp', 'nsMsgPurgeService.cpp', 'nsMsgQuickSearchDBView.cpp', diff --git a/mailnews/base/src/nsMsgAccountManagerDS.cpp b/mailnews/base/src/nsMsgAccountManagerDS.cpp deleted file mode 100644 --- a/mailnews/base/src/nsMsgAccountManagerDS.cpp +++ /dev/null @@ -1,1176 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * RDF datasource for the account manager - */ - -#include "nsMsgAccountManagerDS.h" -#include "rdf.h" -#include "nsRDFCID.h" -#include "nsIRDFDataSource.h" -#include "nsEnumeratorUtils.h" -#include "nsIServiceManager.h" -#include "nsMsgRDFUtils.h" -#include "nsIMsgFolder.h" -#include "nsMsgBaseCID.h" - -#include "nsICategoryManager.h" -#include "nsXPCOM.h" -#include "nsISupportsPrimitives.h" -#include "nsServiceManagerUtils.h" -#include "nsComponentManagerUtils.h" -#include "nsArrayEnumerator.h" -#include "nsMsgUtils.h" -#include "mozilla/Services.h" -#include "nsArrayUtils.h" - -// turn this on to see useful output -#undef DEBUG_amds - -#define NC_RDF_PAGETITLE_PREFIX NC_NAMESPACE_URI "PageTitle" -#define NC_RDF_PAGETITLE_MAIN NC_RDF_PAGETITLE_PREFIX "Main" -#define NC_RDF_PAGETITLE_SERVER NC_RDF_PAGETITLE_PREFIX "Server" -#define NC_RDF_PAGETITLE_COPIES NC_RDF_PAGETITLE_PREFIX "Copies" -#define NC_RDF_PAGETITLE_SYNCHRONIZATION NC_RDF_PAGETITLE_PREFIX "Synchronization" -#define NC_RDF_PAGETITLE_DISKSPACE NC_RDF_PAGETITLE_PREFIX "DiskSpace" -#define NC_RDF_PAGETITLE_ADDRESSING NC_RDF_PAGETITLE_PREFIX "Addressing" -#define NC_RDF_PAGETITLE_SMTP NC_RDF_PAGETITLE_PREFIX "SMTP" -#define NC_RDF_PAGETITLE_JUNK NC_RDF_PAGETITLE_PREFIX "Junk" -#define NC_RDF_PAGETAG NC_NAMESPACE_URI "PageTag" - - -#define NC_RDF_ACCOUNTROOT "msgaccounts:/" - -// the root resource (msgaccounts:/) -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_AccountRoot=nullptr; - -// attributes of accounts -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Name=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_FolderTreeName=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_FolderTreeSimpleName=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_NameSort=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_FolderTreeNameSort=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTag=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_IsDefaultServer=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_SupportsFilters=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_CanGetMessages=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_CanGetIncomingMessages=nullptr; - -// containment -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Child=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Settings=nullptr; - - -// properties corresponding to interfaces -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Account=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Server=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Identity=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_Junk=nullptr; - -// individual pages -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleMain=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleServer=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleCopies=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleSynchronization=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleDiskSpace=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleAddressing=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleSMTP=nullptr; -nsIRDFResource* nsMsgAccountManagerDataSource::kNC_PageTitleJunk=nullptr; - -// common literals -nsIRDFLiteral* nsMsgAccountManagerDataSource::kTrueLiteral = nullptr; - -nsIAtom* nsMsgAccountManagerDataSource::kDefaultServerAtom = nullptr; - -nsrefcnt nsMsgAccountManagerDataSource::gAccountManagerResourceRefCnt = 0; - -// shared arc lists -nsCOMPtr nsMsgAccountManagerDataSource::mAccountArcsOut; -nsCOMPtr nsMsgAccountManagerDataSource::mAccountRootArcsOut; - - -// RDF to match -#define NC_RDF_ACCOUNT NC_NAMESPACE_URI "Account" -#define NC_RDF_SERVER NC_NAMESPACE_URI "Server" -#define NC_RDF_IDENTITY NC_NAMESPACE_URI "Identity" -#define NC_RDF_SETTINGS NC_NAMESPACE_URI "Settings" -#define NC_RDF_JUNK NC_NAMESPACE_URI "Junk" -#define NC_RDF_ISDEFAULTSERVER NC_NAMESPACE_URI "IsDefaultServer" -#define NC_RDF_SUPPORTSFILTERS NC_NAMESPACE_URI "SupportsFilters" -#define NC_RDF_CANGETMESSAGES NC_NAMESPACE_URI "CanGetMessages" -#define NC_RDF_CANGETINCOMINGMESSAGES NC_NAMESPACE_URI "CanGetIncomingMessages" - -nsMsgAccountManagerDataSource::nsMsgAccountManagerDataSource() -{ -#ifdef DEBUG_amds - printf("nsMsgAccountManagerDataSource() being created\n"); -#endif - - // do per-class initialization here - if (gAccountManagerResourceRefCnt++ == 0) { - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHILD), &kNC_Child); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME), &kNC_Name); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREENAME), - &kNC_FolderTreeName); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREESIMPLENAME), - &kNC_FolderTreeSimpleName); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME_SORT), &kNC_NameSort); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREENAME_SORT), - &kNC_FolderTreeNameSort); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETAG), &kNC_PageTag); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISDEFAULTSERVER), - &kNC_IsDefaultServer); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_SUPPORTSFILTERS), - &kNC_SupportsFilters); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANGETMESSAGES), - &kNC_CanGetMessages); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANGETINCOMINGMESSAGES), - &kNC_CanGetIncomingMessages); - - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_ACCOUNT), &kNC_Account); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_SERVER), &kNC_Server); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_IDENTITY), &kNC_Identity); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_JUNK), &kNC_Junk); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_MAIN), - &kNC_PageTitleMain); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_SERVER), - &kNC_PageTitleServer); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_COPIES), - &kNC_PageTitleCopies); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_SYNCHRONIZATION), - &kNC_PageTitleSynchronization); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_DISKSPACE), - &kNC_PageTitleDiskSpace); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_ADDRESSING), - &kNC_PageTitleAddressing); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_SMTP), - &kNC_PageTitleSMTP); - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_PAGETITLE_JUNK), - &kNC_PageTitleJunk); - - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_ACCOUNTROOT), - &kNC_AccountRoot); - - getRDFService()->GetLiteral(u"true", - &kTrueLiteral); - - // eventually these need to exist in some kind of array - // that's easily extensible - getRDFService()->GetResource(NS_LITERAL_CSTRING(NC_RDF_SETTINGS), &kNC_Settings); - - kDefaultServerAtom = MsgNewAtom("DefaultServer").take(); - } -} - -nsMsgAccountManagerDataSource::~nsMsgAccountManagerDataSource() -{ - nsCOMPtr am = do_QueryReferent(mAccountManager); - if (am) - am->RemoveIncomingServerListener(this); - - if (--gAccountManagerResourceRefCnt == 0) { - NS_IF_RELEASE(kNC_Child); - NS_IF_RELEASE(kNC_Name); - NS_IF_RELEASE(kNC_FolderTreeName); - NS_IF_RELEASE(kNC_FolderTreeSimpleName); - NS_IF_RELEASE(kNC_NameSort); - NS_IF_RELEASE(kNC_FolderTreeNameSort); - NS_IF_RELEASE(kNC_PageTag); - NS_IF_RELEASE(kNC_IsDefaultServer); - NS_IF_RELEASE(kNC_SupportsFilters); - NS_IF_RELEASE(kNC_CanGetMessages); - NS_IF_RELEASE(kNC_CanGetIncomingMessages); - NS_IF_RELEASE(kNC_Account); - NS_IF_RELEASE(kNC_Server); - NS_IF_RELEASE(kNC_Identity); - NS_IF_RELEASE(kNC_Junk); - NS_IF_RELEASE(kNC_PageTitleMain); - NS_IF_RELEASE(kNC_PageTitleServer); - NS_IF_RELEASE(kNC_PageTitleCopies); - NS_IF_RELEASE(kNC_PageTitleSynchronization); - NS_IF_RELEASE(kNC_PageTitleDiskSpace); - NS_IF_RELEASE(kNC_PageTitleAddressing); - NS_IF_RELEASE(kNC_PageTitleSMTP); - NS_IF_RELEASE(kNC_PageTitleJunk); - NS_IF_RELEASE(kTrueLiteral); - - NS_IF_RELEASE(kNC_AccountRoot); - - // eventually these need to exist in some kind of array - // that's easily extensible - NS_IF_RELEASE(kNC_Settings); - - - NS_IF_RELEASE(kDefaultServerAtom); - mAccountArcsOut = nullptr; - mAccountRootArcsOut = nullptr; - } - -} - -NS_IMPL_ADDREF_INHERITED(nsMsgAccountManagerDataSource, nsMsgRDFDataSource) -NS_IMPL_RELEASE_INHERITED(nsMsgAccountManagerDataSource, nsMsgRDFDataSource) -NS_INTERFACE_MAP_BEGIN(nsMsgAccountManagerDataSource) - NS_INTERFACE_MAP_ENTRY(nsIIncomingServerListener) - NS_INTERFACE_MAP_ENTRY(nsIFolderListener) -NS_INTERFACE_MAP_END_INHERITING(nsMsgRDFDataSource) - -nsresult -nsMsgAccountManagerDataSource::Init() -{ - nsresult rv; - - rv = nsMsgRDFDataSource::Init(); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr am; - - // get a weak ref to the account manager - if (!mAccountManager) - { - am = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); - mAccountManager = do_GetWeakReference(am); - } - else - am = do_QueryReferent(mAccountManager); - - if (am) - { - am->AddIncomingServerListener(this); - am->AddRootFolderListener(this); - } - - - return NS_OK; -} - -void nsMsgAccountManagerDataSource::Cleanup() -{ - nsCOMPtr am = do_QueryReferent(mAccountManager); - - if (am) - { - am->RemoveIncomingServerListener(this); - am->RemoveRootFolderListener(this); - } - - nsMsgRDFDataSource::Cleanup(); -} - -/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource property, in boolean aTruthValue); */ -NS_IMETHODIMP -nsMsgAccountManagerDataSource::GetTarget(nsIRDFResource *source, - nsIRDFResource *property, - bool aTruthValue, - nsIRDFNode **target) -{ - nsresult rv; - - - rv = NS_RDF_NO_VALUE; - - nsAutoString str; - if (property == kNC_Name || property == kNC_FolderTreeName || - property == kNC_FolderTreeSimpleName) - { - rv = getStringBundle(); - NS_ENSURE_SUCCESS(rv, rv); - - nsString pageTitle; - if (source == kNC_PageTitleServer) - mStringBundle->GetStringFromName("prefPanel-server", pageTitle); - - else if (source == kNC_PageTitleCopies) - mStringBundle->GetStringFromName("prefPanel-copies", pageTitle); - else if (source == kNC_PageTitleSynchronization) - mStringBundle->GetStringFromName("prefPanel-synchronization", pageTitle); - else if (source == kNC_PageTitleDiskSpace) - mStringBundle->GetStringFromName("prefPanel-diskspace", pageTitle); - else if (source == kNC_PageTitleAddressing) - mStringBundle->GetStringFromName("prefPanel-addressing", pageTitle); - else if (source == kNC_PageTitleSMTP) - mStringBundle->GetStringFromName("prefPanel-smtp", pageTitle); - else if (source == kNC_PageTitleJunk) - mStringBundle->GetStringFromName("prefPanel-junk", pageTitle); - - else { - // if it's a server, use the pretty name - nsCOMPtr folder = do_QueryInterface(source, &rv); - if (NS_SUCCEEDED(rv) && folder) { - bool isServer; - rv = folder->GetIsServer(&isServer); - if (NS_SUCCEEDED(rv) && isServer) - rv = folder->GetPrettyName(pageTitle); - } - else { - // allow for the accountmanager to be dynamically extended. - - nsCOMPtr strBundleService = - mozilla::services::GetStringBundleService(); - NS_ENSURE_TRUE(strBundleService, NS_ERROR_UNEXPECTED); - - const char *sourceValue; - rv = source->GetValueConst(&sourceValue); - NS_ENSURE_SUCCESS(rv,rv); - - // make sure the pointer math we're about to do is safe. - NS_ENSURE_TRUE(sourceValue && (strlen(sourceValue) > strlen(NC_RDF_PAGETITLE_PREFIX)), NS_ERROR_UNEXPECTED); - - nsCOMPtr am = do_QueryReferent(mAccountManager, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - // turn NC#PageTitlefoobar into foobar, so we can get the am-foobar.properties bundle - nsCString chromePackageName; - rv = am->GetChromePackageName(nsCString(sourceValue + strlen(NC_RDF_PAGETITLE_PREFIX)), chromePackageName); - NS_ENSURE_SUCCESS(rv,rv); - - nsAutoCString bundleURL; - bundleURL = "chrome://"; - bundleURL += chromePackageName; - bundleURL += "/locale/am-"; - bundleURL += (sourceValue + strlen(NC_RDF_PAGETITLE_PREFIX)); - bundleURL += ".properties"; - - nsCOMPtr bundle; - rv = strBundleService->CreateBundle(bundleURL.get(), getter_AddRefs(bundle)); - - NS_ENSURE_SUCCESS(rv,rv); - - nsAutoCString panelTitleName; - panelTitleName.AssignLiteral("prefPanel-"); - panelTitleName.Append(sourceValue + strlen(NC_RDF_PAGETITLE_PREFIX)); - bundle->GetStringFromName(panelTitleName.get(), pageTitle); - } - } - str = pageTitle.get(); - } - else if (property == kNC_PageTag) { - // do NOT localize these strings. these are the urls of the XUL files - if (source == kNC_PageTitleServer) - str.AssignLiteral("am-server.xul"); - else if (source == kNC_PageTitleCopies) - str.AssignLiteral("am-copies.xul"); - else if ((source == kNC_PageTitleSynchronization) || - (source == kNC_PageTitleDiskSpace)) - str.AssignLiteral("am-offline.xul"); - else if (source == kNC_PageTitleAddressing) - str.AssignLiteral("am-addressing.xul"); - else if (source == kNC_PageTitleSMTP) - str.AssignLiteral("am-smtp.xul"); - else if (source == kNC_PageTitleJunk) - str.AssignLiteral("am-junk.xul"); - else { - nsCOMPtr folder = do_QueryInterface(source, &rv); - if (NS_SUCCEEDED(rv) && folder) { - /* if this is a server, with no identities, then we show a special panel */ - nsCOMPtr server; - rv = getServerForFolderNode(source, getter_AddRefs(server)); - if (server) - server->GetAccountManagerChrome(str); - else - str.AssignLiteral("am-main.xul"); - } - else { - // allow for the accountmanager to be dynamically extended - const char *sourceValue; - rv = source->GetValueConst(&sourceValue); - NS_ENSURE_SUCCESS(rv,rv); - - // make sure the pointer math we're about to do is safe. - NS_ENSURE_TRUE(sourceValue && (strlen(sourceValue) > strlen(NC_RDF_PAGETITLE_PREFIX)), NS_ERROR_UNEXPECTED); - - // turn NC#PageTitlefoobar into foobar, so we can get the am-foobar.xul file - str.AssignLiteral("am-"); - str.Append(NS_ConvertASCIItoUTF16(sourceValue + strlen(NC_RDF_PAGETITLE_PREFIX))); - str.AppendLiteral(".xul"); - } - } - } - - // handle sorting of servers - else if ((property == kNC_NameSort) || - (property == kNC_FolderTreeNameSort)) { - - // order for the folder pane - // and for the account manager tree is: - // - // - default mail account - // - - // - "Local Folders" account - // - news accounts - // - smtp settings (note, this is only in account manager tree) - - // make sure we're handling a root folder that is a server - nsCOMPtr server; - rv = getServerForFolderNode(source, getter_AddRefs(server)); - - if (NS_SUCCEEDED(rv) && server) { - int32_t accountNum; - nsCOMPtr am = do_QueryReferent(mAccountManager); - - if (isDefaultServer(server)) - str.AssignLiteral("000000000"); - else { - rv = am->GetSortOrder(server, &accountNum); - NS_ENSURE_SUCCESS(rv, rv); - str.AppendInt(accountNum); - } - } - else { - const char *sourceValue; - rv = source->GetValueConst(&sourceValue); - NS_ENSURE_SUCCESS(rv, NS_RDF_NO_VALUE); - - // if this is a page (which we determine by the prefix of the URI) - // we want to generate a sort value - // so that we can sort the categories in the account manager tree - // (or the folder pane) - // - // otherwise, return NS_RDF_NO_VALUE - // so that the folder data source will take care of it. - if (sourceValue && (strncmp(sourceValue, NC_RDF_PAGETITLE_PREFIX, strlen(NC_RDF_PAGETITLE_PREFIX)) == 0)) { - if (source == kNC_PageTitleSMTP) - str.AssignLiteral("900000000"); - else if (source == kNC_PageTitleServer) - str.Assign('1'); - else if (source == kNC_PageTitleCopies) - str.Assign('2'); - else if (source == kNC_PageTitleAddressing) - str.Assign('3'); - else if (source == kNC_PageTitleSynchronization) - str.Assign('4'); - else if (source == kNC_PageTitleDiskSpace) - str.Assign('4'); - else if (source == kNC_PageTitleJunk) - str.Assign('5'); - else { - // allow for the accountmanager to be dynamically extended - // all the other pages come after the standard ones - // server, copies, addressing, disk space (or offline & disk space) - CopyASCIItoUTF16(nsDependentCString(sourceValue), str); - } - } - else { - return NS_RDF_NO_VALUE; - } - } - } - - // GetTargets() stuff - need to return a valid answer so that - // twisties will appear - else if (property == kNC_Settings) { - nsCOMPtr folder = do_QueryInterface(source,&rv); - if (NS_FAILED(rv)) - return NS_RDF_NO_VALUE; - - bool isServer=false; - folder->GetIsServer(&isServer); - // no need to localize this! - if (isServer) - str.AssignLiteral("ServerSettings"); - } - - else if (property == kNC_IsDefaultServer) { - nsCOMPtr thisServer; - rv = getServerForFolderNode(source, getter_AddRefs(thisServer)); - if (NS_FAILED(rv) || !thisServer) return NS_RDF_NO_VALUE; - - if (isDefaultServer(thisServer)) - str.AssignLiteral("true"); - } - - else if (property == kNC_SupportsFilters) { - nsCOMPtr server; - rv = getServerForFolderNode(source, getter_AddRefs(server)); - if (NS_FAILED(rv) || !server) return NS_RDF_NO_VALUE; - - if (supportsFilters(server)) - str.AssignLiteral("true"); - } - else if (property == kNC_CanGetMessages) { - nsCOMPtr server; - rv = getServerForFolderNode(source, getter_AddRefs(server)); - if (NS_FAILED(rv) || !server) return NS_RDF_NO_VALUE; - - if (canGetMessages(server)) - str.AssignLiteral("true"); - } - else if (property == kNC_CanGetIncomingMessages) { - nsCOMPtr server; - rv = getServerForFolderNode(source, getter_AddRefs(server)); - if (NS_FAILED(rv) || !server) return NS_RDF_NO_VALUE; - - if (canGetIncomingMessages(server)) - str.AssignLiteral("true"); - } - - if (!str.IsEmpty()) - rv = createNode(str.get(), target, getRDFService()); - - //if we have an empty string and we don't have an error value, then - //we don't have a value for RDF. - else if(NS_SUCCEEDED(rv)) - rv = NS_RDF_NO_VALUE; - - return rv; -} - - - -/* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource property, in boolean aTruthValue); */ -NS_IMETHODIMP -nsMsgAccountManagerDataSource::GetTargets(nsIRDFResource *source, - nsIRDFResource *property, - bool aTruthValue, - nsISimpleEnumerator **_retval) -{ - nsresult rv = NS_RDF_NO_VALUE; - - // create array and enumerator - // even if we're not handling this we need to return something empty? - nsCOMArray nodes; - if (NS_FAILED(rv)) return rv; - if (source == kNC_AccountRoot) - rv = createRootResources(property, &nodes); - else if (property == kNC_Settings) - rv = createSettingsResources(source, &nodes); - - if (NS_FAILED(rv)) - return NS_RDF_NO_VALUE; - return NS_NewArrayEnumerator(_retval, nodes); -} - -// end of all arcs coming out of msgaccounts:/ -nsresult -nsMsgAccountManagerDataSource::createRootResources(nsIRDFResource *property, - nsCOMArray *aNodeArray) -{ - nsresult rv = NS_OK; - if (isContainment(property)) { - - nsCOMPtr am = do_QueryReferent(mAccountManager); - if (!am) return NS_ERROR_FAILURE; - - nsCOMPtr servers; - rv = am->GetAllServers(getter_AddRefs(servers)); - NS_ENSURE_SUCCESS(rv, rv); - - uint32_t length; - rv = servers->GetLength(&length); - NS_ENSURE_SUCCESS(rv, rv); - - for (uint32_t i = 0; i < length; ++i) - { - nsCOMPtr server(do_QueryElementAt(servers, i, &rv)); - if (NS_FAILED(rv)) - continue; - - nsCOMPtr serverFolder; - rv = server->GetRootFolder(getter_AddRefs(serverFolder)); - if (NS_FAILED(rv)) - continue; - - // add the resource to the array - nsCOMPtr serverResource = do_QueryInterface(serverFolder); - if (serverResource) - (void) aNodeArray->AppendObject(serverResource); - } - -#ifdef DEBUG_amds - uint32_t nodecount; - aNodeArray->GetLength(&nodecount); - printf("GetTargets(): added %d servers on %s\n", nodecount, - (const char*)property_arc); -#endif - // For the "settings" arc, we also want to add SMTP setting. - if (property == kNC_Settings) { - aNodeArray->AppendObject(kNC_PageTitleSMTP); - } - } - -#ifdef DEBUG_amds - else { - printf("unknown arc %s on msgaccounts:/\n", (const char*)property_arc); - } -#endif - - return rv; -} - -nsresult -nsMsgAccountManagerDataSource::appendGenericSettingsResources(nsIMsgIncomingServer *server, nsCOMArray *aNodeArray) -{ - nsresult rv; - - nsCOMPtr catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv,rv); - - nsCOMPtr e; - rv = catman->EnumerateCategory(MAILNEWS_ACCOUNTMANAGER_EXTENSIONS, getter_AddRefs(e)); - if(NS_SUCCEEDED(rv) && e) { - while (true) { - nsCOMPtr supports; - rv = e->GetNext(getter_AddRefs(supports)); - nsCOMPtr catEntry = do_QueryInterface(supports); - if (NS_FAILED(rv) || !catEntry) - break; - - nsAutoCString entryString; - rv = catEntry->GetData(entryString); - if (NS_FAILED(rv)) - break; - - nsCString contractidString; - rv = catman->GetCategoryEntry(MAILNEWS_ACCOUNTMANAGER_EXTENSIONS, entryString.get(), getter_Copies(contractidString)); - if (NS_FAILED(rv)) - break; - - nsCOMPtr extension = - do_GetService(contractidString.get(), &rv); - if (NS_FAILED(rv) || !extension) - break; - - bool showPanel; - rv = extension->ShowPanel(server, &showPanel); - if (NS_FAILED(rv)) - break; - - if (showPanel) { - nsCString name; - rv = extension->GetName(name); - if (NS_FAILED(rv)) - break; - - rv = appendGenericSetting(name.get(), aNodeArray); - if (NS_FAILED(rv)) - break; - } - } - } - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::appendGenericSetting(const char *name, - nsCOMArray *aNodeArray) -{ - NS_ENSURE_ARG_POINTER(name); - NS_ENSURE_ARG_POINTER(aNodeArray); - - nsCOMPtr resource; - - nsAutoCString resourceStr; - resourceStr = NC_RDF_PAGETITLE_PREFIX; - resourceStr += name; - - nsresult rv = getRDFService()->GetResource(resourceStr, getter_AddRefs(resource)); - NS_ENSURE_SUCCESS(rv,rv); - - // AppendElement will addref. - aNodeArray->AppendObject(resource); - return NS_OK; -} - -// end of all #Settings arcs -nsresult -nsMsgAccountManagerDataSource::createSettingsResources(nsIRDFResource *aSource, - nsCOMArray *aNodeArray) -{ - // If this isn't a server, just return. - if (aSource == kNC_PageTitleSMTP) - return NS_OK; - - nsCOMPtr server; - getServerForFolderNode(aSource, getter_AddRefs(server)); - if (server) { - bool hasIdentities; - nsresult rv = serverHasIdentities(server, &hasIdentities); - - if (hasIdentities) { - aNodeArray->AppendObject(kNC_PageTitleServer); - aNodeArray->AppendObject(kNC_PageTitleCopies); - aNodeArray->AppendObject(kNC_PageTitleAddressing); - } - - // Junk settings apply for all server types except for news and rss. - nsCString serverType; - server->GetType(serverType); - if (!MsgLowerCaseEqualsLiteral(serverType, "nntp") && - !MsgLowerCaseEqualsLiteral(serverType, "rss")) - aNodeArray->AppendObject(kNC_PageTitleJunk); - - // Check the offline capability before adding - // offline item - int32_t offlineSupportLevel = 0; - rv = server->GetOfflineSupportLevel(&offlineSupportLevel); - NS_ENSURE_SUCCESS(rv,rv); - - bool supportsDiskSpace; - rv = server->GetSupportsDiskSpace(&supportsDiskSpace); - NS_ENSURE_SUCCESS(rv,rv); - - // currently there is no offline without diskspace - if (offlineSupportLevel >= OFFLINE_SUPPORT_LEVEL_REGULAR) - aNodeArray->AppendObject(kNC_PageTitleSynchronization); - else if (supportsDiskSpace) - aNodeArray->AppendObject(kNC_PageTitleDiskSpace); - - if (hasIdentities) { - // extensions come after the default panels - rv = appendGenericSettingsResources(server, aNodeArray); - NS_ASSERTION(NS_SUCCEEDED(rv), "failed to add generic panels"); - } - } - - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::serverHasIdentities(nsIMsgIncomingServer* aServer, - bool *aResult) -{ - nsresult rv; - *aResult = false; - - nsCOMPtr am = do_QueryReferent(mAccountManager, &rv); - - if (NS_FAILED(rv)) return rv; - - nsCOMPtr identities; - rv = am->GetIdentitiesForServer(aServer, getter_AddRefs(identities)); - - // no identities just means no arcs - if (NS_FAILED(rv)) return NS_OK; - - uint32_t count; - rv = identities->GetLength(&count); - if (NS_FAILED(rv)) return NS_OK; - - if (count >0) - *aResult = true; - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::getAccountArcs(nsIMutableArray **aResult) -{ - nsresult rv; - if (!mAccountArcsOut) { - mAccountArcsOut = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - mAccountArcsOut->AppendElement(kNC_Settings); - mAccountArcsOut->AppendElement(kNC_Name); - mAccountArcsOut->AppendElement(kNC_FolderTreeName); - mAccountArcsOut->AppendElement(kNC_FolderTreeSimpleName); - mAccountArcsOut->AppendElement(kNC_NameSort); - mAccountArcsOut->AppendElement(kNC_FolderTreeNameSort); - mAccountArcsOut->AppendElement(kNC_PageTag); - } - - *aResult = mAccountArcsOut; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::getAccountRootArcs(nsIMutableArray **aResult) -{ - nsresult rv; - if (!mAccountRootArcsOut) { - mAccountRootArcsOut = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - mAccountRootArcsOut->AppendElement(kNC_Server); - mAccountRootArcsOut->AppendElement(kNC_Child); - - mAccountRootArcsOut->AppendElement(kNC_Settings); - mAccountRootArcsOut->AppendElement(kNC_Name); - mAccountRootArcsOut->AppendElement(kNC_FolderTreeName); - mAccountRootArcsOut->AppendElement(kNC_FolderTreeSimpleName); - mAccountRootArcsOut->AppendElement(kNC_NameSort); - mAccountRootArcsOut->AppendElement(kNC_FolderTreeNameSort); - mAccountRootArcsOut->AppendElement(kNC_PageTag); - } - - *aResult = mAccountRootArcsOut; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -NS_IMETHODIMP -nsMsgAccountManagerDataSource::HasArcOut(nsIRDFResource *source, nsIRDFResource *aArc, bool *result) -{ - if (aArc == kNC_Settings) { - // based on createSettingsResources() - // we only have settings for local folders and servers with identities - nsCOMPtr server; - nsresult rv = getServerForFolderNode(source, getter_AddRefs(server)); - if (NS_SUCCEEDED(rv) && server) { - // Check the offline capability before adding arc - int32_t offlineSupportLevel = 0; - (void) server->GetOfflineSupportLevel(&offlineSupportLevel); - if (offlineSupportLevel >= OFFLINE_SUPPORT_LEVEL_REGULAR) { - *result = true; - return NS_OK; - } - - bool supportsDiskSpace; - (void) server->GetSupportsDiskSpace(&supportsDiskSpace); - if (supportsDiskSpace) { - *result = true; - return NS_OK; - } - return serverHasIdentities(server, result); - } - } - - *result = false; - return NS_OK; -} - -/* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */ -NS_IMETHODIMP -nsMsgAccountManagerDataSource::ArcLabelsOut(nsIRDFResource *source, - nsISimpleEnumerator **_retval) -{ - nsresult rv; - - // we have to return something, so always create the array/enumerators - nsCOMPtr arcs; - if (source == kNC_AccountRoot) - rv = getAccountRootArcs(getter_AddRefs(arcs)); - else - rv = getAccountArcs(getter_AddRefs(arcs)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = NS_NewArrayEnumerator(_retval, arcs); - if (NS_FAILED(rv)) return rv; - -#ifdef DEBUG_amds_ - printf("GetArcLabelsOut(%s): Adding child, settings, and name arclabels\n", value); -#endif - - return NS_OK; -} - -NS_IMETHODIMP -nsMsgAccountManagerDataSource::HasAssertion(nsIRDFResource *aSource, - nsIRDFResource *aProperty, - nsIRDFNode *aTarget, - bool aTruthValue, - bool *_retval) -{ - nsresult rv=NS_ERROR_FAILURE; - - // - // msgaccounts:/ properties - // - if (aSource == kNC_AccountRoot) { - rv = HasAssertionAccountRoot(aProperty, aTarget, aTruthValue, _retval); - } - // - // server properties - // try to convert the resource to a folder, and then only - // answer if it's a server.. any failure falls through to the default case - // - // short-circuit on property, so objects like filters, etc, don't get queried - else if (aProperty == kNC_IsDefaultServer || aProperty == kNC_CanGetMessages || - aProperty == kNC_CanGetIncomingMessages || aProperty == kNC_SupportsFilters) { - nsCOMPtr server; - rv = getServerForFolderNode(aSource, getter_AddRefs(server)); - if (NS_SUCCEEDED(rv) && server) - rv = HasAssertionServer(server, aProperty, aTarget, - aTruthValue, _retval); - } - - // any failures above fallthrough to the parent class - if (NS_FAILED(rv)) - return nsMsgRDFDataSource::HasAssertion(aSource, aProperty, - aTarget, aTruthValue, _retval); - return NS_OK; -} - - - -nsresult -nsMsgAccountManagerDataSource::HasAssertionServer(nsIMsgIncomingServer *aServer, - nsIRDFResource *aProperty, - nsIRDFNode *aTarget, - bool aTruthValue, - bool *_retval) -{ - if (aProperty == kNC_IsDefaultServer) - *_retval = (aTarget == kTrueLiteral) ? isDefaultServer(aServer) : !isDefaultServer(aServer); - else if (aProperty == kNC_SupportsFilters) - *_retval = (aTarget == kTrueLiteral) ? supportsFilters(aServer) : !supportsFilters(aServer); - else if (aProperty == kNC_CanGetMessages) - *_retval = (aTarget == kTrueLiteral) ? canGetMessages(aServer) : !canGetMessages(aServer); - else if (aProperty == kNC_CanGetIncomingMessages) - *_retval = (aTarget == kTrueLiteral) ? canGetIncomingMessages(aServer) : !canGetIncomingMessages(aServer); - else - *_retval = false; - return NS_OK; -} - -bool -nsMsgAccountManagerDataSource::isDefaultServer(nsIMsgIncomingServer *aServer) -{ - nsresult rv; - if (!aServer) return false; - - nsCOMPtr am = do_QueryReferent(mAccountManager, &rv); - NS_ENSURE_SUCCESS(rv, false); - - nsCOMPtr defaultAccount; - rv = am->GetDefaultAccount(getter_AddRefs(defaultAccount)); - NS_ENSURE_SUCCESS(rv, false); - if (!defaultAccount) return false; - - // in some weird case that there is no default and they asked - // for the default - nsCOMPtr defaultServer; - rv = defaultAccount->GetIncomingServer(getter_AddRefs(defaultServer)); - NS_ENSURE_SUCCESS(rv, false); - if (!defaultServer) return false; - - bool isEqual; - rv = defaultServer->Equals(aServer, &isEqual); - NS_ENSURE_SUCCESS(rv, false); - - return isEqual; -} - - -bool -nsMsgAccountManagerDataSource::supportsFilters(nsIMsgIncomingServer *aServer) -{ - bool supportsFilters; - nsresult rv = aServer->GetCanHaveFilters(&supportsFilters); - NS_ENSURE_SUCCESS(rv, false); - - return supportsFilters; -} - -bool -nsMsgAccountManagerDataSource::canGetMessages(nsIMsgIncomingServer *aServer) -{ - nsCOMPtr protocolInfo; - nsresult rv = aServer->GetProtocolInfo(getter_AddRefs(protocolInfo)); - NS_ENSURE_SUCCESS(rv, false); - - bool canGetMessages; - rv = protocolInfo->GetCanGetMessages(&canGetMessages); - NS_ENSURE_SUCCESS(rv, false); - - return canGetMessages; -} - -bool -nsMsgAccountManagerDataSource::canGetIncomingMessages(nsIMsgIncomingServer *aServer) -{ - nsCOMPtr protocolInfo; - nsresult rv = aServer->GetProtocolInfo(getter_AddRefs(protocolInfo)); - NS_ENSURE_SUCCESS(rv, false); - - bool canGetIncomingMessages; - rv = protocolInfo->GetCanGetIncomingMessages(&canGetIncomingMessages); - NS_ENSURE_SUCCESS(rv, false); - - return canGetIncomingMessages; -} - -nsresult -nsMsgAccountManagerDataSource::HasAssertionAccountRoot(nsIRDFResource *aProperty, - nsIRDFNode *aTarget, - bool aTruthValue, - bool *_retval) -{ - // set up default - *_retval = false; - - // for child and settings arcs, just make sure it's a valid server: - if (isContainment(aProperty)) { - - nsCOMPtr server; - nsresult rv = getServerForFolderNode(aTarget, getter_AddRefs(server)); - if (NS_FAILED(rv) || !server) return rv; - - nsCString serverKey; - server->GetKey(serverKey); - - nsCOMPtr am = do_QueryReferent(mAccountManager, &rv); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr serverArray; - rv = am->GetAllServers(getter_AddRefs(serverArray)); - NS_ENSURE_SUCCESS(rv, rv); - - uint32_t length; - rv = serverArray->GetLength(&length); - NS_ENSURE_SUCCESS(rv, rv); - - for (uint32_t i = 0; i < length; ++i) - { - nsCOMPtr server(do_QueryElementAt(serverArray, i, &rv)); - if (NS_FAILED(rv)) - continue; - - nsCString key; - server->GetKey(key); - if (key.Equals(serverKey)) - { - *_retval = true; - break; - } - } - } - - return NS_OK; -} - -bool -nsMsgAccountManagerDataSource::isContainment(nsIRDFResource *aProperty) -{ - - if (aProperty == kNC_Child || - aProperty == kNC_Settings) - return true; - return false; -} - -// returns failure if the object is not a root server -nsresult -nsMsgAccountManagerDataSource::getServerForFolderNode(nsIRDFNode *aResource, - nsIMsgIncomingServer **aResult) -{ - nsresult rv; - nsCOMPtr folder = do_QueryInterface(aResource, &rv); - if (NS_SUCCEEDED(rv)) - { - bool isServer; - rv = folder->GetIsServer(&isServer); - if (NS_SUCCEEDED(rv) && isServer) - return folder->GetServer(aResult); - } - return NS_ERROR_FAILURE; -} - -nsresult -nsMsgAccountManagerDataSource::getStringBundle() -{ - if (mStringBundle) return NS_OK; - - nsCOMPtr strBundleService = - mozilla::services::GetStringBundleService(); - NS_ENSURE_TRUE(strBundleService, NS_ERROR_UNEXPECTED); - - return strBundleService->CreateBundle("chrome://messenger/locale/prefs.properties", - getter_AddRefs(mStringBundle)); -} - -NS_IMETHODIMP -nsMsgAccountManagerDataSource::OnServerLoaded(nsIMsgIncomingServer* aServer) -{ - nsCOMPtr serverFolder; - nsresult rv = aServer->GetRootFolder(getter_AddRefs(serverFolder)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr serverResource = do_QueryInterface(serverFolder,&rv); - if (NS_FAILED(rv)) return rv; - - NotifyObservers(kNC_AccountRoot, kNC_Child, serverResource, nullptr, true, false); - NotifyObservers(kNC_AccountRoot, kNC_Settings, serverResource, nullptr, true, false); - - return NS_OK; -} - -NS_IMETHODIMP -nsMsgAccountManagerDataSource::OnServerUnloaded(nsIMsgIncomingServer* aServer) -{ - nsCOMPtr serverFolder; - nsresult rv = aServer->GetRootFolder(getter_AddRefs(serverFolder)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr serverResource = do_QueryInterface(serverFolder,&rv); - if (NS_FAILED(rv)) return rv; - - - NotifyObservers(kNC_AccountRoot, kNC_Child, serverResource, nullptr, false, false); - NotifyObservers(kNC_AccountRoot, kNC_Settings, serverResource, nullptr, false, false); - - return NS_OK; -} - -NS_IMETHODIMP -nsMsgAccountManagerDataSource::OnServerChanged(nsIMsgIncomingServer *server) -{ - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::OnItemPropertyChanged(nsIMsgFolder *, nsIAtom *, char const *, char const *) -{ - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::OnItemUnicharPropertyChanged(nsIMsgFolder *, nsIAtom *, const char16_t *, const char16_t *) -{ - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::OnItemRemoved(nsIMsgFolder *, nsISupports *) -{ - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::OnItemPropertyFlagChanged(nsIMsgDBHdr *, nsIAtom *, uint32_t, uint32_t) -{ - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::OnItemAdded(nsIMsgFolder *, nsISupports *) -{ - return NS_OK; -} - - -nsresult -nsMsgAccountManagerDataSource::OnItemBoolPropertyChanged(nsIMsgFolder *aItem, - nsIAtom *aProperty, - bool aOldValue, - bool aNewValue) -{ - if (aProperty == kDefaultServerAtom) { - nsCOMPtr resource(do_QueryInterface(aItem)); - NotifyObservers(resource, kNC_IsDefaultServer, kTrueLiteral, nullptr, aNewValue, false); - } - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::OnItemEvent(nsIMsgFolder *, nsIAtom *) -{ - return NS_OK; -} - -nsresult -nsMsgAccountManagerDataSource::OnItemIntPropertyChanged(nsIMsgFolder *, nsIAtom *, int64_t, int64_t) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsMsgAccountManagerDataSource::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData) -{ - nsMsgRDFDataSource::Observe(aSubject, aTopic, aData); - - return NS_OK; -} diff --git a/mailnews/base/src/nsMsgAccountManagerDS.h b/mailnews/base/src/nsMsgAccountManagerDS.h deleted file mode 100644 --- a/mailnews/base/src/nsMsgAccountManagerDS.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef __nsMsgAccountManagerDS_h -#define __nsMsgAccountManagerDS_h - -#include "mozilla/Attributes.h" -#include "nscore.h" -#include "nsError.h" -#include "nsIID.h" -#include "nsCOMPtr.h" -#include "nsIStringBundle.h" - -#include "nsMsgRDFDataSource.h" -#include "nsIMsgAccountManager.h" -#include "nsIIncomingServerListener.h" -#include "nsIMsgProtocolInfo.h" -#include "nsWeakPtr.h" -#include "nsIMutableArray.h" -#include "nsCOMArray.h" - -/* {3f989ca4-f77a-11d2-969d-006008948010} */ -#define NS_MSGACCOUNTMANAGERDATASOURCE_CID \ - {0x3f989ca4, 0xf77a, 0x11d2, \ - {0x96, 0x9d, 0x00, 0x60, 0x08, 0x94, 0x80, 0x10}} - -class nsMsgAccountManagerDataSource : public nsMsgRDFDataSource, - public nsIFolderListener, - public nsIIncomingServerListener -{ - -public: - - nsMsgAccountManagerDataSource(); - virtual nsresult Init() override; - - virtual void Cleanup() override; - // service manager shutdown method - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIFOLDERLISTENER - NS_DECL_NSIINCOMINGSERVERLISTENER - NS_DECL_NSIOBSERVER - // RDF datasource methods - NS_IMETHOD GetTarget(nsIRDFResource *source, - nsIRDFResource *property, - bool aTruthValue, - nsIRDFNode **_retval) override; - NS_IMETHOD GetTargets(nsIRDFResource *source, - nsIRDFResource *property, - bool aTruthValue, - nsISimpleEnumerator **_retval) override; - NS_IMETHOD ArcLabelsOut(nsIRDFResource *source, - nsISimpleEnumerator **_retval) override; - - NS_IMETHOD HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, - nsIRDFNode *aTarget, bool aTruthValue, - bool *_retval) override; - NS_IMETHOD HasArcOut(nsIRDFResource *source, nsIRDFResource *aArc, - bool *result) override; - -protected: - virtual ~nsMsgAccountManagerDataSource(); - - nsresult HasAssertionServer(nsIMsgIncomingServer *aServer, - nsIRDFResource *aProperty, - nsIRDFNode *aTarget, - bool aTruthValue, bool *_retval); - - nsresult HasAssertionAccountRoot(nsIRDFResource *aProperty, - nsIRDFNode *aTarget, - bool aTruthValue, bool *_retval); - - bool isDefaultServer(nsIMsgIncomingServer *aServer); - bool supportsFilters(nsIMsgIncomingServer *aServer); - bool canGetMessages(nsIMsgIncomingServer *aServer); - bool canGetIncomingMessages(nsIMsgIncomingServer *aServer); - - static bool isContainment(nsIRDFResource *aProperty); - nsresult getServerForFolderNode(nsIRDFNode *aResource, - nsIMsgIncomingServer **aResult); - - nsresult createRootResources(nsIRDFResource *aProperty, - nsCOMArray *aNodeArray); - nsresult createSettingsResources(nsIRDFResource *aSource, - nsCOMArray *aNodeArray); - nsresult appendGenericSettingsResources(nsIMsgIncomingServer *server,\ - nsCOMArray *aNodeArray); - nsresult appendGenericSetting(const char *name, - nsCOMArray *aNodeArray); - - static nsIRDFResource* kNC_Name; - static nsIRDFResource* kNC_FolderTreeName; - static nsIRDFResource* kNC_FolderTreeSimpleName; - static nsIRDFResource* kNC_NameSort; - static nsIRDFResource* kNC_FolderTreeNameSort; - static nsIRDFResource* kNC_PageTag; - static nsIRDFResource* kNC_IsDefaultServer; - static nsIRDFResource* kNC_SupportsFilters; - static nsIRDFResource* kNC_CanGetMessages; - static nsIRDFResource* kNC_CanGetIncomingMessages; - - static nsIRDFResource* kNC_Child; - static nsIRDFResource* kNC_AccountRoot; - - static nsIRDFResource* kNC_Account; - static nsIRDFResource* kNC_Server; - static nsIRDFResource* kNC_Identity; - static nsIRDFResource* kNC_Settings; - static nsIRDFResource* kNC_Junk; - - static nsIRDFResource* kNC_PageTitleMain; - static nsIRDFResource* kNC_PageTitleServer; - static nsIRDFResource* kNC_PageTitleCopies; - static nsIRDFResource* kNC_PageTitleSynchronization; - static nsIRDFResource* kNC_PageTitleDiskSpace; - static nsIRDFResource* kNC_PageTitleAddressing; - static nsIRDFResource* kNC_PageTitleSMTP; - static nsIRDFResource* kNC_PageTitleJunk; - - static nsIRDFLiteral* kTrueLiteral; - - static nsIAtom* kDefaultServerAtom; - - static nsrefcnt gAccountManagerResourceRefCnt; - - static nsresult getAccountArcs(nsIMutableArray **aResult); - static nsresult getAccountRootArcs(nsIMutableArray **aResult); - -private: - nsresult serverHasIdentities(nsIMsgIncomingServer *aServer, bool *aResult); - nsresult getStringBundle(); - - static nsCOMPtr mAccountArcsOut; - static nsCOMPtr mAccountRootArcsOut; - nsWeakPtr mAccountManager; - nsCOMPtr mStringBundle; -}; - -#endif /* __nsMsgAccountManagerDS_h */ diff --git a/mailnews/base/src/nsMsgFolderDataSource.cpp b/mailnews/base/src/nsMsgFolderDataSource.cpp deleted file mode 100644 --- a/mailnews/base/src/nsMsgFolderDataSource.cpp +++ /dev/null @@ -1,2484 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "msgCore.h" // precompiled header... -#include "prlog.h" -#include "prmem.h" -#include "nsMsgFolderDataSource.h" -#include "nsMsgFolderFlags.h" - -#include "nsMsgUtils.h" -#include "nsMsgRDFUtils.h" - -#include "rdf.h" -#include "nsIRDFService.h" -#include "nsRDFCID.h" -#include "nsIRDFNode.h" -#include "nsEnumeratorUtils.h" - -#include "nsString.h" -#include "nsCOMPtr.h" - -#include "nsIMsgMailSession.h" -#include "nsIMsgCopyService.h" -#include "nsMsgBaseCID.h" -#include "nsIInputStream.h" -#include "nsIMsgHdr.h" -#include "nsTraceRefcnt.h" -#include "nsIMsgFolder.h" // TO include biffState enum. Change to bool later... -#include "nsIMutableArray.h" -#include "nsIPop3IncomingServer.h" -#include "nsINntpIncomingServer.h" -#include "nsTextFormatter.h" -#include "nsIStringBundle.h" -#include "nsIPrompt.h" -#include "nsIMsgAccountManager.h" -#include "nsArrayEnumerator.h" -#include "nsArrayUtils.h" -#include "nsComponentManagerUtils.h" -#include "nsServiceManagerUtils.h" -#include "nsMemory.h" -#include "nsMsgUtils.h" -#include "mozilla/Services.h" - -#define MESSENGER_STRING_URL "chrome://messenger/locale/messenger.properties" - -nsIRDFResource* nsMsgFolderDataSource::kNC_Child = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_Folder= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_Name= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_Open = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_FolderTreeName= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_FolderTreeSimpleName= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_NameSort= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_FolderTreeNameSort= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_SpecialFolder= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_ServerType = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_IsDeferred = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CanCreateFoldersOnServer = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CanFileMessagesOnServer = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_IsServer = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_IsSecure = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CanSubscribe = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_SupportsOffline = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CanFileMessages = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CanCreateSubfolders = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CanRename = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CanCompact = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_TotalMessages= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_TotalUnreadMessages= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_FolderSize = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_Charset = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_BiffState = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_HasUnreadMessages = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_NewMessages = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_SubfoldersHaveUnreadMessages = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_NoSelect = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_VirtualFolder = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_InVFEditSearchScope = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_ImapShared = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_Synchronize = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_SyncDisabled = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CanSearchMessages = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_UnreadFolders = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_FavoriteFolders = nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_RecentFolders = nullptr; - -// commands -nsIRDFResource* nsMsgFolderDataSource::kNC_Delete= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_ReallyDelete= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_NewFolder= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_GetNewMessages= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_Copy= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_Move= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CopyFolder= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_MoveFolder= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_MarkAllMessagesRead= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_Compact= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_CompactAll= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_Rename= nullptr; -nsIRDFResource* nsMsgFolderDataSource::kNC_EmptyTrash= nullptr; - -nsrefcnt nsMsgFolderDataSource::gFolderResourceRefCnt = 0; - -nsIAtom * nsMsgFolderDataSource::kBiffStateAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kSortOrderAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kNewMessagesAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kTotalMessagesAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kTotalUnreadMessagesAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kFolderSizeAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kNameAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kSynchronizeAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kOpenAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kIsDeferredAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kIsSecureAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kCanFileMessagesAtom = nullptr; -nsIAtom * nsMsgFolderDataSource::kInVFEditSearchScopeAtom = nullptr; - -static const uint32_t kDisplayBlankCount = 0xFFFFFFFE; -static const uint32_t kDisplayQuestionCount = 0xFFFFFFFF; -static const int64_t kDisplayBlankCount64 = -2; -static const int64_t kDisplayQuestionCount64 = -1; - -nsMsgFolderDataSource::nsMsgFolderDataSource() -{ - // one-time initialization here - nsIRDFService* rdf = getRDFService(); - - if (gFolderResourceRefCnt++ == 0) { - nsCOMPtr sMessengerStringBundle; - - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHILD), &kNC_Child); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDER), &kNC_Folder); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME), &kNC_Name); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_OPEN), &kNC_Open); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREENAME), &kNC_FolderTreeName); - rdf->GetResource(NS_LITERAL_CSTRING("mailnewsunreadfolders:/"), &kNC_UnreadFolders); - rdf->GetResource(NS_LITERAL_CSTRING("mailnewsfavefolders:/"), &kNC_FavoriteFolders); - rdf->GetResource(NS_LITERAL_CSTRING("mailnewsrecentfolders:/"), &kNC_RecentFolders); - - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREESIMPLENAME), &kNC_FolderTreeSimpleName); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NAME_SORT), &kNC_NameSort); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERTREENAME_SORT), &kNC_FolderTreeNameSort); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SPECIALFOLDER), &kNC_SpecialFolder); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SERVERTYPE), &kNC_ServerType); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISDEFERRED),&kNC_IsDeferred); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANCREATEFOLDERSONSERVER), &kNC_CanCreateFoldersOnServer); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANFILEMESSAGESONSERVER), &kNC_CanFileMessagesOnServer); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISSERVER), &kNC_IsServer); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_ISSECURE), &kNC_IsSecure); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANSUBSCRIBE), &kNC_CanSubscribe); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SUPPORTSOFFLINE), &kNC_SupportsOffline); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANFILEMESSAGES), &kNC_CanFileMessages); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANCREATESUBFOLDERS), &kNC_CanCreateSubfolders); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANRENAME), &kNC_CanRename); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANCOMPACT), &kNC_CanCompact); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_TOTALMESSAGES), &kNC_TotalMessages); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_TOTALUNREADMESSAGES), &kNC_TotalUnreadMessages); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_FOLDERSIZE), &kNC_FolderSize); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CHARSET), &kNC_Charset); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_BIFFSTATE), &kNC_BiffState); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_HASUNREADMESSAGES), &kNC_HasUnreadMessages); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NEWMESSAGES), &kNC_NewMessages); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SUBFOLDERSHAVEUNREADMESSAGES), &kNC_SubfoldersHaveUnreadMessages); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NOSELECT), &kNC_NoSelect); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_VIRTUALFOLDER), &kNC_VirtualFolder); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_INVFEDITSEARCHSCOPE), &kNC_InVFEditSearchScope); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_IMAPSHARED), &kNC_ImapShared); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SYNCHRONIZE), &kNC_Synchronize); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_SYNCDISABLED), &kNC_SyncDisabled); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_CANSEARCHMESSAGES), &kNC_CanSearchMessages); - - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_DELETE), &kNC_Delete); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_REALLY_DELETE), &kNC_ReallyDelete); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_NEWFOLDER), &kNC_NewFolder); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_GETNEWMESSAGES), &kNC_GetNewMessages); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_COPY), &kNC_Copy); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_MOVE), &kNC_Move); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_COPYFOLDER), &kNC_CopyFolder); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_MOVEFOLDER), &kNC_MoveFolder); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_MARKALLMESSAGESREAD), - &kNC_MarkAllMessagesRead); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_COMPACT), &kNC_Compact); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_COMPACTALL), &kNC_CompactAll); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_RENAME), &kNC_Rename); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_EMPTYTRASH), &kNC_EmptyTrash); - - kTotalMessagesAtom = MsgNewAtom("TotalMessages").take(); - kTotalUnreadMessagesAtom = MsgNewAtom("TotalUnreadMessages").take(); - kFolderSizeAtom = MsgNewAtom("FolderSize").take(); - kBiffStateAtom = MsgNewAtom("BiffState").take(); - kSortOrderAtom = MsgNewAtom("SortOrder").take(); - kNewMessagesAtom = MsgNewAtom("NewMessages").take(); - kNameAtom = MsgNewAtom("Name").take(); - kSynchronizeAtom = MsgNewAtom("Synchronize").take(); - kOpenAtom = MsgNewAtom("open").take(); - kIsDeferredAtom = MsgNewAtom("isDeferred").take(); - kIsSecureAtom = MsgNewAtom("isSecure").take(); - kCanFileMessagesAtom = MsgNewAtom("canFileMessages").take(); - kInVFEditSearchScopeAtom = MsgNewAtom("inVFEditSearchScope").take(); - } - - CreateLiterals(rdf); - CreateArcsOutEnumerator(); -} - -nsMsgFolderDataSource::~nsMsgFolderDataSource (void) -{ - if (--gFolderResourceRefCnt == 0) - { - nsrefcnt refcnt; - NS_RELEASE2(kNC_Child, refcnt); - NS_RELEASE2(kNC_Folder, refcnt); - NS_RELEASE2(kNC_Name, refcnt); - NS_RELEASE2(kNC_Open, refcnt); - NS_RELEASE2(kNC_FolderTreeName, refcnt); - NS_RELEASE2(kNC_FolderTreeSimpleName, refcnt); - NS_RELEASE2(kNC_NameSort, refcnt); - NS_RELEASE2(kNC_FolderTreeNameSort, refcnt); - NS_RELEASE2(kNC_SpecialFolder, refcnt); - NS_RELEASE2(kNC_ServerType, refcnt); - NS_RELEASE2(kNC_IsDeferred, refcnt); - NS_RELEASE2(kNC_CanCreateFoldersOnServer, refcnt); - NS_RELEASE2(kNC_CanFileMessagesOnServer, refcnt); - NS_RELEASE2(kNC_IsServer, refcnt); - NS_RELEASE2(kNC_IsSecure, refcnt); - NS_RELEASE2(kNC_CanSubscribe, refcnt); - NS_RELEASE2(kNC_SupportsOffline, refcnt); - NS_RELEASE2(kNC_CanFileMessages, refcnt); - NS_RELEASE2(kNC_CanCreateSubfolders, refcnt); - NS_RELEASE2(kNC_CanRename, refcnt); - NS_RELEASE2(kNC_CanCompact, refcnt); - NS_RELEASE2(kNC_TotalMessages, refcnt); - NS_RELEASE2(kNC_TotalUnreadMessages, refcnt); - NS_RELEASE2(kNC_FolderSize, refcnt); - NS_RELEASE2(kNC_Charset, refcnt); - NS_RELEASE2(kNC_BiffState, refcnt); - NS_RELEASE2(kNC_HasUnreadMessages, refcnt); - NS_RELEASE2(kNC_NewMessages, refcnt); - NS_RELEASE2(kNC_SubfoldersHaveUnreadMessages, refcnt); - NS_RELEASE2(kNC_NoSelect, refcnt); - NS_RELEASE2(kNC_VirtualFolder, refcnt); - NS_RELEASE2(kNC_InVFEditSearchScope, refcnt); - NS_RELEASE2(kNC_ImapShared, refcnt); - NS_RELEASE2(kNC_Synchronize, refcnt); - NS_RELEASE2(kNC_SyncDisabled, refcnt); - NS_RELEASE2(kNC_CanSearchMessages, refcnt); - - NS_RELEASE2(kNC_Delete, refcnt); - NS_RELEASE2(kNC_ReallyDelete, refcnt); - NS_RELEASE2(kNC_NewFolder, refcnt); - NS_RELEASE2(kNC_GetNewMessages, refcnt); - NS_RELEASE2(kNC_Copy, refcnt); - NS_RELEASE2(kNC_Move, refcnt); - NS_RELEASE2(kNC_CopyFolder, refcnt); - NS_RELEASE2(kNC_MoveFolder, refcnt); - NS_RELEASE2(kNC_MarkAllMessagesRead, refcnt); - NS_RELEASE2(kNC_Compact, refcnt); - NS_RELEASE2(kNC_CompactAll, refcnt); - NS_RELEASE2(kNC_Rename, refcnt); - NS_RELEASE2(kNC_EmptyTrash, refcnt); - NS_RELEASE2(kNC_UnreadFolders, refcnt); - NS_RELEASE2(kNC_FavoriteFolders, refcnt); - NS_RELEASE2(kNC_RecentFolders, refcnt); - - NS_RELEASE(kTotalMessagesAtom); - NS_RELEASE(kTotalUnreadMessagesAtom); - NS_RELEASE(kFolderSizeAtom); - NS_RELEASE(kBiffStateAtom); - NS_RELEASE(kSortOrderAtom); - NS_RELEASE(kNewMessagesAtom); - NS_RELEASE(kNameAtom); - NS_RELEASE(kSynchronizeAtom); - NS_RELEASE(kOpenAtom); - NS_RELEASE(kIsDeferredAtom); - NS_RELEASE(kIsSecureAtom); - NS_RELEASE(kCanFileMessagesAtom); - NS_RELEASE(kInVFEditSearchScopeAtom); - } -} - -nsresult nsMsgFolderDataSource::CreateLiterals(nsIRDFService *rdf) -{ - createNode(u"true", - getter_AddRefs(kTrueLiteral), rdf); - createNode(u"false", - getter_AddRefs(kFalseLiteral), rdf); - - return NS_OK; -} - -nsresult nsMsgFolderDataSource::Init() -{ - nsresult rv; - - rv = nsMsgRDFDataSource::Init(); - if (NS_FAILED(rv)) - return rv; - - nsCOMPtr mailSession = - do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); - - if(NS_SUCCEEDED(rv)) - mailSession->AddFolderListener(this, - nsIFolderListener::added | - nsIFolderListener::removed | - nsIFolderListener::intPropertyChanged | - nsIFolderListener::boolPropertyChanged | - nsIFolderListener::unicharPropertyChanged); - - return NS_OK; -} - -void nsMsgFolderDataSource::Cleanup() -{ - nsresult rv; - if (!m_shuttingDown) - { - nsCOMPtr mailSession = - do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv); - - if(NS_SUCCEEDED(rv)) - mailSession->RemoveFolderListener(this); - } - - nsMsgRDFDataSource::Cleanup(); -} - -nsresult nsMsgFolderDataSource::CreateArcsOutEnumerator() -{ - nsresult rv; - - rv = getFolderArcLabelsOut(kFolderArcsOutArray); - if(NS_FAILED(rv)) return rv; - - return rv; -} - -NS_IMPL_ADDREF_INHERITED(nsMsgFolderDataSource, nsMsgRDFDataSource) -NS_IMPL_RELEASE_INHERITED(nsMsgFolderDataSource, nsMsgRDFDataSource) - -NS_IMPL_QUERY_INTERFACE_INHERITED(nsMsgFolderDataSource, nsMsgRDFDataSource, nsIFolderListener) - - // nsIRDFDataSource methods -NS_IMETHODIMP nsMsgFolderDataSource::GetURI(char* *uri) -{ - if ((*uri = strdup("rdf:mailnewsfolders")) == nullptr) - return NS_ERROR_OUT_OF_MEMORY; - else - return NS_OK; -} - -NS_IMETHODIMP nsMsgFolderDataSource::GetSource(nsIRDFResource* property, - nsIRDFNode* target, - bool tv, - nsIRDFResource** source /* out */) -{ - NS_ASSERTION(false, "not implemented"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP nsMsgFolderDataSource::GetTarget(nsIRDFResource* source, - nsIRDFResource* property, - bool tv, - nsIRDFNode** target) -{ - nsresult rv = NS_RDF_NO_VALUE; - - // we only have positive assertions in the mail data source. - if (! tv) - return NS_RDF_NO_VALUE; - - nsCOMPtr folder(do_QueryInterface(source)); - if (folder) - rv = createFolderNode(folder, property, target); - else - return NS_RDF_NO_VALUE; - return rv; -} - - -NS_IMETHODIMP nsMsgFolderDataSource::GetSources(nsIRDFResource* property, - nsIRDFNode* target, - bool tv, - nsISimpleEnumerator** sources) -{ - return NS_RDF_NO_VALUE; -} - -NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source, - nsIRDFResource* property, - bool tv, - nsISimpleEnumerator** targets) -{ - nsresult rv = NS_RDF_NO_VALUE; - if(!targets) - return NS_ERROR_NULL_POINTER; - - *targets = nullptr; - - nsCOMPtr folder(do_QueryInterface(source, &rv)); - if (NS_SUCCEEDED(rv)) - { - if (kNC_Child == property) - { - rv = folder->GetSubFolders(targets); - } - else if ((kNC_Name == property) || - (kNC_Open == property) || - (kNC_FolderTreeName == property) || - (kNC_FolderTreeSimpleName == property) || - (kNC_SpecialFolder == property) || - (kNC_IsServer == property) || - (kNC_IsSecure == property) || - (kNC_CanSubscribe == property) || - (kNC_SupportsOffline == property) || - (kNC_CanFileMessages == property) || - (kNC_CanCreateSubfolders == property) || - (kNC_CanRename == property) || - (kNC_CanCompact == property) || - (kNC_ServerType == property) || - (kNC_IsDeferred == property) || - (kNC_CanCreateFoldersOnServer == property) || - (kNC_CanFileMessagesOnServer == property) || - (kNC_NoSelect == property) || - (kNC_VirtualFolder == property) || - (kNC_InVFEditSearchScope == property) || - (kNC_ImapShared == property) || - (kNC_Synchronize == property) || - (kNC_SyncDisabled == property) || - (kNC_CanSearchMessages == property)) - { - return NS_NewSingletonEnumerator(targets, property); - } - } - if(!*targets) - { - //create empty cursor - rv = NS_NewEmptyEnumerator(targets); - } - - return rv; -} - -NS_IMETHODIMP nsMsgFolderDataSource::Assert(nsIRDFResource* source, - nsIRDFResource* property, - nsIRDFNode* target, - bool tv) -{ - nsresult rv; - nsCOMPtr folder(do_QueryInterface(source, &rv)); - //We don't handle tv = false at the moment. - if(NS_SUCCEEDED(rv) && tv) - return DoFolderAssert(folder, property, target); - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP nsMsgFolderDataSource::Unassert(nsIRDFResource* source, - nsIRDFResource* property, - nsIRDFNode* target) -{ - nsresult rv; - nsCOMPtr folder(do_QueryInterface(source, &rv)); - NS_ENSURE_SUCCESS(rv,rv); - return DoFolderUnassert(folder, property, target); -} - - -NS_IMETHODIMP nsMsgFolderDataSource::HasAssertion(nsIRDFResource* source, - nsIRDFResource* property, - nsIRDFNode* target, - bool tv, - bool* hasAssertion) -{ - nsresult rv; - nsCOMPtr folder(do_QueryInterface(source, &rv)); - if(NS_SUCCEEDED(rv)) - return DoFolderHasAssertion(folder, property, target, tv, hasAssertion); - else - *hasAssertion = false; - return NS_OK; -} - - -NS_IMETHODIMP -nsMsgFolderDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *result) -{ - nsresult rv; - nsCOMPtr folder(do_QueryInterface(aSource, &rv)); - if (NS_SUCCEEDED(rv)) - { - *result = (aArc == kNC_Name || - aArc == kNC_Open || - aArc == kNC_FolderTreeName || - aArc == kNC_FolderTreeSimpleName || - aArc == kNC_SpecialFolder || - aArc == kNC_ServerType || - aArc == kNC_IsDeferred || - aArc == kNC_CanCreateFoldersOnServer || - aArc == kNC_CanFileMessagesOnServer || - aArc == kNC_IsServer || - aArc == kNC_IsSecure || - aArc == kNC_CanSubscribe || - aArc == kNC_SupportsOffline || - aArc == kNC_CanFileMessages || - aArc == kNC_CanCreateSubfolders || - aArc == kNC_CanRename || - aArc == kNC_CanCompact || - aArc == kNC_TotalMessages || - aArc == kNC_TotalUnreadMessages || - aArc == kNC_FolderSize || - aArc == kNC_Charset || - aArc == kNC_BiffState || - aArc == kNC_Child || - aArc == kNC_NoSelect || - aArc == kNC_VirtualFolder || - aArc == kNC_InVFEditSearchScope || - aArc == kNC_ImapShared || - aArc == kNC_Synchronize || - aArc == kNC_SyncDisabled || - aArc == kNC_CanSearchMessages); - } - else - { - *result = false; - } - return NS_OK; -} - -NS_IMETHODIMP nsMsgFolderDataSource::ArcLabelsIn(nsIRDFNode* node, - nsISimpleEnumerator** labels) -{ - return nsMsgRDFDataSource::ArcLabelsIn(node, labels); -} - -NS_IMETHODIMP nsMsgFolderDataSource::ArcLabelsOut(nsIRDFResource* source, - nsISimpleEnumerator** labels) -{ - nsresult rv = NS_RDF_NO_VALUE; - - nsCOMPtr folder(do_QueryInterface(source, &rv)); - if (NS_SUCCEEDED(rv)) - { - rv = NS_NewArrayEnumerator(labels, kFolderArcsOutArray); - } - else - { - rv = NS_NewEmptyEnumerator(labels); - } - - return rv; -} - -nsresult -nsMsgFolderDataSource::getFolderArcLabelsOut(nsCOMArray &aArcs) -{ - aArcs.AppendObject(kNC_Name); - aArcs.AppendObject(kNC_Open); - aArcs.AppendObject(kNC_FolderTreeName); - aArcs.AppendObject(kNC_FolderTreeSimpleName); - aArcs.AppendObject(kNC_SpecialFolder); - aArcs.AppendObject(kNC_ServerType); - aArcs.AppendObject(kNC_IsDeferred); - aArcs.AppendObject(kNC_CanCreateFoldersOnServer); - aArcs.AppendObject(kNC_CanFileMessagesOnServer); - aArcs.AppendObject(kNC_IsServer); - aArcs.AppendObject(kNC_IsSecure); - aArcs.AppendObject(kNC_CanSubscribe); - aArcs.AppendObject(kNC_SupportsOffline); - aArcs.AppendObject(kNC_CanFileMessages); - aArcs.AppendObject(kNC_CanCreateSubfolders); - aArcs.AppendObject(kNC_CanRename); - aArcs.AppendObject(kNC_CanCompact); - aArcs.AppendObject(kNC_TotalMessages); - aArcs.AppendObject(kNC_TotalUnreadMessages); - aArcs.AppendObject(kNC_FolderSize); - aArcs.AppendObject(kNC_Charset); - aArcs.AppendObject(kNC_BiffState); - aArcs.AppendObject(kNC_Child); - aArcs.AppendObject(kNC_NoSelect); - aArcs.AppendObject(kNC_VirtualFolder); - aArcs.AppendObject(kNC_InVFEditSearchScope); - aArcs.AppendObject(kNC_ImapShared); - aArcs.AppendObject(kNC_Synchronize); - aArcs.AppendObject(kNC_SyncDisabled); - aArcs.AppendObject(kNC_CanSearchMessages); - - return NS_OK; -} - -NS_IMETHODIMP -nsMsgFolderDataSource::GetAllResources(nsISimpleEnumerator** aCursor) -{ - MOZ_ASSERT_UNREACHABLE("sorry!"); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsMsgFolderDataSource::GetAllCmds(nsIRDFResource* source, - nsISimpleEnumerator/**/** commands) -{ - MOZ_ASSERT_UNREACHABLE("no one actually uses me"); - nsresult rv; - - nsCOMPtr folder(do_QueryInterface(source, &rv)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr cmds = - do_CreateInstance(NS_ARRAY_CONTRACTID); - NS_ENSURE_STATE(cmds); - - cmds->AppendElement(kNC_Delete); - cmds->AppendElement(kNC_ReallyDelete); - cmds->AppendElement(kNC_NewFolder); - cmds->AppendElement(kNC_GetNewMessages); - cmds->AppendElement(kNC_Copy); - cmds->AppendElement(kNC_Move); - cmds->AppendElement(kNC_CopyFolder); - cmds->AppendElement(kNC_MoveFolder); - cmds->AppendElement(kNC_MarkAllMessagesRead); - cmds->AppendElement(kNC_Compact); - cmds->AppendElement(kNC_CompactAll); - cmds->AppendElement(kNC_Rename); - cmds->AppendElement(kNC_EmptyTrash); - - return cmds->Enumerate(commands); -} - -NS_IMETHODIMP -nsMsgFolderDataSource::IsCommandEnabled(nsISupports/*nsISupportsArray*/* aSources, - nsIRDFResource* aCommand, - nsISupports/*nsISupportsArray*/* aArguments, - bool* aResult) -{ -#if 1 - return NS_ERROR_NOT_IMPLEMENTED; -#else - nsresult rv; - nsCOMPtr folder; - - nsCOMPtr sources = do_QueryInterface(aSources); - NS_ENSURE_STATE(sources); - - uint32_t cnt; - rv = sources->Count(&cnt); - if (NS_FAILED(rv)) return rv; - for (uint32_t i = 0; i < cnt; i++) - { - folder = do_QueryElementAt(sources, i, &rv); - if (NS_SUCCEEDED(rv)) - { - // we don't care about the arguments -- folder commands are always enabled - if (!((aCommand == kNC_Delete) || - (aCommand == kNC_ReallyDelete) || - (aCommand == kNC_NewFolder) || - (aCommand == kNC_Copy) || - (aCommand == kNC_Move) || - (aCommand == kNC_CopyFolder) || - (aCommand == kNC_MoveFolder) || - (aCommand == kNC_GetNewMessages) || - (aCommand == kNC_MarkAllMessagesRead) || - (aCommand == kNC_Compact) || - (aCommand == kNC_CompactAll) || - (aCommand == kNC_Rename) || - (aCommand == kNC_EmptyTrash))) - { - *aResult = false; - return NS_OK; - } - } - } - *aResult = true; - return NS_OK; // succeeded for all sources -#endif -} - -NS_IMETHODIMP -nsMsgFolderDataSource::DoCommand(nsISupports/*nsISupportsArray*/* aSources, - nsIRDFResource* aCommand, - nsISupports/*nsISupportsArray*/* aArguments) -{ -#if 1 - return NS_ERROR_NOT_IMPLEMENTED; -#else - nsresult rv = NS_OK; - nsCOMPtr supports; - nsCOMPtr window; - - nsCOMPtr sources = do_QueryInterface(aSources); - NS_ENSURE_STATE(sources); - nsCOMPtr arguments = do_QueryInterface(aArguments); - - // callers can pass in the msgWindow as the last element of the arguments - // array. If they do, we'll use that as the msg window for progress, etc. - if (arguments) - { - uint32_t numArgs; - arguments->Count(&numArgs); - if (numArgs > 1) - window = do_QueryElementAt(arguments, numArgs - 1); - } - if (!window) - window = mWindow; - - // XXX need to handle batching of command applied to all sources - - uint32_t cnt = 0; - uint32_t i = 0; - - rv = sources->Count(&cnt); - if (NS_FAILED(rv)) return rv; - - for ( ; i < cnt; i++) - { - nsCOMPtr folder = do_QueryElementAt(sources, i, &rv); - if (NS_SUCCEEDED(rv)) - { - if (aCommand == kNC_Delete) - { - rv = DoDeleteFromFolder(folder, arguments, window, false); - } - if (aCommand == kNC_ReallyDelete) - { - rv = DoDeleteFromFolder(folder, arguments, window, true); - } - else if (aCommand == kNC_NewFolder) - { - rv = DoNewFolder(folder, arguments, window); - } - else if (aCommand == kNC_GetNewMessages) - { - nsCOMPtr server = do_QueryElementAt(arguments, i, &rv); - NS_ENSURE_SUCCESS(rv, rv); - rv = server->GetNewMessages(folder, window, nullptr); - } - else if (aCommand == kNC_Copy) - { - rv = DoCopyToFolder(folder, arguments, window, false); - } - else if (aCommand == kNC_Move) - { - rv = DoCopyToFolder(folder, arguments, window, true); - } - else if (aCommand == kNC_CopyFolder) - { - rv = DoFolderCopyToFolder(folder, arguments, window, false); - } - else if (aCommand == kNC_MoveFolder) - { - rv = DoFolderCopyToFolder(folder, arguments, window, true); - } - else if (aCommand == kNC_MarkAllMessagesRead) - { - rv = folder->MarkAllMessagesRead(window); - } - else if (aCommand == kNC_Compact) - { - rv = folder->Compact(nullptr, window); - } - else if (aCommand == kNC_CompactAll) - { - // this will also compact offline stores for IMAP - rv = folder->CompactAll(nullptr, window, true); - } - else if (aCommand == kNC_EmptyTrash) - { - rv = folder->EmptyTrash(window, nullptr); - } - else if (aCommand == kNC_Rename) - { - nsCOMPtr literal = do_QueryElementAt(arguments, 0, &rv); - if(NS_SUCCEEDED(rv)) - { - nsString name; - literal->GetValue(getter_Copies(name)); - rv = folder->Rename(name, window); - } - } - } - else - { - rv = NS_ERROR_NOT_IMPLEMENTED; - } - } - //for the moment return NS_OK, because failure stops entire DoCommand process. - return rv; - //return NS_OK; -#endif -} - -NS_IMETHODIMP nsMsgFolderDataSource::OnItemAdded(nsIMsgFolder *parentItem, nsISupports *item) -{ - return OnItemAddedOrRemoved(parentItem, item, true); -} - -NS_IMETHODIMP nsMsgFolderDataSource::OnItemRemoved(nsIMsgFolder *parentItem, nsISupports *item) -{ - return OnItemAddedOrRemoved(parentItem, item, false); -} - -nsresult nsMsgFolderDataSource::OnItemAddedOrRemoved(nsIMsgFolder *parentItem, nsISupports *item, bool added) -{ - nsCOMPtr itemNode(do_QueryInterface(item)); - if (itemNode) - { - nsCOMPtr parentResource(do_QueryInterface(parentItem)); - if (parentResource) // RDF is not happy about a null parent resource. - NotifyObservers(parentResource, kNC_Child, itemNode, nullptr, added, false); - } - return NS_OK; -} - -NS_IMETHODIMP -nsMsgFolderDataSource::OnItemPropertyChanged(nsIMsgFolder *resource, - nsIAtom *property, - const char *oldValue, - const char *newValue) - -{ - return NS_OK; -} - -NS_IMETHODIMP -nsMsgFolderDataSource::OnItemIntPropertyChanged(nsIMsgFolder *folder, - nsIAtom *property, - int64_t oldValue, - int64_t newValue) -{ - nsCOMPtr resource(do_QueryInterface(folder)); - if (kTotalMessagesAtom == property) - OnTotalMessagePropertyChanged(resource, oldValue, newValue); - else if (kTotalUnreadMessagesAtom == property) - OnUnreadMessagePropertyChanged(resource, oldValue, newValue); - else if (kFolderSizeAtom == property) - OnFolderSizePropertyChanged(resource, oldValue, newValue); - else if (kSortOrderAtom == property) - OnFolderSortOrderPropertyChanged(resource, oldValue, newValue); - else if (kBiffStateAtom == property) { - // be careful about skipping if oldValue == newValue - // see the comment in nsMsgFolder::SetBiffState() about filters - - nsCOMPtr biffNode; - nsresult rv = createBiffStateNodeFromFlag(newValue, getter_AddRefs(biffNode)); - NS_ENSURE_SUCCESS(rv,rv); - - NotifyPropertyChanged(resource, kNC_BiffState, biffNode); - } - return NS_OK; -} - -NS_IMETHODIMP -nsMsgFolderDataSource::OnItemUnicharPropertyChanged(nsIMsgFolder *folder, - nsIAtom *property, - const char16_t *oldValue, - const char16_t *newValue) -{ - nsCOMPtr resource(do_QueryInterface(folder)); - if (kNameAtom == property) - { - int32_t numUnread; - folder->GetNumUnread(false, &numUnread); - NotifyFolderTreeNameChanged(folder, resource, numUnread); - NotifyFolderTreeSimpleNameChanged(folder, resource); - NotifyFolderNameChanged(folder, resource); - } - return NS_OK; -} - -NS_IMETHODIMP -nsMsgFolderDataSource::OnItemBoolPropertyChanged(nsIMsgFolder *folder, - nsIAtom *property, - bool oldValue, - bool newValue) -{ - nsCOMPtr resource(do_QueryInterface(folder)); - if (newValue != oldValue) { - nsIRDFNode* literalNode = newValue?kTrueLiteral:kFalseLiteral; - nsIRDFNode* oldLiteralNode = oldValue?kTrueLiteral:kFalseLiteral; - if (kNewMessagesAtom == property) - NotifyPropertyChanged(resource, kNC_NewMessages, literalNode); - else if (kSynchronizeAtom == property) - NotifyPropertyChanged(resource, kNC_Synchronize, literalNode); - else if (kOpenAtom == property) - NotifyPropertyChanged(resource, kNC_Open, literalNode); - else if (kIsDeferredAtom == property) - NotifyPropertyChanged(resource, kNC_IsDeferred, literalNode, oldLiteralNode); - else if (kIsSecureAtom == property) - NotifyPropertyChanged(resource, kNC_IsSecure, literalNode, oldLiteralNode); - else if (kCanFileMessagesAtom == property) - NotifyPropertyChanged(resource, kNC_CanFileMessages, literalNode, oldLiteralNode); - else if (kInVFEditSearchScopeAtom == property) - NotifyPropertyChanged(resource, kNC_InVFEditSearchScope, literalNode); - } - - return NS_OK; -} - -NS_IMETHODIMP -nsMsgFolderDataSource::OnItemPropertyFlagChanged(nsIMsgDBHdr *item, - nsIAtom *property, - uint32_t oldFlag, - uint32_t newFlag) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsMsgFolderDataSource::OnItemEvent(nsIMsgFolder *aFolder, nsIAtom *aEvent) -{ - return NS_OK; -} - - -nsresult nsMsgFolderDataSource::createFolderNode(nsIMsgFolder* folder, - nsIRDFResource* property, - nsIRDFNode** target) -{ - nsresult rv = NS_RDF_NO_VALUE; - - if (kNC_NameSort == property) - rv = createFolderNameNode(folder, target, true); - else if(kNC_FolderTreeNameSort == property) - rv = createFolderNameNode(folder, target, true); - else if (kNC_Name == property) - rv = createFolderNameNode(folder, target, false); - else if(kNC_Open == property) - rv = createFolderOpenNode(folder, target); - else if (kNC_FolderTreeName == property) - rv = createFolderTreeNameNode(folder, target); - else if (kNC_FolderTreeSimpleName == property) - rv = createFolderTreeSimpleNameNode(folder, target); - else if (kNC_SpecialFolder == property) - rv = createFolderSpecialNode(folder,target); - else if (kNC_ServerType == property) - rv = createFolderServerTypeNode(folder, target); - else if (kNC_IsDeferred == property) - rv = createServerIsDeferredNode(folder, target); - else if (kNC_CanCreateFoldersOnServer == property) - rv = createFolderCanCreateFoldersOnServerNode(folder, target); - else if (kNC_CanFileMessagesOnServer == property) - rv = createFolderCanFileMessagesOnServerNode(folder, target); - else if (kNC_IsServer == property) - rv = createFolderIsServerNode(folder, target); - else if (kNC_IsSecure == property) - rv = createFolderIsSecureNode(folder, target); - else if (kNC_CanSubscribe == property) - rv = createFolderCanSubscribeNode(folder, target); - else if (kNC_SupportsOffline == property) - rv = createFolderSupportsOfflineNode(folder, target); - else if (kNC_CanFileMessages == property) - rv = createFolderCanFileMessagesNode(folder, target); - else if (kNC_CanCreateSubfolders == property) - rv = createFolderCanCreateSubfoldersNode(folder, target); - else if (kNC_CanRename == property) - rv = createFolderCanRenameNode(folder, target); - else if (kNC_CanCompact == property) - rv = createFolderCanCompactNode(folder, target); - else if (kNC_TotalMessages == property) - rv = createTotalMessagesNode(folder, target); - else if (kNC_TotalUnreadMessages == property) - rv = createUnreadMessagesNode(folder, target); - else if (kNC_FolderSize == property) - rv = createFolderSizeNode(folder, target); - else if (kNC_Charset == property) - rv = createCharsetNode(folder, target); - else if (kNC_BiffState == property) - rv = createBiffStateNodeFromFolder(folder, target); - else if (kNC_HasUnreadMessages == property) - rv = createHasUnreadMessagesNode(folder, false, target); - else if (kNC_NewMessages == property) - rv = createNewMessagesNode(folder, target); - else if (kNC_SubfoldersHaveUnreadMessages == property) - rv = createHasUnreadMessagesNode(folder, true, target); - else if (kNC_Child == property) - rv = createFolderChildNode(folder, target); - else if (kNC_NoSelect == property) - rv = createFolderNoSelectNode(folder, target); - else if (kNC_VirtualFolder == property) - rv = createFolderVirtualNode(folder, target); - else if (kNC_InVFEditSearchScope == property) - rv = createInVFEditSearchScopeNode(folder, target); - else if (kNC_ImapShared == property) - rv = createFolderImapSharedNode(folder, target); - else if (kNC_Synchronize == property) - rv = createFolderSynchronizeNode(folder, target); - else if (kNC_SyncDisabled == property) - rv = createFolderSyncDisabledNode(folder, target); - else if (kNC_CanSearchMessages == property) - rv = createCanSearchMessages(folder, target); - return NS_FAILED(rv) ? NS_RDF_NO_VALUE : rv; -} - -nsresult -nsMsgFolderDataSource::createFolderNameNode(nsIMsgFolder *folder, - nsIRDFNode **target, bool sort) -{ - nsresult rv; - if (sort) - { - uint8_t *sortKey=nullptr; - uint32_t sortKeyLength; - rv = folder->GetSortKey(&sortKeyLength, &sortKey); - NS_ENSURE_SUCCESS(rv, rv); - createBlobNode(sortKey, sortKeyLength, target, getRDFService()); - PR_Free(sortKey); - } - else - { - nsString name; - rv = folder->GetName(name); - if (NS_FAILED(rv)) - return rv; - createNode(name.get(), target, getRDFService()); - } - - return NS_OK; -} - -nsresult nsMsgFolderDataSource::GetFolderDisplayName(nsIMsgFolder *folder, nsString& folderName) -{ - return folder->GetAbbreviatedName(folderName); -} - -nsresult -nsMsgFolderDataSource::createFolderTreeNameNode(nsIMsgFolder *folder, - nsIRDFNode **target) -{ - nsString name; - nsresult rv = GetFolderDisplayName(folder, name); - if (NS_FAILED(rv)) return rv; - nsAutoString nameString(name); - int32_t unreadMessages; - - rv = folder->GetNumUnread(false, &unreadMessages); - if(NS_SUCCEEDED(rv)) - CreateUnreadMessagesNameString(unreadMessages, nameString); - - createNode(nameString.get(), target, getRDFService()); - return NS_OK; -} - -nsresult nsMsgFolderDataSource::createFolderTreeSimpleNameNode(nsIMsgFolder * folder, nsIRDFNode **target) -{ - nsString name; - nsresult rv = GetFolderDisplayName(folder, name); - if (NS_FAILED(rv)) return rv; - - createNode(name.get(), target, getRDFService()); - return NS_OK; -} - -nsresult nsMsgFolderDataSource::CreateUnreadMessagesNameString(int32_t unreadMessages, nsAutoString &nameString) -{ - //Only do this if unread messages are positive - if(unreadMessages > 0) - { - nameString.Append(NS_LITERAL_STRING(" (")); - nameString.AppendInt(unreadMessages); - nameString.Append(u')'); - } - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderSpecialNode(nsIMsgFolder *folder, - nsIRDFNode **target) -{ - uint32_t flags; - nsresult rv = folder->GetFlags(&flags); - if(NS_FAILED(rv)) - return rv; - - nsAutoString specialFolderString; - if (flags & nsMsgFolderFlags::Inbox) - specialFolderString.AssignLiteral("Inbox"); - else if (flags & nsMsgFolderFlags::Trash) - specialFolderString.AssignLiteral("Trash"); - else if (flags & nsMsgFolderFlags::Queue) - specialFolderString.AssignLiteral("Outbox"); - else if (flags & nsMsgFolderFlags::SentMail) - specialFolderString.AssignLiteral("Sent"); - else if (flags & nsMsgFolderFlags::Drafts) - specialFolderString.AssignLiteral("Drafts"); - else if (flags & nsMsgFolderFlags::Templates) - specialFolderString.AssignLiteral("Templates"); - else if (flags & nsMsgFolderFlags::Junk) - specialFolderString.AssignLiteral("Junk"); - else if (flags & nsMsgFolderFlags::Virtual) - specialFolderString.AssignLiteral("Virtual"); - else if (flags & nsMsgFolderFlags::Archive) - specialFolderString.AssignLiteral("Archives"); - else { - // XXX why do this at all? or just "" - specialFolderString.AssignLiteral("none"); - } - - createNode(specialFolderString.get(), target, getRDFService()); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderServerTypeNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - nsCOMPtr server; - rv = folder->GetServer(getter_AddRefs(server)); - if (NS_FAILED(rv) || !server) return NS_ERROR_FAILURE; - - nsCString serverType; - rv = server->GetType(serverType); - if (NS_FAILED(rv)) return rv; - - createNode(NS_ConvertASCIItoUTF16(serverType).get(), target, getRDFService()); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createServerIsDeferredNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - bool isDeferred = false; - nsCOMPtr incomingServer; - folder->GetServer(getter_AddRefs(incomingServer)); - if (incomingServer) - { - nsCOMPtr pop3Server = do_QueryInterface(incomingServer); - if (pop3Server) - { - nsCString deferredToServer; - pop3Server->GetDeferredToAccount(deferredToServer); - isDeferred = !deferredToServer.IsEmpty(); - } - } - *target = (isDeferred) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderCanCreateFoldersOnServerNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - - nsCOMPtr server; - rv = folder->GetServer(getter_AddRefs(server)); - if (NS_FAILED(rv) || !server) return NS_ERROR_FAILURE; - - bool canCreateFoldersOnServer; - rv = server->GetCanCreateFoldersOnServer(&canCreateFoldersOnServer); - if (NS_FAILED(rv)) return rv; - - if (canCreateFoldersOnServer) - *target = kTrueLiteral; - else - *target = kFalseLiteral; - NS_IF_ADDREF(*target); - - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderCanFileMessagesOnServerNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - - nsCOMPtr server; - rv = folder->GetServer(getter_AddRefs(server)); - if (NS_FAILED(rv) || !server) return NS_ERROR_FAILURE; - - bool canFileMessagesOnServer; - rv = server->GetCanFileMessagesOnServer(&canFileMessagesOnServer); - if (NS_FAILED(rv)) return rv; - - *target = (canFileMessagesOnServer) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - - return NS_OK; -} - - -nsresult -nsMsgFolderDataSource::createFolderIsServerNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - bool isServer; - rv = folder->GetIsServer(&isServer); - if (NS_FAILED(rv)) return rv; - - *target = nullptr; - - if (isServer) - *target = kTrueLiteral; - else - *target = kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderNoSelectNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - bool noSelect; - rv = folder->GetNoSelect(&noSelect); - if (NS_FAILED(rv)) return rv; - - *target = (noSelect) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createInVFEditSearchScopeNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - bool inVFEditSearchScope = false; - folder->GetInVFEditSearchScope(&inVFEditSearchScope); - - *target = inVFEditSearchScope ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderVirtualNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - uint32_t folderFlags; - folder->GetFlags(&folderFlags); - - *target = (folderFlags & nsMsgFolderFlags::Virtual) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - - -nsresult -nsMsgFolderDataSource::createFolderImapSharedNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - bool imapShared; - rv = folder->GetImapShared(&imapShared); - if (NS_FAILED(rv)) return rv; - - *target = (imapShared) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - - -nsresult -nsMsgFolderDataSource::createFolderSynchronizeNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - bool sync; - rv = folder->GetFlag(nsMsgFolderFlags::Offline, &sync); - if (NS_FAILED(rv)) return rv; - - *target = nullptr; - - *target = (sync) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderSyncDisabledNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - - nsresult rv; - bool isServer; - nsCOMPtr server; - - rv = folder->GetIsServer(&isServer); - if (NS_FAILED(rv)) return rv; - - rv = folder->GetServer(getter_AddRefs(server)); - if (NS_FAILED(rv) || !server) return NS_ERROR_FAILURE; - - nsCString serverType; - rv = server->GetType(serverType); - if (NS_FAILED(rv)) return rv; - - *target = isServer || MsgLowerCaseEqualsLiteral(serverType, "none") || MsgLowerCaseEqualsLiteral(serverType, "pop3") ? - kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createCanSearchMessages(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - - nsCOMPtr server; - rv = folder->GetServer(getter_AddRefs(server)); - if (NS_FAILED(rv) || !server) return NS_ERROR_FAILURE; - - bool canSearchMessages; - rv = server->GetCanSearchMessages(&canSearchMessages); - if (NS_FAILED(rv)) return rv; - - *target = (canSearchMessages) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderOpenNode(nsIMsgFolder *folder, nsIRDFNode **target) -{ - NS_ENSURE_ARG_POINTER(target); - - // call GetSubFolders() to ensure mFlags is set correctly - // from the folder cache on startup - nsCOMPtr subFolders; - nsresult rv = folder->GetSubFolders(getter_AddRefs(subFolders)); - if (NS_FAILED(rv)) - return NS_RDF_NO_VALUE; - - bool closed; - rv = folder->GetFlag(nsMsgFolderFlags::Elided, &closed); - if (NS_FAILED(rv)) - return rv; - - *target = (closed) ? kFalseLiteral : kTrueLiteral; - - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderIsSecureNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - bool isSecure = false; - - nsCOMPtr server; - rv = folder->GetServer(getter_AddRefs(server)); - - if (NS_SUCCEEDED(rv) && server) { - rv = server->GetIsSecure(&isSecure); - NS_ENSURE_SUCCESS(rv, rv); - } - - *target = (isSecure) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - - -nsresult -nsMsgFolderDataSource::createFolderCanSubscribeNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - bool canSubscribe; - rv = folder->GetCanSubscribe(&canSubscribe); - if (NS_FAILED(rv)) return rv; - - *target = (canSubscribe) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderSupportsOfflineNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - bool supportsOffline; - rv = folder->GetSupportsOffline(&supportsOffline); - NS_ENSURE_SUCCESS(rv,rv); - - *target = (supportsOffline) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderCanFileMessagesNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - bool canFileMessages; - rv = folder->GetCanFileMessages(&canFileMessages); - if (NS_FAILED(rv)) return rv; - - *target = (canFileMessages) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderCanCreateSubfoldersNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - nsresult rv; - bool canCreateSubfolders; - rv = folder->GetCanCreateSubfolders(&canCreateSubfolders); - if (NS_FAILED(rv)) return rv; - - *target = (canCreateSubfolders) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderCanRenameNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - bool canRename; - nsresult rv = folder->GetCanRename(&canRename); - if (NS_FAILED(rv)) return rv; - - *target = (canRename) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderCanCompactNode(nsIMsgFolder* folder, - nsIRDFNode **target) -{ - bool canCompact; - nsresult rv = folder->GetCanCompact(&canCompact); - if (NS_FAILED(rv)) return rv; - - *target = (canCompact) ? kTrueLiteral : kFalseLiteral; - NS_IF_ADDREF(*target); - return NS_OK; -} - - -nsresult -nsMsgFolderDataSource::createTotalMessagesNode(nsIMsgFolder *folder, - nsIRDFNode **target) -{ - - bool isServer; - nsresult rv = folder->GetIsServer(&isServer); - if (NS_FAILED(rv)) return rv; - - int32_t totalMessages; - if(isServer) - totalMessages = kDisplayBlankCount; - else - { - rv = folder->GetTotalMessages(false, &totalMessages); - if(NS_FAILED(rv)) return rv; - } - GetNumMessagesNode(totalMessages, target); - - return rv; -} - -nsresult -nsMsgFolderDataSource::createFolderSizeNode(nsIMsgFolder *folder, nsIRDFNode **target) -{ - bool isServer; - nsresult rv = folder->GetIsServer(&isServer); - NS_ENSURE_SUCCESS(rv, rv); - - int64_t folderSize; - if (isServer) { - folderSize = kDisplayBlankCount64; - } - else - { - // XXX todo, we are asserting here for news - // for offline news, we'd know the size on disk, right? Yes, bug 851275. - rv = folder->GetSizeOnDisk(&folderSize); - NS_ENSURE_SUCCESS(rv, rv); - } - - return GetFolderSizeNode(folderSize, target); -} - -nsresult -nsMsgFolderDataSource::createCharsetNode(nsIMsgFolder *folder, nsIRDFNode **target) -{ - nsCString charset; - nsresult rv = folder->GetCharset(charset); - if (NS_SUCCEEDED(rv)) - createNode(NS_ConvertASCIItoUTF16(charset).get(), target, getRDFService()); - else - createNode(EmptyString().get(), target, getRDFService()); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createBiffStateNodeFromFolder(nsIMsgFolder *folder, nsIRDFNode **target) -{ - uint32_t biffState; - nsresult rv = folder->GetBiffState(&biffState); - if(NS_FAILED(rv)) return rv; - - rv = createBiffStateNodeFromFlag(biffState, target); - NS_ENSURE_SUCCESS(rv,rv); - - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createBiffStateNodeFromFlag(uint32_t flag, nsIRDFNode **target) -{ - const char16_t *biffStateStr; - - switch (flag) { - case nsIMsgFolder::nsMsgBiffState_NewMail: - biffStateStr = u"NewMail"; - break; - case nsIMsgFolder::nsMsgBiffState_NoMail: - biffStateStr = u"NoMail"; - break; - default: - biffStateStr = u"UnknownMail"; - break; - } - - createNode(biffStateStr, target, getRDFService()); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createUnreadMessagesNode(nsIMsgFolder *folder, - nsIRDFNode **target) -{ - bool isServer; - nsresult rv = folder->GetIsServer(&isServer); - if (NS_FAILED(rv)) return rv; - - int32_t totalUnreadMessages; - if(isServer) - totalUnreadMessages = kDisplayBlankCount; - else - { - rv = folder->GetNumUnread(false, &totalUnreadMessages); - if(NS_FAILED(rv)) return rv; - } - GetNumMessagesNode(totalUnreadMessages, target); - - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createHasUnreadMessagesNode(nsIMsgFolder *folder, bool aIncludeSubfolders, nsIRDFNode **target) -{ - bool isServer; - nsresult rv = folder->GetIsServer(&isServer); - if (NS_FAILED(rv)) return rv; - - *target = kFalseLiteral; - - int32_t totalUnreadMessages; - if(!isServer) - { - rv = folder->GetNumUnread(aIncludeSubfolders, &totalUnreadMessages); - if(NS_FAILED(rv)) return rv; - // if we're including sub-folders, we're trying to find out if child folders - // have unread. If so, we subtract the unread msgs in the current folder. - if (aIncludeSubfolders) - { - int32_t numUnreadInFolder; - rv = folder->GetNumUnread(false, &numUnreadInFolder); - NS_ENSURE_SUCCESS(rv, rv); - // don't subtract if numUnread is negative (which means we don't know the unread count) - if (numUnreadInFolder > 0) - totalUnreadMessages -= numUnreadInFolder; - } - *target = (totalUnreadMessages > 0) ? kTrueLiteral : kFalseLiteral; - } - - NS_IF_ADDREF(*target); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::OnUnreadMessagePropertyChanged(nsIRDFResource *folderResource, int32_t oldValue, int32_t newValue) -{ - nsCOMPtr folder = do_QueryInterface(folderResource); - if(folder) - { - //First send a regular unread message changed notification - nsCOMPtr newNode; - - GetNumMessagesNode(newValue, getter_AddRefs(newNode)); - NotifyPropertyChanged(folderResource, kNC_TotalUnreadMessages, newNode); - - //Now see if hasUnreadMessages has changed - if(oldValue <=0 && newValue >0) - { - NotifyPropertyChanged(folderResource, kNC_HasUnreadMessages, kTrueLiteral); - NotifyAncestors(folder, kNC_SubfoldersHaveUnreadMessages, kTrueLiteral); - } - else if(oldValue > 0 && newValue <= 0) - { - NotifyPropertyChanged(folderResource, kNC_HasUnreadMessages, kFalseLiteral); - // this isn't quite right - parents could still have other children with - // unread messages. NotifyAncestors will have to figure that out... - NotifyAncestors(folder, kNC_SubfoldersHaveUnreadMessages, kFalseLiteral); - } - - //We will have to change the folderTreeName if the unread column is hidden - NotifyFolderTreeNameChanged(folder, folderResource, newValue); - } - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::NotifyFolderNameChanged(nsIMsgFolder* aFolder, nsIRDFResource *folderResource) -{ - nsString name; - nsresult rv = aFolder->GetName(name); - - if (NS_SUCCEEDED(rv)) { - nsCOMPtr newNameNode; - createNode(name.get(), getter_AddRefs(newNameNode), getRDFService()); - NotifyPropertyChanged(folderResource, kNC_Name, newNameNode); - } - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::NotifyFolderTreeSimpleNameChanged(nsIMsgFolder* aFolder, nsIRDFResource *folderResource) -{ - nsString abbreviatedName; - nsresult rv = GetFolderDisplayName(aFolder, abbreviatedName); - if (NS_SUCCEEDED(rv)) { - nsCOMPtr newNameNode; - createNode(abbreviatedName.get(), getter_AddRefs(newNameNode), getRDFService()); - NotifyPropertyChanged(folderResource, kNC_FolderTreeSimpleName, newNameNode); - } - - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::NotifyFolderTreeNameChanged(nsIMsgFolder* aFolder, - nsIRDFResource* aFolderResource, - int32_t aUnreadMessages) -{ - nsString name; - nsresult rv = GetFolderDisplayName(aFolder, name); - if (NS_SUCCEEDED(rv)) { - nsAutoString newNameString(name); - CreateUnreadMessagesNameString(aUnreadMessages, newNameString); - nsCOMPtr newNameNode; - createNode(newNameString.get(), getter_AddRefs(newNameNode), getRDFService()); - NotifyPropertyChanged(aFolderResource, kNC_FolderTreeName, newNameNode); - } - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::NotifyAncestors(nsIMsgFolder *aFolder, nsIRDFResource *aPropertyResource, nsIRDFNode *aNode) -{ - bool isServer = false; - nsresult rv = aFolder->GetIsServer(&isServer); - NS_ENSURE_SUCCESS(rv,rv); - - if (isServer) - // done, stop - return NS_OK; - - nsCOMPtr parentMsgFolder; - rv = aFolder->GetParent(getter_AddRefs(parentMsgFolder)); - NS_ENSURE_SUCCESS(rv,rv); - if (!parentMsgFolder) - return NS_OK; - - rv = parentMsgFolder->GetIsServer(&isServer); - NS_ENSURE_SUCCESS(rv,rv); - - // don't need to notify servers either. - if (isServer) - // done, stop - return NS_OK; - - nsCOMPtr parentFolderResource = do_QueryInterface(parentMsgFolder,&rv); - NS_ENSURE_SUCCESS(rv,rv); - - // if we're setting the subFoldersHaveUnreadMessages property to false, check - // if the folder really doesn't have subfolders with unread messages. - if (aPropertyResource == kNC_SubfoldersHaveUnreadMessages && aNode == kFalseLiteral) - { - nsCOMPtr unreadMsgsNode; - createHasUnreadMessagesNode(parentMsgFolder, true, getter_AddRefs(unreadMsgsNode)); - aNode = unreadMsgsNode; - } - NotifyPropertyChanged(parentFolderResource, aPropertyResource, aNode); - - return NotifyAncestors(parentMsgFolder, aPropertyResource, aNode); -} - -// New Messages - -nsresult -nsMsgFolderDataSource::createNewMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target) -{ - - nsresult rv; - - bool isServer; - rv = folder->GetIsServer(&isServer); - if (NS_FAILED(rv)) return rv; - - *target = kFalseLiteral; - - //int32_t totalNewMessages; - bool isNewMessages; - if(!isServer) - { - rv = folder->GetHasNewMessages(&isNewMessages); - if(NS_FAILED(rv)) return rv; - *target = (isNewMessages) ? kTrueLiteral : kFalseLiteral; - } - NS_IF_ADDREF(*target); - return NS_OK; -} - -/** -nsresult -nsMsgFolderDataSource::OnUnreadMessagePropertyChanged(nsIMsgFolder *folder, int32_t oldValue, int32_t newValue) -{ - nsCOMPtr folderResource = do_QueryInterface(folder); - if(folderResource) - { - //First send a regular unread message changed notification - nsCOMPtr newNode; - - GetNumMessagesNode(newValue, getter_AddRefs(newNode)); - NotifyPropertyChanged(folderResource, kNC_TotalUnreadMessages, newNode); - - //Now see if hasUnreadMessages has changed - nsCOMPtr oldHasUnreadMessages; - nsCOMPtr newHasUnreadMessages; - if(oldValue <=0 && newValue >0) - { - oldHasUnreadMessages = kFalseLiteral; - newHasUnreadMessages = kTrueLiteral; - NotifyPropertyChanged(folderResource, kNC_HasUnreadMessages, newHasUnreadMessages); - } - else if(oldValue > 0 && newValue <= 0) - { - newHasUnreadMessages = kFalseLiteral; - NotifyPropertyChanged(folderResource, kNC_HasUnreadMessages, newHasUnreadMessages); - } - } - return NS_OK; -} - -**/ -nsresult -nsMsgFolderDataSource::OnFolderSortOrderPropertyChanged(nsIRDFResource *folderResource, int32_t oldValue, int32_t newValue) -{ - nsCOMPtr folder(do_QueryInterface(folderResource)); - if (folder) - { - nsCOMPtr newNode; - createFolderNameNode(folder, getter_AddRefs(newNode), true); - NotifyPropertyChanged(folderResource, kNC_FolderTreeNameSort, newNode); - } - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::OnFolderSizePropertyChanged(nsIRDFResource *folderResource, int64_t oldValue, int64_t newValue) -{ - nsCOMPtr newNode; - GetFolderSizeNode(newValue, getter_AddRefs(newNode)); - NotifyPropertyChanged(folderResource, kNC_FolderSize, newNode); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::OnTotalMessagePropertyChanged(nsIRDFResource *folderResource, int32_t oldValue, int32_t newValue) -{ - nsCOMPtr newNode; - GetNumMessagesNode(newValue, getter_AddRefs(newNode)); - NotifyPropertyChanged(folderResource, kNC_TotalMessages, newNode); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::GetNumMessagesNode(int32_t aNumMessages, nsIRDFNode **node) -{ - uint32_t numMessages = aNumMessages; - if(numMessages == kDisplayQuestionCount) - createNode(u"???", node, getRDFService()); - else if (numMessages == kDisplayBlankCount || numMessages == 0) - createNode(EmptyString().get(), node, getRDFService()); - else - createIntNode(numMessages, node, getRDFService()); - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::GetFolderSizeNode(int64_t aFolderSize, nsIRDFNode **aNode) -{ - nsresult rv; - if (aFolderSize == kDisplayBlankCount64 || aFolderSize == 0) - createNode(EmptyString().get(), aNode, getRDFService()); - else if (aFolderSize == kDisplayQuestionCount64) - createNode(u"???", aNode, getRDFService()); - else - { - nsAutoString sizeString; - rv = FormatFileSize(aFolderSize, true, sizeString); - NS_ENSURE_SUCCESS(rv, rv); - - createNode(sizeString.get(), aNode, getRDFService()); - } - return NS_OK; -} - -nsresult -nsMsgFolderDataSource::createFolderChildNode(nsIMsgFolder *folder, - nsIRDFNode **target) -{ - nsCOMPtr subFolders; - nsresult rv = folder->GetSubFolders(getter_AddRefs(subFolders)); - if (NS_FAILED(rv)) - return NS_RDF_NO_VALUE; - - bool hasMore; - rv = subFolders->HasMoreElements(&hasMore); - if (NS_FAILED(rv) || !hasMore) - return NS_RDF_NO_VALUE; - - nsCOMPtr firstFolder; - rv = subFolders->GetNext(getter_AddRefs(firstFolder)); - if (NS_FAILED(rv)) - return NS_RDF_NO_VALUE; - - return CallQueryInterface(firstFolder, target); -} - -#if 0 -nsresult nsMsgFolderDataSource::DoCopyToFolder(nsIMsgFolder *dstFolder, nsISupportsArray *arguments, - nsIMsgWindow *msgWindow, bool isMove) -{ - nsresult rv; - uint32_t itemCount; - rv = arguments->Count(&itemCount); - NS_ENSURE_SUCCESS(rv, rv); - - //need source folder and at least one item to copy - if(itemCount < 2) - return NS_ERROR_FAILURE; - - nsCOMPtr srcFolder(do_QueryElementAt(arguments, 0)); - if(!srcFolder) - return NS_ERROR_FAILURE; - - nsCOMPtr messageArray(do_CreateInstance(NS_ARRAY_CONTRACTID)); - - // Remove first element - for(uint32_t i = 1; i < itemCount; i++) - { - nsCOMPtr message(do_QueryElementAt(arguments, i)); - if (message) - { - messageArray->AppendElement(message); - } - } - - //Call copyservice with dstFolder, srcFolder, messages, isMove, and txnManager - nsCOMPtr copyService = - do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv,rv); - - return copyService->CopyMessages(srcFolder, messageArray, dstFolder, isMove, - nullptr, msgWindow, true/* allowUndo */); -} - -nsresult nsMsgFolderDataSource::DoFolderCopyToFolder(nsIMsgFolder *dstFolder, nsISupportsArray *arguments, - nsIMsgWindow *msgWindow, bool isMoveFolder) -{ - nsresult rv; - uint32_t itemCount; - rv = arguments->Count(&itemCount); - NS_ENSURE_SUCCESS(rv, rv); - - //need at least one item to copy - if(itemCount < 1) - return NS_ERROR_FAILURE; - - if (!isMoveFolder) // copy folder not on the same server - { - // Create an nsIMutableArray from the nsISupportsArray - nsCOMPtr folderArray(do_CreateInstance(NS_ARRAY_CONTRACTID)); - for (uint32_t i = 0; i < itemCount; i++) - { - nsCOMPtr element(do_QueryElementAt(arguments, i, &rv)); - if (NS_SUCCEEDED(rv)) - folderArray->AppendElement(element); - } - - //Call copyservice with dstFolder, srcFolder, folders and isMoveFolder - nsCOMPtr copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv); - if(NS_SUCCEEDED(rv)) - { - rv = copyService->CopyFolders(folderArray, dstFolder, isMoveFolder, - nullptr, msgWindow); - - } - } - else //within the same server therefore no need for copy service - { - - nsCOMPtr msgFolder; - for (uint32_t i=0;i< itemCount; i++) - { - msgFolder = do_QueryElementAt(arguments, i, &rv); - if (NS_SUCCEEDED(rv)) - { - rv = dstFolder->CopyFolder(msgFolder, isMoveFolder , msgWindow, nullptr); - NS_ASSERTION((NS_SUCCEEDED(rv)),"Copy folder failed."); - } - } - } - - return rv; - //return NS_OK; -} - -nsresult nsMsgFolderDataSource::DoDeleteFromFolder(nsIMsgFolder *folder, nsISupportsArray *arguments, - nsIMsgWindow *msgWindow, bool reallyDelete) -{ - nsresult rv = NS_OK; - uint32_t itemCount; - rv = arguments->Count(&itemCount); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr messageArray(do_CreateInstance(NS_ARRAY_CONTRACTID)); - nsCOMPtr folderArray(do_CreateInstance(NS_ARRAY_CONTRACTID)); - - //Split up deleted items into different type arrays to be passed to the folder - //for deletion. - for(uint32_t item = 0; item < itemCount; item++) - { - nsCOMPtr supports(do_QueryElementAt(arguments, item)); - nsCOMPtr deletedMessage(do_QueryInterface(supports)); - nsCOMPtr deletedFolder(do_QueryInterface(supports)); - if (deletedMessage) - { - messageArray->AppendElement(supports); - } - else if(deletedFolder) - { - folderArray->AppendElement(supports); - } - } - uint32_t cnt; - rv = messageArray->GetLength(&cnt); - if (NS_FAILED(rv)) return rv; - if (cnt > 0) - rv = folder->DeleteMessages(messageArray, msgWindow, reallyDelete, false, nullptr, true /*allowUndo*/); - - rv = folderArray->GetLength(&cnt); - if (NS_FAILED(rv)) return rv; - if (cnt > 0) - { - nsCOMPtr folderToDelete = do_QueryElementAt(folderArray, 0); - uint32_t folderFlags = 0; - if (folderToDelete) - { - folderToDelete->GetFlags(&folderFlags); - if (folderFlags & nsMsgFolderFlags::Virtual) - { - NS_ENSURE_ARG_POINTER(msgWindow); - nsCOMPtr sBundleService = - mozilla::services::GetStringBundleService(); - NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED); - nsCOMPtr sMessengerStringBundle; - nsString confirmMsg; - rv = sBundleService->CreateBundle(MESSENGER_STRING_URL, getter_AddRefs(sMessengerStringBundle)); - NS_ENSURE_SUCCESS(rv, rv); - sMessengerStringBundle->GetStringFromName("confirmSavedSearchDeleteMessage", confirmMsg); - - nsCOMPtr dialog; - rv = msgWindow->GetPromptDialog(getter_AddRefs(dialog)); - if (NS_SUCCEEDED(rv)) - { - bool dialogResult; - rv = dialog->Confirm(nullptr, confirmMsg.get(), &dialogResult); - if (!dialogResult) - return NS_OK; - } - } - } - rv = folder->DeleteSubFolders(folderArray, msgWindow); - } - return rv; -} - -nsresult nsMsgFolderDataSource::DoNewFolder(nsIMsgFolder *folder, nsISupportsArray *arguments, nsIMsgWindow *window) -{ - nsresult rv = NS_OK; - nsCOMPtr literal = do_QueryElementAt(arguments, 0, &rv); - if(NS_SUCCEEDED(rv)) - { - nsString name; - literal->GetValue(getter_Copies(name)); - rv = folder->CreateSubfolder(name, window); - } - return rv; -} -#endif - -nsresult nsMsgFolderDataSource::DoFolderAssert(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target) -{ - nsresult rv = NS_ERROR_FAILURE; - - if (kNC_Charset == property) - { - nsCOMPtr literal(do_QueryInterface(target)); - if(literal) - { - const char16_t* value; - rv = literal->GetValueConst(&value); - if(NS_SUCCEEDED(rv)) - rv = folder->SetCharset(NS_LossyConvertUTF16toASCII(value)); - } - else - rv = NS_ERROR_FAILURE; - } - else if (kNC_Open == property && target == kTrueLiteral) - rv = folder->ClearFlag(nsMsgFolderFlags::Elided); - - return rv; -} - -nsresult nsMsgFolderDataSource::DoFolderUnassert(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target) -{ - nsresult rv = NS_ERROR_FAILURE; - - if((kNC_Open == property) && target == kTrueLiteral) - rv = folder->SetFlag(nsMsgFolderFlags::Elided); - - return rv; -} - -nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder, - nsIRDFResource *property, - nsIRDFNode *target, - bool tv, - bool *hasAssertion) -{ - nsresult rv = NS_OK; - if(!hasAssertion) - return NS_ERROR_NULL_POINTER; - - //We're not keeping track of negative assertions on folders. - if(!tv) - { - *hasAssertion = false; - return NS_OK; - } - - if (kNC_Child == property) - { - nsCOMPtr childFolder(do_QueryInterface(target, &rv)); - if(NS_SUCCEEDED(rv)) - { - nsCOMPtr childsParent; - rv = childFolder->GetParent(getter_AddRefs(childsParent)); - *hasAssertion = (NS_SUCCEEDED(rv) && childsParent && folder - && (childsParent.get() == folder)); - } - } - else if ((kNC_Name == property) || - (kNC_Open == property) || - (kNC_FolderTreeName == property) || - (kNC_FolderTreeSimpleName == property) || - (kNC_SpecialFolder == property) || - (kNC_ServerType == property) || - (kNC_IsDeferred == property) || - (kNC_CanCreateFoldersOnServer == property) || - (kNC_CanFileMessagesOnServer == property) || - (kNC_IsServer == property) || - (kNC_IsSecure == property) || - (kNC_CanSubscribe == property) || - (kNC_SupportsOffline == property) || - (kNC_CanFileMessages == property) || - (kNC_CanCreateSubfolders == property) || - (kNC_CanRename == property) || - (kNC_CanCompact == property) || - (kNC_TotalMessages == property) || - (kNC_TotalUnreadMessages == property) || - (kNC_FolderSize == property) || - (kNC_Charset == property) || - (kNC_BiffState == property) || - (kNC_HasUnreadMessages == property) || - (kNC_NoSelect == property) || - (kNC_Synchronize == property) || - (kNC_SyncDisabled == property) || - (kNC_VirtualFolder == property) || - (kNC_CanSearchMessages == property)) - { - nsCOMPtr folderResource(do_QueryInterface(folder, &rv)); - - if(NS_FAILED(rv)) - return rv; - - rv = GetTargetHasAssertion(this, folderResource, property, tv, target, hasAssertion); - } - else - *hasAssertion = false; - return rv; -} - -nsMsgFlatFolderDataSource::nsMsgFlatFolderDataSource() -{ - m_builtFolders = false; -} - -nsMsgFlatFolderDataSource::~nsMsgFlatFolderDataSource() -{ -} - -nsresult nsMsgFlatFolderDataSource::Init() -{ - nsIRDFService* rdf = getRDFService(); - NS_ENSURE_TRUE(rdf, NS_ERROR_FAILURE); - nsCOMPtr source; - nsAutoCString dsUri(m_dsName); - dsUri.Append(":/"); - rdf->GetResource(dsUri, getter_AddRefs(m_rootResource)); - - return nsMsgFolderDataSource::Init(); -} - -void nsMsgFlatFolderDataSource::Cleanup() -{ - m_folders.Clear(); - m_builtFolders = false; - nsMsgFolderDataSource::Cleanup(); -} - -NS_IMETHODIMP nsMsgFlatFolderDataSource::GetTarget(nsIRDFResource* source, - nsIRDFResource* property, - bool tv, - nsIRDFNode** target) -{ - return (property == kNC_Child) - ? NS_RDF_NO_VALUE - : nsMsgFolderDataSource::GetTarget(source, property, tv, target); -} - - -NS_IMETHODIMP nsMsgFlatFolderDataSource::GetTargets(nsIRDFResource* source, - nsIRDFResource* property, - bool tv, - nsISimpleEnumerator** targets) -{ - if (kNC_Child != property) - return nsMsgFolderDataSource::GetTargets(source, property, tv, targets); - - if(!targets) - return NS_ERROR_NULL_POINTER; - - if (ResourceIsOurRoot(source)) - { - EnsureFolders(); - return NS_NewArrayEnumerator(targets, m_folders); - } - return NS_NewSingletonEnumerator(targets, property); -} - -void nsMsgFlatFolderDataSource::EnsureFolders() -{ - if (m_builtFolders) - return; - - m_builtFolders = true; // in case something goes wrong - - nsresult rv; - nsCOMPtr accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS_VOID(rv); - - nsCOMPtr allFolders; - rv = accountManager->GetAllFolders(getter_AddRefs(allFolders)); - if (NS_FAILED(rv) || !allFolders) - return; - - uint32_t count; - rv = allFolders->GetLength(&count); - NS_ENSURE_SUCCESS_VOID(rv); - - for (uint32_t i = 0; i < count; i++) - { - nsCOMPtr curFolder = do_QueryElementAt(allFolders, i); - if (WantsThisFolder(curFolder)) - m_folders.AppendObject(curFolder); - } -} - - -NS_IMETHODIMP nsMsgFlatFolderDataSource::GetURI(char* *aUri) -{ - nsAutoCString uri("rdf:"); - uri.Append(m_dsName); - return (*aUri = ToNewCString(uri)) - ? NS_OK : NS_ERROR_OUT_OF_MEMORY; -} - -NS_IMETHODIMP nsMsgFlatFolderDataSource::HasAssertion(nsIRDFResource* source, - nsIRDFResource* property, - nsIRDFNode* target, - bool tv, - bool* hasAssertion) -{ - nsresult rv; - - nsCOMPtr folder(do_QueryInterface(source, &rv)); - // we need to check if the folder belongs in this datasource. - if (NS_SUCCEEDED(rv) && property != kNC_Open && property != kNC_Child) - { - if (WantsThisFolder(folder) && (kNC_Child != property)) - return DoFolderHasAssertion(folder, property, target, tv, hasAssertion); - } - else if (property == kNC_Child && ResourceIsOurRoot(source)) // check if source is us - { - folder = do_QueryInterface(target); - if (folder) - { - nsCOMPtr parentMsgFolder; - folder->GetParent(getter_AddRefs(parentMsgFolder)); - // a folder without a parent must be getting deleted as part of - // the rename operation and is thus a folder we are - // no longer interested in - if (parentMsgFolder && WantsThisFolder(folder)) - { - *hasAssertion = true; - return NS_OK; - } - } - } - *hasAssertion = false; - return NS_OK; -} - -nsresult nsMsgFlatFolderDataSource::OnItemAddedOrRemoved(nsIMsgFolder *parentItem, nsISupports *item, bool added) -{ - // When a folder is added or removed, parentItem is the parent folder and item is the folder being - // added or removed. In a flat data source, there is no arc in the graph between the parent folder - // and the folder being added or removed. Our flat data source root (i.e. mailnewsunreadfolders:/) has - // an arc with the child property to every folder in the data source. We must change parentItem - // to be our data source root before calling nsMsgFolderDataSource::OnItemAddedOrRemoved. This ensures - // that datasource listeners such as the template builder properly handle add and remove - // notifications on the flat datasource. - nsCOMPtr itemNode(do_QueryInterface(item)); - if (itemNode) - NotifyObservers(m_rootResource, kNC_Child, itemNode, nullptr, added, false); - return NS_OK; -} - -bool nsMsgFlatFolderDataSource::ResourceIsOurRoot(nsIRDFResource *resource) -{ - return m_rootResource.get() == resource; -} - -bool nsMsgFlatFolderDataSource::WantsThisFolder(nsIMsgFolder *folder) -{ - EnsureFolders(); - return m_folders.Contains(folder); -} - -nsresult nsMsgFlatFolderDataSource::GetFolderDisplayName(nsIMsgFolder *folder, nsString& folderName) -{ - folder->GetName(folderName); - uint32_t foldersCount = m_folders.Count(); - nsString otherFolderName; - for (uint32_t index = 0; index < foldersCount; index++) - { - if (folder == m_folders[index]) // ignore ourselves. - continue; - m_folders[index]->GetName(otherFolderName); - if (otherFolderName.Equals(folderName)) - { - nsCOMPtr server; - folder->GetServer(getter_AddRefs(server)); - if (server) - { - nsString serverName; - server->GetPrettyName(serverName); - folderName.AppendLiteral(" - "); - folderName.Append(serverName); - return NS_OK; - } - } - } - // check if folder name is unique - if not, append account name - return folder->GetAbbreviatedName(folderName); -} - - -bool nsMsgUnreadFoldersDataSource::WantsThisFolder(nsIMsgFolder *folder) -{ - int32_t numUnread; - folder->GetNumUnread(false, &numUnread); - return numUnread > 0; -} - -nsresult nsMsgUnreadFoldersDataSource::NotifyPropertyChanged(nsIRDFResource *resource, - nsIRDFResource *property, nsIRDFNode *newNode, - nsIRDFNode *oldNode) -{ - // check if it's the has unread property that's changed; if so, see if we need - // to add this folder to the view. - // Then, call base class. - if (kNC_HasUnreadMessages == property) - { - nsCOMPtr folder(do_QueryInterface(resource)); - if (folder) - { - int32_t numUnread; - folder->GetNumUnread(false, &numUnread); - if (numUnread > 0) - { - if (!m_folders.Contains(folder)) - m_folders.AppendObject(folder); - NotifyObservers(kNC_UnreadFolders, kNC_Child, resource, nullptr, true, false); - } - } - } - return nsMsgFolderDataSource::NotifyPropertyChanged(resource, property, - newNode, oldNode); -} - -bool nsMsgFavoriteFoldersDataSource::WantsThisFolder(nsIMsgFolder *folder) -{ - uint32_t folderFlags; - folder->GetFlags(&folderFlags); - return folderFlags & nsMsgFolderFlags::Favorite; -} - - -void nsMsgRecentFoldersDataSource::Cleanup() -{ - m_cutOffDate = 0; - nsMsgFlatFolderDataSource::Cleanup(); -} - - -void nsMsgRecentFoldersDataSource::EnsureFolders() -{ - if (m_builtFolders) - return; - - m_builtFolders = true; // in case something goes wrong - - nsresult rv; - nsCOMPtr accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS_VOID(rv); - - nsCOMPtr allFolders; - rv = accountManager->GetAllFolders(getter_AddRefs(allFolders)); - if (NS_FAILED(rv) || !allFolders) - return; - - uint32_t count; - rv = allFolders->GetLength(&count); - NS_ENSURE_SUCCESS_VOID(rv); - - for (uint32_t i = 0; i < count; i++) - { - nsCOMPtr curFolder = do_QueryElementAt(allFolders, i); - nsCString dateStr; - curFolder->GetStringProperty(MRU_TIME_PROPERTY, dateStr); - uint32_t curFolderDate = (uint32_t) dateStr.ToInteger(&rv); - if (NS_FAILED(rv)) - curFolderDate = 0; - - if (curFolderDate > m_cutOffDate) - { - // if m_folders is "full", replace oldest folder with this folder, - // and adjust m_cutOffDate so that it's the mrutime - // of the "new" oldest folder. - uint32_t curFaveFoldersCount = m_folders.Count(); - if (curFaveFoldersCount > m_maxNumFolders) - { - uint32_t indexOfOldestFolder = 0; - uint32_t oldestFaveDate = 0; - uint32_t newOldestFaveDate = 0; - for (uint32_t index = 0; index < curFaveFoldersCount; ) - { - nsCString curFaveFolderDateStr; - m_folders[index]->GetStringProperty(MRU_TIME_PROPERTY, curFaveFolderDateStr); - uint32_t curFaveFolderDate = (uint32_t) curFaveFolderDateStr.ToInteger(&rv); - if (!oldestFaveDate || curFaveFolderDate < oldestFaveDate) - { - indexOfOldestFolder = index; - newOldestFaveDate = oldestFaveDate; - oldestFaveDate = curFaveFolderDate; - } - if (!newOldestFaveDate || (index != indexOfOldestFolder - && curFaveFolderDate < newOldestFaveDate)) { - newOldestFaveDate = curFaveFolderDate; - } - index++; - } - if (curFolderDate > oldestFaveDate && !m_folders.Contains(curFolder)) - m_folders.ReplaceObjectAt(curFolder, indexOfOldestFolder); - - NS_ASSERTION(newOldestFaveDate >= m_cutOffDate, "cutoff date should be getting bigger"); - m_cutOffDate = newOldestFaveDate; - } - else if (!m_folders.Contains(curFolder)) - m_folders.AppendObject(curFolder); - } -#ifdef DEBUG_David_Bienvenu - else - { - for (uint32_t index = 0; index < m_folders.Count(); index++) - { - nsCString curFaveFolderDateStr; - m_folders[index]->GetStringProperty(MRU_TIME_PROPERTY, curFaveFolderDateStr); - uint32_t curFaveFolderDate = (uint32_t) curFaveFolderDateStr.ToInteger(&rv); - NS_ASSERTION(curFaveFolderDate > curFolderDate, "folder newer then faves but not added"); - } - } -#endif - } -} - -NS_IMETHODIMP nsMsgRecentFoldersDataSource::OnItemAdded(nsIMsgFolder *parentItem, nsISupports *item) -{ - // if we've already built the recent folder array, we should add this item to the array - // since just added items are by definition new. - // I think this means newly discovered imap folders (ones w/o msf files) will - // get added, but maybe that's OK. - if (m_builtFolders) - { - nsCOMPtr folder(do_QueryInterface(item)); - if (folder && !m_folders.Contains(folder)) - { - m_folders.AppendObject(folder); - nsCOMPtr resource = do_QueryInterface(item); - NotifyObservers(kNC_RecentFolders, kNC_Child, resource, nullptr, true, false); - } - } - return nsMsgFlatFolderDataSource::OnItemAdded(parentItem, item); -} - -nsresult nsMsgRecentFoldersDataSource::NotifyPropertyChanged(nsIRDFResource *resource, - nsIRDFResource *property, nsIRDFNode *newNode, - nsIRDFNode *oldNode) -{ - // check if it's the has new property that's changed; if so, see if we need - // to add this folder to the view. - // Then, call base class. - if (kNC_NewMessages == property) - { - nsCOMPtr folder(do_QueryInterface(resource)); - if (folder) - { - bool hasNewMessages; - folder->GetHasNewMessages(&hasNewMessages); - if (hasNewMessages) - { - if (!m_folders.Contains(folder)) - { - m_folders.AppendObject(folder); - NotifyObservers(kNC_RecentFolders, kNC_Child, resource, nullptr, true, false); - } - } - } - } - return nsMsgFolderDataSource::NotifyPropertyChanged(resource, property, - newNode, oldNode); -} diff --git a/mailnews/base/src/nsMsgFolderDataSource.h b/mailnews/base/src/nsMsgFolderDataSource.h deleted file mode 100644 --- a/mailnews/base/src/nsMsgFolderDataSource.h +++ /dev/null @@ -1,360 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/Attributes.h" -#include "nsIRDFDataSource.h" -#include "nsIRDFService.h" - -#include "nsIFolderListener.h" -#include "nsMsgRDFDataSource.h" - -#include "nsITransactionManager.h" -#include "nsCOMArray.h" -#include "nsIMutableArray.h" -#if 0 -// Disable deprecation warnings generated by nsISupportsArray and associated -// classes. -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif defined(_MSC_VER) -#pragma warning (disable : 4996) -#endif -#include "nsISupportsArray.h" -#endif -/** - * The mail data source. - */ -class nsMsgFolderDataSource : public nsMsgRDFDataSource, - public nsIFolderListener -{ -public: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIFOLDERLISTENER - - nsMsgFolderDataSource(void); - virtual nsresult Init() override; - virtual void Cleanup() override; - - // nsIRDFDataSource methods - NS_IMETHOD GetURI(char* *uri) override; - - NS_IMETHOD GetSource(nsIRDFResource* property, - nsIRDFNode* target, - bool tv, - nsIRDFResource** source /* out */) override; - - NS_IMETHOD GetTarget(nsIRDFResource* source, - nsIRDFResource* property, - bool tv, - nsIRDFNode** target) override; - - NS_IMETHOD GetSources(nsIRDFResource* property, - nsIRDFNode* target, - bool tv, - nsISimpleEnumerator** sources) override; - - NS_IMETHOD GetTargets(nsIRDFResource* source, - nsIRDFResource* property, - bool tv, - nsISimpleEnumerator** targets) override; - - NS_IMETHOD Assert(nsIRDFResource* source, - nsIRDFResource* property, - nsIRDFNode* target, - bool tv) override; - - NS_IMETHOD Unassert(nsIRDFResource* source, - nsIRDFResource* property, - nsIRDFNode* target) override; - - NS_IMETHOD HasAssertion(nsIRDFResource* source, - nsIRDFResource* property, - nsIRDFNode* target, - bool tv, - bool* hasAssertion) override; - - NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, - bool *result) override; - - NS_IMETHOD ArcLabelsIn(nsIRDFNode* node, - nsISimpleEnumerator** labels) override; - - NS_IMETHOD ArcLabelsOut(nsIRDFResource* source, - nsISimpleEnumerator** labels) override; - - NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult) override; - - NS_IMETHOD GetAllCmds(nsIRDFResource* source, - nsISimpleEnumerator/**/** commands - ) override; - - NS_IMETHOD IsCommandEnabled(nsISupports/*nsISupportsArray*/* aSources, - nsIRDFResource* aCommand, - nsISupports/*nsISupportsArray*/* aArguments, - bool* aResult) override; - - NS_IMETHOD DoCommand(nsISupports/*nsISupportsArray*/* aSources, - nsIRDFResource* aCommand, - nsISupports/*nsISupportsArray*/* aArguments) override; -protected: - virtual ~nsMsgFolderDataSource(); - - nsresult GetSenderName(nsAutoString& sender, nsAutoString *senderUserName); - - nsresult createFolderNode(nsIMsgFolder *folder, nsIRDFResource* property, - nsIRDFNode **target); - nsresult createFolderNameNode(nsIMsgFolder *folder, nsIRDFNode **target, bool sort); - nsresult createFolderOpenNode(nsIMsgFolder *folder,nsIRDFNode **target); - nsresult createFolderTreeNameNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createFolderTreeSimpleNameNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createFolderSpecialNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createFolderServerTypeNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createServerIsDeferredNode(nsIMsgFolder* folder, - nsIRDFNode **target); - nsresult createFolderCanCreateFoldersOnServerNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderCanFileMessagesOnServerNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderIsServerNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderIsSecureNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderCanSubscribeNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderSupportsOfflineNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderCanFileMessagesNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderCanCreateSubfoldersNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderCanRenameNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderCanCompactNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createTotalMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createUnreadMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createFolderSizeNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createCharsetNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createBiffStateNodeFromFolder(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createBiffStateNodeFromFlag(uint32_t flag, nsIRDFNode **target); - nsresult createHasUnreadMessagesNode(nsIMsgFolder *folder, bool aIncludeSubfolders, nsIRDFNode **target); - nsresult createNewMessagesNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createFolderNoSelectNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderVirtualNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createInVFEditSearchScopeNode(nsIMsgFolder* folder, - nsIRDFNode **target); - nsresult createFolderImapSharedNode(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderSynchronizeNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createFolderSyncDisabledNode(nsIMsgFolder *folder, nsIRDFNode **target); - nsresult createCanSearchMessages(nsIMsgFolder *folder, - nsIRDFNode **target); - nsresult createFolderChildNode(nsIMsgFolder *folder, nsIRDFNode **target); - - nsresult getFolderArcLabelsOut(nsCOMArray &aArcs); - -#if 0 - nsresult DoDeleteFromFolder(nsIMsgFolder *folder, - nsISupportsArray *arguments, nsIMsgWindow *msgWindow, bool reallyDelete); - - nsresult DoCopyToFolder(nsIMsgFolder *dstFolder, nsISupportsArray *arguments, - nsIMsgWindow *msgWindow, bool isMove); - - nsresult DoFolderCopyToFolder(nsIMsgFolder *dstFolder, nsISupportsArray *arguments, - nsIMsgWindow *msgWindow, bool isMoveFolder); - - nsresult DoNewFolder(nsIMsgFolder *folder, nsISupportsArray *arguments, - nsIMsgWindow *window); -#endif - - nsresult DoFolderAssert(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target); - nsresult DoFolderUnassert(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target); - - nsresult DoFolderHasAssertion(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target, - bool tv, bool *hasAssertion); - - nsresult GetBiffStateString(uint32_t biffState, nsAutoCString & biffStateStr); - - nsresult CreateUnreadMessagesNameString(int32_t unreadMessages, nsAutoString &nameString); - nsresult CreateArcsOutEnumerator(); - - virtual nsresult OnItemAddedOrRemoved(nsIMsgFolder *parentItem, nsISupports *item, bool added); - - nsresult OnUnreadMessagePropertyChanged(nsIRDFResource *folderResource, int32_t oldValue, int32_t newValue); - nsresult OnTotalMessagePropertyChanged(nsIRDFResource *folderResource, int32_t oldValue, int32_t newValue); - nsresult OnFolderSizePropertyChanged(nsIRDFResource *folderResource, int64_t oldValue, int64_t newValue); - nsresult OnFolderSortOrderPropertyChanged(nsIRDFResource *folderResource, int32_t oldValue, int32_t newValue); - nsresult NotifyFolderTreeNameChanged(nsIMsgFolder *folder, nsIRDFResource *folderResource, int32_t aUnreadMessages); - nsresult NotifyFolderTreeSimpleNameChanged(nsIMsgFolder *folder, nsIRDFResource *folderResource); - nsresult NotifyFolderNameChanged(nsIMsgFolder *folder, nsIRDFResource *folderResource); - nsresult NotifyAncestors(nsIMsgFolder *aFolder, nsIRDFResource *aPropertyResource, nsIRDFNode *aNode); - nsresult GetNumMessagesNode(int32_t numMessages, nsIRDFNode **node); - nsresult GetFolderSizeNode(int64_t folderSize, nsIRDFNode **node); - nsresult CreateLiterals(nsIRDFService *rdf); - - virtual nsresult GetFolderDisplayName(nsIMsgFolder *folder, nsString& folderName); - - static nsIRDFResource* kNC_Child; - static nsIRDFResource* kNC_Folder; - static nsIRDFResource* kNC_Name; - static nsIRDFResource* kNC_Open; - static nsIRDFResource* kNC_FolderTreeName; - static nsIRDFResource* kNC_FolderTreeSimpleName; - static nsIRDFResource* kNC_NameSort; - static nsIRDFResource* kNC_FolderTreeNameSort; - static nsIRDFResource* kNC_Columns; - static nsIRDFResource* kNC_MSGFolderRoot; - static nsIRDFResource* kNC_SpecialFolder; - static nsIRDFResource* kNC_ServerType; - static nsIRDFResource* kNC_IsDeferred; - static nsIRDFResource* kNC_CanCreateFoldersOnServer; - static nsIRDFResource* kNC_CanFileMessagesOnServer; - static nsIRDFResource* kNC_IsServer; - static nsIRDFResource* kNC_IsSecure; - static nsIRDFResource* kNC_CanSubscribe; - static nsIRDFResource* kNC_SupportsOffline; - static nsIRDFResource* kNC_CanFileMessages; - static nsIRDFResource* kNC_CanCreateSubfolders; - static nsIRDFResource* kNC_CanRename; - static nsIRDFResource* kNC_CanCompact; - static nsIRDFResource* kNC_TotalMessages; - static nsIRDFResource* kNC_TotalUnreadMessages; - static nsIRDFResource* kNC_FolderSize; - static nsIRDFResource* kNC_Charset; - static nsIRDFResource* kNC_BiffState; - static nsIRDFResource* kNC_HasUnreadMessages; - static nsIRDFResource* kNC_NewMessages; - static nsIRDFResource* kNC_SubfoldersHaveUnreadMessages; - static nsIRDFResource* kNC_NoSelect; - static nsIRDFResource* kNC_ImapShared; - static nsIRDFResource* kNC_Synchronize; - static nsIRDFResource* kNC_SyncDisabled; - static nsIRDFResource* kNC_CanSearchMessages; - static nsIRDFResource* kNC_VirtualFolder; - static nsIRDFResource* kNC_InVFEditSearchScope; - static nsIRDFResource* kNC_UnreadFolders; // maybe should be in nsMsgFlatFolderDataSource? - static nsIRDFResource* kNC_FavoriteFolders; // maybe should be in nsMsgFlatFolderDataSource? - static nsIRDFResource* kNC_RecentFolders; // maybe should be in nsMsgFlatFolderDataSource? - // commands - static nsIRDFResource* kNC_Delete; - static nsIRDFResource* kNC_ReallyDelete; - static nsIRDFResource* kNC_NewFolder; - static nsIRDFResource* kNC_GetNewMessages; - static nsIRDFResource* kNC_Copy; - static nsIRDFResource* kNC_Move; - static nsIRDFResource* kNC_CopyFolder; - static nsIRDFResource* kNC_MoveFolder; - static nsIRDFResource* kNC_MarkAllMessagesRead; - static nsIRDFResource* kNC_Compact; - static nsIRDFResource* kNC_CompactAll; - static nsIRDFResource* kNC_Rename; - static nsIRDFResource* kNC_EmptyTrash; - static nsIRDFResource* kNC_DownloadFlagged; - //Cached literals - nsCOMPtr kTrueLiteral; - nsCOMPtr kFalseLiteral; - - // property atoms - static nsIAtom* kTotalMessagesAtom; - static nsIAtom* kTotalUnreadMessagesAtom; - static nsIAtom* kFolderSizeAtom; - static nsIAtom* kBiffStateAtom; - static nsIAtom* kSortOrderAtom; - static nsIAtom* kNewMessagesAtom; - static nsIAtom* kNameAtom; - static nsIAtom* kSynchronizeAtom; - static nsIAtom* kOpenAtom; - static nsIAtom* kIsDeferredAtom; - static nsIAtom* kIsSecureAtom; - static nsrefcnt gFolderResourceRefCnt; - static nsIAtom* kCanFileMessagesAtom; - static nsIAtom* kInVFEditSearchScopeAtom; - - nsCOMArray kFolderArcsOutArray; - -}; - - -class nsMsgFlatFolderDataSource : public nsMsgFolderDataSource -{ -public: - // constructor could take a filter to filter out folders. - nsMsgFlatFolderDataSource(); - virtual ~nsMsgFlatFolderDataSource(); - virtual nsresult Init() override; - virtual void Cleanup() override; - - NS_IMETHOD GetURI(char* *uri) override; - NS_IMETHOD GetTargets(nsIRDFResource* source, - nsIRDFResource* property, - bool tv, - nsISimpleEnumerator** targets) override; - NS_IMETHOD GetTarget(nsIRDFResource* source, - nsIRDFResource* property, - bool tv, - nsIRDFNode** target) override; - - NS_IMETHOD HasAssertion(nsIRDFResource* source, - nsIRDFResource* property, - nsIRDFNode* target, - bool tv, - bool* hasAssertion) override; -protected: - virtual nsresult GetFolderDisplayName(nsIMsgFolder *folder, - nsString& folderName) override; - virtual void EnsureFolders(); - virtual bool WantsThisFolder(nsIMsgFolder *folder); - bool ResourceIsOurRoot(nsIRDFResource *resource); - virtual nsresult OnItemAddedOrRemoved(nsIMsgFolder *parentItem, nsISupports *item, - bool added) override; - - nsCOMArray m_folders; - nsCOMPtr m_rootResource; // the resource for our root - nsCString m_dsName; - bool m_builtFolders; -}; - - -class nsMsgUnreadFoldersDataSource : public nsMsgFlatFolderDataSource -{ -public: - nsMsgUnreadFoldersDataSource() {m_dsName = "mailnewsunreadfolders";} - virtual ~nsMsgUnreadFoldersDataSource() {} - virtual nsresult NotifyPropertyChanged(nsIRDFResource *resource, - nsIRDFResource *propertyResource, nsIRDFNode *newNode, - nsIRDFNode *oldNode = nullptr) override; -protected: - virtual bool WantsThisFolder(nsIMsgFolder *folder) override; -}; - -class nsMsgFavoriteFoldersDataSource : public nsMsgFlatFolderDataSource -{ -public: - nsMsgFavoriteFoldersDataSource() {m_dsName = "mailnewsfavefolders";} - virtual ~nsMsgFavoriteFoldersDataSource() {} -protected: - virtual bool WantsThisFolder(nsIMsgFolder *folder) override; -}; - -class nsMsgRecentFoldersDataSource : public nsMsgFlatFolderDataSource -{ -public: - nsMsgRecentFoldersDataSource() {m_dsName = "mailnewsrecentfolders"; - m_cutOffDate = 0; m_maxNumFolders = 15;} - virtual ~nsMsgRecentFoldersDataSource() {} - virtual nsresult NotifyPropertyChanged(nsIRDFResource *resource, - nsIRDFResource *property, nsIRDFNode *newNode, - nsIRDFNode *oldNode) override; - NS_IMETHOD OnItemAdded(nsIMsgFolder *parentItem, nsISupports *item) override; - virtual void Cleanup() override; -protected: - virtual void EnsureFolders() override; - uint32_t m_cutOffDate; - uint32_t m_maxNumFolders; -}; diff --git a/mailnews/build/nsMailModule.cpp b/mailnews/build/nsMailModule.cpp --- a/mailnews/build/nsMailModule.cpp +++ b/mailnews/build/nsMailModule.cpp @@ -54,18 +54,16 @@ #include "nsMessengerBootstrap.h" #include "nsMessenger.h" #include "nsIContentViewer.h" #include "nsMsgMailSession.h" #include "nsMsgAccount.h" #include "nsMsgAccountManager.h" #include "nsMsgIdentity.h" #include "nsMsgIncomingServer.h" -#include "nsMsgFolderDataSource.h" -#include "nsMsgAccountManagerDS.h" #include "nsMsgBiffManager.h" #include "nsMsgPurgeService.h" #include "nsStatusBarBiffManager.h" #include "nsMsgKeyArray.h" #include "nsCopyMessageStreamListener.h" #include "nsMsgCopyService.h" #include "nsMsgFolderCache.h" #include "nsMsgStatusFeedback.h" @@ -316,21 +314,16 @@ using namespace mozilla::mailnews; NS_GENERIC_FACTORY_CONSTRUCTOR(nsMessengerBootstrap) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgMailSession, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMessenger) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgAccountManager, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgAccount) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgIdentity) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgFolderDataSource, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgUnreadFoldersDataSource, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgFavoriteFoldersDataSource, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgRecentFoldersDataSource, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgAccountManagerDataSource, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgSearchSession) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgSearchTerm) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgSearchValidityManager) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgFilterService) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMsgBiffManager, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgPurgeService) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStatusBarBiffManager, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsCopyMessageStreamListener) @@ -377,21 +370,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(MailNewsD NS_DEFINE_NAMED_CID(NS_MESSENGERBOOTSTRAP_CID); NS_DEFINE_NAMED_CID(NS_MESSENGERWINDOWSERVICE_CID); NS_DEFINE_NAMED_CID(NS_MSGMAILSESSION_CID); NS_DEFINE_NAMED_CID(NS_MESSENGER_CID); NS_DEFINE_NAMED_CID(NS_MSGACCOUNTMANAGER_CID); NS_DEFINE_NAMED_CID(NS_MSGACCOUNT_CID); NS_DEFINE_NAMED_CID(NS_MSGIDENTITY_CID); -NS_DEFINE_NAMED_CID(NS_MAILNEWSFOLDERDATASOURCE_CID); -NS_DEFINE_NAMED_CID(NS_MAILNEWSUNREADFOLDERDATASOURCE_CID); -NS_DEFINE_NAMED_CID(NS_MAILNEWSFAVORITEFOLDERDATASOURCE_CID); -NS_DEFINE_NAMED_CID(NS_MAILNEWSRECENTFOLDERDATASOURCE_CID); -NS_DEFINE_NAMED_CID(NS_MSGACCOUNTMANAGERDATASOURCE_CID); NS_DEFINE_NAMED_CID(NS_MSGFILTERSERVICE_CID); NS_DEFINE_NAMED_CID(NS_MSGSEARCHSESSION_CID); NS_DEFINE_NAMED_CID(NS_MSGSEARCHTERM_CID); NS_DEFINE_NAMED_CID(NS_MSGSEARCHVALIDITYMANAGER_CID); NS_DEFINE_NAMED_CID(NS_MSGBIFFMANAGER_CID); NS_DEFINE_NAMED_CID(NS_MSGPURGESERVICE_CID); NS_DEFINE_NAMED_CID(NS_STATUSBARBIFFMANAGER_CID); NS_DEFINE_NAMED_CID(NS_COPYMESSAGESTREAMLISTENER_CID); @@ -835,21 +823,16 @@ const mozilla::Module::CIDEntry kMailNew // MailNews Base Entries { &kNS_MESSENGERBOOTSTRAP_CID, false, NULL, nsMessengerBootstrapConstructor }, { &kNS_MESSENGERWINDOWSERVICE_CID, false, NULL, nsMessengerBootstrapConstructor}, { &kNS_MSGMAILSESSION_CID, false, NULL, nsMsgMailSessionConstructor}, { &kNS_MESSENGER_CID, false, NULL,nsMessengerConstructor}, { &kNS_MSGACCOUNTMANAGER_CID, false, NULL, nsMsgAccountManagerConstructor}, { &kNS_MSGACCOUNT_CID, false, NULL, nsMsgAccountConstructor}, { &kNS_MSGIDENTITY_CID, false, NULL, nsMsgIdentityConstructor}, - { &kNS_MAILNEWSFOLDERDATASOURCE_CID, false, NULL, nsMsgFolderDataSourceConstructor}, - { &kNS_MAILNEWSUNREADFOLDERDATASOURCE_CID, false, NULL, nsMsgUnreadFoldersDataSourceConstructor}, - { &kNS_MAILNEWSFAVORITEFOLDERDATASOURCE_CID, false, NULL, nsMsgFavoriteFoldersDataSourceConstructor}, - { &kNS_MAILNEWSRECENTFOLDERDATASOURCE_CID, false, NULL, nsMsgRecentFoldersDataSourceConstructor}, - { &kNS_MSGACCOUNTMANAGERDATASOURCE_CID, false, NULL, nsMsgAccountManagerDataSourceConstructor}, { &kNS_MSGFILTERSERVICE_CID, false, NULL, nsMsgFilterServiceConstructor}, { &kNS_MSGSEARCHSESSION_CID, false, NULL, nsMsgSearchSessionConstructor}, { &kNS_MSGSEARCHTERM_CID, false, NULL, nsMsgSearchTermConstructor}, { &kNS_MSGSEARCHVALIDITYMANAGER_CID, false, NULL, nsMsgSearchValidityManagerConstructor}, { &kNS_MSGBIFFMANAGER_CID, false, NULL, nsMsgBiffManagerConstructor}, { &kNS_MSGPURGESERVICE_CID, false, NULL, nsMsgPurgeServiceConstructor}, { &kNS_STATUSBARBIFFMANAGER_CID, false, NULL, nsStatusBarBiffManagerConstructor}, { &kNS_COPYMESSAGESTREAMLISTENER_CID, false, NULL, nsCopyMessageStreamListenerConstructor}, @@ -1046,21 +1029,16 @@ const mozilla::Module::ContractIDEntry k // MailNews Base Entries { NS_MESSENGERBOOTSTRAP_CONTRACTID, &kNS_MESSENGERBOOTSTRAP_CID }, { NS_MESSENGERWINDOWSERVICE_CONTRACTID, &kNS_MESSENGERWINDOWSERVICE_CID }, { NS_MSGMAILSESSION_CONTRACTID, &kNS_MSGMAILSESSION_CID }, { NS_MESSENGER_CONTRACTID, &kNS_MESSENGER_CID }, { NS_MSGACCOUNTMANAGER_CONTRACTID, &kNS_MSGACCOUNTMANAGER_CID }, { NS_MSGACCOUNT_CONTRACTID, &kNS_MSGACCOUNT_CID }, { NS_MSGIDENTITY_CONTRACTID, &kNS_MSGIDENTITY_CID }, - { NS_MAILNEWSFOLDERDATASOURCE_CONTRACTID, &kNS_MAILNEWSFOLDERDATASOURCE_CID }, - { NS_MAILNEWSUNREADFOLDERDATASOURCE_CONTRACTID, &kNS_MAILNEWSUNREADFOLDERDATASOURCE_CID }, - { NS_MAILNEWSFAVORITEFOLDERDATASOURCE_CONTRACTID, &kNS_MAILNEWSFAVORITEFOLDERDATASOURCE_CID }, - { NS_MAILNEWSRECENTFOLDERDATASOURCE_CONTRACTID, &kNS_MAILNEWSRECENTFOLDERDATASOURCE_CID }, - { NS_RDF_DATASOURCE_CONTRACTID_PREFIX "msgaccountmanager", &kNS_MSGACCOUNTMANAGERDATASOURCE_CID }, { NS_MSGFILTERSERVICE_CONTRACTID, &kNS_MSGFILTERSERVICE_CID }, { NS_MSGSEARCHSESSION_CONTRACTID, &kNS_MSGSEARCHSESSION_CID }, { NS_MSGSEARCHTERM_CONTRACTID, &kNS_MSGSEARCHTERM_CID }, { NS_MSGSEARCHVALIDITYMANAGER_CONTRACTID, &kNS_MSGSEARCHVALIDITYMANAGER_CID }, { NS_MSGBIFFMANAGER_CONTRACTID, &kNS_MSGBIFFMANAGER_CID }, { NS_MSGPURGESERVICE_CONTRACTID, &kNS_MSGPURGESERVICE_CID }, { NS_STATUSBARBIFFMANAGER_CONTRACTID, &kNS_STATUSBARBIFFMANAGER_CID }, { NS_COPYMESSAGESTREAMLISTENER_CONTRACTID, &kNS_COPYMESSAGESTREAMLISTENER_CID },