fix 255326 isSpecialFolder returns true for all sub-folders of inbox - it shouldn't, sr=mscott

This commit is contained in:
bienvenu%nventure.com 2004-08-19 16:27:00 +00:00
parent 92a261b558
commit d4b620f2a2
10 changed files with 34 additions and 48 deletions

View File

@ -20,7 +20,7 @@
# Contributors(s):
# Jan Varga <varga@nixcorp.com>
# Håkan Waara (hwaara@chello.se)
# David Bienvenu (bienvenu@netscape.com)
# David Bienvenu (bienvenu@nventure.com)
/*
* Command-specific code. This stuff should be called by the widgets
*/
@ -314,7 +314,7 @@ function RerootFolder(uri, newFolder, viewType, viewFlags, sortType, sortOrder)
// if this is the drafts, sent, or send later folder,
// we show "Recipient" instead of "Author"
SetSentFolderColumns(IsSpecialFolder(newFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE));
SetSentFolderColumns(IsSpecialFolder(newFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE, true));
// now create the db view, which will sort it.
CreateDBView(newFolder, viewType, viewFlags, sortType, sortOrder);
@ -325,9 +325,11 @@ function RerootFolder(uri, newFolder, viewType, viewFlags, sortType, sortOrder)
/*we don't null out the db reference for inbox because inbox is like the "main" folder
and performance outweighs footprint */
if (!IsSpecialFolder(oldFolder, MSG_FOLDER_FLAG_INBOX))
if (!IsSpecialFolder(oldFolder, MSG_FOLDER_FLAG_INBOX, false))
{
if (oldFolder.URI != newFolder.URI)
oldFolder.setMsgDatabase(null);
}
}
// that should have initialized gDBView, now re-root the thread pane
RerootThreadPane();
@ -812,30 +814,21 @@ function ClearThreadPane()
}
}
function IsSpecialFolder(msgFolder, flags)
function IsSpecialFolder(msgFolder, flags, checkAncestors)
{
if (!msgFolder) {
if (!msgFolder)
return false;
}
else if ((msgFolder.flags & flags) == 0) {
var parentMsgFolder = msgFolder.parentMsgFolder;
else if ((msgFolder.flags & flags) == 0)
{
var parentMsgFolder = msgFolder.parentMsgFolder;
if(!parentMsgFolder) {
return false;
}
return IsSpecialFolder(parentMsgFolder, flags);
return (parentMsgFolder && checkAncestors) ? IsSpecialFolder(parentMsgFolder, flags, true) : false;
}
else {
// the user can set their INBOX to be their SENT folder.
// in that case, we want this folder to act like an INBOX,
// and not a SENT folder
if ((flags & MSG_FOLDER_FLAG_SENTMAIL) && (msgFolder.flags & MSG_FOLDER_FLAG_INBOX)) {
return false;
}
else {
return true;
}
return !((flags & MSG_FOLDER_FLAG_SENTMAIL) && (msgFolder.flags & MSG_FOLDER_FLAG_INBOX));
}
}

View File

@ -93,7 +93,7 @@ function menu_new_init()
var isServer = msgFolder.isServer;
var serverType = msgFolder.server.type;
var canCreateNew = msgFolder.canCreateSubfolders;
var isInbox = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_INBOX);
var isInbox = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_INBOX, false);
var isIMAPFolder = serverType == "imap";
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);

View File

@ -22,6 +22,7 @@
# Håkan Waara (hwaara@chello.se)
# Neil Rashbrook (neil@parkwaycc.co.uk)
# Seth Spitzer <sspitzer@netscape.com>
# David Bienvenu <bienvenu@nventure.com>
/* This is where functions related to the 3 pane window are kept */
@ -152,7 +153,7 @@ var folderListener = {
gDBView.suppressCommandUpdating = false;
}
gIsEditableMsgFolder = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_DRAFTS);
gIsEditableMsgFolder = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_DRAFTS, true);
gCurrentLoadingFolderSortType = 0;
gCurrentLoadingFolderSortOrder = 0;

View File

@ -23,6 +23,7 @@
# Contributor(s):
# Seth Spitzer <sspitzer@netscape.com>
# Scott MacGregor <mscott@mozilla.org>
# David Bienvenu <bienvenu@nventure.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
@ -370,7 +371,7 @@ function createSearchTerms()
var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
var selectedFolder = GetThreadPaneFolder();
var searchAttrib = (IsSpecialFolder(selectedFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE)) ? nsMsgSearchAttrib.ToOrCC : nsMsgSearchAttrib.Sender;
var searchAttrib = (IsSpecialFolder(selectedFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE, true)) ? nsMsgSearchAttrib.ToOrCC : nsMsgSearchAttrib.Sender;
// implement | for QS
// does this break if the user types "foo|bar" expecting to see subjects with that string?
// I claim no, since "foo|bar" will be a hit for "foo" || "bar"

View File

@ -317,7 +317,7 @@ function RerootFolder(uri, newFolder, viewType, viewFlags, sortType, sortOrder)
// if this is the drafts, sent, or send later folder,
// we show "Recipient" instead of "Author"
SetSentFolderColumns(IsSpecialFolder(newFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE));
SetSentFolderColumns(IsSpecialFolder(newFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE, true));
// now create the db view, which will sort it.
CreateDBView(newFolder, viewType, viewFlags, sortType, sortOrder);
@ -328,7 +328,7 @@ function RerootFolder(uri, newFolder, viewType, viewFlags, sortType, sortOrder)
/*we don't null out the db reference for inbox because inbox is like the "main" folder
and performance outweighs footprint */
if (!IsSpecialFolder(oldFolder, MSG_FOLDER_FLAG_INBOX))
if (!IsSpecialFolder(oldFolder, MSG_FOLDER_FLAG_INBOX, false))
if (oldFolder.URI != newFolder.URI)
oldFolder.setMsgDatabase(null);
}
@ -825,30 +825,21 @@ function ClearThreadPane()
}
}
function IsSpecialFolder(msgFolder, flags)
function IsSpecialFolder(msgFolder, flags, checkAncestors)
{
if (!msgFolder) {
if (!msgFolder)
return false;
}
else if ((msgFolder.flags & flags) == 0) {
var parentMsgFolder = msgFolder.parentMsgFolder;
else if ((msgFolder.flags & flags) == 0)
{
var parentMsgFolder = msgFolder.parentMsgFolder;
if(!parentMsgFolder) {
return false;
}
return IsSpecialFolder(parentMsgFolder, flags);
return (parentMsgFolder && checkAncestors) ? IsSpecialFolder(parentMsgFolder, flags, true) : false;
}
else {
// the user can set their INBOX to be their SENT folder.
// in that case, we want this folder to act like an INBOX,
// and not a SENT folder
if ((flags & MSG_FOLDER_FLAG_SENTMAIL) && (msgFolder.flags & MSG_FOLDER_FLAG_INBOX)) {
return false;
}
else {
return true;
}
return !((flags & MSG_FOLDER_FLAG_SENTMAIL) && (msgFolder.flags & MSG_FOLDER_FLAG_INBOX));
}
}

View File

@ -99,7 +99,7 @@ function menu_new_init()
var isServer = msgFolder.isServer;
var serverType = msgFolder.server.type;
var canCreateNew = msgFolder.canCreateSubfolders;
var isInbox = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_INBOX);
var isInbox = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_INBOX, false);
var isIMAPFolder = serverType == "imap";
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);

View File

@ -158,7 +158,7 @@ var folderListener = {
if (gDBView)
gDBView.suppressCommandUpdating = false;
gIsEditableMsgFolder = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_DRAFTS);
gIsEditableMsgFolder = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_DRAFTS, true);
gCurrentLoadingFolderSortType = 0;
gCurrentLoadingFolderSortOrder = 0;

View File

@ -139,7 +139,7 @@ function FindNextChildFolder(aParent, aAfter)
// if there is unread mail in the trash, sent, drafts, unsent messages
// templates or junk special folder,
// we ignore it when doing cross folder "next" navigation
if (!IsSpecialFolder(folder, MSG_FOLDER_FLAG_TRASH | MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE | MSG_FOLDER_FLAG_TEMPLATES | MSG_FOLDER_FLAG_JUNK)) {
if (!IsSpecialFolder(folder, MSG_FOLDER_FLAG_TRASH | MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE | MSG_FOLDER_FLAG_TEMPLATES | MSG_FOLDER_FLAG_JUNK, true)) {
if (folder.getNumUnread(false) > 0)
return folder;

View File

@ -336,7 +336,7 @@ function createSearchTerms()
var searchTermsArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
var selectedFolder = GetThreadPaneFolder();
var searchAttrib = (IsSpecialFolder(selectedFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE)) ? nsMsgSearchAttrib.ToOrCC : nsMsgSearchAttrib.Sender;
var searchAttrib = (IsSpecialFolder(selectedFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE, true)) ? nsMsgSearchAttrib.ToOrCC : nsMsgSearchAttrib.Sender;
// implement | for QS
// does this break if the user types "foo|bar" expecting to see subjects with that string?
// I claim no, since "foo|bar" will be a hit for "foo" || "bar"

View File

@ -177,10 +177,10 @@ function MsgComposeDraftMessage()
function ThreadPaneDoubleClick()
{
if (IsSpecialFolderSelected(MSG_FOLDER_FLAG_DRAFTS)) {
if (IsSpecialFolderSelected(MSG_FOLDER_FLAG_DRAFTS, true)) {
MsgComposeDraftMessage();
}
else if(IsSpecialFolderSelected(MSG_FOLDER_FLAG_TEMPLATES)) {
else if(IsSpecialFolderSelected(MSG_FOLDER_FLAG_TEMPLATES, true)) {
var loadedFolder = GetLoadedMsgFolder();
var messageArray = GetSelectedMessages();
ComposeMessage(msgComposeType.Template, msgComposeFormat.Default, loadedFolder, messageArray);
@ -375,10 +375,10 @@ function UpdateSortIndicators(sortType, sortOrder)
}
}
function IsSpecialFolderSelected(flags)
function IsSpecialFolderSelected(flags, checkAncestors)
{
var selectedFolder = GetThreadPaneFolder();
return IsSpecialFolder(selectedFolder, flags);
return IsSpecialFolder(selectedFolder, flags, checkAncestors);
}
function GetThreadTree()