2000-04-11 20:19:32 +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.
|
2000-09-15 06:17:48 +00:00
|
|
|
*
|
|
|
|
* Contributors: timeless
|
2000-04-11 20:19:32 +00:00
|
|
|
*/
|
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
function file_init()
|
|
|
|
{
|
|
|
|
file_attachments();
|
|
|
|
/* file_attachments() can return false to indicate a load failure,
|
|
|
|
but if you return false to oncreate then
|
|
|
|
the popup menu will not display which is not a good thing.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
function file_attachments()
|
|
|
|
{
|
|
|
|
var apChild=document.getElementById('attachmentPopup').cloneNode(true);
|
|
|
|
if (!apChild)
|
|
|
|
return false;
|
|
|
|
apChild.removeAttribute('popupanchor');
|
|
|
|
apChild.removeAttribute('popupalign');
|
|
|
|
var amParent=document.getElementById('fileAttachmentMenu');
|
|
|
|
if (!amParent)
|
|
|
|
return false;
|
|
|
|
if (apChild.childNodes.length){
|
|
|
|
if ( amParent.childNodes.length )
|
|
|
|
amParent.removeChild(amParent.childNodes[0]);
|
|
|
|
amParent.appendChild(apChild);
|
|
|
|
amParent.removeAttribute('hidden');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
amParent.setAttribute('hidden',true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2000-07-13 05:18:17 +00:00
|
|
|
function view_init()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var message_menuitem=document.getElementById('menu_showMessage');
|
2000-08-08 04:46:42 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if (message_menuitem)
|
|
|
|
{
|
|
|
|
var message_menuitem_hidden = message_menuitem.getAttribute("hidden");
|
|
|
|
if(message_menuitem_hidden != "true"){
|
|
|
|
message_menuitem.setAttribute('checked',!IsThreadAndMessagePaneSplitterCollapsed());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var threadColumn = document.getElementById('ThreadColumnHeader');
|
|
|
|
var thread_menuitem=document.getElementById('menu_showThreads');
|
|
|
|
if (threadColumn && thread_menuitem){
|
|
|
|
thread_menuitem.setAttribute('checked',threadColumn.getAttribute('currentView')=='threaded');
|
|
|
|
}
|
2000-07-13 05:18:17 +00:00
|
|
|
}
|
|
|
|
|
2000-08-21 20:00:48 +00:00
|
|
|
function InitViewMessagesMenu()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var allMenuItem = document.getElementById("viewAllMessagesMenuItem");
|
|
|
|
var hidden = allMenuItem.getAttribute("hidden") == "true";
|
|
|
|
if(allMenuItem && !hidden)
|
|
|
|
allMenuItem.setAttribute("checked", messageView.viewType == viewShowAll);
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var unreadMenuItem = document.getElementById("viewUnreadMessagesMenuItem");
|
|
|
|
hidden = unreadMenuItem.getAttribute("hidden") == "true";
|
|
|
|
if(unreadMenuItem && !hidden)
|
|
|
|
unreadMenuItem.setAttribute("checked", messageView.viewType == viewShowUnread);
|
2000-08-21 20:00:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function InitMessageMenu()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var aMessage = GetSelectedMessage(0);
|
|
|
|
var isNews = false;
|
|
|
|
if(aMessage)
|
|
|
|
{
|
|
|
|
isNews = GetMessageType(aMessage) == "news";
|
|
|
|
}
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
//We show reply to Newsgroups only for news messages.
|
|
|
|
var replyNewsgroupMenuItem = document.getElementById("replyNewsgroupMainMenu");
|
|
|
|
if(replyNewsgroupMenuItem)
|
|
|
|
replyNewsgroupMenuItem.setAttribute("hidden", isNews ? "" : "true");
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
//For mail messages we say reply. For news we say ReplyToSender.
|
|
|
|
var replyMenuItem = document.getElementById("replyMainMenu");
|
|
|
|
if(replyMenuItem)
|
|
|
|
{
|
|
|
|
replyMenuItem.setAttribute("hidden", !isNews ? "" : "true");
|
|
|
|
}
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var replySenderMenuItem = document.getElementById("replySenderMainMenu");
|
|
|
|
if(replySenderMenuItem)
|
|
|
|
{
|
|
|
|
replySenderMenuItem.setAttribute("hidden", isNews ? "" : "true");
|
|
|
|
}
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
//disable the move and copy menus only if there are no messages selected.
|
|
|
|
var moveMenu = document.getElementById("moveMenu");
|
|
|
|
if(moveMenu)
|
|
|
|
moveMenu.setAttribute("disabled", !aMessage);
|
2000-08-26 20:54:51 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var copyMenu = document.getElementById("copyMenu");
|
|
|
|
if(copyMenu)
|
|
|
|
copyMenu.setAttribute("disabled", !aMessage);
|
2000-08-26 20:54:51 +00:00
|
|
|
|
2000-08-21 20:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function GetMessageType(message)
|
|
|
|
{
|
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var compositeDS = GetCompositeDataSource("MessageProperty");
|
|
|
|
var property = RDF.GetResource('http://home.netscape.com/NC-rdf#MessageType');
|
|
|
|
var result = compositeDS.GetTarget(message, property, true);
|
|
|
|
result = result.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
|
|
|
return result.Value;
|
2000-08-21 20:00:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function InitMessageMarkMenu()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
InitMarkReadMenuItem();
|
|
|
|
InitMarkFlaggedMenuItem();
|
2000-08-21 20:00:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function InitMarkReadMenuItem()
|
|
|
|
{
|
2000-08-26 20:54:51 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
areMessagesRead = SelectedMessagesAreRead();
|
2000-08-26 20:54:51 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var markReadMenuItem = document.getElementById("markReadMenuItem");
|
|
|
|
if(markReadMenuItem)
|
|
|
|
markReadMenuItem.setAttribute("checked", areMessagesRead);
|
2000-08-26 20:54:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function SelectedMessagesAreRead()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var aMessage = GetSelectedMessage(0);
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var compositeDS = GetCompositeDataSource("MarkMessageRead");
|
|
|
|
var property = RDF.GetResource('http://home.netscape.com/NC-rdf#IsUnread');
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var areMessagesRead =false;
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if(!aMessage)
|
|
|
|
areMessagesRead = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var result = compositeDS.GetTarget(aMessage, property, true);
|
|
|
|
result = result.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
|
|
|
areMessagesRead = result.Value != "true"
|
|
|
|
}
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
return areMessagesRead;
|
2000-08-21 20:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function InitMarkFlaggedMenuItem()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
areMessagesFlagged = SelectedMessagesAreFlagged();
|
2000-08-26 20:54:51 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var markFlaggedMenuItem = document.getElementById("markFlaggedMenuItem");
|
|
|
|
if(markFlaggedMenuItem)
|
|
|
|
markFlaggedMenuItem.setAttribute("checked", areMessagesFlagged);
|
2000-08-26 20:54:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function SelectedMessagesAreFlagged()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var aMessage = GetSelectedMessage(0);
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var compositeDS = GetCompositeDataSource("MarkMessageFlagged");
|
|
|
|
var property = RDF.GetResource('http://home.netscape.com/NC-rdf#Flagged');
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var areMessagesFlagged = false;
|
2000-08-21 20:00:48 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if(!aMessage)
|
|
|
|
areMessagesFlagged = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var result = compositeDS.GetTarget(aMessage, property, true);
|
|
|
|
result = result.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
|
|
|
areMessagesFlagged = (result.Value == "flagged");
|
|
|
|
}
|
|
|
|
return areMessagesFlagged;
|
2000-08-21 20:00:48 +00:00
|
|
|
}
|
|
|
|
|
2000-04-14 14:07:23 +00:00
|
|
|
function GetFirstSelectedMsgFolder()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var result = null;
|
|
|
|
var selectedFolders = GetSelectedMsgFolders();
|
|
|
|
if (selectedFolders.length > 0) {
|
|
|
|
result = selectedFolders[0];
|
|
|
|
}
|
2000-04-14 14:07:23 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
return result;
|
2000-04-14 14:07:23 +00:00
|
|
|
}
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
function MsgGetMessage()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var folders = GetSelectedMsgFolders();
|
|
|
|
var compositeDataSource = GetCompositeDataSource("GetNewMessages");
|
|
|
|
GetNewMessages(folders, compositeDataSource);
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
|
2000-08-30 23:22:22 +00:00
|
|
|
function MsgGetNextNMessages()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var folder = GetFirstSelectedMsgFolder();
|
|
|
|
if(folder)
|
|
|
|
{
|
|
|
|
GetNextNMessages(folder)
|
|
|
|
}
|
2000-08-30 23:22:22 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 05:30:32 +00:00
|
|
|
function MsgDeleteMessage(reallyDelete, fromToolbar)
|
|
|
|
{
|
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if(reallyDelete)
|
|
|
|
dump("reallyDelete\n");
|
|
|
|
var srcFolder = GetLoadedMsgFolder();
|
|
|
|
// if from the toolbar, return right away if this is a news message
|
|
|
|
// only allow cancel from the menu: "Edit | Cancel / Delete Message"
|
|
|
|
if (fromToolbar)
|
|
|
|
{
|
|
|
|
var folderResource = srcFolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
var uri = folderResource.Value;
|
2000-12-05 01:25:21 +00:00
|
|
|
if (isNewsURI(uri))
|
2000-09-15 06:17:48 +00:00
|
|
|
{
|
|
|
|
//dump("delete ignored!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dump("tree is valid\n");
|
|
|
|
//get the selected elements
|
|
|
|
|
|
|
|
var compositeDataSource = GetCompositeDataSource("DeleteMessages");
|
|
|
|
var messages = GetSelectedMessages();
|
|
|
|
|
|
|
|
SetNextMessageAfterDelete(null, true);
|
|
|
|
DeleteMessages(compositeDataSource, srcFolder, messages, reallyDelete);
|
2000-04-20 05:30:32 +00:00
|
|
|
}
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
function MsgCopyMessage(destFolder)
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
// Get the id for the folder we're copying into
|
2000-04-11 20:19:32 +00:00
|
|
|
destUri = destFolder.getAttribute('id');
|
2000-09-15 06:17:48 +00:00
|
|
|
destResource = RDF.GetResource(destUri);
|
|
|
|
destMsgFolder = destResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
2000-04-11 20:19:32 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var srcFolder = GetLoadedMsgFolder();
|
|
|
|
if(srcFolder)
|
|
|
|
{
|
|
|
|
var compositeDataSource = GetCompositeDataSource("Copy");
|
|
|
|
var messages = GetSelectedMessages();
|
2000-04-11 20:19:32 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
CopyMessages(compositeDataSource, srcFolder, destMsgFolder, messages, false);
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 05:30:32 +00:00
|
|
|
function MsgMoveMessage(destFolder)
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
// Get the id for the folder we're copying into
|
2000-04-20 05:30:32 +00:00
|
|
|
destUri = destFolder.getAttribute('id');
|
2000-09-15 06:17:48 +00:00
|
|
|
destResource = RDF.GetResource(destUri);
|
|
|
|
destMsgFolder = destResource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
|
|
|
|
var srcFolder = GetLoadedMsgFolder();
|
|
|
|
if(srcFolder)
|
|
|
|
{
|
|
|
|
var compositeDataSource = GetCompositeDataSource("Move");
|
|
|
|
var messages = GetSelectedMessages();
|
|
|
|
|
|
|
|
var srcResource = srcFolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
var srcUri = srcResource.Value;
|
2000-12-05 01:25:21 +00:00
|
|
|
if (isNewsURI(srcUri))
|
2000-09-15 06:17:48 +00:00
|
|
|
{
|
|
|
|
CopyMessages(compositeDataSource, srcFolder, destMsgFolder, messages, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetNextMessageAfterDelete(null, true);
|
|
|
|
|
|
|
|
CopyMessages(compositeDataSource, srcFolder, destMsgFolder, messages, true);
|
|
|
|
}
|
|
|
|
}
|
2000-04-20 05:30:32 +00:00
|
|
|
}
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
function MsgNewMessage(event)
|
|
|
|
{
|
2000-04-14 14:07:23 +00:00
|
|
|
var loadedFolder = GetFirstSelectedMsgFolder();
|
2000-04-11 20:19:32 +00:00
|
|
|
var messageArray = GetSelectedMessages();
|
|
|
|
|
2000-07-05 22:06:34 +00:00
|
|
|
if (event && event.shiftKey)
|
2000-04-11 20:19:32 +00:00
|
|
|
ComposeMessage(msgComposeType.New, msgComposeFormat.OppositeOfDefault, loadedFolder, messageArray);
|
|
|
|
else
|
|
|
|
ComposeMessage(msgComposeType.New, msgComposeFormat.Default, loadedFolder, messageArray);
|
|
|
|
}
|
|
|
|
|
|
|
|
function MsgReplyMessage(event)
|
2000-08-21 20:00:48 +00:00
|
|
|
{
|
|
|
|
var loadedFolder = GetLoadedMsgFolder();
|
|
|
|
|
|
|
|
var server = loadedFolder.server;
|
|
|
|
|
|
|
|
if(server && server.type == "nntp")
|
2000-09-15 06:17:48 +00:00
|
|
|
MsgReplyGroup(event);
|
2000-08-21 20:00:48 +00:00
|
|
|
else
|
2000-09-15 06:17:48 +00:00
|
|
|
MsgReplySender(event);
|
2000-08-21 20:00:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function MsgReplySender(event)
|
2000-04-11 20:19:32 +00:00
|
|
|
{
|
|
|
|
var loadedFolder = GetLoadedMsgFolder();
|
|
|
|
var messageArray = GetSelectedMessages();
|
|
|
|
|
2000-05-08 22:04:10 +00:00
|
|
|
if (event && event.shiftKey)
|
2000-04-11 20:19:32 +00:00
|
|
|
ComposeMessage(msgComposeType.Reply, msgComposeFormat.OppositeOfDefault, loadedFolder, messageArray);
|
|
|
|
else
|
|
|
|
ComposeMessage(msgComposeType.Reply, msgComposeFormat.Default, loadedFolder, messageArray);
|
2000-08-21 20:00:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function MsgReplyGroup(event)
|
|
|
|
{
|
|
|
|
var loadedFolder = GetLoadedMsgFolder();
|
|
|
|
var messageArray = GetSelectedMessages();
|
|
|
|
|
|
|
|
if (event && event.shiftKey)
|
|
|
|
ComposeMessage(msgComposeType.ReplyToGroup, msgComposeFormat.OppositeOfDefault, loadedFolder, messageArray);
|
|
|
|
else
|
|
|
|
ComposeMessage(msgComposeType.ReplyToGroup, msgComposeFormat.Default, loadedFolder, messageArray);
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgReplyToAllMessage(event)
|
|
|
|
{
|
|
|
|
var loadedFolder = GetLoadedMsgFolder();
|
|
|
|
var messageArray = GetSelectedMessages();
|
|
|
|
|
|
|
|
dump("\nMsgReplyToAllMessage from XUL\n");
|
2000-05-08 22:04:10 +00:00
|
|
|
if (event && event.shiftKey)
|
2000-04-11 20:19:32 +00:00
|
|
|
ComposeMessage(msgComposeType.ReplyAll, msgComposeFormat.OppositeOfDefault, loadedFolder, messageArray);
|
|
|
|
else
|
|
|
|
ComposeMessage(msgComposeType.ReplyAll, msgComposeFormat.Default, loadedFolder, messageArray);
|
|
|
|
}
|
|
|
|
|
|
|
|
function MsgForwardMessage(event)
|
|
|
|
{
|
|
|
|
|
|
|
|
dump("\nMsgForwardMessage from XUL\n");
|
|
|
|
var forwardType = 0;
|
|
|
|
try {
|
2000-09-15 06:17:48 +00:00
|
|
|
forwardType = pref.GetIntPref("mail.forward_message_mode");
|
2000-04-11 20:19:32 +00:00
|
|
|
} catch (e) {dump ("failed to retrieve pref mail.forward_message_mode");}
|
|
|
|
|
|
|
|
if (forwardType == 0)
|
2000-09-15 06:17:48 +00:00
|
|
|
MsgForwardAsAttachment(event);
|
2000-04-11 20:19:32 +00:00
|
|
|
else
|
2000-09-15 06:17:48 +00:00
|
|
|
MsgForwardAsInline(event);
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgForwardAsAttachment(event)
|
|
|
|
{
|
|
|
|
var loadedFolder = GetLoadedMsgFolder();
|
|
|
|
var messageArray = GetSelectedMessages();
|
|
|
|
|
|
|
|
dump("\nMsgForwardAsAttachment from XUL\n");
|
2000-05-08 22:04:10 +00:00
|
|
|
if (event && event.shiftKey)
|
2000-04-11 20:19:32 +00:00
|
|
|
ComposeMessage(msgComposeType.ForwardAsAttachment,
|
|
|
|
msgComposeFormat.OppositeOfDefault, loadedFolder, messageArray);
|
|
|
|
else
|
|
|
|
ComposeMessage(msgComposeType.ForwardAsAttachment, msgComposeFormat.Default, loadedFolder, messageArray);
|
|
|
|
}
|
|
|
|
|
|
|
|
function MsgForwardAsInline(event)
|
|
|
|
{
|
|
|
|
var loadedFolder = GetLoadedMsgFolder();
|
|
|
|
var messageArray = GetSelectedMessages();
|
|
|
|
|
|
|
|
dump("\nMsgForwardAsInline from XUL\n");
|
2000-05-08 22:04:10 +00:00
|
|
|
if (event && event.shiftKey)
|
2000-04-11 20:19:32 +00:00
|
|
|
ComposeMessage(msgComposeType.ForwardInline,
|
|
|
|
msgComposeFormat.OppositeOfDefault, loadedFolder, messageArray);
|
|
|
|
else
|
|
|
|
ComposeMessage(msgComposeType.ForwardInline, msgComposeFormat.Default, loadedFolder, messageArray);
|
|
|
|
}
|
|
|
|
|
2000-04-14 14:07:23 +00:00
|
|
|
|
|
|
|
function MsgEditMessageAsNew()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var loadedFolder = GetLoadedMsgFolder();
|
|
|
|
var messageArray = GetSelectedMessages();
|
2000-04-14 14:07:23 +00:00
|
|
|
ComposeMessage(msgComposeType.Template, msgComposeFormat.Default, loadedFolder, messageArray);
|
|
|
|
}
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
function MsgHome(url)
|
|
|
|
{
|
|
|
|
window.open( url, "_blank", "chrome,dependent=yes,all" );
|
|
|
|
}
|
|
|
|
|
|
|
|
function MsgNewFolder()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var windowTitle = Bundle.GetStringFromName("newFolderDialogTitle");
|
|
|
|
var preselectedFolder = GetFirstSelectedMsgFolder();
|
2000-09-13 14:24:41 +00:00
|
|
|
var dualUseFolders = true;
|
|
|
|
var server = null;
|
2000-10-06 14:31:00 +00:00
|
|
|
var destinationFolder = null;
|
|
|
|
|
2000-09-13 14:24:41 +00:00
|
|
|
if (preselectedFolder)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
server = preselectedFolder.server;
|
|
|
|
if (server)
|
|
|
|
{
|
2000-10-06 14:31:00 +00:00
|
|
|
destinationFolder = getDestinationFolder(preselectedFolder, server);
|
|
|
|
|
2000-09-13 14:24:41 +00:00
|
|
|
var imapServer =
|
|
|
|
server.QueryInterface(Components.interfaces.nsIImapIncomingServer);
|
|
|
|
if (imapServer)
|
|
|
|
dualUseFolders = imapServer.dualUseFolders;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
dump ("Exception: dualUseFolders = true\n");
|
|
|
|
}
|
|
|
|
}
|
2000-10-06 14:31:00 +00:00
|
|
|
|
|
|
|
CreateNewSubfolder("chrome://messenger/content/newFolderNameDialog.xul",windowTitle, destinationFolder, dualUseFolders);
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-06 14:31:00 +00:00
|
|
|
function getDestinationFolder(preselectedFolder, server)
|
|
|
|
{
|
|
|
|
var destinationFolder = null;
|
|
|
|
|
|
|
|
var isCreateSubfolders = preselectedFolder.canCreateSubfolders;
|
|
|
|
if (!isCreateSubfolders)
|
|
|
|
{
|
|
|
|
var tmpDestFolder = server.RootFolder;
|
|
|
|
destinationFolder
|
|
|
|
= tmpDestFolder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
|
|
|
|
var verifyCreateSubfolders = null;
|
|
|
|
if (destinationFolder)
|
|
|
|
verifyCreateSubfolders = destinationFolder.canCreateSubfolders;
|
|
|
|
|
|
|
|
// in case the server cannot have subfolders,
|
|
|
|
// get default account and set its incoming server as parent folder
|
|
|
|
if (!verifyCreateSubfolders)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
var account = accountManager.defaultAccount;
|
|
|
|
var defaultServer = account.incomingServer;
|
|
|
|
var tmpDefaultFolder = defaultServer.RootFolder;
|
|
|
|
var defaultFolder
|
|
|
|
= tmpDefaultFolder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
|
|
|
|
|
|
|
var checkCreateSubfolders = null;
|
|
|
|
if (defaultFolder)
|
|
|
|
checkCreateSubfolders = defaultFolder.canCreateSubfolders;
|
|
|
|
|
|
|
|
if (checkCreateSubfolders)
|
|
|
|
destinationFolder = defaultFolder;
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
dump ("Exception: defaultAccount Not Available\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
destinationFolder = preselectedFolder;
|
|
|
|
|
|
|
|
return destinationFolder;
|
|
|
|
}
|
|
|
|
|
2000-04-11 20:19:32 +00:00
|
|
|
function MsgSubscribe()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var windowTitle = Bundle.GetStringFromName("subscribeDialogTitle");
|
|
|
|
var preselectedFolder = GetFirstSelectedMsgFolder();
|
|
|
|
Subscribe(windowTitle, preselectedFolder);
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSaveAsFile()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
dump("\MsgSaveAsFile from XUL\n");
|
|
|
|
var messages = GetSelectedMessages();
|
|
|
|
if (messages && messages.length == 1)
|
|
|
|
{
|
|
|
|
SaveAsFile(messages[0]);
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function MsgSaveAsTemplate()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
dump("\MsgSaveAsTemplate from XUL\n");
|
|
|
|
var folder = GetLoadedMsgFolder();
|
|
|
|
var messages = GetSelectedMessages();
|
|
|
|
if (messages && messages.length == 1)
|
|
|
|
{
|
|
|
|
SaveAsTemplate(messages[0], folder);
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgOpenNewWindowForFolder(folderUri)
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
if(!folderUri)
|
|
|
|
{
|
|
|
|
var folder = GetLoadedMsgFolder();
|
|
|
|
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
folderUri = folderResource.Value;
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if(folderUri)
|
|
|
|
{
|
|
|
|
var layoutType = pref.GetIntPref("mail.pane_config");
|
|
|
|
|
|
|
|
if(layoutType == 0)
|
|
|
|
window.openDialog( "chrome://messenger/content/messenger.xul", "_blank", "chrome,all,dialog=no", folderUri );
|
|
|
|
else
|
|
|
|
window.openDialog("chrome://messenger/content/mail3PaneWindowVertLayout.xul", "_blank", "chrome,all,dialog=no", folderUri );
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function MsgOpenNewWindowForMessage(messageUri, folderUri)
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var message;
|
2000-09-08 21:57:43 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if(!messageUri)
|
|
|
|
{
|
|
|
|
message = GetLoadedMessage();
|
|
|
|
var messageResource = message.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
messageUri = messageResource.Value;
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if(!folderUri)
|
|
|
|
{
|
2000-09-08 21:57:43 +00:00
|
|
|
message = RDF.GetResource(messageUri);
|
2000-06-30 06:02:30 +00:00
|
|
|
message = message.QueryInterface(Components.interfaces.nsIMessage);
|
|
|
|
var folder = message.msgFolder;
|
2000-09-15 06:17:48 +00:00
|
|
|
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
folderUri = folderResource.Value;
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if(messageUri && folderUri)
|
|
|
|
{
|
|
|
|
window.openDialog( "chrome://messenger/content/messageWindow.xul", "_blank", "chrome,all,dialog=no", messageUri, folderUri );
|
|
|
|
}
|
2000-04-11 20:19:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-05-01 21:58:24 +00:00
|
|
|
function CloseMailWindow()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
dump("\nClose from XUL\nDo something...\n");
|
|
|
|
window.close();
|
2000-05-01 21:58:24 +00:00
|
|
|
}
|
|
|
|
|
2000-04-14 14:07:23 +00:00
|
|
|
function MsgMarkMsgAsRead(markRead)
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
if(markRead == null)
|
|
|
|
{
|
|
|
|
markRead= !SelectedMessagesAreRead();
|
|
|
|
}
|
|
|
|
var selectedMessages = GetSelectedMessages();
|
|
|
|
var compositeDataSource = GetCompositeDataSource("MarkMessageRead");
|
2000-04-14 14:07:23 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
MarkMessagesRead(compositeDataSource, selectedMessages, markRead);
|
2000-04-14 14:07:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgMarkAsFlagged(markFlagged)
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
if(markFlagged == null)
|
|
|
|
{
|
|
|
|
markFlagged= !SelectedMessagesAreFlagged();
|
|
|
|
}
|
2000-08-26 20:54:51 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var selectedMessages = GetSelectedMessages();
|
|
|
|
var compositeDataSource = GetCompositeDataSource("MarkMessageFlagged");
|
2000-04-14 14:07:23 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
MarkMessagesFlagged(compositeDataSource, selectedMessages, markFlagged);
|
2000-04-14 14:07:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function MsgMarkAllRead()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var compositeDataSource = GetCompositeDataSource("MarkAllMessagesRead");
|
|
|
|
var folder = GetLoadedMsgFolder();
|
2000-04-14 14:07:23 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if(folder)
|
|
|
|
MarkAllMessagesRead(compositeDataSource, folder);
|
2000-04-14 14:07:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgMarkThreadAsRead()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
|
|
|
|
var messageList = GetSelectedMessages();
|
|
|
|
if(messageList.length == 1)
|
|
|
|
{
|
|
|
|
var message = messageList[0];
|
|
|
|
var compositeDataSource = GetCompositeDataSource("MarkThreadAsRead");
|
2000-04-14 14:07:23 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
MarkThreadAsRead(compositeDataSource, message);
|
|
|
|
}
|
2000-04-14 14:07:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-04-20 05:30:32 +00:00
|
|
|
function MsgViewPageSource()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
dump("MsgViewPageSource(); \n ");
|
|
|
|
|
|
|
|
var messages = GetSelectedMessages();
|
|
|
|
ViewPageSource(messages);
|
2000-04-20 05:30:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgFind() {
|
|
|
|
messenger.find();
|
|
|
|
}
|
|
|
|
function MsgFindAgain() {
|
|
|
|
messenger.findAgain();
|
|
|
|
}
|
|
|
|
|
|
|
|
function MsgSearchMessages() {
|
2000-09-15 06:17:48 +00:00
|
|
|
var preselectedFolder = GetFirstSelectedMsgFolder();
|
2000-06-22 22:52:05 +00:00
|
|
|
window.openDialog("chrome://messenger/content/SearchDialog.xul", "SearchMail", "chrome,resizable", { folder: preselectedFolder });
|
2000-04-20 05:30:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgFilters() {
|
2000-06-27 04:42:34 +00:00
|
|
|
window.openDialog("chrome://messenger/content/FilterListDialog.xul", "FilterDialog", "chrome,resizable");
|
2000-04-20 05:30:32 +00:00
|
|
|
}
|
|
|
|
|
2000-05-01 21:58:24 +00:00
|
|
|
function MsgViewAllHeaders()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
pref.SetIntPref("mail.show_headers",2);
|
|
|
|
MsgReload();
|
|
|
|
return true;
|
2000-05-01 21:58:24 +00:00
|
|
|
}
|
|
|
|
function MsgViewNormalHeaders()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
pref.SetIntPref("mail.show_headers",1);
|
|
|
|
MsgReload();
|
|
|
|
return true;
|
2000-05-01 21:58:24 +00:00
|
|
|
}
|
|
|
|
function MsgViewBriefHeaders()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
pref.SetIntPref("mail.show_headers",0);
|
|
|
|
MsgReload();
|
|
|
|
return true;
|
2000-05-01 21:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgReload()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
ReloadMessage();
|
2000-05-01 21:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function MsgStop()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
StopUrls();
|
2000-05-01 21:58:24 +00:00
|
|
|
}
|
2000-04-20 05:30:32 +00:00
|
|
|
|
2000-05-16 22:56:08 +00:00
|
|
|
function MsgSendUnsentMsg()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var folder = GetFirstSelectedMsgFolder();
|
|
|
|
if(folder)
|
|
|
|
{
|
|
|
|
SendUnsentMessages(folder);
|
|
|
|
}
|
2000-05-16 22:56:08 +00:00
|
|
|
}
|
|
|
|
|
2000-08-16 03:23:21 +00:00
|
|
|
function PrintEnginePrint()
|
|
|
|
{
|
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var messageList = GetSelectedMessages();
|
|
|
|
numMessages = messageList.length;
|
2000-08-16 03:23:21 +00:00
|
|
|
|
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
if (numMessages == 0)
|
|
|
|
{
|
|
|
|
dump("PrintEnginePrint(): No messages selected.\n");
|
|
|
|
return false;
|
|
|
|
}
|
2000-08-16 03:23:21 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var selectionArray = new Array(numMessages);
|
2000-08-16 03:23:21 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
for(var i = 0; i < numMessages; i++)
|
|
|
|
{
|
|
|
|
var messageResource = messageList[i].QueryInterface(Components.interfaces.nsIRDFResource);
|
|
|
|
selectionArray[i] = messageResource.Value;
|
|
|
|
}
|
2000-08-16 03:23:21 +00:00
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
printEngineWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
|
|
|
|
"",
|
|
|
|
"chrome,dialog=no,all",
|
|
|
|
numMessages, selectionArray, statusFeedback);
|
|
|
|
return true;
|
2000-08-16 03:23:21 +00:00
|
|
|
}
|
|
|
|
|
2000-08-26 20:54:51 +00:00
|
|
|
function IsMailFolderSelected()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var selectedFolders = GetSelectedMsgFolders();
|
|
|
|
var numFolders = selectedFolders.length;
|
|
|
|
if(numFolders !=1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var folder = selectedFolders[0];
|
|
|
|
if (!folder)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var server = folder.server;
|
|
|
|
var serverType = server.type;
|
|
|
|
|
|
|
|
if((serverType == "nntp"))
|
|
|
|
return false;
|
|
|
|
else return true;
|
2000-08-26 20:54:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function IsGetNewMessagesEnabled()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var selectedFolders = GetSelectedMsgFolders();
|
|
|
|
var numFolders = selectedFolders.length;
|
|
|
|
if(numFolders !=1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var folder = selectedFolders[0];
|
|
|
|
if (!folder)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var server = folder.server;
|
|
|
|
var isServer = folder.isServer;
|
|
|
|
var serverType = server.type;
|
|
|
|
|
|
|
|
if(isServer && (serverType == "nntp"))
|
|
|
|
return false;
|
|
|
|
else if(serverType == "none")
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return true;
|
2000-08-26 20:54:51 +00:00
|
|
|
}
|
|
|
|
|
2000-08-30 23:22:22 +00:00
|
|
|
function IsGetNextNMessagesEnabled()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
var selectedFolders = GetSelectedMsgFolders();
|
2000-08-30 23:22:22 +00:00
|
|
|
var numFolders = selectedFolders.length;
|
|
|
|
if(numFolders !=1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var folder = selectedFolders[0];
|
|
|
|
if (!folder)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var server = folder.server;
|
|
|
|
var serverType = server.type;
|
|
|
|
|
2000-09-15 06:17:48 +00:00
|
|
|
var menuItem = document.getElementById("menu_getnextnmsg");
|
2000-09-01 00:55:11 +00:00
|
|
|
if((serverType == "nntp")) {
|
2000-09-15 06:17:48 +00:00
|
|
|
var newsServer = server.QueryInterface(Components.interfaces.nsINntpIncomingServer);
|
|
|
|
var menuValue = Bundle.formatStringFromName("getNextNMessages",
|
2000-09-01 00:55:11 +00:00
|
|
|
[ newsServer.maxArticles], 1);
|
2000-09-15 06:17:48 +00:00
|
|
|
menuItem.setAttribute("value",menuValue);
|
|
|
|
menuItem.setAttribute("hidden","false");
|
2000-08-30 23:22:22 +00:00
|
|
|
return true;
|
2000-09-15 06:17:48 +00:00
|
|
|
}
|
2000-09-01 00:55:11 +00:00
|
|
|
else {
|
2000-09-15 06:17:48 +00:00
|
|
|
menuItem.setAttribute("hidden","true");
|
|
|
|
return false;
|
|
|
|
}
|
2000-08-30 23:22:22 +00:00
|
|
|
}
|
|
|
|
|
2000-08-26 20:54:51 +00:00
|
|
|
function IsEmptyTrashEnabled()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
return IsMailFolderSelected();
|
2000-08-26 20:54:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function IsCompactFolderEnabled()
|
|
|
|
{
|
2000-09-15 06:17:48 +00:00
|
|
|
return IsMailFolderSelected();
|
2000-08-26 20:54:51 +00:00
|
|
|
}
|
2000-08-16 03:23:21 +00:00
|
|
|
|
2000-04-14 14:07:23 +00:00
|
|
|
function MsgMarkByDate() {}
|
|
|
|
function MsgOpenAttachment() {}
|
|
|
|
function MsgUpdateMsgCount() {}
|
|
|
|
function MsgImport() {}
|
|
|
|
function MsgWorkOffline() {}
|
|
|
|
function MsgSynchronize() {}
|
|
|
|
function MsgGetSelectedMsg() {}
|
|
|
|
function MsgGetFlaggedMsg() {}
|
|
|
|
function MsgSelectThread() {}
|
|
|
|
function MsgSelectFlaggedMsg() {}
|
|
|
|
function MsgShowFolders(){}
|
|
|
|
function MsgShowLocationbar() {}
|
|
|
|
function MsgViewAttachInline() {}
|
|
|
|
function MsgWrapLongLines() {}
|
|
|
|
function MsgIncreaseFont() {}
|
|
|
|
function MsgDecreaseFont() {}
|
|
|
|
function MsgShowImages() {}
|
|
|
|
function MsgRefresh() {}
|
|
|
|
function MsgViewPageInfo() {}
|
|
|
|
function MsgFirstUnreadMessage() {}
|
|
|
|
function MsgFirstFlaggedMessage() {}
|
|
|
|
function MsgGoBack() {}
|
|
|
|
function MsgGoForward() {}
|
|
|
|
function MsgAddSenderToAddressBook() {}
|
|
|
|
function MsgAddAllToAddressBook() {}
|
|
|
|
function MsgIgnoreThread() {}
|
|
|
|
function MsgWatchThread() {}
|