1999-09-01 23:49:47 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* 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 */
|
|
|
|
|
|
|
|
/* globals for a particular window */
|
1999-09-15 05:16:29 +00:00
|
|
|
var messengerProgID = "component://netscape/messenger";
|
|
|
|
var statusFeedbackProgID = "component://netscape/messenger/statusfeedback";
|
|
|
|
var messageViewProgID = "component://netscape/messenger/messageview";
|
|
|
|
var mailSessionProgID = "component://netscape/messenger/services/session";
|
1999-12-02 06:59:28 +00:00
|
|
|
var accountManagerProgID = "component://netscape/messenger/account-manager";
|
2000-01-15 09:00:46 +00:00
|
|
|
var messengerMigratorProgID = "component://netscape/messenger/migrator";
|
1999-09-15 05:16:29 +00:00
|
|
|
var prefProgID = "component://netscape/preferences";
|
1999-10-27 22:38:47 +00:00
|
|
|
var msgWindowProgID = "component://netscape/messenger/msgwindow";
|
1999-09-15 05:16:29 +00:00
|
|
|
|
|
|
|
var datasourceProgIDPrefix = "component://netscape/rdf/datasource?name=";
|
|
|
|
var accountManagerDSProgID = datasourceProgIDPrefix + "msgaccountmanager";
|
|
|
|
var folderDSProgID = datasourceProgIDPrefix + "mailnewsfolders";
|
|
|
|
var messageDSProgID = datasourceProgIDPrefix + "mailnewsmessages";
|
|
|
|
|
2000-02-04 01:56:38 +00:00
|
|
|
var messenger;
|
|
|
|
var accountManagerDataSource;
|
|
|
|
var folderDataSource;
|
|
|
|
var messageDataSource;
|
|
|
|
var pref;
|
|
|
|
var statusFeedback;
|
|
|
|
var messageView;
|
|
|
|
var msgWindow;
|
|
|
|
|
|
|
|
var msgComposeService;
|
|
|
|
var mailSession;
|
|
|
|
var accountManager;
|
|
|
|
var RDF;
|
|
|
|
var showPerformance;
|
|
|
|
var msgNavigationService;
|
|
|
|
|
|
|
|
var msgComposeType;
|
|
|
|
var msgComposeFormat;
|
|
|
|
var Bundle;
|
2000-02-15 06:41:28 +00:00
|
|
|
var BrandBundle;
|
2000-02-04 01:56:38 +00:00
|
|
|
|
1999-09-15 08:29:01 +00:00
|
|
|
var gFolderTree;
|
1999-09-15 08:39:28 +00:00
|
|
|
var gThreadTree;
|
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;
|
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;
|
1999-12-24 01:08:05 +00:00
|
|
|
|
2000-03-14 05:38:51 +00:00
|
|
|
var gActiveThreadPaneSortColumn = "";
|
|
|
|
|
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-03-14 05:38:51 +00:00
|
|
|
folder = item.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
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) {},
|
|
|
|
|
|
|
|
OnFolderLoaded: function (folder)
|
|
|
|
{
|
|
|
|
if(folder)
|
|
|
|
{
|
|
|
|
var resource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
if(resource)
|
|
|
|
{
|
|
|
|
var uri = resource.Value;
|
2000-01-09 19:47:58 +00:00
|
|
|
dump('In OnFolderLoaded for ' + uri);
|
|
|
|
dump('\n');
|
|
|
|
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();
|
1999-10-28 23:27:21 +00:00
|
|
|
dump("before reroot in OnFolderLoaded\n");
|
2000-03-14 05:38:51 +00:00
|
|
|
RerootFolder(uri, msgFolder, gCurrentLoadingFolderIsThreaded, gCurrentLoadingFolderSortID, gCurrentLoadingFolderSortDirection);
|
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;
|
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-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-02-16 00:39:23 +00:00
|
|
|
},
|
|
|
|
OnDeleteOrMoveMessagesCompleted :function(folder)
|
|
|
|
{
|
|
|
|
dump("In OnDeleteOrMoveMessagesCompleted\n");
|
|
|
|
if(IsCurrentLoadedFolder(folder))
|
|
|
|
{
|
|
|
|
msgNavigationService.EnsureDocumentIsLoaded(document);
|
|
|
|
|
|
|
|
dump("next message uri is " + gNextMessageAfterDelete + "\n");
|
2000-03-14 05:38:51 +00:00
|
|
|
if(gNextMessageAfterDelete)
|
|
|
|
{
|
|
|
|
var nextMessage = document.getElementById(gNextMessageAfterDelete);
|
|
|
|
if(!nextMessage)
|
|
|
|
dump("No next message after delete\n");
|
|
|
|
SelectNextMessage(nextMessage);
|
|
|
|
var threadTree = GetThreadTree();
|
|
|
|
if(threadTree)
|
|
|
|
threadTree.ensureElementIsVisible(nextMessage);
|
|
|
|
else
|
|
|
|
dump("No thread tree\n");
|
|
|
|
gNextMessageAfterDelete = null;
|
|
|
|
}
|
2000-02-16 00:39:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function IsCurrentLoadedFolder(folder)
|
|
|
|
{
|
|
|
|
msgfolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
if(msgfolder)
|
|
|
|
{
|
|
|
|
dump("IsCurrentLoadedFolder: has msgFolder\n");
|
|
|
|
var folderResource = msgfolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
if(folderResource)
|
|
|
|
{
|
|
|
|
dump("IsCurrentLoadedFolder: has folderResource\n");
|
|
|
|
var folderURI = folderResource.Value;
|
|
|
|
var currentLoadedFolder = GetThreadTreeFolder();
|
|
|
|
var currentURI = currentLoadedFolder.getAttribute('ref');
|
|
|
|
dump("IsCurrentLoadedFolder: folderURI = " + folderURI + "\n");
|
|
|
|
dump("IsCurrentLoadedFolder: currentURI = " + currentURI + "\n");
|
|
|
|
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();
|
|
|
|
|
|
|
|
CreateGlobals();
|
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);
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
AddDataSources();
|
|
|
|
InitPanes();
|
|
|
|
|
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-01-28 23:25:17 +00:00
|
|
|
dump('Before load start folder\n');
|
2000-02-16 00:39:23 +00:00
|
|
|
setTimeout("loadStartFolder();", 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
|
|
|
|
|
|
|
var afterLoadMessenger = new Date();
|
|
|
|
|
|
|
|
var timeToLoad = (afterLoadMessenger.getTime() - beforeLoadMessenger.getTime())/1000;
|
|
|
|
if(showPerformance)
|
|
|
|
{
|
|
|
|
dump("Time in OnLoadMessger is " + timeToLoad + " seconds\n");
|
|
|
|
}
|
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function OnUnloadMessenger()
|
|
|
|
{
|
|
|
|
dump("\nOnUnload from XUL\nClean up ...\n");
|
1999-09-15 05:16:29 +00:00
|
|
|
var mailSession = Components.classes[mailSessionProgID].getService();
|
1999-09-13 21:11:45 +00:00
|
|
|
if(mailSession)
|
|
|
|
{
|
|
|
|
mailSession = mailSession.QueryInterface(Components.interfaces.nsIMsgMailSession);
|
|
|
|
if(mailSession)
|
1999-10-28 23:27:21 +00:00
|
|
|
{
|
1999-09-13 21:11:45 +00:00
|
|
|
mailSession.RemoveFolderListener(folderListener);
|
1999-10-28 23:27:21 +00:00
|
|
|
mailSession.RemoveMsgWindow(msgWindow);
|
2000-01-09 23:15:07 +00:00
|
|
|
messenger.SetWindow(null, null);
|
1999-10-28 23:27:21 +00:00
|
|
|
}
|
1999-09-13 21:11:45 +00:00
|
|
|
}
|
2000-03-14 05:38:51 +00:00
|
|
|
|
|
|
|
var msgDS = folderDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
|
|
|
|
msgDS.window = null;
|
|
|
|
|
|
|
|
msgDS = messageDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
|
|
|
|
msgDS.window = null;
|
|
|
|
|
|
|
|
msgDS = accountManagerDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
|
|
|
|
msgDS.window = null;
|
2000-02-16 05:33:30 +00:00
|
|
|
|
2000-03-14 05:38:51 +00:00
|
|
|
|
|
|
|
msgWindow.closeWindow();
|
1999-09-22 06:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 01:56:38 +00:00
|
|
|
function CreateGlobals()
|
|
|
|
{
|
|
|
|
// get the messenger instance
|
|
|
|
messenger = Components.classes[messengerProgID].createInstance();
|
|
|
|
messenger = messenger.QueryInterface(Components.interfaces.nsIMessenger);
|
|
|
|
|
|
|
|
//Create datasources
|
|
|
|
accountManagerDataSource = Components.classes[accountManagerDSProgID].createInstance();
|
|
|
|
folderDataSource = Components.classes[folderDSProgID].createInstance();
|
|
|
|
messageDataSource = Components.classes[messageDSProgID].createInstance();
|
|
|
|
|
|
|
|
pref = Components.classes[prefProgID].getService(Components.interfaces.nsIPref);
|
|
|
|
|
|
|
|
//Create windows status feedback
|
|
|
|
statusFeedback = Components.classes[statusFeedbackProgID].createInstance();
|
|
|
|
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);
|
|
|
|
|
|
|
|
//Create message view object
|
|
|
|
messageView = Components.classes[messageViewProgID].createInstance();
|
|
|
|
messageView = messageView.QueryInterface(Components.interfaces.nsIMessageView);
|
|
|
|
|
|
|
|
//Create message window object
|
|
|
|
msgWindow = Components.classes[msgWindowProgID].createInstance();
|
|
|
|
msgWindow = msgWindow.QueryInterface(Components.interfaces.nsIMsgWindow);
|
|
|
|
|
|
|
|
msgComposeService = Components.classes['component://netscape/messengercompose'].getService();
|
|
|
|
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
|
|
|
|
|
|
|
|
mailSession = Components.classes["component://netscape/messenger/services/session"].getService(Components.interfaces.nsIMsgMailSession);
|
|
|
|
|
|
|
|
accountManager = Components.classes["component://netscape/messenger/account-manager"].getService(Components.interfaces.nsIMsgAccountManager);
|
|
|
|
|
|
|
|
RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
|
|
|
|
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
|
|
|
|
|
|
|
|
showPerformance = pref.GetBoolPref('mail.showMessengerPerformance');
|
|
|
|
|
|
|
|
msgNavigationService = Components.classes['component://netscape/messenger/msgviewnavigationservice'].getService();
|
|
|
|
msgNavigationService= msgNavigationService.QueryInterface(Components.interfaces.nsIMsgViewNavigationService);
|
|
|
|
|
|
|
|
msgComposeType = Components.interfaces.nsIMsgCompType;
|
|
|
|
msgComposeFormat = Components.interfaces.nsIMsgCompFormat;
|
|
|
|
Bundle = srGetStrBundle("chrome://messenger/locale/messenger.properties");
|
2000-02-15 06:41:28 +00:00
|
|
|
BrandBundle = srGetStrBundle("chrome://global/locale/brand.properties");
|
2000-02-04 01:56:38 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-09-11 01:54:15 +00:00
|
|
|
function verifyAccounts() {
|
2000-02-15 06:41:28 +00:00
|
|
|
var openWizard = false;
|
|
|
|
var prefillAccount;
|
|
|
|
|
1999-09-11 01:54:15 +00:00
|
|
|
try {
|
1999-12-02 06:59:28 +00:00
|
|
|
var am = Components.classes[accountManagerProgID].getService(Components.interfaces.nsIMsgAccountManager);
|
1999-09-11 01:54:15 +00:00
|
|
|
|
|
|
|
var accounts = am.accounts;
|
|
|
|
|
|
|
|
// as long as we have some accounts, we're fine.
|
2000-02-15 06:41:28 +00:00
|
|
|
var accountCount = accounts.Count();
|
|
|
|
if (accountCount > 0) {
|
|
|
|
prefillAccount = getFirstInvalidAccount(accounts);
|
|
|
|
dump("prefillAccount = " + prefillAccount + "\n");
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
messengerMigrator = Components.classes[messengerMigratorProgID].getService(Components.interfaces.nsIMessengerMigrator);
|
|
|
|
dump("attempt to UpgradePrefs. If that fails, open the account wizard.\n");
|
|
|
|
messengerMigrator.UpgradePrefs();
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
// upgrade prefs failed, so open account wizard
|
|
|
|
openWizard = true;
|
|
|
|
}
|
1999-09-11 01:54:15 +00:00
|
|
|
}
|
2000-02-15 06:41:28 +00:00
|
|
|
|
|
|
|
if (openWizard || prefillAccount) {
|
|
|
|
MsgAccountWizard(prefillAccount);
|
1999-09-11 01:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("error verifying accounts " + ex + "\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-11 00:43:18 +00:00
|
|
|
function loadStartPage() {
|
|
|
|
try {
|
|
|
|
startpageenabled= pref.GetBoolPref("mailnews.start_page.enabled");
|
|
|
|
|
2000-02-24 02:03:11 +00:00
|
|
|
if (startpageenabled) {
|
1999-09-11 00:43:18 +00:00
|
|
|
startpage = pref.CopyCharPref("mailnews.start_page.url");
|
2000-02-24 02:03:11 +00:00
|
|
|
if (startpage != "") {
|
|
|
|
window.frames["messagepane"].location = startpage;
|
|
|
|
dump("start message pane with: " + startpage + "\n");
|
|
|
|
}
|
|
|
|
}
|
1999-09-11 00:43:18 +00:00
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
dump("Error loading start page.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-14 06:27:36 +00:00
|
|
|
function loadStartFolder()
|
|
|
|
{
|
2000-01-10 01:34:36 +00:00
|
|
|
//First get default account
|
2000-01-20 22:56:00 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
var defaultAccount = accountManager.defaultAccount;
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-01-20 22:56:00 +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-01-20 22:56:00 +00:00
|
|
|
//now find Inbox
|
|
|
|
var outNumFolders = new Object();
|
2000-01-28 23:25:17 +00:00
|
|
|
dump('Before getting inbox\n');
|
2000-01-20 22:56:00 +00:00
|
|
|
var inboxFolder = rootMsgFolder.getFoldersWithFlag(0x1000, 1, outNumFolders);
|
|
|
|
if(!inboxFolder) return;
|
2000-01-28 23:25:17 +00:00
|
|
|
dump('We have an inbox\n');
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-01-20 22:56:00 +00:00
|
|
|
var resource = inboxFolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
var inboxURI = resource.Value;
|
2000-01-10 01:34:36 +00:00
|
|
|
|
2000-01-28 23:25:17 +00:00
|
|
|
dump('InboxURI = ' + inboxURI + '\n');
|
2000-01-20 22:56:00 +00:00
|
|
|
//first, let's see if it's already in the dom. This will make life easier.
|
2000-02-04 01:56:38 +00:00
|
|
|
//We need to make sure content is built by this time
|
|
|
|
msgNavigationService.EnsureDocumentIsLoaded(document);
|
|
|
|
|
2000-01-20 22:56:00 +00:00
|
|
|
var inbox = document.getElementById(inboxURI);
|
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.
|
|
|
|
if(!inbox)
|
|
|
|
{
|
2000-01-28 23:25:17 +00:00
|
|
|
dump('There isnt an inbox in the tree yet\n');
|
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();
|
|
|
|
ChangeSelection(folderTree, inbox);
|
|
|
|
}
|
|
|
|
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 {
|
1999-09-15 05:16:29 +00:00
|
|
|
var mailSession = Components.classes[mailSessionProgID].getService(Components.interfaces.nsIMsgMailSession);
|
1999-09-15 04:57:24 +00:00
|
|
|
|
|
|
|
mailSession.AddFolderListener(folderListener);
|
1999-10-28 23:27:21 +00:00
|
|
|
mailSession.AddMsgWindow(msgWindow);
|
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-10-27 22:38:47 +00:00
|
|
|
function InitMsgWindow()
|
|
|
|
{
|
|
|
|
msgWindow.statusFeedback = statusFeedback;
|
|
|
|
msgWindow.messageView = messageView;
|
2000-01-06 00:53:12 +00:00
|
|
|
msgWindow.msgHeaderSink = messageHeaderSink;
|
|
|
|
msgWindow.SetDOMWindow(window);
|
1999-10-27 22:38:47 +00:00
|
|
|
}
|
1999-09-15 04:57:24 +00:00
|
|
|
|
1999-09-01 23:49:47 +00:00
|
|
|
function AddDataSources()
|
|
|
|
{
|
|
|
|
|
|
|
|
accountManagerDataSource = accountManagerDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
|
|
|
folderDataSource = folderDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
2000-01-12 02:25:35 +00:00
|
|
|
//to move menu item
|
|
|
|
SetupMoveCopyMenus('moveMenu', accountManagerDataSource, folderDataSource);
|
1999-09-01 23:49:47 +00:00
|
|
|
|
|
|
|
//to copy menu item
|
2000-01-12 02:25:35 +00:00
|
|
|
SetupMoveCopyMenus('copyMenu', accountManagerDataSource, folderDataSource);
|
|
|
|
|
|
|
|
//To threadpane move context menu
|
|
|
|
SetupMoveCopyMenus('threadPaneContext-moveMenu', accountManagerDataSource, folderDataSource);
|
|
|
|
|
|
|
|
//To threadpane copy content menu
|
|
|
|
SetupMoveCopyMenus('threadPaneContext-copyMenu', accountManagerDataSource, folderDataSource);
|
|
|
|
|
2000-03-14 05:38:51 +00:00
|
|
|
//To FileButton menu
|
|
|
|
SetupMoveCopyMenus('FileButtonMenu', accountManagerDataSource, folderDataSource);
|
1999-09-01 23:49:47 +00:00
|
|
|
//Add statusFeedback
|
|
|
|
|
1999-10-27 22:38:47 +00:00
|
|
|
var msgDS = folderDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
|
|
|
|
msgDS.window = msgWindow;
|
|
|
|
|
|
|
|
msgDS = messageDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
|
|
|
|
msgDS.window = msgWindow;
|
1999-09-01 23:49:47 +00:00
|
|
|
|
1999-10-27 22:38:47 +00:00
|
|
|
msgDS = accountManagerDataSource.QueryInterface(Components.interfaces.nsIMsgRDFDataSource);
|
|
|
|
msgDS.window = msgWindow;
|
1999-09-01 23:49:47 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-01-12 02:25:35 +00:00
|
|
|
function SetupMoveCopyMenus(menuid, accountManagerDataSource, folderDataSource)
|
|
|
|
{
|
2000-03-14 05:38:51 +00:00
|
|
|
dump("SetupMoveCopyMenus for " + menuid + "\n");
|
2000-01-12 02:25:35 +00:00
|
|
|
var menu = document.getElementById(menuid);
|
|
|
|
if(menu)
|
|
|
|
{
|
|
|
|
menu.database.AddDataSource(accountManagerDataSource);
|
|
|
|
menu.database.AddDataSource(folderDataSource);
|
|
|
|
menu.setAttribute('ref', 'msgaccounts:/');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
function OnLoadFolderPane(folderTree)
|
|
|
|
{
|
1999-09-16 21:11:01 +00:00
|
|
|
dump('In onLoadfolderPane\n');
|
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);
|
1999-10-27 22:38:47 +00:00
|
|
|
var database = folderTree.database;
|
|
|
|
|
|
|
|
database.AddDataSource(accountManagerDataSource);
|
|
|
|
database.AddDataSource(folderDataSource);
|
1999-09-01 23:49:47 +00:00
|
|
|
folderTree.setAttribute('ref', 'msgaccounts:/');
|
|
|
|
}
|
|
|
|
|
|
|
|
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-09 06:18:40 +00:00
|
|
|
// add folderSource to thread pane
|
|
|
|
folderDataSource = folderDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
|
|
|
threadTree.database.AddDataSource(folderDataSource);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetThreadTree()
|
|
|
|
{
|
1999-09-15 08:39:28 +00:00
|
|
|
if (gThreadTree) return gThreadTree;
|
1999-09-01 23:49:47 +00:00
|
|
|
var threadTree = document.getElementById('threadTree');
|
|
|
|
if(!threadTree)
|
|
|
|
dump('thread tree is null\n');
|
1999-09-15 08:39:28 +00:00
|
|
|
gThreadTree = threadTree;
|
1999-09-01 23:49:47 +00:00
|
|
|
return threadTree;
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetThreadTreeFolder()
|
|
|
|
{
|
|
|
|
var tree = GetThreadTree();
|
|
|
|
return tree;
|
|
|
|
}
|
|
|
|
|
1999-11-11 20:24:46 +00:00
|
|
|
function GetThreadAndMessagePaneSplitter()
|
|
|
|
{
|
|
|
|
if(gThreadAndMessagePaneSplitter) return gThreadAndMessagePaneSplitter;
|
|
|
|
var splitter = document.getElementById('gray_horizontal_splitter');
|
|
|
|
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-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);
|
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-02-04 15:19:57 +00:00
|
|
|
gCurrentDisplayedMessage = null;
|
1999-12-02 23:49:12 +00:00
|
|
|
if (window.frames["messagepane"].location != "about:blank")
|
2000-01-06 00:53:12 +00:00
|
|
|
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-10-29 04:39:06 +00:00
|
|
|
function StopUrls()
|
|
|
|
{
|
1999-11-02 03:34:45 +00:00
|
|
|
msgWindow.StopUrls();
|
1999-10-29 04:39:06 +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
|
|
|
|
1999-12-21 23:38:31 +00:00
|
|
|
function ThreadPaneOnClick(event)
|
|
|
|
{
|
|
|
|
var targetclass = event.target.getAttribute('class');
|
|
|
|
debug('targetclass = ' + targetclass + '\n');
|
|
|
|
|
|
|
|
if (targetclass == 'twisty') {
|
|
|
|
// The twisty is nested three below the treeitem:
|
|
|
|
// <treeitem>
|
|
|
|
// <treerow>
|
|
|
|
// <treecell>
|
|
|
|
// <titledbutton class="twisty"> <!-- anonymous -->
|
2000-03-01 22:33:25 +00:00
|
|
|
var treeitem = event.target.parentNode.parentNode.parentNode;
|
1999-12-21 23:38:31 +00:00
|
|
|
var open = treeitem.getAttribute('open');
|
|
|
|
if(open == "true")
|
|
|
|
{
|
|
|
|
//open all of the children of the treeitem
|
2000-01-28 23:25:17 +00:00
|
|
|
msgNavigationService.OpenTreeitemAndDescendants(treeitem);
|
1999-12-21 23:38:31 +00:00
|
|
|
}
|
|
|
|
dump('clicked on a twisty\n');
|
|
|
|
}
|
2000-01-31 22:20:55 +00:00
|
|
|
else if(event.clickCount == 2)
|
|
|
|
{
|
|
|
|
ThreadPaneDoubleClick(event.target.parentNode.parentNode);
|
|
|
|
}
|
1999-12-21 23:38:31 +00:00
|
|
|
}
|
|
|
|
|
2000-01-31 22:20:55 +00:00
|
|
|
function ThreadPaneDoubleClick(treeitem)
|
|
|
|
{
|
|
|
|
if(IsSpecialFolderSelected("Drafts"))
|
|
|
|
{
|
|
|
|
ComposeMessage(msgComposeType.Draft, msgComposeFormat.Default);
|
|
|
|
}
|
|
|
|
else if(IsSpecialFolderSelected("Templates"))
|
|
|
|
{
|
|
|
|
ComposeMessage(msgComposeType.Template, msgComposeFormat.Default);
|
|
|
|
}
|
|
|
|
}
|
2000-01-10 01:34:36 +00:00
|
|
|
|
|
|
|
function ChangeSelection(tree, newSelection)
|
|
|
|
{
|
|
|
|
if(newSelection)
|
|
|
|
{
|
|
|
|
tree.clearItemSelection();
|
|
|
|
tree.clearCellSelection();
|
|
|
|
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 = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|