summaryrefslogtreecommitdiff
path: root/include/contacts_group.h
blob: 73090df9892c9ef7b53dd872e34c80dd7ecd7bcb (plain)
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
426
427
/*
 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. 
 */


#ifndef __TIZEN_SOCIAL_CONTACTS_GROUP_H__
#define __TIZEN_SOCIAL_CONTACTS_GROUP_H__

#include <contacts_types.h>

#ifdef __cplusplus
extern "C"
{
#endif

/**
 * @addtogroup CAPI_SOCIAL_CONTACTS_GROUP_MODULE
 * @{
 */

/**
 * @brief   Creates a handle to contacts group.
 *
 * @remarks		@a group must be released with contacts_group_destroy() by you.
 * @remarks    @a group is not added to contacts database until contacts_group_insert_to_db() is called.
 *
 * @param[out]  group      A new contacts group handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_OUT_OF_MEMORY       Out of memory
 *
 * @see contacts_group_destroy()
 */
int contacts_group_create(contacts_group_h *group);

/**
 * @brief       Destroys the handle to contacts group.
 *
 * @param[in]   group   The contacts group handle
 *
 * @return      0 on success, otherwise a negative error value.
 * @retval      #CONTACTS_ERROR_NONE                Successful
 * @retval      #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see contacts_group_create()
 *
 */
int contacts_group_destroy(contacts_group_h group);

/**
 * @brief       Inserts a new group to the contacts database.
 *
 * @param[in]   group       The contacts group handle
 * @param[in]   address_book_db_id      The address book database ID to which the contact insert. \n
 *                      0 means the default address book on the device
 * @param[out]  group_db_id	A group ID to be assigned to the group handle \n 
 * 						If inserting a new group succeeds, database ID will be assigned to a new group, otherwise @a group_db_id stays unchanged
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_DB_FAILED           Database operation failure
 *
 * @pre   This function requires an open connection to contacts service by contacts_connect().
 *
 * @see contacts_connect()
 * @see contacts_group_delete_from_db()
 * @see contacts_group_update_to_db()
 */
int contacts_group_insert_to_db(contacts_group_h group, int address_book_db_id, int *group_db_id);

/**
 * @brief       Deletes the group from the contacts database. 
 *
 * @param[in]   group_db_id		The group ID to delete 
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_DB_FAILED           Database operation failure
 *
 * @pre    This function requires an open connection to contacts service by contacts_connect().
 *
 * @see contacts_connect()
 * @see contacts_group_insert_to_db()
 * @see contacts_group_update_to_db()
 */
int contacts_group_delete_from_db(int group_db_id);

/**
 * @brief       Updates the group to the contacts database.
 *
 *
 * @param[in]   group       The group handle to update
 *
 * @return 0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_DB_FAILED           Database operation failure
 *
 * @pre    This function requires an open connection to contacts service by contacts_connect(). 
 *
 * @see contacts_connect()
 * @see contacts_group_insert_to_db()
 * @see contacts_group_delete_from_db()
 */
int contacts_group_update_to_db(contacts_group_h group);

/**
 * @brief   Gets the group from the contacts database. 
 *
 * @details This function creates the new group handle from the contacts database by the given @a group_db_id. \n
 * @a group will be created, which is filled with contact information.
 *
 * @remarks @a group must be released with contacts_group_destroy() by you. 
 *
 * @param[in]	group_db_id	The group ID
 * @param[out]	group	The contacts group handle associated with the group ID
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_DB_FAILED           Database operation failure
 *
 * @pre This function requires an open connection to contacts service by contacts_connect().
 *
 * @see contacts_connect()
 * @see contacts_group_destroy()
 * @see contacts_group_get_db_id()
 */
int contacts_group_get_from_db(int group_db_id, contacts_group_h *group);

/**
 * @brief   Gets the database ID for the given contacts group handle.
 *
 *
 * @param[in]	group	The contacts group handle
 * @param[out]	group_db_id	The group ID fetched from contacts database (default : 0) \n
 *  0 means the group is not in the contacts database. 
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * 
 * @see contacts_group_get_from_db()
 */
int contacts_group_get_db_id(contacts_group_h group, int *group_db_id);

/**
 * @brief       Gets the group name from the contacts group handle.
 *
 * @remarks @a name must be released with free() by you.
 *
 * @param[in]   group	The contacts group handle
 * @param[out]  name	The group name \n
 *					If @a name does not exist, it is NULL
 *
 * @return      0 on success, otherwise a negative error value.
 * @retval      #CONTACTS_ERROR_NONE                Successful
 * @retval      #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see contacts_group_set_name()
 *
 */
int contacts_group_get_name(contacts_group_h group, char **name);

/**
 * @brief   Sets a group name to the contacts group handle.
 *
 *
 * @param[in]   group	The contacts group handle
 * @param[in]   name	A group name
 *
 * @return      0 on success, otherwise a negative error value.
 * @retval      #CONTACTS_ERROR_NONE                    Successful
 * @retval      #CONTACTS_ERROR_INVALID_PARAMETER       Invalid parameter
 * @see contacts_group_get_name()
 *
 */
int contacts_group_set_name(contacts_group_h group, const char *name);

/**
 * @brief       Gets the ringtone path from the contacts group handle.
 *
 * @remarks @a ringtonepath must be released with free() by you. 
 *
 * @param[in]   group           The contacts group handle
 * @param[out]  ringtonepath    The ringtone path \n 
 * 						If @a ringtonepath does not exist, it is NULL
 *
 * @return      0 on success, otherwise a negative error value.
 * @retval      #CONTACTS_ERROR_NONE                Successful
 * @retval      #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see contacts_group_set_ringtonepath()
 */
int contacts_group_get_ringtonepath(contacts_group_h group, char **ringtonepath);

/**
 * @brief       Sets a ringtone path to the contacts group handle.
 *
 * @param[in]   group           The contacts group handle
 * @param[in]   ringtonepath    The ringtone path
 *
 * @return      0 on success, otherwise a negative error value.
 * @retval      #CONTACTS_ERROR_NONE                Successful
 * @retval      #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @see  contacts_group_get_ringtonepath()
 */
int contacts_group_set_ringtonepath(contacts_group_h group, const char *ringtonepath);

/**
 * @brief       Gets the number of group belonging to the address book.
 *
 * @param[in]    address_book_db_id		 The address book database ID to filter \n
 *                       #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
 *                       #ADDRESS_BOOK_FILTER_ALL means all address books on the device
 * @param[out]  count  The number of contact belonging to the contacts group handle
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @pre    This function requires an open connection to contacts service by contacts_connect().
 *
 * @see contacts_connect()
 */
int contacts_group_get_count(int address_book_db_id, int *count);

/**
 * @brief       Gets the number of contact belonging to the contacts group handle.
 *
 * @param[in]   group   The contacts group handle
 * @param[out]  count  The number of contact belonging to the contacts group handle
 *
 * @return      0 on success, otherwise a negative error value.
 * @retval      #CONTACTS_ERROR_NONE                Successful
 * @retval      #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @pre This function requires an open connection to contacts service by contacts_connect().
 *
 * @see contact_get_total_count_from_db()
 */
int contacts_group_get_member_count_from_db(contacts_group_h group, int *count);

/**
 * @brief       Retrieves all groups by invoking the given callback function iteratively.
 *
 *
 * @param[in]	callback	The callback function to be called
 * @param[in]	user_data	The user data to be passed to the callback function
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_DB_FAILED           Database operation failure
 *
 * @pre      This function requires an open connection to Contacts Service by contacts_connect().
 * @post	 This function invokes contacts_foreach_query_group_cb().
 *
 * @see contacts_connect()
 * @see contacts_foreach_query_group_cb()
 */
int contacts_group_foreach_group_from_db(contacts_foreach_query_group_cb callback, void *user_data);

/**
 * @brief   Gets the address book database ID for the given contacts group handle.
 *
 * @param[in]	group	The contacts group handle
 * @param[out]	address_book_db_id	The address book database ID fetched from contacts database (default : 0) \n
 *  0 means the group is not in the contacts database. 
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * 
 * @see contacts_group_set_address_book_db_id()
 * @see contacts_address_book_get_from_db()
 */
int contacts_group_get_address_book_db_id(contacts_group_h group, int *address_book_db_id);

/**
 * @brief     Retrieves all groups with the given address book database ID
 *
 * @param[in]   callback            The callback function to invoke
 * @param[in]   address_book_db_id  The address book database ID to filter
 * @param[in]   user_data           The user data to be passed to the callback function
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_DB_FAILED           Database operation failure
 *
 * @pre      This function requires an open connection to Contacts Service by contacts_connect()
 * @post 	This function invokes contacts_foreach_query_group_cb().
 *
 * @see contacts_connect()
 * @see contacts_foreach_query_group_cb()
 */
int contacts_group_query_group_by_address_book(contacts_foreach_query_group_cb callback, int address_book_db_id, void *user_data);

/**
 * @brief        Frees contacts group array
 *
 * @param[out]   group_array		The contact group array
 * @param[out]   length						The length of the array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see contacts_group_search_group_by_address_book()
 */
int contacts_group_free_query_group_array(pcontacts_query_group_s *group_array);

/**
 * @brief        Frees contacts group search array
 *
 * @param[out]   group_version_array		The contact group array
 * @param[out]   length								The length of the array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 *
 * @see contacts_group_search_group_by_version()
 */
int contacts_group_free_query_version_array(pcontacts_group_query_version_s *group_version_array);

/**
 * @brief       Retrieves all contacts from all of address books with array
 *
 * @remarks     @a group_array must be released with contacts_group_free_query_group_array() by you. 
 *
 * @param[in]   address_book_db_id		 The address book database ID to filter \n
 *                       #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
 *                       #ADDRESS_BOOK_FILTER_ALL means all address books on the device
 * @param[out]   group_array		The contacts group array
 * @param[out]   length						The length of the  array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_DB_FAILED           Database operation failure
 *
 * @pre    This function requires an open connection to contacts service by contacts_connect().
 *
 * @see contacts_connect()
 * @see contacts_group_free_query_group_array()
 */
int contacts_group_search_group_by_address_book(int address_book_db_id, pcontacts_query_group_s **group_array, int *length);

/**
 * @brief       Retrieves all groups as array with the contacts database version.
 *
 * @details  This function will find all changed groups since the given @a contacts_db_version
 * @remarks     @a group_array must be released with contacts_group_free_query_version_array() by you. 
 *
 * @param[in]   address_book_db_id		 The address book database ID to filter \n
 *                       #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
 *                       #ADDRESS_BOOK_FILTER_ALL means all address books on the device
 * @param[in]   contacts_db_version The contacts database version to filter
 * @param[out]   group_array		The contacts group array
 * @param[out]   length						The length of the  array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_DB_FAILED           Database operation failure
 *
 * @pre    This function requires an open connection to contacts service by contacts_connect().
 *
 * @see contacts_connect()
 * @see contacts_group_free_query_version_array()
 */
int contacts_group_search_group_by_version(int address_book_db_id, int contacts_db_version, pcontacts_group_query_version_s **group_array, int *length);

/**
 * @brief       Retrieves all groups as array which has changed relation with contacts
 *
 * @remarks     @a group_array must be released with contacts_group_free_query_version_array() by you. 
 *
 * @param[in]   address_book_db_id		 The address book database ID to filter \n
 *                       #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
 *                       #ADDRESS_BOOK_FILTER_ALL means all address books on the device
 * @param[in]   contacts_db_version The contacts database version to filter
 * @param[out]   group_array		The contacts group array
 * @param[out]   length						The length of the  array
 *
 * @return  0 on success, otherwise a negative error value.
 * @retval  #CONTACTS_ERROR_NONE                Successful
 * @retval  #CONTACTS_ERROR_OUT_OF_MEMORY       Out of memory
 * @retval  #CONTACTS_ERROR_INVALID_PARAMETER   Invalid parameter
 * @retval  #CONTACTS_ERROR_DB_FAILED           Database operation failure
 *
 * @pre    This function requires an open connection to contacts service by contacts_connect().
 *
 * @see contacts_connect()
 * @see contacts_group_free_query_version_array()
 */
int contacts_group_search_relation_changed_group_by_version(int address_book_db_id, int contacts_db_version, pcontacts_group_query_version_s **group_array, int *length);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* __TIZEN_SOCIAL_CONTACTS_GROUP_H__ */