4 * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include "ctsvc_internal.h"
22 #include "ctsvc_record.h"
23 #include "ctsvc_struct.h"
24 #include "ctsvc_view.h"
26 extern ctsvc_record_plugin_cb_s addressbook_plugin_cbs;
27 extern ctsvc_record_plugin_cb_s group_plugin_cbs;
28 extern ctsvc_record_plugin_cb_s person_plugin_cbs;
29 extern ctsvc_record_plugin_cb_s contact_plugin_cbs;
30 extern ctsvc_record_plugin_cb_s my_profile_plugin_cbs;
31 extern ctsvc_record_plugin_cb_s simple_contact_plugin_cbs;
32 extern ctsvc_record_plugin_cb_s updated_info_plugin_cbs;
34 extern ctsvc_record_plugin_cb_s name_plugin_cbs;
35 extern ctsvc_record_plugin_cb_s number_plugin_cbs;
36 extern ctsvc_record_plugin_cb_s address_plugin_cbs;
37 extern ctsvc_record_plugin_cb_s url_plugin_cbs;
38 extern ctsvc_record_plugin_cb_s event_plugin_cbs;
39 extern ctsvc_record_plugin_cb_s messenger_plugin_cbs;
40 extern ctsvc_record_plugin_cb_s activity_plugin_cbs;
41 extern ctsvc_record_plugin_cb_s activity_photo_plugin_cbs;
42 extern ctsvc_record_plugin_cb_s relationship_plugin_cbs;
43 extern ctsvc_record_plugin_cb_s image_plugin_cbs;
44 extern ctsvc_record_plugin_cb_s group_relation_plugin_cbs;
45 extern ctsvc_record_plugin_cb_s note_plugin_cbs;
46 extern ctsvc_record_plugin_cb_s company_plugin_cbs;
47 extern ctsvc_record_plugin_cb_s profile_plugin_cbs;
48 extern ctsvc_record_plugin_cb_s nickname_plugin_cbs;
49 extern ctsvc_record_plugin_cb_s email_plugin_cbs;
50 extern ctsvc_record_plugin_cb_s result_plugin_cbs;
51 extern ctsvc_record_plugin_cb_s sdn_plugin_cbs;
52 extern ctsvc_record_plugin_cb_s speeddial_plugin_cbs;
53 extern ctsvc_record_plugin_cb_s extension_plugin_cbs;
54 #ifdef ENABLE_LOG_FEATURE
55 extern ctsvc_record_plugin_cb_s phonelog_plugin_cbs;
56 #endif /* ENABLE_LOG_FEATURE */
57 extern ctsvc_record_plugin_cb_s sip_plugin_cbs;
59 static const ctsvc_record_plugin_cb_s *__ctsvc_record_get_plugin_cb(int r_type)
61 switch ((int)r_type) {
62 case CTSVC_RECORD_ADDRESSBOOK:
63 return &addressbook_plugin_cbs;
64 case CTSVC_RECORD_GROUP:
65 return &group_plugin_cbs;
66 case CTSVC_RECORD_PERSON:
67 return &person_plugin_cbs;
68 case CTSVC_RECORD_CONTACT:
69 return &contact_plugin_cbs;
70 case CTSVC_RECORD_MY_PROFILE:
71 return &my_profile_plugin_cbs;
72 case CTSVC_RECORD_SIMPLE_CONTACT:
73 return &simple_contact_plugin_cbs;
74 case CTSVC_RECORD_NAME:
75 return &name_plugin_cbs;
76 case CTSVC_RECORD_COMPANY:
77 return &company_plugin_cbs;
78 case CTSVC_RECORD_NOTE:
79 return ¬e_plugin_cbs;
80 case CTSVC_RECORD_NUMBER:
81 return &number_plugin_cbs;
82 case CTSVC_RECORD_EMAIL:
83 return &email_plugin_cbs;
84 case CTSVC_RECORD_URL:
85 return &url_plugin_cbs;
86 case CTSVC_RECORD_EVENT:
87 return &event_plugin_cbs;
88 case CTSVC_RECORD_NICKNAME:
89 return &nickname_plugin_cbs;
90 case CTSVC_RECORD_ADDRESS:
91 return &address_plugin_cbs;
92 case CTSVC_RECORD_MESSENGER:
93 return &messenger_plugin_cbs;
94 case CTSVC_RECORD_GROUP_RELATION:
95 return &group_relation_plugin_cbs;
96 case CTSVC_RECORD_ACTIVITY:
97 return &activity_plugin_cbs;
98 case CTSVC_RECORD_ACTIVITY_PHOTO:
99 return &activity_photo_plugin_cbs;
100 case CTSVC_RECORD_PROFILE:
101 return &profile_plugin_cbs;
102 case CTSVC_RECORD_RELATIONSHIP:
103 return &relationship_plugin_cbs;
104 case CTSVC_RECORD_IMAGE:
105 return &image_plugin_cbs;
106 case CTSVC_RECORD_EXTENSION:
107 return &extension_plugin_cbs;
108 #ifdef ENABLE_LOG_FEATURE
109 case CTSVC_RECORD_PHONELOG:
110 return &phonelog_plugin_cbs;
111 #endif /* ENABLE_LOG_FEATURE */
112 case CTSVC_RECORD_SPEEDDIAL:
113 return &speeddial_plugin_cbs;
114 case CTSVC_RECORD_SDN:
115 return &sdn_plugin_cbs;
116 case CTSVC_RECORD_UPDATED_INFO:
117 return &updated_info_plugin_cbs;
118 case CTSVC_RECORD_RESULT:
119 return &result_plugin_cbs;
120 case CTSVC_RECORD_SIP:
121 return &sip_plugin_cbs;
127 #define __INVALID_PARAMETER_ERROR_HANDLING() \
128 ERR("Invalid parameter: Operation restricted."); \
129 return CONTACTS_ERROR_INVALID_PARAMETER;
132 * This function is used for view_uri which is able to CRUD.
133 * The view_uri's property should be sequencial value because it is used to find index at the below logic.
135 bool ctsvc_record_check_property_flag(const ctsvc_record_s *s_record, unsigned int property_id, contacts_property_flag_e flag)
137 int index = property_id & 0x000000FF;
139 if (CTSVC_RECORD_RESULT == s_record->r_type)
143 * Check it when getting value of property
144 * property_flag and properties_flags is set when getting record with query
146 if (CTSVC_PROPERTY_FLAG_PROJECTION == flag) {
147 /* all property get. */
148 if (NULL == s_record->properties_flags)
151 * Or before inserting record from DB, just get after setting.
152 * properties_flags is not NULL when just setting dirty
154 if (0 == (CTSVC_PROPERTY_FLAG_PROJECTION & s_record->property_flag))
158 /* Check it when updating record */
159 if (CTSVC_PROPERTY_FLAG_DIRTY == flag) {
160 /* all property is clean */
161 if (NULL == s_record->properties_flags)
164 return (s_record->properties_flags[index] & flag) ? true : false;
167 int ctsvc_record_set_property_flag(ctsvc_record_s *_record, int property_id, contacts_property_flag_e flag)
169 int index = property_id & 0x000000FF;
171 if (CTSVC_RECORD_RESULT == _record->r_type)
172 return CONTACTS_ERROR_NONE;
174 if (NULL == _record->properties_flags) {
175 unsigned int count = 0;
176 ctsvc_view_get_all_property_infos(_record->view_uri, &count);
177 RETVM_IF(count <= 0, CONTACTS_ERROR_INVALID_PARAMETER, "ctsvc_view_get_all_property_infos() Fail");
179 _record->properties_flags = calloc(count, sizeof(char));
180 _record->property_max_count = count;
181 RETVM_IF(NULL == _record->properties_flags, CONTACTS_ERROR_OUT_OF_MEMORY, "calloc() Fail");
183 _record->property_flag |= flag;
184 _record->properties_flags[index] |= flag;
186 return CONTACTS_ERROR_NONE;
189 #define __CHECK_READ_ONLY_PROPERTY() \
190 if (CTSVC_READ_ONLY_CHECK(property_id, CTSVC_READ_ONLY_PROPERTY)) { \
191 ERR("Don't try to change read-only property.(0x%0x)", property_id); \
192 return CONTACTS_ERROR_INVALID_PARAMETER; \
195 #define __CHECK_PROJECTED_PROPERTY() \
196 if (false == ctsvc_record_check_property_flag(s_record, property_id, CTSVC_PROPERTY_FLAG_PROJECTION)) { \
197 ERR("Don't try to get un-projected property(0x%0x).", property_id); \
198 return CONTACTS_ERROR_INVALID_PARAMETER; \
201 /* Record constuct/destruct */
202 EXPORT_API int contacts_record_create(const char *view_uri, contacts_record_h *out_record)
205 ctsvc_record_type_e r_type;
206 const ctsvc_record_plugin_cb_s *plugin_cb;
208 RETV_IF(NULL == view_uri, CONTACTS_ERROR_INVALID_PARAMETER);
209 RETV_IF(NULL == out_record, CONTACTS_ERROR_INVALID_PARAMETER);
212 r_type = ctsvc_view_get_record_type(view_uri);
213 RETVM_IF(CTSVC_RECORD_INVALID == r_type, CONTACTS_ERROR_INVALID_PARAMETER,
214 "view_uri(%s)", view_uri);
216 plugin_cb = __ctsvc_record_get_plugin_cb(r_type);
217 if (plugin_cb && plugin_cb->create) {
218 ret = plugin_cb->create(out_record);
219 if (CONTACTS_ERROR_NONE == ret)
220 CTSVC_RECORD_INIT_BASE((ctsvc_record_s*)*out_record, r_type, plugin_cb, ctsvc_view_get_uri(view_uri));
225 __INVALID_PARAMETER_ERROR_HANDLING();
228 EXPORT_API int contacts_record_destroy(contacts_record_h record, bool delete_child)
230 ctsvc_record_s *s_record;
232 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
233 s_record = (ctsvc_record_s*)record;
235 if (s_record && s_record->plugin_cbs && s_record->plugin_cbs->destroy)
236 return s_record->plugin_cbs->destroy(record, delete_child);
238 __INVALID_PARAMETER_ERROR_HANDLING();
241 EXPORT_API int contacts_record_clone(contacts_record_h record, contacts_record_h *out_record)
243 ctsvc_record_s *s_record;
245 RETV_IF(NULL == out_record, CONTACTS_ERROR_INVALID_PARAMETER);
248 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
249 s_record = (ctsvc_record_s*)record;
251 if (s_record->plugin_cbs && s_record->plugin_cbs->clone)
252 return s_record->plugin_cbs->clone(record, out_record);
254 __INVALID_PARAMETER_ERROR_HANDLING();
257 EXPORT_API int contacts_record_get_uri_p(contacts_record_h record, const char **out_str)
259 int ret = CONTACTS_ERROR_NONE;
261 ctsvc_record_s *temp = (ctsvc_record_s*)(record);
263 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
264 RETV_IF(NULL == out_str, CONTACTS_ERROR_INVALID_PARAMETER);
266 *out_str = (temp->view_uri);
271 /* Record get/set int,str, etc.. */
272 EXPORT_API int contacts_record_get_str(contacts_record_h record, unsigned int property_id, char **out_str)
274 ctsvc_record_s *s_record;
276 RETV_IF(NULL == out_str, CONTACTS_ERROR_INVALID_PARAMETER);
279 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
280 s_record = (ctsvc_record_s*)record;
282 __CHECK_PROJECTED_PROPERTY();
284 if (s_record->plugin_cbs && s_record->plugin_cbs->get_str)
285 return s_record->plugin_cbs->get_str(record, property_id, out_str);
287 __INVALID_PARAMETER_ERROR_HANDLING();
290 EXPORT_API int contacts_record_get_lli(contacts_record_h record, unsigned int property_id, long long int *value)
292 ctsvc_record_s *s_record;
294 RETV_IF(NULL == value, CONTACTS_ERROR_INVALID_PARAMETER);
297 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
298 s_record = (ctsvc_record_s*)record;
300 __CHECK_PROJECTED_PROPERTY();
302 if (s_record->plugin_cbs && s_record->plugin_cbs->get_lli)
303 return s_record->plugin_cbs->get_lli(record, property_id, value);
305 __INVALID_PARAMETER_ERROR_HANDLING();
308 EXPORT_API int contacts_record_get_double(contacts_record_h record, unsigned int property_id, double *value)
310 ctsvc_record_s *s_record;
312 RETV_IF(NULL == value, CONTACTS_ERROR_INVALID_PARAMETER);
315 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
316 s_record = (ctsvc_record_s*)record;
318 __CHECK_PROJECTED_PROPERTY();
320 if (s_record->plugin_cbs && s_record->plugin_cbs->get_double)
321 return s_record->plugin_cbs->get_double(record, property_id, value);
323 __INVALID_PARAMETER_ERROR_HANDLING();
326 EXPORT_API int contacts_record_get_str_p(contacts_record_h record, unsigned int property_id, char **out_str)
328 ctsvc_record_s *s_record;
330 RETV_IF(NULL == out_str, CONTACTS_ERROR_INVALID_PARAMETER);
333 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
334 s_record = (ctsvc_record_s*)record;
336 __CHECK_PROJECTED_PROPERTY();
338 if (s_record->plugin_cbs && s_record->plugin_cbs->get_str_p)
339 return s_record->plugin_cbs->get_str_p(record, property_id, out_str);
341 __INVALID_PARAMETER_ERROR_HANDLING();
344 EXPORT_API int contacts_record_get_int(contacts_record_h record, unsigned int property_id, int *out_value)
346 ctsvc_record_s *s_record;
348 RETV_IF(NULL == out_value, CONTACTS_ERROR_INVALID_PARAMETER);
351 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
352 s_record = (ctsvc_record_s*)record;
354 __CHECK_PROJECTED_PROPERTY();
356 if (s_record->plugin_cbs && s_record->plugin_cbs->get_int)
357 return s_record->plugin_cbs->get_int(record, property_id, out_value);
359 __INVALID_PARAMETER_ERROR_HANDLING();
362 EXPORT_API int contacts_record_set_str(contacts_record_h record, unsigned int property_id, const char *value)
364 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
366 __CHECK_READ_ONLY_PROPERTY();
368 return ctsvc_record_set_str(record, property_id, value);
371 int ctsvc_record_set_str(contacts_record_h record, unsigned int property_id, const char *value)
374 ctsvc_record_s *s_record;
377 s_record = (ctsvc_record_s*)record;
378 __CHECK_PROJECTED_PROPERTY();
385 if (s_record->plugin_cbs && s_record->plugin_cbs->set_str) {
386 bool is_dirty = false;
387 ret = s_record->plugin_cbs->set_str(record, property_id, str, &is_dirty);
388 if (CONTACTS_ERROR_NONE == ret && is_dirty)
389 ctsvc_record_set_property_flag(s_record, property_id, CTSVC_PROPERTY_FLAG_DIRTY);
394 __INVALID_PARAMETER_ERROR_HANDLING();
397 EXPORT_API int contacts_record_get_bool(contacts_record_h record,
398 unsigned int property_id, bool *value)
400 ctsvc_record_s *s_record;
402 RETV_IF(NULL == value, CONTACTS_ERROR_INVALID_PARAMETER);
405 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
406 s_record = (ctsvc_record_s*)record;
408 __CHECK_PROJECTED_PROPERTY();
410 if (s_record->plugin_cbs && s_record->plugin_cbs->get_bool)
411 return s_record->plugin_cbs->get_bool(record, property_id, value);
413 __INVALID_PARAMETER_ERROR_HANDLING();
416 EXPORT_API int contacts_record_set_bool(contacts_record_h record,
417 unsigned int property_id, bool value)
419 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
421 __CHECK_READ_ONLY_PROPERTY();
423 return ctsvc_record_set_bool(record, property_id, value);
426 int ctsvc_record_set_bool(contacts_record_h record, unsigned int property_id, bool value)
429 ctsvc_record_s *s_record;
430 s_record = (ctsvc_record_s*)record;
431 __CHECK_PROJECTED_PROPERTY();
433 if (s_record->plugin_cbs && s_record->plugin_cbs->set_bool) {
434 bool is_dirty = false;
435 ret = s_record->plugin_cbs->set_bool(record, property_id, value, &is_dirty);
436 if (CONTACTS_ERROR_NONE == ret && is_dirty)
437 ctsvc_record_set_property_flag(s_record, property_id, CTSVC_PROPERTY_FLAG_DIRTY);
441 __INVALID_PARAMETER_ERROR_HANDLING();
444 EXPORT_API int contacts_record_set_int(contacts_record_h record, unsigned int property_id,
447 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
449 __CHECK_READ_ONLY_PROPERTY();
451 #ifdef _CONTACTS_IPC_CLIENT
452 if (CTSVC_RECORD_RESULT == ((ctsvc_record_s*)record)->r_type) {
453 ERR("Can not set int to result record");
454 return CONTACTS_ERROR_INVALID_PARAMETER;
457 return ctsvc_record_set_int(record, property_id, value);
460 int ctsvc_record_set_int(contacts_record_h record, unsigned int property_id, int value)
463 ctsvc_record_s *s_record;
464 s_record = (ctsvc_record_s*)record;
465 __CHECK_PROJECTED_PROPERTY();
467 if (s_record->plugin_cbs && s_record->plugin_cbs->set_int) {
468 bool is_dirty = false;
469 ret = s_record->plugin_cbs->set_int(record, property_id, value, &is_dirty);
470 if (CONTACTS_ERROR_NONE == ret && is_dirty)
471 ctsvc_record_set_property_flag(s_record, property_id, CTSVC_PROPERTY_FLAG_DIRTY);
474 __INVALID_PARAMETER_ERROR_HANDLING();
477 EXPORT_API int contacts_record_set_lli(contacts_record_h record, unsigned int property_id,
480 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
482 __CHECK_READ_ONLY_PROPERTY();
484 return ctsvc_record_set_lli(record, property_id, value);
487 int ctsvc_record_set_lli(contacts_record_h record, unsigned int property_id,
491 ctsvc_record_s *s_record;
492 s_record = (ctsvc_record_s*)record;
493 __CHECK_PROJECTED_PROPERTY();
495 if (s_record->plugin_cbs && s_record->plugin_cbs->set_lli) {
496 bool is_dirty = false;
497 ret = s_record->plugin_cbs->set_lli(record, property_id, value, &is_dirty);
498 if (CONTACTS_ERROR_NONE == ret && is_dirty)
499 ctsvc_record_set_property_flag(s_record, property_id, CTSVC_PROPERTY_FLAG_DIRTY);
503 __INVALID_PARAMETER_ERROR_HANDLING();
506 EXPORT_API int contacts_record_set_double(contacts_record_h record, unsigned int property_id,
509 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
511 __CHECK_READ_ONLY_PROPERTY();
513 return ctsvc_record_set_double(record, property_id, value);
516 int ctsvc_record_set_double(contacts_record_h record, unsigned int property_id,
520 ctsvc_record_s *s_record;
522 s_record = (ctsvc_record_s*)record;
523 __CHECK_PROJECTED_PROPERTY();
525 if (s_record->plugin_cbs && s_record->plugin_cbs->set_double) {
526 bool is_dirty = false;
527 ret = s_record->plugin_cbs->set_double(record, property_id, value, &is_dirty);
528 if (CONTACTS_ERROR_NONE == ret && is_dirty)
529 ctsvc_record_set_property_flag(s_record, property_id, CTSVC_PROPERTY_FLAG_DIRTY);
533 __INVALID_PARAMETER_ERROR_HANDLING();
536 /* Record get/set child records */
537 EXPORT_API int contacts_record_add_child_record(contacts_record_h record,
538 unsigned int property_id, contacts_record_h child_record)
540 ctsvc_record_s *s_record;
542 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
543 RETV_IF(NULL == child_record, CONTACTS_ERROR_INVALID_PARAMETER);
544 s_record = (ctsvc_record_s*)record;
546 if (s_record->plugin_cbs && s_record->plugin_cbs->add_child_record)
547 return s_record->plugin_cbs->add_child_record(record, property_id, child_record);
549 __INVALID_PARAMETER_ERROR_HANDLING();
552 EXPORT_API int contacts_record_remove_child_record(contacts_record_h record,
553 unsigned int property_id, contacts_record_h child_record)
555 ctsvc_record_s *s_record;
557 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
558 RETV_IF(NULL == child_record, CONTACTS_ERROR_INVALID_PARAMETER);
559 s_record = (ctsvc_record_s*)record;
561 if (s_record->plugin_cbs && s_record->plugin_cbs->remove_child_record)
562 return s_record->plugin_cbs->remove_child_record(record, property_id, child_record);
564 __INVALID_PARAMETER_ERROR_HANDLING();
567 EXPORT_API int contacts_record_get_child_record_count(contacts_record_h record,
568 unsigned int property_id, int *count)
570 ctsvc_record_s *s_record;
572 RETV_IF(NULL == count, CONTACTS_ERROR_INVALID_PARAMETER);
575 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
576 s_record = (ctsvc_record_s*)record;
578 if (s_record->plugin_cbs && s_record->plugin_cbs->get_child_record_count)
579 return s_record->plugin_cbs->get_child_record_count(record, property_id, count);
581 __INVALID_PARAMETER_ERROR_HANDLING();
584 EXPORT_API int contacts_record_get_child_record_at_p(contacts_record_h record,
585 unsigned int property_id, int index, contacts_record_h *out_record)
587 ctsvc_record_s *s_record;
589 RETV_IF(NULL == out_record, CONTACTS_ERROR_INVALID_PARAMETER);
592 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
593 s_record = (ctsvc_record_s*)record;
595 if (s_record->plugin_cbs && s_record->plugin_cbs->get_child_record_at_p)
596 return s_record->plugin_cbs->get_child_record_at_p(record, property_id, index, out_record);
598 __INVALID_PARAMETER_ERROR_HANDLING();
601 EXPORT_API int contacts_record_clone_child_record_list(contacts_record_h record,
602 unsigned int property_id, contacts_list_h *out_list)
604 ctsvc_record_s *s_record;
606 RETV_IF(NULL == out_list, CONTACTS_ERROR_INVALID_PARAMETER);
609 RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
610 s_record = (ctsvc_record_s*)record;
612 if (s_record->plugin_cbs && s_record->plugin_cbs->clone_child_record_list)
613 return s_record->plugin_cbs->clone_child_record_list(record, property_id, out_list);
615 __INVALID_PARAMETER_ERROR_HANDLING();
618 int ctsvc_record_set_projection_flags(contacts_record_h record,
619 const unsigned int *projection,
620 const unsigned int projection_count,
621 const unsigned int property_max_count)
625 RETV_IF(record == NULL, CONTACTS_ERROR_INVALID_PARAMETER);
627 ctsvc_record_s *_record = (ctsvc_record_s*)record;
629 free(_record->properties_flags);
630 _record->properties_flags = NULL;
632 _record->properties_flags = calloc(property_max_count, sizeof(char));
633 if (NULL == _record->properties_flags) {
634 /* LCOV_EXCL_START */
636 return CONTACTS_ERROR_OUT_OF_MEMORY;
640 _record->property_max_count = property_max_count;
642 if (CTSVC_RECORD_RESULT == _record->r_type) {
643 _record->property_flag |= CTSVC_PROPERTY_FLAG_PROJECTION;
645 for (i = 0; i < projection_count; i++)
646 ctsvc_record_set_property_flag(_record, projection[i], CTSVC_PROPERTY_FLAG_PROJECTION);
649 return CONTACTS_ERROR_NONE;