From 0c2ea2b36052817cd57c11e8e3c2cb04a418a2fe Mon Sep 17 00:00:00 2001 From: Donghee Ye Date: Thu, 11 Apr 2013 19:16:15 +0900 Subject: Update version 0.9.64 - Fix memory leak - Remove unnecessary noti - Fix bug - wrong reverse display name - Change sorting order : special character will be display first Add reverse_display_name_language - Remove account_id 1/2/3 from persons table - Fix update group without group image change - Fix unlink contact bug Change-Id: I6fcf1ce8ce109330700d05a94c813c8f3b1e3e97 --- CMakeLists.txt | 2 +- common/ctsvc_inotify.c | 4 +- common/ctsvc_normalize.c | 15 ++--- common/ctsvc_notify.h | 1 - common/ctsvc_record_contact.c | 1 + common/ctsvc_struct.h | 1 + common/ctsvc_vcard.c | 99 +++++++++++++++++++++----------- common/ipc/ctsvc_ipc_contact.c | 2 + common/ipc/ctsvc_ipc_marshal.c | 24 +++++--- contacts-service2.manifest | 4 +- include/contacts.h | 2 +- include/contacts_db.h | 47 +++++++++++++++ include/contacts_utils.h | 23 -------- native/ctsvc_db_init.c | 5 ++ native/ctsvc_db_plugin_contact.c | 18 +++--- native/ctsvc_db_plugin_contact_helper.c | 69 ++++++++++++++++++++-- native/ctsvc_db_plugin_group.c | 5 +- native/ctsvc_db_plugin_person.c | 1 - native/ctsvc_db_plugin_person_helper.c | 33 +++++++---- native/ctsvc_db_plugin_phonelog.c | 43 ++++++++------ native/ctsvc_db_plugin_profile_helper.c | 2 +- native/ctsvc_db_query.c | 10 ++-- native/ctsvc_notification.c | 9 --- native/ctsvc_person.c | 31 +++------- native/ctsvc_sqlite.c | 2 +- native/ctsvc_utils.c | 12 ++-- packaging/contacts-service.spec | 2 +- res/.CONTACTS_SVC_SIMPLE_CONTACT_CHANGED | 0 schema.sql | 6 +- server/ctsvc_server.c | 1 - server/ctsvc_server_bg.c | 8 ++- server/ctsvc_server_sqlite.c | 44 ++++++++++++++ server/ctsvc_server_utils.c | 2 +- 33 files changed, 346 insertions(+), 182 deletions(-) delete mode 100644 res/.CONTACTS_SVC_SIMPLE_CONTACT_CHANGED diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e2e22e..d59252b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") SET(INCLUDEDIR "\${prefix}/${DEST_INCLUDE_DIR}") SET(VERSION_MAJOR 0) -SET(VERSION "${VERSION_MAJOR}.9.61") +SET(VERSION "${VERSION_MAJOR}.9.64") EXECUTE_PROCESS(COMMAND build-util/generator.sh) diff --git a/common/ctsvc_inotify.c b/common/ctsvc_inotify.c index 6b8e6cc..fbe63de 100755 --- a/common/ctsvc_inotify.c +++ b/common/ctsvc_inotify.c @@ -84,7 +84,6 @@ static inline void __ctsvc_inotify_handle_callback(GSList *noti_list, int wd, ui CTS_DBG("%s", noti->view_uri); noti->cb(noti->view_uri, noti->cb_data); } - } } } @@ -200,11 +199,10 @@ static inline const char* __ctsvc_noti_get_file_path(const char *view_uri) case CTSVC_RECORD_PERSON: return CTSVC_NOTI_PERSON_CHANGED; case CTSVC_RECORD_CONTACT: + case CTSVC_RECORD_SIMPLE_CONTACT: return CTSVC_NOTI_CONTACT_CHANGED; case CTSVC_RECORD_MY_PROFILE: return CTSVC_NOTI_MY_PROFILE_CHANGED; - case CTSVC_RECORD_SIMPLE_CONTACT: - return CTSVC_NOTI_SIMPLE_CONTACT_CHANGED; case CTSVC_RECORD_NAME: return CTSVC_NOTI_NAME_CHANGED; case CTSVC_RECORD_COMPANY: diff --git a/common/ctsvc_normalize.c b/common/ctsvc_normalize.c index 07fc667..e10ca8b 100644 --- a/common/ctsvc_normalize.c +++ b/common/ctsvc_normalize.c @@ -653,16 +653,18 @@ API int contacts_utils_get_index_characters(char **index_string) RETV_IF(NULL == index_string, CONTACTS_ERROR_INVALID_PARAMETER); char temp[5]; + sprintf(list, "#"); + strcat(list, ":"); + i = 0; - sprintf(list, "%d", i); + sprintf(temp, "%d", i); + strcat(list, temp); for (i=1;i<10;i++) { sprintf(temp, ";%d", i); strcat(list, temp); } - strcat(list, ":"); - sort_first = ctsvc_get_default_language(); switch(sort_first) { @@ -719,9 +721,6 @@ API int contacts_utils_get_index_characters(char **index_string) } free(second_list); - strcat(list, ":"); - strcat(list, "#"); - *index_string = strdup(list); return CONTACTS_ERROR_NONE; } @@ -975,7 +974,7 @@ static bool __ctsvc_compare_unicode_letter(const UChar* haystack, int haystack_l * @return a position of the beginning of the substring, Negative value(#cts_error) on error or difference. * @par example * @code - ret = contacts_strstr(str1, str2, &len); + ret = contacts_utils_strstr(str1, str2, &len); if(CONTACTS_ERROR_NONE == ret) { snprintf(first, ret+1, "%s", item_data->display); snprintf(middle, len+1, "%s", item_data->display + ret); @@ -984,8 +983,6 @@ static bool __ctsvc_compare_unicode_letter(const UChar* haystack, int haystack_l printf("str1 doesn't has str2"); * @endcode */ - - API int contacts_utils_strstr(const char *haystack, const char *needle, int *len) { diff --git a/common/ctsvc_notify.h b/common/ctsvc_notify.h index 6a41067..91e9b64 100644 --- a/common/ctsvc_notify.h +++ b/common/ctsvc_notify.h @@ -23,7 +23,6 @@ #define CTSVC_NOTI_ADDRESSBOOK_CHANGED "/opt/usr/data/contacts-svc/.CONTACTS_SVC_AB_CHANGED" #define CTSVC_NOTI_GROUP_CHANGED "/opt/usr/data/contacts-svc/.CONTACTS_SVC_GROUP_CHANGED" #define CTSVC_NOTI_PERSON_CHANGED "/opt/usr/data/contacts-svc/.CONTACTS_SVC_PERSON_CHANGED" -#define CTSVC_NOTI_SIMPLE_CONTACT_CHANGED "/opt/usr/data/contacts-svc/.CONTACTS_SVC_SIMPLE_CONTACT_CHANGED" #define CTSVC_NOTI_CONTACT_CHANGED "/opt/usr/data/contacts-svc/.CONTACTS_SVC_DB_CHANGED" #define CTSVC_NOTI_MY_PROFILE_CHANGED "/opt/usr/data/contacts-svc/.CONTACTS_SVC_MY_PROFILE_CHANGED" #define CTSVC_NOTI_NAME_CHANGED "/opt/usr/data/contacts-svc/.CONTACTS_SVC_NAME_CHANGED" diff --git a/common/ctsvc_record_contact.c b/common/ctsvc_record_contact.c index e714c8f..071b52f 100644 --- a/common/ctsvc_record_contact.c +++ b/common/ctsvc_record_contact.c @@ -3801,6 +3801,7 @@ static int __ctsvc_contact_clone(contacts_record_h record, contacts_record_h *ou out_data->changed_time = src_data->changed_time; out_data->display_source_type = src_data->display_source_type; out_data->display_name_language = src_data->display_name_language; + out_data->reverse_display_name_language = src_data->reverse_display_name_language; out_data->has_phonenumber = src_data->has_phonenumber; out_data->has_email = src_data->has_email; out_data->is_favorite = src_data->is_favorite; diff --git a/common/ctsvc_struct.h b/common/ctsvc_struct.h index eae39c3..858ae66 100644 --- a/common/ctsvc_struct.h +++ b/common/ctsvc_struct.h @@ -494,6 +494,7 @@ typedef struct { char *reverse_display_name; int display_source_type; int display_name_language; + int reverse_display_name_language; char *sort_name; char *reverse_sort_name; char *sortkey; diff --git a/common/ctsvc_vcard.c b/common/ctsvc_vcard.c index f8d3e96..eff08d0 100644 --- a/common/ctsvc_vcard.c +++ b/common/ctsvc_vcard.c @@ -190,7 +190,6 @@ static int __ctsvc_vcard_append_str(char **buf, int *buf_size, int len, const ch if (need_realloc) { if (NULL == (tmp = realloc(*buf, *buf_size))) { - free(*buf); return -1; } else @@ -1225,6 +1224,23 @@ static inline int __ctsvc_vcard_append_my_profile(ctsvc_my_profile_s *my_profile return len; } +static inline int __ctsvc_vcard_append_start_vcard_3_0(char **buf, int *buf_size, int len) +{ + CTSVC_VCARD_APPEND_STR(buf, buf_size, len, "BEGIN:VCARD"); + CTSVC_VCARD_APPEND_STR(buf, buf_size, len, CTSVC_CRLF); + CTSVC_VCARD_APPEND_STR(buf, buf_size, len, "VERSION:3.0"); + CTSVC_VCARD_APPEND_STR(buf, buf_size, len, CTSVC_CRLF); + return len; +} + +static inline int __ctsvc_vcard_append_end_vcard(char **buf, int *buf_size, int len) +{ + CTSVC_VCARD_APPEND_STR(buf, buf_size, len, "END:VCARD"); + CTSVC_VCARD_APPEND_STR(buf, buf_size, len, CTSVC_CRLF); + return len; +} + + static int __ctsvc_vcard_make(ctsvc_contact_s *contact, char **vcard_stream) { char *buf = NULL; @@ -1234,11 +1250,12 @@ static int __ctsvc_vcard_make(ctsvc_contact_s *contact, char **vcard_stream) __ctsvc_vcard_initial(); buf = calloc(1, buf_size); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, "BEGIN:VCARD"); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, CTSVC_CRLF); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, "VERSION:3.0"); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, CTSVC_CRLF); + len = __ctsvc_vcard_append_start_vcard_3_0(&buf, &buf_size, len); + if (len < 0) { + free(buf); + return CONTACTS_ERROR_INTERNAL; + } len = __ctsvc_vcard_append_contact(contact, &buf, &buf_size, len); if (len < 0) { @@ -1247,8 +1264,11 @@ static int __ctsvc_vcard_make(ctsvc_contact_s *contact, char **vcard_stream) } - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, "END:VCARD"); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, CTSVC_CRLF); + len = __ctsvc_vcard_append_end_vcard(&buf, &buf_size, len); + if (len < 0) { + free(buf); + return CONTACTS_ERROR_INTERNAL; + } len = __ctsvc_vcard_add_folding(&buf, &buf_size, len); if (len < 0) { @@ -1269,11 +1289,11 @@ static int __ctsvc_vcard_make_from_my_profile(ctsvc_my_profile_s *my_profile, ch __ctsvc_vcard_initial(); buf = calloc(1, buf_size); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, "BEGIN:VCARD"); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, CTSVC_CRLF); - - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, "VERSION:3.0"); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, CTSVC_CRLF); + len = __ctsvc_vcard_append_start_vcard_3_0(&buf, &buf_size, len); + if (len < 0) { + free(buf); + return CONTACTS_ERROR_INTERNAL; + } len = __ctsvc_vcard_append_my_profile(my_profile, &buf, &buf_size, len); if (len < 0) { @@ -1281,8 +1301,11 @@ static int __ctsvc_vcard_make_from_my_profile(ctsvc_my_profile_s *my_profile, ch return CONTACTS_ERROR_INTERNAL; } - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, "END:VCARD"); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, CTSVC_CRLF); + len = __ctsvc_vcard_append_end_vcard(&buf, &buf_size, len); + if (len < 0) { + free(buf); + return CONTACTS_ERROR_INTERNAL; + } len = __ctsvc_vcard_add_folding(&buf, &buf_size, len); if (len < 0) { @@ -1476,7 +1499,7 @@ static int __ctsvc_vcard_append_person(ctsvc_person_s *person, ctsvc_list_s *lis static int __ctsvc_vcard_make_from_person(ctsvc_person_s *person, ctsvc_list_s *list_contacts, char **vcard_stream) { - int ret; + int ret = CONTACTS_ERROR_NONE; char *buf = NULL; int buf_size = VCARD_INIT_LENGTH; int len = 0; @@ -1487,25 +1510,27 @@ static int __ctsvc_vcard_make_from_person(ctsvc_person_s *person, ctsvc_list_s * __ctsvc_vcard_initial(); buf = calloc(1, buf_size); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, "BEGIN:VCARD"); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, CTSVC_CRLF); - - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, "VERSION:3.0"); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, CTSVC_CRLF); + len = __ctsvc_vcard_append_start_vcard_3_0(&buf, &buf_size, len); + if (len < 0) { + free(buf); + return CONTACTS_ERROR_INTERNAL; + } len = __ctsvc_vcard_append_person(person, list_contacts, &buf, &buf_size, len); if (len < 0) { free(buf); return CONTACTS_ERROR_INTERNAL; } - - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, "END:VCARD"); - CTSVC_VCARD_APPEND_STR(&buf, &buf_size, len, CTSVC_CRLF); + len = __ctsvc_vcard_append_end_vcard(&buf, &buf_size, len); + if (len < 0) { + free(buf); + return CONTACTS_ERROR_INTERNAL; + } len = __ctsvc_vcard_add_folding(&buf, &buf_size, len); if (len < 0) { free(buf); - return ret; + return CONTACTS_ERROR_INTERNAL; } *vcard_stream = buf; @@ -2040,27 +2065,33 @@ static inline int __ctsvc_vcard_get_phonetic_last_name(ctsvc_list_s *name_list, static inline int __ctsvc_vcard_get_nickname(ctsvc_list_s *nickname_list, char *val) { - int ret; + int ret = CONTACTS_ERROR_NONE; char *temp; char *start; const char *separator = ","; - contacts_record_h nickname; start = __ctsvc_get_content_value(val); RETV_IF(NULL == start, CONTACTS_ERROR_NO_DATA); - ret = contacts_record_create(_contacts_nickname._uri, &nickname); - RETVM_IF(ret < CONTACTS_ERROR_NONE, ret, "contacts_record_create is failed(%d)", ret); - temp = strtok(start, separator); while (temp) { if ('\0' == *temp) continue; - contacts_record_create(_contacts_nickname._uri, &nickname); - if (nickname) { - contacts_record_set_str(nickname, _contacts_nickname.name, temp); - contacts_list_add((contacts_list_h)nickname_list, nickname); - } + contacts_record_h nickname = NULL; + ret = contacts_record_create(_contacts_nickname._uri, &nickname); + if (ret < CONTACTS_ERROR_NONE) { + GList *cursor = NULL; + CTS_ERR("contacts_record_create is failed(%d)", ret); + for(cursor = nickname_list->records;cursor;cursor=cursor->next) + contacts_record_destroy((contacts_record_h)(cursor->data), true); + g_list_free(nickname_list->records); + nickname_list->records = NULL; + nickname_list->cursor = NULL; + nickname_list->count = 0; + return ret; + } + contacts_record_set_str(nickname, _contacts_nickname.name, temp); + contacts_list_add((contacts_list_h)nickname_list, nickname); temp = strtok(NULL, separator); } diff --git a/common/ipc/ctsvc_ipc_contact.c b/common/ipc/ctsvc_ipc_contact.c index 702c77b..e25599a 100644 --- a/common/ipc/ctsvc_ipc_contact.c +++ b/common/ipc/ctsvc_ipc_contact.c @@ -35,6 +35,7 @@ static int __ctsvc_ipc_unmarshal_contact(pims_ipc_data_h ipc_data, const char* v if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->reverse_display_name) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->display_source_type) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->display_name_language) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->reverse_display_name_language) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->sort_name) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->reverse_sort_name) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->sortkey) != CONTACTS_ERROR_NONE) break; @@ -89,6 +90,7 @@ static int __ctsvc_ipc_marshal_contact(const contacts_record_h record, pims_ipc_ if (ctsvc_ipc_marshal_string((pcontact->reverse_display_name),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_int((pcontact->display_source_type),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_int((pcontact->display_name_language),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_int((pcontact->reverse_display_name_language),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((pcontact->sort_name),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((pcontact->reverse_sort_name),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((pcontact->sortkey),ipc_data) != CONTACTS_ERROR_NONE) break; diff --git a/common/ipc/ctsvc_ipc_marshal.c b/common/ipc/ctsvc_ipc_marshal.c index edf0b59..d2d16d9 100644 --- a/common/ipc/ctsvc_ipc_marshal.c +++ b/common/ipc/ctsvc_ipc_marshal.c @@ -474,30 +474,36 @@ static int __ctsvc_ipc_marshal_attribute_filter(const ctsvc_attribute_filter_s* int ctsvc_ipc_unmarshal_record(const pims_ipc_data_h ipc_data, contacts_record_h* precord) { int ret = CONTACTS_ERROR_NONE; - ctsvc_record_s common = {0,}; ctsvc_record_s *precord_common = NULL; + ctsvc_ipc_marshal_record_plugin_cb_s *plugin_cb; - if (ctsvc_ipc_unmarshal_record_common(ipc_data, &common) != CONTACTS_ERROR_NONE) - { + RETVM_IF( NULL == precord || NULL == ipc_data, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter"); + + if (ctsvc_ipc_unmarshal_record_common(ipc_data, &common) != CONTACTS_ERROR_NONE) { CTS_ERR("ctsvc_ipc_unmarshal_common fail"); return CONTACTS_ERROR_INVALID_PARAMETER; } - RETVM_IF( NULL == precord || NULL == ipc_data, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter"); + plugin_cb = __ctsvc_ipc_marshal_get_plugin_cb(common.r_type); + if (NULL == plugin_cb || NULL == plugin_cb->unmarshal_record) { + CTS_ERR("Invalid parameter"); + free(common.properties_flags); + return CONTACTS_ERROR_INVALID_PARAMETER; + } ret = contacts_record_create(common.view_uri, precord); - RETVM_IF(ret != CONTACTS_ERROR_NONE, ret, "create activity record fail"); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("create activity record fail"); + free(common.properties_flags); + return ret; + } precord_common = (ctsvc_record_s *)(*precord); precord_common->property_max_count = common.property_max_count; precord_common->properties_flags = common.properties_flags; precord_common->property_flag = common.property_flag; - ctsvc_ipc_marshal_record_plugin_cb_s *plugin_cb = __ctsvc_ipc_marshal_get_plugin_cb(common.r_type); - - RETVM_IF(NULL == plugin_cb || NULL == plugin_cb->unmarshal_record, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter"); - ret = plugin_cb->unmarshal_record(ipc_data, common.view_uri, *precord); if( CONTACTS_ERROR_NONE != ret ) { diff --git a/contacts-service2.manifest b/contacts-service2.manifest index 4ff2437..7543246 100644 --- a/contacts-service2.manifest +++ b/contacts-service2.manifest @@ -10,9 +10,9 @@ - + - + diff --git a/include/contacts.h b/include/contacts.h index 14dd0d2..d9de6cf 100644 --- a/include/contacts.h +++ b/include/contacts.h @@ -959,7 +959,7 @@ * string app_id read, write * string uri read, write * string catagory read, write - * string extra_data read, write + * string extra_data read, write It includes "key:value" pair. You should parse it. * * * @section CAPI_SOCIAL_CONTACTS_SVC_VIEW_MODULE_contacts_activity _contacts_activity view diff --git a/include/contacts_db.h b/include/contacts_db.h index da37a4f..b06c9e7 100755 --- a/include/contacts_db.h +++ b/include/contacts_db.h @@ -468,9 +468,56 @@ API int contacts_db_remove_changed_cb( const char* view_uri, contacts_db_changed #ifndef _CONTACTS_NATIVE +/** + * @brief Called when designated view changes. + * + * @param[in] view_uri The view uri, now support only _contacts_person and _contacts_phone_log + * @param[in] changes It includes changes information ("type:id," string is repeated. You should parse it) + * @param[in] user_data The user data passed from the callback registration function + * + * @see contacts_db_add_changed_cb_with_info() + */ + typedef void (*contacts_db_change_cb_with_info)(const char* view_uri, char *changes, void* user_data); +/** + * @brief Registers a callback function. + * + * @param[in] view_uri The view URI of record to subscribe to changing notifications + * @param[in] callback The callback function to register + * @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 + * + * @pre This function requires an open connection to the contacts service by contacts_connect2(). + * + * @see contacts_connect2() + * @see contacts_db_changed_cb_with_info() + * @see contacts_db_remove_changed_cb_with_info() + */ + API int contacts_db_add_changed_cb_with_info(const char* view_uri, contacts_db_change_cb_with_info callback, void* user_data); + +/** + * @brief Unregisters a callback function. + * + * @param[in] view_uri The view URI of record to subscribe to changing notifications + * @param[in] callback The callback function to register + * @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 + * + * @pre This function requires an open connection to the contacts service by contacts_connect2(). + * + * @see contacts_connect2() + * @see contacts_db_changed_cb_with_info() + * @see contacts_db_add_changed_cb_with_info() + */ + API int contacts_db_remove_changed_cb_with_info(const char* view_uri, contacts_db_change_cb_with_info callback, void* user_data); #endif diff --git a/include/contacts_utils.h b/include/contacts_utils.h index 8ba7609..9757b20 100644 --- a/include/contacts_utils.h +++ b/include/contacts_utils.h @@ -44,29 +44,6 @@ extern "C" */ API int contacts_utils_get_index_characters(char **index_string); -/** - * This function compares compares two strings which is not normalized. - * If search_str is included in str, this function return #sCONTACTS_ERROR_NONE. \n - * The behavior of this function cannot fix because of localization. - * So, The behavior can be different from each other. - * - * @param[in] haystack Base string. - * @param[in] needle searching string - * @param[out] len substring length - * @return a position of the beginning of the substring, Negative value(#cts_error) on error or difference. - * @par example - * @code - ret = contacts_strstr(str1, str2, &len); - if(CONTACTS_ERROR_NONE == ret) { - snprintf(first, ret+1, "%s", item_data->display); - snprintf(middle, len+1, "%s", item_data->display + ret); - printf("%s -> %s, %s, %s", item_data->display, first, middle, item_data->display + ret + len); - } else - printf("str1 doesn't has str2"); - * @endcode - */ -API int contacts_utils_strstr(const char *haystack, const char *needle, int *len); - /** * @} */ diff --git a/native/ctsvc_db_init.c b/native/ctsvc_db_init.c index 707522f..01f392d 100644 --- a/native/ctsvc_db_init.c +++ b/native/ctsvc_db_init.c @@ -260,6 +260,7 @@ static int __ctsvc_db_create_views() "SELECT persons.person_id, " "display_name, reverse_display_name, " "display_name_language, " + "reverse_display_name_language, " "sort_name, reverse_sort_name, " "sortkey, reverse_sortkey, " "name_contact_id, " @@ -565,6 +566,7 @@ static int __ctsvc_db_create_views() "SELECT persons.person_id, " "name_contacts.display_name, name_contacts.reverse_display_name, " "name_contacts.display_name_language, " + "name_contacts.reverse_display_name_language, " "name_contacts.sort_name, name_contacts.reverse_sort_name, " "name_contacts.sortkey, name_contacts.reverse_sortkey, " "persons.image_thumbnail_path, " @@ -677,6 +679,7 @@ static int __ctsvc_db_create_views() "SELECT C.id phonelog_id, " "F.display_name, F.reverse_display_name, " "F.display_name_language, " + "F.reverse_display_name_language, " "F.sort_name, F.reverse_sort_name, " "F.sortkey, F.reverse_sortkey, " "F.image_thumbnail_path, " @@ -706,6 +709,7 @@ static int __ctsvc_db_create_views() "GROUP BY A.id) C " "LEFT JOIN (SELECT D.person_id, D.display_name, D.reverse_display_name, " "D.display_name_language, " + "D.reverse_display_name_language, " "D.sort_name, D.reverse_sort_name, " "D.sortkey, D.reverse_sortkey, " "E.image_thumbnail_path " @@ -796,6 +800,7 @@ static int __ctsvc_db_create_views() "A.display_name_source, " "A.reverse_display_name, " "A.display_name_language, " + "A.reverse_display_name_language, " "A.sort_name, A.reverse_sort_name, " "A.sortkey, A.reverse_sortkey, " "A.addressbook_id, " diff --git a/native/ctsvc_db_plugin_contact.c b/native/ctsvc_db_plugin_contact.c index b5d8cdb..be785df 100644 --- a/native/ctsvc_db_plugin_contact.c +++ b/native/ctsvc_db_plugin_contact.c @@ -1218,9 +1218,10 @@ static int __ctsvc_db_contact_update_record( contacts_record_h record ) version, (int)time(NULL), contact->has_phonenumber, contact->has_email); if (ctsvc_record_check_property_flag((ctsvc_record_s *)contact, _contacts_contact.display_name, CTSVC_PROPERTY_FLAG_DIRTY)) { len += snprintf(query_set+len, sizeof(query_set)-len, - ", display_name=?, reverse_display_name=?, display_name_source=%d, display_name_language=%d, " + ", display_name=?, reverse_display_name=?, display_name_source=%d, " + "display_name_language=%d, reverse_display_name_language=%d, " "sort_name=?, reverse_sort_name=?, sortkey=?, reverse_sortkey=?", - contact->display_source_type, contact->display_name_language); + contact->display_source_type, contact->display_name_language, contact->reverse_display_name_language); bind_text = g_slist_append(bind_text, strdup(SAFE_STR(contact->display_name))); bind_text = g_slist_append(bind_text, strdup(SAFE_STR(contact->reverse_display_name))); bind_text = g_slist_append(bind_text, strdup(SAFE_STR(contact->sort_name))); @@ -1915,14 +1916,15 @@ static int __ctsvc_db_contact_insert_record( contacts_record_h record, int *id) snprintf(query, sizeof(query), "INSERT INTO "CTS_TABLE_CONTACTS"(contact_id, person_id, addressbook_id, is_favorite, " "created_ver, changed_ver, changed_time, image_changed_ver, has_phonenumber, has_email, " - "display_name, reverse_display_name, display_name_source, display_name_language, " + "display_name, reverse_display_name, display_name_source, " + "display_name_language, reverse_display_name_language, " "sort_name, reverse_sort_name, " "sortkey, reverse_sortkey, " "uid, ringtone_path, vibration, image_thumbnail_path) " - "VALUES(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, ?, ?, %d, %d, ?, ?, ?, ?, ?, ?, ?, ?)", + "VALUES(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, ?, ?, %d, %d, %d, ?, ?, ?, ?, ?, ?, ?, ?)", contact->id, contact->person_id, contact->addressbook_id, contact->is_favorite, version, version, (int)time(NULL), (NULL !=contact->image_thumbnail_path)?version:0, contact->has_phonenumber, contact->has_email, - contact->display_source_type, contact->display_name_language); + contact->display_source_type, contact->display_name_language, contact->reverse_display_name_language); stmt = cts_query_prepare(query); if (NULL == stmt) { @@ -2100,13 +2102,15 @@ static int __ctsvc_db_contact_replace_record( contacts_record_h record, int cont len = snprintf(query, sizeof(query), "UPDATE "CTS_TABLE_CONTACTS" SET changed_ver=%d, changed_time=%d, " "has_phonenumber=%d, has_email=%d , display_name=?, " - "reverse_display_name=?, display_name_source=%d, display_name_language=%d, " + "reverse_display_name=?, display_name_source=%d, " + "display_name_language=%d, reverse_display_name_language=%d, " "sort_name=?, reverse_sort_name=?, " "sortkey=?, reverse_sortkey=?, uid=?, ringtone_path=?, vibration=?, " "image_thumbnail_path=?", version, (int)time(NULL), contact->has_phonenumber, contact->has_email, - contact->display_source_type, contact->display_name_language); + contact->display_source_type, + contact->display_name_language, contact->reverse_display_name_language); if (ctsvc_record_check_property_flag((ctsvc_record_s *)contact, _contacts_contact.image_thumbnail_path, CTSVC_PROPERTY_FLAG_DIRTY)) len += snprintf(query+len, sizeof(query)-len, ", image_changed_ver = %d", version); diff --git a/native/ctsvc_db_plugin_contact_helper.c b/native/ctsvc_db_plugin_contact_helper.c index 7c98892..95064fc 100644 --- a/native/ctsvc_db_plugin_contact_helper.c +++ b/native/ctsvc_db_plugin_contact_helper.c @@ -272,6 +272,7 @@ void ctsvc_make_contact_display_name(ctsvc_contact_s *contact) contact->reverse_display_name = NULL; contact->display_name_language = CTSVC_SORT_OTHERS; + contact->reverse_display_name_language = CTSVC_SORT_OTHERS; if ( contact->name->count > 0 && contact->name->records != NULL && contact->name->records->data != NULL ) { @@ -317,6 +318,7 @@ void ctsvc_make_contact_display_name(ctsvc_contact_s *contact) contact->display_name = display; + display_len += 1; // "," // make reverse_display_name display = calloc(1, display_len); len = 0; @@ -447,7 +449,6 @@ void ctsvc_make_contact_display_name(ctsvc_contact_s *contact) if (phonetic && ctsvc_get_name_sort_type(phonetic) == CTSVC_SORT_JAPANESE) { ret = CTSVC_SORT_JAPANESE; FREEandSTRDUP(contact->sort_name, phonetic); - FREEandSTRDUP(contact->reverse_sort_name, phonetic); } else { { @@ -456,18 +457,17 @@ void ctsvc_make_contact_display_name(ctsvc_contact_s *contact) if (ctsvc_convert_chinese_to_pinyin(contact->display_name, &pinyinname, &size) == CONTACTS_ERROR_NONE) { FREEandSTRDUP(contact->sort_name, pinyinname[0].pinyin_name); - FREEandSTRDUP(contact->reverse_sort_name, pinyinname[0].pinyin_name); free(pinyinname); } ret = CTSVC_SORT_WESTERN; } } free(phonetic); + phonetic = NULL; break; case CTSVC_SORT_JAPANESE: { ctsvc_convert_japanese_to_hiragana(contact->display_name, &contact->sort_name); - ctsvc_convert_japanese_to_hiragana(contact->reverse_display_name, &contact->reverse_sort_name); break; } } @@ -479,6 +479,63 @@ void ctsvc_make_contact_display_name(ctsvc_contact_s *contact) else contact->display_name_language = ret; + // check reverse sort_name, reverser_display_name_language + ret = ctsvc_get_name_sort_type(contact->reverse_display_name); + WARN_IF( ret < 0, "ctsvc_check_language_type Failed(%d)", ret); + switch (ret) + { + case CTSVC_SORT_CJK: + if (contact->display_source_type == CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NAME) { + len = SAFE_STRLEN(name->phonetic_first) + SAFE_STRLEN(name->phonetic_last) + SAFE_STRLEN(name->phonetic_middle); + if (len > 0) { + len += 3; // for space and null string + phonetic = calloc(1, len); + if (name->phonetic_last) + temp_len += snprintf(phonetic, len, "%s", name->phonetic_last); + if (name->phonetic_middle) { + if (temp_len) + temp_len += snprintf(phonetic + temp_len, len - temp_len, " "); + temp_len += snprintf(phonetic + temp_len, len - temp_len, "%s", name->phonetic_middle); + } + if (name->phonetic_first) { + if (temp_len) + temp_len += snprintf(phonetic + temp_len, len - temp_len, " "); + temp_len += snprintf(phonetic + temp_len, len - temp_len, "%s", name->phonetic_first); + } + } + } + + if (phonetic && ctsvc_get_name_sort_type(phonetic) == CTSVC_SORT_JAPANESE) { + ret = CTSVC_SORT_JAPANESE; + FREEandSTRDUP(contact->reverse_sort_name, phonetic); + } + else { + pinyin_name_s *pinyinname = NULL; + int size; + + if (ctsvc_convert_chinese_to_pinyin(contact->reverse_display_name, &pinyinname, &size) == CONTACTS_ERROR_NONE) { + FREEandSTRDUP(contact->reverse_sort_name, pinyinname[0].pinyin_name); + free(pinyinname); + } + ret = CTSVC_SORT_WESTERN; + } + free(phonetic); + phonetic = NULL; + break; + case CTSVC_SORT_JAPANESE: + { + ctsvc_convert_japanese_to_hiragana(contact->reverse_display_name, &contact->reverse_sort_name); + break; + } + } + + if (ctsvc_get_default_language() == ret) + contact->reverse_display_name_language = CTSVC_SORT_PRIMARY; + else if (ctsvc_get_secondary_language() == ret) + contact->reverse_display_name_language = CTSVC_SORT_SECONDARY; + else + contact->reverse_display_name_language = ret; + ret = ctsvc_collation_str(contact->sort_name, &sortkey); if (CONTACTS_ERROR_NONE == ret) contact->sortkey = sortkey; @@ -1719,9 +1776,11 @@ int ctsvc_contact_update_display_name(int contact_id, contacts_display_name_sour ctsvc_make_contact_display_name(contact); snprintf(query, sizeof(query), "UPDATE "CTS_TABLE_CONTACTS" SET " - "display_name=?, reverse_display_name=?, display_name_source=%d, display_name_language=%d, " + "display_name=?, reverse_display_name=?, display_name_source=%d, " + "display_name_language=%d, reverse_display_name_language=%d, " "sort_name=?, reverse_sort_name=?, sortkey=?, reverse_sortkey=? " - "WHERE contact_id=%d", contact->display_source_type, contact->display_name_language, contact_id); + "WHERE contact_id=%d", contact->display_source_type, + contact->display_name_language, contact->reverse_display_name_language, contact_id); stmt = cts_query_prepare(query); if (NULL == stmt) { diff --git a/native/ctsvc_db_plugin_group.c b/native/ctsvc_db_plugin_group.c index a73d7b7..056240d 100644 --- a/native/ctsvc_db_plugin_group.c +++ b/native/ctsvc_db_plugin_group.c @@ -227,7 +227,10 @@ static int __ctsvc_db_group_update_record( contacts_record_h record ) ret = ctsvc_change_image(CTS_GROUP_IMAGE_LOCATION, group->id, group->image_thumbnail_path, image, sizeof(image)); if (*image) { free(group->image_thumbnail_path); - group->image_thumbnail_path = strdup(image); + if (strstr(image, CTS_GROUP_IMAGE_LOCATION) != NULL) + group->image_thumbnail_path = strdup(image + strlen(CTS_GROUP_IMAGE_LOCATION) + 1); + else + group->image_thumbnail_path = strdup(image); } } diff --git a/native/ctsvc_db_plugin_person.c b/native/ctsvc_db_plugin_person.c index a5faaa8..1682393 100644 --- a/native/ctsvc_db_plugin_person.c +++ b/native/ctsvc_db_plugin_person.c @@ -232,7 +232,6 @@ static int __ctsvc_db_person_update_record( contacts_record_h record ) cts_stmt_finalize(stmt); } while (0); - if (CONTACTS_ERROR_NONE != ret) { ctsvc_end_trans(false); CTSVC_RECORD_RESET_PROPERTY_FLAGS((ctsvc_record_s *)record); diff --git a/native/ctsvc_db_plugin_person_helper.c b/native/ctsvc_db_plugin_person_helper.c index 92ebaf2..4db3cf9 100755 --- a/native/ctsvc_db_plugin_person_helper.c +++ b/native/ctsvc_db_plugin_person_helper.c @@ -22,6 +22,7 @@ #include "ctsvc_schema.h" #include "ctsvc_sqlite.h" #include "ctsvc_db_plugin_person_helper.h" +#include "ctsvc_localize.h" #include "ctsvc_normalize.h" #include "ctsvc_db_init.h" #include "ctsvc_utils.h" @@ -573,26 +574,34 @@ void ctsvc_db_normalize_str_callback(sqlite3_context * context, int argc, sqlite3_value ** argv) { const char *display_name; + int display_name_language = CTSVC_LANG_OTHERS; if (argc < 1) { sqlite3_result_null(context); return; } - display_name = (const char *)sqlite3_value_text(argv[0]); - if (display_name) { - int ret; - char *dest = NULL; - ret = ctsvc_normalize_index(display_name, &dest); - if (ret < CONTACTS_ERROR_NONE) { - CTS_ERR("ctsvc_normalize_index() Failed(%d)", ret); - sqlite3_result_null(context); + display_name_language = sqlite3_value_int(argv[1]); + if (display_name_language == CTSVC_SORT_OTHERS || display_name_language == CTSVC_SORT_NUMBER) { + sqlite3_result_text(context, "#", 1, SQLITE_TRANSIENT); + return; + } + else { + display_name = (const char *)sqlite3_value_text(argv[0]); + if (display_name) { + int ret; + char *dest = NULL; + ret = ctsvc_normalize_index(display_name, &dest); + if (ret < CONTACTS_ERROR_NONE) { + CTS_ERR("ctsvc_normalize_index() Failed(%d)", ret); + sqlite3_result_null(context); + return; + } + CTS_VERBOSE("normalize index : %s, %s", display_name, dest); + sqlite3_result_text(context, dest, strlen(dest), SQLITE_TRANSIENT); + free(dest); return; } - CTS_VERBOSE("normalize index : %s, %s", display_name, dest); - sqlite3_result_text(context, dest, strlen(dest), SQLITE_TRANSIENT); - free(dest); - return; } sqlite3_result_null(context); diff --git a/native/ctsvc_db_plugin_phonelog.c b/native/ctsvc_db_plugin_phonelog.c index 18963d1..6af9076 100644 --- a/native/ctsvc_db_plugin_phonelog.c +++ b/native/ctsvc_db_plugin_phonelog.c @@ -463,30 +463,37 @@ static int __ctsvc_db_phonelog_insert_record( contacts_record_h record, int *id ctsvc_change_subject_add_changed_phone_log_id(CONTACTS_CHANGE_INSERTED, *id); #endif ret = ctsvc_end_trans(true); - - // set missed call Badge number to Apptray - if(phonelog-> log_type == CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN || phonelog-> log_type == CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN) { - - #define PHONE_PACKAGE_NAME "org.tizen.phone" - unsigned int call_cnt = 0; - bool bBadgeExist = FALSE; - - badge_is_existing(PHONE_PACKAGE_NAME, &bBadgeExist); - if(bBadgeExist == FALSE) - badge_create(PHONE_PACKAGE_NAME, PHONE_PACKAGE_NAME); - - badge_get_count(PHONE_PACKAGE_NAME, &call_cnt); - call_cnt++; - badge_set_count(PHONE_PACKAGE_NAME, call_cnt); - } - - if (ret < CONTACTS_ERROR_NONE) { CTS_ERR("DB error : ctsvc_end_trans() Failed(%d)", ret); return ret; } else + { + // set missed call Badge number to Apptray + if(phonelog-> log_type == CONTACTS_PLOG_TYPE_VOICE_INCOMMING_UNSEEN || phonelog-> log_type == CONTACTS_PLOG_TYPE_VIDEO_INCOMMING_UNSEEN) { + + #define PHONE_PACKAGE_NAME "org.tizen.phone" + unsigned int call_cnt = 0; + bool bBadgeExist = FALSE; + + badge_is_existing(PHONE_PACKAGE_NAME, &bBadgeExist); + if(bBadgeExist == FALSE) + { + badge_error_e err = BADGE_ERROR_NONE; + err = badge_create(PHONE_PACKAGE_NAME, PHONE_PACKAGE_NAME); + if(err != BADGE_ERROR_NONE) + { + CTS_ERR("Fail to badge_create : %d", err); + return CONTACTS_ERROR_NONE; // ignore badge error + } + } + + badge_get_count(PHONE_PACKAGE_NAME, &call_cnt); + call_cnt++; + badge_set_count(PHONE_PACKAGE_NAME, call_cnt); + } return CONTACTS_ERROR_NONE; + } } diff --git a/native/ctsvc_db_plugin_profile_helper.c b/native/ctsvc_db_plugin_profile_helper.c index e00cab0..5749f19 100644 --- a/native/ctsvc_db_plugin_profile_helper.c +++ b/native/ctsvc_db_plugin_profile_helper.c @@ -96,7 +96,7 @@ int ctsvc_db_profile_insert(contacts_record_h record, int contact_id, bool is_my char query[CTS_SQL_MAX_LEN] = {0}; ctsvc_profile_s *profile = (ctsvc_profile_s *)record; - RETV_IF(NULL == profile->service_operation, CONTACTS_ERROR_NONE); + RETV_IF(NULL == profile->text, CONTACTS_ERROR_NONE); RETVM_IF(contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter : contact_id(%d) is mandatory field to insert profile record ", profile->contact_id); RETVM_IF(0 < profile->id, CONTACTS_ERROR_INVALID_PARAMETER, diff --git a/native/ctsvc_db_query.c b/native/ctsvc_db_query.c index 6bcb479..ce655f0 100755 --- a/native/ctsvc_db_query.c +++ b/native/ctsvc_db_query.c @@ -597,7 +597,7 @@ int ctsvc_db_make_get_records_query_stmt(ctsvc_query_s *s_query, int offset, int ret = __ctsvc_db_create_projection(s_query->properties, s_query->property_count, s_query->projection, s_query->projection_count, &projection); if (CONTACTS_ERROR_NONE != ret) { - CTS_ERR("__ctsvc_db_create_projection is failed(%s)", ret); + CTS_ERR("__ctsvc_db_create_projection is failed(%d)", ret); return ret; } @@ -822,7 +822,7 @@ static int __ctsvc_db_get_all_records( const char* view_uri, int offset, int lim const property_info_s *p = ctsvc_view_get_all_property_infos(view_uri, &count); ret = __ctsvc_db_create_projection(p, count, NULL, 0, &projection); - RETVM_IF (CONTACTS_ERROR_NONE != ret, ret, "__ctsvc_db_create_projection is failed(%s)", ret); + RETVM_IF (CONTACTS_ERROR_NONE != ret, ret, "__ctsvc_db_create_projection is failed(%d)", ret); ret = __ctsvc_db_get_all_records_exec(view_uri, p, count, projection, offset, limit, out_list); free(projection); @@ -956,7 +956,7 @@ static int __ctsvc_db_search_records_exec(const char *view_uri, const property_i projection, table); len += __ctsvc_db_append_search_query(keyword, query + len, sizeof(query) - len); len += snprintf(query + len, sizeof(query) - len, " GROUP BY person_id_in_contact) temp_contacts " - "ON %s.person_id = temp_contacts.person_id_in_contact", table); + "ON %s.person_id = temp_contacts.person_id_in_contact", table); } /* len += snprintf(query+len, sizeof(query)-len, "FROM %s, %s " @@ -1469,7 +1469,7 @@ static int __ctsvc_db_update_records( contacts_list_h list) ctsvc_end_trans(false); return ret; } - }while(CONTACTS_ERROR_NONE == contacts_list_next(list)); + }while(CONTACTS_ERROR_NONE == contacts_list_next(list)); ret = ctsvc_end_trans(true); if (ret < CONTACTS_ERROR_NONE) { @@ -1596,7 +1596,7 @@ static int __ctsvc_db_get_count_with_query( contacts_query_h query, int *out_cou ret = __ctsvc_db_create_projection(query_s->properties, query_s->property_count, query_s->projection, query_s->projection_count, &projection); if (CONTACTS_ERROR_NONE != ret) { - CTS_ERR("__ctsvc_db_create_projection is failed(%s)", ret); + CTS_ERR("__ctsvc_db_create_projection is failed(%d)", ret); for (cursor=bind_text;cursor;cursor=cursor->next) free(cursor->data); g_slist_free(bind_text); diff --git a/native/ctsvc_notification.c b/native/ctsvc_notification.c index 31805f7..e14ced0 100644 --- a/native/ctsvc_notification.c +++ b/native/ctsvc_notification.c @@ -125,15 +125,6 @@ static inline void __ctsvc_noti_publish_person_change(void) } } -static inline void __ctsvc_noti_publish_simple_contact_change(void) -{ - int fd = open(CTSVC_NOTI_SIMPLE_CONTACT_CHANGED, O_TRUNC | O_RDWR); - if (0 <= fd) { - close(fd); - contact_change = false; - } -} - static inline void __ctsvc_noti_publish_name_change(void) { int fd = open(CTSVC_NOTI_NAME_CHANGED, O_TRUNC | O_RDWR); diff --git a/native/ctsvc_person.c b/native/ctsvc_person.c index e01515c..3b1e260 100644 --- a/native/ctsvc_person.c +++ b/native/ctsvc_person.c @@ -30,8 +30,6 @@ #include "ctsvc_server_change_subject.h" #endif -#define DISPLAY_ACCOUNT_MAX 3 - enum { CTSVC_GET_PERSON_DEFAULT_NUMBER_VALUE, CTSVC_GET_PERSON_DEFAULT_EMAIL_VALUE, @@ -491,7 +489,6 @@ int ctsvc_person_aggregate(int person_id) int version; int link_count; int id = 0; - int account_ids[DISPLAY_ACCOUNT_MAX] = {0}; char *addressbook_ids = NULL; int addressbooks_len = 100; int name_contact_id = 0; @@ -572,12 +569,11 @@ int ctsvc_person_aggregate(int person_id) snprintf(query, sizeof(query), "SELECT contact_id, contacts.addressbook_id, %s, display_name_source, " - "image_thumbnail_path, ringtone_path, vibration, account_id, is_favorite " - "FROM %s, %s " - "ON contacts.addressbook_id = addressbooks.addressbook_id AND contacts.deleted = 0 " - "WHERE person_id = %d " + "image_thumbnail_path, ringtone_path, vibration, is_favorite " + "FROM %s " + "WHERE person_id = %d AND contacts.deleted = 0 " "ORDER BY contact_id", - ctsvc_get_display_column(), CTS_TABLE_CONTACTS, CTS_TABLE_ADDRESSBOOKS, person_id); + ctsvc_get_display_column(), CTS_TABLE_CONTACTS, person_id); stmt = cts_query_prepare(query); if (NULL == stmt) { ERR("DB error : cts_query_prepare() Failed"); @@ -591,7 +587,6 @@ int ctsvc_person_aggregate(int person_id) while ((ret = cts_stmt_step(stmt))) { const char *temp_str; int i = 0; - int account_id; int contact_id; int addressbook_id; int contact_display_name_source_type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID; @@ -615,29 +610,18 @@ int ctsvc_person_aggregate(int person_id) contact_ringtone_path = SAFE_STRDUP(temp); temp = ctsvc_stmt_get_text(stmt, i++); contact_vibration = SAFE_STRDUP(temp); - account_id = ctsvc_stmt_get_int(stmt, i++); is_favorite = ctsvc_stmt_get_int(stmt, i++); link_count++; - for( i=0; i display_name_source_type) { display_name_source_type = contact_display_name_source_type; name_contact_id = contact_id; } else if (contact_display_name_source_type == display_name_source_type){ - if (name_contact_id != person_name_contact_id) + if (name_contact_id != person_name_contact_id && person_name_contact_id != 0) name_contact_id = person_name_contact_id; } - addr_len = snprintf(addr, sizeof(addr), "%d ", addressbook_id); if (NULL == addressbook_ids) addressbook_ids = calloc(addressbooks_len, sizeof(char)); @@ -675,11 +659,10 @@ int ctsvc_person_aggregate(int person_id) "WHERE person_id = %d AND has_phonenumber = 1 AND deleted = 0), " "has_email = EXISTS(SELECT contact_id FROM "CTS_TABLE_CONTACTS" " "WHERE person_id = %d AND has_email = 1 AND deleted = 0), " - "link_count = %d, account_id1 = %d, account_id2 = %d, account_id3 = %d, " - "addressbook_ids = ?, ringtone_path=?, vibration=?, status=?, image_thumbnail_path=? " + "link_count = %d, addressbook_ids = ?, ringtone_path=?, vibration=?, status=?, image_thumbnail_path=? " "WHERE person_id = %d ", name_contact_id, version, person_id, - person_id, link_count, account_ids[0], account_ids[1], account_ids[2], person_id); + person_id, link_count, person_id); stmt = cts_query_prepare(query); if (NULL == stmt) { diff --git a/native/ctsvc_sqlite.c b/native/ctsvc_sqlite.c index 9dfff89..92d3876 100755 --- a/native/ctsvc_sqlite.c +++ b/native/ctsvc_sqlite.c @@ -72,7 +72,7 @@ int ctsvc_db_open(void) { ctsvc_db_data_company_delete_callback, NULL, NULL); RETVM_IF(SQLITE_OK != ret, CONTACTS_ERROR_DB, "sqlite3_create_function() Failed(%d)", ret); - ret = sqlite3_create_function(ctsvc_db, "_NORMALIZE_INDEX_", 1, SQLITE_UTF8, NULL, + ret = sqlite3_create_function(ctsvc_db, "_NORMALIZE_INDEX_", 2, SQLITE_UTF8, NULL, ctsvc_db_normalize_str_callback, NULL, NULL); RETVM_IF(SQLITE_OK != ret, CONTACTS_ERROR_DB, "sqlite3_create_function() Failed(%d)", ret); diff --git a/native/ctsvc_utils.c b/native/ctsvc_utils.c index 51d8b3f..574f89f 100644 --- a/native/ctsvc_utils.c +++ b/native/ctsvc_utils.c @@ -176,12 +176,11 @@ const char* ctsvc_get_sort_name_column(void) contacts_setting_get_name_sorting_order(&order); if (CONTACTS_NAME_SORTING_ORDER_FIRSTLAST == order) - return "sort_name"; + return "sort_name, display_name_language"; else - return "reverse_sort_name"; + return "reverse_sort_name, reverse_display_name_language"; } - const char* ctsvc_get_sort_column(void) { contacts_name_sorting_order_e order; @@ -190,7 +189,7 @@ const char* ctsvc_get_sort_column(void) if (CONTACTS_NAME_SORTING_ORDER_FIRSTLAST == order) return "display_name_language, sortkey"; else - return "display_name_language, reverse_sortkey"; + return "reverse_display_name_language, reverse_sortkey"; } static char* __ctsvc_get_image(const char *dir, int index, char *dest, int dest_size) @@ -458,8 +457,11 @@ int ctsvc_change_image(const char *dir, int index, const char *path, char *image char dest[CTSVC_IMG_FULL_PATH_SIZE_MAX] = {0}; if (__ctsvc_get_image(dir, index, dest, sizeof(dest))) { - if (path && 0 == strcmp(dest, path)) + if (path && 0 == strcmp(dest, path)) { + if (image) + snprintf(image, image_len, "%s", path); return CONTACTS_ERROR_NONE; + } ret = unlink(dest); RETVM_IF(ret < 0, CONTACTS_ERROR_SYSTEM, "System : unlink(%s) Failed(%d)", dest, errno); } diff --git a/packaging/contacts-service.spec b/packaging/contacts-service.spec index cb92f62..dae1c81 100644 --- a/packaging/contacts-service.spec +++ b/packaging/contacts-service.spec @@ -1,6 +1,6 @@ Name: contacts-service Summary: Contacts Service -Version: 0.9.61 +Version: 0.9.64 Release: 1 Group: TO_BE/FILLED_IN License: Apache-2.0 diff --git a/res/.CONTACTS_SVC_SIMPLE_CONTACT_CHANGED b/res/.CONTACTS_SVC_SIMPLE_CONTACT_CHANGED deleted file mode 100644 index e69de29..0000000 diff --git a/schema.sql b/schema.sql index 4e331d4..3a6017a 100755 --- a/schema.sql +++ b/schema.sql @@ -34,9 +34,6 @@ CREATE TABLE persons image_thumbnail_path TEXT, image_path TEXT, link_count INTEGER, - account_id1 INTEGER, - account_id2 INTEGER, - account_id3 INTEGER, addressbook_ids TEXT, dirty INTEGER, status TEXT @@ -82,6 +79,7 @@ CREATE TABLE contacts reverse_display_name TEXT, display_name_source INTEGER, display_name_language INTEGER, + reverse_display_name_language INTEGER, sort_name TEXT, reverse_sort_name TEXT, sortkey TEXT COLLATE NOCASE, @@ -100,7 +98,7 @@ CREATE TABLE contacts CREATE INDEX contacts_idx1 ON contacts(changed_ver); CREATE INDEX contacts_idx2 ON contacts(person_id); CREATE INDEX contacts_idx3 ON contacts(display_name_language, sortkey); -CREATE INDEX contacts_idx4 ON contacts(display_name_language, reverse_sortkey); +CREATE INDEX contacts_idx4 ON contacts(reverse_display_name_language, reverse_sortkey); -- There are three case of deleting contact logically -- Case 1 : delete contact diff --git a/server/ctsvc_server.c b/server/ctsvc_server.c index 0488aec..59aeb79 100644 --- a/server/ctsvc_server.c +++ b/server/ctsvc_server.c @@ -87,7 +87,6 @@ static int __server_main(void) /* if (pims_ipc_svc_register(CTSVC_IPC_SIM_MODULE, CTSVC_IPC_SERVER_SIM_IMPORT_ALL_CONTACTS, ctsvc_ipc_sim_import_all_contacts, NULL) != 0) break; - if (pims_ipc_svc_register(CTSVC_IPC_SIM_MODULE, CTSVC_IPC_SERVER_SIM_EXPORT_PERSON, ctsvc_ipc_sim_export_person, NULL) != 0) break; */ if (pims_ipc_svc_register(CTSVC_IPC_SIM_MODULE, CTSVC_IPC_SERVER_SIM_INSERT_CONTACT, ctsvc_ipc_sim_insert_contact, NULL) != 0) break; if (pims_ipc_svc_register(CTSVC_IPC_SIM_MODULE, CTSVC_IPC_SERVER_SIM_UPDATE_CONTACT, ctsvc_ipc_sim_update_contact, NULL) != 0) break; diff --git a/server/ctsvc_server_bg.c b/server/ctsvc_server_bg.c index 0d02a40..175ab10 100644 --- a/server/ctsvc_server_bg.c +++ b/server/ctsvc_server_bg.c @@ -78,11 +78,13 @@ static int __ctsvc_server_bg_contact_delete_step1(__ctsvc_delete_data_s* data) data->contact_ids = g_slist_append(data->contact_ids, GINT_TO_POINTER(id)); } cts_stmt_finalize(stmt); + if (ret < CONTACTS_ERROR_NONE) + return ret; } count = g_slist_length(data->contact_ids); if (count <= 0) - return CONTACTS_ERROR_DB; + return CONTACTS_ERROR_NO_DATA; cursor = g_slist_nth(data->contact_ids, 0); if (cursor) { @@ -246,8 +248,8 @@ static int __ctsvc_server_bg_contact_delete_step4(__ctsvc_delete_data_s* data) static bool __ctsvc_server_bg_contact_delete_step(int ret, __ctsvc_delete_data_s* data) { if (ret != CONTACTS_ERROR_NONE && ret != CONTACTS_ERROR_NO_DATA) { - if(data->contact_ids) - g_slist_free(data->contact_ids); + if(data->contact_ids) + g_slist_free(data->contact_ids); ERR("fail (%d)",ret); return false; } diff --git a/server/ctsvc_server_sqlite.c b/server/ctsvc_server_sqlite.c index 902ecdf..2ce6365 100755 --- a/server/ctsvc_server_sqlite.c +++ b/server/ctsvc_server_sqlite.c @@ -197,6 +197,50 @@ int ctsvc_server_update_default_language(int prev_sort_primary, int prev_sort_se return CONTACTS_ERROR_DB; } + snprintf(query, sizeof(query), "UPDATE %s SET reverse_display_name_language=%d WHERE reverse_display_name_language = %d" , + CTS_TABLE_CONTACTS, prev_sort_primary, CTSVC_SORT_PRIMARY); + ret = sqlite3_exec(db, query, NULL, NULL, &errmsg); + if (SQLITE_OK != ret) { + ERR("sqlite3_exec(%s) Failed(%d, %s)", query, ret, errmsg); + sqlite3_free(errmsg); + ctsvc_server_end_trans(false); + ctsvc_server_db_close(); + return CONTACTS_ERROR_DB; + } + + snprintf(query, sizeof(query), "UPDATE %s SET reverse_display_name_language=%d WHERE reverse_display_name_language = %d" , + CTS_TABLE_CONTACTS, prev_sort_secondary, CTSVC_SORT_SECONDARY); + ret = sqlite3_exec(db, query, NULL, NULL, &errmsg); + if (SQLITE_OK != ret) { + ERR("sqlite3_exec(%s) Failed(%d, %s)", query, ret, errmsg); + sqlite3_free(errmsg); + ctsvc_server_end_trans(false); + ctsvc_server_db_close(); + return CONTACTS_ERROR_DB; + } + + snprintf(query, sizeof(query), "UPDATE %s SET reverse_display_name_language=%d WHERE reverse_display_name_language = %d", + CTS_TABLE_CONTACTS, CTSVC_SORT_PRIMARY, new_sort_primary); + ret = sqlite3_exec(db, query, NULL, NULL, &errmsg); + if (SQLITE_OK != ret) { + ERR("sqlite3_exec(%s) Failed(%d, %s)", query, ret, errmsg); + sqlite3_free(errmsg); + ctsvc_server_end_trans(false); + ctsvc_server_db_close(); + return CONTACTS_ERROR_DB; + } + + snprintf(query, sizeof(query), "UPDATE %s SET reverse_display_name_language=%d WHERE reverse_display_name_language = %d" , + CTS_TABLE_CONTACTS, CTSVC_SORT_SECONDARY, new_sort_secondary); + ret = sqlite3_exec(db, query, NULL, NULL, &errmsg); + if (SQLITE_OK != ret) { + ERR("sqlite3_exec(%s) Failed(%d, %s)", query, ret, errmsg); + sqlite3_free(errmsg); + ctsvc_server_end_trans(false); + ctsvc_server_db_close(); + return CONTACTS_ERROR_DB; + } + ret = ctsvc_server_set_default_language(new_sort_primary); if (CONTACTS_ERROR_NONE != ret) { ctsvc_server_end_trans(false); diff --git a/server/ctsvc_server_utils.c b/server/ctsvc_server_utils.c index eae5f87..faa599e 100755 --- a/server/ctsvc_server_utils.c +++ b/server/ctsvc_server_utils.c @@ -74,7 +74,7 @@ static void ctsvc_server_change_language_cb(keynode_t *key, void *data) break; default: new_primary_sort = CTSVC_SORT_WESTERN; - break; + break; } if (primary_sort ==-1) { -- cgit v1.2.3