1999-06-08 00:59:02 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
1999-06-08 02:17:35 +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.
|
1999-06-08 00:59:02 +00:00
|
|
|
*/
|
|
|
|
|
1999-06-08 02:17:35 +00:00
|
|
|
|
1999-06-08 00:59:02 +00:00
|
|
|
/*
|
|
|
|
* Command-specific code. This stuff should be called by the widgets
|
|
|
|
*/
|
|
|
|
|
1999-06-04 04:00:58 +00:00
|
|
|
|
1999-06-11 00:25:15 +00:00
|
|
|
var msgComposeService = Components.classes['component://netscape/messengercompose'].getService();
|
1999-11-11 00:23:29 +00:00
|
|
|
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
|
1999-09-20 08:13:27 +00:00
|
|
|
var mailSession = Components.classes["component://netscape/messenger/services/session"].getService(Components.interfaces.nsIMsgMailSession);
|
1999-12-02 06:59:28 +00:00
|
|
|
var accountManager = Components.classes["component://netscape/messenger/account-manager"].getService(Components.interfaces.nsIMsgAccountManager);
|
1999-06-11 00:25:15 +00:00
|
|
|
|
1999-06-03 22:56:45 +00:00
|
|
|
var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
|
|
|
|
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
|
|
|
|
|
1999-06-21 23:23:12 +00:00
|
|
|
var prefs = Components.classes['component://netscape/preferences'].getService();
|
|
|
|
prefs = prefs.QueryInterface(Components.interfaces.nsIPref);
|
|
|
|
var showPerformance = prefs.GetBoolPref('mail.showMessengerPerformance');
|
|
|
|
|
1999-09-16 21:11:01 +00:00
|
|
|
var gBeforeFolderLoadTime;
|
1999-05-28 19:41:31 +00:00
|
|
|
|
|
|
|
function OpenURL(url)
|
|
|
|
{
|
|
|
|
dump("\n\nOpenURL from XUL\n\n\n");
|
1999-10-29 04:39:06 +00:00
|
|
|
messenger.SetWindow(window, msgWindow);
|
1999-06-08 00:26:29 +00:00
|
|
|
messenger.OpenURL(url);
|
1999-05-28 19:41:31 +00:00
|
|
|
}
|
|
|
|
|
1999-10-20 18:31:26 +00:00
|
|
|
function FindIncomingServer(uri)
|
|
|
|
{
|
|
|
|
//dump("FindIncomingServer("+uri+")\n");
|
|
|
|
var server=null;
|
|
|
|
|
|
|
|
if (!uri) return server;
|
|
|
|
|
|
|
|
try {
|
|
|
|
var resource = RDF.GetResource(uri);
|
|
|
|
var msgfolder = resource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
server = msgfolder.server;
|
|
|
|
|
|
|
|
//dump("server = " + server + "\n");
|
|
|
|
return server;
|
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-10 23:47:59 +00:00
|
|
|
function ComposeMessage(type, format) //type is a nsIMsgCompType and format is a nsIMsgCompFormat
|
1999-05-28 19:41:31 +00:00
|
|
|
{
|
1999-11-10 23:47:59 +00:00
|
|
|
var msgComposeType = Components.interfaces.nsIMsgCompType;
|
1999-09-20 08:13:27 +00:00
|
|
|
var identity = null;
|
1999-12-24 10:54:52 +00:00
|
|
|
var newsgroup = null;
|
1999-09-20 08:13:27 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
var selectedFolderList = folderTree.selectedItems;
|
|
|
|
if(selectedFolderList.length > 0)
|
|
|
|
{
|
|
|
|
var selectedFolder = selectedFolderList[0];
|
|
|
|
var uri = selectedFolder.getAttribute('id');
|
|
|
|
// dump("selectedFolder uri = " + uri + "\n");
|
|
|
|
|
1999-10-20 18:31:26 +00:00
|
|
|
// get the incoming server associated with this uri
|
|
|
|
var server = FindIncomingServer(uri);
|
1999-12-24 10:54:52 +00:00
|
|
|
|
|
|
|
// if they hit new and they are reading a newsgroup
|
|
|
|
// turn this into a new post, not a new mail message
|
|
|
|
if (type == msgComposeType.New) {
|
|
|
|
if (server.type == "nntp") {
|
|
|
|
type = msgComposeType.NewsPost;
|
2000-01-11 09:51:28 +00:00
|
|
|
|
|
|
|
// from the uri, get the newsgroup name
|
|
|
|
var resource = RDF.GetResource(uri);
|
|
|
|
var msgfolder = resource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
if (msgfolder.isServer)
|
|
|
|
newsgroup = "";
|
|
|
|
else
|
|
|
|
newsgroup = msgfolder.name;
|
1999-12-24 10:54:52 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-20 08:13:27 +00:00
|
|
|
// dump("server = " + server + "\n");
|
|
|
|
// get the identity associated with this server
|
|
|
|
var identities = accountManager.GetIdentitiesForServer(server);
|
|
|
|
// dump("identities = " + identities + "\n");
|
|
|
|
// just get the first one
|
|
|
|
if (identities.Count() > 0 ) {
|
|
|
|
identity = identities.GetElementAt(0).QueryInterface(Components.interfaces.nsIMsgIdentity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// dump("identity = " + identity + "\n");
|
|
|
|
}
|
|
|
|
catch (ex)
|
|
|
|
{
|
|
|
|
// dump("failed to get an identity to pre-select\n");
|
1999-09-20 02:12:28 +00:00
|
|
|
}
|
|
|
|
|
1999-05-28 19:41:31 +00:00
|
|
|
dump("\nComposeMessage from XUL\n");
|
1999-06-11 00:25:15 +00:00
|
|
|
var uri = null;
|
1999-05-28 19:41:31 +00:00
|
|
|
|
1999-06-11 00:25:15 +00:00
|
|
|
if (! msgComposeService)
|
|
|
|
{
|
|
|
|
dump("### msgComposeService is invalid\n");
|
|
|
|
return;
|
|
|
|
}
|
1999-05-28 19:41:31 +00:00
|
|
|
|
1999-11-10 23:47:59 +00:00
|
|
|
if (type == msgComposeType.New) //new message
|
1999-06-11 00:25:15 +00:00
|
|
|
{
|
1999-10-20 18:31:26 +00:00
|
|
|
//dump("OpenComposeWindow with " + identity + "\n");
|
1999-12-24 16:06:52 +00:00
|
|
|
msgComposeService.OpenComposeWindow(null, null, type, format, identity);
|
1999-06-11 00:25:15 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-12-24 10:54:52 +00:00
|
|
|
else if (type == msgComposeType.NewsPost)
|
|
|
|
{
|
2000-01-11 09:51:28 +00:00
|
|
|
dump("OpenComposeWindow with " + identity + " and " + newsgroup + "\n");
|
1999-12-24 16:06:52 +00:00
|
|
|
msgComposeService.OpenComposeWindow(null, newsgroup, type, format, identity);
|
1999-12-24 10:54:52 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-06-11 00:25:15 +00:00
|
|
|
|
1999-06-23 03:02:21 +00:00
|
|
|
var tree = GetThreadTree();
|
1999-06-11 00:25:15 +00:00
|
|
|
if (tree)
|
1999-05-28 19:41:31 +00:00
|
|
|
{
|
1999-08-23 02:58:28 +00:00
|
|
|
var nodeList = tree.selectedItems;
|
1999-06-11 00:25:15 +00:00
|
|
|
var appCore = FindMessenger();
|
|
|
|
if (appCore)
|
1999-10-29 04:39:06 +00:00
|
|
|
appCore.SetWindow(window, msgWindow);
|
1999-06-11 00:25:15 +00:00
|
|
|
|
|
|
|
var object = null;
|
|
|
|
|
|
|
|
if (nodeList && nodeList.length > 0)
|
1999-05-28 19:41:31 +00:00
|
|
|
{
|
1999-06-11 00:25:15 +00:00
|
|
|
uri = "";
|
|
|
|
for (var i = 0; i < nodeList.length && i < 8; i ++)
|
1999-07-13 20:29:33 +00:00
|
|
|
{
|
|
|
|
dump('i = '+ i);
|
|
|
|
dump('\n');
|
1999-11-10 23:47:59 +00:00
|
|
|
if (type == msgComposeType.Reply || type == msgComposeType.ReplyAll || type == msgComposeType.ForwardInline)
|
1999-06-11 00:25:15 +00:00
|
|
|
{
|
1999-11-09 02:07:58 +00:00
|
|
|
msgComposeService.OpenComposeWindow(null, nodeList[i].getAttribute('id'), type, format, identity);
|
1999-06-11 00:25:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i)
|
1999-11-10 23:47:59 +00:00
|
|
|
uri += ","
|
1999-06-11 00:25:15 +00:00
|
|
|
uri += nodeList[i].getAttribute('id');
|
|
|
|
}
|
|
|
|
}
|
1999-11-10 23:47:59 +00:00
|
|
|
if (type == msgComposeType.ForwardAsAttachment)
|
1999-06-11 00:25:15 +00:00
|
|
|
{
|
1999-11-09 02:07:58 +00:00
|
|
|
msgComposeService.OpenComposeWindow(null, uri, type, format, identity);
|
1999-11-10 23:47:59 +00:00
|
|
|
}
|
1999-05-28 19:41:31 +00:00
|
|
|
}
|
1999-06-21 20:28:39 +00:00
|
|
|
else
|
|
|
|
dump("### nodeList is invalid\n");
|
1999-05-28 19:41:31 +00:00
|
|
|
}
|
1999-06-11 00:25:15 +00:00
|
|
|
else
|
|
|
|
dump("### tree is invalid\n");
|
1999-05-28 19:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function GetNewMessages()
|
|
|
|
{
|
1999-09-20 02:12:28 +00:00
|
|
|
var folderTree = GetFolderTree();
|
1999-08-23 02:58:28 +00:00
|
|
|
var selectedFolderList = folderTree.selectedItems;
|
1999-05-28 19:41:31 +00:00
|
|
|
if(selectedFolderList.length > 0)
|
|
|
|
{
|
|
|
|
var selectedFolder = selectedFolderList[0];
|
1999-12-18 00:48:25 +00:00
|
|
|
messenger.GetNewMessages(folderTree.database, selectedFolder.resource);
|
1999-05-28 19:41:31 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
dump("Nothing was selected\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function LoadMessage(messageNode)
|
|
|
|
{
|
|
|
|
var uri = messageNode.getAttribute('id');
|
|
|
|
dump(uri);
|
1999-06-11 22:11:32 +00:00
|
|
|
if(uri)
|
|
|
|
OpenURL(uri);
|
1999-05-28 19:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function ChangeFolderByDOMNode(folderNode)
|
|
|
|
{
|
|
|
|
var uri = folderNode.getAttribute('id');
|
|
|
|
dump(uri + "\n");
|
1999-09-08 07:03:03 +00:00
|
|
|
|
1999-11-11 00:23:29 +00:00
|
|
|
var isThreaded = folderNode.getAttribute('threaded');
|
|
|
|
|
1999-09-08 07:03:03 +00:00
|
|
|
if (uri)
|
1999-11-11 00:23:29 +00:00
|
|
|
ChangeFolderByURI(uri, isThreaded == "true", "");
|
1999-05-28 19:41:31 +00:00
|
|
|
}
|
|
|
|
|
1999-11-11 00:23:29 +00:00
|
|
|
function ChangeFolderByURI(uri, isThreaded, sortID)
|
1999-05-28 19:41:31 +00:00
|
|
|
{
|
1999-10-28 23:27:21 +00:00
|
|
|
dump('In ChangeFolderByURI\n');
|
1999-09-08 07:03:03 +00:00
|
|
|
var resource = RDF.GetResource(uri);
|
|
|
|
var msgfolder =
|
|
|
|
resource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
1999-09-09 00:52:52 +00:00
|
|
|
if (msgfolder.isServer)
|
1999-09-14 06:26:50 +00:00
|
|
|
window.title = msgfolder.name;
|
1999-12-02 06:59:28 +00:00
|
|
|
else if (msgfolder.server)
|
1999-09-14 06:26:50 +00:00
|
|
|
window.title = msgfolder.name + " on " +
|
1999-09-09 00:52:52 +00:00
|
|
|
msgfolder.server.prettyName;
|
1999-12-02 06:59:28 +00:00
|
|
|
else
|
|
|
|
window.title = msgfolder.name;
|
1999-09-08 07:03:03 +00:00
|
|
|
|
1999-09-16 21:11:01 +00:00
|
|
|
gBeforeFolderLoadTime = new Date();
|
2000-01-09 19:47:58 +00:00
|
|
|
gCurrentLoadingFolderURI = uri;
|
1999-09-16 21:11:01 +00:00
|
|
|
|
1999-10-20 21:58:21 +00:00
|
|
|
if(msgfolder.manyHeadersToDownload())
|
1999-09-16 21:11:01 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2000-01-09 19:47:58 +00:00
|
|
|
gCurrentFolderToReroot = uri;
|
1999-11-11 00:23:29 +00:00
|
|
|
gCurrentLoadingFolderIsThreaded = isThreaded;
|
|
|
|
gCurrentLoadingFolderSortID = sortID;
|
1999-10-20 21:58:21 +00:00
|
|
|
msgfolder.startFolderLoading();
|
1999-11-02 21:36:59 +00:00
|
|
|
msgfolder.updateFolder(msgWindow);
|
1999-09-16 21:11:01 +00:00
|
|
|
}
|
|
|
|
catch(ex)
|
|
|
|
{
|
1999-12-02 23:14:42 +00:00
|
|
|
dump("Error loading with many headers to download\n");
|
1999-09-16 21:11:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-01-09 19:47:58 +00:00
|
|
|
gCurrentFolderToReroot = "";
|
1999-11-11 00:23:29 +00:00
|
|
|
gCurrentLoadingFolderIsThreaded = false;
|
|
|
|
gCurrentLoadingFolderSortID = "";
|
|
|
|
RerootFolder(uri, msgfolder, isThreaded, sortID);
|
2000-01-09 19:47:58 +00:00
|
|
|
//Need to do this after rerooting folder. Otherwise possibility of receiving folder loaded
|
|
|
|
//notification before folder has actually changed.
|
|
|
|
msgfolder.updateFolder(msgWindow);
|
1999-09-16 21:11:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-11 00:23:29 +00:00
|
|
|
function RerootFolder(uri, newFolder, isThreaded, sortID)
|
1999-09-16 21:11:01 +00:00
|
|
|
{
|
1999-11-11 00:23:29 +00:00
|
|
|
dump('In reroot folder\n');
|
1999-06-23 03:02:21 +00:00
|
|
|
var folder = GetThreadTreeFolder();
|
1999-09-13 21:11:45 +00:00
|
|
|
ClearThreadTreeSelection();
|
1999-10-28 23:27:21 +00:00
|
|
|
|
|
|
|
//Set the window's new open folder.
|
|
|
|
msgWindow.openFolder = newFolder;
|
|
|
|
|
1999-11-11 00:23:29 +00:00
|
|
|
//Set threaded state
|
|
|
|
ShowThreads(isThreaded);
|
|
|
|
|
1999-07-27 17:20:28 +00:00
|
|
|
folder.setAttribute('ref', uri);
|
1999-10-28 23:27:21 +00:00
|
|
|
|
1999-11-22 22:08:23 +00:00
|
|
|
UpdateStatusMessageCounts(newFolder);
|
|
|
|
|
1999-09-16 21:11:01 +00:00
|
|
|
var afterFolderLoadTime = new Date();
|
|
|
|
var timeToLoad = (afterFolderLoadTime.getTime() - gBeforeFolderLoadTime.getTime())/1000;
|
1999-06-21 23:23:12 +00:00
|
|
|
if(showPerformance)
|
|
|
|
dump("Time to load " + uri + " is " + timeToLoad + " seconds\n");
|
1999-05-28 19:41:31 +00:00
|
|
|
}
|
|
|
|
|
1999-11-22 22:08:23 +00:00
|
|
|
|
|
|
|
function UpdateStatusMessageCounts(folder)
|
|
|
|
{
|
|
|
|
var unreadElement = GetUnreadCountElement();
|
|
|
|
var totalElement = GetTotalCountElement();
|
|
|
|
if(folder && unreadElement && totalElement)
|
|
|
|
{
|
|
|
|
var numUnread = folder.getNumUnread(false);
|
|
|
|
var numTotal = folder.getTotalMessages(false);
|
|
|
|
|
|
|
|
unreadElement.setAttribute("value", numUnread);
|
|
|
|
totalElement.setAttribute("value", numTotal);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-05-28 19:41:31 +00:00
|
|
|
function SortThreadPane(column, sortKey)
|
|
|
|
{
|
1999-09-01 23:50:16 +00:00
|
|
|
var node = document.getElementById(column);
|
1999-05-28 19:41:31 +00:00
|
|
|
if(!node)
|
|
|
|
return false;
|
|
|
|
|
1999-08-27 03:47:44 +00:00
|
|
|
return SortColumn(node, sortKey);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function SortFolderPane(column, sortKey)
|
|
|
|
{
|
1999-09-16 21:11:01 +00:00
|
|
|
var node = FindInSidebar(window, column);
|
1999-08-27 03:47:44 +00:00
|
|
|
if(!node)
|
1999-09-16 21:11:01 +00:00
|
|
|
{
|
|
|
|
dump('Couldnt find sort column\n');
|
1999-08-27 03:47:44 +00:00
|
|
|
return false;
|
1999-09-16 21:11:01 +00:00
|
|
|
}
|
1999-08-27 03:47:44 +00:00
|
|
|
return SortColumn(node, sortKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
function SortColumn(node, sortKey)
|
|
|
|
{
|
1999-09-16 21:11:01 +00:00
|
|
|
dump('In sortColumn\n');
|
1999-08-30 02:57:03 +00:00
|
|
|
var xulSortService = Components.classes["component://netscape/rdf/xul-sort-service"].getService();
|
|
|
|
|
|
|
|
if (xulSortService)
|
1999-05-28 19:41:31 +00:00
|
|
|
{
|
1999-08-30 02:57:03 +00:00
|
|
|
xulSortService = xulSortService.QueryInterface(Components.interfaces.nsIXULSortService);
|
|
|
|
if (xulSortService)
|
1999-05-28 19:41:31 +00:00
|
|
|
{
|
1999-08-30 02:57:03 +00:00
|
|
|
// sort!!!
|
|
|
|
sortDirection = "ascending";
|
|
|
|
var currentDirection = node.getAttribute('sortDirection');
|
|
|
|
if (currentDirection == "ascending")
|
|
|
|
sortDirection = "descending";
|
|
|
|
else if (currentDirection == "descending")
|
|
|
|
sortDirection = "ascending";
|
|
|
|
else sortDirection = "ascending";
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xulSortService.Sort(node, sortKey, sortDirection);
|
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
1999-12-21 21:43:29 +00:00
|
|
|
//dump("Sort failed: " + e + "\n");
|
1999-08-30 02:57:03 +00:00
|
|
|
}
|
1999-05-28 19:41:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-06-03 22:56:45 +00:00
|
|
|
function GetSelectedFolderResource()
|
|
|
|
{
|
|
|
|
var folderTree = GetFolderTree();
|
1999-08-23 02:58:28 +00:00
|
|
|
var selectedFolderList = folderTree.selectedItems;
|
1999-06-03 22:56:45 +00:00
|
|
|
var selectedFolder = selectedFolderList[0];
|
|
|
|
var uri = selectedFolder.getAttribute('id');
|
|
|
|
|
|
|
|
|
|
|
|
var folderResource = RDF.GetResource(uri);
|
|
|
|
return folderResource;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function SetFolderCharset(folderResource, aCharset)
|
|
|
|
{
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
|
|
|
|
var db = folderTree.database;
|
|
|
|
var db2 = db.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
|
|
|
|
|
|
|
var charsetResource = RDF.GetLiteral(aCharset);
|
|
|
|
var charsetProperty = RDF.GetResource("http://home.netscape.com/NC-rdf#Charset");
|
|
|
|
|
|
|
|
db2.Assert(folderResource, charsetProperty, charsetResource, true);
|
|
|
|
}
|
1999-06-23 03:02:21 +00:00
|
|
|
|
1999-09-01 23:50:16 +00:00
|
|
|
|
1999-06-24 20:23:28 +00:00
|
|
|
|
1999-07-15 03:11:33 +00:00
|
|
|
function ToggleMessageRead(treeItem)
|
|
|
|
{
|
|
|
|
|
|
|
|
var tree = GetThreadTree();
|
2000-01-05 00:56:27 +00:00
|
|
|
var isUnread = treeItem.getAttribute('IsUnread');
|
|
|
|
var unread = (isUnread == "true");
|
1999-12-18 00:48:25 +00:00
|
|
|
messenger.MarkMessageRead(tree.database, treeItem.resource, unread);
|
1999-07-15 03:11:33 +00:00
|
|
|
}
|
|
|
|
|
1999-08-24 21:48:24 +00:00
|
|
|
function ToggleMessageFlagged(treeItem)
|
|
|
|
{
|
|
|
|
|
|
|
|
var tree = GetThreadTree();
|
|
|
|
var flaggedValue = treeItem.getAttribute('Flagged');
|
1999-09-09 06:18:40 +00:00
|
|
|
dump('flaggedValue is ' + flaggedValue);
|
|
|
|
dump('\n');
|
1999-08-24 21:48:24 +00:00
|
|
|
var flagged = (flaggedValue =="flagged");
|
1999-12-18 00:48:25 +00:00
|
|
|
messenger.MarkMessageFlagged(tree.database, treeItem.resource, !flagged);
|
1999-08-24 21:48:24 +00:00
|
|
|
}
|
|
|
|
|
1999-11-11 20:24:46 +00:00
|
|
|
//Called when the splitter in between the thread and message panes is clicked.
|
|
|
|
function OnClickThreadAndMessagePaneSplitter()
|
|
|
|
{
|
|
|
|
var collapsed = IsThreadAndMessagePaneSplitterCollapsed();
|
|
|
|
//collapsed is the previous state so we know we are opening.
|
|
|
|
if(collapsed)
|
|
|
|
LoadSelectionIntoMessagePane();
|
|
|
|
}
|
|
|
|
|
|
|
|
//Called when selection changes in the thread pane.
|
|
|
|
function ThreadPaneSelectionChange()
|
|
|
|
{
|
|
|
|
var collapsed = IsThreadAndMessagePaneSplitterCollapsed();
|
|
|
|
|
|
|
|
if(!collapsed)
|
|
|
|
{
|
|
|
|
LoadSelectionIntoMessagePane();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//takes the selection from the thread pane and loads it into the message pane
|
|
|
|
function LoadSelectionIntoMessagePane()
|
1999-08-02 23:58:09 +00:00
|
|
|
{
|
1999-08-23 02:58:28 +00:00
|
|
|
var tree = GetThreadTree();
|
1999-08-02 23:58:09 +00:00
|
|
|
|
1999-08-23 02:58:28 +00:00
|
|
|
var selArray = tree.selectedItems;
|
1999-08-02 23:58:09 +00:00
|
|
|
if ( selArray && (selArray.length == 1) )
|
|
|
|
LoadMessage(selArray[0]);
|
|
|
|
else
|
2000-01-06 00:54:09 +00:00
|
|
|
{
|
|
|
|
// don't necessarily clear the message pane...if you uncomment this,
|
|
|
|
// you'll be introducing a large inefficiency when deleting messages...as deleting
|
|
|
|
// a msg brings us here twice...so we end up clearing the message pane twice for no
|
|
|
|
// good reason...
|
|
|
|
// ClearMessagePane();
|
|
|
|
}
|
1999-08-02 23:58:09 +00:00
|
|
|
}
|
|
|
|
|
1999-10-05 04:14:26 +00:00
|
|
|
function FolderPaneSelectionChange()
|
|
|
|
{
|
|
|
|
var tree = GetFolderTree();
|
|
|
|
if(tree)
|
|
|
|
{
|
|
|
|
var selArray = tree.selectedItems;
|
|
|
|
if ( selArray && (selArray.length == 1) )
|
2000-01-06 00:54:09 +00:00
|
|
|
{
|
1999-10-05 04:14:26 +00:00
|
|
|
ChangeFolderByDOMNode(selArray[0]);
|
2000-01-06 00:54:09 +00:00
|
|
|
// explicitly force the message pane to get cleared when we switch folders
|
|
|
|
ClearMessagePane();
|
|
|
|
}
|
1999-10-05 04:14:26 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
var threadTree = GetThreadTree();
|
|
|
|
ClearThreadTreeSelection();
|
|
|
|
threadTree.setAttribute('ref', null);
|
|
|
|
ClearMessagePane();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-07 00:22:44 +00:00
|
|
|
function OpenFolderTreeToFolder(folderURI)
|
|
|
|
{
|
|
|
|
var tree = GetFolderTree();
|
|
|
|
return OpenToFolder(tree, folderURI);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function OpenToFolder(item, folderURI)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(item.nodeType != Node.ELEMENT_NODE)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
var uri = item.getAttribute('id');
|
|
|
|
dump(uri);
|
|
|
|
dump('\n');
|
|
|
|
if(uri == folderURI)
|
|
|
|
{
|
|
|
|
dump('found folder: ' + uri);
|
|
|
|
dump('\n');
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
var children = item.childNodes;
|
|
|
|
var length = children.length;
|
|
|
|
var i;
|
|
|
|
dump('folder ' + uri);
|
|
|
|
dump('has ' + length);
|
|
|
|
dump('children\n');
|
|
|
|
for(i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
var child = children[i];
|
|
|
|
var folder = OpenToFolder(child, folderURI);
|
|
|
|
if(folder)
|
|
|
|
{
|
|
|
|
child.setAttribute('open', 'true');
|
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
1999-08-09 19:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function IsSpecialFolderSelected(folderName)
|
|
|
|
{
|
|
|
|
var selectedFolder = GetThreadTreeFolder();
|
|
|
|
var id = selectedFolder.getAttribute('ref');
|
|
|
|
var folderResource = RDF.GetResource(id);
|
|
|
|
if(!folderResource)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var folderTree = GetFolderTree();
|
|
|
|
var db = folderTree.database;
|
|
|
|
var db = db.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
|
|
|
|
|
|
|
var property = RDF.GetResource('http://home.netscape.com/NC-rdf#SpecialFolder');
|
|
|
|
var result = db.GetTarget(folderResource, property , true);
|
|
|
|
result = result.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
|
|
|
if(result.Value == folderName)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
1999-08-20 22:47:12 +00:00
|
|
|
|
1999-08-25 23:56:54 +00:00
|
|
|
|
|
|
|
function ChangeThreadView()
|
|
|
|
{
|
1999-11-11 00:23:29 +00:00
|
|
|
var folder = GetSelectedFolder();
|
|
|
|
|
1999-09-01 23:50:16 +00:00
|
|
|
var threadColumn = document.getElementById('ThreadColumnHeader');
|
1999-08-25 23:56:54 +00:00
|
|
|
if(threadColumn)
|
|
|
|
{
|
|
|
|
var currentView = threadColumn.getAttribute('currentView');
|
|
|
|
if(currentView== 'threaded')
|
|
|
|
{
|
|
|
|
ShowThreads(false);
|
1999-11-11 00:23:29 +00:00
|
|
|
if(folder)
|
|
|
|
folder.setAttribute('threaded', "");
|
1999-08-25 23:56:54 +00:00
|
|
|
}
|
|
|
|
else if(currentView == 'unthreaded')
|
|
|
|
{
|
|
|
|
ShowThreads(true);
|
1999-11-11 00:23:29 +00:00
|
|
|
if(folder)
|
|
|
|
folder.setAttribute('threaded', "true");
|
1999-08-25 23:56:54 +00:00
|
|
|
}
|
|
|
|
RefreshThreadTreeView();
|
|
|
|
}
|
|
|
|
}
|
1999-08-20 22:47:12 +00:00
|
|
|
|
1999-08-25 23:56:54 +00:00
|
|
|
function ShowThreads(showThreads)
|
|
|
|
{
|
1999-09-01 23:50:16 +00:00
|
|
|
dump('in showthreads\n');
|
1999-09-09 06:18:40 +00:00
|
|
|
if(messageView)
|
1999-08-25 23:56:54 +00:00
|
|
|
{
|
1999-09-09 06:18:40 +00:00
|
|
|
messageView.showThreads = showThreads;
|
1999-09-01 23:50:16 +00:00
|
|
|
var threadColumn = document.getElementById('ThreadColumnHeader');
|
1999-08-25 23:56:54 +00:00
|
|
|
if(threadColumn)
|
|
|
|
{
|
|
|
|
if(showThreads)
|
|
|
|
{
|
|
|
|
threadColumn.setAttribute('currentView', 'threaded');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
threadColumn.setAttribute('currentView', 'unthreaded');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-08-20 22:47:12 +00:00
|
|
|
}
|
|
|
|
|
1999-09-09 06:18:40 +00:00
|
|
|
function FolderTest5000()
|
|
|
|
{
|
|
|
|
|
|
|
|
folderDataSource = folderDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
|
|
|
|
|
|
|
var childProperty = RDF.GetResource("http://home.netscape.com/NC-rdf#MessageChild");
|
|
|
|
|
|
|
|
var folderResource = RDF.GetResource("mailbox://scottip@nsmail-2.mcom.com/test5000");
|
|
|
|
|
|
|
|
var beforeTime = new Date();
|
|
|
|
|
|
|
|
var messageChildren = folderDataSource.GetTargets(folderResource, childProperty, true);
|
|
|
|
|
|
|
|
var afterGetTargetsTime = new Date();
|
|
|
|
var timeToLoad = (afterGetTargetsTime.getTime() - beforeTime.getTime())/1000;
|
|
|
|
dump("Time to load is " + timeToLoad + " seconds\n");
|
|
|
|
|
|
|
|
messageChildren = messageChildren.QueryInterface(Components.interfaces.nsISimpleEnumerator);
|
|
|
|
|
|
|
|
while(messageChildren.HasMoreElements())
|
|
|
|
{
|
|
|
|
messageChildren.GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
var afterTime = new Date();
|
|
|
|
timeToLoad = (afterTime.getTime() - beforeTime.getTime())/1000;
|
|
|
|
dump("Time to load is " + timeToLoad + " seconds\n");
|
1999-09-12 08:27:01 +00:00
|
|
|
}
|
1999-09-13 21:11:45 +00:00
|
|
|
|
1999-09-14 04:41:46 +00:00
|
|
|
function GetNextMessageAfterDelete(messages)
|
1999-09-13 21:11:45 +00:00
|
|
|
{
|
|
|
|
var count = messages.length;
|
|
|
|
|
1999-09-14 04:41:46 +00:00
|
|
|
var curMessage = messages[0];
|
|
|
|
var nextMessage = null;
|
1999-10-27 04:46:12 +00:00
|
|
|
var tree = GetThreadTree();
|
|
|
|
|
1999-09-14 04:41:46 +00:00
|
|
|
//search forward
|
|
|
|
while(curMessage)
|
|
|
|
{
|
2000-01-09 19:47:58 +00:00
|
|
|
nextMessage = GetNextMessageUnthreaded(tree, curMessage, GoMessage, false);
|
1999-09-14 04:41:46 +00:00
|
|
|
if(nextMessage)
|
|
|
|
{
|
|
|
|
if(!MessageInSelection(nextMessage, messages))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curMessage = nextMessage;
|
|
|
|
}
|
|
|
|
//if no nextmessage then search backwards
|
|
|
|
if(!nextMessage)
|
|
|
|
{
|
|
|
|
|
|
|
|
var curMessage = messages[0];
|
|
|
|
var nextMessage = null;
|
|
|
|
//search forward
|
|
|
|
while(curMessage)
|
|
|
|
{
|
|
|
|
nextMessage = GetPreviousMessage(curMessage, GoMessage, false);
|
|
|
|
if(nextMessage)
|
|
|
|
{
|
|
|
|
if(!MessageInSelection(nextMessage, messages))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curMessage = nextMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
return nextMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
function MessageInSelection(message, messages)
|
|
|
|
{
|
|
|
|
var count = messages.length;
|
|
|
|
|
|
|
|
for(var i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if(message == messages[i])
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function SelectNextMessage(nextMessage)
|
|
|
|
{
|
1999-09-13 21:11:45 +00:00
|
|
|
var tree = GetThreadTree();
|
|
|
|
ChangeSelection(tree, nextMessage);
|
|
|
|
|
|
|
|
}
|
1999-12-03 05:59:57 +00:00
|
|
|
|
|
|
|
function GetSelectTrashUri(folder)
|
|
|
|
{
|
|
|
|
if (!folder) return null;
|
|
|
|
var uri = folder.getAttribute('id');
|
|
|
|
dump (uri + "\n");
|
|
|
|
var resource = RDF.GetResource(uri);
|
|
|
|
var msgFolder =
|
|
|
|
resource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
if (msgFolder)
|
|
|
|
{
|
|
|
|
dump("GetSelectTrashUri" + "\n");
|
|
|
|
var rootFolder = msgFolder.rootFolder;
|
|
|
|
var numFolder;
|
2000-01-11 08:01:37 +00:00
|
|
|
var out = new Object();
|
|
|
|
var trashFolder = rootFolder.getFoldersWithFlag(0x0100, 1, out);
|
2000-01-11 08:20:31 +00:00
|
|
|
numFolder = out.value;
|
1999-12-03 05:59:57 +00:00
|
|
|
dump (numFolder + "\n");
|
|
|
|
if (trashFolder)
|
|
|
|
{
|
|
|
|
dump (trashFolder.URI + "\n");
|
|
|
|
return trashFolder.URI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|