/* -*- 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. * * Contributors: timeless * slucy@objectivesw.co.uk * Håkan Waara */ var gMessengerBundle; function goUpdateMailMenuItems(commandset) { // dump("Updating commands for " + commandset.id + "\n"); for (var i = 0; i < commandset.childNodes.length; i++) { var commandID = commandset.childNodes[i].getAttribute("id"); if (commandID) { goUpdateCommand(commandID); } } } function file_init() { if (!gMessengerBundle) gMessengerBundle = document.getElementById("bundle_messenger"); 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. */ document.commandDispatcher.updateCommands('create-menu-file'); } 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; } function InitEditMessagesMenu() { document.commandDispatcher.updateCommands('create-menu-edit'); } function InitSearchMessagesMenu() { document.commandDispatcher.updateCommands('create-menu-search'); } function InitGoMessagesMenu() { document.commandDispatcher.updateCommands('create-menu-go'); } function view_init() { if (!gMessengerBundle) gMessengerBundle = document.getElementById("bundle_messenger"); var message_menuitem=document.getElementById('menu_showMessage'); 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'); } document.commandDispatcher.updateCommands('create-menu-view'); } function setSortByMenuItemCheckState(id, value) { var menuitem = document.getElementById(id); if (menuitem) { menuitem.setAttribute("checked", value); } } function InitViewSortByMenu() { var sortType = gDBView.sortType; setSortByMenuItemCheckState("sortByDateMenuitem", (sortType == nsMsgViewSortType.byDate)); setSortByMenuItemCheckState("sortByFlagMenuitem", (sortType == nsMsgViewSortType.byFlagged)); setSortByMenuItemCheckState("sortByOrderReceivedMenuitem", (sortType == nsMsgViewSortType.byId)); setSortByMenuItemCheckState("sortByPriorityMenuitem", (sortType == nsMsgViewSortType.byPriority)); setSortByMenuItemCheckState("sortBySizeMenuitem", (sortType == nsMsgViewSortType.bySize)); setSortByMenuItemCheckState("sortByStatusMenuitem", (sortType == nsMsgViewSortType.byStatus)); setSortByMenuItemCheckState("sortBySubjectMenuitem", (sortType == nsMsgViewSortType.bySubject)); setSortByMenuItemCheckState("sortByThreadMenuitem", (sortType == nsMsgViewSortType.byThread)); setSortByMenuItemCheckState("sortByUnreadMenuitem", (sortType == nsMsgViewSortType.byUnread)); // the Sender / Recipient menu is dynamic setSortByMenuItemCheckState("sortBySenderOrRecipientMenuitem", (sortType == nsMsgViewSortType.byAuthor) || (sortType == nsMsgViewSortType.byRecipient)); var senderOrRecipientMenuitem = document.getElementById("sortBySenderOrRecipientMenuitem"); if (senderOrRecipientMenuitem) { var currentFolder = gDBView.msgFolder; if (IsSpecialFolder(currentFolder, MSG_FOLDER_FLAG_SENTMAIL | MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_QUEUE)) { senderOrRecipientMenuitem.setAttribute('label',gMessengerBundle.getString('recipientColumnHeader')); senderOrRecipientMenuitem.setAttribute('accesskey',gMessengerBundle.getString('recipientAccessKey')); } else { senderOrRecipientMenuitem.setAttribute('label',gMessengerBundle.getString('senderColumnHeader')); senderOrRecipientMenuitem.setAttribute('accesskey',gMessengerBundle.getString('senderAccessKey')); } } var sortOrder = gDBView.sortOrder; setSortByMenuItemCheckState("sortAscending", (sortOrder == nsMsgViewSortOrder.ascending)); setSortByMenuItemCheckState("sortDescending", (sortOrder == nsMsgViewSortOrder.descending)); } function InitViewMessagesMenu() { var allMenuItem = document.getElementById("viewAllMessagesMenuItem"); var viewFlags = gDBView.viewFlags; var viewType = gDBView.viewType; if(allMenuItem) allMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kUnreadOnly) == 0 && (viewType == nsMsgViewType.eShowAllThreads)); var unreadMenuItem = document.getElementById("viewUnreadMessagesMenuItem"); if(unreadMenuItem) unreadMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kUnreadOnly) != 0); var theadedMenuItem = document.getElementById("menu_showThreads"); if (theadedMenuItem) theadedMenuItem.setAttribute("checked", (viewFlags & nsMsgViewFlagsType.kThreadedDisplay) != 0); document.commandDispatcher.updateCommands('create-menu-view'); var theadsWithUnreadMenuItem = document.getElementById("viewThreadsWithUnreadMenuItem"); if(theadsWithUnreadMenuItem) theadsWithUnreadMenuItem.setAttribute("checked", viewType == nsMsgViewType.eShowThreadsWithUnread); var watchedTheadsWithUnreadMenuItem = document.getElementById("viewWatchedThreadsWithUnreadMenuItem"); if(watchedTheadsWithUnreadMenuItem) watchedTheadsWithUnreadMenuItem.setAttribute("checked", viewType == nsMsgViewType.eShowWatchedThreadsWithUnread); } function InitMessageMenu() { var aMessage = GetFirstSelectedMessage(); var isNews = false; if(aMessage) { isNews = IsNewsMessage(aMessage); } //We show reply to Newsgroups only for news messages. var replyNewsgroupMenuItem = document.getElementById("replyNewsgroupMainMenu"); if(replyNewsgroupMenuItem) { replyNewsgroupMenuItem.setAttribute("hidden", isNews ? "" : "true"); } //For mail messages we say reply. For news we say ReplyToSender. var replyMenuItem = document.getElementById("replyMainMenu"); if(replyMenuItem) { replyMenuItem.setAttribute("hidden", !isNews ? "" : "true"); } var replySenderMenuItem = document.getElementById("replySenderMainMenu"); if(replySenderMenuItem) { replySenderMenuItem.setAttribute("hidden", isNews ? "" : "true"); } // we only kill and watch threads for news var killThreadMenuItem = document.getElementById("killThread"); if (killThreadMenuItem) { killThreadMenuItem.setAttribute("hidden", isNews ? "" : "true"); } var watchThreadMenuItem = document.getElementById("watchThread"); if (watchThreadMenuItem) { watchThreadMenuItem.setAttribute("hidden", isNews ? "" : "true"); } //disable the move and copy menus only if there are no messages selected. var moveMenu = document.getElementById("moveMenu"); if(moveMenu) moveMenu.setAttribute("disabled", !aMessage); var copyMenu = document.getElementById("copyMenu"); if(copyMenu) copyMenu.setAttribute("disabled", !aMessage); document.commandDispatcher.updateCommands('create-menu-message'); } function IsNewsMessage(messageUri) { if (!messageUri) return false; return (messageUri.substring(0,14) == "news_message:/") } function InitMessageMark() { InitMarkReadItem("markReadMenuItem"); InitMarkReadItem("markReadToolbarItem"); InitMarkFlaggedItem("markFlaggedMenuItem"); InitMarkFlaggedItem("markFlaggedToolbarItem"); } function InitMarkReadItem(id) { var areMessagesRead = SelectedMessagesAreRead(); var item = document.getElementById(id); if(item) item.setAttribute("checked", areMessagesRead); } function InitMarkFlaggedItem(id) { var areMessagesFlagged = SelectedMessagesAreFlagged(); var item = document.getElementById(id); if(item) item.setAttribute("checked", areMessagesFlagged); } function SelectedMessagesAreRead() { var isRead; try { isRead = gDBView.hdrForFirstSelectedMessage.isRead; } catch (ex) { isRead = false; } return isRead; } function SelectedMessagesAreFlagged() { var isFlagged; try { isFlagged = gDBView.hdrForFirstSelectedMessage.isFlagged; } catch (ex) { isFlagged = false; } return isFlagged; } function GetFirstSelectedMsgFolder() { var result = null; var selectedFolders = GetSelectedMsgFolders(); if (selectedFolders.length > 0) { result = selectedFolders[0]; } return result; } function GetInboxFolder(server) { try { var rootFolder = server.RootFolder; var rootMsgFolder = rootFolder.QueryInterface(Components.interfaces.nsIMsgFolder); //now find Inbox var outNumFolders = new Object(); var inboxFolder = rootMsgFolder.getFoldersWithFlag(0x1000, 1, outNumFolders); return inboxFolder.QueryInterface(Components.interfaces.nsIMsgFolder); } catch (ex) { dump(ex + "\n"); } return null; } function GetMessagesForInboxOnServer(server) { var inboxFolder = GetInboxFolder(server); if (!inboxFolder) return; var folders = new Array(1); folders[0] = inboxFolder; var compositeDataSource = GetCompositeDataSource("GetNewMessages"); GetNewMessages(folders, compositeDataSource); } function MsgGetMessage() { var folders = GetSelectedMsgFolders(); var compositeDataSource = GetCompositeDataSource("GetNewMessages"); GetNewMessages(folders, compositeDataSource); } function MsgGetMessagesForAllServers(defaultServer) { // now log into any server try { var allServers = accountManager.allServers; for (var i=0;i