2000-06-21 06:35:58 +00:00
|
|
|
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
1999-09-01 23:49:47 +00:00
|
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
|
|
|
|
*
|
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
|
* rights and limitations under the License.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
|
* March 31, 1998.
|
|
|
|
|
*
|
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
|
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
|
* Rights Reserved.
|
2001-08-15 05:07:48 +00:00
|
|
|
|
*
|
|
|
|
|
* Contributor(s):
|
|
|
|
|
* Jan Varga (varga@utcru.sk)
|
|
|
|
|
* H<EFBFBD>kan Waara (hwaara@chello.se)
|
1999-09-01 23:49:47 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* This is where functions related to the 3 pane window are kept */
|
|
|
|
|
|
2002-02-21 01:37:36 +00:00
|
|
|
|
// from MailNewsTypes.h
|
|
|
|
|
const nsMsgViewIndex_None = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var gFolderTree;
|
2000-10-05 21:17:22 +00:00
|
|
|
|
var gMessagePane;
|
2001-02-07 04:40:40 +00:00
|
|
|
|
var gMessagePaneFrame;
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var gThreadTree;
|
2001-12-19 15:10:22 +00:00
|
|
|
|
var gSearchInput;
|
2001-02-07 04:40:40 +00:00
|
|
|
|
|
1999-11-11 20:24:46 +00:00
|
|
|
|
var gThreadAndMessagePaneSplitter = null;
|
1999-11-22 22:08:23 +00:00
|
|
|
|
var gUnreadCount = null;
|
|
|
|
|
var gTotalCount = null;
|
1999-11-11 20:24:46 +00:00
|
|
|
|
|
1999-11-11 00:23:29 +00:00
|
|
|
|
var gCurrentLoadingFolderURI;
|
2000-01-09 19:47:58 +00:00
|
|
|
|
var gCurrentFolderToReroot;
|
2001-03-17 01:59:34 +00:00
|
|
|
|
var gCurrentLoadingFolderSortType = 0;
|
|
|
|
|
var gCurrentLoadingFolderSortOrder = 0;
|
|
|
|
|
var gCurrentLoadingFolderViewType = 0;
|
|
|
|
|
var gCurrentLoadingFolderViewFlags = 0;
|
2001-12-08 00:59:38 +00:00
|
|
|
|
var gRerootOnFolderLoad = false;
|
2000-02-04 15:19:57 +00:00
|
|
|
|
var gCurrentDisplayedMessage = null;
|
2000-02-16 00:39:23 +00:00
|
|
|
|
var gNextMessageAfterDelete = null;
|
2001-04-04 04:32:10 +00:00
|
|
|
|
var gNextMessageAfterLoad = null;
|
2001-05-01 05:25:49 +00:00
|
|
|
|
var gNextMessageViewIndexAfterDelete = -2;
|
2002-02-21 00:16:57 +00:00
|
|
|
|
var gCurrentlyDisplayedMessage=nsMsgViewIndex_None;
|
2000-03-17 01:10:57 +00:00
|
|
|
|
var gStartFolderUri = null;
|
2001-10-09 03:05:18 +00:00
|
|
|
|
var gStartMsgKey = -1;
|
2002-04-18 22:32:25 +00:00
|
|
|
|
var gRightMouseButtonDown = false;
|
2002-03-14 02:40:51 +00:00
|
|
|
|
// Global var to keep track of which row in the thread pane has been selected
|
|
|
|
|
// This is used to make sure that the row with the currentIndex has the selection
|
|
|
|
|
// after a Delete or Move of a message that has a row index less than currentIndex.
|
|
|
|
|
var gThreadPaneCurrentSelectedIndex = -1;
|
|
|
|
|
|
|
|
|
|
// Global var to keep track of if the 'Delete Message' or 'Move To' thread pane
|
2002-03-29 02:46:01 +00:00
|
|
|
|
// context menu item was triggered. This helps prevent the tree view from
|
2002-03-14 02:40:51 +00:00
|
|
|
|
// not updating on one of those menu item commands.
|
|
|
|
|
var gThreadPaneDeleteOrMoveOccurred = false;
|
|
|
|
|
|
2000-04-21 14:22:16 +00:00
|
|
|
|
//If we've loaded a message, set to true. Helps us keep the start page around.
|
|
|
|
|
var gHaveLoadedMessage;
|
|
|
|
|
|
2001-03-14 02:32:04 +00:00
|
|
|
|
var gDisplayStartupPage = false;
|
2001-01-30 22:02:27 +00:00
|
|
|
|
|
1999-09-13 21:11:45 +00:00
|
|
|
|
// the folderListener object
|
|
|
|
|
var folderListener = {
|
2001-10-11 20:45:44 +00:00
|
|
|
|
OnItemAdded: function(parentItem, item, view) { },
|
|
|
|
|
|
|
|
|
|
OnItemRemoved: function(parentItem, item, view) { },
|
|
|
|
|
|
|
|
|
|
OnItemPropertyChanged: function(item, property, oldValue, newValue) { },
|
|
|
|
|
|
|
|
|
|
OnItemIntPropertyChanged: function(item, property, oldValue, newValue) {
|
|
|
|
|
var currentLoadedFolder = GetThreadPaneFolder();
|
|
|
|
|
if (!currentLoadedFolder) return;
|
|
|
|
|
var currentURI = currentLoadedFolder.URI;
|
|
|
|
|
|
|
|
|
|
//if we don't have a folder loaded, don't bother.
|
|
|
|
|
if(currentURI) {
|
|
|
|
|
if(property.GetUnicode() == "TotalMessages" || property.GetUnicode() == "TotalUnreadMessages") {
|
|
|
|
|
var folder = item.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
|
if(folder) {
|
|
|
|
|
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
|
if(folderResource) {
|
|
|
|
|
var folderURI = folderResource.Value;
|
|
|
|
|
if(currentURI == folderURI) {
|
|
|
|
|
UpdateStatusMessageCounts(folder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
1999-11-22 22:08:23 +00:00
|
|
|
|
|
2001-10-11 20:45:44 +00:00
|
|
|
|
OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) { },
|
1999-11-22 22:08:23 +00:00
|
|
|
|
|
2001-10-11 20:45:44 +00:00
|
|
|
|
OnItemUnicharPropertyChanged: function(item, property, oldValue, newValue) { },
|
|
|
|
|
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) { },
|
1999-09-16 21:11:01 +00:00
|
|
|
|
|
2000-05-14 20:36:26 +00:00
|
|
|
|
OnItemEvent: function(folder, event) {
|
2001-10-09 03:05:18 +00:00
|
|
|
|
var eventType = event.GetUnicode();
|
|
|
|
|
if (eventType == "FolderLoaded") {
|
|
|
|
|
if (folder) {
|
|
|
|
|
var resource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
|
if(resource) {
|
|
|
|
|
var uri = resource.Value;
|
|
|
|
|
if(uri == gCurrentFolderToReroot) {
|
|
|
|
|
gCurrentFolderToReroot="";
|
|
|
|
|
var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
|
if(msgFolder) {
|
|
|
|
|
msgFolder.endFolderLoading();
|
2001-11-01 04:05:41 +00:00
|
|
|
|
// suppress command updating when rerooting the folder
|
|
|
|
|
// when rerooting, we'll be clearing the selection
|
|
|
|
|
// which will cause us to update commands.
|
|
|
|
|
if (gDBView) {
|
|
|
|
|
gDBView.suppressCommandUpdating = true;
|
2002-01-18 22:48:24 +00:00
|
|
|
|
// if the db's view isn't set, something went wrong and we should reroot
|
|
|
|
|
// the folder, which will re-open the view.
|
|
|
|
|
if (!gDBView.db)
|
|
|
|
|
gRerootOnFolderLoad = true;
|
2001-11-01 04:05:41 +00:00
|
|
|
|
}
|
2001-12-08 00:59:38 +00:00
|
|
|
|
if (gRerootOnFolderLoad)
|
|
|
|
|
RerootFolder(uri, msgFolder, gCurrentLoadingFolderViewType, gCurrentLoadingFolderViewFlags, gCurrentLoadingFolderSortType, gCurrentLoadingFolderSortOrder);
|
2001-12-12 01:47:24 +00:00
|
|
|
|
|
|
|
|
|
var db = msgFolder.getMsgDatabase(msgWindow);
|
|
|
|
|
if (db)
|
|
|
|
|
db.resetHdrCacheSize(100);
|
2001-11-01 04:05:41 +00:00
|
|
|
|
|
|
|
|
|
if (gDBView) {
|
|
|
|
|
gDBView.suppressCommandUpdating = false;
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-09 03:05:18 +00:00
|
|
|
|
gIsEditableMsgFolder = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_DRAFTS);
|
|
|
|
|
|
|
|
|
|
gCurrentLoadingFolderSortType = 0;
|
|
|
|
|
gCurrentLoadingFolderSortOrder = 0;
|
|
|
|
|
gCurrentLoadingFolderViewType = 0;
|
|
|
|
|
gCurrentLoadingFolderViewFlags = 0;
|
|
|
|
|
|
|
|
|
|
var scrolled = false;
|
|
|
|
|
|
2002-02-21 00:16:57 +00:00
|
|
|
|
LoadCurrentlyDisplayedMessage(); //used for rename folder msg loading after folder is loaded.
|
|
|
|
|
|
2001-10-09 03:05:18 +00:00
|
|
|
|
if (gStartMsgKey != -1) {
|
|
|
|
|
// select the desired message
|
|
|
|
|
gDBView.selectMsgByKey(gStartMsgKey);
|
|
|
|
|
gStartMsgKey = -1;
|
|
|
|
|
|
|
|
|
|
// now scroll to it
|
|
|
|
|
var indicies = GetSelectedIndices(gDBView);
|
2002-03-29 02:46:01 +00:00
|
|
|
|
EnsureRowInThreadTreeIsVisible(indicies[0]);
|
2001-10-09 03:05:18 +00:00
|
|
|
|
scrolled = true;
|
|
|
|
|
}
|
|
|
|
|
if (gNextMessageAfterLoad) {
|
|
|
|
|
var type = gNextMessageAfterLoad;
|
|
|
|
|
gNextMessageAfterLoad = null;
|
|
|
|
|
|
|
|
|
|
// scroll to and select the proper message
|
|
|
|
|
scrolled = ScrollToMessage(type, true, true /* selectMessage */);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(uri == gCurrentLoadingFolderURI) {
|
|
|
|
|
gCurrentLoadingFolderURI = "";
|
|
|
|
|
//Now let's select the first new message if there is one
|
|
|
|
|
if (!scrolled) {
|
|
|
|
|
// if we didn't just scroll, scroll to the first new message
|
|
|
|
|
// don't select it though
|
|
|
|
|
scrolled = ScrollToMessage(nsMsgNavigationType.firstNew, true, false /* selectMessage */);
|
2001-04-04 04:43:15 +00:00
|
|
|
|
|
2001-10-09 03:05:18 +00:00
|
|
|
|
// if we failed to find a new message, scroll to the top
|
|
|
|
|
if (!scrolled) {
|
2002-03-29 02:46:01 +00:00
|
|
|
|
EnsureRowInThreadTreeIsVisible(0);
|
2001-10-09 03:05:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SetBusyCursor(window, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (eventType == "DeleteOrMoveMsgCompleted") {
|
|
|
|
|
HandleDeleteOrMoveMsgCompleted(folder);
|
|
|
|
|
}
|
|
|
|
|
else if (eventType == "DeleteOrMoveMsgFailed") {
|
|
|
|
|
HandleDeleteOrMoveMsgFailed(folder);
|
|
|
|
|
}
|
|
|
|
|
else if (eventType == "CompactCompleted") {
|
|
|
|
|
HandleCompactCompleted(folder);
|
|
|
|
|
}
|
2002-02-21 00:16:57 +00:00
|
|
|
|
else if(eventType == "RenameCompleted") {
|
|
|
|
|
SelectFolder(folder.URI);
|
|
|
|
|
}
|
2001-08-15 05:07:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var folderObserver = {
|
|
|
|
|
canDropOn: function(index)
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
return CanDropOnFolderTree(index);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
canDropBeforeAfter: function(index, before)
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
return CanDropBeforeAfterFolderTree(index, before);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onDrop: function(row, orientation)
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
DropOnFolderTree(row, orientation);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onToggleOpenState: function()
|
|
|
|
|
{
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onCycleHeader: function(colID, elt)
|
|
|
|
|
{
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onCycleCell: function(row, colID)
|
|
|
|
|
{
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onSelectionChanged: function()
|
|
|
|
|
{
|
|
|
|
|
},
|
2001-08-02 03:09:33 +00:00
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
isEditable: function(row, colID)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onSetCellText: function(row, colID, value)
|
|
|
|
|
{
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onPerformAction: function(action)
|
|
|
|
|
{
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onPerformActionOnRow: function(action, row)
|
|
|
|
|
{
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onPerformActionOnCell: function(action, row, colID)
|
|
|
|
|
{
|
2000-08-14 14:40:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-21 00:14:24 +00:00
|
|
|
|
function HandleDeleteOrMoveMsgFailed(folder)
|
|
|
|
|
{
|
2001-12-26 21:58:32 +00:00
|
|
|
|
gDBView.onDeleteCompleted(false);
|
2001-01-30 22:02:27 +00:00
|
|
|
|
if(IsCurrentLoadedFolder(folder)) {
|
|
|
|
|
if(gNextMessageAfterDelete) {
|
|
|
|
|
gNextMessageAfterDelete = null;
|
2001-05-01 05:25:49 +00:00
|
|
|
|
gNextMessageViewIndexAfterDelete = -2;
|
2001-01-30 22:02:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-09-21 00:14:24 +00:00
|
|
|
|
|
2001-03-17 01:59:34 +00:00
|
|
|
|
// fix me???
|
2001-03-24 01:12:33 +00:00
|
|
|
|
// ThreadPaneSelectionChange(true);
|
2000-09-21 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-14 14:40:33 +00:00
|
|
|
|
function HandleDeleteOrMoveMsgCompleted(folder)
|
|
|
|
|
{
|
2001-12-26 21:58:32 +00:00
|
|
|
|
gDBView.onDeleteCompleted(true);
|
2001-05-01 05:25:49 +00:00
|
|
|
|
if (gNextMessageViewIndexAfterDelete != -2)
|
|
|
|
|
{
|
|
|
|
|
if (IsCurrentLoadedFolder(folder))
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView);
|
|
|
|
|
var treeSelection = treeView.selection;
|
2002-02-11 23:31:49 +00:00
|
|
|
|
if (gNextMessageViewIndexAfterDelete != nsMsgViewIndex_None)
|
2001-05-01 05:25:49 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
viewSize = treeView.rowCount;
|
2001-05-01 05:25:49 +00:00
|
|
|
|
if (gNextMessageViewIndexAfterDelete >= viewSize)
|
|
|
|
|
{
|
|
|
|
|
if (viewSize > 0)
|
|
|
|
|
gNextMessageViewIndexAfterDelete = viewSize - 1;
|
|
|
|
|
else
|
2002-02-11 23:31:49 +00:00
|
|
|
|
{
|
|
|
|
|
gNextMessageViewIndexAfterDelete = nsMsgViewIndex_None;
|
|
|
|
|
|
|
|
|
|
//there is nothing to select viewSize is 0
|
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
treeSelection.clearSelection();
|
2002-02-11 23:31:49 +00:00
|
|
|
|
setTitleFromFolder(folder,null);
|
|
|
|
|
ClearMessagePane();
|
|
|
|
|
}
|
2001-05-01 05:25:49 +00:00
|
|
|
|
}
|
2001-03-17 01:59:34 +00:00
|
|
|
|
}
|
2001-03-24 01:12:33 +00:00
|
|
|
|
|
2001-03-17 01:59:34 +00:00
|
|
|
|
// if we are about to set the selection with a new element then DON'T clear
|
|
|
|
|
// the selection then add the next message to select. This just generates
|
|
|
|
|
// an extra round of command updating notifications that we are trying to
|
|
|
|
|
// optimize away.
|
2002-02-11 23:31:49 +00:00
|
|
|
|
if (gNextMessageViewIndexAfterDelete != nsMsgViewIndex_None)
|
2001-05-01 05:25:49 +00:00
|
|
|
|
{
|
2001-12-04 04:02:02 +00:00
|
|
|
|
// when deleting a message we don't update the commands when the selection goes to 0
|
2001-11-27 21:45:41 +00:00
|
|
|
|
// (we have a hack in nsMsgDBView which prevents that update) so there is no need to
|
2001-12-04 04:02:02 +00:00
|
|
|
|
// update commands when we select the next message after the delete; the commands already
|
2001-11-27 21:45:41 +00:00
|
|
|
|
// have the right update state...
|
|
|
|
|
gDBView.suppressCommandUpdating = true;
|
2002-03-14 02:40:51 +00:00
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
// This check makes sure that the tree does not perform a
|
2002-03-14 02:40:51 +00:00
|
|
|
|
// selection on a non selected row (row < 0), else assertions will
|
|
|
|
|
// be thrown.
|
|
|
|
|
if (gNextMessageViewIndexAfterDelete >= 0)
|
2002-03-29 02:46:01 +00:00
|
|
|
|
treeSelection.select(gNextMessageViewIndexAfterDelete);
|
2001-12-04 04:02:02 +00:00
|
|
|
|
|
|
|
|
|
// if gNextMessageViewIndexAfterDelete has the same value
|
2002-03-29 02:46:01 +00:00
|
|
|
|
// as the last index we had selected, the tree won't generate a
|
|
|
|
|
// selectionChanged notification for the tree view. So force a manual
|
2001-12-04 04:02:02 +00:00
|
|
|
|
// selection changed call. (don't worry it's cheap if we end up calling it twice).
|
2002-03-29 02:46:01 +00:00
|
|
|
|
if (treeView)
|
|
|
|
|
treeView.selectionChanged();
|
2001-12-04 04:02:02 +00:00
|
|
|
|
|
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
EnsureRowInThreadTreeIsVisible(gNextMessageViewIndexAfterDelete);
|
2001-11-27 21:45:41 +00:00
|
|
|
|
gDBView.suppressCommandUpdating = false;
|
2001-03-17 01:59:34 +00:00
|
|
|
|
}
|
2001-05-01 05:25:49 +00:00
|
|
|
|
}
|
|
|
|
|
gNextMessageViewIndexAfterDelete = -2;
|
|
|
|
|
//default value after delete/move/copy is over
|
2001-03-24 01:12:33 +00:00
|
|
|
|
}
|
2000-02-16 00:39:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-08-02 03:09:33 +00:00
|
|
|
|
function HandleCompactCompleted (folder)
|
|
|
|
|
{
|
|
|
|
|
if(folder)
|
|
|
|
|
{
|
|
|
|
|
var resource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
|
if(resource)
|
|
|
|
|
{
|
|
|
|
|
var uri = resource.Value;
|
|
|
|
|
var msgFolder = msgWindow.openFolder;
|
|
|
|
|
if (msgFolder && uri == msgFolder.URI)
|
|
|
|
|
{
|
|
|
|
|
var msgdb = msgFolder.getMsgDatabase(msgWindow);
|
|
|
|
|
if (msgdb)
|
|
|
|
|
{
|
|
|
|
|
var dbFolderInfo = msgdb.dBFolderInfo;
|
|
|
|
|
sortType = dbFolderInfo.sortType;
|
|
|
|
|
sortOrder = dbFolderInfo.sortOrder;
|
|
|
|
|
viewFlags = dbFolderInfo.viewFlags;
|
|
|
|
|
viewType = dbFolderInfo.viewType;
|
2001-10-08 02:06:15 +00:00
|
|
|
|
dbFolderInfo = null;
|
2001-08-02 03:09:33 +00:00
|
|
|
|
}
|
|
|
|
|
RerootFolder(uri, msgFolder, viewType, viewFlags, sortType, sortOrder);
|
2002-02-21 00:16:57 +00:00
|
|
|
|
LoadCurrentlyDisplayedMessage();
|
2001-08-02 03:09:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-21 00:16:57 +00:00
|
|
|
|
function LoadCurrentlyDisplayedMessage()
|
|
|
|
|
{
|
|
|
|
|
if (gCurrentlyDisplayedMessage != nsMsgViewIndex_None)
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView);
|
|
|
|
|
var treeSelection = treeView.selection;
|
|
|
|
|
treeSelection.select(gCurrentlyDisplayedMessage);
|
|
|
|
|
if (treeView)
|
|
|
|
|
treeView.selectionChanged();
|
|
|
|
|
EnsureRowInThreadTreeIsVisible(gCurrentlyDisplayedMessage);
|
2002-02-21 00:16:57 +00:00
|
|
|
|
SetFocusThreadPane();
|
|
|
|
|
gCurrentlyDisplayedMessage = nsMsgViewIndex_None; //reset
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-16 00:39:23 +00:00
|
|
|
|
function IsCurrentLoadedFolder(folder)
|
|
|
|
|
{
|
2000-09-08 04:22:01 +00:00
|
|
|
|
var msgfolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
2000-02-16 00:39:23 +00:00
|
|
|
|
if(msgfolder)
|
|
|
|
|
{
|
|
|
|
|
var folderResource = msgfolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
|
if(folderResource)
|
|
|
|
|
{
|
|
|
|
|
var folderURI = folderResource.Value;
|
2001-03-17 01:59:34 +00:00
|
|
|
|
var currentLoadedFolder = GetThreadPaneFolder();
|
|
|
|
|
var currentURI = currentLoadedFolder.URI;
|
2000-02-16 00:39:23 +00:00
|
|
|
|
return(currentURI == folderURI);
|
|
|
|
|
}
|
1999-09-16 21:11:01 +00:00
|
|
|
|
}
|
2000-02-16 00:39:23 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
1999-09-13 21:11:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-09-26 01:01:49 +00:00
|
|
|
|
function ServerContainsFolder(server, folder)
|
|
|
|
|
{
|
|
|
|
|
if (!folder || !server)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return server.equals(folder.server);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SelectServer(server)
|
|
|
|
|
{
|
2002-01-14 22:59:02 +00:00
|
|
|
|
SelectFolder(server.rootFolder.URI);
|
2001-09-26 01:01:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we have this incoming server listener in case we need to
|
|
|
|
|
// alter the folder pane selection when a server is removed
|
|
|
|
|
// or changed (currently, when the real username or real hostname change)
|
|
|
|
|
var gThreePaneIncomingServerListener = {
|
|
|
|
|
onServerLoaded: function(server) {},
|
|
|
|
|
onServerUnloaded: function(server) {
|
|
|
|
|
var selectedFolders = GetSelectedMsgFolders();
|
|
|
|
|
for (var i = 0; i < selectedFolders.length; i++) {
|
|
|
|
|
if (ServerContainsFolder(server, selectedFolders[i])) {
|
|
|
|
|
SelectServer(accountManager.defaultAccount.incomingServer);
|
|
|
|
|
// we've made a new selection, we're done
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if nothing is selected at this point, better go select the default
|
|
|
|
|
// this could happen if nothing was selected when the server was removed
|
|
|
|
|
selectedFolders = GetSelectedMsgFolders();
|
|
|
|
|
if (selectedFolders.length == 0) {
|
|
|
|
|
SelectServer(accountManager.defaultAccount.incomingServer);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onServerChanged: function(server) {
|
|
|
|
|
// if the current selected folder is on the server that changed
|
|
|
|
|
// and that server is an imap or news server,
|
|
|
|
|
// we need to update the selection.
|
|
|
|
|
// on those server types, we'll be reconnecting to the server
|
|
|
|
|
// and our currently selected folder will need to be reloaded
|
|
|
|
|
// or worse, be invalid.
|
|
|
|
|
if (server.type != "imap" && server.type !="nntp")
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var selectedFolders = GetSelectedMsgFolders();
|
|
|
|
|
for (var i = 0; i < selectedFolders.length; i++) {
|
|
|
|
|
// if the selected item is a server, we don't have to update
|
|
|
|
|
// the selection
|
|
|
|
|
if (!(selectedFolders[i].isServer) && ServerContainsFolder(server, selectedFolders[i])) {
|
|
|
|
|
SelectServer(server);
|
|
|
|
|
// we've made a new selection, we're done
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
|
/* Functions related to startup */
|
|
|
|
|
function OnLoadMessenger()
|
|
|
|
|
{
|
2001-05-15 05:49:09 +00:00
|
|
|
|
AddMailOfflineObserver();
|
2000-04-11 20:19:32 +00:00
|
|
|
|
CreateMailWindowGlobals();
|
|
|
|
|
Create3PaneGlobals();
|
2001-09-18 06:56:08 +00:00
|
|
|
|
verifyAccounts(null);
|
1999-09-11 01:54:15 +00:00
|
|
|
|
|
2001-01-23 21:54:34 +00:00
|
|
|
|
HideAccountCentral();
|
2000-01-06 00:53:12 +00:00
|
|
|
|
loadStartPage();
|
2001-08-15 05:07:48 +00:00
|
|
|
|
InitMsgWindow();
|
1999-10-27 22:38:47 +00:00
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
messenger.SetWindow(window, msgWindow);
|
1999-10-29 04:39:06 +00:00
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
InitializeDataSources();
|
|
|
|
|
InitPanes();
|
1999-09-01 23:49:47 +00:00
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
accountManager.SetSpecialFoldersForIdentities();
|
2001-09-26 01:01:49 +00:00
|
|
|
|
accountManager.addIncomingServerListener(gThreePaneIncomingServerListener);
|
1999-09-13 21:11:45 +00:00
|
|
|
|
|
2000-01-06 00:53:12 +00:00
|
|
|
|
AddToSession();
|
2000-01-20 22:56:00 +00:00
|
|
|
|
//need to add to session before trying to load start folder otherwise listeners aren't
|
|
|
|
|
//set up correctly.
|
2002-03-22 23:28:55 +00:00
|
|
|
|
// argument[0] --> folder uri
|
|
|
|
|
// argument[1] --> optional message key
|
|
|
|
|
|
2000-12-21 01:26:18 +00:00
|
|
|
|
if ("arguments" in window && window.arguments[0])
|
2000-03-17 01:10:57 +00:00
|
|
|
|
{
|
2002-03-22 23:28:55 +00:00
|
|
|
|
gStartFolderUri = window.arguments[0];
|
|
|
|
|
gStartMsgKey = window.arguments[1];
|
2000-03-17 01:10:57 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gStartFolderUri = null;
|
2001-10-09 03:05:18 +00:00
|
|
|
|
gStartMsgKey = -1;
|
2000-03-17 01:10:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setTimeout("loadStartFolder(gStartFolderUri);", 0);
|
2000-01-06 00:53:12 +00:00
|
|
|
|
|
|
|
|
|
// FIX ME - later we will be able to use onload from the overlay
|
|
|
|
|
OnLoadMsgHeaderPane();
|
1999-12-24 01:08:05 +00:00
|
|
|
|
|
2001-11-28 04:17:54 +00:00
|
|
|
|
gHaveLoadedMessage = false;
|
1999-12-24 01:08:05 +00:00
|
|
|
|
|
2001-11-28 04:17:54 +00:00
|
|
|
|
//Set focus to the Thread Pane the first time the window is opened.
|
|
|
|
|
SetFocusThreadPane();
|
1999-09-01 23:49:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function OnUnloadMessenger()
|
|
|
|
|
{
|
2001-09-26 01:01:49 +00:00
|
|
|
|
accountManager.removeIncomingServerListener(gThreePaneIncomingServerListener);
|
2002-06-19 12:43:06 +00:00
|
|
|
|
|
|
|
|
|
// FIX ME - later we will be able to use onload from the overlay
|
|
|
|
|
OnUnloadMsgHeaderPane();
|
|
|
|
|
|
2001-05-15 05:49:09 +00:00
|
|
|
|
OnMailWindowUnload();
|
1999-09-22 06:05:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
|
function Create3PaneGlobals()
|
2000-02-04 01:56:38 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
2001-08-21 06:18:58 +00:00
|
|
|
|
|
|
|
|
|
// because the "open" state persists, we'll call
|
|
|
|
|
// PerformExpand() for all servers that are open at startup.
|
|
|
|
|
function PerformExpandForAllOpenServers()
|
2001-08-15 05:07:48 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
|
var view = folderTree.treeBoxObject.view;
|
2001-08-15 05:07:48 +00:00
|
|
|
|
for (var i = 0; i < view.rowCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (view.isContainer(i))
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderResource = GetFolderResource(folderTree, i);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var isServer = GetFolderAttribute(folderTree, folderResource, "IsServer");
|
2001-08-21 06:18:58 +00:00
|
|
|
|
if (isServer == "true")
|
2001-08-15 05:07:48 +00:00
|
|
|
|
{
|
2001-08-21 06:18:58 +00:00
|
|
|
|
if (view.isContainerOpen(i))
|
2001-08-15 05:07:48 +00:00
|
|
|
|
{
|
|
|
|
|
var server = msgFolder.server;
|
|
|
|
|
// Don't do this for imap servers. See bug #41943
|
|
|
|
|
if (server.type != "imap")
|
2001-08-21 06:18:58 +00:00
|
|
|
|
server.performExpand(msgWindow);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-04 05:47:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-01-23 21:54:34 +00:00
|
|
|
|
function loadStartFolder(initialUri)
|
1999-09-14 06:27:36 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
2001-01-23 21:54:34 +00:00
|
|
|
|
var defaultServer = null;
|
2001-08-15 05:07:48 +00:00
|
|
|
|
var startFolderResource = null;
|
2001-02-07 03:55:46 +00:00
|
|
|
|
var isLoginAtStartUpEnabled = false;
|
2001-02-23 02:42:31 +00:00
|
|
|
|
var enabledNewMailCheckOnce = false;
|
|
|
|
|
var mailCheckOncePref = "mail.startup.enabledMailCheckOnce";
|
2000-01-10 01:34:36 +00:00
|
|
|
|
|
2001-01-23 21:54:34 +00:00
|
|
|
|
//First get default account
|
|
|
|
|
try
|
|
|
|
|
{
|
2001-08-15 05:07:48 +00:00
|
|
|
|
if(initialUri)
|
|
|
|
|
startFolderResource = RDF.GetResource(initialUri);
|
|
|
|
|
else
|
2001-01-23 21:54:34 +00:00
|
|
|
|
{
|
|
|
|
|
var defaultAccount = accountManager.defaultAccount;
|
2000-01-10 01:34:36 +00:00
|
|
|
|
|
2001-01-23 21:54:34 +00:00
|
|
|
|
defaultServer = defaultAccount.incomingServer;
|
2002-01-14 22:59:02 +00:00
|
|
|
|
var rootMsgFolder = defaultServer.rootMsgFolder;
|
2000-01-10 01:34:36 +00:00
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
startFolderResource = rootMsgFolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
2000-01-10 01:34:36 +00:00
|
|
|
|
|
2001-10-27 05:39:25 +00:00
|
|
|
|
enabledNewMailCheckOnce = pref.getBoolPref(mailCheckOncePref);
|
2001-02-23 02:42:31 +00:00
|
|
|
|
|
|
|
|
|
// Enable checknew mail once by turning checkmail pref 'on' to bring
|
|
|
|
|
// all users to one plane. This allows all users to go to Inbox. User can
|
|
|
|
|
// always go to server settings panel and turn off "Check for new mail at startup"
|
|
|
|
|
if (!enabledNewMailCheckOnce)
|
|
|
|
|
{
|
2001-10-27 05:39:25 +00:00
|
|
|
|
pref.setBoolPref(mailCheckOncePref, true);
|
2001-02-23 02:42:31 +00:00
|
|
|
|
defaultServer.loginAtStartUp = true;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-07 03:55:46 +00:00
|
|
|
|
// Get the user pref to see if the login at startup is enabled for default account
|
|
|
|
|
isLoginAtStartUpEnabled = defaultServer.loginAtStartUp;
|
2000-02-04 01:56:38 +00:00
|
|
|
|
|
2001-02-07 03:55:46 +00:00
|
|
|
|
// Get Inbox only if when we have to login
|
|
|
|
|
if (isLoginAtStartUpEnabled)
|
|
|
|
|
{
|
|
|
|
|
//now find Inbox
|
|
|
|
|
var outNumFolders = new Object();
|
|
|
|
|
var inboxFolder = rootMsgFolder.getFoldersWithFlag(0x1000, 1, outNumFolders);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
if (!inboxFolder) return;
|
2001-02-07 03:55:46 +00:00
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
startFolderResource = inboxFolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
2001-02-07 03:55:46 +00:00
|
|
|
|
}
|
2001-08-23 01:10:05 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// set the startFolderResource to the server, so we select it
|
|
|
|
|
// so we'll get account central
|
|
|
|
|
startFolderResource = RDF.GetResource(defaultServer.serverURI);
|
|
|
|
|
}
|
2001-01-23 21:54:34 +00:00
|
|
|
|
}
|
2000-01-10 01:34:36 +00:00
|
|
|
|
|
2001-08-22 18:41:59 +00:00
|
|
|
|
var startFolder = startFolderResource.QueryInterface(Components.interfaces.nsIFolder);
|
|
|
|
|
SelectFolder(startFolder.URI);
|
2001-01-23 21:54:34 +00:00
|
|
|
|
|
|
|
|
|
// only do this on startup, when we pass in null
|
2001-02-07 03:55:46 +00:00
|
|
|
|
if (!initialUri && isLoginAtStartUpEnabled)
|
2001-01-23 21:54:34 +00:00
|
|
|
|
{
|
2001-03-30 05:07:20 +00:00
|
|
|
|
// Perform biff on the server to check for new mail, except for imap
|
2001-08-15 05:07:48 +00:00
|
|
|
|
if (defaultServer.type != "imap")
|
2001-12-12 01:47:24 +00:00
|
|
|
|
defaultServer.PerformBiff();
|
2001-01-23 21:54:34 +00:00
|
|
|
|
}
|
2001-08-21 06:18:58 +00:00
|
|
|
|
|
|
|
|
|
// because the "open" state persists, we'll call
|
|
|
|
|
// PerformExpand() for all servers that are open at startup.
|
2001-10-30 22:57:12 +00:00
|
|
|
|
// note, because of the "news.persist_server_open_state_in_folderpane" pref
|
|
|
|
|
// we don't persist the "open" state of news servers across sessions,
|
|
|
|
|
// but we do within a session, so if you open another 3 pane
|
|
|
|
|
// and a news server is "open", we'll update the unread counts.
|
2001-08-21 06:18:58 +00:00
|
|
|
|
PerformExpandForAllOpenServers();
|
2001-01-23 21:54:34 +00:00
|
|
|
|
}
|
|
|
|
|
catch(ex)
|
|
|
|
|
{
|
|
|
|
|
dump(ex);
|
|
|
|
|
dump('Exception in LoadStartFolder caused by no default account. We know about this\n');
|
|
|
|
|
}
|
1999-09-14 06:27:36 +00:00
|
|
|
|
|
2001-01-23 21:54:34 +00:00
|
|
|
|
if (!initialUri)
|
|
|
|
|
{
|
2002-05-16 03:32:20 +00:00
|
|
|
|
MsgGetMessagesForAllServers(null);
|
2001-01-23 21:54:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function TriggerGetMessages(server)
|
|
|
|
|
{
|
|
|
|
|
// downloadMessagesAtStartup for a given server type indicates whether
|
|
|
|
|
// or not there is a need to Trigger GetMessages action
|
|
|
|
|
if (server.downloadMessagesAtStartup)
|
|
|
|
|
MsgGetMessage();
|
1999-09-14 06:27:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-28 23:27:21 +00:00
|
|
|
|
function AddToSession()
|
1999-09-15 04:57:24 +00:00
|
|
|
|
{
|
|
|
|
|
try {
|
2000-09-13 23:57:52 +00:00
|
|
|
|
var mailSession = Components.classes[mailSessionContractID].getService(Components.interfaces.nsIMsgMailSession);
|
1999-09-15 04:57:24 +00:00
|
|
|
|
|
2001-10-11 20:45:44 +00:00
|
|
|
|
var nsIFolderListener = Components.interfaces.nsIFolderListener;
|
|
|
|
|
var notifyFlags = nsIFolderListener.intPropertyChanged | nsIFolderListener.event;
|
|
|
|
|
mailSession.AddFolderListener(folderListener, notifyFlags);
|
1999-09-15 04:57:24 +00:00
|
|
|
|
} catch (ex) {
|
1999-10-28 23:27:21 +00:00
|
|
|
|
dump("Error adding to session\n");
|
1999-09-15 04:57:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
|
function InitPanes()
|
|
|
|
|
{
|
2001-08-15 05:07:48 +00:00
|
|
|
|
OnLoadFolderPane();
|
2001-12-14 02:57:31 +00:00
|
|
|
|
OnLoadThreadPane();
|
2001-08-15 05:07:48 +00:00
|
|
|
|
SetupCommandUpdateHandlers();
|
1999-09-01 23:49:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
|
function InitializeDataSources()
|
|
|
|
|
{
|
|
|
|
|
//Setup common mailwindow stuff.
|
|
|
|
|
AddDataSources();
|
|
|
|
|
|
|
|
|
|
//To threadpane move context menu
|
|
|
|
|
SetupMoveCopyMenus('threadPaneContext-moveMenu', accountManagerDataSource, folderDataSource);
|
|
|
|
|
|
|
|
|
|
//To threadpane copy content menu
|
|
|
|
|
SetupMoveCopyMenus('threadPaneContext-copyMenu', accountManagerDataSource, folderDataSource);
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
function OnFolderUnreadColAttrModified(event)
|
|
|
|
|
{
|
|
|
|
|
if (event.attrName == "hidden")
|
|
|
|
|
{
|
|
|
|
|
var folderNameCell = document.getElementById("folderNameCell");
|
2002-03-12 15:34:33 +00:00
|
|
|
|
var label = {"true": "?folderTreeName", "false": "?folderTreeSimpleName"};
|
|
|
|
|
folderNameCell.setAttribute("label", label[event.newValue]);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-22 00:13:21 +00:00
|
|
|
|
// builds prior to 8-14-2001 did not have the unread and total columns
|
|
|
|
|
// in the folder pane. so if a user ran an old build, and then
|
|
|
|
|
// upgraded, they get the new columns, and this causes problems
|
|
|
|
|
// because it looks like all the folder names are gone (see bug #96979)
|
|
|
|
|
// to work around this, we hide those columns once, using the
|
|
|
|
|
// "mail.ui.folderpane.version" pref.
|
|
|
|
|
function UpgradeFolderPaneUI()
|
|
|
|
|
{
|
2001-10-27 05:39:25 +00:00
|
|
|
|
var folderPaneUIVersion = pref.getIntPref("mail.ui.folderpane.version");
|
2001-09-22 00:13:21 +00:00
|
|
|
|
|
|
|
|
|
if (folderPaneUIVersion == 1) {
|
|
|
|
|
var folderUnreadCol = document.getElementById("folderUnreadCol");
|
|
|
|
|
folderUnreadCol.setAttribute("hidden", "true");
|
|
|
|
|
var folderTotalCol = document.getElementById("folderTotalCol");
|
|
|
|
|
folderTotalCol.setAttribute("hidden", "true");
|
2001-10-27 05:39:25 +00:00
|
|
|
|
pref.setIntPref("mail.ui.folderpane.version", 2);
|
2001-09-22 00:13:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
function OnLoadFolderPane()
|
1999-09-01 23:49:47 +00:00
|
|
|
|
{
|
2001-09-22 00:13:21 +00:00
|
|
|
|
UpgradeFolderPaneUI();
|
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
var folderUnreadCol = document.getElementById("folderUnreadCol");
|
|
|
|
|
var hidden = folderUnreadCol.getAttribute("hidden");
|
2002-04-19 07:19:26 +00:00
|
|
|
|
if (hidden != "true")
|
2001-08-15 05:07:48 +00:00
|
|
|
|
{
|
|
|
|
|
var folderNameCell = document.getElementById("folderNameCell");
|
|
|
|
|
folderNameCell.setAttribute("label", "?folderTreeSimpleName");
|
|
|
|
|
}
|
|
|
|
|
folderUnreadCol.addEventListener("DOMAttrModified", OnFolderUnreadColAttrModified, false);
|
1999-12-21 23:38:31 +00:00
|
|
|
|
|
2001-10-08 20:05:00 +00:00
|
|
|
|
//Add folderDataSource and accountManagerDataSource to folderPane
|
|
|
|
|
accountManagerDataSource = accountManagerDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
|
|
|
|
folderDataSource = folderDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
|
|
|
|
var database = GetFolderDatasource();
|
|
|
|
|
|
|
|
|
|
database.AddDataSource(accountManagerDataSource);
|
|
|
|
|
database.AddDataSource(folderDataSource);
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
|
folderTree.setAttribute("ref", "msgaccounts:/");
|
2001-10-08 20:05:00 +00:00
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTreeBuilder = folderTree.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder);
|
|
|
|
|
folderTreeBuilder.addObserver(folderObserver);
|
|
|
|
|
folderTree.addEventListener("click",FolderPaneOnClick,true);
|
|
|
|
|
folderTree.addEventListener("mousedown",TreeOnMouseDown,true);
|
2000-06-30 06:02:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-14 02:57:31 +00:00
|
|
|
|
// builds prior to 12-08-2001 did not have the labels column
|
|
|
|
|
// in the thread pane. so if a user ran an old build, and then
|
|
|
|
|
// upgraded, they get the new column, and this causes problems.
|
|
|
|
|
// We're trying to avoid a similar problem to bug #96979.
|
|
|
|
|
// to work around this, we hide the column once, using the
|
|
|
|
|
// "mailnews.ui.threadpane.version" pref.
|
|
|
|
|
function UpgradeThreadPaneUI()
|
|
|
|
|
{
|
|
|
|
|
var labelCol;
|
|
|
|
|
var threadPaneUIVersion;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
threadPaneUIVersion = pref.getIntPref("mailnews.ui.threadpane.version");
|
|
|
|
|
if (threadPaneUIVersion == 1) {
|
|
|
|
|
labelCol = document.getElementById("labelCol");
|
|
|
|
|
labelCol.setAttribute("hidden", "true");
|
|
|
|
|
pref.setIntPref("mailnews.ui.threadpane.version", 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (ex) {
|
|
|
|
|
dump("UpgradeThreadPane: ex = " + ex + "\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function OnLoadThreadPane()
|
|
|
|
|
{
|
|
|
|
|
UpgradeThreadPaneUI();
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
function GetFolderDatasource()
|
1999-09-01 23:49:47 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
|
return folderTree.database;
|
1999-09-01 23:49:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Functions for accessing particular parts of the window*/
|
2002-03-29 02:46:01 +00:00
|
|
|
|
function GetFolderTree()
|
1999-09-01 23:49:47 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
if (! gFolderTree)
|
|
|
|
|
gFolderTree = document.getElementById("folderTree");
|
|
|
|
|
return gFolderTree;
|
1999-09-01 23:49:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-19 12:02:17 +00:00
|
|
|
|
function GetSearchInput()
|
|
|
|
|
{
|
|
|
|
|
if (gSearchInput) return gSearchInput;
|
|
|
|
|
gSearchInput = document.getElementById("searchInput");
|
|
|
|
|
return gSearchInput;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-05 21:17:22 +00:00
|
|
|
|
function GetMessagePane()
|
|
|
|
|
{
|
|
|
|
|
if (gMessagePane) return gMessagePane;
|
|
|
|
|
gMessagePane = document.getElementById("messagepanebox");
|
|
|
|
|
return gMessagePane;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-07 04:40:40 +00:00
|
|
|
|
function GetMessagePaneFrame()
|
|
|
|
|
{
|
|
|
|
|
if (gMessagePaneFrame) return gMessagePaneFrame;
|
2002-07-17 13:06:09 +00:00
|
|
|
|
gMessagePaneFrame = document.getElementById("messagepane").contentWindow;
|
2001-02-07 04:40:40 +00:00
|
|
|
|
return gMessagePaneFrame;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
|
function FindInSidebar(currentWindow, id)
|
|
|
|
|
{
|
|
|
|
|
var item = currentWindow.document.getElementById(id);
|
|
|
|
|
if(item)
|
|
|
|
|
return item;
|
|
|
|
|
|
1999-09-16 21:11:01 +00:00
|
|
|
|
for(var i = 0; i < currentWindow.frames.length; i++)
|
1999-09-01 23:49:47 +00:00
|
|
|
|
{
|
|
|
|
|
var frameItem = FindInSidebar(currentWindow.frames[i], id);
|
|
|
|
|
if(frameItem)
|
|
|
|
|
return frameItem;
|
|
|
|
|
}
|
2000-09-08 05:46:35 +00:00
|
|
|
|
|
|
|
|
|
return null;
|
1999-09-01 23:49:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-11 20:24:46 +00:00
|
|
|
|
function GetThreadAndMessagePaneSplitter()
|
|
|
|
|
{
|
|
|
|
|
if(gThreadAndMessagePaneSplitter) return gThreadAndMessagePaneSplitter;
|
2000-09-11 23:47:50 +00:00
|
|
|
|
var splitter = document.getElementById('threadpane-splitter');
|
1999-11-11 20:24:46 +00:00
|
|
|
|
gThreadAndMessagePaneSplitter = splitter;
|
|
|
|
|
return splitter;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-22 22:08:23 +00:00
|
|
|
|
function GetUnreadCountElement()
|
|
|
|
|
{
|
|
|
|
|
if(gUnreadCount) return gUnreadCount;
|
|
|
|
|
var unreadCount = document.getElementById('unreadMessageCount');
|
|
|
|
|
gUnreadCount = unreadCount;
|
|
|
|
|
return unreadCount;
|
|
|
|
|
}
|
|
|
|
|
function GetTotalCountElement()
|
|
|
|
|
{
|
|
|
|
|
if(gTotalCount) return gTotalCount;
|
|
|
|
|
var totalCount = document.getElementById('totalMessageCount');
|
|
|
|
|
gTotalCount = totalCount;
|
|
|
|
|
return totalCount;
|
|
|
|
|
}
|
2001-05-01 03:05:02 +00:00
|
|
|
|
|
1999-11-11 20:24:46 +00:00
|
|
|
|
function IsThreadAndMessagePaneSplitterCollapsed()
|
|
|
|
|
{
|
2001-05-01 03:05:02 +00:00
|
|
|
|
var messagePane = GetMessagePane();
|
|
|
|
|
try {
|
|
|
|
|
return (messagePane.getAttribute("collapsed") == "true");
|
1999-11-11 20:24:46 +00:00
|
|
|
|
}
|
2001-05-01 03:05:02 +00:00
|
|
|
|
catch (ex) {
|
1999-11-11 20:24:46 +00:00
|
|
|
|
return false;
|
2001-05-01 03:05:02 +00:00
|
|
|
|
}
|
1999-11-11 20:24:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-11 01:17:04 +00:00
|
|
|
|
function IsFolderPaneCollapsed()
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderPaneBox = GetFolderTree().parentNode;
|
2002-01-11 01:17:04 +00:00
|
|
|
|
return folderPaneBox.getAttribute("collapsed") == "true"
|
|
|
|
|
|| folderPaneBox.getAttribute("hidden") == "true";
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
|
function FindMessenger()
|
|
|
|
|
{
|
|
|
|
|
return messenger;
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-24 01:12:33 +00:00
|
|
|
|
function ClearThreadPaneSelection()
|
1999-09-13 21:11:45 +00:00
|
|
|
|
{
|
2001-03-24 01:12:33 +00:00
|
|
|
|
try {
|
|
|
|
|
if (gDBView) {
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView);
|
|
|
|
|
var treeSelection = treeView.selection;
|
|
|
|
|
if (treeSelection)
|
|
|
|
|
treeSelection.clearSelection();
|
2001-03-24 01:12:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (ex) {
|
|
|
|
|
dump("ClearThreadPaneSelection: ex = " + ex + "\n");
|
|
|
|
|
}
|
1999-09-13 21:11:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
|
function ClearMessagePane()
|
|
|
|
|
{
|
2000-04-21 14:22:16 +00:00
|
|
|
|
if(gHaveLoadedMessage)
|
|
|
|
|
{
|
2001-03-17 01:59:34 +00:00
|
|
|
|
gHaveLoadedMessage = false;
|
2000-04-21 14:22:16 +00:00
|
|
|
|
gCurrentDisplayedMessage = null;
|
2002-07-17 13:06:09 +00:00
|
|
|
|
if (GetMessagePaneFrame().location != "about:blank")
|
|
|
|
|
GetMessagePaneFrame().location = "about:blank";
|
2002-07-12 17:57:02 +00:00
|
|
|
|
// hide the message header view AND the message pane...
|
2000-04-21 14:22:16 +00:00
|
|
|
|
HideMessageHeaderPane();
|
|
|
|
|
}
|
1999-09-11 00:43:18 +00:00
|
|
|
|
}
|
1999-09-13 21:11:45 +00:00
|
|
|
|
|
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
function GetSelectedFolderIndex()
|
1999-11-11 00:23:29 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
2001-08-15 05:07:48 +00:00
|
|
|
|
var startIndex = {};
|
|
|
|
|
var endIndex = {};
|
2002-03-29 02:46:01 +00:00
|
|
|
|
folderTree.treeBoxObject.selection.getRangeAt(0, startIndex, endIndex);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
return startIndex.value;
|
1999-11-11 00:23:29 +00:00
|
|
|
|
}
|
1999-09-13 21:11:45 +00:00
|
|
|
|
|
2002-03-14 02:40:51 +00:00
|
|
|
|
// Function to change the highlighted row to where the mouse was clicked
|
|
|
|
|
// without loading the contents of the selected row.
|
|
|
|
|
// It will also keep the outline/dotted line in the original row.
|
2002-03-29 02:46:01 +00:00
|
|
|
|
function ChangeSelectionWithoutContentLoad(event, tree)
|
2002-03-14 02:40:51 +00:00
|
|
|
|
{
|
|
|
|
|
var row = {};
|
|
|
|
|
var col = {};
|
|
|
|
|
var elt = {};
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var treeBoxObj = tree.treeBoxObject;
|
|
|
|
|
var treeSelection = treeBoxObj.selection;
|
2002-03-14 02:40:51 +00:00
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
treeBoxObj.getCellAt(event.clientX, event.clientY, row, col, elt);
|
2002-03-16 03:12:58 +00:00
|
|
|
|
// make sure that row.value is valid so that it doesn't mess up
|
|
|
|
|
// the call to ensureRowIsVisible().
|
2002-03-29 02:46:01 +00:00
|
|
|
|
if((row.value >= 0) && !treeSelection.isSelected(row.value))
|
2002-03-14 02:40:51 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var saveCurrentIndex = treeSelection.currentIndex;
|
|
|
|
|
treeSelection.selectEventsSuppressed = true;
|
|
|
|
|
treeSelection.select(row.value);
|
|
|
|
|
treeSelection.currentIndex = saveCurrentIndex;
|
|
|
|
|
treeBoxObj.ensureRowIsVisible(row.value);
|
|
|
|
|
treeSelection.selectEventsSuppressed = false;
|
2002-03-14 02:40:51 +00:00
|
|
|
|
|
|
|
|
|
// Keep track of which row in the thread pane is currently selected.
|
2002-03-29 02:46:01 +00:00
|
|
|
|
if(tree.id == "threadTree")
|
2002-03-14 02:40:51 +00:00
|
|
|
|
gThreadPaneCurrentSelectedIndex = row.value;
|
|
|
|
|
}
|
|
|
|
|
event.preventBubble();
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
function TreeOnMouseDown(event)
|
2002-03-14 02:40:51 +00:00
|
|
|
|
{
|
|
|
|
|
// Detect right mouse click and change the highlight to the row
|
|
|
|
|
// where the click happened without loading the message headers in
|
|
|
|
|
// the Folder or Thread Pane.
|
|
|
|
|
if (event.button == 2)
|
2002-04-18 22:32:25 +00:00
|
|
|
|
{
|
|
|
|
|
gRightMouseButtonDown = true;
|
2002-03-14 02:40:51 +00:00
|
|
|
|
ChangeSelectionWithoutContentLoad(event, event.target.parentNode);
|
2002-04-18 22:32:25 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
gRightMouseButtonDown = false;
|
2002-03-14 02:40:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
|
function FolderPaneOnClick(event)
|
|
|
|
|
{
|
2001-08-15 05:07:48 +00:00
|
|
|
|
// we only care about button 0 (left click) events
|
|
|
|
|
if (event.button != 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
2001-08-15 05:07:48 +00:00
|
|
|
|
var row = {};
|
|
|
|
|
var col = {};
|
|
|
|
|
var elt = {};
|
2002-03-29 02:46:01 +00:00
|
|
|
|
folderTree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, elt);
|
2002-01-10 04:47:52 +00:00
|
|
|
|
if (row.value == -1)
|
|
|
|
|
return;
|
2001-08-15 05:07:48 +00:00
|
|
|
|
|
|
|
|
|
if (elt.value == "twisty")
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderResource = GetFolderResource(folderTree, row.value);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
if (!(folderTree.treeBoxObject.view.isContainerOpen(row.value)))
|
2001-08-15 05:07:48 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var isServer = GetFolderAttribute(folderTree, folderResource, "IsServer");
|
2001-08-15 05:07:48 +00:00
|
|
|
|
if (isServer == "true")
|
|
|
|
|
{
|
|
|
|
|
var server = msgFolder.server;
|
2001-08-21 06:18:58 +00:00
|
|
|
|
server.performExpand(msgWindow);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var serverType = GetFolderAttribute(folderTree, folderResource, "ServerType");
|
2001-08-15 05:07:48 +00:00
|
|
|
|
if (serverType == "imap")
|
|
|
|
|
{
|
|
|
|
|
var imapFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgImapMailFolder);
|
|
|
|
|
imapFolder.performExpand(msgWindow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-03-29 02:46:01 +00:00
|
|
|
|
else if ((event.originalTarget.localName == "treecol") ||
|
2001-08-29 22:14:18 +00:00
|
|
|
|
(event.originalTarget.localName == "slider") ||
|
2001-08-15 05:07:48 +00:00
|
|
|
|
(event.originalTarget.localName == "scrollbarbutton")) {
|
|
|
|
|
// clicking on the name column in the folder pane should not sort
|
|
|
|
|
event.preventBubble();
|
|
|
|
|
}
|
|
|
|
|
else if (event.detail == 2) {
|
|
|
|
|
FolderPaneDoubleClick(row.value, event);
|
2000-04-04 02:31:43 +00:00
|
|
|
|
}
|
2001-10-25 05:34:49 +00:00
|
|
|
|
else if (gDBView && gDBView.isSearchView)
|
|
|
|
|
{
|
2002-01-29 21:32:05 +00:00
|
|
|
|
onClearSearch();
|
2001-10-25 05:34:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
function FolderPaneDoubleClick(folderIndex, event)
|
2000-03-17 01:10:57 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
|
var folderResource = GetFolderResource(folderTree, folderIndex);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var isServer = GetFolderAttribute(folderTree, folderResource, "IsServer");
|
2000-04-04 02:31:43 +00:00
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
if (isServer == "true")
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
if (!(folderTree.treeBoxObject.view.isContainerOpen(folderIndex)))
|
2001-08-15 05:07:48 +00:00
|
|
|
|
{
|
|
|
|
|
var server = msgFolder.server;
|
2001-08-21 06:18:58 +00:00
|
|
|
|
server.performExpand(msgWindow);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Open a new msg window only if we are double clicking on
|
|
|
|
|
// folders or newsgroups.
|
2001-10-09 03:05:18 +00:00
|
|
|
|
MsgOpenNewWindowForFolder(folderResource.Value, -1 /* key */);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
|
|
|
|
|
// double clicking should not toggle the open / close state of the
|
|
|
|
|
// folder. this will happen if we don't prevent the event from
|
2002-03-29 02:46:01 +00:00
|
|
|
|
// bubbling to the default handler in tree.xml
|
2001-08-15 05:07:48 +00:00
|
|
|
|
event.preventBubble();
|
|
|
|
|
}
|
2000-03-17 01:10:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
function ChangeSelection(tree, newIndex)
|
2000-01-10 01:34:36 +00:00
|
|
|
|
{
|
2001-08-15 05:07:48 +00:00
|
|
|
|
if(newIndex >= 0)
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
tree.treeBoxObject.selection.select(newIndex);
|
|
|
|
|
tree.treeBoxObject.ensureRowIsVisible(newIndex);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
}
|
2000-01-10 01:34:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
function GetSelectedFolders()
|
|
|
|
|
{
|
|
|
|
|
var folderArray = [];
|
|
|
|
|
var k = 0;
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
|
var rangeCount = folderTree.treeBoxObject.selection.getRangeCount();
|
2001-08-15 05:07:48 +00:00
|
|
|
|
|
|
|
|
|
for(var i = 0; i < rangeCount; i++)
|
|
|
|
|
{
|
|
|
|
|
var startIndex = {};
|
|
|
|
|
var endIndex = {};
|
2002-03-29 02:46:01 +00:00
|
|
|
|
folderTree.treeBoxObject.selection.getRangeAt(i, startIndex, endIndex);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
for (var j = startIndex.value; j <= endIndex.value; j++)
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderResource = GetFolderResource(folderTree, j);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
folderArray[k++] = folderResource.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return folderArray;
|
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
|
|
|
|
|
function GetSelectedMsgFolders()
|
|
|
|
|
{
|
2001-08-15 05:07:48 +00:00
|
|
|
|
var folderArray = [];
|
|
|
|
|
var k = 0;
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
|
var rangeCount = folderTree.treeBoxObject.selection.getRangeCount();
|
2000-04-11 20:19:32 +00:00
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
for(var i = 0; i < rangeCount; i++)
|
|
|
|
|
{
|
|
|
|
|
var startIndex = {};
|
|
|
|
|
var endIndex = {};
|
2002-03-29 02:46:01 +00:00
|
|
|
|
folderTree.treeBoxObject.selection.getRangeAt(i, startIndex, endIndex);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
for (var j = startIndex.value; j <= endIndex.value; j++)
|
|
|
|
|
{
|
2002-04-10 11:57:39 +00:00
|
|
|
|
var folderResource = GetFolderResource(folderTree, j);
|
|
|
|
|
if (folderResource.Value != "http://home.netscape.com/NC-rdf#PageTitleFakeAccount") {
|
|
|
|
|
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
if(msgFolder)
|
2002-04-10 11:57:39 +00:00
|
|
|
|
folderArray[k++] = msgFolder;
|
|
|
|
|
}
|
2001-08-15 05:07:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
|
2001-08-15 05:07:48 +00:00
|
|
|
|
return folderArray;
|
2000-04-11 20:19:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-17 01:59:34 +00:00
|
|
|
|
function GetFirstSelectedMessage()
|
2000-08-26 20:54:51 +00:00
|
|
|
|
{
|
2001-03-17 01:59:34 +00:00
|
|
|
|
try {
|
2002-03-14 02:40:51 +00:00
|
|
|
|
// Use this instead of gDBView.URIForFirstSelectedMessage, else it
|
|
|
|
|
// will return the currentIndex message instead of the highlighted
|
|
|
|
|
// message.
|
|
|
|
|
return GetSelectedMessages()[0];
|
2001-03-17 01:59:34 +00:00
|
|
|
|
}
|
|
|
|
|
catch (ex) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2000-08-26 20:54:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-17 01:59:34 +00:00
|
|
|
|
function GetSelectedIndices(dbView)
|
2000-08-26 20:54:51 +00:00
|
|
|
|
{
|
2001-03-17 01:59:34 +00:00
|
|
|
|
try {
|
|
|
|
|
var indicesArray = {};
|
|
|
|
|
var length = {};
|
|
|
|
|
dbView.getIndicesForSelection(indicesArray,length);
|
|
|
|
|
return indicesArray.value;
|
|
|
|
|
}
|
|
|
|
|
catch (ex) {
|
|
|
|
|
dump("ex = " + ex + "\n");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2000-08-26 20:54:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
|
function GetSelectedMessages()
|
|
|
|
|
{
|
2001-03-17 01:59:34 +00:00
|
|
|
|
try {
|
|
|
|
|
var messageArray = {};
|
|
|
|
|
var length = {};
|
|
|
|
|
gDBView.getURIsForSelection(messageArray,length);
|
|
|
|
|
return messageArray.value;
|
|
|
|
|
}
|
|
|
|
|
catch (ex) {
|
|
|
|
|
dump("ex = " + ex + "\n");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GetLoadedMsgFolder()
|
|
|
|
|
{
|
2001-03-17 01:59:34 +00:00
|
|
|
|
if (!gDBView) return null;
|
|
|
|
|
return gDBView.msgFolder;
|
2000-04-11 20:19:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GetLoadedMessage()
|
|
|
|
|
{
|
2001-03-17 01:59:34 +00:00
|
|
|
|
try {
|
|
|
|
|
return gDBView.URIForFirstSelectedMessage;
|
|
|
|
|
}
|
|
|
|
|
catch (ex) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-26 20:54:51 +00:00
|
|
|
|
//Clear everything related to the current message. called after load start page.
|
|
|
|
|
function ClearMessageSelection()
|
|
|
|
|
{
|
2001-03-24 01:12:33 +00:00
|
|
|
|
ClearThreadPaneSelection();
|
2000-08-26 20:54:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
|
function GetCompositeDataSource(command)
|
|
|
|
|
{
|
2001-03-17 01:59:34 +00:00
|
|
|
|
if (command == "GetNewMessages" || command == "NewFolder" || command == "MarkAllMessagesRead")
|
2000-06-30 06:02:30 +00:00
|
|
|
|
return GetFolderDatasource();
|
2000-04-11 20:19:32 +00:00
|
|
|
|
|
|
|
|
|
return null;
|
2000-04-12 15:32:27 +00:00
|
|
|
|
}
|
2000-04-20 05:30:32 +00:00
|
|
|
|
|
2001-01-30 22:02:27 +00:00
|
|
|
|
function SetNextMessageAfterDelete()
|
2000-04-20 05:30:32 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var treeSelection = GetThreadTree().treeBoxObject.selection;
|
2002-03-14 02:40:51 +00:00
|
|
|
|
|
|
|
|
|
gThreadPaneDeleteOrMoveOccurred = true;
|
2002-03-29 02:46:01 +00:00
|
|
|
|
if (treeSelection.isSelected(treeSelection.currentIndex))
|
2001-04-30 03:17:34 +00:00
|
|
|
|
gNextMessageViewIndexAfterDelete = gDBView.msgToSelectAfterDelete;
|
2002-03-29 02:46:01 +00:00
|
|
|
|
else if (treeSelection.currentIndex > gThreadPaneCurrentSelectedIndex)
|
2002-03-14 02:40:51 +00:00
|
|
|
|
// Since the currentIndex (the row with the outline/dotted line) is greater
|
|
|
|
|
// than the currently selected row (the row that is highlighted), we need to
|
|
|
|
|
// make sure that upon a Delete or Move of the selected row, the highlight
|
|
|
|
|
// returns to the currentIndex'ed row. It is necessary to subtract 1
|
|
|
|
|
// because the row being deleted is above the row with the currentIndex.
|
|
|
|
|
// If the subtraction is not done, then the highlight will end up on the
|
|
|
|
|
// row listed after the currentIndex'ed row.
|
2002-03-29 02:46:01 +00:00
|
|
|
|
gNextMessageViewIndexAfterDelete = treeSelection.currentIndex - 1;
|
2002-03-14 02:40:51 +00:00
|
|
|
|
else
|
2002-03-29 02:46:01 +00:00
|
|
|
|
gNextMessageViewIndexAfterDelete = treeSelection.currentIndex;
|
2000-04-20 05:30:32 +00:00
|
|
|
|
}
|
2000-04-21 14:22:16 +00:00
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
function EnsureAllAncestorsAreExpanded(tree, resource)
|
2001-08-22 03:24:52 +00:00
|
|
|
|
{
|
|
|
|
|
// get the parent of the desired folder, and then try to get
|
2002-03-29 02:46:01 +00:00
|
|
|
|
// the index of the parent in the tree
|
2001-08-22 03:24:52 +00:00
|
|
|
|
var folder = resource.QueryInterface(Components.interfaces.nsIFolder);
|
2001-08-23 01:10:05 +00:00
|
|
|
|
|
|
|
|
|
// if this is a server, there are no ancestors, so stop.
|
|
|
|
|
var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
|
if (msgFolder.isServer)
|
|
|
|
|
return;
|
|
|
|
|
|
2001-08-22 03:24:52 +00:00
|
|
|
|
var parentFolderResource = RDF.GetResource(folder.parent.URI);
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderIndex = GetFolderIndex(tree, parentFolderResource);
|
2001-08-22 03:24:52 +00:00
|
|
|
|
|
|
|
|
|
if (folderIndex == -1) {
|
|
|
|
|
// if we couldn't find the parent, recurse
|
2002-03-29 02:46:01 +00:00
|
|
|
|
EnsureAllAncestorsAreExpanded(tree, parentFolderResource);
|
2001-08-22 03:24:52 +00:00
|
|
|
|
// ok, now we should be able to find the parent
|
2002-03-29 02:46:01 +00:00
|
|
|
|
folderIndex = GetFolderIndex(tree, parentFolderResource);
|
2001-08-22 03:24:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if the parent isn't open, open it
|
2002-03-29 02:46:01 +00:00
|
|
|
|
if (!(tree.treeBoxObject.view.isContainerOpen(folderIndex)))
|
|
|
|
|
tree.treeBoxObject.view.toggleOpenState(folderIndex);
|
2001-08-22 03:24:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-28 20:10:36 +00:00
|
|
|
|
function SelectFolder(folderUri)
|
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var folderTree = GetFolderTree();
|
2001-08-15 05:07:48 +00:00
|
|
|
|
var folderResource = RDF.GetResource(folderUri);
|
2001-08-22 03:24:52 +00:00
|
|
|
|
|
|
|
|
|
// before we can select a folder, we need to make sure it is "visible"
|
2002-03-29 02:46:01 +00:00
|
|
|
|
// in the tree. to do that, we need to ensure that all its
|
2001-08-22 03:24:52 +00:00
|
|
|
|
// ancestors are expanded
|
2002-03-29 02:46:01 +00:00
|
|
|
|
EnsureAllAncestorsAreExpanded(folderTree, folderResource);
|
|
|
|
|
var folderIndex = GetFolderIndex(folderTree, folderResource);
|
|
|
|
|
ChangeSelection(folderTree, folderIndex);
|
2000-04-28 20:10:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SelectMessage(messageUri)
|
|
|
|
|
{
|
2002-02-05 03:46:15 +00:00
|
|
|
|
var msgHdr = messenger.messageServiceFromURI(messageUri).messageURIToMsgHdr(messageUri);
|
|
|
|
|
if (msgHdr)
|
|
|
|
|
gDBView.selectMsgByKey(msgHdr.messageKey);
|
2000-04-28 20:10:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-29 04:44:50 +00:00
|
|
|
|
function ReloadWithAllParts()
|
|
|
|
|
{
|
|
|
|
|
gDBView.reloadMessageWithAllParts();
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-01 21:58:24 +00:00
|
|
|
|
function ReloadMessage()
|
2000-04-21 14:22:16 +00:00
|
|
|
|
{
|
2001-03-17 01:59:34 +00:00
|
|
|
|
gDBView.reloadMessage();
|
2000-04-21 14:22:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-08-26 20:54:51 +00:00
|
|
|
|
function SetBusyCursor(window, enable)
|
|
|
|
|
{
|
2002-02-09 22:11:23 +00:00
|
|
|
|
// setCursor() is only available for chrome windows.
|
|
|
|
|
// However one of our frames is the start page which
|
|
|
|
|
// is a non-chrome window, so check if this window has a
|
|
|
|
|
// setCursor method
|
|
|
|
|
if ("setCursor" in window) {
|
|
|
|
|
if (enable)
|
|
|
|
|
window.setCursor("wait");
|
|
|
|
|
else
|
|
|
|
|
window.setCursor("auto");
|
|
|
|
|
}
|
2000-04-21 14:22:16 +00:00
|
|
|
|
|
2000-09-08 21:57:43 +00:00
|
|
|
|
var numFrames = window.frames.length;
|
2000-08-26 20:54:51 +00:00
|
|
|
|
for(var i = 0; i < numFrames; i++)
|
|
|
|
|
SetBusyCursor(window.frames[i], enable);
|
|
|
|
|
}
|
2001-03-17 01:59:34 +00:00
|
|
|
|
|
|
|
|
|
function GetDBView()
|
|
|
|
|
{
|
|
|
|
|
return gDBView;
|
|
|
|
|
}
|
2001-08-15 05:07:48 +00:00
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
function GetFolderResource(tree, index)
|
2001-08-15 05:07:48 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
return tree.builderView.getResourceAtIndex(index);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
function GetFolderIndex(tree, resource)
|
2001-08-15 05:07:48 +00:00
|
|
|
|
{
|
2002-03-29 02:46:01 +00:00
|
|
|
|
return tree.builderView.getIndexOfResource(resource);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
|
function GetFolderAttribute(tree, source, attribute)
|
2001-08-15 05:07:48 +00:00
|
|
|
|
{
|
|
|
|
|
var property = RDF.GetResource("http://home.netscape.com/NC-rdf#" + attribute);
|
2002-03-29 02:46:01 +00:00
|
|
|
|
var target = tree.database.GetTarget(source, property, true);
|
2001-08-15 05:07:48 +00:00
|
|
|
|
if (target)
|
|
|
|
|
target = target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
|
|
|
|
return target;
|
|
|
|
|
}
|
2002-07-12 17:57:02 +00:00
|
|
|
|
|