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.
19 #include <sys/types.h>
24 #include "ctsvc_internal.h"
25 #include "ctsvc_db_sqlite.h"
26 #include "ctsvc_db_schema.h"
27 #include "ctsvc_db_init.h"
28 #include "ctsvc_db_query.h"
29 #include "ctsvc_db_utils.h"
30 #include "ctsvc_record.h"
31 #include "ctsvc_normalize.h"
32 #include "ctsvc_list.h"
33 #include "ctsvc_server_setting.h"
34 #include "ctsvc_localize_ch.h"
35 #include "ctsvc_server_group.h"
36 #include "ctsvc_notification.h"
37 #include "ctsvc_localize_utils.h"
38 #include "ctsvc_db_access_control.h"
39 #include "ctsvc_notify.h"
41 #include "ctsvc_db_plugin_contact_helper.h"
43 #define CTSVC_MY_PROFILE_DISPLAY_NAME_MAX_LEN 1024
46 static int __ctsvc_db_get_my_profile_base_info(int id, ctsvc_my_profile_s *my_profile)
51 char query[CTS_SQL_MAX_LEN] = {0};
53 char full_path[CTSVC_IMG_FULL_PATH_SIZE_MAX] = {0};
55 snprintf(query, sizeof(query),
56 "SELECT my_profile_id, addressbook_id, changed_time, %s, image_thumbnail_path, uid "
57 "FROM "CTS_TABLE_MY_PROFILES" WHERE my_profile_id = %d AND deleted = 0",
58 ctsvc_get_display_column(), id);
60 ret = ctsvc_query_prepare(query, &stmt);
61 RETVM_IF(NULL == stmt, ret, "ctsvc_query_prepare() Fail(%d)", ret);
63 ret = ctsvc_stmt_step(stmt);
64 if (1 /*CTS_TRUE*/ != ret) {
66 ERR("ctsvc_stmt_step() Fail(%d)", ret);
67 ctsvc_stmt_finalize(stmt);
68 if (CONTACTS_ERROR_NONE == ret)
69 return CONTACTS_ERROR_NO_DATA;
76 my_profile->id = ctsvc_stmt_get_int(stmt, i++);
77 my_profile->addressbook_id = ctsvc_stmt_get_int(stmt, i++);
78 my_profile->changed_time = ctsvc_stmt_get_int(stmt, i++);
79 temp = ctsvc_stmt_get_text(stmt, i++);
80 my_profile->display_name = SAFE_STRDUP(temp);
81 temp = ctsvc_stmt_get_text(stmt, i++);
83 snprintf(full_path, sizeof(full_path), "%s/%s", CTSVC_CONTACT_IMG_FULL_LOCATION, temp);
84 my_profile->image_thumbnail_path = strdup(full_path);
86 temp = ctsvc_stmt_get_text(stmt, i++);
87 my_profile->uid = SAFE_STRDUP(temp);
88 ctsvc_stmt_finalize(stmt);
90 return CONTACTS_ERROR_NONE;
93 static int __ctsvc_db_my_profile_get_data(int id, ctsvc_my_profile_s *my_profile)
98 char query[CTS_SQL_MAX_LEN] = {0};
100 snprintf(query, sizeof(query),
101 "SELECT datatype, id, contact_id, is_default, data1, data2, "
102 "data3, data4, data5, data6, data7, data8, data9, data10, data11, data12 "
103 "FROM "CTS_TABLE_DATA" WHERE contact_id = %d AND is_my_profile = 1", id);
105 ret = ctsvc_query_prepare(query, &stmt);
106 RETVM_IF(NULL == stmt, ret, "ctsvc_query_prepare() Fail(%d)", ret);
108 ret = ctsvc_stmt_step(stmt);
109 if (1 /*CTS_TRUE */!= ret) {
110 /* LCOV_EXCL_START */
111 ERR("ctsvc_stmt_step() Fail(%d)", ret);
112 ctsvc_stmt_finalize(stmt);
118 datatype = ctsvc_stmt_get_int(stmt, 0);
120 case CONTACTS_DATA_TYPE_NAME:
121 ctsvc_get_data_info_name(stmt, (contacts_list_h)my_profile->name);
123 case CONTACTS_DATA_TYPE_EVENT:
124 ctsvc_get_data_info_event(stmt, (contacts_list_h)my_profile->events);
126 case CONTACTS_DATA_TYPE_MESSENGER:
127 ctsvc_get_data_info_messenger(stmt, (contacts_list_h)my_profile->messengers);
129 case CONTACTS_DATA_TYPE_POSTAL:
130 ctsvc_get_data_info_address(stmt, (contacts_list_h)my_profile->postal_addrs);
132 case CONTACTS_DATA_TYPE_URL:
133 ctsvc_get_data_info_url(stmt, (contacts_list_h)my_profile->urls);
135 case CONTACTS_DATA_TYPE_NICKNAME:
136 ctsvc_get_data_info_nickname(stmt, (contacts_list_h)my_profile->nicknames);
138 case CONTACTS_DATA_TYPE_NUMBER:
139 ctsvc_get_data_info_number(stmt, (contacts_list_h)my_profile->numbers);
141 case CONTACTS_DATA_TYPE_EMAIL:
142 ctsvc_get_data_info_email(stmt, (contacts_list_h)my_profile->emails);
144 case CONTACTS_DATA_TYPE_PROFILE:
145 ctsvc_get_data_info_profile(stmt, (contacts_list_h)my_profile->profiles);
147 case CONTACTS_DATA_TYPE_RELATIONSHIP:
148 ctsvc_get_data_info_relationship(stmt, (contacts_list_h)my_profile->relationships);
150 case CONTACTS_DATA_TYPE_IMAGE:
151 ctsvc_get_data_info_image(stmt, (contacts_list_h)my_profile->images);
153 case CONTACTS_DATA_TYPE_COMPANY:
154 ctsvc_get_data_info_company(stmt, (contacts_list_h)my_profile->company);
156 case CONTACTS_DATA_TYPE_NOTE:
157 ctsvc_get_data_info_note(stmt, (contacts_list_h)my_profile->note);
159 case CONTACTS_DATA_TYPE_EXTENSION:
160 ctsvc_get_data_info_extension(stmt, (contacts_list_h)my_profile->extensions);
162 case CONTACTS_DATA_TYPE_SIP:
163 ctsvc_get_data_info_sip(stmt, (contacts_list_h)my_profile->sips);
166 /* LCOV_EXCL_START */
167 ERR("Intenal : Not supported data type (%d)", datatype);
172 } while (1 /*CTS_TRUE*/ == ctsvc_stmt_step(stmt));
174 ctsvc_stmt_finalize(stmt);
176 return CONTACTS_ERROR_NONE;
180 static int __ctsvc_db_my_profile_get_record(int id, contacts_record_h *out_record)
183 contacts_record_h record;
184 ctsvc_my_profile_s *my_profile;
186 RETV_IF(NULL == out_record, CONTACTS_ERROR_INVALID_PARAMETER);
189 contacts_record_create(_contacts_my_profile._uri, &record);
190 my_profile = (ctsvc_my_profile_s*)record;
191 ret = __ctsvc_db_get_my_profile_base_info(id, my_profile);
192 if (CONTACTS_ERROR_NONE != ret) {
193 /* LCOV_EXCL_START */
194 ERR("cts_get_main_contacts_info(ALL) Fail(%d)", ret);
195 contacts_record_destroy(record, true);
200 ret = __ctsvc_db_my_profile_get_data(id, my_profile);
201 if (CONTACTS_ERROR_NONE != ret) {
202 /* LCOV_EXCL_START */
203 ERR("__ctsvc_db_my_profile_get_data Fail(%d)", ret);
204 contacts_record_destroy(record, true);
209 *out_record = record;
211 return CONTACTS_ERROR_NONE;
214 static int __ctsvc_db_my_profile_delete_record(int id)
219 char query[CTS_SQL_MAX_LEN] = {0};
221 ret = ctsvc_begin_trans();
222 RETVM_IF(ret, ret, "ctsvc_begin_trans() Fail(%d)", ret);
224 snprintf(query, sizeof(query),
225 "SELECT addressbook_id FROM "CTSVC_DB_VIEW_MY_PROFILE" WHERE my_profile_id = %d", id);
226 ret = ctsvc_query_get_first_int_result(query, &addressbook_id);
227 if (CONTACTS_ERROR_NONE != ret) {
228 /* LCOV_EXCL_START */
229 ERR("ctsvc_query_get_first_int_result() Fail(%d)", ret);
230 ctsvc_end_trans(false);
235 if (false == ctsvc_have_ab_write_permission(addressbook_id, false)) {
236 /* LCOV_EXCL_START */
237 ERR("No permission in this addresbook_id(%d)", addressbook_id);
238 ctsvc_end_trans(false);
239 return CONTACTS_ERROR_PERMISSION_DENIED;
243 snprintf(query, sizeof(query), "UPDATE "CTS_TABLE_MY_PROFILES" "
244 "SET deleted = 1, changed_ver = %d WHERE my_profile_id = %d", ctsvc_get_next_ver(), id);
245 ret = ctsvc_query_exec(query);
246 if (CONTACTS_ERROR_NONE != ret) {
247 /* LCOV_EXCL_START */
248 ERR("ctsvc_query_exec() Fail(%d)", ret);
249 ctsvc_end_trans(false);
254 ctsvc_set_my_profile_noti();
256 ret = ctsvc_end_trans(true);
257 if (ret < CONTACTS_ERROR_NONE) {
258 /* LCOV_EXCL_START */
259 ERR("ctsvc_end_trans() Fail(%d)", ret);
263 return CONTACTS_ERROR_NONE;
267 static inline int __ctsvc_my_profile_update_data(ctsvc_my_profile_s *my_profile)
271 if (my_profile->name) {
272 ret = ctsvc_contact_update_data_name((contacts_list_h)my_profile->name, my_profile->id, true);
273 if (CONTACTS_ERROR_NONE != ret) {
274 /* LCOV_EXCL_START */
275 ERR("ctsvc_contact_update_data_name() Fail(%d)", ret);
281 if (my_profile->company) {
282 ret = ctsvc_contact_update_data_company((contacts_list_h)my_profile->company, my_profile->id, true);
283 if (CONTACTS_ERROR_NONE != ret) {
284 /* LCOV_EXCL_START */
285 ERR("ctsvc_contact_update_data_company() Fail(%d)", ret);
291 if (my_profile->note) {
292 ret = ctsvc_contact_update_data_note((contacts_list_h)my_profile->note, my_profile->id, true);
293 if (CONTACTS_ERROR_NONE != ret) {
294 /* LCOV_EXCL_START */
295 ERR("ctsvc_contact_update_data_note() Fail(%d)", ret);
301 if (my_profile->events) {
302 ret = ctsvc_contact_update_data_event((contacts_list_h)my_profile->events, my_profile->id, true);
303 if (CONTACTS_ERROR_NONE != ret) {
304 /* LCOV_EXCL_START */
305 ERR("ctsvc_contact_update_data_events() Fail(%d)", ret);
311 if (my_profile->messengers) {
312 ret = ctsvc_contact_update_data_messenger((contacts_list_h)my_profile->messengers, my_profile->id, true);
313 if (CONTACTS_ERROR_NONE != ret) {
314 /* LCOV_EXCL_START */
315 ERR("ctsvc_contact_update_data_messengers() Fail(%d)", ret);
321 if (my_profile->postal_addrs) {
322 ret = ctsvc_contact_update_data_address((contacts_list_h)my_profile->postal_addrs, my_profile->id, true);
323 if (CONTACTS_ERROR_NONE != ret) {
324 /* LCOV_EXCL_START */
325 ERR("ctsvc_contact_update_data_address() Fail(%d)", ret);
331 if (my_profile->urls) {
332 ret = ctsvc_contact_update_data_url((contacts_list_h)my_profile->urls, my_profile->id, true);
333 if (CONTACTS_ERROR_NONE != ret) {
334 /* LCOV_EXCL_START */
335 ERR("ctsvc_contact_update_data_url() Fail(%d)", ret);
341 if (my_profile->nicknames) {
342 ret = ctsvc_contact_update_data_nickname((contacts_list_h)my_profile->nicknames, my_profile->id, true);
343 if (CONTACTS_ERROR_NONE != ret) {
344 /* LCOV_EXCL_START */
345 ERR("ctsvc_contact_update_data_nickname() Fail(%d)", ret);
351 if (my_profile->numbers) {
352 bool had_phonenumber;
353 ret = ctsvc_contact_update_data_number((contacts_list_h)my_profile->numbers, my_profile->id, true, &had_phonenumber);
354 if (CONTACTS_ERROR_NONE != ret) {
355 /* LCOV_EXCL_START */
356 ERR("ctsvc_contact_update_data_number() Fail(%d)", ret);
362 if (my_profile->emails) {
364 ret = ctsvc_contact_update_data_email((contacts_list_h)my_profile->emails, my_profile->id, true, &had_email);
365 if (CONTACTS_ERROR_NONE != ret) {
366 /* LCOV_EXCL_START */
367 ERR("ctsvc_contact_update_data_email() Fail(%d)", ret);
373 if (my_profile->profiles) {
374 ret = ctsvc_contact_update_data_profile((contacts_list_h)my_profile->profiles, my_profile->id, true);
375 if (CONTACTS_ERROR_NONE != ret) {
376 /* LCOV_EXCL_START */
377 ERR("ctsvc_contact_update_data_profile() Fail(%d)", ret);
383 if (my_profile->relationships) {
384 ret = ctsvc_contact_update_data_relationship((contacts_list_h)my_profile->relationships, my_profile->id, true);
385 if (CONTACTS_ERROR_NONE != ret) {
386 /* LCOV_EXCL_START */
387 ERR("ctsvc_contact_update_data_relationship() Fail(%d)", ret);
393 if (my_profile->images) {
394 ret = ctsvc_contact_update_data_image((contacts_list_h)my_profile->images, my_profile->id, true);
395 if (CONTACTS_ERROR_NONE != ret) {
396 /* LCOV_EXCL_START */
397 ERR("ctsvc_contact_update_data_image() Fail(%d)", ret);
403 if (my_profile->extensions) {
404 ret = ctsvc_contact_update_data_extension((contacts_list_h)my_profile->extensions, my_profile->id, true);
405 if (CONTACTS_ERROR_NONE != ret) {
406 /* LCOV_EXCL_START */
407 ERR("ctsvc_contact_update_data_extension() Fail(%d)", ret);
413 return CONTACTS_ERROR_NONE;
416 static void __ctsvc_my_profile_check_default_data(ctsvc_my_profile_s *my_profile)
418 ctsvc_contact_check_default_number((contacts_list_h)my_profile->numbers);
419 ctsvc_contact_check_default_email((contacts_list_h)my_profile->emails);
420 ctsvc_contact_check_default_image((contacts_list_h)my_profile->images);
421 ctsvc_contact_check_default_address((contacts_list_h)my_profile->postal_addrs);
424 static void __ctsvc_make_my_profile_display_name(ctsvc_my_profile_s *my_profile)
426 ctsvc_name_s *name = NULL;
428 free(my_profile->display_name);
429 my_profile->display_name = NULL;
431 free(my_profile->reverse_display_name);
432 my_profile->reverse_display_name = NULL;
434 if (0 < my_profile->name->count && my_profile->name->records
435 && my_profile->name->records->data) {
436 name = (ctsvc_name_s*)my_profile->name->records->data;
439 if (name && (name->first || name->last || name->prefix || name->addition
441 char *display = NULL;
442 int len, display_len;
443 int reverse_lang_type = -1;
444 int temp_display_len;
445 char *temp_display = NULL;
448 * Make reverse display name (Last name first)
449 * Default : Prefix Last, First Middle(addition), Suffix
450 * Korean, Chinese : Prefix LastFirstMiddleSuffix
451 * Japanese : Prefix Last Middle First Suffix
452 * reverse sort name does not include prefix
453 * But, if there is only prefix, reverse sort_name is prefix
455 temp_display_len = SAFE_STRLEN(name->first)
456 + SAFE_STRLEN(name->addition)
457 + SAFE_STRLEN(name->last)
458 + SAFE_STRLEN(name->suffix);
459 if (0 < temp_display_len) {
460 temp_display_len += 7;
461 temp_display = calloc(1, temp_display_len);
462 if (NULL == temp_display) {
463 /* LCOV_EXCL_START */
464 ERR("calloc() Fail");
471 len += snprintf(temp_display + len, temp_display_len - len, "%s",
474 if (reverse_lang_type < 0)
475 reverse_lang_type = ctsvc_check_language_type(temp_display);
477 if (reverse_lang_type != CTSVC_LANG_KOREAN &&
478 reverse_lang_type != CTSVC_LANG_CHINESE &&
479 reverse_lang_type != CTSVC_LANG_JAPANESE) {
480 if (name->first || name->addition)
481 len += snprintf(temp_display + len, temp_display_len - len, ",");
485 if (reverse_lang_type < 0) {
487 reverse_lang_type = ctsvc_check_language_type(temp_display);
488 else if (name->first)
489 reverse_lang_type = ctsvc_check_language_type(name->first);
490 else if (name->addition)
491 reverse_lang_type = ctsvc_check_language_type(name->addition);
494 if (reverse_lang_type == CTSVC_LANG_JAPANESE) {
495 /* make temp_display name Prefix - Last - Middle - First - Suffix */
496 if (name->addition) {
498 len += snprintf(temp_display + len, temp_display_len - len, " ");
499 len += snprintf(temp_display + len, temp_display_len - len, "%s", name->addition);
504 len += snprintf(temp_display + len, temp_display_len - len, " ");
505 len += snprintf(temp_display + len, temp_display_len - len, "%s", name->first);
510 if (reverse_lang_type < 0)
511 reverse_lang_type = ctsvc_check_language_type(temp_display);
513 if (reverse_lang_type != CTSVC_LANG_KOREAN &&
514 reverse_lang_type != CTSVC_LANG_CHINESE)
515 len += snprintf(temp_display + len, temp_display_len - len, " ");
517 len += snprintf(temp_display + len, temp_display_len - len, "%s", name->first);
520 if (name->addition) {
522 if (reverse_lang_type < 0)
523 reverse_lang_type = ctsvc_check_language_type(temp_display);
525 if (reverse_lang_type != CTSVC_LANG_KOREAN &&
526 reverse_lang_type != CTSVC_LANG_CHINESE)
527 len += snprintf(temp_display + len, temp_display_len - len, " ");
529 len += snprintf(temp_display + len, temp_display_len - len, "%s", name->addition);
535 if (reverse_lang_type < 0)
536 reverse_lang_type = ctsvc_check_language_type(temp_display);
538 if (reverse_lang_type == CTSVC_LANG_JAPANESE) {
539 len += snprintf(temp_display + len, temp_display_len - len, " ");
540 } else if (reverse_lang_type != CTSVC_LANG_KOREAN &&
541 reverse_lang_type != CTSVC_LANG_CHINESE) {
542 len += snprintf(temp_display + len, temp_display_len - len, ", ");
545 len += snprintf(temp_display + len, temp_display_len - len, "%s", name->suffix);
549 if (name->prefix && temp_display) {
550 display_len = SAFE_STRLEN(name->prefix) + temp_display_len + 2;
551 display = calloc(1, display_len);
552 if (NULL == display) {
553 /* LCOV_EXCL_START */
554 ERR("calloc() Fail");
559 snprintf(display, display_len, "%s %s", name->prefix, temp_display);
560 my_profile->reverse_display_name = display;
562 } else if (temp_display) {
563 my_profile->reverse_display_name = temp_display;
564 } else if (name->prefix) {
565 my_profile->reverse_display_name = strdup(name->prefix);
569 * Make display name (First name first)
570 * Default : Prefix First Middle Last, Suffix
571 * Korean, Chinese : Prefix LastFirstMiddleSuffix (Same as reverse display name)
572 * Japanese : Prefix First Middle Last Suffix
573 * sort name does not include prefix
574 * But, if there is only prefix, sort_name is prefix
576 if (reverse_lang_type == CTSVC_LANG_KOREAN ||
577 reverse_lang_type == CTSVC_LANG_CHINESE) {
578 my_profile->display_name = SAFE_STRDUP(my_profile->reverse_display_name);
582 temp_display_len = SAFE_STRLEN(name->first)
583 + SAFE_STRLEN(name->addition)
584 + SAFE_STRLEN(name->last)
585 + SAFE_STRLEN(name->suffix);
586 if (0 < temp_display_len) {
587 temp_display_len += 6;
588 /* make reverse_temp_display_name */
589 temp_display = calloc(1, temp_display_len);
590 if (NULL == temp_display) {
591 /* LCOV_EXCL_START */
592 ERR("calloc() Fail");
600 len += snprintf(temp_display + len, temp_display_len - len, " ");
601 len += snprintf(temp_display + len, temp_display_len - len, "%s", name->first);
604 if (name->addition) {
606 len += snprintf(temp_display + len, temp_display_len - len, " ");
607 len += snprintf(temp_display + len, temp_display_len - len, "%s", name->addition);
612 len += snprintf(temp_display + len, temp_display_len - len, " ");
613 len += snprintf(temp_display + len, temp_display_len - len, "%s", name->last);
618 lang_type = ctsvc_check_language_type(temp_display);
619 if (lang_type == CTSVC_LANG_JAPANESE)
620 len += snprintf(temp_display + len, temp_display_len - len, " ");
622 len += snprintf(temp_display + len, temp_display_len - len, ", ");
624 len += snprintf(temp_display + len, temp_display_len - len, "%s", name->suffix);
628 if (name->prefix && temp_display) {
629 display_len = SAFE_STRLEN(name->prefix) + temp_display_len + 2;
630 display = calloc(1, display_len);
631 if (NULL == display) {
632 /* LCOV_EXCL_START */
633 ERR("calloc() Fail");
638 snprintf(display, display_len, "%s %s", name->prefix, temp_display);
639 my_profile->display_name = display;
641 } else if (temp_display) {
642 my_profile->display_name = temp_display;
643 } else if (name->prefix) {
644 my_profile->display_name = strdup(name->prefix);
648 ctsvc_record_set_property_flag((ctsvc_record_s*)my_profile,
649 _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY);
652 if (my_profile->company && my_profile->company->records) {
653 for (cur = my_profile->company->records; cur; cur = cur->next) {
654 ctsvc_company_s *company = cur->data;
655 if (company && company->name) {
656 ctsvc_record_set_property_flag((ctsvc_record_s*)my_profile,
657 _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY);
658 my_profile->display_name = SAFE_STRDUP(company->name);
664 if (false == ctsvc_record_check_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY) &&
665 my_profile->nicknames && my_profile->nicknames->records) {
666 for (cur = my_profile->nicknames->records; cur; cur = cur->next) {
667 ctsvc_nickname_s *nickname = cur->data;
668 if (nickname && nickname->nickname) {
669 ctsvc_record_set_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY);
670 free(my_profile->display_name);
671 my_profile->display_name = SAFE_STRDUP(nickname->nickname);
677 if (false == ctsvc_record_check_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY) &&
678 my_profile->numbers && my_profile->numbers->records) {
679 for (cur = my_profile->numbers->records; cur; cur = cur->next) {
680 ctsvc_number_s *number = cur->data;
681 if (number && number->number) {
682 ctsvc_record_set_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY);
683 free(my_profile->display_name);
684 my_profile->display_name = SAFE_STRDUP(number->number);
690 if (false == ctsvc_record_check_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY) &&
691 my_profile->emails && my_profile->emails->records) {
692 for (cur = my_profile->emails->records; cur; cur = cur->next) {
693 ctsvc_email_s *email = cur->data;
694 if (email && email->email_addr) {
695 ctsvc_record_set_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY);
696 free(my_profile->display_name);
697 my_profile->display_name = SAFE_STRDUP(email->email_addr);
703 if (ctsvc_record_check_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY)) {
704 my_profile->reverse_display_name = SAFE_STRDUP(my_profile->display_name);
707 ctsvc_record_set_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY);
714 static int __ctsvc_db_my_profile_update_record(contacts_record_h record)
719 char query[CTS_SQL_MAX_LEN] = {0};
720 ctsvc_my_profile_s *my_profile = (ctsvc_my_profile_s*)record;
721 GSList *bind_text = NULL;
722 GSList *cursor = NULL;
724 ret = ctsvc_begin_trans();
725 RETVM_IF(ret, ret, "ctsvc_begin_trans() Fail(%d)", ret);
727 snprintf(query, sizeof(query),
728 "SELECT my_profile_id FROM "CTSVC_DB_VIEW_MY_PROFILE" WHERE my_profile_id = %d", my_profile->id);
729 ret = ctsvc_query_get_first_int_result(query, &id);
730 if (CONTACTS_ERROR_NONE != ret) {
731 /* LCOV_EXCL_START */
732 ERR("The index(%d) is Invalid. %d Record(s) is(are) found", my_profile->id, ret);
733 ctsvc_end_trans(false);
738 if (false == ctsvc_have_ab_write_permission(my_profile->addressbook_id, false)) {
739 /* LCOV_EXCL_START */
740 ERR("No permission in this addresbook_id(%d)", my_profile->addressbook_id);
741 ctsvc_end_trans(false);
742 return CONTACTS_ERROR_PERMISSION_DENIED;
746 __ctsvc_make_my_profile_display_name(my_profile);
747 __ctsvc_my_profile_check_default_data(my_profile);
750 ret = __ctsvc_my_profile_update_data(my_profile);
751 if (CONTACTS_ERROR_NONE != ret) {
752 /* LCOV_EXCL_START */
753 ERR("__ctsvc_my_profile_update_data() Fail(%d)", ret);
754 ctsvc_end_trans(false);
760 if (my_profile->images) {
761 int ret = CONTACTS_ERROR_NONE;
763 ctsvc_image_s *image;
765 contacts_list_get_count((contacts_list_h)my_profile->images, &count);
767 contacts_list_first((contacts_list_h)my_profile->images);
769 ret = contacts_list_get_current_record_p((contacts_list_h)my_profile->images, (contacts_record_h*)&image);
770 if (CONTACTS_ERROR_NONE != ret) {
771 /* LCOV_EXCL_START */
772 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
773 ctsvc_end_trans(false);
774 return CONTACTS_ERROR_DB;
778 if (image->is_default)
780 } while (CONTACTS_ERROR_NONE == contacts_list_next((contacts_list_h)my_profile->images));
782 if ((NULL == my_profile->image_thumbnail_path && image->path) ||
783 (my_profile->image_thumbnail_path && NULL == image->path) ||
784 (my_profile->image_thumbnail_path && image->path && STRING_EQUAL != strcmp(my_profile->image_thumbnail_path, image->path))) {
785 ctsvc_record_set_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.image_thumbnail_path, CTSVC_PROPERTY_FLAG_DIRTY);
787 if (ctsvc_contact_check_image_location(image->path))
788 my_profile->image_thumbnail_path = SAFE_STRDUP(image->path + strlen(CTSVC_CONTACT_IMG_FULL_LOCATION) + 1);
790 my_profile->image_thumbnail_path = SAFE_STRDUP(image->path);
792 } else if (my_profile->image_thumbnail_path) {
793 free(my_profile->image_thumbnail_path);
794 my_profile->image_thumbnail_path = NULL;
795 ctsvc_record_set_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.image_thumbnail_path, CTSVC_PROPERTY_FLAG_DIRTY);
802 char query[CTS_SQL_MAX_LEN] = {0};
803 char query_set[CTS_SQL_MIN_LEN] = {0, };
804 cts_stmt stmt = NULL;
806 version = ctsvc_get_next_ver();
808 ret = ctsvc_db_create_set_query(record, &set, &bind_text);
809 WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_db_create_set_query() Fail(%d)", ret);
812 len = snprintf(query_set, sizeof(query_set), "%s, ", set);
813 len += snprintf(query_set+len, sizeof(query_set)-len, " changed_ver=%d, changed_time=%d", version, (int)time(NULL));
815 if (ctsvc_record_check_property_flag((ctsvc_record_s*)my_profile, _contacts_my_profile.display_name, CTSVC_PROPERTY_FLAG_DIRTY)) {
816 len += snprintf(query_set+len, sizeof(query_set)-len,
817 ", display_name=?, reverse_display_name=?");
818 bind_text = g_slist_append(bind_text, strdup(SAFE_STR(my_profile->display_name)));
819 bind_text = g_slist_append(bind_text, strdup(SAFE_STR(my_profile->reverse_display_name)));
822 snprintf(query, sizeof(query), "UPDATE %s SET %s WHERE my_profile_id = %d", CTS_TABLE_MY_PROFILES, query_set, my_profile->id);
824 ret = ctsvc_query_prepare(query, &stmt);
826 /* LCOV_EXCL_START */
827 ERR("ctsvc_query_prepare() Fail(%d)", ret);
834 for (cursor = bind_text, i = 1; cursor; cursor = cursor->next, i++) {
835 const char *text = cursor->data;
837 ctsvc_stmt_bind_text(stmt, i, text);
841 ret = ctsvc_stmt_step(stmt);
842 if (CONTACTS_ERROR_NONE != ret) {
843 /* LCOV_EXCL_START */
844 ERR("ctsvc_stmt_step() Fail(%d)", ret);
845 ctsvc_stmt_finalize(stmt);
849 ctsvc_stmt_finalize(stmt);
852 CTSVC_RECORD_RESET_PROPERTY_FLAGS((ctsvc_record_s*)record);
856 for (cursor = bind_text; cursor; cursor = cursor->next) {
860 g_slist_free(bind_text);
863 ctsvc_set_my_profile_noti();
865 ret = ctsvc_end_trans(true);
866 RETVM_IF(ret < CONTACTS_ERROR_NONE, ret, "ctsvc_end_trans() Fail(%d)", ret);
868 return CONTACTS_ERROR_NONE;
871 static int __ctsvc_db_my_profile_get_all_records(int offset, int limit, contacts_list_h *out_list)
877 char query[CTS_SQL_MAX_LEN] = {0};
878 contacts_list_h list;
880 len = snprintf(query, sizeof(query),
881 "SELECT my_profile_id FROM "CTSVC_DB_VIEW_MY_PROFILE);
884 len += snprintf(query+len, sizeof(query)-len, " LIMIT %d", limit);
886 len += snprintf(query+len, sizeof(query)-len, " OFFSET %d", offset);
889 ret = ctsvc_query_prepare(query, &stmt);
890 RETVM_IF(NULL == stmt, ret, "ctsvc_query_prepare() Fail(%d)", ret);
892 contacts_list_create(&list);
893 while ((ret = ctsvc_stmt_step(stmt))) {
894 contacts_record_h record;
896 /* LCOV_EXCL_START */
897 ERR("ctsvc_stmt_step() Fail(%d)", ret);
898 ctsvc_stmt_finalize(stmt);
899 contacts_list_destroy(list, true);
903 my_profile_id = ctsvc_stmt_get_int(stmt, 0);
904 ret = ctsvc_db_get_record(_contacts_my_profile._uri, my_profile_id, &record);
905 if (CONTACTS_ERROR_NONE != ret) {
906 /* LCOV_EXCL_START */
907 ERR("contacts_db_get_record() Fail(%d)", ret);
908 ctsvc_stmt_finalize(stmt);
909 contacts_list_destroy(list, true);
913 ctsvc_list_prepend(list, record);
915 ctsvc_stmt_finalize(stmt);
916 ctsvc_list_reverse(list);
918 *out_list = (contacts_list_h)list;
919 return CONTACTS_ERROR_NONE;
922 static int __ctsvc_db_my_profile_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h *out_list)
927 ctsvc_query_s *s_query;
929 contacts_list_h list;
930 ctsvc_my_profile_s *my_profile;
931 char full_path[CTSVC_IMG_FULL_PATH_SIZE_MAX] = {0};
932 bool had_my_profile_id = false;
933 int my_profile_id = 0;
935 RETV_IF(NULL == query, CONTACTS_ERROR_INVALID_PARAMETER);
936 s_query = (ctsvc_query_s*)query;
938 if (s_query->projection) {
939 for (i = 0; i < s_query->projection_count; i++) {
940 if (s_query->projection[i] == CTSVC_PROPERTY_MY_PROFILE_ID) {
941 had_my_profile_id = true;
946 s_query->projection_count = 0;
947 had_my_profile_id = true;
950 if (false == had_my_profile_id) {
951 s_query->projection = realloc(s_query->projection, s_query->projection_count+1);
952 if (NULL == s_query->projection) {
953 /* LCOV_EXCL_START */
954 ERR("realloc() Fail");
955 return CONTACTS_ERROR_OUT_OF_MEMORY;
958 s_query->projection[s_query->projection_count] = CTSVC_PROPERTY_MY_PROFILE_ID;
959 s_query->projection_count++;
962 ret = ctsvc_db_make_get_records_query_stmt(s_query, offset, limit, &stmt);
963 RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_db_make_get_records_query_stmt fail(%d)", ret);
965 contacts_list_create(&list);
966 while ((ret = ctsvc_stmt_step(stmt))) {
967 contacts_record_h record;
969 /* LCOV_EXCL_START */
970 ERR("ctsvc_stmt_step() Fail(%d)", ret);
971 ctsvc_stmt_finalize(stmt);
972 contacts_list_destroy(list, true);
977 contacts_record_create(_contacts_my_profile._uri, &record);
978 my_profile = (ctsvc_my_profile_s*)record;
979 if (0 == s_query->projection_count) {
980 field_count = s_query->property_count;
982 field_count = s_query->projection_count;
983 ret = ctsvc_record_set_projection_flags(record, s_query->projection,
984 s_query->projection_count, s_query->property_count);
986 if (CONTACTS_ERROR_NONE != ret)
987 ASSERT_NOT_REACHED("To set projection is Fail.\n");
990 for (i = 0; i < field_count; i++) {
993 if (0 == s_query->projection_count)
994 property_id = s_query->properties[i].property_id;
996 property_id = s_query->projection[i];
998 switch (property_id) {
999 case CTSVC_PROPERTY_MY_PROFILE_ID:
1000 my_profile_id = ctsvc_stmt_get_int(stmt, i);
1001 if (had_my_profile_id)
1002 my_profile->id = my_profile_id;
1004 case CTSVC_PROPERTY_MY_PROFILE_DISPLAY_NAME:
1005 temp = ctsvc_stmt_get_text(stmt, i);
1006 free(my_profile->display_name);
1007 my_profile->display_name = SAFE_STRDUP(temp);
1009 case CTSVC_PROPERTY_MY_PROFILE_ADDRESSBOOK_ID:
1010 my_profile->addressbook_id = ctsvc_stmt_get_int(stmt, i);
1012 case CTSVC_PROPERTY_MY_PROFILE_IMAGE_THUMBNAIL:
1013 temp = ctsvc_stmt_get_text(stmt, i);
1015 snprintf(full_path, sizeof(full_path), "%s/%s", CTSVC_CONTACT_IMG_FULL_LOCATION, temp);
1016 free(my_profile->image_thumbnail_path);
1017 my_profile->image_thumbnail_path = strdup(full_path);
1020 case CTSVC_PROPERTY_MY_PROFILE_CHANGED_TIME:
1021 my_profile->changed_time = ctsvc_stmt_get_int(stmt, i);
1023 case CTSVC_PROPERTY_MY_PROFILE_UID:
1024 temp = ctsvc_stmt_get_text(stmt, i);
1025 free(my_profile->uid);
1026 my_profile->uid = SAFE_STRDUP(temp);
1032 ret = __ctsvc_db_my_profile_get_data(my_profile_id, my_profile);
1033 if (CONTACTS_ERROR_NONE != ret) {
1034 /* LCOV_EXCL_START */
1035 ERR("__ctsvc_db_my_profile_get_data Fail(%d)", ret);
1036 ctsvc_stmt_finalize(stmt);
1037 contacts_list_destroy(list, true);
1039 /* LCOV_EXCL_STOP */
1042 ctsvc_list_prepend(list, record);
1044 ctsvc_stmt_finalize(stmt);
1045 ctsvc_list_reverse(list);
1047 *out_list = (contacts_list_h)list;
1049 return CONTACTS_ERROR_NONE;
1052 static int __ctsvc_my_profile_insert_data(ctsvc_my_profile_s *contact)
1056 /* Insert the name */
1057 if (contact->name) {
1058 ret = ctsvc_contact_insert_data_name((contacts_list_h)contact->name, contact->id, true);
1059 if (CONTACTS_ERROR_NONE != ret) {
1060 /* LCOV_EXCL_START */
1061 ERR("ctsvc_contact_insert_data_name() Fail(%d)", ret);
1063 /* LCOV_EXCL_STOP */
1067 /* Insert the company */
1068 if (contact->company) {
1069 ret = ctsvc_contact_insert_data_company((contacts_list_h)contact->company, contact->id, true);
1070 if (CONTACTS_ERROR_NONE != ret) {
1071 /* LCOV_EXCL_START */
1072 ERR("ctsvc_insert_my_profile_data_company() Fail(%d)", ret);
1074 /* LCOV_EXCL_STOP */
1078 /* Insert the events */
1079 if (contact->events) {
1080 ret = ctsvc_contact_insert_data_event((contacts_list_h)contact->events, contact->id, true);
1081 if (CONTACTS_ERROR_NONE != ret) {
1082 /* LCOV_EXCL_START */
1083 ERR("ctsvc_insert_my_profile_data_event() Fail(%d)", ret);
1085 /* LCOV_EXCL_STOP */
1089 /* Insert the messengers */
1090 if (contact->messengers) {
1091 ret = ctsvc_contact_insert_data_messenger((contacts_list_h)contact->messengers, contact->id, true);
1092 if (CONTACTS_ERROR_NONE != ret) {
1093 /* LCOV_EXCL_START */
1094 ERR("ctsvc_insert_my_profile_data_messenger() Fail(%d)", ret);
1096 /* LCOV_EXCL_STOP */
1100 /* Insert the postals */
1101 if (contact->postal_addrs) {
1102 ret = ctsvc_contact_insert_data_address((contacts_list_h)contact->postal_addrs, contact->id, true);
1103 if (CONTACTS_ERROR_NONE != ret) {
1104 /* LCOV_EXCL_START */
1105 ERR("ctsvc_insert_my_profile_data_postal() Fail(%d)", ret);
1107 /* LCOV_EXCL_STOP */
1111 /* Insert the Web addrs */
1112 if (contact->urls) {
1113 ret = ctsvc_contact_insert_data_url((contacts_list_h)contact->urls, contact->id, true);
1114 if (CONTACTS_ERROR_NONE != ret) {
1115 /* LCOV_EXCL_START */
1116 ERR("ctsvc_insert_my_profile_data_web() Fail(%d)", ret);
1118 /* LCOV_EXCL_STOP */
1122 /* Insert the Nick names */
1123 if (contact->nicknames) {
1124 ret = ctsvc_contact_insert_data_nickname((contacts_list_h)contact->nicknames, contact->id, true);
1125 if (CONTACTS_ERROR_NONE != ret) {
1126 /* LCOV_EXCL_START */
1127 ERR("ctsvc_insert_my_profile_data_nickname() Fail(%d)", ret);
1129 /* LCOV_EXCL_STOP */
1133 /* Insert the numbers */
1134 if (contact->numbers) {
1135 ret = ctsvc_contact_insert_data_number((contacts_list_h)contact->numbers, contact->id, true);
1136 if (ret < CONTACTS_ERROR_NONE) {
1137 /* LCOV_EXCL_START */
1138 ERR("ctsvc_contact_insert_data_number() Fail(%d)", ret);
1140 /* LCOV_EXCL_STOP */
1144 /* Insert the emails */
1145 if (contact->emails) {
1146 ret = ctsvc_contact_insert_data_email((contacts_list_h)contact->emails, contact->id, true);
1147 if (ret < CONTACTS_ERROR_NONE) {
1148 /* LCOV_EXCL_START */
1149 ERR("ctsvc_insert_my_profile_data_email() Fail(%d)", ret);
1151 /* LCOV_EXCL_STOP */
1155 /* Insert the profile values */
1156 if (contact->profiles) {
1157 ret = ctsvc_contact_insert_data_profile((contacts_list_h)contact->profiles, contact->id, true);
1158 if (CONTACTS_ERROR_NONE != ret) {
1159 /* LCOV_EXCL_START */
1160 ERR("ctsvc_insert_my_profile_data_profile() Fail(%d)", ret);
1162 /* LCOV_EXCL_STOP */
1166 /* Insert the relationship values */
1167 if (contact->relationships) {
1168 ret = ctsvc_contact_insert_data_relationship((contacts_list_h)contact->relationships, contact->id, true);
1169 if (CONTACTS_ERROR_NONE != ret) {
1170 /* LCOV_EXCL_START */
1171 ERR("ctsvc_contact_insert_data_relationship() Fail(%d)", ret);
1173 /* LCOV_EXCL_STOP */
1177 /* Insert the image values */
1178 if (contact->images) {
1179 ret = ctsvc_contact_insert_data_image((contacts_list_h)contact->images, contact->id, true);
1180 if (CONTACTS_ERROR_NONE != ret) {
1181 /* LCOV_EXCL_START */
1182 ERR("ctsvc_contact_insert_data_image() Fail(%d)", ret);
1184 /* LCOV_EXCL_STOP */
1188 /* Insert the note values */
1189 if (contact->note) {
1190 ret = ctsvc_contact_insert_data_note((contacts_list_h)contact->note, contact->id, true);
1191 if (CONTACTS_ERROR_NONE != ret) {
1192 /* LCOV_EXCL_START */
1193 ERR("ctsvc_contact_insert_data_note() Fail(%d)", ret);
1195 /* LCOV_EXCL_STOP */
1199 /* Insert the extensions values */
1200 if (contact->extensions) {
1201 ret = ctsvc_contact_insert_data_extension((contacts_list_h)contact->extensions, contact->id, true);
1202 if (CONTACTS_ERROR_NONE != ret) {
1203 /* LCOV_EXCL_START */
1204 ERR("ctsvc_contact_insert_data_extension() Fail(%d)", ret);
1206 /* LCOV_EXCL_STOP */
1210 return CONTACTS_ERROR_NONE;
1213 static int __ctsvc_db_my_profile_insert_record(contacts_record_h record, int *id)
1218 char query[CTS_SQL_MAX_LEN] = {0};
1220 ctsvc_my_profile_s *my_profile = (ctsvc_my_profile_s*)record;
1223 /* These check should be done in client side */
1224 RETV_IF(NULL == my_profile, CONTACTS_ERROR_INVALID_PARAMETER);
1225 RETVM_IF(my_profile->addressbook_id < 0, CONTACTS_ERROR_INVALID_PARAMETER,
1226 "addressbook_id(%d) is mandatory field to insert my_profile record ", my_profile->addressbook_id);
1227 RETVM_IF(0 < my_profile->id, CONTACTS_ERROR_INVALID_PARAMETER,
1228 "id(%d), This record is already inserted", my_profile->id);
1230 ret = ctsvc_begin_trans();
1231 RETVM_IF(ret < CONTACTS_ERROR_NONE, ret, "ctsvc_begin_trans() Fail(%d)", ret);
1233 if (false == ctsvc_have_ab_write_permission(my_profile->addressbook_id, false)) {
1234 /* LCOV_EXCL_START */
1235 ERR("No permission in this addresbook_id(%d)", my_profile->addressbook_id);
1236 ctsvc_end_trans(false);
1237 return CONTACTS_ERROR_PERMISSION_DENIED;
1238 /* LCOV_EXCL_STOP */
1241 snprintf(query, sizeof(query), "DELETE FROM "CTS_TABLE_MY_PROFILES" WHERE addressbook_id = %d AND deleted = 1", my_profile->addressbook_id);
1242 ret = ctsvc_query_exec(query);
1243 WARN_IF(CONTACTS_ERROR_NONE != ret, "Delete deleted my_profile of addressbook(%d) Fail", my_profile->addressbook_id);
1245 ret = ctsvc_db_get_next_id(CTS_TABLE_MY_PROFILES);
1246 if (ret < CONTACTS_ERROR_NONE) {
1247 /* LCOV_EXCL_START */
1248 ERR("ctsvc_db_get_next_id() Fail(%d)", ret);
1249 ctsvc_end_trans(false);
1251 /* LCOV_EXCL_STOP */
1253 my_profile->id = ret;
1257 __ctsvc_make_my_profile_display_name(my_profile);
1258 __ctsvc_my_profile_check_default_data(my_profile);
1261 ret = __ctsvc_my_profile_insert_data(my_profile);
1262 if (CONTACTS_ERROR_NONE != ret) {
1263 /* LCOV_EXCL_START */
1264 ERR("cts_insert_my_profile_data() Fail(%d)", ret);
1265 ctsvc_end_trans(false);
1267 /* LCOV_EXCL_STOP */
1271 free(my_profile->image_thumbnail_path);
1272 my_profile->image_thumbnail_path = NULL;
1273 if (my_profile->images) {
1275 ctsvc_image_s *image;
1277 contacts_list_get_count((contacts_list_h)my_profile->images, &count);
1279 contacts_list_first((contacts_list_h)my_profile->images);
1281 ret = contacts_list_get_current_record_p((contacts_list_h)my_profile->images, (contacts_record_h*)&image);
1282 if (CONTACTS_ERROR_NONE != ret) {
1283 /* LCOV_EXCL_START */
1284 ERR("contacts_list_get_current_record_p() Fail(%d)", ret);
1285 ctsvc_end_trans(false);
1286 return CONTACTS_ERROR_DB;
1287 /* LCOV_EXCL_STOP */
1290 if (image->path && image->is_default) {
1291 my_profile->image_thumbnail_path = strdup(image->path);
1294 } while (CONTACTS_ERROR_NONE == contacts_list_next((contacts_list_h)my_profile->images));
1298 version = ctsvc_get_next_ver();
1300 snprintf(query, sizeof(query),
1301 "INSERT INTO "CTS_TABLE_MY_PROFILES"(my_profile_id, addressbook_id, "
1302 "created_ver, changed_ver, changed_time, "
1303 "display_name, reverse_display_name, uid, image_thumbnail_path) "
1304 "VALUES(%d, %d, %d, %d, %d, ?, ?, ?, ?)",
1305 my_profile->id, my_profile->addressbook_id, version, version, (int)time(NULL));
1307 ret = ctsvc_query_prepare(query, &stmt);
1309 /* LCOV_EXCL_START */
1310 ERR("ctsvc_query_prepare() Fail(%d)", ret);
1311 ctsvc_end_trans(false);
1313 /* LCOV_EXCL_STOP */
1316 if (my_profile->display_name)
1317 ctsvc_stmt_bind_text(stmt, 1, my_profile->display_name);
1318 if (my_profile->reverse_display_name)
1319 ctsvc_stmt_bind_text(stmt, 2, my_profile->reverse_display_name);
1320 if (my_profile->uid)
1321 ctsvc_stmt_bind_text(stmt, 3, my_profile->uid);
1322 if (my_profile->image_thumbnail_path)
1323 ctsvc_stmt_bind_text(stmt, 4, my_profile->image_thumbnail_path);
1325 ret = ctsvc_stmt_step(stmt);
1326 if (CONTACTS_ERROR_NONE != ret) {
1327 /* LCOV_EXCL_START */
1328 ERR("ctsvc_stmt_step() Fail(%d)", ret);
1329 ctsvc_stmt_finalize(stmt);
1330 ctsvc_end_trans(false);
1332 /* LCOV_EXCL_STOP */
1334 ctsvc_stmt_finalize(stmt);
1336 ctsvc_set_my_profile_noti();
1338 ret = ctsvc_end_trans(true);
1339 RETVM_IF(ret < CONTACTS_ERROR_NONE, ret, "contacts_svc_end_trans() Fail(%d)", ret);
1341 return CONTACTS_ERROR_NONE;
1344 ctsvc_db_plugin_info_s ctsvc_db_plugin_my_profile = {
1345 .is_query_only = false,
1346 .insert_record = __ctsvc_db_my_profile_insert_record,
1347 .get_record = __ctsvc_db_my_profile_get_record,
1348 .update_record = __ctsvc_db_my_profile_update_record,
1349 .delete_record = __ctsvc_db_my_profile_delete_record,
1350 .get_all_records = __ctsvc_db_my_profile_get_all_records,
1351 .get_records_with_query = __ctsvc_db_my_profile_get_records_with_query,
1352 .insert_records = NULL,
1353 .update_records = NULL,
1354 .delete_records = NULL,
1356 .get_count_with_query = NULL,
1357 .replace_record = NULL,
1358 .replace_records = NULL,