4 * Copyright (c) 2004 Novell, Inc. All Rights Reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 #ifndef PURPLE_NOVELL_NMCONTACT_H
22 #define PURPLE_NOVELL_NMCONTACT_H
26 typedef struct _NMContact NMContact
;
27 typedef struct _NMContactProperty NMContactProperty
;
28 typedef struct _NMFolder NMFolder
;
36 * Should be released by calling nm_release_contact
38 * @return The new NMContact
41 NMContact
*nm_create_contact(void);
44 * Creates a contact from a field array representing the
47 * Should be released by calling nm_release_contact
49 * @param fields Should be the NM_A_FA_CONTACT for
52 * @return The new contact
55 NMContact
*nm_create_contact_from_fields(NMField
* fields
);
58 * Add a reference to an existing contact
60 * The reference should be released by calling
63 * @param contact The contact
66 void nm_contact_add_ref(NMContact
* contact
);
69 * Update the contact list properties of the contact (sequence, parent id, etc.)
71 * @param contact The contact to update
72 * @param fields The fields to update from (should be a NM_A_FA_CONTACT array)
75 void nm_contact_update_list_properties(NMContact
* contact
, NMField
* fields
);
78 * Release a contact reference
80 * @param contact The contact to release.
83 void nm_release_contact(NMContact
* contact
);
86 * Get the display name of a contact
88 * @param contact The contact
90 * @return The display name of a contact
93 const char *nm_contact_get_display_name(NMContact
* contact
);
96 * Get the DN of a contact
98 * @param contact The contact
100 * @return The DN of the contact
102 const char *nm_contact_get_dn(NMContact
* contact
);
105 * Set the display name for a contact. This is called
106 * by nm_send_rename_contact. It should not be called
107 * directly (it does not change the display name on the
108 * server side list -- nm_send_rename_conact does).
110 * @param contact The contact
111 * @param display_name The new display name
114 void nm_contact_set_display_name(NMContact
* contact
, const char * display_name
);
117 * Set the DN for the contact
119 * @param contact The contact
120 * @param dn The new DN for the contact
123 void nm_contact_set_dn(NMContact
* contact
, const char * dn
);
126 * Return a field array (NM_A_FA_CONTACT) representing the contact
128 * @param contact The contact
130 * @return A field array representing the contact
132 NMField
*nm_contact_to_fields(NMContact
* contact
);
135 * Set the user record for the contact
137 * @param contact The contact
138 * @param user_record The user record
141 void nm_contact_set_user_record(NMContact
* contact
, NMUserRecord
* user_record
);
144 * Get the user record for the contact
146 * @param contact The contact
148 * @return The user record associated with the contact
151 NMUserRecord
*nm_contact_get_user_record(NMContact
* contact
);
154 * Get the user defined data for the contact
156 * @param contact The contact
158 * @return The user defined data for the contact
161 gpointer
nm_contact_get_data(NMContact
* contact
);
164 * Get the Object ID for the contact
166 * @param contact The contact
168 * @return The ID for the contact
170 int nm_contact_get_id(NMContact
* contact
);
173 * Get the ID for the folder that the contact is in
175 * @param contact The contact
177 * @return The ID of the folder that contains the contact
180 int nm_contact_get_parent_id(NMContact
* contact
);
183 * Get The userid of the contact.
185 * @param contact The contact
187 * @return The userid of the contact
190 const char *nm_contact_get_userid(NMContact
* contact
);
193 * Get the display id of the contact
195 * @param contact The contact
197 * @return The display id of the contact
199 const char *nm_contact_get_display_id(NMContact
* contact
);
202 * Set the user defined data for the contact
204 * @param contact The contact
205 * @param data The user defined data
208 void nm_contact_set_data(NMContact
* contact
, gpointer data
);
211 * Create a folder with the given name
213 * @param name The name of the folder
215 * @return The new folder
218 NMFolder
*nm_create_folder(const char *name
);
221 * Create a folder from a NM_A_FA_FOLDER field array
223 * @param fields The NM_A_FA_FOLDER field array
225 * @return The new folder
228 NMFolder
*nm_create_folder_from_fields(NMField
* fields
);
231 * Add a reference to an existing folder
233 * The reference should be released by calling
236 * @param folder The folder
239 void nm_folder_add_ref(NMFolder
* folder
);
242 * Release a reference to a folder.
244 * @param folder The folder to release
247 void nm_release_folder(NMFolder
* folder
);
250 * Return the number of subfolders for the given
253 * @param folder The folder
255 * @return The number of subfolders contained by folder
257 int nm_folder_get_subfolder_count(NMFolder
* folder
);
262 * @param folder The root folder
263 * @param index The index of the folder to get
265 * @return The subfolder at the given index
268 NMFolder
*nm_folder_get_subfolder(NMFolder
* folder
, int index
);
271 * Get the number of contacts in the given folder
273 * @param folder The folder
275 * @return The number of contacts contained by folder
278 int nm_folder_get_contact_count(NMFolder
* folder
);
281 * Get a contact in the given folder
283 * @param folder The folder
284 * @param index The index of the contact to get
286 * @return The contact at the given index
289 NMContact
*nm_folder_get_contact(NMFolder
* folder
, int index
);
292 * Get the name of the folder
294 * @param folder The folder
296 * @return The name of the folder.
299 const char *nm_folder_get_name(NMFolder
* folder
);
302 * Set the name of a folder. Do not call this directly.
303 * It does not change the name of the folder in the
304 * server side contact list. You must call
305 * nm_send_set_folder_name().
307 * @param folder The folder
308 * @param name The new name for the folder
311 void nm_folder_set_name(NMFolder
* folder
, const char *name
);
314 * Get Object ID for folder
316 * @param folder The folder
318 * @return The ID of the folder
321 int nm_folder_get_id(NMFolder
* folder
);
324 * Add contacts and folders from fields into root
326 * @param user The logged in user
327 * @param root The root folder
328 * @param fields The contact list field array
331 void nm_folder_add_contacts_and_folders(NMUser
* user
, NMFolder
* root
,
334 * Add a contact to the contact list.
336 * @param root_folder The root folder of the contact list
337 * @param contact The contact to add
340 void nm_folder_add_contact_to_list(NMFolder
* root_folder
,
341 NMContact
* contact
);
344 * Update the contact list properties of the folder (sequence, parent id, etc.)
346 * @param folder The folder to update
347 * @param fields The fields to update from (should be a NM_A_FA_FOLDER array)
350 void nm_folder_update_list_properties(NMFolder
* folder
, NMField
* fields
);
353 * Add folder to the contact list
355 * @param root_folder The root folder of the contact list
356 * @param folder The folder to add to the contact list
359 void nm_folder_add_folder_to_list(NMFolder
* root_folder
, NMFolder
* folder
);
362 * Find the object with the given id
364 * @param root_folder The root folder of the contact list
365 * @param object_id The object id of the object to find
367 * @return The object with object id (either a contact or a folder)
369 gpointer
nm_folder_find_item_by_object_id(NMFolder
* root_folder
,
373 * Remove a contact from the folder
375 * @param folder The folder
376 * @param contact The contact to remove
379 void nm_folder_remove_contact(NMFolder
* folder
, NMContact
* contact
);
382 * Find a contact in a folder by DN
384 * @param folder The folder to search
385 * @param dn The DN of the contact to find
387 * @return The contact if found, NULL otherwise
390 NMContact
*nm_folder_find_contact(NMFolder
* folder
, const char *dn
);
393 * Find a contact in a folder by userid
395 * @param folder The folder to search
396 * @param userid The userid of the contact to find
398 * @return The contact if found, NULL otherwise
401 NMContact
*nm_folder_find_contact_by_userid(NMFolder
* folder
,
405 * Find a contact in a folder by display id
407 * @param folder The folder to search
408 * @param display_id The userid of the contact to find
410 * @return The contact if found, NULL otherwise
414 nm_folder_find_contact_by_display_id(NMFolder
* folder
, const char *display_id
);
417 * Return a field array (NM_A_FA_FOLDER) representing the folder
419 * @param folder The folder
421 * @return A field array representing the folder
423 NMField
*nm_folder_to_fields(NMFolder
* folder
);
425 #endif /* PURPLE_NOVELL_NMCONTACT_H */