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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This is where functions related to the 3 pane window are kept */
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
|
2000-02-04 01:56:38 +00:00
|
|
|
var showPerformance;
|
|
|
|
var msgNavigationService;
|
|
|
|
|
1999-09-15 08:29:01 +00:00
|
|
|
var gFolderTree;
|
1999-09-15 08:39:28 +00:00
|
|
|
var gThreadTree;
|
2000-10-05 21:17:22 +00:00
|
|
|
var gMessagePane;
|
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;
|
1999-11-11 00:23:29 +00:00
|
|
|
var gCurrentLoadingFolderIsThreaded = false;
|
|
|
|
var gCurrentLoadingFolderSortID ="";
|
2000-03-14 05:38:51 +00:00
|
|
|
var gCurrentLoadingFolderSortDirection = null;
|
2001-01-04 00:12:36 +00:00
|
|
|
var gCurrentLoadingFolderViewType = "";
|
1999-09-15 08:29:01 +00:00
|
|
|
|
2000-02-04 15:19:57 +00:00
|
|
|
var gCurrentDisplayedMessage = null;
|
2000-02-16 00:39:23 +00:00
|
|
|
var gNextMessageAfterDelete = null;
|
2000-11-05 02:29:47 +00:00
|
|
|
var gNextMessageAfterLoad = false;
|
1999-12-24 01:08:05 +00:00
|
|
|
|
2000-03-14 05:38:51 +00:00
|
|
|
var gActiveThreadPaneSortColumn = "";
|
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
var gStartFolderUri = null;
|
|
|
|
|
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;
|
|
|
|
|
1999-09-13 21:11:45 +00:00
|
|
|
// the folderListener object
|
|
|
|
var folderListener = {
|
1999-11-11 00:23:29 +00:00
|
|
|
OnItemAdded: function(parentItem, item, view) {},
|
1999-09-13 21:11:45 +00:00
|
|
|
|
1999-11-11 00:23:29 +00:00
|
|
|
OnItemRemoved: function(parentItem, item, view){},
|
1999-09-13 21:11:45 +00:00
|
|
|
|
|
|
|
OnItemPropertyChanged: function(item, property, oldValue, newValue) {},
|
|
|
|
|
1999-11-22 22:08:23 +00:00
|
|
|
OnItemIntPropertyChanged: function(item, property, oldValue, newValue)
|
|
|
|
{
|
2000-03-14 05:38:51 +00:00
|
|
|
var currentLoadedFolder = GetThreadTreeFolder();
|
|
|
|
var currentURI = currentLoadedFolder.getAttribute('ref');
|
|
|
|
|
|
|
|
//if we don't have a folder loaded, don't bother.
|
|
|
|
if(currentURI)
|
1999-11-22 22:08:23 +00:00
|
|
|
{
|
2000-03-14 05:38:51 +00:00
|
|
|
if(property.GetUnicode() == "TotalMessages" || property.GetUnicode() == "TotalUnreadMessages")
|
1999-11-22 22:08:23 +00:00
|
|
|
{
|
2000-09-08 04:22:01 +00:00
|
|
|
var folder = item.QueryInterface(Components.interfaces.nsIMsgFolder);
|
2000-03-14 05:38:51 +00:00
|
|
|
if(folder)
|
1999-11-22 22:08:23 +00:00
|
|
|
{
|
2000-03-14 05:38:51 +00:00
|
|
|
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
if(folderResource)
|
1999-11-22 22:08:23 +00:00
|
|
|
{
|
2000-03-14 05:38:51 +00:00
|
|
|
var folderURI = folderResource.Value;
|
|
|
|
if(currentURI == folderURI)
|
|
|
|
{
|
|
|
|
UpdateStatusMessageCounts(folder);
|
|
|
|
}
|
1999-11-22 22:08:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-14 05:38:51 +00:00
|
|
|
}
|
1999-11-22 22:08:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2000-03-14 05:38:51 +00:00
|
|
|
}
|
1999-11-22 22:08:23 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) {},
|
|
|
|
|
2000-01-20 22:56:00 +00:00
|
|
|
OnItemUnicharPropertyChanged: function(item, property, oldValue, newValue){},
|
1999-09-16 21:11:01 +00:00
|
|
|
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {},
|
|
|
|
|
2000-05-14 20:36:26 +00:00
|
|
|
OnItemEvent: function(folder, event) {
|
|
|
|
if (event.GetUnicode() == "FolderLoaded") {
|
|
|
|
|
1999-09-16 21:11:01 +00:00
|
|
|
if(folder)
|
|
|
|
{
|
|
|
|
var resource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
if(resource)
|
|
|
|
{
|
|
|
|
var uri = resource.Value;
|
2000-11-05 02:29:47 +00:00
|
|
|
dump("In OnFolderLoaded for " + uri +"\n");
|
2001-01-05 08:34:29 +00:00
|
|
|
|
2000-01-09 19:47:58 +00:00
|
|
|
if(uri == gCurrentFolderToReroot)
|
1999-09-16 21:11:01 +00:00
|
|
|
{
|
2000-01-09 19:47:58 +00:00
|
|
|
gCurrentFolderToReroot="";
|
1999-09-21 21:04:52 +00:00
|
|
|
var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
if(msgFolder)
|
1999-10-28 23:27:21 +00:00
|
|
|
{
|
1999-10-20 21:58:21 +00:00
|
|
|
msgFolder.endFolderLoading();
|
2001-01-04 00:12:36 +00:00
|
|
|
RerootFolder(uri, msgFolder, gCurrentLoadingFolderIsThreaded, gCurrentLoadingFolderSortID, gCurrentLoadingFolderSortDirection, gCurrentLoadingFolderViewType);
|
1999-12-08 23:00:22 +00:00
|
|
|
gCurrentLoadingFolderIsThreaded = false;
|
1999-11-11 00:23:29 +00:00
|
|
|
gCurrentLoadingFolderSortID = "";
|
2000-03-14 05:38:51 +00:00
|
|
|
gCurrentLoadingFolderSortDirection = null;
|
2001-01-04 00:12:36 +00:00
|
|
|
gCurrentLoadingFolderViewType = "";
|
2000-08-26 20:54:51 +00:00
|
|
|
|
2000-11-05 02:29:47 +00:00
|
|
|
if (gNextMessageAfterLoad) {
|
|
|
|
gNextMessageAfterLoad = false;
|
|
|
|
|
|
|
|
GoNextMessage(navigateUnread, true);
|
|
|
|
|
|
|
|
msgNavigationService.EnsureDocumentIsLoaded(document);
|
|
|
|
SetFocusThreadPane();
|
|
|
|
PositionThreadPane();
|
|
|
|
}
|
1999-10-28 23:27:21 +00:00
|
|
|
}
|
1999-09-16 21:11:01 +00:00
|
|
|
}
|
2000-01-09 19:47:58 +00:00
|
|
|
if(uri == gCurrentLoadingFolderURI)
|
|
|
|
{
|
|
|
|
gCurrentLoadingFolderURI = "";
|
|
|
|
//Now let's select the first new message if there is one
|
2000-01-28 23:25:17 +00:00
|
|
|
var beforeScrollToNew = new Date();
|
2000-02-04 01:56:38 +00:00
|
|
|
msgNavigationService.EnsureDocumentIsLoaded(document);
|
|
|
|
|
2000-01-12 07:18:58 +00:00
|
|
|
ScrollToFirstNewMessage();
|
2000-01-28 23:25:17 +00:00
|
|
|
var afterScrollToNew = new Date();
|
|
|
|
var timeToScroll = (afterScrollToNew.getTime() - beforeScrollToNew.getTime())/1000;
|
|
|
|
|
|
|
|
|
|
|
|
var afterFolderLoadTime = new Date();
|
|
|
|
var timeToLoad = (afterFolderLoadTime.getTime() - gBeforeFolderLoadTime.getTime())/1000;
|
|
|
|
if(showPerformance)
|
|
|
|
{
|
|
|
|
dump("Time to load " + uri + " is " + timeToLoad + " seconds\n");
|
|
|
|
dump("of which scrolling to new is" + timeToScroll + "seconds\n");
|
|
|
|
}
|
2000-08-26 20:54:51 +00:00
|
|
|
SetBusyCursor(window, false);
|
2000-01-09 19:47:58 +00:00
|
|
|
}
|
1999-09-16 21:11:01 +00:00
|
|
|
}
|
2000-01-09 19:47:58 +00:00
|
|
|
|
1999-09-16 21:11:01 +00:00
|
|
|
}
|
2000-05-14 20:36:26 +00:00
|
|
|
} else if (event.GetUnicode() == "DeleteOrMoveMsgCompleted") {
|
2000-08-14 14:40:33 +00:00
|
|
|
HandleDeleteOrMoveMsgCompleted(folder);
|
2000-09-21 00:14:24 +00:00
|
|
|
}
|
|
|
|
else if (event.GetUnicode() == "DeleteOrMoveMsgFailed") {
|
|
|
|
HandleDeleteOrMoveMsgFailed(folder);
|
|
|
|
}
|
|
|
|
|
2000-08-14 14:40:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-21 00:14:24 +00:00
|
|
|
function HandleDeleteOrMoveMsgFailed(folder)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(IsCurrentLoadedFolder(folder))
|
|
|
|
{
|
|
|
|
if(gNextMessageAfterDelete)
|
|
|
|
{
|
|
|
|
gNextMessageAfterDelete = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-14 14:40:33 +00:00
|
|
|
function HandleDeleteOrMoveMsgCompleted(folder)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(IsCurrentLoadedFolder(folder))
|
|
|
|
{
|
|
|
|
msgNavigationService.EnsureDocumentIsLoaded(document);
|
|
|
|
if(gNextMessageAfterDelete)
|
2000-02-16 00:39:23 +00:00
|
|
|
{
|
2000-08-14 14:40:33 +00:00
|
|
|
var nextMessage = document.getElementById(gNextMessageAfterDelete);
|
|
|
|
gNextMessageAfterDelete = null;
|
|
|
|
SelectNextMessage(nextMessage);
|
|
|
|
var threadTree = GetThreadTree();
|
|
|
|
if(threadTree)
|
|
|
|
threadTree.ensureElementIsVisible(nextMessage);
|
|
|
|
}
|
|
|
|
//if there's nothing to select then see if the tree has any messages.
|
|
|
|
//if not, then clear the message pane.
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var tree = GetThreadTree();
|
|
|
|
var topmost = msgNavigationService.FindFirstMessage(tree);
|
|
|
|
if(!topmost)
|
|
|
|
ClearMessagePane()
|
2000-02-16 00:39:23 +00:00
|
|
|
}
|
|
|
|
}
|
2000-08-14 14:40:33 +00:00
|
|
|
|
2000-02-16 00:39:23 +00:00
|
|
|
}
|
|
|
|
|
2000-08-14 14:40:33 +00:00
|
|
|
|
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;
|
|
|
|
var currentLoadedFolder = GetThreadTreeFolder();
|
|
|
|
var currentURI = currentLoadedFolder.getAttribute('ref');
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
/* Functions related to startup */
|
|
|
|
function OnLoadMessenger()
|
|
|
|
{
|
2000-02-04 01:56:38 +00:00
|
|
|
var beforeLoadMessenger = new Date();
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
CreateMailWindowGlobals();
|
|
|
|
Create3PaneGlobals();
|
2000-01-06 00:53:12 +00:00
|
|
|
verifyAccounts();
|
1999-09-11 01:54:15 +00:00
|
|
|
|
2000-01-06 00:53:12 +00:00
|
|
|
loadStartPage();
|
1999-10-27 22:38:47 +00:00
|
|
|
InitMsgWindow();
|
|
|
|
|
1999-10-29 04:39:06 +00:00
|
|
|
messenger.SetWindow(window, msgWindow);
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
InitializeDataSources();
|
1999-09-01 23:49:47 +00:00
|
|
|
InitPanes();
|
|
|
|
|
2000-08-30 14:51:10 +00:00
|
|
|
accountManager.SetSpecialFoldersForIdentities();
|
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.
|
2000-12-21 01:26:18 +00:00
|
|
|
if ("arguments" in window && window.arguments[0])
|
2000-03-17 01:10:57 +00:00
|
|
|
{
|
|
|
|
gStartFolderUri = window.arguments[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gStartFolderUri = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
var id = null;
|
|
|
|
var headerchoice = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
headerchoice = pref.GetIntPref("mail.show_headers");
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("failed to get the header pref\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (headerchoice) {
|
|
|
|
case 2:
|
|
|
|
id = "viewallheaders";
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
id = "viewbriefheaders";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
id = "viewnormalheaders";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
id = "viewnormalheaders";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
var menuitem = document.getElementById(id);
|
|
|
|
|
|
|
|
try {
|
|
|
|
// not working right yet. see bug #??????
|
|
|
|
// menuitem.setAttribute("checked", "true");
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("failed to set the view headers menu item\n");
|
|
|
|
}
|
2000-02-04 01:56:38 +00:00
|
|
|
|
2000-04-21 14:22:16 +00:00
|
|
|
gHaveLoadedMessage = false;
|
|
|
|
|
2000-09-22 02:51:23 +00:00
|
|
|
//Set focus to the Thread Pane the first time the window is opened.
|
|
|
|
SetFocusThreadPane();
|
|
|
|
|
2000-02-04 01:56:38 +00:00
|
|
|
var afterLoadMessenger = new Date();
|
|
|
|
|
|
|
|
var timeToLoad = (afterLoadMessenger.getTime() - beforeLoadMessenger.getTime())/1000;
|
|
|
|
if(showPerformance)
|
|
|
|
{
|
|
|
|
dump("Time in OnLoadMessger is " + timeToLoad + " seconds\n");
|
|
|
|
}
|
2000-09-22 02:51:23 +00:00
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function OnUnloadMessenger()
|
|
|
|
{
|
|
|
|
dump("\nOnUnload from XUL\nClean up ...\n");
|
2000-03-14 05:38:51 +00:00
|
|
|
|
2000-04-28 20:10:36 +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
|
|
|
{
|
|
|
|
showPerformance = pref.GetBoolPref('mail.showMessengerPerformance');
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
msgNavigationService = Components.classes['@mozilla.org/messenger/msgviewnavigationservice;1'].getService();
|
2000-02-04 01:56:38 +00:00
|
|
|
msgNavigationService= msgNavigationService.QueryInterface(Components.interfaces.nsIMsgViewNavigationService);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-09-11 01:54:15 +00:00
|
|
|
|
2000-04-04 05:47:24 +00:00
|
|
|
function PerformExpandForAllOpenServers(tree)
|
|
|
|
{
|
2000-04-04 05:53:39 +00:00
|
|
|
//dump("PerformExpandForAllOpenServers()\n");
|
2000-04-04 05:47:24 +00:00
|
|
|
|
|
|
|
var uri = null;
|
|
|
|
var open = null;
|
|
|
|
var treechild = null;
|
|
|
|
var server = null;
|
|
|
|
|
|
|
|
if ( tree && tree.childNodes ) {
|
|
|
|
for ( var i = tree.childNodes.length - 1; i >= 0; i-- ) {
|
|
|
|
treechild = tree.childNodes[i];
|
2000-06-07 00:50:19 +00:00
|
|
|
if (treechild.localName == 'treechildren') {
|
2000-04-04 05:47:24 +00:00
|
|
|
var treeitems = treechild.childNodes;
|
|
|
|
for ( var j = treeitems.length - 1; j >= 0; j--) {
|
|
|
|
open = treeitems[j].getAttribute('open');
|
2000-04-04 05:53:39 +00:00
|
|
|
//dump("open="+open+"\n");
|
2000-04-04 05:47:24 +00:00
|
|
|
if (open == "true") {
|
|
|
|
var isServer = (treeitems[j].getAttribute('IsServer') == "true");
|
2000-04-04 05:53:39 +00:00
|
|
|
//dump("isServer="+isServer+"\n");
|
2000-04-04 05:47:24 +00:00
|
|
|
if (isServer) {
|
|
|
|
uri = treeitems[j].getAttribute('id');
|
2000-04-04 05:53:39 +00:00
|
|
|
//dump("uri="+uri+"\n");
|
2000-04-04 05:47:24 +00:00
|
|
|
server = GetServer(uri);
|
|
|
|
if (server) {
|
2000-06-09 04:55:29 +00:00
|
|
|
// don't do this for imap servers.
|
|
|
|
// see bug #41943
|
|
|
|
if (server.type != "imap") {
|
|
|
|
//dump("PerformExpand on " + uri + "\n");
|
|
|
|
server.PerformExpand(msgWindow);
|
|
|
|
}
|
2000-04-04 05:47:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
function loadStartFolder(startFolderUri)
|
1999-09-14 06:27:36 +00:00
|
|
|
{
|
2000-01-10 01:34:36 +00:00
|
|
|
//First get default account
|
2000-01-20 22:56:00 +00:00
|
|
|
try
|
|
|
|
{
|
2000-03-17 01:10:57 +00:00
|
|
|
if(!startFolderUri)
|
|
|
|
{
|
|
|
|
var defaultAccount = accountManager.defaultAccount;
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
var server = defaultAccount.incomingServer;
|
|
|
|
var rootFolder = server.RootFolder;
|
|
|
|
var rootMsgFolder = rootFolder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
//now find Inbox
|
|
|
|
var outNumFolders = new Object();
|
|
|
|
var inboxFolder = rootMsgFolder.getFoldersWithFlag(0x1000, 1, outNumFolders);
|
|
|
|
if(!inboxFolder) return;
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
var resource = inboxFolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
2000-09-08 05:46:35 +00:00
|
|
|
startFolderUri = resource.Value;
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
//first, let's see if it's already in the dom. This will make life easier.
|
|
|
|
//We need to make sure content is built by this time
|
|
|
|
}
|
2000-02-04 01:56:38 +00:00
|
|
|
msgNavigationService.EnsureDocumentIsLoaded(document);
|
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
var startFolder = document.getElementById(startFolderUri);
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-01-20 22:56:00 +00:00
|
|
|
//if it's not here we will have to make sure it's open.
|
2000-03-17 01:10:57 +00:00
|
|
|
if(!startFolder)
|
2000-01-20 22:56:00 +00:00
|
|
|
{
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-01-20 22:56:00 +00:00
|
|
|
}
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-01-20 22:56:00 +00:00
|
|
|
var folderTree= GetFolderTree();
|
2000-03-17 01:10:57 +00:00
|
|
|
ChangeSelection(folderTree, startFolder);
|
2000-04-04 05:47:24 +00:00
|
|
|
|
|
|
|
// because the "open" state persists, we'll call
|
|
|
|
// PerformExpand() for all servers that are open at startup.
|
|
|
|
PerformExpandForAllOpenServers(folderTree);
|
2000-01-20 22:56:00 +00:00
|
|
|
}
|
|
|
|
catch(ex)
|
|
|
|
{
|
2000-02-04 01:56:38 +00:00
|
|
|
dump(ex);
|
2000-01-20 22:56:00 +00:00
|
|
|
dump('Exception in LoadStartFolder caused by no default account. We know about this\n');
|
|
|
|
}
|
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
|
|
|
|
|
|
|
mailSession.AddFolderListener(folderListener);
|
|
|
|
} catch (ex) {
|
1999-10-28 23:27:21 +00:00
|
|
|
dump("Error adding to session\n");
|
1999-09-15 04:57:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-12 02:25:35 +00:00
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
function InitPanes()
|
|
|
|
{
|
1999-09-16 21:11:01 +00:00
|
|
|
var threadTree = GetThreadTree();
|
|
|
|
if(threadTree);
|
|
|
|
OnLoadThreadPane(threadTree);
|
|
|
|
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
if(folderTree)
|
|
|
|
OnLoadFolderPane(folderTree);
|
1999-11-02 03:55:59 +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);
|
|
|
|
}
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
function OnLoadFolderPane(folderTree)
|
|
|
|
{
|
1999-09-15 08:29:01 +00:00
|
|
|
gFolderTree = folderTree;
|
1999-10-29 20:46:15 +00:00
|
|
|
SortFolderPane('FolderColumn', 'http://home.netscape.com/NC-rdf#FolderTreeName');
|
1999-12-21 23:38:31 +00:00
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
//Add folderDataSource and accountManagerDataSource to folderPane
|
|
|
|
accountManagerDataSource = accountManagerDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
|
|
|
folderDataSource = folderDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
2000-06-30 06:02:30 +00:00
|
|
|
var database = GetFolderDatasource();
|
1999-10-27 22:38:47 +00:00
|
|
|
|
|
|
|
database.AddDataSource(accountManagerDataSource);
|
|
|
|
database.AddDataSource(folderDataSource);
|
1999-09-01 23:49:47 +00:00
|
|
|
folderTree.setAttribute('ref', 'msgaccounts:/');
|
|
|
|
}
|
|
|
|
|
2000-06-30 06:02:30 +00:00
|
|
|
function GetFolderDatasource()
|
|
|
|
{
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
var db = folderTree.database;
|
|
|
|
if (!db) return false;
|
|
|
|
return db;
|
|
|
|
}
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
function OnLoadThreadPane(threadTree)
|
|
|
|
{
|
1999-09-15 08:39:28 +00:00
|
|
|
gThreadTree = threadTree;
|
2000-01-06 00:47:02 +00:00
|
|
|
//Sort by date by default
|
1999-09-01 23:49:47 +00:00
|
|
|
|
|
|
|
//Add message data source
|
|
|
|
messageDataSource = messageDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
|
|
|
threadTree.database.AddDataSource(messageDataSource);
|
|
|
|
|
2000-02-12 00:55:14 +00:00
|
|
|
//FIX ME: Tempory patch for bug 24182
|
|
|
|
//ShowThreads(false);
|
|
|
|
setTimeout("ShowThreads(false);", 0);
|
1999-09-01 23:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Functions for accessing particular parts of the window*/
|
|
|
|
function GetFolderTree()
|
|
|
|
{
|
1999-09-15 08:29:01 +00:00
|
|
|
if (gFolderTree) return gFolderTree;
|
|
|
|
|
1999-09-16 21:11:01 +00:00
|
|
|
var folderTree = document.getElementById('folderTree');
|
1999-09-15 08:39:28 +00:00
|
|
|
gFolderTree = folderTree;
|
1999-09-01 23:49:47 +00:00
|
|
|
return folderTree;
|
|
|
|
}
|
|
|
|
|
2000-10-05 21:17:22 +00:00
|
|
|
function GetMessagePane()
|
|
|
|
{
|
|
|
|
if (gMessagePane) return gMessagePane;
|
|
|
|
gMessagePane = document.getElementById("messagepanebox");
|
|
|
|
return gMessagePane;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
1999-11-11 20:24:46 +00:00
|
|
|
function IsThreadAndMessagePaneSplitterCollapsed()
|
|
|
|
{
|
|
|
|
var splitter = GetThreadAndMessagePaneSplitter();
|
|
|
|
if(splitter)
|
|
|
|
{
|
|
|
|
var state = splitter.getAttribute('state');
|
|
|
|
return (state == "collapsed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
function FindMessenger()
|
|
|
|
{
|
|
|
|
return messenger;
|
|
|
|
}
|
|
|
|
|
|
|
|
function RefreshThreadTreeView()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
SetBusyCursor(window, true);
|
|
|
|
|
2000-02-04 01:56:38 +00:00
|
|
|
var selection = SaveThreadPaneSelection();
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
var currentFolder = GetThreadTreeFolder();
|
|
|
|
var currentFolderID = currentFolder.getAttribute('ref');
|
1999-10-27 22:38:47 +00:00
|
|
|
ClearThreadTreeSelection();
|
1999-09-01 23:49:47 +00:00
|
|
|
currentFolder.setAttribute('ref', currentFolderID);
|
2000-02-04 01:56:38 +00:00
|
|
|
|
|
|
|
RestoreThreadPaneSelection(selection);
|
2000-08-26 20:54:51 +00:00
|
|
|
SetBusyCursor(window, false);
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
}
|
|
|
|
|
1999-09-13 21:11:45 +00:00
|
|
|
function ClearThreadTreeSelection()
|
|
|
|
{
|
|
|
|
var tree = GetThreadTree();
|
|
|
|
if(tree)
|
1999-09-16 21:11:01 +00:00
|
|
|
{
|
1999-09-13 21:11:45 +00:00
|
|
|
tree.clearItemSelection();
|
1999-09-16 21:11:01 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
gCurrentDisplayedMessage = null;
|
|
|
|
if (window.frames["messagepane"].location != "about:blank")
|
|
|
|
window.frames["messagepane"].location = "about:blank";
|
|
|
|
// hide the message header view AND the message pane...
|
|
|
|
HideMessageHeaderPane();
|
|
|
|
}
|
1999-09-11 00:43:18 +00:00
|
|
|
}
|
1999-09-13 21:11:45 +00:00
|
|
|
|
|
|
|
|
1999-11-11 00:23:29 +00:00
|
|
|
function GetSelectedFolder()
|
|
|
|
{
|
|
|
|
var tree = GetFolderTree();
|
|
|
|
var selection = tree.selectedItems;
|
|
|
|
if(selection.length > 0)
|
|
|
|
return selection[0];
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
1999-09-13 21:11:45 +00:00
|
|
|
|
2000-04-04 05:47:24 +00:00
|
|
|
function GetServer(uri)
|
2000-04-04 02:31:43 +00:00
|
|
|
{
|
2000-08-10 22:02:52 +00:00
|
|
|
if (!uri) return null;
|
2000-04-04 02:31:43 +00:00
|
|
|
try {
|
|
|
|
var folder = GetMsgFolderFromUri(uri);
|
2000-04-04 05:47:24 +00:00
|
|
|
return folder.server;
|
2000-04-04 02:31:43 +00:00
|
|
|
}
|
|
|
|
catch (ex) {
|
2000-04-04 05:47:24 +00:00
|
|
|
dump("GetServer("+uri+") failed, ex="+ex+"\n");
|
2000-04-04 02:31:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2000-03-17 01:10:57 +00:00
|
|
|
function FolderPaneOnClick(event)
|
|
|
|
{
|
2000-04-22 17:13:59 +00:00
|
|
|
debug("in FolderPaneClick()\n");
|
|
|
|
|
2000-09-07 08:17:32 +00:00
|
|
|
var t = event.originalTarget;
|
2000-09-08 21:57:43 +00:00
|
|
|
var item;
|
|
|
|
var uri;
|
2000-04-04 02:31:43 +00:00
|
|
|
|
2000-09-07 08:17:32 +00:00
|
|
|
if (t.getAttribute('twisty') == 'true') {
|
2000-04-04 02:31:43 +00:00
|
|
|
// The twisty is nested three below the treeitem:
|
|
|
|
// <treeitem>
|
|
|
|
// <treerow>
|
|
|
|
// <treecell>
|
2000-11-25 01:19:03 +00:00
|
|
|
// <button class="tree-cell-twisty"> <!-- anonymous -->
|
2000-09-07 08:17:32 +00:00
|
|
|
var treeitem = t.parentNode.parentNode.parentNode;
|
2000-04-04 02:31:43 +00:00
|
|
|
var open = treeitem.getAttribute('open');
|
|
|
|
if(open == "true") {
|
2000-04-04 05:53:39 +00:00
|
|
|
//dump("twisty open\n");
|
2000-04-04 02:31:43 +00:00
|
|
|
|
2000-09-08 21:57:43 +00:00
|
|
|
item = t.parentNode.parentNode.parentNode;
|
2000-06-07 01:05:50 +00:00
|
|
|
if (item.localName == "treeitem") {
|
2000-04-04 05:47:24 +00:00
|
|
|
var isServer = (treeitem.getAttribute('IsServer') == "true");
|
|
|
|
if (isServer) {
|
2000-09-08 21:57:43 +00:00
|
|
|
uri = treeitem.getAttribute("id");
|
2000-04-04 05:47:24 +00:00
|
|
|
var server = GetServer(uri);
|
|
|
|
if (server) {
|
2000-04-21 22:55:18 +00:00
|
|
|
server.PerformExpand(msgWindow);
|
2000-04-04 05:47:24 +00:00
|
|
|
}
|
2000-04-04 02:31:43 +00:00
|
|
|
}
|
2000-06-03 00:22:07 +00:00
|
|
|
else {
|
|
|
|
var isImap = (treeitem.getAttribute('ServerType') == "imap");
|
|
|
|
if (isImap) {
|
2000-09-08 21:57:43 +00:00
|
|
|
uri = treeitem.getAttribute("id");
|
2000-06-03 00:22:07 +00:00
|
|
|
var folder = GetMsgFolderFromUri(uri);
|
|
|
|
if (folder) {
|
|
|
|
var imapFolder = folder.QueryInterface(Components.interfaces.nsIMsgImapMailFolder);
|
|
|
|
if (imapFolder) {
|
|
|
|
imapFolder.PerformExpand(msgWindow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-04-04 02:31:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-05-16 11:35:12 +00:00
|
|
|
else if(event.detail == 2)
|
2000-03-17 01:10:57 +00:00
|
|
|
{
|
2000-09-08 21:57:43 +00:00
|
|
|
item = t.parentNode.parentNode;
|
2000-06-07 01:05:50 +00:00
|
|
|
if (item.localName == "treeitem")
|
2000-03-17 01:10:57 +00:00
|
|
|
FolderPaneDoubleClick(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function FolderPaneDoubleClick(treeitem)
|
|
|
|
{
|
2000-04-04 05:47:24 +00:00
|
|
|
var isServer = false;
|
2000-04-04 02:31:43 +00:00
|
|
|
|
2000-03-30 23:42:15 +00:00
|
|
|
if (treeitem) {
|
2000-04-04 05:47:24 +00:00
|
|
|
isServer = (treeitem.getAttribute('IsServer') == "true");
|
|
|
|
if (isServer) {
|
|
|
|
var open = treeitem.getAttribute('open');
|
|
|
|
if (open == "true") {
|
|
|
|
var uri = treeitem.getAttribute("id");
|
|
|
|
server = GetServer(uri);
|
|
|
|
if (server) {
|
2000-04-04 05:53:39 +00:00
|
|
|
//dump("double clicking open, PerformExpand()\n");
|
2000-04-21 22:55:18 +00:00
|
|
|
server.PerformExpand(msgWindow);
|
2000-04-04 05:47:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2000-04-04 05:53:39 +00:00
|
|
|
//dump("double clicking close, don't PerformExpand()\n");
|
2000-04-04 05:47:24 +00:00
|
|
|
}
|
2000-03-30 23:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-04 02:31:43 +00:00
|
|
|
// don't open a new msg window if we are double clicking on a server.
|
|
|
|
// only do it for folders or newsgroups
|
2000-04-04 05:47:24 +00:00
|
|
|
if (!isServer) {
|
2000-04-11 20:19:32 +00:00
|
|
|
MsgOpenNewWindowForFolder(treeitem.getAttribute('id'));
|
2000-04-04 02:31:43 +00:00
|
|
|
}
|
2000-03-17 01:10:57 +00:00
|
|
|
}
|
|
|
|
|
2000-01-10 01:34:36 +00:00
|
|
|
function ChangeSelection(tree, newSelection)
|
|
|
|
{
|
|
|
|
if(newSelection)
|
|
|
|
{
|
|
|
|
tree.clearItemSelection();
|
|
|
|
tree.selectItem(newSelection);
|
|
|
|
tree.ensureElementIsVisible(newSelection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-14 05:38:51 +00:00
|
|
|
function SetActiveThreadPaneSortColumn(column)
|
|
|
|
{
|
|
|
|
gActiveThreadPaneSortColumn = column;
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetActiveThreadPaneSortColumn()
|
|
|
|
{
|
|
|
|
return gActiveThreadPaneSortColumn;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ClearActiveThreadPaneSortColumn()
|
|
|
|
{
|
|
|
|
var activeColumn = document.getElementById(gActiveThreadPaneSortColumn);
|
|
|
|
if(activeColumn)
|
|
|
|
{
|
|
|
|
activeColumn.removeAttribute("sortActive");
|
|
|
|
activeColumn = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
function GetSelectedMsgFolders()
|
|
|
|
{
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
var selectedFolders = folderTree.selectedItems;
|
|
|
|
var numFolders = selectedFolders.length;
|
|
|
|
|
|
|
|
var folderArray = new Array(numFolders);
|
|
|
|
|
|
|
|
for(var i = 0; i < numFolders; i++)
|
|
|
|
{
|
|
|
|
var folder = selectedFolders[i];
|
|
|
|
var folderUri = folder.getAttribute("id");
|
|
|
|
var folderResource = RDF.GetResource(folderUri);
|
|
|
|
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
if(msgFolder)
|
|
|
|
{
|
|
|
|
folderArray[i] = msgFolder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return folderArray;
|
|
|
|
}
|
|
|
|
|
2000-08-26 20:54:51 +00:00
|
|
|
function GetSelectedMessage(index)
|
|
|
|
{
|
|
|
|
var threadTree = GetThreadTree();
|
|
|
|
var selectedMessages = threadTree.selectedItems;
|
|
|
|
var numMessages = selectedMessages.length;
|
|
|
|
if(index <0 || index > (numMessages - 1))
|
|
|
|
return null;
|
|
|
|
|
|
|
|
var messageNode = selectedMessages[index];
|
|
|
|
var messageUri = messageNode.getAttribute("id");
|
|
|
|
var messageResource = RDF.GetResource(messageUri);
|
|
|
|
var message = messageResource.QueryInterface(Components.interfaces.nsIMessage);
|
|
|
|
return message;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetNumSelectedMessages()
|
|
|
|
{
|
|
|
|
var threadTree = GetThreadTree();
|
|
|
|
var selectedMessages = threadTree.selectedItems;
|
|
|
|
var numMessages = selectedMessages.length;
|
|
|
|
return numMessages;
|
|
|
|
}
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
function GetSelectedMessages()
|
|
|
|
{
|
|
|
|
var threadTree = GetThreadTree();
|
|
|
|
var selectedMessages = threadTree.selectedItems;
|
|
|
|
var numMessages = selectedMessages.length;
|
|
|
|
|
|
|
|
var messageArray = new Array(numMessages);
|
|
|
|
|
|
|
|
for(var i = 0; i < numMessages; i++)
|
|
|
|
{
|
|
|
|
var messageNode = selectedMessages[i];
|
|
|
|
var messageUri = messageNode.getAttribute("id");
|
|
|
|
var messageResource = RDF.GetResource(messageUri);
|
|
|
|
var message = messageResource.QueryInterface(Components.interfaces.nsIMessage);
|
|
|
|
if(message)
|
|
|
|
{
|
|
|
|
messageArray[i] = message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return messageArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetLoadedMsgFolder()
|
|
|
|
{
|
|
|
|
var loadedFolder = GetThreadTreeFolder();
|
|
|
|
var folderUri = loadedFolder.getAttribute("ref");
|
2000-04-14 14:07:23 +00:00
|
|
|
if(folderUri && folderUri != "" && folderUri !="null")
|
2000-04-11 20:19:32 +00:00
|
|
|
{
|
2000-04-14 14:07:23 +00:00
|
|
|
var folderResource = RDF.GetResource(folderUri);
|
|
|
|
if(folderResource)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
var msgFolder = folderResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
return msgFolder;
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump(ex + "\n");
|
|
|
|
dump("we know about this. see bug #35591\n");
|
|
|
|
}
|
2000-04-12 15:32:27 +00:00
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetLoadedMessage()
|
|
|
|
{
|
2000-05-05 00:14:08 +00:00
|
|
|
if(gCurrentDisplayedMessage)
|
2000-04-11 20:19:32 +00:00
|
|
|
{
|
2000-05-05 00:14:08 +00:00
|
|
|
var messageResource = RDF.GetResource(gCurrentDisplayedMessage);
|
|
|
|
if(messageResource)
|
|
|
|
{
|
|
|
|
var message = messageResource.QueryInterface(Components.interfaces.nsIMessage);
|
|
|
|
return message;
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-08-26 20:54:51 +00:00
|
|
|
//Clear everything related to the current message. called after load start page.
|
|
|
|
function ClearMessageSelection()
|
|
|
|
{
|
|
|
|
ClearThreadTreeSelection();
|
|
|
|
}
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
function GetCompositeDataSource(command)
|
|
|
|
{
|
2000-05-16 22:56:08 +00:00
|
|
|
if(command == "GetNewMessages" || command == "DeleteMessages" || command == "Copy" ||
|
2000-12-12 03:18:06 +00:00
|
|
|
command == "Move" || command == "NewFolder" || command == "MarkAllMessagesRead" ||
|
|
|
|
command == "DownloadFlagged")
|
2000-04-11 20:19:32 +00:00
|
|
|
{
|
2000-06-30 06:02:30 +00:00
|
|
|
return GetFolderDatasource();
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
2000-05-16 22:56:08 +00:00
|
|
|
else if(command == "MarkMessageRead" ||
|
2000-05-05 00:14:08 +00:00
|
|
|
command == "MarkMessageFlagged" || command == "MarkThreadAsRead" ||
|
2000-12-12 03:18:06 +00:00
|
|
|
command == "DownloadSelected" || command == "MessageProperty")
|
2000-04-14 14:07:23 +00:00
|
|
|
{
|
|
|
|
var threadTree = GetThreadTree();
|
|
|
|
return threadTree.database;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
//Sets the next message after a delete. If useSelection is true then use the
|
|
|
|
//current selection to determine this. Otherwise use messagesToCheck which will
|
|
|
|
//be an array of nsIMessage's.
|
|
|
|
function SetNextMessageAfterDelete(messagesToCheck, useSelection)
|
|
|
|
{
|
|
|
|
if(useSelection)
|
|
|
|
{
|
|
|
|
var tree = GetThreadTree();
|
|
|
|
var nextMessage = GetNextMessageAfterDelete(tree.selectedItems);
|
|
|
|
if(nextMessage)
|
|
|
|
gNextMessageAfterDelete = nextMessage.getAttribute('id');
|
|
|
|
else
|
|
|
|
gNextMessageAfterDelete = null;
|
|
|
|
}
|
|
|
|
}
|
2000-04-21 14:22:16 +00:00
|
|
|
|
2000-04-28 20:10:36 +00:00
|
|
|
function SelectFolder(folderUri)
|
|
|
|
{
|
|
|
|
var tree = GetFolderTree();
|
|
|
|
var treeitem = document.getElementById(folderUri);
|
|
|
|
if(tree && treeitem)
|
|
|
|
ChangeSelection(tree, treeitem);
|
|
|
|
}
|
|
|
|
|
|
|
|
function SelectMessage(messageUri)
|
|
|
|
{
|
2000-11-05 02:29:47 +00:00
|
|
|
dump("SelectMessage: " + messageUri + "\n");
|
2000-04-28 20:10:36 +00:00
|
|
|
var tree = GetThreadTree();
|
|
|
|
var treeitem = document.getElementById(messageUri);
|
|
|
|
if(tree && treeitem)
|
|
|
|
ChangeSelection(tree, treeitem);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-05-01 21:58:24 +00:00
|
|
|
function ReloadMessage()
|
2000-04-21 14:22:16 +00:00
|
|
|
{
|
2000-05-01 21:58:24 +00:00
|
|
|
var msgToLoad = gCurrentDisplayedMessage;
|
|
|
|
//null it out so it will work.
|
|
|
|
gCurrentDisplayedMessage = null;
|
|
|
|
LoadMessageByUri(msgToLoad);
|
2000-04-21 14:22:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-26 20:54:51 +00:00
|
|
|
function SetBusyCursor(window, enable)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|