sync with 2.4
[platform/core/pim/contacts-service.git] / common / ctsvc_record.h
1 /*
2  * Contacts Service
3  *
4  * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Dohyung Jin <dh.jin@samsung.com>
7  *                 Jongwon Lee <gogosing.lee@samsung.com>
8  *                 Donghee Ye <donghee.ye@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24 #ifndef __TIZEN_SOCIAL_CTSVC_RECORD_H__
25 #define __TIZEN_SOCIAL_CTSVC_RECORD_H__
26
27 #define CTSVC_RECORD_INIT_BASE(base, type, cb, uri) do {\
28     (base)->r_type = (type);\
29     (base)->plugin_cbs = (cb);\
30     (base)->view_uri = (uri);\
31     (base)->property_max_count = 0;\
32 } while (0)
33
34 #define CTSVC_RECORD_COPY_BASE(dest, src) do {\
35     (dest)->r_type = (src)->r_type;\
36     (dest)->plugin_cbs = (src)->plugin_cbs;\
37     (dest)->view_uri = (src)->view_uri;\
38     (dest)->property_max_count = (src)->property_max_count;\
39     (dest)->property_flag = (src)->property_flag;\
40     if ((src)->properties_flags) \
41     {\
42         (dest)->properties_flags  = calloc((dest)->property_max_count, sizeof(char));\
43                 memcpy((dest)->properties_flags,(src)->properties_flags,sizeof(char)*(dest)->property_max_count);\
44     }\
45 } while (0)
46
47 #define CTSVC_RECORD_RESET_PROPERTY_FLAGS(base)do {\
48     if ((base)->properties_flags) \
49     {\
50         free((base)->properties_flags); \
51         (base)->property_max_count = 0;\
52         (base)->properties_flags = NULL;\
53         (base)->property_flag = 0;\
54     }\
55 } while (0)
56
57 int ctsvc_record_set_property_flag(ctsvc_record_s* _record, int property_id, contacts_property_flag_e flag);
58 int ctsvc_record_set_projection_flags( contacts_record_h record, const unsigned int *projection, const unsigned int projection_count, const unsigned int property_max_count);
59 int ctsvc_record_set_str( contacts_record_h record, unsigned int property_id, const char* value );
60 int ctsvc_record_set_bool( contacts_record_h record, unsigned int property_id, bool value );
61 int ctsvc_record_set_int( contacts_record_h record, unsigned int property_id, int value );
62 int ctsvc_record_set_lli( contacts_record_h record, unsigned int property_id, long long int value );
63 int ctsvc_record_set_double( contacts_record_h record, unsigned int property_id, double value );
64 bool ctsvc_record_check_property_flag(const ctsvc_record_s* s_record, unsigned int property_id, contacts_property_flag_e flag);
65
66 #endif /* __TIZEN_SOCIAL_CTSVC_RECORD_H__ */