fix svace issues
[platform/core/pim/contacts-service.git] / doc / contacts_doc.h
1 /*
2  * Contacts Service
3  *
4  * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20  
21 #ifndef __TIZEN_SOCIAL_CONTACTS_DOC_H__
22 #define __TIZEN_SOCIAL_CONTACTS_DOC_H__
23
24
25 /**
26  * @ingroup CAPI_SOCIAL_FRAMEWORK
27  * @defgroup CAPI_SOCIAL_CONTACTS_SVC_MODULE Contacts
28  * @brief The Contacts Service API provides methods for managing contact information for people.
29  *        A contact object is always associated with a specific address book.
30  *        A person object is an aggregation of one or more contacts associated with the same person.
31  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_HEADER Required Header
32  * \#include <contacts.h>
33  *
34  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_OVERVIEW Overview
35  * The Contacts-service provides functions for managing contact information for people.
36  * A contact object is always associated with a specific address book.
37  * A person object is an aggregation of one or more contacts associated with the same person.
38  * Contacts-service has a relationship between Entities.
39  *
40  * @image html Contact_structure.png "Figure: Contact structure"
41  * There are three same contacts made from different address book.
42  * Person1 is an aggregation of Contact1, Contact2 and Contact3.
43  * The contacts-service provides an interface to manage the information
44  * <table>
45  * <tr>
46  * <td>
47  *      - Managing contacts information stored in database <br>
48  *      - Aggregating contacts information from various accounts <br>
49  *      - Notifying changes of contacts information <br>
50  *      - Searching contacts information <br>
51  *      - vCard supports <br>
52  * </td>
53  * </tr>
54  * </table>
55  *
56  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_ENTITIES Entities
57  * Contacts-Service manages information related to following entities.
58  * - Contact
59  *   - Information for individuals, like name, phone number, email, address, job, instant messenger, company, etc.
60  * - Account
61  *   - Accounts are handled by account module. Contacts-service should use account ID which is created in the module.
62  *   - Exceptionally, Local device address book has no account and its related account ID is zero.
63  *   - Each account can create only one address book.
64  * - Address book
65  *   - Represents where contacts and groups should belong to
66  *   - Created by one of contacts sources below
67  *      - Local device, which has no account.
68  *      - Service providers such as Google or Yahoo, with account.
69  *      - Applications like ChatON, Joyn, Facebook, etc.
70  * - Group
71  *   - Grouped contacts on a same address book.
72  *   - Groups and contacts have many-to-many relationship.
73  * - Person
74  *   - A virtual contact that keeps merged information of contacts linked together.
75  *   - When more than one contact from different sources designate same individual, then instead of showing each contacts separately, by Person concept, they can be shown and managed as one virtual contact.
76  *   - Every contact becomes linked to at least one person.
77  * - My profile
78  *   - My information which has almost same properties as contact information but it has no properties such as group relation, ringtone and message alert.
79  *   - Single entry can be available on each address book.
80  * - Activity
81  *   - Social activities are stored.
82  * - Speed Dial
83  *   - Shortcut dialing number key information.
84  * - Phone Log
85  *   - Call or message logs are stored.
86  *
87  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_ENTITIES_RELATIONSHIP Relationship between entities
88  * Contacts-service has a relationship between Entities.
89  *
90  * @image html Relationship_between_entities.png "Figure: Relationship between entities"
91  *
92  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_RELATIONSHIP_BETWEEN_CONTACT_AND_PERSON Relationship between Contact and Person
93  * Person will be created automatically when inserting a contact record. Cannot create person record directly.
94  *
95  * Sample code: Insert a contact record
96  * @code
97  * // create contact record
98  * contacts_record_h contact = NULL;
99  * contacts_record_create(_contacts_contact._uri, &contact);
100  *
101  * // add name
102  * contacts_record_h name = NULL;
103  * contacts_record_create(_contacts_name._uri, &name);
104  * contacts_record_set_str(name, _contacts_name.first, “test”);
105  * contacts_record_add_child_record(contact, _contacts_contact.name, name);
106  *
107  * // add number
108  * contacts_record_h number = NULL;
109  * contacts_record_create(_contacts_number._uri, &number);
110  * contacts_record_set_str(number, _contacts_number.number, “1234”);
111  * contacts_record_add_child_record(contact, _contacts_contact.number, number);
112  *
113  * // insert to database
114  * int contact_id = 0;
115  * contacts_db_insert_record(contact, &contact_id);
116  *
117  * // destroy record
118  * contacts_record_destroy(contact, true);
119  * @endcode
120  *
121  * @image html Creating_a_person_record.png "Figure: Creating a person record"
122  * Person record can be link to another person. Even though contacts address book is different, link is possible.
123  *
124  * Sample code: Link contact
125  * @code
126  * int person_id1 = ... // acquire ID of Person1 record
127  * int person_id2 = ... // acquire ID of Person2 record
128  *
129  * contacts_person_link_person(person_id1, person_id2);
130  * @endcode
131  *
132  * @image html Link_person.png "Figure: Link person"
133  * Contact record can be separate from person record. New person will be created when unlinking contact record.
134  *
135  * Sample code: Unlink contact
136  * @code
137  * int person_id1 = ... // acquire ID of Person1 record
138  * int contact_id3 = ... // acquire ID of Contact3 record
139  *
140  * contacts_person_unlink_contact(person_id1, contact_id3);
141  * @endcode
142  *
143  * @image html Unlink_contact.png "Figure: Unlink contact"
144  *
145  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_VIEWS Views
146  * To access and handle entities, views are provided.
147  * According to data-view declarations, generic access functions are used (contacts_db_insert_record(), contacts_record_get_int(), …).
148  * Data-View is almost same as database “VIEW” which limits access and guarantees the performance by offering various views for the proper purpose.
149  * “Record” represents a single row of the data-views. <br>
150  * A data-view is a structure, which has property elements.
151  * For example, the _contacts_contact view describes the properties of the contact record.
152  * Its properties include name, company, nickname of the contact and many more.
153  * <table>
154  * <caption> Table: Contact editable views </caption>
155  * <tr>
156  * <th>View (Editable)</th>
157  * <th>Description</th>
158  * </tr>
159  * <tr> <td>    _contacts_address_book  </td>   <td>    Describes the properties of the address book            </td>   </tr>
160  * <tr> <td>    _contacts_group </td>   <td>    Describes the properties of the group           </td>   </tr>
161  * <tr> <td>    _contacts_person        </td>   <td>    Describes the properties of the person          </td>   </tr>
162  * <tr> <td>    _contacts_simple_contact        </td>   <td>    Describes the properties of the contact         </td>   </tr>
163  * <tr> <td>    _contacts_contact       </td>   <td>    Describes the properties of the contact         </td>   </tr>
164  * <tr> <td>    _contacts_my_profile    </td>   <td>    Describes the properties of my profile          </td>   </tr>
165  * <tr> <td>    _contacts_name  </td>   <td>    Describes the properties of the contacts name           </td>   </tr>
166  * <tr> <td>    _contacts_number        </td>   <td>    Describes the properties of the contacts number         </td>   </tr>
167  * <tr> <td>    _contacts_email </td>   <td>    Describes the properties of the contacts email          </td>   </tr>
168  * <tr> <td>    _contacts_address       </td>   <td>    Describes the properties of the contacts address                </td>   </tr>
169  * <tr> <td>    _contacts_note  </td>   <td>    Describes the properties of the contacts note           </td>   </tr>
170  * <tr> <td>    _contacts_url   </td>   <td>    Describes the properties of the contacts url            </td>   </tr>
171  * <tr> <td>    _contacts_event </td>   <td>    Describes the properties of the contacts birthday and anniversary               </td>   </tr>
172  * <tr> <td>    _contacts_group_relation        </td>   <td>    Describes the properties of the contacts group relation         </td>   </tr>
173  * <tr> <td>    _contacts_relationship  </td>   <td>    Describes the properties of the contacts relationship           </td>   </tr>
174  * <tr> <td>    _contacts_image </td>   <td>    Describes the properties of the contacts image          </td>   </tr>
175  * <tr> <td>    _contacts_company       </td>   <td>    Describes the properties of the contacts company                </td>   </tr>
176  * <tr> <td>    _contacts_nickname      </td>   <td>    Describes the properties of the contacts nickname               </td>   </tr>
177  * <tr> <td>    _contacts_messenger     </td>   <td>    Describes the properties of the contacts messenger              </td>   </tr>
178  * <tr> <td>    _contacts_extension     </td>   <td>    Describes the properties of the extension               </td>   </tr>
179  * <tr> <td>    _contacts_sdn   </td>   <td>    Describes the properties of the service description number              </td>   </tr>
180  * <tr> <td>    _contacts_profile       </td>   <td>    Describes the properties of the profile         </td>   </tr>
181  * <tr> <td>    _contacts_activity_photo        </td>   <td>    Describes the properties of the photo of contacts activity              </td>   </tr>
182  * <tr> <td>    _contacts_activity      </td>   <td>    Describes the properties of the contacts activity               </td>   </tr>
183  * <tr> <td>    _contacts_speeddial     </td>   <td>    Describes the properties of the speed dial              </td>   </tr>
184  * <tr> <td>    _contacts_phone_log     </td>   <td>    Describes the properties of the log             </td>   </tr>
185  * </table>
186  * <table>
187  * <caption> Table: Contact read only views </caption>
188  * <tr>
189  * <th>View (Read only)</th>
190  * <th>Description</th>
191  * </tr>
192  * <tr> <td>    _contacts_contact_updated_info  </td>   <td>    used when identifying contact changes depending on version      </td>   </tr>
193  * <tr> <td>    _contacts_my_profile_updated_info       </td>   <td>    used when identifying my profile changes depending on version   </td>   </tr>
194  * <tr> <td>    _contacts_group_updated_info    </td>   <td>    used when identifying group changes depending on version        </td>   </tr>
195  * <tr> <td>    _contacts_group_member_updated_info     </td>   <td>    used when identifying group member changes depending on version </td>   </tr>
196  * <tr> <td>    _contacts_grouprel_updated_info </td>   <td>    used when identifying group relation profile changes depending on version       </td>   </tr>
197  * <tr> <td>    _contacts_person_contact        </td>   <td>    used when querying to merge information of person and contact   </td>   </tr>
198  * <tr> <td>    _contacts_person_number </td>   <td>    used when querying to merge information of person and number    </td>   </tr>
199  * <tr> <td>    _contacts_person_email  </td>   <td>    used when querying to merge information of person and email     </td>   </tr>
200  * <tr> <td>    _contacts_person_grouprel       </td>   <td>    used when querying to merge information of person and group relation    </td>   </tr>
201  * <tr> <td>    _contacts_person_group_assigned </td>   <td>    used when querying for information of person who is assigned to group   </td>   </tr>
202  * <tr> <td>    _contacts_person_group_not_assigned     </td>   <td>    used when querying for information of person who is not assigned to group       </td>   </tr>
203  * <tr> <td>    _contacts_person_phone_log      </td>   <td>    used when querying to merge information of person and phone log </td>   </tr>
204  * <tr> <td>    _contacts_person_usage  </td>   <td>    used when querying for information of person usage      </td>   </tr>
205  * <tr> <td>    _contacts_contact_number        </td>   <td>    used when querying to merge information of contact and number   </td>   </tr>
206  * <tr> <td>    _contacts_contact_email </td>   <td>    used when querying to merge information of contact and email    </td>   </tr>
207  * <tr> <td>    _contacts_contact_grouprel      </td>   <td>    used when querying to merge information of contact and group relation   </td>   </tr>
208  * <tr> <td>    _contacts_contact_activity      </td>   <td>    used when querying to merge information of contact and activity </td>   </tr>
209  * <tr> <td>    _contacts_phone_log_stat        </td>   <td>    used when querying for information of phone log status  </td>   </tr>
210  * </table>
211  *
212  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_VIEWS_PROPERTIES Properties
213  * Property elements have their data types and name. <br>
214  * Record types which have *_id as their properties, hold identifiers of other records - e.g. name, number and email views hold ID of their corresponding contacts in contact_id property (as children of the corresponding contacts record). <br>
215  * A type of some property is ‘record’.
216  * It means that the parent record can have child records.
217  * For example, a contact record has 'name', 'number' and 'email' properties, which means that records of those types can be children of contact type records.<br>
218  * In contacts_view.h headear file, view macros are found and below figure shows what the macro means.
219  *
220  * @image html Properties.png "Figure: Properties"
221  *
222  * Sample code: Create a contact record then set caller ID
223  * @code
224  * contacts_record_h contact = NULL;
225  * contacts_record_create(_contacts_contact._uri, &contact);
226  *
227  * // set image to _contacts_contact view.
228  * contacts_record_h image = NULL;
229  * contacts_record_create(_contacts_image._uri, &image);
230  *
231  * char *resource_path = app_get_resource_path();
232  * char caller_id_path[1024] = {0};
233  * snprintf(caller_id_path, sizeof(caller_id_path), "%s/caller_id.jpg", resource_path);
234  * free(resource_path);
235  * contacts_record_set_str(image, _contacts_image.path, caller_id_path);
236  *
237  * // add image record to contact
238  * contacts_record_add_child_record(contact, _contacts_contact.image, image);
239  * @endcode
240  *
241  * <table class="note">
242  *    <tr>
243  *     <th class="note">Note</th>
244  *    </tr>
245  *    <tr>
246  *     <td class="note">For an application to insert private images in contacts, it needs to follow below conditions:<br/>
247  * &nbsp;&nbsp;&nbsp;1. Application must have privilege of http://tizen.org/privilege/contact.write to use APIs such as contacts_db_insert_record().<br/>
248  * &nbsp;&nbsp;&nbsp;2. Application's private directory and files must have 'read' permission of others, '644' for example. SMACK protects read permission from the other applications.<br/>
249  * &nbsp;&nbsp;&nbsp;3. Application may erase the image after destroying the contact record (contacts_record_destroy).<br/>
250  *     </td>
251  *    </tr>
252  * </table>
253  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_RECORDS Records
254  * In contacts-service, one of the basic concept is a record.
255  * It may be helpful to know that a record represents an actual record in the internal database, but in general,
256  * you can think of a record as a piece of information, like an address, phone number or group of contacts.
257  * A record can be a complex set of data, containing other data, e.g. an address record contains country, region, and street, among others.<br>
258  * Also, the contained data can be a reference to another record.
259  * For example, a contact record contains the 'address' property, which is a reference to an address record.
260  * An address record belongs to a contact record - its 'contact_id' property is set to identifier of the corresponding contact (more on IDs later).
261  * In this case, the address is the contacts child record and the contact is the parent record.<br>
262  * Effectively, a record can be a node in a tree or graph of relations between records.
263  *
264  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_RECORDS_URI URI
265  * Each record type has a special structure defined for it, called 'view', which contains identifiers of its properties. <br>
266  * Every view has a special field - _uri - that uniquely identifies the view.
267  * In many cases you need to use the _uri value to indicate what type of record you wish to create or operate on.
268  *
269  * APIs which needs _uri
270  * @code
271  * API int contacts_record_create(const char* view_uri, ...)
272  * API int contacts_filter_create(const char* view_uri, ...)
273  * API int contacts_query_create(const char* view_uri, ...)
274  * API int contacts_db_get_record(const char* view_uri, ...)
275  * API int contacts_db_delete_record(const char* view_uri, ...)
276  * API int contacts_db_get_all_records(const char* view_uri, ...)
277  * API int contacts_db_delete_records(const char* view_uri, ...)
278  * API int contacts_db_add_changed_cb(const char* view_uri, ...)
279  * API int contacts_db_remove_changed_cb(const char* view_uri, ...)
280  * API int contacts_db_get_changes_by_version(const char* view_uri, ...)
281  * API int contacts_db_search_records(const char* view_uri, ...)
282  * API int contacts_db_search_records_with_range(const char* view_uri, ...)
283  * API int contacts_db_get_count(const char* view_uri, ...)
284  * @endcode
285  *
286  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_RECORDS_HANDLE Record handle
287  * To use a record, you must obtain its handle.
288  * There are many ways to obtains it, including creating a new record and referring to child records of a record. <br>
289  * When creating a record, you need to specify what type of record you want to create.
290  * This is where you should use the URI property.
291  *
292  * Sample code: Creates a contact record
293  * @code
294  * contacts_record_h contact = NULL;
295  * contacts_record_create(_contacts_contact._uri, &contact);
296  * @endcode
297  *
298  * Sample code: Gets a contact record with id
299  * @code
300  * contacts_record_h contact = NULL;
301  * contacts_db_get_record(_contacts_contact._uri, id, &contact);
302  * @endcode
303  *
304  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_RECORDS_BASIC_TYPES Basic types
305  * A record can have basic properties of five types: integer, string, boolean, long integer, lli (long long int), double.
306  * Each property of basic type has functions to operate on it:
307  * <table>
308  * <caption> Table: Setter and getter functions </caption>
309  * <tr>
310  *    <th>Property type</th>
311  *    <th>Setter</th>
312  *    <th>Getter</th>
313  * </tr>
314  * <tr>
315  *    <td> string </td>
316  *    <td> @ref contacts_record_set_str </td>
317  *    <td> @ref contacts_record_get_str </td>
318  * </tr>
319  * <tr>
320  *    <td> integer </td>
321  *    <td> @ref contacts_record_set_int </td>
322  *    <td> @ref contacts_record_get_int </td>
323  * </tr>
324  * <tr>
325  *    <td> boolean </td>
326  *    <td> @ref contacts_record_set_bool </td>
327  *    <td> @ref contacts_record_get_bool </td>
328  * </tr>
329  * <tr>
330  *    <td> long long integer </td>
331  *    <td> @ref contacts_record_set_lli </td>
332  *    <td> @ref contacts_record_get_lli </td>
333  * </tr>
334  * <tr>
335  *    <td> double </td>
336  *    <td> @ref contacts_record_set_double </td>
337  *    <td> @ref contacts_record_get_double </td>
338  * </tr>
339  * </table>
340  * Above functions also require specifying which property you wish to get/set.
341  * Every getter and setter functions need record and property ID.
342  * You can make property ID by combine data-view name and property name.
343  * (.e.g. property ID of a contact display_name property : _contacts_contact.display_name)
344  *
345  * Sample code : Sets the ‘ringtone_path’ property of a contact record.
346  * @code
347  * char *resource_path = app_get_resource_path();
348  * char ringtone_path[1024] = {0};
349  * snprintf(ringtone_path, sizeof(ringtone_path), "%s/ringtone.mp3", resource_path);
350  * free(resource_path);
351  * contacts_record_set_str(contact, _contacts_contact.ringtone_path, ringtone_path);
352  * @endcode
353  *
354  * Note on returned values ownership: string getter function have the "_p" postfix.
355  * It means that the returned value should not be freed by the application, as it is a pointer to data in an existing record.
356  *
357  * Sample code: Two ways of getting string property
358  * @code
359  * contacts_record_get_str(record, _contacts_person.display_name, &display_name);
360  * contacts_record_get_str_p(record, _contacts_person.display_name, &display_name);
361  * @endcode
362  *
363  * In the first case, the returned string should be freed by the application.
364  * In second one, display_name value will freed automatically when destroying the record handle.
365  *
366  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_RECORDS_CHILD Child
367  * A record can have properties of type 'record' called child records.
368  * A record can contain several records of a given type. For example, a ‘contact record’(parent) can contain many ‘address records’(children).
369  * The code below inserts an address record into a contact record.
370  * Note that it is not necessary to insert all records - just the contact record needs to be inserted into the database, it is enough for all information to be stored.
371  * Both records are then destroyed.
372  *
373  * Sample code: Add child record
374  * @code
375  * contacts_record_h address = NULL;
376  * contacts_record_h image = NULL;
377  * int contact_id = 0;
378  *
379  * // image, address record can be child record of contact record
380  * contacts_record_create(_contacts_contact._uri, &contact);
381  *
382  * contacts_record_create(_contacts_image._uri, &image);
383  * char *resource_path = app_get_resource_path();
384  * char caller_id_path[1024] = {0};
385  * snprintf(caller_id_path, sizeof(caller_id_path), "%s/caller_id.jpg", resource_path);
386  * free(resource_path);
387  * contacts_record_set_str(image, _contacts_image.path, caller_id_path);
388  * contacts_record_add_child_record(contact, _contacts_contact.image, image);
389  *
390  * contacts_record_create(_contacts_address._uri, &address);
391  * contacts_record_set_str(address, _contacts_address.country, "Korea");
392  * contacts_record_add_child_record(contact, _contacts_contact.address, address);
393  *
394  * // insert contact to DBs
395  * contacts_db_insert_record(contact, &contact_id);
396  * contacts_record_destroy(contact, true);
397  * @endcode
398  *
399  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_RECORDS_RECORD_ID_PROPERTY Record ID property
400  * ID is unique number which can identify a record Therefore, if you know the ID of a record, you can directly handle the record.
401  * The ID is read-only property, which is available after the record has been inserted into the database.
402  *
403  * Sample code: Gets a contact record with id
404  * @code
405  * contacts_record_h contact = NULL;
406  * contacts_record_create(_contacts_contact._uri, &contact);
407  *
408  * contacts_record_h name = NULL;
409  * contacts_record_create(_contacts_name._uri, &name);
410  * contacts_record_set_str(name, _contacts_name.first, “first name”);
411  * contacts_record_add_child_record(contact, _contacts_contact.name, name);
412  *
413  * int contact_id = 0;
414  * contacts_db_insert_record(contact, &contact_id); // contact_id is unique number of contact record
415  * contacts_record_destroy(contact, true); // contact is no longer usable
416  *
417  * contacts_db_get_record(_contacts_contact._uri, contact_id, &contact); // contact is now a handle to the same record as before
418  * char *display_name = NULL;
419  * contacts_record_get_str(contact, _contacts_contact.display_name, &display_name);
420  * contacts_record_destroy(contact, true); // contact is no longer usable
421  * @endcode
422  *
423  * Identifiers can also be used to establish a relation between two records. The following code sets an address record's 'contact_id' property to the ID of the contact. contact_id make relate between the address record and the contact which is identified by the contact_id. After that is done, the address becomes one of the addresses connected to the contact. The address is now the contacts child record, the contact is the parent record.
424  *
425  * Sample code: Insert a address record with contact_id
426  * @code
427  * int contact_id = ... // acquire id of created contact
428  * int address_id = 0;
429  * contacts_record_create(_contacts_address._uri, &address);
430  * contacts_record_set_int(address, _contacts_address.contact_id, contact_id);
431  * // set other address properties
432  * // ...
433  * contacts_db_insert_record(address, &address_id);
434  * @endcode
435  * Having a record handle, you can access all records of a specific type related to the given record.
436  *
437  * Sample code: Gets a contact record
438  * @code
439  * int contact_id = ... // acquire id of created contact
440  * int address_num = 0;
441  * int i = 0;
442  * contacts_db_get_record(_contacts_contact._uri, contact_id, &contact);
443  * contacts_record_get_child_record_count(contact, _contacts_contact.address, &address_num);
444  * for (i = 0; i < address_num; i++) {
445  *  contacts_record_h address = NULL;
446  *  contacts_record_get_child_record_at_p(contact, _contacts_contact.address, i, &address);
447  *  contacts_record_set_str(address, _contacts_address.country, "Korea");
448  * }
449  * contacts_db_update_record(contact);
450  * contacts_record_destroy(contact, true);
451  * @endcode
452  *
453  * This example is to change a country of addresses which are child records of a contact. Each address can be traversed by using contacts_record_get_child_record_at_p(). It is possible to apply the changes by updating the contact which is the parent record.
454  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_LISTS Lists
455  * The contacts-service provides functions which can handle list of same type records. Lists concept is based on standard doubly linked list.
456  * To operate a list, you must obtain its handle. The handle is provided during creation of the list. List handle must destroy after use.
457  *
458  * @code
459  * API int contacts_list_create(contacts_list_h* contacts_list);
460  * API int contacts_list_destroy(contacts_list_h contacts_list, bool delete_child);
461  * @endcode
462  *
463  * If ‘delete_child’ parameter is the true, child resources will destroy automatically.
464  *
465  * Sample code: Create a list handle
466  * @code
467  * // get list handle with query
468  * contacts_list_h list = NULL;
469  * contacts_list_create(&list);
470  *
471  * // use list
472  * //  ...
473  *
474  * contacts_list_destroy(list, true);
475  * @endcode
476  *
477  * Sample code: Gets person list handle from database.
478  * @code
479  * // get list handle with query
480  * contacts_list_h list = NULL;
481  * contacts_db_get_all_records(_contacts_person._uri, 0, 0, &list);
482  *
483  * // use list
484  * // ...
485  *
486  * contacts_list_destroy(list, true);
487  * @endcode
488  *
489  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_LISTS_CURSOR Cursor
490  * The list can be traversed by using cursor.
491  *
492  * @code
493  * API int contacts_list_first(contacts_list_h contacts_list);
494  * API int contacts_list_last(contacts_list_h contacts_list);
495  * API int contacts_list_next(contacts_list_h contacts_list);
496  * API int contacts_list_prev(contacts_list_h contacts_list);
497  * @endcode
498  *
499  * You can get a record of current cursor.
500  *
501  * @code
502  * API int contacts_list_get_current_record_p(contacts_list_h contacts_list, contacts_record_h* record);
503  * @endcode
504  *
505  * Sample code: Loop list
506  * @code
507  * contacts_list_h list = NULL;
508  * contacts_record_h record = NULL;
509  * contacts_db_get_all_records(_contacts_person._uri, 0, 0, &list);
510  * do {
511  *  contacts_list_get_current_record_p(list, &record);
512  *  if (NULL == record)
513  *   break;
514  *  char *name = NULL;
515  *  contacts_record_get_str_p(record, _contacts_person.display_name, &name);
516  *  printf(“name=%s\n”, name);
517  * } while (CONTACTS_ERROR_NONE == contacts_list_next(list));
518  * contacts_list_destroy(list, true); // destroy child records automatically
519  * @endcode
520  *
521  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_LISTS_ADD_REMOVE Add / Remove
522  * The contacts-service provides functions for adding/removing child record on list.
523  * @code
524  * API int contacts_list_add(contacts_list_h contacts_list, contacts_record_h record);
525  * API int contacts_list_remove(contacts_list_h contacts_list, contacts_record_h record);
526  * @endcode
527  *
528  * Sample code: Adds records to the list
529  * @code
530  * contacts_record_h group1 = NULL;
531  * contacts_record_create(_contacts_group._uri, &group1);
532  * contacts_record_set_str(group1, _contacts_group.name, “group test1”);
533  *
534  * contacts_record_h group2 = NULL;
535  * contacts_record_create(_contacts_group._uri, &group2);
536  * contacts_record_set_str(group2, _contacts_group.name, “group test2”);
537  *
538  * contacts_list_h list = NULL;
539  * contacts_list_create(&list);
540  *
541  * // Adds records to the list
542  * contacts_list_add(list, group1);
543  * contacts_list_add(list, group2);
544  *
545  * contacts_db_insert_records(list, NULL, NULL);
546  * contacts_list_destroy(list, true);
547  * @endcode
548  *
549  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_BULK_APIS Bulk APIs
550  * Bulk APIs provide to insert/update/delete multiple records. There is no limit of record count on bulk API, but it causes a process to hang during the time the API is operated. Bulk APIs guarantee atomicity. That is, the API operating either all, or nothing.
551  *
552  * @code
553  * API int contacts_db_insert_records(contacts_list_h record_list, int **ids, int *count);
554  * API int contacts_db_update_records(contacts_list_h record_list);
555  * API int contacts_db_delete_records(const char* view_uri, int record_id_array[], int count);
556  * API int contacts_db_replace_records(contacts_list_h list, int record_id_array[], int count);
557  * @endcode
558  *
559  * Sample code: Insert two contact records using bulk API.
560  * @code
561  * contacts_record_h contact1;
562  * contacts_record_create(_contacts_contact.uri, &contact1);
563  *
564  * // fill contact record
565  * // ...
566  *
567  * contacts_record_h contact2;
568  * contacts_record_create(_contacts_contact._uri, &contact2);
569  *
570  * // fill contact record
571  * // ...
572  *
573  * contacts_list_h list = NULL;
574  * contacts_list_create(&list);
575  *
576  * contacts_list_add(list, contact1);
577  * contacts_list_add(list, contact2);
578  *
579  * int **ids = NULL;
580  * int count = 0;
581  *
582  * // Insert contact records using bulk API
583  * contacts_db_insert_records(list, &ids, &count);
584  *
585  * // use ids
586  * // ...
587  *
588  * contacts_list_destroy(list, true);
589  * free(ids);
590  * @endcode
591  *
592  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_FILTER_AND_QUERIES Queries
593  * Queries are used to retrieve data which satisfies given criteria, like an integer property being greater than a given value, or a string property containing a given substring. Query needs a filter which can set the condition for search. The contacts-service provides query APIs for sorting, set projection and removing duplicated results.
594  *
595  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_FILTER_AND_QUERIES_FILTER Filter
596  * The contacts Filter API provides the set of definitions and interfaces that enable application developers to make filters to set query. <br>
597  * When creating a filter, you need to specify what type of filter you want to create using _uri property. Filter handle must destroy after use.
598  *
599  * @code
600  * API int contacts_filter_create(const char* view_uri, contacts_filter_h* filter);
601  * API int contacts_filter_destroy(contacts_filter_h filter);
602  * @endcode
603  *
604  * Sample code: Set filter condition to contain a given substring.
605  * @code
606  * contacts_filter_add_str(filter, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, “1234”);
607  * @endcode
608  *
609  * Sample code: Set filter condition to property value is true.
610  * @code
611  * contacts_filter_add_bool(filter, _contacts_person.is_favorite, true);
612  * @endcode
613  *
614  * Conditions can be added to a filter. The conditions SHOULD be joined by using a AND and OR logical operator.
615  *
616  * Sample code: Creates composite filter with OR operator.
617  * @code
618  * contacts_filter_add_str(filter1, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, “1234”);
619  * contacts_filter_add_operator(filter1, CONTACTS_FILTER_OPERATOR_OR);
620  * contacts_filter_add_str(filter1, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, “5678”);
621  * @endcode
622  *
623  * Additionally, filters can join each other by using a AND and OR logical operator.
624  *
625  * Sample code: Creates joined filter with AND operator.
626  * @code
627  * contacts_filter_add_str(filter1, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, “1234”);
628  * contacts_filter_add_operator(filter1, CONTACTS_FILTER_OPERATOR_OR);
629  * contacts_filter_add_str(filter1, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, “5678”);
630  *
631  * contacts_filter_add_bool(filter2, _contacts_person.is_fovorite, true);
632  *
633  * contacts_filter_add_operator(filter1, CONTACTS_FILTER_OPERATOR_AND);
634  * contacts_filter_add_filter(filter1, filter2);
635  * @endcode
636  *
637  * Operator precedence in filters is determined by the order in which the conditions and filters are added. For example, if the following sequence is added:
638  * <table>
639  * <caption> Table: Filter and conditions </caption>
640  * <tr>
641  *      <th> Filter with conditions </th>
642  *      <th> Result </th>
643  * </tr>
644  * <tr>
645  *      <td>
646  *              Contidion C1 <br>
647  *              OR <br>
648  *              Contidion C2 <br>
649  *              AND <br>
650  *              Condition C3
651  *      </td>
652  *      <td> (C1 OR C2) AND C3 </td>
653  * </tr>
654  * <tr>
655  *      <td>
656  *              Filter F1: <br>
657  *                      Condition C1 <br>
658  *                      OR <br>
659  *                      Condition C2 <br><br>
660  *              Filter F2: <br>
661  *                      Condition C3 <br>
662  *                      OR <br>
663  *                      Condition C4 <br><br>
664  *              Filter F3: <br>
665  *                      Condition C5 <br>
666  *                      AND <br>
667  *                      F1 <br>
668  *                      AND <br>
669  *                      F2
670  *      </td>
671  *      <td>
672  *              (C5 AND F1) AND F2 <br>
673  *              Which is: <br>
674  *              (C5 AND (C1 OR C2)) AND (C3 OR C4)
675  *      </td>
676  * </tr>
677  * </table>
678  *
679  * Sample code: Create a filter which will accept addresses with their contact's id equal to a given id (integer filter), or their country property equal to "Korea" (string filter). Create a query and add the filter to it. Results are received in a list.
680  * @code
681  * contacts_filter_h filter = NULL;
682  * contacts_list_h list = NULL;
683  * contacts_query_h query = NULL;
684  *
685  * contacts_filter_create(_contacts_address._uri, &filter);
686  * contacts_filter_add_int(filter, _contacts_address.contact_id, CONTACTS_MATCH_EQUAL, id);
687  * contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_OR);
688  * contacts_filter_add_str(filter, _contacts_address.country, CONTACTS_MATCH_EXACTLY, "Korea");
689  * contacts_query_create(_contacts_address._uri, &query);
690  * contacts_query_set_filter(query, filter);
691  *
692  * contacts_db_get_records_with_query(query, 0, 0, &list);
693  *
694  * contacts_filter_destroy(filter);
695  * contacts_query_destroy(query);
696  *
697  * // use the list
698  * // ...
699  *
700  * contacts_list_destroy(list, true);
701  *
702  * @endcode
703  *
704  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_FILTER_AND_QUERIES_SORT Sort
705  * Query results list can sort by property id.
706  *
707  * @code
708  * API int contacts_query_set_sort(contacts_query_h query, unsigned int property_id, bool is_ascending);
709  * @endcode
710  *
711  * Sample code: Sort to query result by person id
712  * @code
713  * contacts_filter_add_str(filter, _contacts_person.display_name, CONTACTS_MATCH_CONTAINS, “Joe”);
714  * contacts_query_set_filter(query, filter);
715  * contacts_query_set_sort(query, _contacts_person.id, true);
716  *
717  * contacts_db_get_records_with_query(query, 0, 0, &list);
718  *
719  * contacts_query_destroy(query);
720  * contacts_filter_destroy(filter);
721  * contacts_list_destroy(person_list, true);
722  * @endcode
723  *
724  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_FILTER_AND_QUERIES_PROJECTION Projection
725  * Projection allows you to query the Data for just those specific properties of a record that you actually need, at lower latency and cost than retrieving the entire properties.
726  *
727  * @code
728  * API int contacts_query_set_projection(contacts_query_h query, unsigned int property_ids[], int count)
729  * @endcode
730  *
731  * Sample code: Creates a filter which will get only person id, display name, image thumbnail path from the person record with its vibration path has “test” (string filter). Create a query and add the filter to it. Results are received in a list.
732  * @code
733  * contacts_filter_add_str(filter, _contacts_person.vibration, CONTACTS_MATCH_CONTAINS, "test");
734  * contacts_query_set_filter(query, filter);
735  *
736  * //set projections to get
737  * unsigned int person_projection[] = {
738  *  _contacts_person.id,
739  *  _contacts_person.display_name,
740  *  _contacts_person.image_thumbnail_path,
741  * };
742  * contacts_query_set_projection(query, person_projection, sizeof(person_projection)/sizeof(int));
743  *
744  * contacts_db_get_records_with_query(query, 0, 0, &person_list);
745  *
746  * // use list
747  * // ...
748  *
749  * contacts_query_destroy(query);
750  * contacts_filter_destroy(filter);
751  * contacts_list_destroy(person_list, true);
752  * @endcode
753  *
754  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_FILTER_AND_QUERIES_DISTINCT Distinct
755  * If you query to some read-only view with set projection, result list can contain duplicates. You can remove duplicates using _contacts_query_set_distinct.
756  *
757  * @code
758  * API int contacts_query_set_distinct(contacts_query_h query, bool set)
759  * endcode
760  *
761  * Sample code: Remove duplicates
762  * @code
763  * unsigned int projection[] = {
764  * _contacts_person_number.person_id,
765  * _contacts_person_number.display_name,
766  * };
767  * contacts_filter_create(_contacts_person_number._uri, &filter);
768  * contacts_filter_add_bool(filter, _contacts_person_number.has_phonenumber, true);
769  *
770  * contacts_query_create(_contacts_person_number._uri, &query);
771  * contacts_query_set_projection(query, projection, sizeof(projection)/sizeof(int));
772  * contacts_query_set_filter(query, filter);
773  *
774  * // set distinct (remove duplicates)
775  * contacts_query_set_distinct(query, true);
776  *
777  * contacts_db_get_records_with_query(query, 0, 0, &list);
778  *
779  * // use list
780  * // ...
781  *
782  * contacts_list_destroy(list, true);
783  * contacts_query_destroy(query);
784  * contacts_filter_destroy(filter);
785  * @endcode
786  *
787  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_DATABASE_CHANGE_NOTIFICATIONS Database Change Notifications
788  * Applications add/remove callback function to detect/ignore the contacts DB changes with contacts_db_add_changed_cb() / contacts_db_remove_changed_cb(). <br>
789  * Clients wait contacts change notification on client side. <br>
790  * If contact is changed by another module, server publishes notification. The notification will be broadcast to subscribed modules. Finally, user callback function is called with user data.
791  *
792  * Sample code: Register person changes notification callback
793  * @code
794  * // callback function
795  * static void __person_changed_cb(const char *view_uri, void *user_data)
796  * {
797  * // jobs for callback
798  * }
799  * // add changed noti callback
800  * contacts_db_add_changed_cb(_contacts_person._uri,  __person_changed_cb,  NULL);
801  * @endcode
802  *
803  * @section CAPI_SOCIAL_CONTACTS_SVC_MODULE_VCARD vCard
804  * Contacts-service provides methods for parsing and making vCard . vCard APIs based on vCard v3.0 specification. For more information about vCard, refer to rfc2426 (http://www.ietf.org/rfc/rfc2426.txt)
805  *
806  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_VCARD_PARSING_VCARD Parsing vCard
807  * There are two ways for parsing vCard.
808  *
809  * Sample code: Parsing vCard from stream then insert to database.
810  * @code
811  * // make contact record list from vcard stream
812  * contacts_list_h list = NULL;
813  * contacts_vcard_parse_to_contacts(vcard_stream, &list);
814  *
815  * int *ids = NULL;
816  * int count = 0;
817  * contacts_db_insert_records(list, &ids, &count);
818  *
819  * // use ids, count
820  * // ...
821  *
822  * free(ids);
823  * contacts_list_destroy(list, true);
824  * @endcode
825  *
826  * Sample code: Parsing vCard from file then insert to database
827  * @code
828  * // called to get a record handle of _contacts_contact view
829  * static bool __vcard_parse_cb(contacts_record_h record, void *user_data)
830  * {
831  * int id = 0;
832  * contacts_db_insert_record(record, &id);
833  *
834  * // return false to break out of the loop
835  * // return true to continue with the next iteration of the loop
836  * return true;
837  * }
838  *
839  * // parse vCard from file
840  * char *resource_path = app_get_resource_path();
841  * char vcard_path[1024] = {0};
842  * snprintf(vcard_path, sizeof(vcard_path), "%s/vcard.vcf", resource_path);
843  * free(resource_path);
844  * contacts_vcard_parse_to_contact_foreach(vcard_path, __vcard_parse_cb, NULL);
845  * @endcode
846  *
847  * @subsection CAPI_SOCIAL_CONTACTS_SVC_MODULE_VCARD_MAKING_VCARD_STREAM Making vCard stream
848  * You can make vcard stream from contact, person or my profile record.
849  *
850  * Sample code: Makes vCard stream using contact record.
851  * @code
852  * contacts_record_h contact;
853  * char *vcard_stream = NULL;
854  *
855  * contacts_db_get_record(_contacts_contact._uri, contact_id, &contact);
856  * contacts_vcard_make_from_contact(contact, &vcard_stream);
857  *
858  * // use the vcard stream
859  * // ...
860  *
861  * free(vcard_stream);
862  * contacts_record_destroy(contact, true);
863  * @endcode
864  */
865
866  
867 #endif /* __TIZEN_SOCIAL_CONTACTS_DOC_H__ */
868