1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 "nsIAbListener.idl"
40
41 interface nsIDOMWindow;
42 interface nsIAbDirectory;
43 interface nsIAbCard;
44 interface nsIAbDirectoryProperties;
45 interface nsIRDFDataSource;
46 interface nsILocalFile;
47 interface nsISimpleEnumerator;
48
49 /**
50 * nsIAbManager is an interface to the main address book mananger
51 * via the contract id "@mozilla.org/abmanager;1"
52 *
53 * It contains the main functions to create and delete address books as well
54 * as some helper functions.
55 */
56 [scriptable, uuid(a5be4ab5-5bf4-4559-ae79-d0cee9e45380)]
57 interface nsIAbManager : nsISupports
58 {
59 /**
60 * Returns an enumerator containing all the top-level directories
61 * (non-recursive)
62 */
63 readonly attribute nsISimpleEnumerator directories;
64
65 /**
66 * Returns the directory that represents the supplied URI.
67 *
68 * @param aURI The URI of the address book to find.
69 * @return The found address book.
70 */
71 nsIAbDirectory getDirectory(in ACString aURI);
72
73 /**
74 * Creates a new address book.
75 *
76 * @param aDirName The description of the address book.
77 * @param aURI The URI for the address book. This is specific to each
78 * type of address book.
79 * @param aType The type of the address book (see nsDirPrefs.h)
80 */
81 ACString newAddressBook(in AString aDirName, in ACString aURI,
82 in unsigned long aType);
83
84 /**
85 * Deletes an address book.
86 *
87 * @param aURI The URI for the address book. This is specific to each
88 * type of address book.
89 */
90 void deleteAddressBook(in ACString aURI);
91
92 /**
93 * Exports an address book, it will provide a dialog to the user for the
94 * location to save the file to and will then save the address book to media.
95 *
96 * @param aParentWin Parent Window for the file save dialog to use.
97 * @param aDirectory The directory to export.
98 */
99 void exportAddressBook(in nsIDOMWindow aParentWin, in nsIAbDirectory aDirectory);
100
101 /**
102 * Adds a nsIAbListener to receive notifications of address book updates
103 * according to the specified notifyFlags.
104 *
105 * @param aListener The listener that is to receive updates.
106 * @param aNotifyFlags A bitwise-or of abListenerNotifyFlagValue items
107 * specifying which notifications to receive. See
108 * nsIAbListener for possible values.
109 */
110 void addAddressBookListener(in nsIAbListener aListener,
111 in abListenerNotifyFlagValue aNotifyFlags);
112
113 /**
114 * Removes a nsIAbListener from receive notifications of address book
115 * updates.
116 *
117 * @param aListener The listener that is to no longer receive updates.
118 */
119 void removeAddressBookListener(in nsIAbListener aListener);
120
121 /**
122 * Call to notify the registered listeners when a property on an item has
123 * changed.
124 *
125 * @param aItem The items that has changed (e.g. an nsIAbDirectory)
126 * @param aProperty The property that has changed (e.g. DirName)
127 * @param aOldValue The old value of the property.
128 * @param aNewValue The new value of the property.
129 */
130 void notifyItemPropertyChanged(in nsISupports aItem,
131 in string aProperty,
132 in wstring aOldValue,
133 in wstring aNewValue);
134
135 /**
136 * Call to notify the registered listeners when a directory item is added.
137 *
138 * @param aParentDirectory The parent directory of the item that has been
139 * added.
140 * @param aItem The item that has been added.
141 */
142 void notifyDirectoryItemAdded(in nsIAbDirectory aParentDirectory,
143 in nsISupports aItem);
144
145 /**
146 * Call to notify the registered listeners when a directory item is removed.
147 *
148 * @param aParentDirectory The parent directory of the item that has been
149 * removed.
150 * @param aItem The item that has been removed.
151 */
152 void notifyDirectoryItemDeleted(in nsIAbDirectory aParentDirectory,
153 in nsISupports aItem);
154
155 /**
156 * Call to notify the registered listeners when a directory is removed.
157 *
158 * @param aParentDirectory The parent directory of the directory that has
159 * been removed.
160 * @param aDirectory The directory that has been removed.
161 */
162 void notifyDirectoryDeleted(in nsIAbDirectory aParentDirectory,
163 in nsISupports aDirectory);
164
165 /**
166 * Returns the user profile directory. NOTE: this should not be used
167 * as it may go away soon.
168 */
169 readonly attribute nsILocalFile userProfileDirectory;
170
171 /**
172 * Finds out if the mailing list name exists in any *mork/MDB* based
173 * address book
174 *
175 * @param aName The name of the list to try and find.
176 *
177 * @return True if the name exists.
178 */
179 boolean mailListNameExists(in wstring name);
180
181 /**
182 * Translates an escaped vcard string into a nsIAbCard.
183 *
184 * @param escapedVCardStr The string containing the vcard.
185 *
186 * @return A card containing the translated vcard data.
187 */
188 nsIAbCard escapedVCardToAbCard(in string escapedVCardStr);
189 };