From 44aee4259f97e379d0af0d52bf00531f7d5a3507 Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Fri, 9 Jun 2006 14:26:31 +0000 Subject: [PATCH] add support for unlimited number of tags per profile and per message, replace labels with tags, sr=mscott, sspitzer 114656 --- mail/base/content/mail3PaneWindowCommands.js | 30 -- mail/base/content/mailWindowOverlay.js | 132 ++++--- mail/base/content/mailWindowOverlay.xul | 185 ++-------- mail/base/content/messageWindow.js | 18 - mail/base/content/messenger.css | 4 +- mail/base/jar.mn | 2 + mail/extensions/newsblog/content/FeedItem.js | 1 + .../en-US/chrome/messenger/FilterEditor.dtd | 1 + .../en-US/chrome/messenger/messenger.dtd | 2 + .../chrome/messenger/messenger.properties | 7 + .../en-US/chrome/messenger/newTagDialog.dtd | 38 ++ .../messenger/search-attributes.properties | 4 +- mail/locales/jar.mn | 1 + mailnews/base/public/Makefile.in | 1 + mailnews/base/public/nsIMsgFolder.idl | 7 +- mailnews/base/public/nsIMsgTagService.idl | 72 ++++ mailnews/base/public/nsMsgBaseCID.h | 10 + mailnews/base/public/nsMsgLocalFolderHdrs.h | 3 + .../base/resources/content/mailWidgets.xml | 70 ++-- .../resources/content/mailWindowOverlay.js | 55 --- mailnews/base/resources/content/messenger.css | 4 +- .../base/resources/content/newTagDialog.js | 90 +++++ .../base/resources/content/newTagDialog.xul | 58 +++ .../locale/en-US/messenger.properties | 3 + .../resources/locale/en-US/newTagDialog.dtd | 0 .../base/search/public/nsIMsgSearchTerm.idl | 3 +- .../base/search/public/nsMsgFilterCore.idl | 3 +- .../base/search/public/nsMsgSearchCore.idl | 14 +- .../search/resources/content/FilterEditor.js | 6 +- .../resources/content/searchWidgets.xml | 42 +-- .../locale/en-US/search-attributes.properties | 4 +- mailnews/base/search/src/nsMsgFilter.cpp | 2 + mailnews/base/search/src/nsMsgFilterList.cpp | 11 +- .../base/search/src/nsMsgFilterService.cpp | 7 + mailnews/base/search/src/nsMsgImapSearch.cpp | 22 +- mailnews/base/search/src/nsMsgLocalSearch.cpp | 9 +- .../base/search/src/nsMsgSearchAdapter.cpp | 2 +- mailnews/base/search/src/nsMsgSearchTerm.cpp | 222 +++++++----- mailnews/base/search/src/nsMsgSearchValue.cpp | 2 + mailnews/base/src/Makefile.in | 1 + mailnews/base/src/nsMsgDBView.cpp | 38 +- mailnews/base/src/nsMsgDBView.h | 3 + mailnews/base/src/nsMsgFolderCompactor.cpp | 167 +++++++-- mailnews/base/src/nsMsgFolderCompactor.h | 3 +- mailnews/base/src/nsMsgTagService.cpp | 329 ++++++++++++++++++ mailnews/base/src/nsMsgTagService.h | 76 ++++ mailnews/base/util/nsMsgDBFolder.cpp | 76 ++++ mailnews/base/util/nsMsgLineBuffer.h | 8 +- mailnews/base/util/nsMsgUtils.cpp | 33 ++ mailnews/base/util/nsMsgUtils.h | 5 + mailnews/build/nsMailModule.cpp | 7 + mailnews/compose/src/nsMsgRecipientArray.cpp | 17 +- mailnews/compose/src/nsMsgSendLater.cpp | 2 + mailnews/db/msgdb/public/nsIMsgDatabase.idl | 4 +- .../public/nsIMsgOfflineImapOperation.idl | 26 +- mailnews/db/msgdb/public/nsImapMailDatabase.h | 1 + mailnews/db/msgdb/public/nsMailDatabase.h | 1 + mailnews/db/msgdb/public/nsMsgDatabase.h | 2 +- mailnews/db/msgdb/src/nsImapMailDatabase.cpp | 5 + mailnews/db/msgdb/src/nsMailDatabase.cpp | 13 + mailnews/db/msgdb/src/nsMsgDatabase.cpp | 5 + .../msgdb/src/nsMsgOfflineImapOperation.cpp | 82 +++++ .../db/msgdb/src/nsMsgOfflineImapOperation.h | 28 +- mailnews/imap/src/nsImapMailFolder.cpp | 67 +++- mailnews/imap/src/nsImapMailFolder.h | 3 + mailnews/imap/src/nsImapOfflineSync.cpp | 88 +++++ mailnews/imap/src/nsImapOfflineSync.h | 1 + mailnews/imap/src/nsImapService.cpp | 5 - mailnews/local/src/nsLocalMailFolder.cpp | 150 +++++++- mailnews/local/src/nsLocalMailFolder.h | 7 +- mailnews/local/src/nsParseMailbox.cpp | 30 +- mailnews/local/src/nsParseMailbox.h | 1 + mailnews/local/src/nsPop3Sink.cpp | 2 + mailnews/mime/public/nsMailHeaders.h | 2 +- 74 files changed, 1883 insertions(+), 552 deletions(-) create mode 100755 mail/locales/en-US/chrome/messenger/newTagDialog.dtd create mode 100755 mailnews/base/public/nsIMsgTagService.idl create mode 100755 mailnews/base/resources/content/newTagDialog.js create mode 100755 mailnews/base/resources/content/newTagDialog.xul create mode 100755 mailnews/base/resources/locale/en-US/newTagDialog.dtd create mode 100755 mailnews/base/src/nsMsgTagService.cpp create mode 100755 mailnews/base/src/nsMsgTagService.h diff --git a/mail/base/content/mail3PaneWindowCommands.js b/mail/base/content/mail3PaneWindowCommands.js index ddbe2590300..36f39853647 100644 --- a/mail/base/content/mail3PaneWindowCommands.js +++ b/mail/base/content/mail3PaneWindowCommands.js @@ -214,12 +214,6 @@ var DefaultController = case "cmd_applyFilters": case "cmd_runJunkControls": case "cmd_deleteJunk": - case "cmd_label0": - case "cmd_label1": - case "cmd_label2": - case "cmd_label3": - case "cmd_label4": - case "cmd_label5": case "button_file": case "cmd_file": case "cmd_emptyTrash": @@ -346,12 +340,6 @@ var DefaultController = case "button_mark": case "cmd_markAsRead": case "cmd_markThreadAsRead": - case "cmd_label0": - case "cmd_label1": - case "cmd_label2": - case "cmd_label3": - case "cmd_label4": - case "cmd_label5": return GetNumSelectedMessages() > 0; case "button_previous": case "button_next": @@ -647,24 +635,6 @@ var DefaultController = case "cmd_deleteJunk": deleteJunkInFolder(); return; - case "cmd_label0": - gDBView.doCommand(nsMsgViewCommandType.label0); - return; - case "cmd_label1": - gDBView.doCommand(nsMsgViewCommandType.label1); - return; - case "cmd_label2": - gDBView.doCommand(nsMsgViewCommandType.label2); - return; - case "cmd_label3": - gDBView.doCommand(nsMsgViewCommandType.label3); - return; - case "cmd_label4": - gDBView.doCommand(nsMsgViewCommandType.label4); - return; - case "cmd_label5": - gDBView.doCommand(nsMsgViewCommandType.label5); - return; case "cmd_emptyTrash": MsgEmptyTrash(); return; diff --git a/mail/base/content/mailWindowOverlay.js b/mail/base/content/mailWindowOverlay.js index a8f4dad4bb1..1808a574674 100644 --- a/mail/base/content/mailWindowOverlay.js +++ b/mail/base/content/mailWindowOverlay.js @@ -26,7 +26,7 @@ # Håkan Waara # Jan Varga # Seth Spitzer -# David Bienvenu +# David Bienvenu # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -554,58 +554,92 @@ function SetMenuItemLabel(menuItemId, customLabel) menuItem.setAttribute('label', customLabel); } -function InitMessageLabel(menuType) +function TagCurMessage(key) { - var color; + // ###need to do all selected messsages + var msgHdr = gDBView.hdrForFirstSelectedMessage; + var messages = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray); + messages.AppendElement(msgHdr); + msgHdr.folder.addKeywordToMessages(messages, key); +} - try +function UnTagCurMessage(key) +{ + // ###need to do all selected messsages + var msgHdr = gDBView.hdrForFirstSelectedMessage; + var messages = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray); + messages.AppendElement(msgHdr); + msgHdr.folder.removeKeywordFromMessages(messages, key); +} + + +function AddTag() +{ + var args = {result: "", okCallback: AddTagCallback}; + var dialog = window.openDialog( + "chrome://messenger/content/newTagDialog.xul", + "", + "chrome,titlebar,modal", + args); +} + +function AddTagCallback(name, color) +{ + var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"].getService(Components.interfaces.nsIMsgTagService); + tagService.addTag(name, color); + TagCurMessage(name); + return true; +} + +function InitMessageTags(menuType) +{ + var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"].getService(Components.interfaces.nsIMsgTagService); + var allTags = tagService.tagEnumerator; + var allKeys = tagService.keyEnumerator; + // remove any existing entries... + var menuItemId = menuType + "-tagpopup"; + var menupopupNode = document.getElementById(menuItemId); + for (var i = menupopupNode.childNodes.length - 1; i >= 0; --i) + menupopupNode.removeChild(menupopupNode.childNodes[i]); + + // now rebuild the list + var msgHdr = gDBView.hdrForFirstSelectedMessage; + var curKeys = msgHdr.getStringProperty("keywords"); + var newMenuItem; + + var curMsgHdrKeyArray = curKeys.split(" "); + + while (allTags.hasMore()) + { + var tag = allTags.getNext(); + var key = allKeys.getNext(); + // TODO we want to either remove or "check" the tags that already exist + newMenuItem = document.createElement('menuitem'); + newMenuItem.setAttribute('label', tag); + newMenuItem.setAttribute('value', key); + newMenuItem.setAttribute('type', 'checkbox'); + var keySet = false; + for ( var index = 0; index < curMsgHdrKeyArray.length; index++ ) { - var isChecked = true; - var checkedLabel = gDBView.hdrForFirstSelectedMessage.label; + if (key == curMsgHdrKeyArray[index]) + { + keySet = true; + break; + } } - catch(ex) - { - isChecked = false; - } - - for (var label = 0; label <= 5; label++) - { - try - { - var prefString = gPrefBranch.getComplexValue("mailnews.labels.description." + label, - Components.interfaces.nsIPrefLocalizedString); - var formattedPrefString = gMessengerBundle.getFormattedString("labelMenuItemFormat" + label, - [prefString], 1); - var menuItemId = menuType + "-labelMenuItem" + label; - var menuItem = document.getElementById(menuItemId); - - SetMenuItemLabel(menuItemId, formattedPrefString); - if (isChecked && label == checkedLabel) - menuItem.setAttribute("checked", "true"); - else - menuItem.setAttribute("checked", "false"); - - // commented out for now until UE decides on how to show the Labels menu items. - // This code will color either the text or background for the Labels menu items. - /***** - if (label != 0) - { - color = prefBranch.getCharPref("mailnews.labels.color." + label); - // this colors the text of the menuitem only. - //menuItem.setAttribute("style", ("color: " + color)); - - // this colors the background of the menuitem and - // when selected, text becomes white. - //menuItem.setAttribute("style", ("color: #FFFFFF")); - //menuItem.setAttribute("style", ("background-color: " + color)); - } - ****/ - } - catch(ex) - { - } - } - document.commandDispatcher.updateCommands('create-menu-label'); + // if we already have this tag, we should change the command to "UnTag" + var command = ((keySet) ? "Un" : "") + "TagCurMessage(" + "'" + key + "');"; + newMenuItem.setAttribute('oncommand', command); + newMenuItem.setAttribute('checked', keySet); + menupopupNode.appendChild(newMenuItem); + } + var menuseparator = document.createElement('menuseparator'); + menupopupNode.appendChild(menuseparator); + + newMenuItem = document.createElement('menuitem'); + newMenuItem.setAttribute('label', gMessengerBundle.getString("newTag")); + newMenuItem.setAttribute('oncommand', "AddTag()"); + menupopupNode.appendChild(newMenuItem); } function InitMessageMark() diff --git a/mail/base/content/mailWindowOverlay.xul b/mail/base/content/mailWindowOverlay.xul index 317d3eb86f5..1138f9f454b 100644 --- a/mail/base/content/mailWindowOverlay.xul +++ b/mail/base/content/mailWindowOverlay.xul @@ -606,45 +606,8 @@ - - - - - - - - - + + @@ -948,46 +911,9 @@ - - - - - - - - - - + + + @@ -1613,85 +1539,48 @@ - - - - - - - - - - - - - - + + + + + + - - - - - + + - - + - \n' + 'From: ' + this.author + '\n' + diff --git a/mail/locales/en-US/chrome/messenger/FilterEditor.dtd b/mail/locales/en-US/chrome/messenger/FilterEditor.dtd index a2c001acb95..9e7233cbc44 100644 --- a/mail/locales/en-US/chrome/messenger/FilterEditor.dtd +++ b/mail/locales/en-US/chrome/messenger/FilterEditor.dtd @@ -43,6 +43,7 @@ + diff --git a/mail/locales/en-US/chrome/messenger/messenger.dtd b/mail/locales/en-US/chrome/messenger/messenger.dtd index c4ac89db745..a8d5880210b 100644 --- a/mail/locales/en-US/chrome/messenger/messenger.dtd +++ b/mail/locales/en-US/chrome/messenger/messenger.dtd @@ -330,6 +330,8 @@ + + diff --git a/mail/locales/en-US/chrome/messenger/messenger.properties b/mail/locales/en-US/chrome/messenger/messenger.properties index 13f744c6858..7fd4784eccc 100644 --- a/mail/locales/en-US/chrome/messenger/messenger.properties +++ b/mail/locales/en-US/chrome/messenger/messenger.properties @@ -48,6 +48,7 @@ newSubfolderMenuItem=Subfolder... newFolder=New Folder... newSubfolder=New Subfolder... folderProperties=Folder Properties +newTag=New Tag... getNextNMessages=Get Next %S News Messages advanceNextPrompt=Advance to next unread message in %S? titleNewsPreHost=on @@ -234,6 +235,9 @@ junk=Junk # for the has attachment picker in search and mail views hasAttachments=Has Attachments +# for the Tag picker in search and mail views. +tag=Tags + # mailnews.js mailnews.send_default_charset=ISO-8859-1 mailnews.view_default_charset=ISO-8859-1 @@ -361,6 +365,9 @@ passwordTitle=Mail Server Password Required openWindowWarningTitle=Confirm openWindowWarningText=Opening %S messages may be slow. Continue? +# for warning the user that a tag they're trying to create already exists +tagExists=A tag with that name already exists. + # for the virtual folder list dialog title # %S is the name of the saved search folder editVirtualFolderPropertiesTitle=Edit Saved Search Properties for %S diff --git a/mail/locales/en-US/chrome/messenger/newTagDialog.dtd b/mail/locales/en-US/chrome/messenger/newTagDialog.dtd new file mode 100755 index 00000000000..e143571b443 --- /dev/null +++ b/mail/locales/en-US/chrome/messenger/newTagDialog.dtd @@ -0,0 +1,38 @@ + + + + + + diff --git a/mail/locales/en-US/chrome/messenger/search-attributes.properties b/mail/locales/en-US/chrome/messenger/search-attributes.properties index e777b533433..239f060d139 100644 --- a/mail/locales/en-US/chrome/messenger/search-attributes.properties +++ b/mail/locales/en-US/chrome/messenger/search-attributes.properties @@ -15,7 +15,7 @@ 12=Folder Info 13=Size 14=AnyText -15=Keywords +15=Tags # for AB and LDAP 16=Any Name 17=Display Name @@ -50,5 +50,5 @@ 46=Attachment Status 47=Junk Status 48=Label +49=Customize # don't use above 49 -49=Customize... diff --git a/mail/locales/jar.mn b/mail/locales/jar.mn index acda23405a1..da90476c106 100644 --- a/mail/locales/jar.mn +++ b/mail/locales/jar.mn @@ -33,6 +33,7 @@ locale/@AB_CD@/messenger/threadpane.dtd (%chrome/messenger/threadpane.dtd) locale/@AB_CD@/messenger/folderpane.dtd (%chrome/messenger/folderpane.dtd) locale/@AB_CD@/messenger/newFolderDialog.dtd (%chrome/messenger/newFolderDialog.dtd) + locale/@AB_CD@/messenger/newTagDialog.dtd (%chrome/messenger/newTagDialog.dtd) locale/@AB_CD@/messenger/renameFolderDialog.dtd (%chrome/messenger/renameFolderDialog.dtd) locale/@AB_CD@/messenger/folderProps.dtd (%chrome/messenger/folderProps.dtd) locale/@AB_CD@/messenger/subscribe.dtd (%chrome/messenger/subscribe.dtd) diff --git a/mailnews/base/public/Makefile.in b/mailnews/base/public/Makefile.in index bee070052ed..536ba8acf31 100644 --- a/mailnews/base/public/Makefile.in +++ b/mailnews/base/public/Makefile.in @@ -70,6 +70,7 @@ XPIDLSRCS = \ nsIMsgMailSession.idl \ nsIMsgMessageService.idl \ nsIMsgSignature.idl \ + nsIMsgTagService.idl \ nsIMsgThread.idl \ nsIUrlListener.idl \ nsIUrlListenerManager.idl \ diff --git a/mailnews/base/public/nsIMsgFolder.idl b/mailnews/base/public/nsIMsgFolder.idl index c4f5968f6ab..86807b3f3c6 100644 --- a/mailnews/base/public/nsIMsgFolder.idl +++ b/mailnews/base/public/nsIMsgFolder.idl @@ -70,7 +70,7 @@ typedef long nsMsgBiffState; // enumerated type for determining if a message has been replied to, forwarded, etc. typedef long nsMsgDispositionState; -[scriptable, uuid(28424d1c-db6f-4ac5-bc5d-418dd336120b)] +[scriptable, uuid(5711cb97-42ad-466d-9e8f-48b84a8b76a2)] interface nsIMsgFolder : nsICollection { const nsMsgBiffState nsMsgBiffState_NewMail = 0; // User has new mail waiting. @@ -497,4 +497,9 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne in unsigned long aNumKeys, in boolean aLocalOnly, in nsIUrlListener aUrlListener, out boolean aAsyncResults); + // used to set/clear tags - we could have a single method to setKeywords which + // would figure out the diffs, but these methods might be more convenient. + void addKeywordToMessages(in nsISupportsArray aMessages, in string aKeyword); + void removeKeywordFromMessages(in nsISupportsArray aMessages, in string aKeyword); + }; diff --git a/mailnews/base/public/nsIMsgTagService.idl b/mailnews/base/public/nsIMsgTagService.idl new file mode 100755 index 00000000000..9a47ae1dde9 --- /dev/null +++ b/mailnews/base/public/nsIMsgTagService.idl @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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.org code. + * + * The Initial Developer of the Original Code is + * The Mozilla Corporation. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Bienvenu + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" +#include "nsIStringEnumerator.idl" + +/* + * Keys are the internal representation of tags, and use a limited range of + * characters, basically the characters allowed in imap keywords, which are + * alphanumeric characters, but don't include spaces. Keys are stored on + * the imap server, in local mail messages, and in summary files. + * + * Tags are the user visible representation of keys, and are full unicode + * strings. Tags should allow any unicode character. + * + * This service will do the mapping between keys and tags. When a tag + * is added, we'll need to "compute" the corresponding key to use. This + * will probably entail replacing illegal ascii characters (' ', '/', etc) + * with '_' and then converting to imap mod utf7. We'll then need to make + * sure that no other keyword has the same value since that algorithm + * doesn't guarantee a unique mapping. + * + */ +[scriptable, uuid(ad04db53-cfcc-47eb-b409-b24b3a0b6130)] +interface nsIMsgTagService : nsISupports { + AString getTagForKey(in ACString key); // look up the tag for a key. + void setTagForKey(in ACString key, in AString tag); // this can be used to "rename" a tag + ACString getKeyForTag(in AString tag); // get the key representation of a given tag + void addTagForKey(in ACString key, in AString tag, in ACString color); + void addTag(in AString tag, in ACString color); + ACString getColorForKey(in ACString key); + void deleteTag(in AString tag); + // we need some way to enumerate all tags. Or return a list of all tags. + readonly attribute nsIStringEnumerator tagEnumerator; + readonly attribute nsIUTF8StringEnumerator keyEnumerator; +}; + diff --git a/mailnews/base/public/nsMsgBaseCID.h b/mailnews/base/public/nsMsgBaseCID.h index b964228a216..29c6e743ff6 100644 --- a/mailnews/base/public/nsMsgBaseCID.h +++ b/mailnews/base/public/nsMsgBaseCID.h @@ -515,6 +515,16 @@ 0xce6038ae, 0xe5e0, 0x4372, \ {0x9c, 0xff, 0x2a, 0x66, 0x33, 0x33, 0x3b, 0x2b }} +// +// nsMsgTagService +// +#define NS_MSGTAGSERVICE_CONTRACTID \ + "@mozilla.org/messenger/tagservice;1" + +#define NS_MSGTAGSERVICE_CID \ +{ /* ad04db53-cfcc-47eb-b409-b24b3a0b6130 */ \ + 0xad04db53, 0xcfcc, 0x47eb, \ + { 0xb4, 0x09, 0xb2, 0x4b, 0x3a, 0x0b, 0x61, 0x30}} // // nsMessengerOSIntegration // diff --git a/mailnews/base/public/nsMsgLocalFolderHdrs.h b/mailnews/base/public/nsMsgLocalFolderHdrs.h index 2bd794dae60..975baa4aae9 100644 --- a/mailnews/base/public/nsMsgLocalFolderHdrs.h +++ b/mailnews/base/public/nsMsgLocalFolderHdrs.h @@ -64,4 +64,7 @@ /* Provide a common means of detecting empty lines in a message. i.e. to detect the end of headers among other things...*/ #define EMPTY_MESSAGE_LINE(buf) (buf[0] == nsCRT::CR || buf[0] == nsCRT::LF || buf[0] == '\0') +/* blank filled header to store keyword/tags in the mailbox */ +#define X_MOZILLA_KEYWORDS HEADER_X_MOZILLA_KEYWORDS ": " MSG_LINEBREAK + #endif diff --git a/mailnews/base/resources/content/mailWidgets.xml b/mailnews/base/resources/content/mailWidgets.xml index 2545a6a433c..15f8c2cb0f5 100644 --- a/mailnews/base/resources/content/mailWidgets.xml +++ b/mailnews/base/resources/content/mailWidgets.xml @@ -1235,7 +1235,8 @@ @@ -1277,12 +1278,6 @@ - - - - - - @@ -1375,12 +1370,7 @@ // it's a text search, so show the textbox this.setAttribute("selectedIndex", "0"); } - else if (val == Components.interfaces.nsMsgSearchAttrib.Label) - { - var children = document.getAnonymousNodes(this); - var abs = children[5].getElementsByAttribute("value", "1"); - if (abs.item(0)) - children[5].selectedItem = abs[0]; + else if (val == Components.interfaces.nsMsgSearchAttrib.Keywords) { this.setAttribute("selectedIndex", "5"); } else if (val == Components.interfaces.nsMsgSearchAttrib.JunkStatus) { @@ -1433,11 +1423,14 @@ else children[0].value = val.str; } - else if (attrib == nsMsgSearchAttrib.Label) + else if (attrib == nsMsgSearchAttrib.Keywords) { - var labelVal = children[5].getElementsByAttribute("value", val.label); - if (labelVal.item(0)) - children[5].selectedItem = labelVal[0]; + var keywordVal = children[5].getElementsByAttribute("value", val.str); + if (keywordVal.item(0)) + { + children[5].value = val.str; + children[5].selectedItem = keywordVal[0]; + } } else if (attrib == nsMsgSearchAttrib.JunkStatus) { var junkStatus = @@ -1485,8 +1478,10 @@ else searchValue.str = children[0].value; } - else if (searchAttribute == nsMsgSearchAttrib.Label) - searchValue.label = children[5].selectedItem.value; + else if (searchAttribute == nsMsgSearchAttrib.Keywords) + { + searchValue.str = children[5].value; + } else if (searchAttribute == nsMsgSearchAttrib.JunkStatus) searchValue.junkStatus = children[6].value; else if (searchAttribute == nsMsgSearchAttrib.Size) @@ -1507,6 +1502,33 @@ ]]> + + + + + @@ -1565,18 +1587,14 @@ // initialize the address book picker this.initialize(document.getAnonymousNodes(this)[4], bundle); - // initialize the label picker.... - var labelStrings = GetLabelStrings(); - var children = document.getAnonymousNodes(this)[5].firstChild.childNodes; - // set the label string on each label element... - for (var index = 0; index < 6; index++) - children[index].setAttribute('label', labelStrings[index]); - // initialize the junk status picker this.initialize(document.getAnonymousNodes(this)[6], bundle); // initialize the has attachment status picker this.initialize(document.getAnonymousNodes(this)[7], bundle); + + // initialize the tag list + fillInTags(); ]]> diff --git a/mailnews/base/resources/content/mailWindowOverlay.js b/mailnews/base/resources/content/mailWindowOverlay.js index f1867635cfe..1f4472fefb4 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.js +++ b/mailnews/base/resources/content/mailWindowOverlay.js @@ -526,61 +526,6 @@ function SetMenuItemLabel(menuItemId, customLabel) menuItem.setAttribute('label', customLabel); } -function InitMessageLabel(menuType) -{ - /* this code gets the label strings and changes the menu labels */ - var color; - - try - { - var isChecked = true; - var checkedLabel = gDBView.hdrForFirstSelectedMessage.label; - } - catch(ex) - { - isChecked = false; - } - - for (var label = 0; label <= 5; label++) - { - try - { - var prefString = gPrefBranch.getComplexValue("mailnews.labels.description." + label, - Components.interfaces.nsIPrefLocalizedString); - var formattedPrefString = gMessengerBundle.getFormattedString("labelMenuItemFormat" + label, - [prefString], 1); - var menuItemId = menuType + "-labelMenuItem" + label; - var menuItem = document.getElementById(menuItemId); - - SetMenuItemLabel(menuItemId, formattedPrefString); - if (isChecked && label == checkedLabel) - menuItem.setAttribute("checked", "true"); - else - menuItem.setAttribute("checked", "false"); - - // commented out for now until UE decides on how to show the Labels menu items. - // This code will color either the text or background for the Labels menu items. - /***** - if (label != 0) - { - color = gPrefBranch.getCharPref("mailnews.labels.color." + label); - // this colors the text of the menuitem only. - //menuItem.setAttribute("style", ("color: " + color)); - - // this colors the background of the menuitem and - // when selected, text becomes white. - //menuItem.setAttribute("style", ("color: #FFFFFF")); - //menuItem.setAttribute("style", ("background-color: " + color)); - } - ****/ - } - catch(ex) - { - } - } - document.commandDispatcher.updateCommands('create-menu-label'); -} - function InitMessageMark() { var areMessagesRead = SelectedMessagesAreRead(); diff --git a/mailnews/base/resources/content/messenger.css b/mailnews/base/resources/content/messenger.css index 2cc22409973..adf11b8423b 100644 --- a/mailnews/base/resources/content/messenger.css +++ b/mailnews/base/resources/content/messenger.css @@ -108,8 +108,8 @@ searchterm { -moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-folder"); } -.ruleactiontarget[type="labelmessageas"] { - -moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-label"); +.ruleactiontarget[type="addtagtomessage"] { + -moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-tag"); } .ruleactiontarget[type="setpriorityto"] { diff --git a/mailnews/base/resources/content/newTagDialog.js b/mailnews/base/resources/content/newTagDialog.js new file mode 100755 index 00000000000..5e631d49600 --- /dev/null +++ b/mailnews/base/resources/content/newTagDialog.js @@ -0,0 +1,90 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the new tag dialog + * + * The Initial Developer of the Original Code is + * David Bienvenu. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Bienvenu + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var dialog; + +function onLoad() +{ + var arguments = window.arguments[0]; + + dialog = {}; + + dialog.OKButton = document.documentElement.getButton("accept"); + + dialog.nameField = document.getElementById("name"); + dialog.nameField.focus(); + + // call this when OK is pressed + dialog.okCallback = arguments.okCallback; + + moveToAlertPosition(); + doEnabling(); +} + +function onOK() +{ + var name = dialog.nameField.value; + + var tagService = Components.classes["@mozilla.org/messenger/tagservice;1"].getService(Components.interfaces.nsIMsgTagService); + // do name validity check? Has to be non-empty, and not existing already + try + { + var key = tagService.getKeyForTag(name); + // above will throw an error if tag doesn't exist. So if it doesn't throw an error, + // the tag exists, so alert the user and return false. + } + catch (ex) {return dialog.okCallback(name, "")} + + var messengerBundle = document.getElementById("bundle_messenger"); + var alertText = messengerBundle.getString("tagExists"); + window.alert(alertText); + return false; +} + +function doEnabling() +{ + if (dialog.nameField.value) { + if (dialog.OKButton.disabled) + dialog.OKButton.disabled = false; + } else { + if (!dialog.OKButton.disabled) + dialog.OKButton.disabled = true; + } +} + diff --git a/mailnews/base/resources/content/newTagDialog.xul b/mailnews/base/resources/content/newTagDialog.xul new file mode 100755 index 00000000000..7cd7f5e95dc --- /dev/null +++ b/mailnews/base/resources/content/newTagDialog.xul @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + +