зеркало из https://github.com/mozilla/gecko-dev.git
64751, 64753. sr =sspitzer, bienvenu. Adding Compact Folders feature to file_menu and Compact This Folder when
you right click on a folder. thanks to sspitzer and bienvenu for good review. Thanks to david for providing nsMsgFolder::ListDescendents function and all the help.
This commit is contained in:
Родитель
e0c2c3974f
Коммит
85c4d363cc
|
@ -23,6 +23,8 @@
|
|||
#include "nsICollection.idl"
|
||||
#include "nsIFolderListener.idl"
|
||||
|
||||
interface nsISupportsArray;
|
||||
|
||||
[scriptable, uuid(75621650-0fce-11d3-8b49-006008948010)]
|
||||
interface nsIFolder : nsICollection {
|
||||
|
||||
|
@ -66,7 +68,8 @@ interface nsIFolder : nsICollection {
|
|||
// void NotifyFolderLoaded();
|
||||
// void NotifyDeleteOrMoveMessagesCompleted(in nsIFolder folder);
|
||||
|
||||
|
||||
// lists all descendents, not just first level children
|
||||
void ListDescendents(in nsISupportsArray descendents);
|
||||
void Shutdown(in boolean shutdownChildren);
|
||||
};
|
||||
|
||||
|
|
|
@ -70,7 +70,8 @@ interface nsIMessenger : nsISupports {
|
|||
void RenameFolder(in nsIRDFCompositeDataSource db,
|
||||
in nsIRDFResource folder, in wstring name);
|
||||
void CompactFolder(in nsIRDFCompositeDataSource db,
|
||||
in nsIRDFResource folder);
|
||||
in nsIRDFResource folder,
|
||||
in boolean forAll);
|
||||
void EmptyTrash(in nsIRDFCompositeDataSource db,
|
||||
in nsIRDFResource folder);
|
||||
|
||||
|
|
|
@ -126,6 +126,8 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
|
|||
*/
|
||||
readonly attribute boolean canRename;
|
||||
|
||||
readonly attribute boolean canCompact;
|
||||
|
||||
/**
|
||||
* the phantom server folder
|
||||
*/
|
||||
|
@ -151,6 +153,7 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
|
|||
void createStorageIfMissing(in nsIUrlListener urlListener);
|
||||
|
||||
void compact(in nsIUrlListener aListener);
|
||||
void compactAll(in nsIUrlListener aListener);
|
||||
void emptyTrash(in nsIMsgWindow aMsgWindow, in nsIUrlListener aListener);
|
||||
|
||||
/**
|
||||
|
@ -331,6 +334,8 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
|
|||
*/
|
||||
attribute nsIFileSpec path;
|
||||
|
||||
readonly attribute string baseMessageURI;
|
||||
|
||||
const nsMsgDispositionState nsMsgDispositionState_Replied = 0;
|
||||
const nsMsgDispositionState nsMsgDispositionState_Forwarded = 1;
|
||||
void addMessageDispositionState(in nsIMessage aMessage, in nsMsgDispositionState aDispositionFlag);
|
||||
|
|
|
@ -35,6 +35,7 @@ interface nsIMsgFolderCompactor : nsISupports
|
|||
{
|
||||
void Init(in nsIMsgFolder folder, in string baseMsgUri, in nsIMsgDatabase db,
|
||||
in nsIFileSpec pathSpec);
|
||||
void InitCompactAll(in nsIMsgFolder folder);
|
||||
// we probably want to add the ability to set an enumerator to determine which
|
||||
// messages to copy over in the compaction process.
|
||||
void StartCompacting();
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
NewMessages="rdf:http://home.netscape.com/NC-rdf#NewMessages"
|
||||
SubfoldersHaveUnreadMessages="rdf:http://home.netscape.com/NC-rdf#SubfoldersHaveUnreadMessages"
|
||||
CanRename="rdf:http://home.netscape.com/NC-rdf#CanRename"
|
||||
CanCompact="rdf:http://home.netscape.com/NC-rdf#CanCompact"
|
||||
CanCreateSubfolders="rdf:http://home.netscape.com/NC-rdf#CanCreateSubfolders"
|
||||
CanSubscribe="rdf:http://home.netscape.com/NC-rdf#CanSubscribe"
|
||||
CanFileMessages="rdf:http://home.netscape.com/NC-rdf#CanFileMessages"
|
||||
|
@ -74,6 +75,7 @@
|
|||
HasUnreadMessages="rdf:http://home.netscape.com/NC-rdf#HasUnreadMessages"
|
||||
SubfoldersHaveUnreadMessages="rdf:http://home.netscape.com/NC-rdf#SubfoldersHaveUnreadMessages"
|
||||
CanRename="rdf:http://home.netscape.com/NC-rdf#CanRename"
|
||||
CanCompact="rdf:http://home.netscape.com/NC-rdf#CanCompact"
|
||||
CanCreateSubfolders="rdf:http://home.netscape.com/NC-rdf#CanCreateSubfolders"
|
||||
CanSubscribe="rdf:http://home.netscape.com/NC-rdf#CanSubscribe"
|
||||
CanFileMessages="rdf:http://home.netscape.com/NC-rdf#CanFileMessages"
|
||||
|
|
|
@ -490,7 +490,7 @@ var DefaultController =
|
|||
MsgEmptyTrash();
|
||||
return;
|
||||
case "cmd_compactFolder":
|
||||
MsgCompactFolder();
|
||||
MsgCompactFolder(true);
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -191,6 +191,7 @@ function fillFolderPaneContextMenu()
|
|||
|
||||
SetupRenameMenuItem(targetFolder, numSelected, isServer, serverType, specialFolder);
|
||||
SetupRemoveMenuItem(targetFolder, numSelected, isServer, serverType, specialFolder);
|
||||
SetupCompactMenuItem(targetFolder, numSelected, isServer, serverType);
|
||||
|
||||
ShowMenuItem("folderPaneContext-emptyTrash", (numSelected <= 1) && (specialFolder == 'Trash'));
|
||||
EnableMenuItem("folderPaneContext-emptyTrash", true);
|
||||
|
@ -252,6 +253,18 @@ function SetupRemoveMenuItem(targetFolder, numSelected, isServer, serverType, sp
|
|||
}
|
||||
}
|
||||
|
||||
function SetupCompactMenuItem(targetFolder, numSelected)
|
||||
{
|
||||
var canCompact = (targetFolder.getAttribute('CanCompact') == "true");
|
||||
ShowMenuItem("folderPaneContext-compact", (numSelected <=1) && canCompact);
|
||||
EnableMenuItem("folderPaneContext-compact", true );
|
||||
|
||||
if(canCompact)
|
||||
{
|
||||
SetMenuItemValue("folderPaneContext-compact", Bundle.GetStringFromName("compactFolder"));
|
||||
}
|
||||
}
|
||||
|
||||
function SetupNewMenuItem(targetFolder, numSelected, isServer, serverType, specialFolder)
|
||||
{
|
||||
var canCreateNew = targetFolder.getAttribute('CanCreateSubfolders') == 'true';
|
||||
|
|
|
@ -940,7 +940,18 @@ function IsEmptyTrashEnabled()
|
|||
|
||||
function IsCompactFolderEnabled()
|
||||
{
|
||||
return IsMailFolderSelected();
|
||||
var folderTree = GetFolderTree();
|
||||
var selectedFolders = folderTree.selectedItems;
|
||||
var numFolders = selectedFolders.length;
|
||||
|
||||
if (numFolders <= 0 )
|
||||
return false;
|
||||
|
||||
var folder = selectedFolders[0];
|
||||
if (!folder)
|
||||
return false;
|
||||
|
||||
return (folder.getAttribute('CanCompact') == "true");
|
||||
}
|
||||
|
||||
var gDeleteButton = null;
|
||||
|
|
|
@ -122,7 +122,7 @@ Rights Reserved.
|
|||
<broadcaster id="cmd_markAsFlagged" oncommand="goDoCommand('cmd_markAsFlagged'); event.preventBubble()" disabled="true"/>
|
||||
<broadcaster id="cmd_file" disabled="true"/>
|
||||
<broadcaster id="cmd_emptyTrash" oncommand="goDoCommand('cmd_emptyTrash')" disabled="true"/>
|
||||
<broadcaster id="cmd_compactFolder" oncommand="goDoCommand('cmd_compactFolder')" disabled="true"/>
|
||||
<broadcaster id="cmd_compactFolder" oncommand="goDoCommand('cmd_compactFolder')" disabled="true"/>
|
||||
<broadcaster id="cmd_workOffline" oncommand="goDoCommand('cmd_workOffline')" disabled="true"/>
|
||||
<broadcaster id="cmd_synchronizeOffline" oncommand="goDoCommand('cmd_synchronizeOffline')" disabled="true"/>
|
||||
<broadcaster id="cmd_downloadFlagged" oncommand="goDoCommand('cmd_downloadFlagged')" disabled="true"/>
|
||||
|
@ -387,6 +387,10 @@ Rights Reserved.
|
|||
value="&folderContextRename.label;"
|
||||
accesskey="&folderContextRename.accesskey;"
|
||||
oncommand="MsgRenameFolder();"/>
|
||||
<menuitem id="folderPaneContext-compact"
|
||||
value="&folderContextCompact.label;"
|
||||
accesskey="&folderContextCompact.accesskey;"
|
||||
oncommand="MsgCompactFolder(false);"/> //for one folder only
|
||||
<menuitem id="folderPaneContext-remove"
|
||||
value="&folderContextRemove.label;"
|
||||
accesskey="&folderContextRemove.accesskey;"
|
||||
|
@ -629,7 +633,7 @@ Rights Reserved.
|
|||
|
||||
<menubar id="mailMenubar">
|
||||
<menu id="menu_File">
|
||||
<menupopup id="menu_FilePopup" oncreate="file_init();">
|
||||
<menupopup id="menu_FilePopup" oncreate="file_init();">
|
||||
<menuitem value="&newMsgCmd.label;"
|
||||
accesskey="&newMsgCmd.accesskey;"
|
||||
key="key_newMessage"
|
||||
|
@ -709,7 +713,7 @@ Rights Reserved.
|
|||
<menuitem id="menu_emptyTrash" value="&emptyTrashCmd.label;"
|
||||
accesskey="&emptyTrashCmd.accesskey;"
|
||||
observes="cmd_emptyTrash"/>
|
||||
<menuitem id="menu_compactFolder" value="&compactFolder.label;" accesskey="&compactFolder.accesskey;" observes="cmd_compactFolder"/>
|
||||
<menuitem id="menu_compactFolder" value="&compactFolders.label;" accesskey="&compactFolder.accesskey;" observes="cmd_compactFolder"/>
|
||||
<menuseparator id="trashMenuSeparator"/>
|
||||
<menuitem value="&importCmd.label;" accesskey="&importCmd.accesskey;" oncommand="toImport();"/>
|
||||
<menuseparator/>
|
||||
|
|
|
@ -168,7 +168,7 @@ function MsgEmptyTrash()
|
|||
}
|
||||
}
|
||||
|
||||
function MsgCompactFolder()
|
||||
function MsgCompactFolder(isAll)
|
||||
{
|
||||
//get the selected elements
|
||||
var tree = GetFolderTree();
|
||||
|
@ -209,7 +209,7 @@ function MsgCompactFolder()
|
|||
dump("folder = " + folder.localName + "\n");
|
||||
try
|
||||
{
|
||||
messenger.CompactFolder(tree.database, folder.resource);
|
||||
messenger.CompactFolder(tree.database, folder.resource, isAll);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
|
|
|
@ -58,7 +58,7 @@ Rights Reserved.
|
|||
<!ENTITY subscribeCmd.accesskey "b">
|
||||
<!ENTITY renameFolder.label "Rename Folder...">
|
||||
<!ENTITY renameFolder.accesskey "r">
|
||||
<!ENTITY compactFolder.label "Compact This Folder">
|
||||
<!ENTITY compactFolders.label "Compact Folders">
|
||||
<!ENTITY compactFolder.accesskey "t">
|
||||
<!ENTITY emptyTrashCmd.label "Empty Trash">
|
||||
<!ENTITY emptyTrashCmd.accesskey "y">
|
||||
|
@ -428,6 +428,8 @@ Rights Reserved.
|
|||
<!ENTITY folderContextRename.accesskey "r">
|
||||
<!ENTITY folderContextRemove.label "Delete">
|
||||
<!ENTITY folderContextRemove.accesskey "d">
|
||||
<!ENTITY folderContextCompact.label "Compact This Folder">
|
||||
<!ENTITY folderContextCompact.accesskey "t">
|
||||
<!ENTITY folderContextEmptyTrash.label "Empty Trash Can">
|
||||
<!ENTITY folderContextEmptyTrash.accesskey "y">
|
||||
<!ENTITY folderContextSendUnsentMessages.label "Send Unsent Messages...">
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
renameAccount=Rename Account...
|
||||
renameNewsAccount=Rename News Account...
|
||||
renameFolder=Rename Folder...
|
||||
compactFolder=Compact This Folder
|
||||
removeAccount=Delete Account...
|
||||
removeNewsAccount=Delete News Account...
|
||||
removeFolder=Delete Folder...
|
||||
|
|
|
@ -1164,7 +1164,7 @@ nsMessenger::RenameFolder(nsIRDFCompositeDataSource* db,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::CompactFolder(nsIRDFCompositeDataSource* db,
|
||||
nsIRDFResource* folderResource)
|
||||
nsIRDFResource* folderResource, PRBool forAll)
|
||||
{
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
@ -1174,7 +1174,7 @@ nsMessenger::CompactFolder(nsIRDFCompositeDataSource* db,
|
|||
rv = NS_NewISupportsArray(getter_AddRefs(folderArray));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
folderArray->AppendElement(folderResource);
|
||||
rv = DoCommand(db, NC_RDF_COMPACT, folderArray, nsnull);
|
||||
rv = DoCommand(db, forAll ? NC_RDF_COMPACTALL : NC_RDF_COMPACT, folderArray, nsnull);
|
||||
if (NS_SUCCEEDED(rv) && mTxnMgr)
|
||||
mTxnMgr->Clear();
|
||||
return rv;
|
||||
|
|
|
@ -54,6 +54,8 @@ nsFolderCompactState::nsFolderCompactState()
|
|||
m_curIndex = -1;
|
||||
m_status = NS_OK;
|
||||
m_messageService = nsnull;
|
||||
m_compactAll = PR_FALSE;
|
||||
m_folderIndex =0;
|
||||
}
|
||||
|
||||
nsFolderCompactState::~nsFolderCompactState()
|
||||
|
@ -128,6 +130,85 @@ nsFolderCompactState::InitDB(nsIMsgDatabase *db)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFolderCompactState::InitCompactAll(nsIMsgFolder *folder)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMsgFolder> rootFolder;
|
||||
nsCOMPtr<nsISupportsArray> allDescendents;
|
||||
folder->GetRootFolder(getter_AddRefs(rootFolder));
|
||||
NS_NewISupportsArray(getter_AddRefs(allDescendents));
|
||||
rootFolder->ListDescendents(allDescendents);
|
||||
PRUint32 cnt =0;
|
||||
rv = allDescendents->Count(&cnt);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
NS_NewISupportsArray(getter_AddRefs(m_folderArray));
|
||||
PRUint32 expungedBytes=0;
|
||||
for (PRUint32 i=0; i< cnt;i++)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports = getter_AddRefs(allDescendents->ElementAt(i));
|
||||
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
expungedBytes=0;
|
||||
if (folder)
|
||||
rv = folder->GetExpungedBytes(&expungedBytes);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
if (expungedBytes > 0)
|
||||
rv = m_folderArray->AppendElement(supports);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
rv = m_folderArray->Count(&cnt);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if ( cnt == 0)
|
||||
return rv; //no folders to compact
|
||||
else
|
||||
m_compactAll = PR_TRUE;
|
||||
|
||||
m_folderIndex = 0;
|
||||
nsCOMPtr<nsISupports> supports = getter_AddRefs(m_folderArray->ElementAt(m_folderIndex));
|
||||
nsCOMPtr<nsIMsgFolder> firstFolder = do_QueryInterface(supports, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && firstFolder)
|
||||
CompactHelper(firstFolder); //start with first folder from here.
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFolderCompactState::CompactHelper(nsIMsgFolder *folder)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIMsgDatabase> db;
|
||||
nsCOMPtr<nsIDBFolderInfo> folderInfo;
|
||||
nsCOMPtr<nsIMsgDatabase> mailDBFactory;
|
||||
nsresult folderOpen = NS_OK;
|
||||
nsCOMPtr<nsIFileSpec> pathSpec;
|
||||
char *baseMessageURI;
|
||||
|
||||
rv = folder->GetMsgDatabase(nsnull, getter_AddRefs(db));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = folder->GetPath(getter_AddRefs(pathSpec));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = folder->GetBaseMessageURI(&baseMessageURI);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = Init(folder, baseMessageURI, db, pathSpec);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = StartCompacting();
|
||||
|
||||
if (baseMessageURI)
|
||||
nsCRT::free(baseMessageURI);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFolderCompactState::Init(nsIMsgFolder *folder, const char *baseMsgUri, nsIMsgDatabase *db,
|
||||
nsIFileSpec *pathSpec)
|
||||
|
@ -197,10 +278,8 @@ nsFolderCompactState::FinishCompact()
|
|||
nsCOMPtr<nsIMsgFolder> parentFolder;
|
||||
nsCOMPtr<nsIDBFolderInfo> folderInfo;
|
||||
nsFileSpec fileSpec;
|
||||
PRUint32 flags;
|
||||
|
||||
// get leaf name and database name of the folder
|
||||
m_folder->GetFlags(&flags);
|
||||
rv = m_folder->GetPath(getter_AddRefs(pathSpec));
|
||||
pathSpec->GetFileSpec(&fileSpec);
|
||||
|
||||
|
@ -229,7 +308,6 @@ nsFolderCompactState::FinishCompact()
|
|||
// close down database of the original folder and remove the folder node
|
||||
// and all it's message node from the tree
|
||||
m_folder->ForceDBClosed();
|
||||
|
||||
// remove the old folder and database
|
||||
fileSpec.Delete(PR_FALSE);
|
||||
summarySpec.Delete(PR_FALSE);
|
||||
|
@ -238,6 +316,22 @@ nsFolderCompactState::FinishCompact()
|
|||
m_fileSpec.Rename((const char*) idlName);
|
||||
newSummarySpec.Rename(dbName);
|
||||
|
||||
if (m_compactAll)
|
||||
{
|
||||
m_folderIndex++;
|
||||
PRUint32 cnt=0;
|
||||
rv = m_folderArray->Count(&cnt);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (m_folderIndex == cnt)
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsISupports> supports = getter_AddRefs(m_folderArray->ElementAt(m_folderIndex));
|
||||
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && folder)
|
||||
CompactHelper(folder);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
// nsIFileSpec *pathSpec);
|
||||
// virtual nsresult FinishCompact();
|
||||
virtual nsresult InitDB(nsIMsgDatabase *db);
|
||||
nsresult CompactHelper(nsIMsgFolder *folder);
|
||||
|
||||
nsresult GetMessage(nsIMessage **message);
|
||||
nsresult BuildMessageURI(const char *baseURI, PRUint32 key, nsCString& uri);
|
||||
|
@ -62,6 +63,10 @@ public:
|
|||
nsresult m_status; // the status of the copying operation
|
||||
nsIMsgMessageService* m_messageService; // message service for copying
|
||||
// message
|
||||
nsCOMPtr<nsISupportsArray> m_folderArray; // to store all the folders in case of compact all
|
||||
PRUint32 m_folderIndex; // tells which folder to compact in case of compact all
|
||||
PRBool m_compactAll; //flag for compact all
|
||||
|
||||
};
|
||||
|
||||
class nsOfflineStoreCompactState : public nsFolderCompactState
|
||||
|
|
|
@ -67,6 +67,7 @@ nsIRDFResource* nsMsgFolderDataSource::kNC_CanSubscribe = nsnull;
|
|||
nsIRDFResource* nsMsgFolderDataSource::kNC_CanFileMessages = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_CanCreateSubfolders = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_CanRename = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_CanCompact = nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalMessages= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_TotalUnreadMessages= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Charset = nsnull;
|
||||
|
@ -87,6 +88,7 @@ nsIRDFResource* nsMsgFolderDataSource::kNC_CopyFolder= nsnull;
|
|||
nsIRDFResource* nsMsgFolderDataSource::kNC_MoveFolder= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_MarkAllMessagesRead= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Compact= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_CompactAll= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_Rename= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_EmptyTrash= nsnull;
|
||||
nsIRDFResource* nsMsgFolderDataSource::kNC_DownloadFlagged= nsnull;
|
||||
|
@ -120,6 +122,7 @@ nsMsgFolderDataSource::nsMsgFolderDataSource()
|
|||
rdf->GetResource(NC_RDF_CANFILEMESSAGES, &kNC_CanFileMessages);
|
||||
rdf->GetResource(NC_RDF_CANCREATESUBFOLDERS, &kNC_CanCreateSubfolders);
|
||||
rdf->GetResource(NC_RDF_CANRENAME, &kNC_CanRename);
|
||||
rdf->GetResource(NC_RDF_CANCOMPACT, &kNC_CanCompact);
|
||||
rdf->GetResource(NC_RDF_TOTALMESSAGES, &kNC_TotalMessages);
|
||||
rdf->GetResource(NC_RDF_TOTALUNREADMESSAGES, &kNC_TotalUnreadMessages);
|
||||
rdf->GetResource(NC_RDF_CHARSET, &kNC_Charset);
|
||||
|
@ -140,6 +143,7 @@ nsMsgFolderDataSource::nsMsgFolderDataSource()
|
|||
rdf->GetResource(NC_RDF_MARKALLMESSAGESREAD,
|
||||
&kNC_MarkAllMessagesRead);
|
||||
rdf->GetResource(NC_RDF_COMPACT, &kNC_Compact);
|
||||
rdf->GetResource(NC_RDF_COMPACTALL, &kNC_CompactAll);
|
||||
rdf->GetResource(NC_RDF_RENAME, &kNC_Rename);
|
||||
rdf->GetResource(NC_RDF_EMPTYTRASH, &kNC_EmptyTrash);
|
||||
rdf->GetResource(NC_RDF_DOWNLOADFLAGGED, &kNC_DownloadFlagged);
|
||||
|
@ -176,6 +180,7 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
|||
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_Charset, refcnt);
|
||||
|
@ -195,6 +200,7 @@ nsMsgFolderDataSource::~nsMsgFolderDataSource (void)
|
|||
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_DownloadFlagged, refcnt);
|
||||
|
@ -392,6 +398,7 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
|
|||
(kNC_CanFileMessages == property) ||
|
||||
(kNC_CanCreateSubfolders == property) ||
|
||||
(kNC_CanRename == property) ||
|
||||
(kNC_CanCompact == property) ||
|
||||
(kNC_ServerType == property) ||
|
||||
(kNC_NoSelect == property) )
|
||||
{
|
||||
|
@ -477,6 +484,7 @@ nsMsgFolderDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc,
|
|||
aArc == kNC_CanFileMessages ||
|
||||
aArc == kNC_CanCreateSubfolders ||
|
||||
aArc == kNC_CanRename ||
|
||||
aArc == kNC_CanCompact ||
|
||||
aArc == kNC_TotalMessages ||
|
||||
aArc == kNC_TotalUnreadMessages ||
|
||||
aArc == kNC_Charset ||
|
||||
|
@ -533,6 +541,7 @@ nsMsgFolderDataSource::getFolderArcLabelsOut(nsISupportsArray **arcs)
|
|||
(*arcs)->AppendElement(kNC_CanFileMessages);
|
||||
(*arcs)->AppendElement(kNC_CanCreateSubfolders);
|
||||
(*arcs)->AppendElement(kNC_CanRename);
|
||||
(*arcs)->AppendElement(kNC_CanCompact);
|
||||
(*arcs)->AppendElement(kNC_TotalMessages);
|
||||
(*arcs)->AppendElement(kNC_TotalUnreadMessages);
|
||||
(*arcs)->AppendElement(kNC_Charset);
|
||||
|
@ -572,6 +581,7 @@ nsMsgFolderDataSource::GetAllCommands(nsIRDFResource* source,
|
|||
cmds->AppendElement(kNC_MoveFolder);
|
||||
cmds->AppendElement(kNC_MarkAllMessagesRead);
|
||||
cmds->AppendElement(kNC_Compact);
|
||||
cmds->AppendElement(kNC_CompactAll);
|
||||
cmds->AppendElement(kNC_Rename);
|
||||
cmds->AppendElement(kNC_EmptyTrash);
|
||||
cmds->AppendElement(kNC_DownloadFlagged);
|
||||
|
@ -617,6 +627,7 @@ nsMsgFolderDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aS
|
|||
(aCommand == kNC_GetNewMessages) ||
|
||||
(aCommand == kNC_MarkAllMessagesRead) ||
|
||||
(aCommand == kNC_Compact) ||
|
||||
(aCommand == kNC_CompactAll) ||
|
||||
(aCommand == kNC_Rename) ||
|
||||
(aCommand == kNC_EmptyTrash) ||
|
||||
(aCommand == kNC_DownloadFlagged) ))
|
||||
|
@ -690,6 +701,10 @@ nsMsgFolderDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
|
|||
{
|
||||
rv = folder->Compact(nsnull);
|
||||
}
|
||||
else if ((aCommand == kNC_CompactAll))
|
||||
{
|
||||
rv = folder->CompactAll(nsnull);
|
||||
}
|
||||
else if ((aCommand == kNC_EmptyTrash))
|
||||
{
|
||||
rv = folder->EmptyTrash(mWindow, nsnull);
|
||||
|
@ -908,6 +923,8 @@ nsresult nsMsgFolderDataSource::createFolderNode(nsIMsgFolder* folder,
|
|||
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))
|
||||
|
@ -1192,6 +1209,25 @@ nsMsgFolderDataSource::createFolderCanRenameNode(nsIMsgFolder* folder,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgFolderDataSource::createFolderCanCompactNode(nsIMsgFolder* folder,
|
||||
nsIRDFNode **target)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool canCompact;
|
||||
rv = folder->GetCanCompact(&canCompact);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*target = nsnull;
|
||||
|
||||
if (canCompact)
|
||||
*target = kTrueLiteral;
|
||||
else
|
||||
*target = kFalseLiteral;
|
||||
NS_IF_ADDREF(*target);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMsgFolderDataSource::createTotalMessagesNode(nsIMsgFolder *folder,
|
||||
|
@ -1724,6 +1760,7 @@ nsresult nsMsgFolderDataSource::DoFolderHasAssertion(nsIMsgFolder *folder,
|
|||
(kNC_CanFileMessages == property) ||
|
||||
(kNC_CanCreateSubfolders == property) ||
|
||||
(kNC_CanRename == property) ||
|
||||
(kNC_CanCompact == property) ||
|
||||
(kNC_TotalMessages == property) ||
|
||||
(kNC_TotalUnreadMessages == property) ||
|
||||
(kNC_Charset == property) ||
|
||||
|
|
|
@ -128,6 +128,8 @@ protected:
|
|||
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 createCharsetNode(nsIMsgFolder *folder, nsIRDFNode **target);
|
||||
|
@ -196,6 +198,7 @@ protected:
|
|||
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_Charset;
|
||||
|
@ -216,6 +219,7 @@ protected:
|
|||
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;
|
||||
|
|
|
@ -71,6 +71,7 @@ typedef struct _nsMsgRDFNotification {
|
|||
#define NC_RDF_CANFILEMESSAGES NC_NAMESPACE_URI "CanFileMessages"
|
||||
#define NC_RDF_CANCREATESUBFOLDERS NC_NAMESPACE_URI "CanCreateSubfolders"
|
||||
#define NC_RDF_CANRENAME NC_NAMESPACE_URI "CanRename"
|
||||
#define NC_RDF_CANCOMPACT NC_NAMESPACE_URI "CanCompact"
|
||||
#define NC_RDF_TOTALMESSAGES NC_NAMESPACE_URI "TotalMessages"
|
||||
#define NC_RDF_TOTALUNREADMESSAGES NC_NAMESPACE_URI "TotalUnreadMessages"
|
||||
#define NC_RDF_CHARSET NC_NAMESPACE_URI "Charset"
|
||||
|
@ -107,6 +108,7 @@ typedef struct _nsMsgRDFNotification {
|
|||
#define NC_RDF_MARKALLMESSAGESREAD NC_NAMESPACE_URI "MarkAllMessagesRead"
|
||||
#define NC_RDF_MARKTHREADREAD NC_NAMESPACE_URI "MarkThreadRead"
|
||||
#define NC_RDF_COMPACT NC_NAMESPACE_URI "Compact"
|
||||
#define NC_RDF_COMPACTALL NC_NAMESPACE_URI "CompactAll"
|
||||
#define NC_RDF_RENAME NC_NAMESPACE_URI "Rename"
|
||||
#define NC_RDF_EMPTYTRASH NC_NAMESPACE_URI "EmptyTrash"
|
||||
#define NC_RDF_DOWNLOADFLAGGED NC_NAMESPACE_URI "DownloadFlaggedMessages"
|
||||
|
|
|
@ -807,6 +807,17 @@ nsMsgFolder::GetCanRename(PRBool *aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolder::GetCanCompact(PRBool *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
PRBool isServer = PR_FALSE;
|
||||
nsresult rv = GetIsServer(&isServer);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
*aResult = !isServer; //servers cannot be compacted --> 4.x
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::GetPrettyName(PRUnichar ** name)
|
||||
|
@ -1178,6 +1189,12 @@ NS_IMETHODIMP nsMsgFolder::Compact(nsIUrlListener *aListener)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::CompactAll(nsIUrlListener *aListener)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "should be overridden by child class");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::EmptyTrash(nsIMsgWindow *msgWindow, nsIUrlListener *aListener)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -2489,4 +2506,41 @@ NS_IMETHODIMP nsMsgFolder::GetMessageHeader(nsMsgKey msgKey, nsIMsgDBHdr **aMsgH
|
|||
return rv;
|
||||
}
|
||||
|
||||
// this gets the deep sub-folders too, e.g., the children of the children
|
||||
NS_IMETHODIMP nsMsgFolder::ListDescendents(nsISupportsArray *descendents)
|
||||
{
|
||||
NS_ENSURE_ARG(descendents);
|
||||
PRUint32 cnt;
|
||||
nsresult rv = mSubFolders->Count(&cnt);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
for (PRUint32 index = 0; index < cnt; index++)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(index));
|
||||
nsCOMPtr<nsIMsgFolder> child(do_QueryInterface(supports, &rv));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = descendents->AppendElement(supports);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = child->ListDescendents(descendents); // recurse
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::GetBaseMessageURI(char **baseMessageURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(baseMessageURI);
|
||||
|
||||
if (mBaseMessageURI)
|
||||
{
|
||||
*baseMessageURI = nsCRT::strdup(mBaseMessageURI);
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ hasMessages);
|
|||
NS_IMETHOD GetCanFileMessages(PRBool *aCanFileMessages);
|
||||
NS_IMETHOD GetCanCreateSubfolders(PRBool *aCanCreateSubfolders);
|
||||
NS_IMETHOD GetCanRename(PRBool *aCanRename);
|
||||
NS_IMETHOD GetCanCompact(PRBool *aCanCompact);
|
||||
NS_IMETHOD GetFilterList(nsIMsgFilterList **aFilterList);
|
||||
NS_IMETHOD ForceDBClosed(void);
|
||||
NS_IMETHOD Delete(void);
|
||||
|
@ -99,6 +100,7 @@ hasMessages);
|
|||
NS_IMETHOD CreateSubfolder(const PRUnichar *folderName, nsIMsgWindow *msgWindow);
|
||||
NS_IMETHOD AddSubfolder(nsAutoString *folderName, nsIMsgFolder **newFolder);
|
||||
NS_IMETHOD Compact(nsIUrlListener *aListener);
|
||||
NS_IMETHOD CompactAll(nsIUrlListener *aListener);
|
||||
NS_IMETHOD EmptyTrash(nsIMsgWindow *msgWindow, nsIUrlListener *aListener);
|
||||
NS_IMETHOD Rename(const PRUnichar *name, nsIMsgWindow *msgWindow);
|
||||
NS_IMETHOD Adopt(nsIMsgFolder *srcFolder, PRUint32 *outPos);
|
||||
|
@ -166,6 +168,7 @@ hasMessages);
|
|||
|
||||
NS_IMETHOD GetPath(nsIFileSpec * *aPath);
|
||||
NS_IMETHOD SetPath(nsIFileSpec * aPath);
|
||||
NS_IMETHOD GetBaseMessageURI (char ** baseMessageURI);
|
||||
NS_IMETHOD MarkMessagesRead(nsISupportsArray *messages, PRBool markRead);
|
||||
NS_IMETHOD AddMessageDispositionState(nsIMessage *aMessage, nsMsgDispositionState aDispositionFlag);
|
||||
NS_IMETHOD MarkAllMessagesRead(void);
|
||||
|
|
|
@ -1013,6 +1013,11 @@ NS_IMETHODIMP nsImapMailFolder::Compact(nsIUrlListener *aListener)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::CompactAll(nsIUrlListener *aListener)
|
||||
{
|
||||
return Compact(aListener); //for now
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *msgWindow,
|
||||
nsIUrlListener *aListener)
|
||||
{
|
||||
|
|
|
@ -126,6 +126,7 @@ public:
|
|||
NS_IMETHODIMP CreateStorageIfMissing(nsIUrlListener* urlListener);
|
||||
|
||||
NS_IMETHOD Compact(nsIUrlListener *aListener);
|
||||
NS_IMETHOD CompactAll(nsIUrlListener *aListener);
|
||||
NS_IMETHOD EmptyTrash(nsIMsgWindow *msgWindow, nsIUrlListener *aListener);
|
||||
NS_IMETHOD Delete ();
|
||||
NS_IMETHOD Rename (const PRUnichar *newName, nsIMsgWindow *msgWindow);
|
||||
|
|
|
@ -843,6 +843,17 @@ nsMsgLocalMailFolder::CreateSubfolder(const PRUnichar *folderName, nsIMsgWindow
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::CompactAll(nsIUrlListener *aListener)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIMsgFolderCompactor> folderCompactor = do_CreateInstance(NS_MSGLOCALFOLDERCOMPACTOR_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && folderCompactor)
|
||||
{
|
||||
rv=folderCompactor->InitCompactAll(this); // start with each folder compaction from there
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// **** jefft -- needs to provide nsIMsgWindow for the compact status
|
||||
// update; come back later
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::Compact(nsIUrlListener *aListener)
|
||||
|
|
|
@ -106,6 +106,7 @@ public:
|
|||
NS_IMETHOD AddSubfolder(nsAutoString *folderName, nsIMsgFolder** newFolder);
|
||||
|
||||
NS_IMETHOD Compact(nsIUrlListener *aListener);
|
||||
NS_IMETHOD CompactAll(nsIUrlListener *aListener);
|
||||
NS_IMETHOD EmptyTrash(nsIMsgWindow *msgWindow, nsIUrlListener *aListener);
|
||||
NS_IMETHOD Delete ();
|
||||
NS_IMETHOD DeleteSubFolders(nsISupportsArray *folders, nsIMsgWindow *msgWindow);
|
||||
|
|
|
@ -453,6 +453,15 @@ nsMsgNewsFolder::GetCanRename(PRBool *aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgNewsFolder::GetCanCompact(PRBool *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = PR_FALSE;
|
||||
// you can't compact a news server or a news group
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgNewsFolder::GetMessages(nsIMsgWindow *aMsgWindow, nsISimpleEnumerator* *result)
|
||||
{
|
||||
|
|
|
@ -92,6 +92,7 @@ public:
|
|||
NS_IMETHOD GetCanFileMessages(PRBool *aResult);
|
||||
NS_IMETHOD GetCanCreateSubfolders(PRBool *aResult);
|
||||
NS_IMETHOD GetCanRename(PRBool *aResult);
|
||||
NS_IMETHOD GetCanCompact(PRBool *aResult);
|
||||
NS_IMETHOD OnReadChanged(nsIDBChangeListener * aInstigator);
|
||||
|
||||
NS_IMETHOD Compact(nsIUrlListener *aListener);
|
||||
|
|
Загрузка…
Ссылка в новой задаче