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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
|
/*
* nmcontact.h
*
* Copyright (c) 2004 Novell, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/
#ifndef __NM_CONTACT_H__
#define __NM_CONTACT_H__
#include <glib.h>
typedef struct _NMContact NMContact;
typedef struct _NMContactProperty NMContactProperty;
typedef struct _NMFolder NMFolder;
#include "nmfield.h"
#include "nmuser.h"
/**
* Creates a contact
*
* Should be released by calling nm_release_contact
*
* @return The new NMContact
*
*/
NMContact *nm_create_contact(void);
/**
* Creates a contact from a field array representing the
* contact
*
* Should be released by calling nm_release_contact
*
* @param fields Should be the NM_A_FA_CONTACT for
* the contact
*
* @return The new contact
*
*/
NMContact *nm_create_contact_from_fields(NMField * fields);
/**
* Add a reference to an existing contact
*
* The reference should be released by calling
* nm_release_contact
*
* @param contact The contact
*
*/
void nm_contact_add_ref(NMContact * contact);
/**
* Update the contact list properties of the contact (sequence, parent id, etc.)
*
* @param contact The contact to update
* @param fields The fields to update from (should be a NM_A_FA_CONTACT array)
*
*/
void nm_contact_update_list_properties(NMContact * contact, NMField * fields);
/**
* Release a contact reference
*
* @param contact The contact to release.
*
*/
void nm_release_contact(NMContact * contact);
/**
* Get the display name of a contact
*
* @param contact The contact
*
* @return The display name of a contact
*
*/
const char *nm_contact_get_display_name(NMContact * contact);
/**
* Get the DN of a contact
*
* @param contact The contact
*
* @return The DN of the contact
*/
const char *nm_contact_get_dn(NMContact * contact);
/**
* Set the display name for a contact. This is called
* by nm_send_rename_contact. It should not be called
* directly (it does not change the display name on the
* server side list -- nm_send_rename_conact does).
*
* @param contact The contact
* @param display_name The new display name
*
*/
void nm_contact_set_display_name(NMContact * contact, const char * display_name);
/**
* Set the DN for the contact
*
* @param contact The contact
* @param dn The new DN for the contact
*
*/
void nm_contact_set_dn(NMContact * contact, const char * dn);
/**
* Return a field array (NM_A_FA_CONTACT) representing the contact
*
* @param contact The contact
*
* @return A field array representing the contact
*/
NMField *nm_contact_to_fields(NMContact * contact);
/**
* Set the user record for the contact
*
* @param contact The contact
* @param user_record The user record
*
*/
void nm_contact_set_user_record(NMContact * contact, NMUserRecord * user_record);
/**
* Get the user record for the contact
*
* @param contact The contact
*
* @return The user record associated with the contact
*
*/
NMUserRecord *nm_contact_get_user_record(NMContact * contact);
/**
* Get the user defined data for the contact
*
* @param contact The contact
*
* @return The user defined data for the contact
*
*/
gpointer nm_contact_get_data(NMContact * contact);
/**
* Get the Object ID for the contact
*
* @param contact The contact
*
* @return The ID for the contact
*/
int nm_contact_get_id(NMContact * contact);
/**
* Get the ID for the folder that the contact is in
*
* @param contact The contact
*
* @return The ID of the folder that contains the contact
*
*/
int nm_contact_get_parent_id(NMContact * contact);
/**
* Get The userid of the contact.
*
* @param contact The contact
*
* @return The userid of the contact
*
*/
const char *nm_contact_get_userid(NMContact * contact);
/**
* Get the display id of the contact
*
* @param contact The contact
*
* @return The display id of the contact
*/
const char *nm_contact_get_display_id(NMContact * contact);
/**
* Set the user defined data for the contact
*
* @param contact The contact
* @param data The user defined data
*
*/
void nm_contact_set_data(NMContact * contact, gpointer data);
/**
* Create a folder with the given name
*
* @param name The name of the folder
*
* @return The new folder
*
*/
NMFolder *nm_create_folder(const char *name);
/**
* Create a folder from a NM_A_FA_FOLDER field array
*
* @param fields The NM_A_FA_FOLDER field array
*
* @return The new folder
*
*/
NMFolder *nm_create_folder_from_fields(NMField * fields);
/**
* Add a reference to an existing folder
*
* The reference should be released by calling
* nm_release_folder
*
* @param folder The folder
*
*/
void nm_folder_add_ref(NMFolder * folder);
/**
* Release a reference to a folder.
*
* @param folder The folder to release
*
*/
void nm_release_folder(NMFolder * folder);
/**
* Return the number of subfolders for the given
* folder
*
* @param folder The folder
*
* @return The number of subfolders contained by folder
*/
int nm_folder_get_subfolder_count(NMFolder * folder);
/**
* Get a subfolder
*
* @param folder The root folder
* @param index The index of the folder to get
*
* @return The subfolder at the given index
*
*/
NMFolder *nm_folder_get_subfolder(NMFolder * folder, int index);
/**
* Get the number of contacts in the given folder
*
* @param folder The folder
*
* @return The number of contacts contained by folder
*
*/
int nm_folder_get_contact_count(NMFolder * folder);
/**
* Get a contact in the given folder
*
* @param folder The folder
* @param index The index of the contact to get
*
* @return The contact at the given index
*
*/
NMContact *nm_folder_get_contact(NMFolder * folder, int index);
/**
* Get the name of the folder
*
* @param folder The folder
*
* @return The name of the folder.
*
*/
const char *nm_folder_get_name(NMFolder * folder);
/**
* Set the name of a folder. Do not call this directly.
* It does not change the name of the folder in the
* server side contact list. You must call
* nm_send_set_folder_name().
*
* @param folder The folder
* @param name The new name for the folder
*
*/
void nm_folder_set_name(NMFolder * folder, const char *name);
/**
* Get Object ID for folder
*
* @param folder The folder
*
* @return The ID of the folder
*
*/
int nm_folder_get_id(NMFolder * folder);
/**
* Add contacts and folders from fields into root
*
* @param user The logged in user
* @param root The root folder
* @param fields The contact list field array
*
*/
void nm_folder_add_contacts_and_folders(NMUser * user, NMFolder * root,
NMField * fields);
/**
* Add a contact to the contact list.
*
* @param root_folder The root folder of the contact list
* @param contact The contact to add
*
*/
void nm_folder_add_contact_to_list(NMFolder * root_folder,
NMContact * contact);
/**
* Update the contact list properties of the folder (sequence, parent id, etc.)
*
* @param folder The folder to update
* @param fields The fields to update from (should be a NM_A_FA_FOLDER array)
*
*/
void nm_folder_update_list_properties(NMFolder * folder, NMField * fields);
/**
* Add folder to the contact list
*
* @param root_folder The root folder of the contact list
* @param folder The folder to add to the contact list
*
*/
void nm_folder_add_folder_to_list(NMFolder * root_folder, NMFolder * folder);
/**
* Find the object with the given id
*
* @param root_folder The root folder of the contact list
* @param object_id The object id of the object to find
*
* @return The object with object id (either a contact or a folder)
*/
gpointer nm_folder_find_item_by_object_id(NMFolder * root_folder,
int object_id);
/**
* Remove a contact from the folder
*
* @param folder The folder
* @param contact The contact to remove
*
*/
void nm_folder_remove_contact(NMFolder * folder, NMContact * contact);
/**
* Find a contact in a folder by DN
*
* @param folder The folder to search
* @param dn The DN of the contact to find
*
* @return The contact if found, NULL otherwise
*
*/
NMContact *nm_folder_find_contact(NMFolder * folder, const char *dn);
/**
* Find a contact in a folder by userid
*
* @param folder The folder to search
* @param userid The userid of the contact to find
*
* @return The contact if found, NULL otherwise
*
*/
NMContact *nm_folder_find_contact_by_userid(NMFolder * folder,
const char *userid);
/**
* Find a contact in a folder by display id
*
* @param folder The folder to search
* @param display_id The userid of the contact to find
*
* @return The contact if found, NULL otherwise
*
*/
NMContact *
nm_folder_find_contact_by_display_id(NMFolder * folder, const char *display_id);
/**
* Return a field array (NM_A_FA_FOLDER) representing the folder
*
* @param folder The folder
*
* @return A field array representing the folder
*/
NMField *nm_folder_to_fields(NMFolder * folder);
#endif
|