зеркало из https://github.com/mozilla/gecko-dev.git
fix for #95457. the open / closed state of servers and folders in the folder pane
was not persisting across sessions. I added a new attribute to outliner "statedatasource" that you can set to use for state, otherwise, if you are "trusted" it will use the localstore. if not trusted, it will use an in memory datasource, which will not persist across sessions. r/sr=bienvenu for the mailnews part, r/sr=waterson for the content part.
This commit is contained in:
Родитель
c4a9f265fc
Коммит
9c896ab736
|
@ -260,6 +260,7 @@ XUL_ATOM(content, "content")
|
|||
XUL_ATOM(coalesceduplicatearcs, "coalesceduplicatearcs")
|
||||
XUL_ATOM(allownegativeassertions, "allownegativeassertions")
|
||||
XUL_ATOM(datasources, "datasources")
|
||||
XUL_ATOM(statedatasource,"statedatasource")
|
||||
XUL_ATOM(commandupdater, "commandupdater")
|
||||
XUL_ATOM(keyset, "keyset")
|
||||
XUL_ATOM(element, "element")
|
||||
|
|
|
@ -53,6 +53,9 @@
|
|||
#include "nsXULTemplateBuilder.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
// For security check
|
||||
#include "nsIDocument.h"
|
||||
|
||||
/**
|
||||
* A XUL template builder that serves as an outliner view, allowing
|
||||
* (pretty much) arbitrary RDF to be presented in an outliner.
|
||||
|
@ -604,13 +607,50 @@ nsXULOutlinerBuilder::SetOutliner(nsIOutlinerBoxObject* outliner)
|
|||
|
||||
LoadDataSources();
|
||||
|
||||
// So we can remember open state.
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mRoot->GetDocument(*getter_AddRefs(doc));
|
||||
NS_ASSERTION(doc, "element has no document");
|
||||
if (!doc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// Grab the doc's principal...
|
||||
nsCOMPtr<nsIPrincipal> docPrincipal;
|
||||
nsresult rv = doc->GetPrincipal(getter_AddRefs(docPrincipal));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRBool isTrusted = PR_FALSE;
|
||||
rv = IsSystemPrincipal(docPrincipal.get(), &isTrusted);
|
||||
if (NS_SUCCEEDED(rv) && isTrusted) {
|
||||
// Get the datasource we intend to use to remember open state.
|
||||
nsAutoString datasourceStr;
|
||||
mRoot->GetAttr(kNameSpaceID_None, nsXULAtoms::statedatasource, datasourceStr);
|
||||
|
||||
// since we are trusted, use the user specified datasource
|
||||
// if non specified, use localstore, which gives us
|
||||
// persistance across sessions
|
||||
if (datasourceStr.Length()) {
|
||||
gRDFService->GetDataSource(NS_ConvertUCS2toUTF8(datasourceStr).get(),
|
||||
getter_AddRefs(mPersistStateStore));
|
||||
}
|
||||
else {
|
||||
gRDFService->GetDataSource("rdf:local-store",
|
||||
getter_AddRefs(mPersistStateStore));
|
||||
}
|
||||
}
|
||||
|
||||
// Either no specific datasource was specified, or we failed
|
||||
// to get one because we are not trusted.
|
||||
//
|
||||
// XXX We should fix this so that if the document is
|
||||
// ``trusted'', we use the localstore.
|
||||
// XXX if it were possible to ``write an arbitrary datasource
|
||||
// back'', then we could also allow an untrusted document to
|
||||
// use a statedatasource from the same codebase.
|
||||
if (! mPersistStateStore) {
|
||||
mPersistStateStore =
|
||||
do_CreateInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource");
|
||||
}
|
||||
|
||||
NS_ASSERTION(mPersistStateStore, "failed to get a persistant state store");
|
||||
if (! mPersistStateStore)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -986,6 +1026,8 @@ nsXULOutlinerBuilder::ReplaceMatch(nsIRDFResource* aMember,
|
|||
// Use the persist store to remember if the container
|
||||
// is open or closed.
|
||||
PRBool open = PR_FALSE;
|
||||
|
||||
if (mPersistStateStore)
|
||||
mPersistStateStore->HasAssertion(container,
|
||||
nsXULContentUtils::NC_open,
|
||||
nsXULContentUtils::true_,
|
||||
|
|
|
@ -779,7 +779,11 @@ nsXULTemplateBuilder::LoadDataSources()
|
|||
rv = doc->GetPrincipal(getter_AddRefs(docPrincipal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (docPrincipal.get() == gSystemPrincipal) {
|
||||
PRBool isTrusted = PR_FALSE;
|
||||
rv = IsSystemPrincipal(docPrincipal.get(), &isTrusted);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (isTrusted) {
|
||||
// If we're a privileged (e.g., chrome) document, then add the
|
||||
// local store as the first data source in the db. Note that
|
||||
// we _might_ not be able to get a local store if we haven't
|
||||
|
@ -829,7 +833,7 @@ nsXULTemplateBuilder::LoadDataSources()
|
|||
// protocol) leaves uriStr unaltered.
|
||||
NS_MakeAbsoluteURI(uriStr, uriStr, docurl);
|
||||
|
||||
if (docPrincipal.get() != gSystemPrincipal) {
|
||||
if (!isTrusted) {
|
||||
// Our document is untrusted, so check to see if we can
|
||||
// load the datasource that they've asked for.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
@ -2391,3 +2395,13 @@ nsXULTemplateBuilder::CanSetProperty(const nsIID * iid, const PRUnichar *propert
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULTemplateBuilder::IsSystemPrincipal(nsIPrincipal *principal, PRBool *result)
|
||||
{
|
||||
if (!gSystemPrincipal)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
*result = (principal == gSystemPrincipal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -331,6 +331,9 @@ public:
|
|||
nsresult
|
||||
CheckContainer(nsIRDFResource* aTargetResource, PRBool* aIsContainer, PRBool* aIsEmpty);
|
||||
|
||||
nsresult
|
||||
IsSystemPrincipal(nsIPrincipal *principal, PRBool *result);
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
nsresult
|
||||
Log(const char* aOperation,
|
||||
|
|
|
@ -53,6 +53,9 @@
|
|||
#include "nsXULTemplateBuilder.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
// For security check
|
||||
#include "nsIDocument.h"
|
||||
|
||||
/**
|
||||
* A XUL template builder that serves as an outliner view, allowing
|
||||
* (pretty much) arbitrary RDF to be presented in an outliner.
|
||||
|
@ -604,13 +607,50 @@ nsXULOutlinerBuilder::SetOutliner(nsIOutlinerBoxObject* outliner)
|
|||
|
||||
LoadDataSources();
|
||||
|
||||
// So we can remember open state.
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mRoot->GetDocument(*getter_AddRefs(doc));
|
||||
NS_ASSERTION(doc, "element has no document");
|
||||
if (!doc)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// Grab the doc's principal...
|
||||
nsCOMPtr<nsIPrincipal> docPrincipal;
|
||||
nsresult rv = doc->GetPrincipal(getter_AddRefs(docPrincipal));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRBool isTrusted = PR_FALSE;
|
||||
rv = IsSystemPrincipal(docPrincipal.get(), &isTrusted);
|
||||
if (NS_SUCCEEDED(rv) && isTrusted) {
|
||||
// Get the datasource we intend to use to remember open state.
|
||||
nsAutoString datasourceStr;
|
||||
mRoot->GetAttr(kNameSpaceID_None, nsXULAtoms::statedatasource, datasourceStr);
|
||||
|
||||
// since we are trusted, use the user specified datasource
|
||||
// if non specified, use localstore, which gives us
|
||||
// persistance across sessions
|
||||
if (datasourceStr.Length()) {
|
||||
gRDFService->GetDataSource(NS_ConvertUCS2toUTF8(datasourceStr).get(),
|
||||
getter_AddRefs(mPersistStateStore));
|
||||
}
|
||||
else {
|
||||
gRDFService->GetDataSource("rdf:local-store",
|
||||
getter_AddRefs(mPersistStateStore));
|
||||
}
|
||||
}
|
||||
|
||||
// Either no specific datasource was specified, or we failed
|
||||
// to get one because we are not trusted.
|
||||
//
|
||||
// XXX We should fix this so that if the document is
|
||||
// ``trusted'', we use the localstore.
|
||||
// XXX if it were possible to ``write an arbitrary datasource
|
||||
// back'', then we could also allow an untrusted document to
|
||||
// use a statedatasource from the same codebase.
|
||||
if (! mPersistStateStore) {
|
||||
mPersistStateStore =
|
||||
do_CreateInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource");
|
||||
}
|
||||
|
||||
NS_ASSERTION(mPersistStateStore, "failed to get a persistant state store");
|
||||
if (! mPersistStateStore)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -986,6 +1026,8 @@ nsXULOutlinerBuilder::ReplaceMatch(nsIRDFResource* aMember,
|
|||
// Use the persist store to remember if the container
|
||||
// is open or closed.
|
||||
PRBool open = PR_FALSE;
|
||||
|
||||
if (mPersistStateStore)
|
||||
mPersistStateStore->HasAssertion(container,
|
||||
nsXULContentUtils::NC_open,
|
||||
nsXULContentUtils::true_,
|
||||
|
|
|
@ -143,7 +143,7 @@ interface nsIMsgIncomingServer : nsISupports {
|
|||
readonly attribute boolean serverRequiresPasswordForBiff;
|
||||
|
||||
/* this gets called when the server is expanded in the folder pane */
|
||||
void PerformExpand(in nsIMsgWindow aMsgWindow);
|
||||
void performExpand(in nsIMsgWindow aMsgWindow);
|
||||
|
||||
/* Write out all known folder data to panacea.dat */
|
||||
void WriteToFolderCache(in nsIMsgFolderCache folderCache);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
seltype="single">
|
||||
<outlinerbody flex="1"
|
||||
datasources="rdf:null"
|
||||
statedatasource="rdf:mailnewsfolders"
|
||||
ondraggesture="return BeginDragFolderOutliner(event);"
|
||||
onselect="FolderPaneSelectionChange();">
|
||||
<template>
|
||||
|
|
|
@ -52,7 +52,6 @@ var gBrandBundle;
|
|||
var datasourceContractIDPrefix = "@mozilla.org/rdf/datasource;1?name=";
|
||||
var accountManagerDSContractID = datasourceContractIDPrefix + "msgaccountmanager";
|
||||
var folderDSContractID = datasourceContractIDPrefix + "mailnewsfolders";
|
||||
var messageDSContractID = datasourceContractIDPrefix + "mailnewsmessages";
|
||||
|
||||
var accountManagerDataSource;
|
||||
var folderDataSource;
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
/* This is where functions related to the 3 pane window are kept */
|
||||
|
||||
const MSG_FOLDER_FLAG_ELIDED = 0x0010;
|
||||
|
||||
var showPerformance = false;
|
||||
|
||||
var gFolderOutliner;
|
||||
|
@ -450,7 +448,9 @@ function Create3PaneGlobals()
|
|||
{
|
||||
}
|
||||
|
||||
function OpenAndExpandElidedServers()
|
||||
// because the "open" state persists, we'll call
|
||||
// PerformExpand() for all servers that are open at startup.
|
||||
function PerformExpandForAllOpenServers()
|
||||
{
|
||||
var folderOutliner = GetFolderOutliner();
|
||||
var view = folderOutliner.outlinerBoxObject.view;
|
||||
|
@ -460,17 +460,18 @@ function OpenAndExpandElidedServers()
|
|||
{
|
||||
var folderResource = GetFolderResource(folderOutliner, i);
|
||||
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
var open = msgFolder.getFlag(MSG_FOLDER_FLAG_ELIDED)
|
||||
if (open)
|
||||
{
|
||||
view.toggleOpenState(i);
|
||||
var isServer = GetFolderAttribute(folderOutliner, folderResource, "IsServer");
|
||||
if (isServer == "true")
|
||||
{
|
||||
if (view.isContainerOpen(i))
|
||||
{
|
||||
var server = msgFolder.server;
|
||||
// Don't do this for imap servers. See bug #41943
|
||||
if (server.type != "imap")
|
||||
server.PerformExpand(msgWindow);
|
||||
{
|
||||
dump("perform expand #1" + msgFolder.URI + "\n");
|
||||
server.performExpand(msgWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -479,8 +480,6 @@ function OpenAndExpandElidedServers()
|
|||
|
||||
function loadStartFolder(initialUri)
|
||||
{
|
||||
OpenAndExpandElidedServers();
|
||||
|
||||
var folderOutliner = GetFolderOutliner();
|
||||
var defaultServer = null;
|
||||
var startFolderResource = null;
|
||||
|
@ -557,6 +556,10 @@ function loadStartFolder(initialUri)
|
|||
defaultServer.PerformBiff();
|
||||
}
|
||||
}
|
||||
|
||||
// because the "open" state persists, we'll call
|
||||
// PerformExpand() for all servers that are open at startup.
|
||||
PerformExpandForAllOpenServers();
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
|
@ -577,7 +580,7 @@ function OpenTwistyForServer(folderOutliner, server)
|
|||
if (folderIndex >= 0)
|
||||
{
|
||||
var isContainerOpen = folderOutliner.outlinerBoxObject.view.isContainerOpen(folderIndex);
|
||||
if (! isContainerOpen)
|
||||
if (!isContainerOpen)
|
||||
folderOutliner.outlinerBoxObject.view.toggleOpenState(folderIndex);
|
||||
}
|
||||
}
|
||||
|
@ -820,16 +823,13 @@ function FolderPaneOnClick(event)
|
|||
var folderResource = GetFolderResource(folderOutliner, row.value);
|
||||
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
|
||||
if (folderOutliner.outlinerBoxObject.view.isContainerOpen(row.value))
|
||||
msgFolder.clearFlag(MSG_FOLDER_FLAG_ELIDED);
|
||||
else
|
||||
if (!(folderOutliner.outlinerBoxObject.view.isContainerOpen(row.value)))
|
||||
{
|
||||
msgFolder.setFlag(MSG_FOLDER_FLAG_ELIDED);
|
||||
var isServer = GetFolderAttribute(folderOutliner, folderResource, "IsServer");
|
||||
if (isServer == "true")
|
||||
{
|
||||
var server = msgFolder.server;
|
||||
server.PerformExpand(msgWindow);
|
||||
server.performExpand(msgWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -861,13 +861,10 @@ function FolderPaneDoubleClick(folderIndex, event)
|
|||
|
||||
if (isServer == "true")
|
||||
{
|
||||
if (folderOutliner.outlinerBoxObject.view.isContainerOpen(folderIndex))
|
||||
msgFolder.clearFlag(MSG_FOLDER_FLAG_ELIDED);
|
||||
else
|
||||
if (!(folderOutliner.outlinerBoxObject.view.isContainerOpen(folderIndex)))
|
||||
{
|
||||
msgFolder.setFlag(MSG_FOLDER_FLAG_ELIDED);
|
||||
var server = msgFolder.server;
|
||||
server.PerformExpand(msgWindow);
|
||||
server.performExpand(msgWindow);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -167,7 +167,7 @@ function onSynchronizeClick(event)
|
|||
|
||||
if (GetFolderAttribute(gSynchronizeOutliner, folderResource, "IsServer") == "true") {
|
||||
var server = msgFolder.server;
|
||||
server.PerformExpand(gMsgWindow);
|
||||
server.performExpand(gMsgWindow);
|
||||
}
|
||||
else {
|
||||
var imapFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgImapMailFolder);
|
||||
|
|
|
@ -105,7 +105,7 @@ Rights Reserved.
|
|||
<vbox>
|
||||
<spring flex="1" />
|
||||
<button label="&openButton.label;" id="openButton" command="cmd_open" />
|
||||
<menubutton id="fileMessageButton" label="&fileButton.label;"
|
||||
<menubutton class="push" id="fileMessageButton" label="&fileButton.label;"
|
||||
observes="file_message_button"
|
||||
oncommand="MoveMessageInSearch(event.target)"
|
||||
datasources="rdf:msgaccountmanager rdf:mailnewsfolders"
|
||||
|
|
|
@ -54,6 +54,7 @@ static NS_DEFINE_CID(kMsgCopyServiceCID, NS_MSGCOPYSERVICE_CID);
|
|||
nsIRDFResource* nsMsgFolderDataSource::kNC_Child = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Folder= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Name= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Open = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_FolderTreeName= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_FolderTreeSimpleName= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_NameSort= nsnull;
|
||||
|
@ -105,7 +106,7 @@ nsIAtom * nsMsgFolderDataSource::kTotalMessagesAtom = nsnull;
|
|||
nsIAtom * nsMsgFolderDataSource::kTotalUnreadMessagesAtom = nsnull;
|
||||
nsIAtom * nsMsgFolderDataSource::kNameAtom = nsnull;
|
||||
nsIAtom * nsMsgFolderDataSource::kSynchronizeAtom = nsnull;
|
||||
|
||||
nsIAtom * nsMsgFolderDataSource::kOpenAtom = nsnull;
|
||||
|
||||
nsMsgFolderDataSource::nsMsgFolderDataSource()
|
||||
{
|
||||
|
@ -116,6 +117,7 @@ nsMsgFolderDataSource::nsMsgFolderDataSource()
|
|||
rdf->GetResource(NC_RDF_CHILD, &kNC_Child);
|
||||
rdf->GetResource(NC_RDF_FOLDER, &kNC_Folder);
|
||||
rdf->GetResource(NC_RDF_NAME, &kNC_Name);
|
||||
rdf->GetResource(NC_RDF_OPEN, &kNC_Open);
|
||||
rdf->GetResource(NC_RDF_FOLDERTREENAME, &kNC_FolderTreeName);
|
||||
rdf->GetResource(NC_RDF_FOLDERTREESIMPLENAME, &kNC_FolderTreeSimpleName);
|
||||
rdf->GetResource(NC_RDF_NAME_SORT, &kNC_NameSort);
|
||||
|
@ -166,6 +168,7 @@ nsMsgFolderDataSource::nsMsgFolderDataSource()
|
|||
kNewMessagesAtom = NS_NewAtom("NewMessages");
|
||||
kNameAtom = NS_NewAtom("Name");
|
||||
kSynchronizeAtom = NS_NewAtom("Synchronize");
|
||||
kOpenAtom = NS_NewAtom("open");
|
||||
}
|
||||
|
||||
CreateLiterals(rdf);
|
||||
|
@ -181,6 +184,7 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
|||
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);
|
||||
|
@ -230,6 +234,7 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
|||
NS_RELEASE(kNewMessagesAtom);
|
||||
NS_RELEASE(kNameAtom);
|
||||
NS_RELEASE(kSynchronizeAtom);
|
||||
NS_RELEASE(kOpenAtom);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -411,6 +416,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
|
|||
}
|
||||
}
|
||||
else if ((kNC_Name == property) ||
|
||||
(kNC_Open == property) ||
|
||||
(kNC_FolderTreeName == property) ||
|
||||
(kNC_FolderTreeSimpleName == property) ||
|
||||
(kNC_SpecialFolder == property) ||
|
||||
|
@ -465,7 +471,10 @@ NS_IMETHODIMP nsMsgFolderDataSource::Unassert(nsIRDFResource* source,
|
|||
nsIRDFResource* property,
|
||||
nsIRDFNode* target)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(source, &rv));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
return DoFolderUnassert(folder, property, target);
|
||||
}
|
||||
|
||||
|
||||
|
@ -502,6 +511,7 @@ nsMsgFolderDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc,
|
|||
nsCOMPtr<nsIMsgFolder> 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 ||
|
||||
|
@ -565,6 +575,7 @@ nsMsgFolderDataSource::getFolderArcLabelsOut(nsISupportsArray **arcs)
|
|||
return rv;
|
||||
|
||||
(*arcs)->AppendElement(kNC_Name);
|
||||
(*arcs)->AppendElement(kNC_Open);
|
||||
(*arcs)->AppendElement(kNC_FolderTreeName);
|
||||
(*arcs)->AppendElement(kNC_FolderTreeSimpleName);
|
||||
(*arcs)->AppendElement(kNC_SpecialFolder);
|
||||
|
@ -893,6 +904,9 @@ nsMsgFolderDataSource::OnItemBoolPropertyChanged(nsISupports *item,
|
|||
else if (kSynchronizeAtom == property) {
|
||||
NotifyPropertyChanged(resource, kNC_Synchronize, literalNode);
|
||||
}
|
||||
else if (kOpenAtom == property) {
|
||||
NotifyPropertyChanged(resource, kNC_Open, literalNode);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -956,6 +970,8 @@ nsresult nsMsgFolderDataSource::createFolderNode(nsIMsgFolder* folder,
|
|||
rv = createFolderTreeSimpleNameNode(folder, target, PR_TRUE);
|
||||
else if (kNC_Name == property)
|
||||
rv = createFolderNameNode(folder, target, PR_FALSE);
|
||||
else if(kNC_Open == property)
|
||||
rv = createFolderOpenNode(folder, target);
|
||||
else if (kNC_FolderTreeName == property)
|
||||
rv = createFolderTreeNameNode(folder, target, PR_FALSE);
|
||||
else if (kNC_FolderTreeSimpleName == property)
|
||||
|
@ -1277,6 +1293,32 @@ nsMsgFolderDataSource::createFolderSyncDisabledNode(nsIMsgFolder* folder,
|
|||
}
|
||||
|
||||
|
||||
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<nsIEnumerator> subFolders;
|
||||
nsresult rv = folder->GetSubFolders(getter_AddRefs(subFolders));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_RDF_NO_VALUE;
|
||||
|
||||
PRBool closed;
|
||||
rv = folder->GetFlag(MSG_FOLDER_FLAG_ELIDED, &closed);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (closed)
|
||||
*target = kFalseLiteral;
|
||||
else
|
||||
*target = kTrueLiteral;
|
||||
|
||||
NS_IF_ADDREF(*target);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgFolderDataSource::createFolderIsSecureNode(nsIMsgFolder* folder,
|
||||
nsIRDFNode **target)
|
||||
|
@ -1905,11 +1947,27 @@ nsresult nsMsgFolderDataSource::DoFolderAssert(nsIMsgFolder *folder, nsIRDFResou
|
|||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
else if ((kNC_Open == property))
|
||||
{
|
||||
if (target == kTrueLiteral)
|
||||
rv = folder->ClearFlag(MSG_FOLDER_FLAG_ELIDED);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMsgFolderDataSource::DoFolderUnassert(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if((kNC_Open == property))
|
||||
{
|
||||
if (target == kTrueLiteral)
|
||||
rv = folder->SetFlag(MSG_FOLDER_FLAG_ELIDED);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder,
|
||||
nsIRDFResource *property,
|
||||
|
@ -1941,6 +1999,7 @@ nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder,
|
|||
}
|
||||
}
|
||||
else if ((kNC_Name == property) ||
|
||||
(kNC_Open == property) ||
|
||||
(kNC_FolderTreeName == property) ||
|
||||
(kNC_FolderTreeSimpleName == property) ||
|
||||
(kNC_SpecialFolder == property) ||
|
||||
|
|
|
@ -112,6 +112,7 @@ protected:
|
|||
nsresult createFolderNode(nsIMsgFolder *folder, nsIRDFResource* property,
|
||||
nsIRDFNode **target);
|
||||
nsresult createFolderNameNode(nsIMsgFolder *folder, nsIRDFNode **target, PRBool sort);
|
||||
nsresult createFolderOpenNode(nsIMsgFolder *folder,nsIRDFNode **target);
|
||||
nsresult createFolderTreeNameNode(nsIMsgFolder *folder, nsIRDFNode **target, PRBool sort);
|
||||
nsresult createFolderTreeSimpleNameNode(nsIMsgFolder *folder, nsIRDFNode **target, PRBool sort);
|
||||
nsresult createFolderSpecialNode(nsIMsgFolder *folder, nsIRDFNode **target);
|
||||
|
@ -166,6 +167,7 @@ protected:
|
|||
nsISupportsArray *arguments);
|
||||
|
||||
nsresult DoFolderAssert(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target);
|
||||
nsresult DoFolderUnassert(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target);
|
||||
|
||||
nsresult DoFolderHasAssertion(nsIMsgFolder *folder, nsIRDFResource *property, nsIRDFNode *target,
|
||||
PRBool tv, PRBool *hasAssertion);
|
||||
|
@ -193,6 +195,7 @@ protected:
|
|||
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;
|
||||
|
@ -249,6 +252,7 @@ protected:
|
|||
static nsIAtom* kNewMessagesAtom;
|
||||
static nsIAtom* kNameAtom;
|
||||
static nsIAtom* kSynchronizeAtom;
|
||||
static nsIAtom* kOpenAtom;
|
||||
|
||||
static nsrefcnt gFolderResourceRefCnt;
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ typedef struct _nsMsgRDFNotification {
|
|||
|
||||
#define NC_RDF_CHILD NC_NAMESPACE_URI "child"
|
||||
#define NC_RDF_NAME NC_NAMESPACE_URI "Name"
|
||||
#define NC_RDF_OPEN NC_NAMESPACE_URI "open"
|
||||
#define NC_RDF_FOLDERTREENAME NC_NAMESPACE_URI "FolderTreeName"
|
||||
#define NC_RDF_FOLDERTREESIMPLENAME NC_NAMESPACE_URI "FolderTreeSimpleName"
|
||||
#define NC_RDF_FOLDER NC_NAMESPACE_URI "Folder"
|
||||
|
|
|
@ -84,6 +84,7 @@ nsIAtom * nsMsgFolder::kFlaggedAtom = nsnull;
|
|||
nsIAtom * nsMsgFolder::kStatusAtom = nsnull;
|
||||
nsIAtom * nsMsgFolder::kNameAtom = nsnull;
|
||||
nsIAtom * nsMsgFolder::kSynchronizeAtom = nsnull;
|
||||
nsIAtom * nsMsgFolder::kOpenAtom = nsnull;
|
||||
|
||||
#ifdef MSG_FASTER_URI_PARSING
|
||||
nsCOMPtr<nsIURL> nsMsgFolder::mParsingURL;
|
||||
|
@ -128,6 +129,7 @@ nsMsgFolder::nsMsgFolder(void)
|
|||
kStatusAtom = NS_NewAtom("Status");
|
||||
kFlaggedAtom = NS_NewAtom("Flagged");
|
||||
kSynchronizeAtom = NS_NewAtom("Synchronize");
|
||||
kOpenAtom = NS_NewAtom("open");
|
||||
|
||||
initializeStrings();
|
||||
|
||||
|
@ -169,6 +171,7 @@ nsMsgFolder::~nsMsgFolder(void)
|
|||
NS_IF_RELEASE(kStatusAtom);
|
||||
NS_IF_RELEASE(kNameAtom);
|
||||
NS_IF_RELEASE(kSynchronizeAtom);
|
||||
NS_IF_RELEASE(kOpenAtom);
|
||||
|
||||
CRTFREEIF(kInboxName);
|
||||
CRTFREEIF(kTrashName);
|
||||
|
@ -1597,6 +1600,11 @@ NS_IMETHODIMP nsMsgFolder::OnFlagChange(PRUint32 flag)
|
|||
rv = NotifyBoolPropertyChanged(kSynchronizeAtom, !newValue, newValue);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
else if (flag & MSG_FOLDER_FLAG_ELIDED) {
|
||||
PRBool newValue = mFlags & MSG_FOLDER_FLAG_ELIDED;
|
||||
rv = NotifyBoolPropertyChanged(kOpenAtom, newValue, !newValue);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
}
|
||||
folderInfo = nsnull;
|
||||
return rv;
|
||||
|
|
|
@ -296,6 +296,7 @@ protected:
|
|||
static nsIAtom* kFlaggedAtom;
|
||||
static nsIAtom* kNameAtom;
|
||||
static nsIAtom* kSynchronizeAtom;
|
||||
static nsIAtom* kOpenAtom;
|
||||
|
||||
#ifdef MSG_FASTER_URI_PARSING
|
||||
// cached parsing URL object
|
||||
|
|
Загрузка…
Ссылка в новой задаче