summaryrefslogtreecommitdiff
path: root/include/contacts_group.h
blob: 02935170fb1721f2ea14077b7a52b599a52fb1f7 (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
/*
 * 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_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_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_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_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 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_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);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* __TIZEN_SOCIAL_CONTACTS_GROUP_H__ */