1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38 #include "nsISupports.idl"
39 #include "nsrootidl.idl"
40
41 interface nsISimpleEnumerator;
42
43 %{C++
44
45 #define NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID \
46 "@mozilla.org/messenger/headerparser;1"
47 %}
48
49 /*
50 * nsIMsgRFCParser Interface declaration
51 */
52 [scriptable, uuid(10A88A11-729E-11d2-804A-006008128C4E)]
53 interface nsIMsgHeaderParser : nsISupports {
54
55 void parseHeadersWithArray(in wstring aLine,
56 [array, size_is(count)] out wstring aEmailAddresses,
57 [array, size_is(count)] out wstring aNames,
58 [array, size_is(count)] out wstring aFullNames,
59 [retval] out unsigned long count);
60
61
62 /* Given a string which contains a list of Header addresses, parses it into
63 their component names and mailboxes.
64
65 The returned value is the number of addresses, or a negative error code;
66 the names and addresses are returned into the provided pointers as
67 consecutive null-terminated strings. It is up to the caller to free them.
68 Note that some of the strings may be zero-length.
69
70 The caller may pass nsnull for charset and it will be interpreted as "us-ascii".
71
72 Either of the provided pointers may be NULL if the caller is not interested
73 in those components.
74 */
75 [noscript] void parseHeaderAddresses (in string charset, in string line, out string names,
76 out string addresses, out PRUint32 numAddresses);
77
78 /* Given a string which contains a list of Header addresses, returns a
79 comma-separated list of just the `mailbox' portions.
80
81 The caller may pass nsnull for charset and it will be interpreted as "us-ascii".
82
83 Caller must call PL_strfree on returnValue (which is allocated by the function)
84 */
85 string extractHeaderAddressMailboxes (in string charset, in string line);
86
87
88 /* Given a string which contains a list of Header addresses, returns a
89 comma-separated list of just the `user name' portions. If any of
90 the addresses doesn't have a name, then the mailbox is used instead.
91
92 The caller may pass nsnull for charset and it will be interpreted as "us-ascii".
93
94 Caller must PL_strfree usernames.
95 */
96 [noscript] void extractHeaderAddressNames (in string charset, in string line, out string userNames);
97
98 /* Like MSG_ExtractHeaderAddressNames(), but only returns the first name
99 in the list, if there is more than one.
100
101 The caller may pass nsnull for charset and it will be interpreted as "us-ascii".
102
103 Caller must call PL_strfree on name
104 */
105 [noscript] void extractHeaderAddressName (in string charset, in string line, out string name);
106
107 /* Given a string which contains a list of Header addresses, returns a new
108 string with the same data, but inserts missing commas, parses and reformats
109 it, and wraps long lines with newline-tab.
110
111 The caller may pass nsnull for charset and it will be interpreted as "us-ascii".
112
113 Caller must call PL_strfree on reformattedAddress
114 */
115 [noscript] void reformatHeaderAddresses (in string charset, in string line,
116 out string reformattedAddress);
117
118 /* Returns a copy of ADDRS which may have had some addresses removed.
119 Addresses are removed if they are already in either ADDRS or OTHER_ADDRS.
120 (If OTHER_ADDRS contain addresses which are not in ADDRS, they are not
121 added. That argument is for passing in addresses that were already
122 mentioned in other header fields.)
123
124 Addresses are considered to be the same if they contain the same mailbox
125 part (case-insensitive.) Real names and other comments are not compared.
126
127 removeAliasesToMe allows the address parser to use the preference which
128 contains regular expressions which also mean 'me' for the purpose of
129 stripping the user's email address(es) out of addrs
130
131 The caller may pass nsnull for charset and it will be interpreted as "us-ascii".
132
133 Caller must call PL_strfree on newAddress which is the return value.
134 */
135 [noscript] void removeDuplicateAddresses (in string charset, in string addrs, in string other_addrs,
136 in PRBool removeAliasesToMe, out string newAddress);
137
138
139 /* Given an e-mail address and a person's name, cons them together into a
140 single string of the form "name <address>", doing all the necessary quoting.
141 A new string is returned, which you must free when you're done with it.
142
143 The caller may pass nsnull for charset and it will be interpreted as "us-ascii".
144
145 Caller must call PL_strfree on fullAddress (this is the out parameter)
146 */
147 [noscript] string makeFullAddress (in string charset, in string name, in string addr);
148 wstring makeFullAddressWString (in wstring name, in wstring addr);
149
150 /* This function removes the quoting if you want to show the
151 names to users. e.g. summary file, address book. If preserveIntegrity is set to true,
152 quote will not be removed in case the name part of the email contains a comma.
153 */
154 [noscript] string unquotePhraseOrAddr (in string line, in boolean preserveIntegrity);
155 wstring unquotePhraseOrAddrWString (in wstring line, in boolean preserveIntegrity);
156
157 /* Given a string, will make it safe to use by adding missing quote and escaping needed quote */
158 wstring reformatUnquotedAddresses(in wstring line);
159 };