summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/base/public/nsIMsgTagService.idl
blob: 0317b64960ba0d0ccded2296688f78b1853bf015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.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.
 *
 * Tags are sorted internally by 'importance' by their ordinal strings (which by
 * default are equal to a tag's key and thus only stored if different).
 * The alphanumerically 'smallest' string is called the 'most important' one and
 * comes first in any sorted array. The remainder follows in ascending order.
 */

[scriptable, uuid(84d593a3-5d8a-45e6-96e2-9189acd422e1)]
interface nsIMsgTag : nsISupports {
  readonly attribute ACString key;     // distinct tag identifier
  readonly attribute AString  tag;     // human readable tag name
  readonly attribute ACString color;   // tag color
  readonly attribute ACString ordinal; // custom sort string (usually empty)
};

[scriptable, uuid(97360ce3-0fba-4f1c-8214-af7bdc6f8587)]
interface nsIMsgTagService : nsISupports {
  // create new tag by deriving the key from the tag
  void addTag(in AString tag, in ACString color, in ACString ordinal);
  // create/update tag with known key
  void addTagForKey(in ACString key, in AString tag, in ACString color, in ACString ordinal);
  // get the key representation of a given tag
  ACString getKeyForTag(in AString tag);
  // get the first key by ordinal order
  ACString getTopKey(in ACString keyList);
  // support functions for single tag aspects
  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 getColorForKey(in ACString key);
  AString getSelectorForKey(in ACString key);  // return wide string to avoid conversion
  void setColorForKey(in ACString key, in ACString color);
  ACString getOrdinalForKey(in ACString key);
  void setOrdinalForKey(in ACString key, in ACString ordinal);
  // delete a tag from the list of known tags (but not from any messages)
  void deleteKey(in ACString key);
  // get all known tags
  Array<nsIMsgTag> getAllTags();
  /*
   * Determines if the token in aKey corresponds to a current valid tag
   *
   * @param aKey        The string to test
   * @return            True if aKey is a current token
   */
  boolean isValidKey(in ACString aKey);
};