From 26617d6ee542aa8e85639afdcbd990bdaa71838e Mon Sep 17 00:00:00 2001 From: Donghee Ye Date: Thu, 20 Jun 2013 20:38:50 +0900 Subject: Update version 0.9.106.1 - Add message_alert property to contact - Change number noramlization, minmatch for search - Add normalized_number property for search(server side), Divide normalize_str and normalize_number - Add number type (company main, radio), vcard put/get number type (company_main/radio) - Add contacts_db_search_records_with_range API - Fix : export vcard with bmp image - Change return value, memory leak - Ignore invalid photo when importing vcard - Fix : make vcard during realloc - Fix search contact (diacritical case) : conatcts_db_search_records Change-Id: I0e52e72fb7ff1dd3f2c76f5a114d5cc45d94d465 --- CMakeLists.txt | 2 +- client/ctsvc_client_db.c | 68 ++++++ common/ctsvc_localize.c | 2 - common/ctsvc_normalize.c | 343 +++---------------------------- common/ctsvc_normalize.h | 158 +++++++------- common/ctsvc_record_contact.c | 16 ++ common/ctsvc_record_person.c | 8 + common/ctsvc_record_phonelog.c | 2 + common/ctsvc_struct.h | 9 +- common/ctsvc_vcard.c | 144 ++++++++++++- common/ctsvc_view.c | 37 +++- common/ctsvc_view.h | 6 + common/ipc/ctsvc_ipc_contact.c | 2 + common/ipc/ctsvc_ipc_define.h | 1 + common/ipc/ctsvc_ipc_person.c | 2 + common/ipc/ctsvc_ipc_simple_contact.c | 2 + contacts-service2.manifest | 2 +- include/contacts.h | 16 +- include/contacts_db.h | 26 +++ include/contacts_phone_log.h | 2 +- include/contacts_service.h | 8 +- include/contacts_sim.h | 2 +- include/contacts_types.h | 9 +- include/contacts_views.h | 16 +- native/ctsvc_db_init.c | 18 +- native/ctsvc_db_plugin_addressbook.c | 5 +- native/ctsvc_db_plugin_contact.c | 62 ++++-- native/ctsvc_db_plugin_image_helper.c | 2 +- native/ctsvc_db_plugin_name_helper.c | 1 - native/ctsvc_db_plugin_number_helper.c | 34 +-- native/ctsvc_db_plugin_person.c | 14 +- native/ctsvc_db_plugin_person_helper.c | 23 ++- native/ctsvc_db_plugin_phonelog.c | 23 ++- native/ctsvc_db_plugin_simple_contact.c | 18 +- native/ctsvc_db_query.c | 202 ++++++++++++++---- native/ctsvc_number_utils.c | 353 ++++++++++++++++++++++++++++++++ native/ctsvc_number_utils.h | 29 +++ native/ctsvc_person.c | 24 ++- native/ctsvc_service.c | 1 + packaging/contacts-service.spec | 2 +- schema.sql | 3 + server/CMakeLists.txt | 1 + server/ctsvc_ipc_server.c | 112 +++++++++- server/ctsvc_ipc_server.h | 1 + server/ctsvc_server.c | 1 + 45 files changed, 1256 insertions(+), 556 deletions(-) create mode 100644 native/ctsvc_number_utils.c create mode 100644 native/ctsvc_number_utils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 57ff1ea..15bf9dc 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.103.1") +SET(VERSION "${VERSION_MAJOR}.9.106.1") EXECUTE_PROCESS(COMMAND build-util/generator.sh) diff --git a/client/ctsvc_client_db.c b/client/ctsvc_client_db.c index f7c8037..cc6b2a4 100644 --- a/client/ctsvc_client_db.c +++ b/client/ctsvc_client_db.c @@ -1346,6 +1346,74 @@ API int contacts_db_search_records(const char* view_uri, const char *keyword, return ret; } +API int contacts_db_search_records_with_range(const char* view_uri, const char *keyword, + int offset, int limit, int range, contacts_list_h* out_list) +{ + int ret = CONTACTS_ERROR_NONE; + pims_ipc_data_h indata = NULL; + pims_ipc_data_h outdata = NULL; + + RETVM_IF(out_list == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL"); + *out_list = NULL; + RETVM_IF(range == 0, CONTACTS_ERROR_INVALID_PARAMETER, "range is 0"); + RETVM_IF(ctsvc_get_ipc_handle() == NULL, CONTACTS_ERROR_IPC, "contacts not connected"); + + indata = pims_ipc_data_create(0); + if (indata == NULL) { + CTS_ERR("ipc data created fail !"); + return CONTACTS_ERROR_OUT_OF_MEMORY; + } + + ret = ctsvc_ipc_marshal_string(view_uri, indata); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("marshal fail"); + goto DATA_FREE; + } + ret = ctsvc_ipc_marshal_string(keyword, indata); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("marshal fail"); + goto DATA_FREE; + } + ret = ctsvc_ipc_marshal_int(offset, indata); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("marshal fail"); + goto DATA_FREE; + } + ret = ctsvc_ipc_marshal_int(limit, indata); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("marshal fail"); + goto DATA_FREE; + } + ret = ctsvc_ipc_marshal_int(range, indata); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("marshal fail"); + goto DATA_FREE; + } + + if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS_WITH_RANGE, indata, &outdata) != 0) { + CTS_ERR("ctsvc_ipc_call failed"); + pims_ipc_data_destroy(indata); + return CONTACTS_ERROR_IPC; + } + + pims_ipc_data_destroy(indata); + + if (outdata) { + unsigned int size = 0; + ret = *(int*) pims_ipc_data_get(outdata,&size); + + if (ret == CONTACTS_ERROR_NONE) + ret = ctsvc_ipc_unmarshal_list(outdata,out_list); + pims_ipc_data_destroy(outdata); + } + + return ret; + +DATA_FREE: + free(indata); + return ret; +} + API int contacts_db_search_records_with_query(contacts_query_h query, const char *keyword, int offset, int limit, contacts_list_h* out_list) { diff --git a/common/ctsvc_localize.c b/common/ctsvc_localize.c index 15a284f..88e3470 100755 --- a/common/ctsvc_localize.c +++ b/common/ctsvc_localize.c @@ -24,8 +24,6 @@ #include "ctsvc_normalize.h" #include "ctsvc_localize.h" -#define CTSVC_COMPARE_BETWEEN(left_range, value, right_range) (((left_range) <= (value)) && ((value) <= (right_range))) - /* korean -Hangul Jamo extended A*/ #define CTSVC_JAMO_A_START (UChar)0xA960 #define CTSVC_JAMO_A_END (UChar)0xA97F diff --git a/common/ctsvc_normalize.c b/common/ctsvc_normalize.c index 12c82dd..a047268 100644 --- a/common/ctsvc_normalize.c +++ b/common/ctsvc_normalize.c @@ -59,273 +59,6 @@ static hiragana_group_letter hiragana_group[13] = { {0x3093, 0x93, 0x93}, // ゐ ゑ を }; - -static inline bool __ctsvc_check_dirty_number(char digit) -{ - switch (digit) - { - case '0' ... '9': - case 'p': - case 'w': - case 'P': - case 'W': - case '#': - case '*': - case '(': - case '/': - case ')': - case 'N': - case ',': - case '.': - case ';': - case '+': - return false; - default: - return true; - } -} - -int ctsvc_clean_number(const char *src, char *dest, int dest_size) -{ - int s_pos=0, d_pos=0, char_type; - - if (NULL == src) - CTS_ERR("The parameter(src) is NULL"); - else { - while (src[s_pos] != 0) - { - if (d_pos >= dest_size-2) break; - char_type = ctsvc_check_utf8(src[s_pos]); - if (char_type <= 1) { - if (__ctsvc_check_dirty_number(src[s_pos])) { - s_pos++; - continue; - } - dest[d_pos++] = src[s_pos++]; - } - else - s_pos += char_type; - } - } - - dest[d_pos] = 0; - return d_pos; -} - -static inline const char* __ctsvc_clean_country_code(const char *src) -{ - int ret = 1; - switch (src[ret++]-'0') - { - case 1: - case 7: - break; - case 2: - switch (src[ret++]-'0') - { - case 0: - case 7: - break; - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 8: - case 9: - ret += 1; - break; - default: - CTS_ERR("The parameter(src:%s) has invalid character set", src); - } - break; - case 3: - switch (src[ret++]-'0') - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 6: - case 9: - break; - case 5: - case 7: - case 8: - ret += 1; - break; - default: - CTS_ERR("The parameter(src:%s) has invalid character set", src); - } - break; - case 4: - switch (src[ret++]-'0') - { - case 0: - case 1: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - break; - case 2: - ret += 1; - break; - default: - CTS_ERR("The parameter(src:%s) has invalid character set", src); - } - break; - case 5: - switch (src[ret++]-'0') - { - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - break; - case 0: - case 9: - ret += 1; - break; - default: - CTS_ERR("The parameter(src:%s) has invalid character set", src); - } - break; - case 6: - switch (src[ret++]-'0') - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - break; - case 7: - case 8: - case 9: - ret += 1; - break; - default: - CTS_ERR("The parameter(src:%s) has invalid character set", src); - } - break; - case 8: - switch (src[ret++]-'0') - { - case 1: - case 2: - case 4: - case 6: - break; - case 0: - case 3: - case 5: - case 7: - case 8: - case 9: - ret += 1; - break; - default: - CTS_ERR("The parameter(src:%s) has invalid character set", src); - } - break; - case 9: - switch (src[ret++]-'0') - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 8: - break; - case 6: - case 7: - case 9: - ret += 1; - break; - default: - CTS_ERR("The parameter(src:%s) has invalid character set", src); - } - break; - case 0: - default: - CTS_ERR("The parameter(src:%s) has invalid character set", src); - return src; - } - - return &src[ret]; -} - -static int __ctsvc_normalize_number(const char *src, char *dest, int dest_size, int min_match) -{ - int i; - int len; - int d_pos = 0; - const char *temp_number; - - if ('+' == src[0]) - temp_number = __ctsvc_clean_country_code(src); - else if ('0' == src[0]) - temp_number = src+1; - else - temp_number = src; - - len = strlen(temp_number); - - if (0 < len) { - while(0 <= (len-d_pos-1) && temp_number[len-d_pos-1] - && d_pos < min_match) { - if (dest_size-d_pos == 0) { - CTS_ERR("Destination string buffer is not enough(%s)", src); - return CONTACTS_ERROR_INTERNAL; - } - - dest[d_pos] = temp_number[len-d_pos-1]; - d_pos++; - } - dest[d_pos] = 0; - - len = strlen(dest); - for(i=0; i '9') { - CTS_ERR("keyword[%d]: %c is not number)", i, keyword[i]); - return false; - } - } - return true; -} - #define LARGE_BUFFER_SIZE 100 -static bool __ctsvc_is_phonenumber_fullwidth(const char* keyword) -{ - UChar unicodes[LARGE_BUFFER_SIZE]; - - int size = 0; - if( __ctsvc_convert_halfwidth_ascii_and_symbol(keyword, unicodes, LARGE_BUFFER_SIZE, &size) != CONTACTS_ERROR_NONE ) - { - CTS_ERR("convert failed! %s", keyword); - - return false; - } - - int i = 0; - for( i = 0; i < size; i++ ) - { - if (unicodes[i] < (UChar)0xFF10 || unicodes[i] > (UChar)0xFF19 ) - { - CTS_ERR("keyword[%d]: 0x%0x is not number)", i, unicodes[i] ); - - return false; - } - } - - return true; -} - -bool ctsvc_is_phonenumber(const char* src) -{ - return ( __ctsvc_is_phonenumber_halfwidth(src) || __ctsvc_is_phonenumber_fullwidth(src) ); -} - int ctsvc_get_halfwidth_string(const char *src, char** dest, int* dest_size) { UChar unicodes[LARGE_BUFFER_SIZE]; @@ -664,7 +367,7 @@ int ctsvc_get_halfwidth_string(const char *src, char** dest, int* dest_size) return CONTACTS_ERROR_NONE; } - +////// contacts_normalized_strstr API should be separated from contacts-service ///////////////////////////////////////////////////////////// static int __ctsvc_normalize_str_to_unicode(const char *src, int src_size, UChar *dest, int dest_size) { int ret; diff --git a/common/ctsvc_normalize.h b/common/ctsvc_normalize.h index d248c5e..444de46 100644 --- a/common/ctsvc_normalize.h +++ b/common/ctsvc_normalize.h @@ -1,80 +1,78 @@ -/* - * Contacts Service - * - * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -#ifndef __TIZEN_SOCIAL_CTSVC_NORMALIZE_H__ -#define __TIZEN_SOCIAL_CTSVC_NORMALIZE_H__ - -enum LANGTYPE{ - CTSVC_LANG_NUMBER = 0, - CTSVC_LANG_DEFAULT = 1, - CTSVC_LANG_SECONDARY = 2, - CTSVC_LANG_ENGLISH = 3, - CTSVC_LANG_KOREAN = 4, /* always last-first */ - CTSVC_LANG_CHINESE = 5, - CTSVC_LANG_JAPANESE = 6, - CTSVC_LANG_FRENCH = 7, - CTSVC_LANG_GERMAN = 8, - CTSVC_LANG_ITALIAN = 9, - CTSVC_LANG_RUSSIAN = 10, - CTSVC_LANG_DUTCH = 11, - CTSVC_LANG_PORTUGUESE = 12, - CTSVC_LANG_TURKISH = 13, - CTSVC_LANG_GREEK = 14, - CTSVC_LANG_SPANISH = 15, - CTSVC_LANG_DANISH = 16, - CTSVC_LANG_AZERBAIJAN = 17, - CTSVC_LANG_ARABIC = 18, - CTSVC_LANG_BULGARIAN = 19, - CTSVC_LANG_CATALAN = 20, - CTSVC_LANG_CZECH = 21, - CTSVC_LANG_ESTONIAN = 22, - CTSVC_LANG_BASQUE = 23, - CTSVC_LANG_FINNISH = 24, - CTSVC_LANG_IRISH = 25, - CTSVC_LANG_GALICIAN = 26, - CTSVC_LANG_HINDI = 27, - CTSVC_LANG_CROATIAN = 28, - CTSVC_LANG_HUNGARIAN= 29, - CTSVC_LANG_ARMENIAN = 30, - CTSVC_LANG_ICELANDIC = 31, - CTSVC_LANG_GEORGIAN = 32, - CTSVC_LANG_KAZAKHSTAN = 33, - CTSVC_LANG_LITHUANIAN = 34, - CTSVC_LANG_LATVIAN = 35, - CTSVC_LANG_MACEDONIA = 36, - CTSVC_LANG_NORWAY= 37, - CTSVC_LANG_POLISH = 38, - CTSVC_LANG_ROMANIA = 39, - CTSVC_LANG_SLOVAK = 40, - CTSVC_LANG_SLOVENIAN = 41, - CTSVC_LANG_SERBIAN = 42, - CTSVC_LANG_SWEDISH = 43, - CTSVC_LANG_UKRAINE = 44, - CTSVC_LANG_OTHERS = 1000, -}; - -int ctsvc_clean_number(const char *src, char *dest, int dest_size); -int ctsvc_normalize_number(const char *src, char *dest, int dest_size, int min_match); -int ctsvc_normalize_str(const char *src, char **dest); -int ctsvc_collation_str(char *src, char **dest); -int ctsvc_normalize_index(const char *src, char **dest); - -bool ctsvc_is_phonenumber(const char* src); -int ctsvc_get_halfwidth_string(const char *src, char** dest, int* dest_size); - -#endif /* __TIZEN_SOCIAL_CTSVC_NORMALIZE_H__ */ +/* + * Contacts Service + * + * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef __TIZEN_SOCIAL_CTSVC_NORMALIZE_H__ +#define __TIZEN_SOCIAL_CTSVC_NORMALIZE_H__ + +enum LANGTYPE{ + CTSVC_LANG_NUMBER = 0, + CTSVC_LANG_DEFAULT = 1, + CTSVC_LANG_SECONDARY = 2, + CTSVC_LANG_ENGLISH = 3, + CTSVC_LANG_KOREAN = 4, /* always last-first */ + CTSVC_LANG_CHINESE = 5, + CTSVC_LANG_JAPANESE = 6, + CTSVC_LANG_FRENCH = 7, + CTSVC_LANG_GERMAN = 8, + CTSVC_LANG_ITALIAN = 9, + CTSVC_LANG_RUSSIAN = 10, + CTSVC_LANG_DUTCH = 11, + CTSVC_LANG_PORTUGUESE = 12, + CTSVC_LANG_TURKISH = 13, + CTSVC_LANG_GREEK = 14, + CTSVC_LANG_SPANISH = 15, + CTSVC_LANG_DANISH = 16, + CTSVC_LANG_AZERBAIJAN = 17, + CTSVC_LANG_ARABIC = 18, + CTSVC_LANG_BULGARIAN = 19, + CTSVC_LANG_CATALAN = 20, + CTSVC_LANG_CZECH = 21, + CTSVC_LANG_ESTONIAN = 22, + CTSVC_LANG_BASQUE = 23, + CTSVC_LANG_FINNISH = 24, + CTSVC_LANG_IRISH = 25, + CTSVC_LANG_GALICIAN = 26, + CTSVC_LANG_HINDI = 27, + CTSVC_LANG_CROATIAN = 28, + CTSVC_LANG_HUNGARIAN= 29, + CTSVC_LANG_ARMENIAN = 30, + CTSVC_LANG_ICELANDIC = 31, + CTSVC_LANG_GEORGIAN = 32, + CTSVC_LANG_KAZAKHSTAN = 33, + CTSVC_LANG_LITHUANIAN = 34, + CTSVC_LANG_LATVIAN = 35, + CTSVC_LANG_MACEDONIA = 36, + CTSVC_LANG_NORWAY= 37, + CTSVC_LANG_POLISH = 38, + CTSVC_LANG_ROMANIA = 39, + CTSVC_LANG_SLOVAK = 40, + CTSVC_LANG_SLOVENIAN = 41, + CTSVC_LANG_SERBIAN = 42, + CTSVC_LANG_SWEDISH = 43, + CTSVC_LANG_UKRAINE = 44, + CTSVC_LANG_OTHERS = 1000, +}; + +#define CTSVC_COMPARE_BETWEEN(left_range, value, right_range) (((left_range) <= (value)) && ((value) <= (right_range))) + +int ctsvc_normalize_str(const char *src, char **dest); +int ctsvc_collation_str(char *src, char **dest); +int ctsvc_normalize_index(const char *src, char **dest); +int ctsvc_get_halfwidth_string(const char *src, char** dest, int* dest_size); + +#endif /* __TIZEN_SOCIAL_CTSVC_NORMALIZE_H__ */ diff --git a/common/ctsvc_record_contact.c b/common/ctsvc_record_contact.c index 1f88457..0586ccc 100644 --- a/common/ctsvc_record_contact.c +++ b/common/ctsvc_record_contact.c @@ -1115,6 +1115,7 @@ static int __ctsvc_simple_contact_destroy(contacts_record_h record, bool delete_ free(contact->image_thumbnail_path); free(contact->ringtone_path); free(contact->vibration); + free(contact->message_alert); free(contact->uid); free(contact); @@ -1190,6 +1191,7 @@ static int __ctsvc_contact_destroy(contacts_record_h record, bool delete_child) free(contact->image_thumbnail_path); free(contact->ringtone_path); free(contact->vibration); + free(contact->message_alert); free(contact->sort_name); free(contact->reverse_sort_name); free(contact->sortkey); @@ -2173,6 +2175,9 @@ static int __ctsvc_contact_get_str_real(contacts_record_h record, unsigned int p case CTSVC_PROPERTY_CONTACT_VIBRATION: *out_str = GET_STR(copy, contact->vibration); break; + case CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT: + *out_str = GET_STR(copy, contact->message_alert); + break; default : CTS_ERR("Invalid parameter : property_id(%d) is not supported in value(contact)", property_id); return CONTACTS_ERROR_INVALID_PARAMETER; @@ -2475,6 +2480,9 @@ static int __ctsvc_simple_contact_get_str_real(contacts_record_h record, case CTSVC_PROPERTY_CONTACT_VIBRATION: *out_str = GET_STR(copy, contact->vibration); break; + case CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT: + *out_str = GET_STR(copy, contact->message_alert); + break; default : CTS_ERR("Invalid parameter : property_id(%d) is not supported in value(simple_contact)", property_id); return CONTACTS_ERROR_INVALID_PARAMETER; @@ -3090,6 +3098,9 @@ static int __ctsvc_contact_set_str(contacts_record_h record, unsigned int proper case CTSVC_PROPERTY_CONTACT_VIBRATION: FREEandSTRDUP(contact->vibration, str); break; + case CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT: + FREEandSTRDUP(contact->message_alert, str); + break; default : CTS_ERR("Invalid parameter : property_id(%d) is not supported in value(contact)", property_id); return CONTACTS_ERROR_INVALID_PARAMETER; @@ -3122,6 +3133,9 @@ static int __ctsvc_simple_contact_set_str(contacts_record_h record, unsigned int case CTSVC_PROPERTY_CONTACT_VIBRATION: FREEandSTRDUP(contact->vibration, str); break; + case CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT: + FREEandSTRDUP(contact->message_alert, str); + break; default : CTS_ERR("Invalid parameter : property_id(%d) is not supported in value(simple_contact)", property_id); return CONTACTS_ERROR_INVALID_PARAMETER; @@ -3773,6 +3787,7 @@ static int __ctsvc_contact_clone(contacts_record_h record, contacts_record_h *ou out_data->uid = SAFE_STRDUP(src_data->uid); out_data->ringtone_path = SAFE_STRDUP(src_data->ringtone_path); out_data->vibration = SAFE_STRDUP(src_data->vibration); + out_data->message_alert = SAFE_STRDUP(src_data->message_alert); out_data->image_thumbnail_path = SAFE_STRDUP(src_data->image_thumbnail_path); out_data->sort_name = SAFE_STRDUP(src_data->sort_name); out_data->reverse_sort_name = SAFE_STRDUP(src_data->reverse_sort_name); @@ -4257,6 +4272,7 @@ static int __ctsvc_simple_contact_clone(contacts_record_h record, contacts_recor out_data->uid = SAFE_STRDUP(src_data->uid); out_data->ringtone_path = SAFE_STRDUP(src_data->ringtone_path); out_data->vibration = SAFE_STRDUP(src_data->vibration); + out_data->message_alert = SAFE_STRDUP(src_data->message_alert); out_data->image_thumbnail_path = SAFE_STRDUP(src_data->image_thumbnail_path); CTSVC_RECORD_COPY_BASE(&(out_data->base), &(src_data->base)); diff --git a/common/ctsvc_record_person.c b/common/ctsvc_record_person.c index eb57492..0098a4b 100755 --- a/common/ctsvc_record_person.c +++ b/common/ctsvc_record_person.c @@ -79,6 +79,7 @@ static int __ctsvc_person_destroy(contacts_record_h record, bool delete_child) free(person->display_name_index); free(person->ringtone_path); free(person->vibration); + free(person->message_alert); free(person->image_thumbnail_path); free(person->status); free(person->addressbook_ids); @@ -109,6 +110,7 @@ static int __ctsvc_person_clone(contacts_record_h record, contacts_record_h *out out_data->image_thumbnail_path = SAFE_STRDUP(src_data->image_thumbnail_path); out_data->ringtone_path = SAFE_STRDUP(src_data->ringtone_path); out_data->vibration = SAFE_STRDUP(src_data->vibration); + out_data->message_alert = SAFE_STRDUP(src_data->message_alert); out_data->status = SAFE_STRDUP(src_data->status); CTSVC_RECORD_COPY_BASE(&(out_data->base), &(src_data->base)); @@ -153,6 +155,9 @@ static int __ctsvc_person_get_str_real(contacts_record_h record, unsigned int pr case CTSVC_PROPERTY_PERSON_VIBRATION: *out_str = GET_STR(copy, person->vibration); break; + case CTSVC_PROPERTY_PERSON_MESSAGE_ALERT: + *out_str = GET_STR(copy, person->message_alert); + break; case CTSVC_PROPERTY_PERSON_STATUS: *out_str = GET_STR(copy, person->status); break; @@ -240,6 +245,9 @@ static int __ctsvc_person_set_str(contacts_record_h record, unsigned int propert case CTSVC_PROPERTY_PERSON_VIBRATION: FREEandSTRDUP(person->vibration, str); break; + case CTSVC_PROPERTY_PERSON_MESSAGE_ALERT: + FREEandSTRDUP(person->message_alert, str); + break; default : ASSERT_NOT_REACHED("This field(%d) is not supported in value(person)", property_id); return CONTACTS_ERROR_INVALID_PARAMETER; diff --git a/common/ctsvc_record_phonelog.c b/common/ctsvc_record_phonelog.c index d2214aa..7ba0159 100644 --- a/common/ctsvc_record_phonelog.c +++ b/common/ctsvc_record_phonelog.c @@ -211,6 +211,8 @@ static int __ctsvc_phonelog_set_str(contacts_record_h record, unsigned int prope switch(property_id) { case CTSVC_PROPERTY_PHONELOG_ADDRESS: + RETVM_IF(phonelog->id > 0, CONTACTS_ERROR_INVALID_PARAMETER, + "Invalid parameter : property_id(%d) is a read-only value (phonelog)", property_id); FREEandSTRDUP(phonelog->address, str); break; case CTSVC_PROPERTY_PHONELOG_EXTRA_DATA2: diff --git a/common/ctsvc_struct.h b/common/ctsvc_struct.h index 5948d2b..de762ba 100644 --- a/common/ctsvc_struct.h +++ b/common/ctsvc_struct.h @@ -242,6 +242,7 @@ typedef struct { char *image_thumbnail_path; char *ringtone_path; char *vibration; + char *message_alert; char *status; int link_count; char *addressbook_ids; @@ -259,6 +260,7 @@ typedef struct { char *image_thumbnail_path; char *ringtone_path; char *vibration; + char *message_alert; char *display_name; char *uid; int display_source_type; @@ -290,7 +292,7 @@ typedef struct { int type; char *label; char *number; - char *lookup; // internally used + char *lookup; // internally used : for min match }ctsvc_number_s; typedef struct { @@ -453,8 +455,8 @@ typedef struct { int log_type; int extra_data1; /* duration, message_id */ char *extra_data2; /*short message*/ - char *display_name; // new - char *image_thumbnail_path; // new + char *display_name; + char *image_thumbnail_path; }ctsvc_phonelog_s; typedef struct { @@ -498,6 +500,7 @@ typedef struct { char *image_thumbnail_path; char *ringtone_path; char *vibration; + char *message_alert; ctsvc_list_s* name; ctsvc_list_s* note; ctsvc_list_s* company; diff --git a/common/ctsvc_vcard.c b/common/ctsvc_vcard.c index 3d86384..b2be924 100644 --- a/common/ctsvc_vcard.c +++ b/common/ctsvc_vcard.c @@ -131,10 +131,24 @@ enum { enum{ CTSVC_VCARD_IMG_NONE, - CTSVC_VCARD_IMG_JPEG, - CTSVC_VCARD_IMG_PNG, - CTSVC_VCARD_IMG_GIF, - CTSVC_VCARD_IMG_TIFF, + CTSVC_VCARD_IMG_PNG, // Portable Network Graphics + // vcard 2.1 spec + CTSVC_VCARD_IMG_JPEG, // ISO JPEG format + CTSVC_VCARD_IMG_GIF, //Graphics Interchange Format + CTSVC_VCARD_IMG_TIFF, // Tagged Image File Format + CTSVC_VCARD_IMG_CGM, //ISO Computer Graphics Metafile + CTSVC_VCARD_IMG_WMF, // MS Windows Metafile + CTSVC_VCARD_IMG_BMP, // MS Windows Bitmap + CTSVC_VCARD_IMG_MET, // IBM PM Metafile + CTSVC_VCARD_IMG_PMB, // IBM PM Bitmap + CTSVC_VCARD_IMG_DIB, // MS Windows DIB + CTSVC_VCARD_IMG_PICT, // Apple Picture format + CTSVC_VCARD_IMG_PDF, // Adobe Page Description Format + CTSVC_VCARD_IMG_PS, // Adobe PostScript format + CTSVC_VCARD_IMG_QTIME, // Apple QuickTime format + CTSVC_VCARD_IMG_MPEG, // ISO MPEG format + CTSVC_VCARD_IMG_MPEG2, // ISO MPEG version 2 format + CTSVC_VCARD_IMG_AVI, // Intel AVI format }; static const char *content_name[CTSVC_VCARD_VALUE_MAX] = {0}; @@ -303,8 +317,10 @@ static inline int __ctsvc_vcard_add_folding(char **buf, int *buf_size, int buf_l free(buf_copy); return -1; } - else + else { buf_copy = tmp; + r = (buf_copy + result_len); + } } if ('\r' == *s) @@ -431,6 +447,32 @@ static inline const char* __ctsvc_get_img_suffix(int type) return "gif"; case CTSVC_VCARD_IMG_PNG: return "png"; + case CTSVC_VCARD_IMG_CGM: + return "cgm"; + case CTSVC_VCARD_IMG_WMF: + return "wmf"; + case CTSVC_VCARD_IMG_BMP: + return "bmp"; + case CTSVC_VCARD_IMG_MET: + return "met"; + case CTSVC_VCARD_IMG_PMB: + return "pmb"; + case CTSVC_VCARD_IMG_DIB: + return "dib"; + case CTSVC_VCARD_IMG_PICT: + return "pict"; + case CTSVC_VCARD_IMG_PDF: + return "pdf"; + case CTSVC_VCARD_IMG_PS: + return "ps"; + case CTSVC_VCARD_IMG_QTIME: + return "qtime"; + case CTSVC_VCARD_IMG_MPEG: + return "mpeg"; + case CTSVC_VCARD_IMG_MPEG2: + return "mpeg2"; + case CTSVC_VCARD_IMG_AVI: + return "avi"; case CTSVC_VCARD_IMG_JPEG: case CTSVC_VCARD_IMG_NONE: default: @@ -463,6 +505,45 @@ static inline int __ctsvc_vcard_get_image_type(char *val) result = strstr(val, "tiff"); if (result) return CTSVC_VCARD_IMG_TIFF; + result = strstr(val, "cgm"); + if (result) return CTSVC_VCARD_IMG_CGM; + + result = strstr(val, "wmf"); + if (result) return CTSVC_VCARD_IMG_WMF; + + result = strstr(val, "bmp"); + if (result) return CTSVC_VCARD_IMG_BMP; + + result = strstr(val, "met"); + if (result) return CTSVC_VCARD_IMG_MET; + + result = strstr(val, "pmb"); + if (result) return CTSVC_VCARD_IMG_PMB; + + result = strstr(val, "dib"); + if (result) return CTSVC_VCARD_IMG_DIB; + + result = strstr(val, "pict"); + if (result) return CTSVC_VCARD_IMG_PICT; + + result = strstr(val, "pdf"); + if (result) return CTSVC_VCARD_IMG_PDF; + + result = strstr(val, "ps"); + if (result) return CTSVC_VCARD_IMG_PS; + + result = strstr(val, "qtime"); + if (result) return CTSVC_VCARD_IMG_QTIME; + + result = strstr(val, "mpeg"); + if (result) return CTSVC_VCARD_IMG_MPEG; + + result = strstr(val, "mpeg2"); + if (result) return CTSVC_VCARD_IMG_MPEG2; + + result = strstr(val, "avi"); + if (result) return CTSVC_VCARD_IMG_AVI; + return CTSVC_VCARD_IMG_NONE; } @@ -476,6 +557,32 @@ static inline const char* __ctsvc_get_image_type_str(int type) return "GIF"; case CTSVC_VCARD_IMG_PNG: return "PNG"; + case CTSVC_VCARD_IMG_CGM: + return "CGM"; + case CTSVC_VCARD_IMG_WMF: + return "WMF"; + case CTSVC_VCARD_IMG_BMP: + return "BMP"; + case CTSVC_VCARD_IMG_MET: + return "MET"; + case CTSVC_VCARD_IMG_PMB: + return "PMB"; + case CTSVC_VCARD_IMG_DIB: + return "DIB"; + case CTSVC_VCARD_IMG_PICT: + return "PICT"; + case CTSVC_VCARD_IMG_PDF: + return "PDF"; + case CTSVC_VCARD_IMG_PS: + return "PS"; + case CTSVC_VCARD_IMG_QTIME: + return "QTIME"; + case CTSVC_VCARD_IMG_MPEG: + return "MPEG"; + case CTSVC_VCARD_IMG_MPEG2: + return "MPEG2"; + case CTSVC_VCARD_IMG_AVI: + return "AVI"; case CTSVC_VCARD_IMG_JPEG: default: return "JPEG"; @@ -868,6 +975,10 @@ static inline int __ctsvc_vcard_put_number_type(int type, char *label, char **bu CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=PCS"); if (type & CONTACTS_NUMBER_TYPE_ASSISTANT) CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=X-ASSISTANT"); + if (type & CONTACTS_NUMBER_TYPE_RADIO) + CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=X-RADIO"); + if (type & CONTACTS_NUMBER_TYPE_COMPANY_MAIN) + CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=X-COMPANY-MAIN"); if (type == CONTACTS_NUMBER_TYPE_CUSTOM) { if (__ctsvc_vcard_is_valid_custom_label(label)) { CTSVC_VCARD_APPEND_STR(buf, buf_size, len, ";TYPE=X-"); @@ -1738,7 +1849,8 @@ API int contacts_vcard_make_from_person(contacts_record_h record, char **vcard_s return CONTACTS_ERROR_INVALID_PARAMETER; } contacts_query_create(_contacts_contact._uri, &query); - contacts_query_set_filter(query, filter); + ret = contacts_query_set_filter(query, filter); + WARN_IF(CONTACTS_ERROR_NONE != ret, "contacts_query_set_filter() Failed(%d)", ret); ret = contacts_db_get_records_with_query(query, 0, 0, &list); if (ret == CONTACTS_ERROR_NONE) @@ -2319,6 +2431,12 @@ static inline int __ctsvc_vcard_get_photo(contacts_record_h contact, ctsvc_list_ type = __ctsvc_vcard_get_image_type(val); + buf = g_base64_decode(temp+1, &size); + if (0 == size) { + g_free(buf); + return CONTACTS_ERROR_NONE; + } + gettimeofday(&tv, NULL); ret = snprintf(dest, sizeof(dest), "%s/vcard-image-%ld%ld.%s", CTSVC_VCARD_IMAGE_LOCATION, tv.tv_sec, tv.tv_usec, __ctsvc_get_img_suffix(type)); @@ -2327,8 +2445,6 @@ static inline int __ctsvc_vcard_get_photo(contacts_record_h contact, ctsvc_list_ fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC, 0660); RETVM_IF(fd < 0, CONTACTS_ERROR_SYSTEM, "System : open(%s) Failed(%d)", dest, errno); - buf = g_base64_decode(temp+1, &size); - while (0 < size) { ret = write(fd, buf, size); if (ret <= 0) { @@ -2567,6 +2683,12 @@ static inline int __ctsvc_vcard_get_company_logo(ctsvc_list_s *company_list, cha *temp = '\0'; type = __ctsvc_vcard_get_image_type(val); + buf = g_base64_decode(temp+1, &size); + if (0 == size) { + g_free(buf); + return CONTACTS_ERROR_NONE; + } + gettimeofday(&tv, NULL); ret = snprintf(dest, sizeof(dest), "%s/%d-%ld%ld-logo.%s", CTSVC_VCARD_IMAGE_LOCATION, getpid(), tv.tv_sec, tv.tv_usec, __ctsvc_get_img_suffix(type)); @@ -2575,8 +2697,6 @@ static inline int __ctsvc_vcard_get_company_logo(ctsvc_list_s *company_list, cha fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC, 0660); RETVM_IF(fd < 0, CONTACTS_ERROR_INTERNAL, "System : open(%s) Failed(%d)", dest, errno); - buf = g_base64_decode(temp+1, &size); - while (0 < size) { ret = write(fd, buf, size); if (ret <= 0) { @@ -2788,6 +2908,10 @@ static inline bool __ctsvc_vcard_get_number_type(contacts_record_h number, char if (result) { if (strstr(lower, "x-assistant")) type |= CONTACTS_NUMBER_TYPE_ASSISTANT; + else if (strstr(lower, "x-radio")) + type |= CONTACTS_NUMBER_TYPE_RADIO; + else if (strstr(lower, "x-company-main")) + type |= CONTACTS_NUMBER_TYPE_COMPANY_MAIN; else { type = CONTACTS_NUMBER_TYPE_CUSTOM; contacts_record_set_str(number, _contacts_number.label, temp+(result-lower)+2); diff --git a/common/ctsvc_view.c b/common/ctsvc_view.c index 6bcabfe..3bd0448 100644 --- a/common/ctsvc_view.c +++ b/common/ctsvc_view.c @@ -54,6 +54,7 @@ API const _contacts_person_property_ids _contacts_person = { .ringtone_path = CTSVC_PROPERTY_PERSON_RINGTONE, .image_thumbnail_path = CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, .vibration = CTSVC_PROPERTY_PERSON_VIBRATION, + .message_alert = CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, .status = CTSVC_PROPERTY_PERSON_STATUS, .is_favorite = CTSVC_PROPERTY_PERSON_IS_FAVORITE, .favorite_priority = CTSVC_PROPERTY_PERSON_FAVORITE_PRIORITY, @@ -77,6 +78,7 @@ API const _contacts_contact_property_ids _contacts_contact = { .person_id = CTSVC_PROPERTY_CONTACT_PERSON_ID, .uid = CTSVC_PROPERTY_CONTACT_UID, .vibration = CTSVC_PROPERTY_CONTACT_VIBRATION, + .message_alert = CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT, .changed_time = CTSVC_PROPERTY_CONTACT_CHANGED_TIME, .link_mode = CTSVC_PROPERTY_CONTACT_LINK_MODE, .name = CTSVC_PROPERTY_CONTACT_NAME, @@ -135,6 +137,7 @@ API const _contacts_simple_contact_property_ids _contacts_simple_contact = { .has_email = CTSVC_PROPERTY_CONTACT_HAS_EMAIL, .uid = CTSVC_PROPERTY_CONTACT_UID, .vibration = CTSVC_PROPERTY_CONTACT_VIBRATION, + .message_alert = CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT, .changed_time = CTSVC_PROPERTY_CONTACT_CHANGED_TIME, }; @@ -159,7 +162,8 @@ API const _contacts_number_property_ids _contacts_number = { .type = CTSVC_PROPERTY_NUMBER_TYPE, .label = CTSVC_PROPERTY_NUMBER_LABEL, .is_default = CTSVC_PROPERTY_NUMBER_IS_DEFAULT, - .number = CTSVC_PROPERTY_NUMBER_NUMBER + .number = CTSVC_PROPERTY_NUMBER_NUMBER, + .normalized_number = CTSVC_PROPERTY_NUMBER_NORMALIZED_NUMBER }; API const _contacts_email_property_ids _contacts_email = { @@ -307,6 +311,7 @@ API const _contacts_speeddial_property_ids _contacts_speeddial = { .person_id = CTSVC_PROPERTY_SPEEDDIAL_PERSON_ID, .display_name = CTSVC_PROPERTY_SPEEDDIAL_DISPLAY_NAME, .image_thumbnail_path = CTSVC_PROPERTY_SPEEDDIAL_IMAGE_THUMBNAIL, + .normalized_number = CTSVC_PROPERTY_SPEEDDIAL_NORMALIZED_NUMBER, }; API const _contacts_contact_updated_info_property_ids _contacts_contact_updated_info = { @@ -378,6 +383,7 @@ API const _contacts_phone_log_property_ids _contacts_phone_log = { .log_type = CTSVC_PROPERTY_PHONELOG_LOG_TYPE, .extra_data1 = CTSVC_PROPERTY_PHONELOG_EXTRA_DATA1, .extra_data2 = CTSVC_PROPERTY_PHONELOG_EXTRA_DATA2, + .normalized_address = CTSVC_PROPERTY_PHONELOG_NORMALIZED_ADDRESS, }; API const _contacts_extension_property_ids _contacts_extension = { @@ -407,6 +413,7 @@ API const _contacts_person_contact_property_ids _contacts_person_contact = { .ringtone_path = CTSVC_PROPERTY_PERSON_RINGTONE, .image_thumbnail_path = CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, .vibration = CTSVC_PROPERTY_PERSON_VIBRATION, + .message_alert = CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, .status = CTSVC_PROPERTY_PERSON_STATUS, .is_favorite = CTSVC_PROPERTY_PERSON_IS_FAVORITE, .link_count = CTSVC_PROPERTY_PERSON_LINK_COUNT, @@ -428,6 +435,7 @@ API const _contacts_person_number_property_ids _contacts_person_number = { .ringtone_path = CTSVC_PROPERTY_PERSON_RINGTONE, .image_thumbnail_path = CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, .vibration = CTSVC_PROPERTY_PERSON_VIBRATION, + .message_alert = CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, .is_favorite = CTSVC_PROPERTY_PERSON_IS_FAVORITE, .has_phonenumber = CTSVC_PROPERTY_PERSON_HAS_PHONENUMBER, .has_email = CTSVC_PROPERTY_PERSON_HAS_EMAIL, @@ -437,6 +445,7 @@ API const _contacts_person_number_property_ids _contacts_person_number = { .is_primary_default = CTSVC_PROPERTY_DATA_IS_PRIMARY_DEFAULT, .number = CTSVC_PROPERTY_NUMBER_NUMBER, .number_filter = CTSVC_PROPERTY_NUMBER_NUMBER_FILTER, + .normalized_number = CTSVC_PROPERTY_NUMBER_NORMALIZED_NUMBER, }; API const _contacts_person_email_property_ids _contacts_person_email = { @@ -448,6 +457,7 @@ API const _contacts_person_email_property_ids _contacts_person_email = { .ringtone_path = CTSVC_PROPERTY_PERSON_RINGTONE, .image_thumbnail_path = CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, .vibration = CTSVC_PROPERTY_PERSON_VIBRATION, + .message_alert = CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, .is_favorite = CTSVC_PROPERTY_PERSON_IS_FAVORITE, .has_phonenumber = CTSVC_PROPERTY_PERSON_HAS_PHONENUMBER, .has_email = CTSVC_PROPERTY_PERSON_HAS_EMAIL, @@ -467,6 +477,7 @@ API const _contacts_person_usage_property_ids _contacts_person_usage = { .ringtone_path = CTSVC_PROPERTY_PERSON_RINGTONE, .image_thumbnail_path = CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, .vibration = CTSVC_PROPERTY_PERSON_VIBRATION, + .message_alert = CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, .is_favorite = CTSVC_PROPERTY_PERSON_IS_FAVORITE, .has_phonenumber = CTSVC_PROPERTY_PERSON_HAS_PHONENUMBER, .has_email = CTSVC_PROPERTY_PERSON_HAS_EMAIL, @@ -483,6 +494,7 @@ API const _contacts_person_grouprel_property_ids _contacts_person_grouprel = { .ringtone_path = CTSVC_PROPERTY_PERSON_RINGTONE, .image_thumbnail_path = CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, .vibration = CTSVC_PROPERTY_PERSON_VIBRATION, + .message_alert = CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, .status = CTSVC_PROPERTY_PERSON_STATUS, .is_favorite = CTSVC_PROPERTY_PERSON_IS_FAVORITE, .has_phonenumber = CTSVC_PROPERTY_PERSON_HAS_PHONENUMBER, @@ -508,6 +520,7 @@ API const _contacts_person_phone_log_property_ids _contacts_person_phone_log = { .log_type = CTSVC_PROPERTY_PHONELOG_LOG_TYPE, .extra_data1 = CTSVC_PROPERTY_PHONELOG_EXTRA_DATA1, .extra_data2 = CTSVC_PROPERTY_PHONELOG_EXTRA_DATA2, + .normalized_address = CTSVC_PROPERTY_PHONELOG_NORMALIZED_ADDRESS, }; API const _contacts_contact_number_property_ids _contacts_contact_number = { @@ -525,6 +538,7 @@ API const _contacts_contact_number_property_ids _contacts_contact_number = { .is_default = CTSVC_PROPERTY_NUMBER_IS_DEFAULT, .number = CTSVC_PROPERTY_NUMBER_NUMBER, .number_filter = CTSVC_PROPERTY_NUMBER_NUMBER_FILTER, + .normalized_number = CTSVC_PROPERTY_NUMBER_NORMALIZED_NUMBER, }; API const _contacts_contact_email_property_ids _contacts_contact_email = { @@ -617,6 +631,7 @@ const property_info_s __property_person[] = { {CTSVC_PROPERTY_PERSON_RINGTONE, CTSVC_SEARCH_PROPERTY_ALL, "ringtone_path"}, {CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, CTSVC_SEARCH_PROPERTY_ALL, "image_thumbnail_path"}, {CTSVC_PROPERTY_PERSON_VIBRATION, CTSVC_SEARCH_PROPERTY_ALL, "vibration"}, + {CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, CTSVC_SEARCH_PROPERTY_ALL, "message_alert"}, {CTSVC_PROPERTY_PERSON_STATUS, CTSVC_SEARCH_PROPERTY_ALL, "status"}, {CTSVC_PROPERTY_PERSON_IS_FAVORITE, CTSVC_SEARCH_PROPERTY_ALL, "is_favorite"}, {CTSVC_PROPERTY_PERSON_FAVORITE_PRIORITY, CTSVC_SEARCH_PROPERTY_FILTER, "favorite_prio"}, @@ -639,6 +654,7 @@ const property_info_s __property_simple_contact[] = { {CTSVC_PROPERTY_CONTACT_PERSON_ID, CTSVC_SEARCH_PROPERTY_ALL, "person_id"}, {CTSVC_PROPERTY_CONTACT_UID, CTSVC_SEARCH_PROPERTY_ALL, "uid"}, {CTSVC_PROPERTY_CONTACT_VIBRATION, CTSVC_SEARCH_PROPERTY_ALL, "vibration"}, + {CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT, CTSVC_SEARCH_PROPERTY_ALL, "message_alert"}, {CTSVC_PROPERTY_CONTACT_CHANGED_TIME, CTSVC_SEARCH_PROPERTY_ALL, "changed_time"}, }; @@ -662,6 +678,7 @@ const property_info_s __property_number[] = { {CTSVC_PROPERTY_NUMBER_LABEL, CTSVC_SEARCH_PROPERTY_ALL, "data2"}, {CTSVC_PROPERTY_NUMBER_IS_DEFAULT, CTSVC_SEARCH_PROPERTY_ALL, "is_default"}, {CTSVC_PROPERTY_NUMBER_NUMBER, CTSVC_SEARCH_PROPERTY_ALL, "data3"}, + {CTSVC_PROPERTY_NUMBER_NORMALIZED_NUMBER, CTSVC_SEARCH_PROPERTY_FILTER, "data5"}, }; const property_info_s __property_email[] = { @@ -827,6 +844,7 @@ const property_info_s __property_contact[] = { {CTSVC_PROPERTY_CONTACT_PERSON_ID, CTSVC_SEARCH_PROPERTY_ALL, "person_id"}, {CTSVC_PROPERTY_CONTACT_UID, CTSVC_SEARCH_PROPERTY_ALL, "uid"}, {CTSVC_PROPERTY_CONTACT_VIBRATION, CTSVC_SEARCH_PROPERTY_ALL, "vibration"}, + {CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT, CTSVC_SEARCH_PROPERTY_ALL, "message_alert"}, {CTSVC_PROPERTY_CONTACT_CHANGED_TIME, CTSVC_SEARCH_PROPERTY_ALL, "changed_time"}, {CTSVC_PROPERTY_CONTACT_LINK_MODE, CTSVC_SEARCH_PROPERTY_ALL, "link_mode"}, {CTSVC_PROPERTY_CONTACT_NAME, CTSVC_SEARCH_PROPERTY_NONE,(void*)__property_name}, @@ -869,7 +887,6 @@ const property_info_s __property_my_profile[] = { {CTSVC_PROPERTY_MY_PROFILE_EXTENSION, CTSVC_SEARCH_PROPERTY_NONE,(void*)__property_extension}, }; - const property_info_s __property_speeddial[] = { {CTSVC_PROPERTY_SPEEDDIAL_DIAL_NUMBER, CTSVC_SEARCH_PROPERTY_ALL, "speed_number"}, {CTSVC_PROPERTY_SPEEDDIAL_NUMBER_ID, CTSVC_SEARCH_PROPERTY_ALL, "number_id"}, @@ -879,6 +896,7 @@ const property_info_s __property_speeddial[] = { {CTSVC_PROPERTY_SPEEDDIAL_PERSON_ID, CTSVC_SEARCH_PROPERTY_ALL, "person_id"}, {CTSVC_PROPERTY_SPEEDDIAL_DISPLAY_NAME, CTSVC_SEARCH_PROPERTY_ALL, NULL}, // display_name or reverse_display_name {CTSVC_PROPERTY_SPEEDDIAL_IMAGE_THUMBNAIL, CTSVC_SEARCH_PROPERTY_ALL, "image_thumbnail_path"}, + {CTSVC_PROPERTY_SPEEDDIAL_NORMALIZED_NUMBER, CTSVC_SEARCH_PROPERTY_FILTER, "normalized_number"}, }; const property_info_s __property_phonelog[] = { @@ -889,6 +907,7 @@ const property_info_s __property_phonelog[] = { {CTSVC_PROPERTY_PHONELOG_LOG_TYPE, CTSVC_SEARCH_PROPERTY_ALL, "log_type"}, {CTSVC_PROPERTY_PHONELOG_EXTRA_DATA1, CTSVC_SEARCH_PROPERTY_ALL, "data1"}, // duration {CTSVC_PROPERTY_PHONELOG_EXTRA_DATA2, CTSVC_SEARCH_PROPERTY_ALL, "data2"}, // short message, email subject + {CTSVC_PROPERTY_PHONELOG_NORMALIZED_ADDRESS, CTSVC_SEARCH_PROPERTY_FILTER, "normal_num"}, }; #if 0 @@ -919,6 +938,7 @@ const property_info_s __property_person_contact[] = { // _contacts_person_conta {CTSVC_PROPERTY_PERSON_RINGTONE, CTSVC_SEARCH_PROPERTY_PROJECTION, "ringtone_path"}, {CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, CTSVC_SEARCH_PROPERTY_PROJECTION, "image_thumbnail_path"}, {CTSVC_PROPERTY_PERSON_VIBRATION, CTSVC_SEARCH_PROPERTY_PROJECTION, "vibration"}, + {CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, CTSVC_SEARCH_PROPERTY_PROJECTION, "message_alert"}, {CTSVC_PROPERTY_PERSON_STATUS, CTSVC_SEARCH_PROPERTY_PROJECTION, "status"}, {CTSVC_PROPERTY_PERSON_IS_FAVORITE, CTSVC_SEARCH_PROPERTY_ALL, "is_favorite"}, {CTSVC_PROPERTY_PERSON_LINK_COUNT, CTSVC_SEARCH_PROPERTY_ALL, "link_count"}, @@ -941,6 +961,7 @@ const property_info_s __property_person_number[] = { // _contacts_person_number {CTSVC_PROPERTY_PERSON_RINGTONE, CTSVC_SEARCH_PROPERTY_PROJECTION, "ringtone_path"}, {CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, CTSVC_SEARCH_PROPERTY_PROJECTION, "image_thumbnail_path"}, {CTSVC_PROPERTY_PERSON_VIBRATION, CTSVC_SEARCH_PROPERTY_PROJECTION, "vibration"}, + {CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, CTSVC_SEARCH_PROPERTY_PROJECTION, "message_alert"}, {CTSVC_PROPERTY_PERSON_IS_FAVORITE, CTSVC_SEARCH_PROPERTY_ALL, "is_favorite"}, {CTSVC_PROPERTY_PERSON_HAS_PHONENUMBER, CTSVC_SEARCH_PROPERTY_ALL, "has_phonenumber"}, {CTSVC_PROPERTY_PERSON_HAS_EMAIL, CTSVC_SEARCH_PROPERTY_ALL, "has_email"}, @@ -949,8 +970,9 @@ const property_info_s __property_person_number[] = { // _contacts_person_number {CTSVC_PROPERTY_DATA_IS_PRIMARY_DEFAULT, CTSVC_SEARCH_PROPERTY_ALL, "is_primary_default"}, {CTSVC_PROPERTY_NUMBER_TYPE, CTSVC_SEARCH_PROPERTY_PROJECTION, "type"}, {CTSVC_PROPERTY_NUMBER_LABEL, CTSVC_SEARCH_PROPERTY_PROJECTION, "label"}, - {CTSVC_PROPERTY_NUMBER_NUMBER, CTSVC_SEARCH_PROPERTY_ALL, "number"}, - {CTSVC_PROPERTY_NUMBER_NUMBER_FILTER, CTSVC_SEARCH_PROPERTY_FILTER, "normalized_number"}, + {CTSVC_PROPERTY_NUMBER_NUMBER, CTSVC_SEARCH_PROPERTY_ALL, "number"}, + {CTSVC_PROPERTY_NUMBER_NUMBER_FILTER, CTSVC_SEARCH_PROPERTY_FILTER, "minmatch"}, + {CTSVC_PROPERTY_NUMBER_NORMALIZED_NUMBER, CTSVC_SEARCH_PROPERTY_FILTER, "normalized_number"}, }; const property_info_s __property_person_email[] = { // _contacts_person_email @@ -961,6 +983,7 @@ const property_info_s __property_person_email[] = { // _contacts_person_email {CTSVC_PROPERTY_PERSON_RINGTONE, CTSVC_SEARCH_PROPERTY_PROJECTION, "ringtone_path"}, {CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, CTSVC_SEARCH_PROPERTY_PROJECTION, "image_thumbnail_path"}, {CTSVC_PROPERTY_PERSON_VIBRATION, CTSVC_SEARCH_PROPERTY_PROJECTION, "vibration"}, + {CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, CTSVC_SEARCH_PROPERTY_PROJECTION, "message_alert"}, {CTSVC_PROPERTY_PERSON_IS_FAVORITE, CTSVC_SEARCH_PROPERTY_ALL, "is_favorite"}, {CTSVC_PROPERTY_PERSON_HAS_PHONENUMBER, CTSVC_SEARCH_PROPERTY_ALL, "has_phonenumber"}, {CTSVC_PROPERTY_PERSON_HAS_EMAIL, CTSVC_SEARCH_PROPERTY_ALL, "has_email"}, @@ -980,6 +1003,7 @@ const property_info_s __property_person_grouprel[] = { // _contacts_person_group {CTSVC_PROPERTY_PERSON_RINGTONE, CTSVC_SEARCH_PROPERTY_PROJECTION, "ringtone_path"}, {CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, CTSVC_SEARCH_PROPERTY_PROJECTION, "image_thumbnail_path"}, {CTSVC_PROPERTY_PERSON_VIBRATION, CTSVC_SEARCH_PROPERTY_PROJECTION, "vibration"}, + {CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, CTSVC_SEARCH_PROPERTY_PROJECTION, "message_alert"}, {CTSVC_PROPERTY_PERSON_STATUS, CTSVC_SEARCH_PROPERTY_PROJECTION, "status"}, {CTSVC_PROPERTY_PERSON_IS_FAVORITE, CTSVC_SEARCH_PROPERTY_ALL, "is_favorite"}, {CTSVC_PROPERTY_PERSON_LINK_COUNT, CTSVC_SEARCH_PROPERTY_ALL, "link_count"}, @@ -1008,6 +1032,7 @@ const property_info_s __property_person_phonelog[] = { // _contacts_person_phone {CTSVC_PROPERTY_PHONELOG_LOG_TYPE, CTSVC_SEARCH_PROPERTY_ALL, "log_type"}, {CTSVC_PROPERTY_PHONELOG_EXTRA_DATA1, CTSVC_SEARCH_PROPERTY_PROJECTION, "data1"}, // duration {CTSVC_PROPERTY_PHONELOG_EXTRA_DATA2, CTSVC_SEARCH_PROPERTY_PROJECTION, "data2"}, // message_id + {CTSVC_PROPERTY_PHONELOG_NORMALIZED_ADDRESS, CTSVC_SEARCH_PROPERTY_FILTER, "normal_num"}, }; const property_info_s __property_person_usage[] = { // _contacts_person_usage @@ -1018,6 +1043,7 @@ const property_info_s __property_person_usage[] = { // _contacts_person_usage {CTSVC_PROPERTY_PERSON_RINGTONE, CTSVC_SEARCH_PROPERTY_PROJECTION, "ringtone_path"}, {CTSVC_PROPERTY_PERSON_IMAGE_THUMBNAIL, CTSVC_SEARCH_PROPERTY_PROJECTION, "image_thumbnail_path"}, {CTSVC_PROPERTY_PERSON_VIBRATION, CTSVC_SEARCH_PROPERTY_PROJECTION, "vibration"}, + {CTSVC_PROPERTY_PERSON_MESSAGE_ALERT, CTSVC_SEARCH_PROPERTY_PROJECTION, "message_alert"}, {CTSVC_PROPERTY_PERSON_IS_FAVORITE, CTSVC_SEARCH_PROPERTY_ALL, "is_favorite"}, {CTSVC_PROPERTY_PERSON_HAS_PHONENUMBER, CTSVC_SEARCH_PROPERTY_ALL, "has_phonenumber"}, {CTSVC_PROPERTY_PERSON_HAS_EMAIL, CTSVC_SEARCH_PROPERTY_ALL, "has_email"}, @@ -1040,7 +1066,8 @@ const property_info_s __property_contact_number[] = { // _contacts_contact_numb {CTSVC_PROPERTY_NUMBER_LABEL, CTSVC_SEARCH_PROPERTY_PROJECTION, "label"}, {CTSVC_PROPERTY_NUMBER_IS_DEFAULT, CTSVC_SEARCH_PROPERTY_ALL, "is_default"}, {CTSVC_PROPERTY_NUMBER_NUMBER, CTSVC_SEARCH_PROPERTY_ALL, "number"}, - {CTSVC_PROPERTY_NUMBER_NUMBER_FILTER, CTSVC_SEARCH_PROPERTY_FILTER, "normalized_number"}, + {CTSVC_PROPERTY_NUMBER_NUMBER_FILTER, CTSVC_SEARCH_PROPERTY_FILTER, "minmatch"}, + {CTSVC_PROPERTY_NUMBER_NORMALIZED_NUMBER, CTSVC_SEARCH_PROPERTY_FILTER, "normalized_number"}, }; const property_info_s __property_contact_email[] = { // _contacts_contact_email diff --git a/common/ctsvc_view.h b/common/ctsvc_view.h index 9c39a2b..aa9491f 100644 --- a/common/ctsvc_view.h +++ b/common/ctsvc_view.h @@ -180,6 +180,8 @@ typedef enum { // person-stat CTSVC_PROPERTY_PERSON_USAGE_TYPE = (CTSVC_PROPERTY_PERSON | CTSVC_VIEW_DATA_TYPE_INT) +14, CTSVC_PROPERTY_PERSON_TIMES_USED = (CTSVC_PROPERTY_PERSON | CTSVC_VIEW_DATA_TYPE_INT) +15, + // added + CTSVC_PROPERTY_PERSON_MESSAGE_ALERT = (CTSVC_PROPERTY_PERSON | CTSVC_VIEW_DATA_TYPE_STR) +16, // simple contact : read only // contact @@ -212,6 +214,7 @@ typedef enum { CTSVC_PROPERTY_CONTACT_GROUP_RELATION = (CTSVC_PROPERTY_CONTACT | CTSVC_VIEW_DATA_TYPE_REC) +26, CTSVC_PROPERTY_CONTACT_EXTENSION = (CTSVC_PROPERTY_CONTACT | CTSVC_VIEW_DATA_TYPE_REC) +27, CTSVC_PROPERTY_CONTACT_LINK_MODE = (CTSVC_PROPERTY_CONTACT | CTSVC_VIEW_DATA_TYPE_INT) +28, + CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT = (CTSVC_PROPERTY_PERSON | CTSVC_VIEW_DATA_TYPE_STR) +29, // my_profile CTSVC_PROPERTY_MY_PROFILE_ID = (CTSVC_PROPERTY_MY_PROFILE | CTSVC_VIEW_DATA_TYPE_INT | CTSVC_READ_ONLY_PROPERTY), @@ -256,6 +259,7 @@ typedef enum { CTSVC_PROPERTY_NUMBER_IS_DEFAULT = (CTSVC_PROPERTY_NUMBER | CTSVC_VIEW_DATA_TYPE_BOOL) +4, CTSVC_PROPERTY_NUMBER_NUMBER = (CTSVC_PROPERTY_NUMBER | CTSVC_VIEW_DATA_TYPE_STR) +5, CTSVC_PROPERTY_NUMBER_NUMBER_FILTER = (CTSVC_PROPERTY_NUMBER | CTSVC_VIEW_DATA_TYPE_STR) +6, + CTSVC_PROPERTY_NUMBER_NORMALIZED_NUMBER = (CTSVC_PROPERTY_NUMBER | CTSVC_VIEW_DATA_TYPE_STR | CTSVC_READ_ONLY_PROPERTY) +7, // contact_email CTSVC_PROPERTY_EMAIL_ID = (CTSVC_PROPERTY_EMAIL | CTSVC_VIEW_DATA_TYPE_INT | CTSVC_READ_ONLY_PROPERTY), @@ -419,6 +423,7 @@ typedef enum { CTSVC_PROPERTY_SPEEDDIAL_PERSON_ID = (CTSVC_PROPERTY_SPEEDDIAL | CTSVC_VIEW_DATA_TYPE_INT | CTSVC_READ_ONLY_PROPERTY) +5, CTSVC_PROPERTY_SPEEDDIAL_DISPLAY_NAME = (CTSVC_PROPERTY_SPEEDDIAL | CTSVC_VIEW_DATA_TYPE_STR | CTSVC_READ_ONLY_PROPERTY) +6, CTSVC_PROPERTY_SPEEDDIAL_IMAGE_THUMBNAIL = (CTSVC_PROPERTY_SPEEDDIAL | CTSVC_VIEW_DATA_TYPE_STR | CTSVC_READ_ONLY_PROPERTY) +7, + CTSVC_PROPERTY_SPEEDDIAL_NORMALIZED_NUMBER = (CTSVC_PROPERTY_SPEEDDIAL | CTSVC_VIEW_DATA_TYPE_STR | CTSVC_READ_ONLY_PROPERTY) +8, // phonelog CTSVC_PROPERTY_PHONELOG_ID = (CTSVC_PROPERTY_PHONELOG | CTSVC_VIEW_DATA_TYPE_INT | CTSVC_READ_ONLY_PROPERTY), @@ -428,6 +433,7 @@ typedef enum { CTSVC_PROPERTY_PHONELOG_LOG_TYPE = (CTSVC_PROPERTY_PHONELOG | CTSVC_VIEW_DATA_TYPE_INT) +4, CTSVC_PROPERTY_PHONELOG_EXTRA_DATA1 = (CTSVC_PROPERTY_PHONELOG | CTSVC_VIEW_DATA_TYPE_INT) +5, // duration, message_id, email_id CTSVC_PROPERTY_PHONELOG_EXTRA_DATA2 = (CTSVC_PROPERTY_PHONELOG | CTSVC_VIEW_DATA_TYPE_STR) +6, // short message, subject + CTSVC_PROPERTY_PHONELOG_NORMALIZED_ADDRESS = (CTSVC_PROPERTY_PHONELOG | CTSVC_VIEW_DATA_TYPE_STR|CTSVC_READ_ONLY_PROPERTY) +7, // for search by calllog number // updated_info : read only CTSVC_PROPERTY_UPDATE_INFO_ID = (CTSVC_PROPERTY_UPDATE_INFO | CTSVC_VIEW_DATA_TYPE_INT), diff --git a/common/ipc/ctsvc_ipc_contact.c b/common/ipc/ctsvc_ipc_contact.c index 75d65a9..2d1dd30 100644 --- a/common/ipc/ctsvc_ipc_contact.c +++ b/common/ipc/ctsvc_ipc_contact.c @@ -59,6 +59,7 @@ static int __ctsvc_ipc_unmarshal_contact(pims_ipc_data_h ipc_data, const char* v if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->image_thumbnail_path) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->ringtone_path) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->vibration) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->message_alert) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_child_list(ipc_data, (contacts_list_h*)&pcontact->name) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_child_list(ipc_data, (contacts_list_h*)&pcontact->note) != CONTACTS_ERROR_NONE) break; @@ -111,6 +112,7 @@ static int __ctsvc_ipc_marshal_contact(const contacts_record_h record, pims_ipc_ if (ctsvc_ipc_marshal_string((pcontact->image_thumbnail_path),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((pcontact->ringtone_path),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((pcontact->vibration),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((pcontact->message_alert),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_list( (contacts_list_h)pcontact->name, ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_list( (contacts_list_h)pcontact->note, ipc_data) != CONTACTS_ERROR_NONE) break; diff --git a/common/ipc/ctsvc_ipc_define.h b/common/ipc/ctsvc_ipc_define.h index c2d28c3..226a3e8 100644 --- a/common/ipc/ctsvc_ipc_define.h +++ b/common/ipc/ctsvc_ipc_define.h @@ -56,6 +56,7 @@ #define CTSVC_IPC_SERVER_DB_CHANGES_BY_VERSION "changes_by_version" #define CTSVC_IPC_SERVER_DB_GET_CURRENT_VERSION "get_current_version" #define CTSVC_IPC_SERVER_DB_SEARCH_RECORDS "search_records" +#define CTSVC_IPC_SERVER_DB_SEARCH_RECORDS_WITH_RANGE "search_records_with_range" #define CTSVC_IPC_SERVER_DB_SEARCH_RECORDS_WITH_QUERY "search_records_with_query" #define CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_CONTACT_ID "activity_delete_by_contact_id" diff --git a/common/ipc/ctsvc_ipc_person.c b/common/ipc/ctsvc_ipc_person.c index fd20077..311feac 100644 --- a/common/ipc/ctsvc_ipc_person.c +++ b/common/ipc/ctsvc_ipc_person.c @@ -51,6 +51,7 @@ static int __ctsvc_ipc_unmarshal_person(pims_ipc_data_h ipc_data, const char* vi if (ctsvc_ipc_unmarshal_string(ipc_data, &person_p->image_thumbnail_path) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &person_p->ringtone_path) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &person_p->vibration) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &person_p->message_alert) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &person_p->status) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_int(ipc_data, &person_p->link_count) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &person_p->addressbook_ids) != CONTACTS_ERROR_NONE) break; @@ -80,6 +81,7 @@ static int __ctsvc_ipc_marshal_person(const contacts_record_h record, pims_ipc_d if (ctsvc_ipc_marshal_string((person_p->image_thumbnail_path),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((person_p->ringtone_path),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((person_p->vibration),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((person_p->message_alert),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((person_p->status),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_int((person_p->link_count),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((person_p->addressbook_ids),ipc_data) != CONTACTS_ERROR_NONE) break; diff --git a/common/ipc/ctsvc_ipc_simple_contact.c b/common/ipc/ctsvc_ipc_simple_contact.c index 08e605d..d231e09 100644 --- a/common/ipc/ctsvc_ipc_simple_contact.c +++ b/common/ipc/ctsvc_ipc_simple_contact.c @@ -48,6 +48,7 @@ static int __ctsvc_ipc_unmarshal_simple_contact(pims_ipc_data_h ipc_data, const if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->image_thumbnail_path) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->ringtone_path) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->vibration) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->message_alert) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->display_name) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_string(ipc_data, &pcontact->uid) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->display_source_type) != CONTACTS_ERROR_NONE) break; @@ -75,6 +76,7 @@ static int __ctsvc_ipc_marshal_simple_contact(const contacts_record_h record, pi if (ctsvc_ipc_marshal_string((pcontact->image_thumbnail_path),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((pcontact->ringtone_path),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((pcontact->vibration),ipc_data) != CONTACTS_ERROR_NONE) break; + if (ctsvc_ipc_marshal_string((pcontact->message_alert),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((pcontact->display_name),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_string((pcontact->uid),ipc_data) != CONTACTS_ERROR_NONE) break; if (ctsvc_ipc_marshal_int((pcontact->display_source_type),ipc_data) != CONTACTS_ERROR_NONE) break; diff --git a/contacts-service2.manifest b/contacts-service2.manifest index e188552..815d459 100644 --- a/contacts-service2.manifest +++ b/contacts-service2.manifest @@ -18,7 +18,7 @@ - + diff --git a/include/contacts.h b/include/contacts.h index fc3abc1..47e22af 100644 --- a/include/contacts.h +++ b/include/contacts.h @@ -557,6 +557,7 @@ * integerperson_idread only * stringuidread, write * stringvibrationread, write + * stringmessage_alertread, write * integerchanged_timeread only * integerlink_moderead, write contacts_contact_link_mode_e * recordnameread, write single @@ -626,6 +627,7 @@ * integerperson_idread only * stringuidread, write * stringvibrationread, write + * stringmessage_alertread, write * integerchanged_timeread only * * @@ -645,6 +647,7 @@ * string ringtone_path read, write * string image_thumbnail_path read only * string vibration read, write + * stringmessage_alertread, write * string status read only * boolean is_favorite read, write * double favorite_priority filter only The priority of favorite contacts. You can not set the value but you can use it as sorting key. @@ -724,6 +727,7 @@ * string label read, write * boolean is_default read, write * string number read, write + * string normalized_number filter only You can only use this property for search filter. * * * @section CAPI_SOCIAL_CONTACTS_SVC_VIEW_MODULE_contacts_email _contacts_email view @@ -1030,6 +1034,7 @@ * integer log_type read, writecontacts_phone_log_type_e * integer extra_data1 read, write once You can set the related integer data (e.g. message_id, email_id or duration of call). * string extra_data2 read, write once You can set the related string data (e.g. short message, subject). + * string normalized_address filter only You can only use this property for search filter. * * *

@@ -1111,6 +1116,7 @@ * string ringtone_path * string image_thumbnail_path * string vibration + * string message_alert * boolean is_favorite * boolean has_phonenumber * boolean has_email @@ -1119,7 +1125,8 @@ * string label * boolean is_primary_default * string number - * string number_filter If you add filter with this property, the string will be normalized internally and the match rule will be applied CONTACTS_MATCH_EXACTLY + * string number_filter If you add filter with this property, the string will be normalized as minmatch length internally and the match rule will be applied CONTACTS_MATCH_EXACTLY + * string normalized_number You can only use this property for search filter * * * @section CAPI_SOCIAL_CONTACTS_SVC_VIEW_MODULE_contacts_person_email _contacts_person_email view @@ -1138,6 +1145,7 @@ * string ringtone_path * string image_thumbnail_path * string vibration + * string message_alert * boolean is_favorite * boolean has_phonenumber * boolean has_email @@ -1164,6 +1172,7 @@ * string ringtone_path * string image_thumbnail_path * string vibration + * string message_alert * string status * boolean is_favorite * integer link_count @@ -1192,6 +1201,7 @@ * integer log_type * integer extra_data1 * string extra_data2 + * string normalized_address You can only use this property for search filter * * * @section CAPI_SOCIAL_CONTACTS_SVC_VIEW_MODULE_contacts_person_usage _contacts_person_usage view @@ -1210,6 +1220,7 @@ * string ringtone_path * string image_thumbnail_path * string vibration + * string message_alert * boolean is_favorite * boolean has_phonenumber > * boolean has_email @@ -1238,7 +1249,8 @@ * string label * boolean is_ default * string number - * string number_filter If you add filter with this property, the string will be normalized internally and the match rule will be applied CONTACTS_MATCH_EXACTLY + * string number_filter If you add filter with this property, the string will be normalized as minmatch length internally and the match rule will be applied CONTACTS_MATCH_EXACTLY + * string normalized_number You can only use this property for search filter * * * @section CAPI_SOCIAL_CONTACTS_SVC_VIEW_MODULE_contacts_contact_email _contacts_contact_email view diff --git a/include/contacts_db.h b/include/contacts_db.h index b06c9e7..c8a1fa2 100755 --- a/include/contacts_db.h +++ b/include/contacts_db.h @@ -598,6 +598,32 @@ API int contacts_db_search_records(const char* view_uri, const char *keyword, in */ API int contacts_db_search_records_with_query(contacts_query_h query, const char *keyword, int offset, int limit, contacts_list_h* record_list); +/** + * @brief Retrieves records with a keyword in range + * + * @remarks @a record_list must be released with contacts_list_destroy() by you. \n + * This API works only for \ref CAPI_SOCIAL_CONTACTS_SVC_VIEW_MODULE_contacts_person and \ref CAPI_SOCIAL_CONTACTS_SVC_VIEW_MODULE_contacts_person_grouprel. + * + * @param[in] view_uri The view URI to get records + * @param[in] keyword Thekeyword + * @param[in] offset The index to get results from which index + * @param[in] limit The number to limit results + * @param[in] range The search range + * @param[out] record_list The record list + * + * @return 0 on success, otherwise a negative error value. + * @retval #CONTACTS_ERROR_NONE Successful + * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONTACTS_ERROR_DB Database operation failure + * + * @pre This function requires an open connection to contacts service by contacts_connect2(). + * + * @see contacts_connect2() + * @see contacts_list_destroy() + */ +API int contacts_db_search_records_with_range(const char* view_uri, const char *keyword, int offset, int limit, int range, contacts_list_h* record_list); + /** * @brief Gets records count of a specific view * diff --git a/include/contacts_phone_log.h b/include/contacts_phone_log.h index f799307..903ed08 100644 --- a/include/contacts_phone_log.h +++ b/include/contacts_phone_log.h @@ -45,7 +45,7 @@ extern "C" * * @see contacts_connect2() */ -API int contacts_phone_log_reset_statistics(); +API int contacts_phone_log_reset_statistics(void); typedef enum { CONTACTS_PHONE_LOG_DELETE_BY_ADDRESS, /**< . */ diff --git a/include/contacts_service.h b/include/contacts_service.h index a82b9bc..032db20 100755 --- a/include/contacts_service.h +++ b/include/contacts_service.h @@ -45,7 +45,7 @@ extern "C" * * @see contacts_disconnect2() */ -API int contacts_connect2(); +API int contacts_connect2(void); /** * @brief Disconnects from the contacts service. @@ -58,7 +58,7 @@ API int contacts_connect2(); * * @see contacts_connect2() */ -API int contacts_disconnect2(); +API int contacts_disconnect2(void); @@ -73,7 +73,7 @@ API int contacts_disconnect2(); * * @see contacts_disconnect_on_thread() */ -API int contacts_connect_on_thread(); +API int contacts_connect_on_thread(void); /** * @brief Disconnects from the contacts service. @@ -86,7 +86,7 @@ API int contacts_connect_on_thread(); * * @see contacts_connect_on_thread() */ -API int contacts_disconnect_on_thread(); +API int contacts_disconnect_on_thread(void); #define CONTACTS_CONNECT_FLAG_RETRY 0x00000001 diff --git a/include/contacts_sim.h b/include/contacts_sim.h index 3a7019c..b75dba0 100644 --- a/include/contacts_sim.h +++ b/include/contacts_sim.h @@ -44,7 +44,7 @@ extern "C" * * @see contacts_connect2() */ -API int contacts_sim_import_all_contacts(); +API int contacts_sim_import_all_contacts(void); /** diff --git a/include/contacts_types.h b/include/contacts_types.h index f491877..60dd0ca 100644 --- a/include/contacts_types.h +++ b/include/contacts_types.h @@ -95,7 +95,8 @@ typedef enum { CONTACTS_NUMBER_TYPE_ISDN = 1<<11, /**< An ISDN service telephone number */ CONTACTS_NUMBER_TYPE_VIDEO = 1<<12, /**< A video conferencing telephone number */ CONTACTS_NUMBER_TYPE_PCS = 1<<13, /**< A personal communication services telephone number */ - + CONTACTS_NUMBER_TYPE_COMPANY_MAIN = 1<<14, /**< A company main number */ + CONTACTS_NUMBER_TYPE_RADIO = 1<<15, /**< A radio phone number */ CONTACTS_NUMBER_TYPE_ASSISTANT = 1<<30, /**< A additional type for assistant */ }contacts_number_type_e; @@ -225,6 +226,12 @@ typedef enum { CONTACTS_RELATIONSHIP_TYPE_CUSTOM, /**< .*/ }contacts_relationship_type_e; +typedef enum { + CONTACTS_SEARCH_RANGE_NAME = 0x00000001, /**< .*/ + CONTACTS_SEARCH_RANGE_NUMBER = 0x00000002, /**< .*/ + CONTACTS_SEARCH_RANGE_DATA = 0x00000004, /**< .*/ +}contacts_search_range_e; + /** * @} */ diff --git a/include/contacts_views.h b/include/contacts_views.h index 2660343..90bbe36 100755 --- a/include/contacts_views.h +++ b/include/contacts_views.h @@ -62,11 +62,12 @@ _CONTACTS_BEGIN_VIEW() _CONTACTS_PROPERTY_STR( vibration ) // read, write _CONTACTS_PROPERTY_STR( status ) // read only _CONTACTS_PROPERTY_BOOL( is_favorite ) // read, write - _CONTACTS_PROPERTY_DOUBLE( favorite_priority ) // read only + _CONTACTS_PROPERTY_DOUBLE( favorite_priority ) // filter only _CONTACTS_PROPERTY_INT( link_count ) // read only _CONTACTS_PROPERTY_STR( addressbook_ids ) // read only _CONTACTS_PROPERTY_BOOL( has_phonenumber ) // read only _CONTACTS_PROPERTY_BOOL( has_email ) // read only + _CONTACTS_PROPERTY_STR( message_alert ) // read, write _CONTACTS_END_VIEW( _contacts_person ) // simple contact @@ -84,6 +85,7 @@ _CONTACTS_BEGIN_VIEW() _CONTACTS_PROPERTY_STR( uid ) // read, write _CONTACTS_PROPERTY_STR( vibration ) // read, write _CONTACTS_PROPERTY_INT( changed_time ) // read only + _CONTACTS_PROPERTY_STR( message_alert ) // read, write _CONTACTS_END_VIEW( _contacts_simple_contact ) // contact @@ -117,6 +119,7 @@ _CONTACTS_BEGIN_VIEW() _CONTACTS_PROPERTY_CHILD_MULTIPLE( relationship ) // read, write _CONTACTS_PROPERTY_CHILD_MULTIPLE( group_relation ) // read, write _CONTACTS_PROPERTY_CHILD_MULTIPLE( extension ) // read, write + _CONTACTS_PROPERTY_STR( message_alert ) // read, write _CONTACTS_END_VIEW( _contacts_contact ) // my_profile @@ -166,6 +169,7 @@ _CONTACTS_BEGIN_VIEW() _CONTACTS_PROPERTY_STR( label ) // read, write _CONTACTS_PROPERTY_BOOL( is_default ) // read, write _CONTACTS_PROPERTY_STR( number ) // read, write + _CONTACTS_PROPERTY_STR( normalized_number ) // filter only _CONTACTS_END_VIEW( _contacts_number ) // contact_email @@ -352,6 +356,7 @@ _CONTACTS_BEGIN_VIEW() _CONTACTS_PROPERTY_INT( person_id ) // read only _CONTACTS_PROPERTY_STR( display_name ) // read only _CONTACTS_PROPERTY_STR( image_thumbnail_path ) // read only + _CONTACTS_PROPERTY_STR( normalized_number) // filter only _CONTACTS_END_VIEW( _contacts_speeddial ) // phone_log @@ -363,6 +368,7 @@ _CONTACTS_BEGIN_VIEW() _CONTACTS_PROPERTY_INT( log_type ) // read, write _CONTACTS_PROPERTY_INT( extra_data1 ) // read, write once : message or email id, duration _CONTACTS_PROPERTY_STR( extra_data2 ) // read, write once : shortmsg, subject + _CONTACTS_PROPERTY_STR( normalized_address ) // filter only _CONTACTS_END_VIEW( _contacts_phone_log ) // contact_updated_info : read only @@ -426,6 +432,7 @@ _CONTACTS_BEGIN_READ_ONLY_VIEW() _CONTACTS_PROPERTY_INT( address_book_id ) _CONTACTS_PROPERTY_STR( address_book_name ) _CONTACTS_PROPERTY_INT( address_book_mode ) + _CONTACTS_PROPERTY_PROJECTION_STR( message_alert ) _CONTACTS_END_READ_ONLY_VIEW( _contacts_person_contact ) // person_number : read only @@ -446,6 +453,8 @@ _CONTACTS_BEGIN_READ_ONLY_VIEW() _CONTACTS_PROPERTY_BOOL( is_primary_default ) _CONTACTS_PROPERTY_STR( number ) _CONTACTS_PROPERTY_FILTER_STR( number_filter ) + _CONTACTS_PROPERTY_FILTER_STR( normalized_number ) + _CONTACTS_PROPERTY_PROJECTION_STR( message_alert ) _CONTACTS_END_READ_ONLY_VIEW( _contacts_person_number ) // person_email : read only @@ -465,6 +474,7 @@ _CONTACTS_BEGIN_READ_ONLY_VIEW() _CONTACTS_PROPERTY_PROJECTION_STR( label ) _CONTACTS_PROPERTY_BOOL( is_primary_default ) _CONTACTS_PROPERTY_STR( email ) + _CONTACTS_PROPERTY_PROJECTION_STR( message_alert ) _CONTACTS_END_READ_ONLY_VIEW( _contacts_person_email ) // person_group : read only @@ -487,6 +497,7 @@ _CONTACTS_BEGIN_READ_ONLY_VIEW() _CONTACTS_PROPERTY_STR( address_book_name ) _CONTACTS_PROPERTY_INT( address_book_mode ) _CONTACTS_PROPERTY_PROJECTION_INT( contact_id ) + _CONTACTS_PROPERTY_PROJECTION_STR( message_alert ) _CONTACTS_END_READ_ONLY_VIEW( _contacts_person_grouprel ) //person phone_log : read only @@ -501,6 +512,7 @@ _CONTACTS_BEGIN_READ_ONLY_VIEW() _CONTACTS_PROPERTY_INT( log_type ) _CONTACTS_PROPERTY_PROJECTION_INT( extra_data1 ) _CONTACTS_PROPERTY_PROJECTION_STR( extra_data2 ) + _CONTACTS_PROPERTY_FILTER_STR( normalized_address) _CONTACTS_END_READ_ONLY_VIEW( _contacts_person_phone_log ) // person, stat : read only @@ -517,6 +529,7 @@ _CONTACTS_BEGIN_READ_ONLY_VIEW() _CONTACTS_PROPERTY_BOOL( has_email ) _CONTACTS_PROPERTY_INT( usage_type ) _CONTACTS_PROPERTY_INT( times_used ) + _CONTACTS_PROPERTY_PROJECTION_STR( message_alert ) _CONTACTS_END_READ_ONLY_VIEW( _contacts_person_usage ) // simple contact number : read only @@ -534,6 +547,7 @@ _CONTACTS_BEGIN_READ_ONLY_VIEW() _CONTACTS_PROPERTY_BOOL( is_default ) _CONTACTS_PROPERTY_STR( number ) _CONTACTS_PROPERTY_FILTER_STR( number_filter ) + _CONTACTS_PROPERTY_FILTER_STR( normalized_number ) _CONTACTS_END_READ_ONLY_VIEW( _contacts_contact_number ) // simple contact email : read only diff --git a/native/ctsvc_db_init.c b/native/ctsvc_db_init.c index 353dc3a..9d110d6 100644 --- a/native/ctsvc_db_init.c +++ b/native/ctsvc_db_init.c @@ -267,6 +267,7 @@ static int __ctsvc_db_create_views() "persons.ringtone_path, " "persons.image_thumbnail_path, " "persons.vibration, " + "persons.message_alert, " "status, " "link_count, " "addressbook_ids, " @@ -310,7 +311,8 @@ static int __ctsvc_db_create_views() "data1, " "data2, " "data3, " - "data4 " + "data4, " + "data5 " "FROM "CTS_TABLE_DATA", "CTSVC_DB_VIEW_CONTACT" " "ON "CTS_TABLE_DATA".contact_id = "CTSVC_DB_VIEW_CONTACT".contact_id " "WHERE datatype = %d AND is_my_profile = 0 ", @@ -586,6 +588,7 @@ static int __ctsvc_db_create_views() "data.data1 type, " "data.data2 label, " "data.data3 number, " + "data.data5 normalized_number, " "speeddials.speed_number " "FROM "CTS_TABLE_PERSONS", "CTS_TABLE_CONTACTS" AS name_contacts, " CTSVC_DB_VIEW_CONTACT" AS temp_contacts, " @@ -662,7 +665,8 @@ static int __ctsvc_db_create_views() "is_primary_default, " "data2 label, " "data3 number, " - "data4 normalized_number " + "data4 minmatch, " + "data5 normalized_number " "FROM "CTS_TABLE_DATA" WHERE datatype = %d AND is_my_profile = 0) temp_data " "ON temp_data.contact_id = "CTSVC_DB_VIEW_PERSON_CONTACT".contact_id", CTSVC_DATA_NUMBER); @@ -696,20 +700,21 @@ static int __ctsvc_db_create_views() "F.sortkey, F.reverse_sortkey, " "F.image_thumbnail_path, " "C.number address, " + "C.normal_num, " "C.log_type, " "C.log_time, " "C.data1, " "C.data2, " "C.person_id id, " "C.number_type address_type " - "FROM (SELECT A.id, A.number, A.log_type, A.log_time, A.data1, A.data2, " + "FROM (SELECT A.id, A.number, A.normal_num, A.log_type, A.log_time, A.data1, A.data2, " "MIN(B.person_id) person_id, B.data1 number_type " "FROM "CTS_TABLE_PHONELOGS" A " "LEFT JOIN (SELECT G.person_id person_id, G.contact_id contact_id, " "H.datatype datatype, H.data1 data1, H.data4 data4 " "FROM "CTSVC_DB_VIEW_CONTACT" G, "CTS_TABLE_DATA" H " "ON H.datatype = %d AND G.contact_id = H.contact_id AND H.is_my_profile = 0 ) B " - "ON A.normal_num = B.data4 " + "ON A.minmatch = B.data4 " "AND (A.person_id = B.person_id " "OR A.person_id IS NULL " "OR NOT EXISTS (SELECT id FROM "CTS_TABLE_DATA" " @@ -717,7 +722,7 @@ static int __ctsvc_db_create_views() "AND contact_id IN(SELECT contact_id " "FROM "CTSVC_DB_VIEW_CONTACT" " "WHERE person_id = A.person_id) " - "AND A.normal_num = data4)) " + "AND A.minmatch = data4)) " "GROUP BY A.id) C " "LEFT JOIN (SELECT D.person_id, D.display_name, D.reverse_display_name, " "D.display_name_language, " @@ -770,7 +775,8 @@ static int __ctsvc_db_create_views() "is_default, " "data2 label, " "data3 number, " - "data4 normalized_number " + "data4 minmatch, " + "data5 normalized_number " "FROM "CTS_TABLE_DATA" WHERE datatype = %d AND is_my_profile = 0) temp_data " "ON temp_data.contact_id = "CTSVC_DB_VIEW_CONTACT".contact_id", CTSVC_DATA_NUMBER); diff --git a/native/ctsvc_db_plugin_addressbook.c b/native/ctsvc_db_plugin_addressbook.c index 7ce63d6..bc0c150 100644 --- a/native/ctsvc_db_plugin_addressbook.c +++ b/native/ctsvc_db_plugin_addressbook.c @@ -101,7 +101,10 @@ static int __ctsvc_db_addressbook_get_record( int id, contacts_record_h* out_rec if (1 /*CTS_TRUE*/ != ret) { CTS_ERR("cts_stmt_step() Failed(%d)", ret); cts_stmt_finalize(stmt); - return CONTACTS_ERROR_NO_DATA; + if (CONTACTS_ERROR_NONE == ret) + return CONTACTS_ERROR_NO_DATA; + else + return ret; } ret = __ctsvc_db_addressbook_value_set(stmt, &record); diff --git a/native/ctsvc_db_plugin_contact.c b/native/ctsvc_db_plugin_contact.c index 8385d09..2769e6f 100644 --- a/native/ctsvc_db_plugin_contact.c +++ b/native/ctsvc_db_plugin_contact.c @@ -30,6 +30,7 @@ #include "ctsvc_utils.h" #include "ctsvc_record.h" #include "ctsvc_normalize.h" +#include "ctsvc_number_utils.h" #include "ctsvc_list.h" #include "ctsvc_setting.h" #include "ctsvc_localize_ch.h" @@ -84,7 +85,8 @@ static int __ctsvc_db_get_contact_base_info(int id, ctsvc_contact_s *contact) len = snprintf(query, sizeof(query), "SELECT contact_id, addressbook_id, person_id, changed_time, link_mode, %s, " "display_name_source, image_thumbnail_path, " - "ringtone_path, vibration, uid, is_favorite, has_phonenumber, has_email, " + "ringtone_path, vibration, message_alert, " + "uid, is_favorite, has_phonenumber, has_email, " "sort_name, reverse_sort_name " "FROM "CTS_TABLE_CONTACTS" WHERE contact_id = %d AND deleted = 0", ctsvc_get_display_column(), id); @@ -120,6 +122,8 @@ static int __ctsvc_db_get_contact_base_info(int id, ctsvc_contact_s *contact) temp = ctsvc_stmt_get_text(stmt, i++); contact->vibration = SAFE_STRDUP(temp); temp = ctsvc_stmt_get_text(stmt, i++); + contact->message_alert = SAFE_STRDUP(temp); + temp = ctsvc_stmt_get_text(stmt, i++); contact->uid = SAFE_STRDUP(temp); contact->is_favorite = ctsvc_stmt_get_int(stmt, i++); contact->has_phonenumber = ctsvc_stmt_get_int(stmt, i++); @@ -473,16 +477,22 @@ static inline void __ctsvc_contact_get_initial(char *src, char *dest, int dest_s int i, j=0; bool bFirst = true; int len = strlen(src); - for(i = 0; i < len && j < (dest_size-1); i++) + for(i = 0; i < len && j < (dest_size-1);) { if (src[i] == ' ') { bFirst=true; + i++; } else if (bFirst) { - dest[j++] = src[i]; + int char_len = ctsvc_check_utf8(src[i]); + int k; + for (k=0;knumber, normalized_number, CTSVC_NUMBER_MAX_LEN, CTSVC_NUMBER_MAX_LEN -1); + if (NULL != number_record && number_record->number) { + char normal_num[CTSVC_NUMBER_MAX_LEN] = {0}; + ret = ctsvc_normalize_number(number_record->number, normal_num, sizeof(normal_num)); + if (ret <= 0) + continue; snprintf(query, sizeof(query), "INSERT INTO %s(data_id, contact_id, number, min_match) " - "VALUES(%d, %d, ?, ?)", CTS_TABLE_PHONE_LOOKUP, number_record->id, + "VALUES(%d, %d, ?, ?)", CTS_TABLE_PHONE_LOOKUP, number_record->id, contact_id); stmt = cts_query_prepare(query); @@ -1007,8 +1018,8 @@ static inline int __ctsvc_contact_refresh_lookup_data(int contact_id) return CONTACTS_ERROR_DB; } - if (*normalized_number) - cts_stmt_bind_text(stmt, 1, normalized_number); + if (*normal_num) + cts_stmt_bind_text(stmt, 1, normal_num); if (number_record->lookup) cts_stmt_bind_text(stmt, 2, number_record->lookup); @@ -1096,7 +1107,7 @@ static inline int __ctsvc_update_contact_search_data(int contact_id) ret = __ctsvc_contact_make_search_data(contact_id, &search_name, &search_number, &search_data); if (CONTACTS_ERROR_NONE != ret) { - CTS_ERR("cts_make_contact_search_data() Failed(%d)", ret); + CTS_ERR("__ctsvc_contact_make_search_data() Failed(%d)", ret); cts_stmt_finalize(stmt); ctsvc_end_trans(false); return ret; @@ -1480,6 +1491,10 @@ static int __ctsvc_db_contact_get_records_with_query( contacts_query_h query, in temp = ctsvc_stmt_get_text(stmt, i); contact->vibration = SAFE_STRDUP(temp); break; + case CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT: + temp = ctsvc_stmt_get_text(stmt, i); + contact->message_alert = SAFE_STRDUP(temp); + break; case CTSVC_PROPERTY_CONTACT_CHANGED_TIME: contact->changed_time = ctsvc_stmt_get_int(stmt, i); break; @@ -1761,23 +1776,22 @@ static inline int __ctsvc_contact_insert_grouprel(int contact_id, contacts_list_ return CONTACTS_ERROR_NONE; } -inline static int __ctsvc_find_person_to_link_with_number(const char *normalized_number, int addressbook_id, int *person_id) +inline static int __ctsvc_find_person_to_link_with_number(const char *number, int addressbook_id, int *person_id) { int ret; - char query[CTS_SQL_MIN_LEN] = {0}; + char minmatch[CTSVC_NUMBER_MAX_LEN] = {0}; char normal_num[CTSVC_NUMBER_MAX_LEN] = {0}; - char clean_num[CTSVC_NUMBER_MAX_LEN] = {0}; - ret = ctsvc_clean_number(normalized_number, clean_num, sizeof(clean_num)); + ret = ctsvc_normalize_number(number, normal_num, sizeof(normal_num)); if (0 < ret) { - ret = ctsvc_normalize_number(clean_num, normal_num, CTSVC_NUMBER_MAX_LEN, ctsvc_get_phonenumber_min_match_digit()); + ret = ctsvc_get_minmatch_number(normal_num, minmatch, CTSVC_NUMBER_MAX_LEN, ctsvc_get_phonenumber_min_match_digit()); snprintf(query, sizeof(query), "SELECT C.person_id FROM "CTS_TABLE_CONTACTS" C, "CTS_TABLE_DATA" D " "ON C.contact_id=D.contact_id AND D.datatype=%d AND C.deleted = 0 " "AND C.addressbook_id <> %d " "WHERE D.data4='%s' AND D.is_my_profile = 0", - CTSVC_DATA_NUMBER, addressbook_id, normal_num); + CTSVC_DATA_NUMBER, addressbook_id, minmatch); ret = ctsvc_query_get_first_int_result(query, person_id); CTS_DBG("%s", query); CTS_DBG("result ret(%d) person_id(%d)", ret, *person_id); @@ -1953,8 +1967,8 @@ static int __ctsvc_db_contact_insert_record( contacts_record_h record, int *id) "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, %d, %d, ?, ?, ?, ?, ?, ?, ?, ?)", + "uid, ringtone_path, vibration, message_alert, image_thumbnail_path) " + "VALUES(%d, %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), contact->link_mode, (NULL !=contact->image_thumbnail_path)?version:0, contact->has_phonenumber, contact->has_email, @@ -1985,8 +1999,10 @@ static int __ctsvc_db_contact_insert_record( contacts_record_h record, int *id) cts_stmt_bind_text(stmt, 8, contact->ringtone_path); if (contact->vibration) cts_stmt_bind_text(stmt, 9, contact->vibration); + if (contact->message_alert) + cts_stmt_bind_text(stmt, 10, contact->message_alert); if (contact->image_thumbnail_path) - cts_stmt_bind_text(stmt, 10, contact->image_thumbnail_path); + cts_stmt_bind_text(stmt, 11, contact->image_thumbnail_path); ret = cts_stmt_step(stmt); if (CONTACTS_ERROR_NONE != ret) { @@ -2140,7 +2156,7 @@ static int __ctsvc_db_contact_replace_record( contacts_record_h record, int cont "display_name_language=%d, reverse_display_name_language=%d, " "sort_name=?, reverse_sort_name=?, " "sortkey=?, reverse_sortkey=?, uid=?, ringtone_path=?, vibration=?, " - "image_thumbnail_path=?", + "message_alert =?, image_thumbnail_path=?", version, (int)time(NULL), contact->has_phonenumber, contact->has_email, contact->display_source_type, @@ -2176,8 +2192,10 @@ static int __ctsvc_db_contact_replace_record( contacts_record_h record, int cont cts_stmt_bind_text(stmt, 8, contact->ringtone_path); if (contact->vibration) cts_stmt_bind_text(stmt, 9, contact->vibration); + if (contact->message_alert) + cts_stmt_bind_text(stmt, 10, contact->message_alert); if (contact->image_thumbnail_path) - cts_stmt_bind_text(stmt, 10, contact->image_thumbnail_path); + cts_stmt_bind_text(stmt, 11, contact->image_thumbnail_path); ret = cts_stmt_step(stmt); if (CONTACTS_ERROR_NONE != ret) { diff --git a/native/ctsvc_db_plugin_image_helper.c b/native/ctsvc_db_plugin_image_helper.c index f674c9d..e1b6684 100644 --- a/native/ctsvc_db_plugin_image_helper.c +++ b/native/ctsvc_db_plugin_image_helper.c @@ -98,7 +98,7 @@ int ctsvc_db_image_insert(contacts_record_h record, int contact_id, bool is_my_p ret = ctsvc_contact_add_image_file(contact_id, image_id, image->path, image_path, sizeof(image_path)); if (CONTACTS_ERROR_NONE != ret) { - CTS_ERR("ctsvc_contact_add_image_file(NORMAL) Failed(%d)", ret); + CTS_ERR("ctsvc_contact_add_image_file() Failed(%d)", ret); return ret; } free(image->path); diff --git a/native/ctsvc_db_plugin_name_helper.c b/native/ctsvc_db_plugin_name_helper.c index 383acad..3e7a766 100644 --- a/native/ctsvc_db_plugin_name_helper.c +++ b/native/ctsvc_db_plugin_name_helper.c @@ -211,7 +211,6 @@ int ctsvc_db_name_insert(contacts_record_h record, int contact_id, bool is_my_pr ctsvc_set_name_noti(); } - // update search index table return CONTACTS_ERROR_NONE; } diff --git a/native/ctsvc_db_plugin_number_helper.c b/native/ctsvc_db_plugin_number_helper.c index c426877..a77e86d 100644 --- a/native/ctsvc_db_plugin_number_helper.c +++ b/native/ctsvc_db_plugin_number_helper.c @@ -24,6 +24,7 @@ #include "ctsvc_db_init.h" #include "ctsvc_db_query.h" #include "ctsvc_normalize.h" +#include "ctsvc_number_utils.h" #include "ctsvc_db_plugin_number_helper.h" #include "ctsvc_record.h" #include "ctsvc_notification.h" @@ -35,8 +36,8 @@ int ctsvc_db_number_insert(contacts_record_h record, int contact_id, bool is_my_ cts_stmt stmt = NULL; char query[CTS_SQL_MAX_LEN] = {0}; ctsvc_number_s *number = (ctsvc_number_s *)record; + char minmatch[CTSVC_NUMBER_MAX_LEN] = {0}; char normal_num[CTSVC_NUMBER_MAX_LEN] = {0}; - char clean_num[CTSVC_NUMBER_MAX_LEN] = {0}; RETV_IF(NULL == number->number, CONTACTS_ERROR_NONE); RETVM_IF(contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER, @@ -45,8 +46,8 @@ int ctsvc_db_number_insert(contacts_record_h record, int contact_id, bool is_my_ "Invalid parameter : id(%d), This record is already inserted", number->id); snprintf(query, sizeof(query), - "INSERT INTO "CTS_TABLE_DATA"(contact_id, is_my_profile, datatype, is_default, data1, data2, data3, data4) " - "VALUES(%d, %d, %d, %d, %d, ?, ?, ?)", + "INSERT INTO "CTS_TABLE_DATA"(contact_id, is_my_profile, datatype, is_default, data1, data2, data3, data4, data5) " + "VALUES(%d, %d, %d, %d, %d, ?, ?, ?, ?)", contact_id, is_my_profile, CTSVC_DATA_NUMBER, number->is_default, number->type); stmt = cts_query_prepare(query); @@ -56,11 +57,12 @@ int ctsvc_db_number_insert(contacts_record_h record, int contact_id, bool is_my_ cts_stmt_bind_text(stmt, 1, number->label); cts_stmt_bind_text(stmt, 2, number->number); - ret = ctsvc_clean_number(number->number, clean_num, sizeof(clean_num)); + ret = ctsvc_normalize_number(number->number, normal_num, sizeof(normal_num)); if (0 < ret) { - ret = ctsvc_normalize_number(clean_num, normal_num, CTSVC_NUMBER_MAX_LEN, ctsvc_get_phonenumber_min_match_digit()); + cts_stmt_bind_text(stmt, 4, normal_num); + ret = ctsvc_get_minmatch_number(normal_num, minmatch, CTSVC_NUMBER_MAX_LEN, ctsvc_get_phonenumber_min_match_digit()); if (CONTACTS_ERROR_NONE == ret) - cts_stmt_bind_text(stmt, 3, normal_num); + cts_stmt_bind_text(stmt, 3, minmatch); } ret = cts_stmt_step(stmt); @@ -114,12 +116,13 @@ int ctsvc_db_number_update(contacts_record_h record, bool is_my_profile) GSList *bind_text = NULL; GSList *cursor = NULL; ctsvc_number_s *number = (ctsvc_number_s *)record; - char clean_num[CTSVC_NUMBER_MAX_LEN] = {0}; char normal_num[CTSVC_NUMBER_MAX_LEN] = {0}; + char minmatch[CTSVC_NUMBER_MAX_LEN] = {0}; char query[CTS_SQL_MAX_LEN] = {0}; RETVM_IF(!number->id, CONTACTS_ERROR_INVALID_PARAMETER, "number of contact has no ID."); - RETVM_IF(CTSVC_PROPERTY_FLAG_DIRTY != (number->base.property_flag & CTSVC_PROPERTY_FLAG_DIRTY), CONTACTS_ERROR_NONE, "No update"); + RETVM_IF(CTSVC_PROPERTY_FLAG_DIRTY != (number->base.property_flag & CTSVC_PROPERTY_FLAG_DIRTY), + CONTACTS_ERROR_NONE, "No update"); snprintf(query, sizeof(query), "SELECT id FROM "CTS_TABLE_DATA" WHERE id = %d", number->id); @@ -129,12 +132,19 @@ int ctsvc_db_number_update(contacts_record_h record, bool is_my_profile) do { if (CONTACTS_ERROR_NONE != (ret = ctsvc_db_create_set_query(record, &set, &bind_text))) break; if (ctsvc_record_check_property_flag((ctsvc_record_s *)record, CTSVC_PROPERTY_NUMBER_NUMBER, CTSVC_PROPERTY_FLAG_DIRTY)) { - ret = ctsvc_clean_number(number->number, clean_num, sizeof(clean_num)); + ret = ctsvc_normalize_number(number->number, normal_num, sizeof(normal_num)); if (0 < ret) { - ret = ctsvc_normalize_number(clean_num, normal_num, CTSVC_NUMBER_MAX_LEN, ctsvc_get_phonenumber_min_match_digit()); + char query_set[CTS_SQL_MAX_LEN] = {0}; + ret = ctsvc_get_minmatch_number(normal_num, minmatch, CTSVC_NUMBER_MAX_LEN, ctsvc_get_phonenumber_min_match_digit()); if (CONTACTS_ERROR_NONE == ret) { - char query_set[CTS_SQL_MAX_LEN] = {0}; - snprintf(query_set, sizeof(query_set), "%s, data4=?", set); + snprintf(query_set, sizeof(query_set), "%s, data4=?, data5=?", set); + free(set); + set = strdup(query_set); + bind_text = g_slist_append(bind_text, strdup(minmatch)); + bind_text = g_slist_append(bind_text, strdup(normal_num)); + } + else { + snprintf(query_set, sizeof(query_set), "%s, data5=?", set); free(set); set = strdup(query_set); bind_text = g_slist_append(bind_text, strdup(normal_num)); diff --git a/native/ctsvc_db_plugin_person.c b/native/ctsvc_db_plugin_person.c index 9f2da6e..54e7432 100644 --- a/native/ctsvc_db_plugin_person.c +++ b/native/ctsvc_db_plugin_person.c @@ -83,6 +83,7 @@ static int __ctsvc_db_person_get_record( int id, contacts_record_h* out_record ) "persons.image_thumbnail_path, " "persons.ringtone_path, " "persons.vibration, " + "persons.message_alert, " "status, " "link_count, " "addressbook_ids, " @@ -249,6 +250,8 @@ static int __ctsvc_db_person_update_record( contacts_record_h record ) len += snprintf(contact_query + len, sizeof(contact_query) - len, ", ringtone_path=? "); if (ctsvc_record_check_property_flag((ctsvc_record_s *)person, _contacts_person.vibration, CTSVC_PROPERTY_FLAG_DIRTY)) len += snprintf(contact_query + len, sizeof(contact_query) - len, ", vibration=? "); + if (ctsvc_record_check_property_flag((ctsvc_record_s *)person, _contacts_person.message_alert, CTSVC_PROPERTY_FLAG_DIRTY)) + len += snprintf(contact_query + len, sizeof(contact_query) - len, ", message_alert=? "); snprintf(contact_query+len, sizeof(contact_query)-len, " WHERE person_id=%d AND deleted = 0", person->person_id); stmt = cts_query_prepare(contact_query); @@ -271,12 +274,16 @@ static int __ctsvc_db_person_update_record( contacts_record_h record ) cts_stmt_bind_text(stmt, i, person->ringtone_path); i++; } - if (ctsvc_record_check_property_flag((ctsvc_record_s *)person, _contacts_person.vibration, CTSVC_PROPERTY_FLAG_DIRTY)) { if (person->vibration) cts_stmt_bind_text(stmt, i, person->vibration); i++; } + if (ctsvc_record_check_property_flag((ctsvc_record_s *)person, _contacts_person.message_alert, CTSVC_PROPERTY_FLAG_DIRTY)) { + if (person->message_alert) + cts_stmt_bind_text(stmt, i, person->message_alert); + i++; + } ret = cts_stmt_step(stmt); if (CONTACTS_ERROR_NONE != ret) { @@ -422,6 +429,7 @@ static int __ctsvc_db_person_get_all_records( int offset, int limit, contacts_li "image_thumbnail_path, " "ringtone_path, " "vibration, " + "message_alert, " "status, " "link_count, " "addressbook_ids, " @@ -565,6 +573,10 @@ static int __ctsvc_db_person_get_records_with_query( contacts_query_h query, int temp = ctsvc_stmt_get_text(stmt, i); person->status = SAFE_STRDUP(temp); break; + case CTSVC_PROPERTY_PERSON_MESSAGE_ALERT: + temp = ctsvc_stmt_get_text(stmt, i); + person->message_alert = SAFE_STRDUP(temp); + break; default: break; } diff --git a/native/ctsvc_db_plugin_person_helper.c b/native/ctsvc_db_plugin_person_helper.c index 6120141..cf89d29 100755 --- a/native/ctsvc_db_plugin_person_helper.c +++ b/native/ctsvc_db_plugin_person_helper.c @@ -77,6 +77,10 @@ int ctsvc_db_person_create_record_from_stmt_with_projection(cts_stmt stmt, unsig temp = ctsvc_stmt_get_text(stmt, i); person->vibration = SAFE_STRDUP(temp); break; + case CTSVC_PROPERTY_PERSON_MESSAGE_ALERT: + temp = ctsvc_stmt_get_text(stmt, i); + person->message_alert = SAFE_STRDUP(temp); + break; case CTSVC_PROPERTY_PERSON_STATUS: temp = ctsvc_stmt_get_text(stmt, i); person->status = SAFE_STRDUP(temp); @@ -171,6 +175,8 @@ int ctsvc_db_person_create_record_from_stmt(cts_stmt stmt, contacts_record_h *re temp = ctsvc_stmt_get_text(stmt, i++); person->vibration = SAFE_STRDUP(temp); temp = ctsvc_stmt_get_text(stmt, i++); + person->message_alert = SAFE_STRDUP(temp); + temp = ctsvc_stmt_get_text(stmt, i++); person->status = SAFE_STRDUP(temp); person->link_count = ctsvc_stmt_get_int(stmt, i++); @@ -279,9 +285,9 @@ int ctsvc_db_insert_person(contacts_record_h record) version = ctsvc_get_next_ver(); snprintf(query, sizeof(query), "INSERT INTO "CTS_TABLE_PERSONS"(name_contact_id, created_ver, changed_ver, " - "has_phonenumber, has_email, ringtone_path, vibration, status, " + "has_phonenumber, has_email, ringtone_path, vibration, message_alert, status, " "image_thumbnail_path, link_count, addressbook_ids) " - "VALUES(%d, %d, %d, %d, %d, ?, ?, ?, ?, 1, '%d') ", + "VALUES(%d, %d, %d, %d, %d, ?, ?, ?, ?, ?, 1, '%d') ", contact->id, version, version, contact->has_phonenumber, contact->has_email, contact->addressbook_id); @@ -295,10 +301,12 @@ int ctsvc_db_insert_person(contacts_record_h record) cts_stmt_bind_text(stmt, 1, contact->ringtone_path); if(contact->vibration) cts_stmt_bind_text(stmt, 2, contact->vibration); + if(contact->message_alert) + cts_stmt_bind_text(stmt, 3, contact->message_alert); if(status) - cts_stmt_bind_text(stmt, 3, status); + cts_stmt_bind_text(stmt, 4, status); if(contact->image_thumbnail_path) - cts_stmt_bind_text(stmt, 4, __cts_get_image_filename(contact->image_thumbnail_path)); + cts_stmt_bind_text(stmt, 5, __cts_get_image_filename(contact->image_thumbnail_path)); ret = cts_stmt_step(stmt); if (CONTACTS_ERROR_NONE != ret) { @@ -467,6 +475,8 @@ int ctsvc_db_update_person(contacts_record_h record) len += snprintf(query+len, sizeof(query)-len, ", ringtone_path=?"); if (ctsvc_record_check_property_flag((ctsvc_record_s *)record, _contacts_contact.vibration, CTSVC_PROPERTY_FLAG_DIRTY)) len += snprintf(query+len, sizeof(query)-len, ", vibration=?"); + if (ctsvc_record_check_property_flag((ctsvc_record_s *)record, _contacts_contact.message_alert, CTSVC_PROPERTY_FLAG_DIRTY)) + len += snprintf(query+len, sizeof(query)-len, ", message_alert=?"); if (ctsvc_record_check_property_flag((ctsvc_record_s *)record, _contacts_contact.image_thumbnail_path, CTSVC_PROPERTY_FLAG_DIRTY) && (contact->id == thumbnail_contact_id || thumbnail_contact_id == -1)) len += snprintf(query+len, sizeof(query)-len, ", image_thumbnail_path=?"); @@ -491,6 +501,11 @@ int ctsvc_db_update_person(contacts_record_h record) cts_stmt_bind_text(stmt, i, contact->vibration); i++; } + if (ctsvc_record_check_property_flag((ctsvc_record_s *)record, _contacts_contact.message_alert, CTSVC_PROPERTY_FLAG_DIRTY)) { + if (contact->message_alert) + cts_stmt_bind_text(stmt, i, contact->message_alert); + i++; + } if (ctsvc_record_check_property_flag((ctsvc_record_s *)record, _contacts_contact.image_thumbnail_path, CTSVC_PROPERTY_FLAG_DIRTY) && (contact->id == thumbnail_contact_id || thumbnail_contact_id == -1)) { if (contact->image_thumbnail_path) diff --git a/native/ctsvc_db_plugin_phonelog.c b/native/ctsvc_db_plugin_phonelog.c index 1d7c133..6edd9c1 100644 --- a/native/ctsvc_db_plugin_phonelog.c +++ b/native/ctsvc_db_plugin_phonelog.c @@ -24,6 +24,7 @@ #include "ctsvc_schema.h" #include "ctsvc_sqlite.h" #include "ctsvc_normalize.h" +#include "ctsvc_number_utils.h" #include "ctsvc_utils.h" #include "ctsvc_list.h" #include "ctsvc_record.h" @@ -386,17 +387,17 @@ static int __ctsvc_db_phonelog_insert(ctsvc_phonelog_s *phonelog, int *id) { int ret; cts_stmt stmt = NULL; - char clean_num[CTSVC_NUMBER_MAX_LEN] = {0}; - char query[CTS_SQL_MAX_LEN] = {0}; char normal_num[CTSVC_NUMBER_MAX_LEN] = {0}; + char query[CTS_SQL_MAX_LEN] = {0}; + char minmatch[CTSVC_NUMBER_MAX_LEN] = {0}; RETVM_IF(phonelog->log_type <= CONTACTS_PLOG_TYPE_NONE || CONTACTS_PLOG_TYPE_MAX <= phonelog->log_type, CONTACTS_ERROR_INVALID_PARAMETER, "phonelog type(%d) is invaid", phonelog->log_type); snprintf(query, sizeof(query), "INSERT INTO "CTS_TABLE_PHONELOGS"(" - "number, normal_num, person_id, log_type, log_time, data1, data2) " - "VALUES(?, ?, ?, %d, %d, %d, ?)", + "number, normal_num, minmatch, person_id, log_type, log_time, data1, data2) " + "VALUES(?, ?, ?, ?, %d, %d, %d, ?)", phonelog->log_type, phonelog->log_time, phonelog->extra_data1); stmt = cts_query_prepare(query); @@ -405,23 +406,23 @@ static int __ctsvc_db_phonelog_insert(ctsvc_phonelog_s *phonelog, int *id) if (phonelog->address) { cts_stmt_bind_text(stmt, 1, phonelog->address); if (phonelog->log_type < CONTACTS_PLOG_TYPE_EMAIL_RECEIVED) { - ret = ctsvc_clean_number(phonelog->address, clean_num, sizeof(clean_num)); + ret = ctsvc_normalize_number(phonelog->address, normal_num, sizeof(normal_num)); + cts_stmt_bind_text(stmt, 2, normal_num); if (0 < ret) { - ret = ctsvc_normalize_number(clean_num, normal_num, CTSVC_NUMBER_MAX_LEN, ctsvc_get_phonenumber_min_match_digit()); - cts_stmt_bind_text(stmt, 2, normal_num); + ret = ctsvc_get_minmatch_number(normal_num, minmatch, CTSVC_NUMBER_MAX_LEN, ctsvc_get_phonenumber_min_match_digit()); + cts_stmt_bind_text(stmt, 3, minmatch); } } } if (0 < phonelog->person_id) - cts_stmt_bind_int(stmt, 3, phonelog->person_id); + cts_stmt_bind_int(stmt, 4, phonelog->person_id); if (phonelog->extra_data2) - cts_stmt_bind_text(stmt, 4, phonelog->extra_data2); + cts_stmt_bind_text(stmt, 5, phonelog->extra_data2); ret = cts_stmt_step(stmt); - if (CONTACTS_ERROR_NONE != ret) - { + if (CONTACTS_ERROR_NONE != ret) { CTS_ERR("cts_stmt_step() Failed(%d)", ret); cts_stmt_finalize(stmt); return ret; diff --git a/native/ctsvc_db_plugin_simple_contact.c b/native/ctsvc_db_plugin_simple_contact.c index 2780e59..ce3aab2 100644 --- a/native/ctsvc_db_plugin_simple_contact.c +++ b/native/ctsvc_db_plugin_simple_contact.c @@ -88,6 +88,8 @@ static int __ctsvc_db_simple_contact_value_set(cts_stmt stmt, contacts_record_h temp = ctsvc_stmt_get_text(stmt, i++); contact->vibration = SAFE_STRDUP(temp); temp = ctsvc_stmt_get_text(stmt, i++); + contact->message_alert = SAFE_STRDUP(temp); + temp = ctsvc_stmt_get_text(stmt, i++); contact->uid = SAFE_STRDUP(temp); contact->is_favorite = ctsvc_stmt_get_int(stmt, i++); contact->has_phonenumber = ctsvc_stmt_get_int(stmt, i++); @@ -110,7 +112,7 @@ static int __ctsvc_db_simple_contact_get_record( int id, contacts_record_h* out_ len = snprintf(query, sizeof(query), "SELECT contact_id, addressbook_id, person_id, changed_time, %s, " "display_name_source, image_thumbnail_path, " - "ringtone_path, vibration, uid, is_favorite, has_phonenumber, has_email " + "ringtone_path, vibration, message_alert, uid, is_favorite, has_phonenumber, has_email " "FROM "CTS_TABLE_CONTACTS" WHERE contact_id = %d AND deleted = 0", ctsvc_get_display_column(), id); @@ -285,7 +287,7 @@ static int __ctsvc_db_simple_contact_get_all_records( int offset, int limit, len = snprintf(query, sizeof(query), "SELECT contact_id, addressbook_id, person_id, changed_time, " "%s, display_name_source, image_thumbnail_path, " - "ringtone_path, vibration, uid, is_favorite, has_phonenumber, has_email " + "ringtone_path, vibration, message_alert, uid, is_favorite, has_phonenumber, has_email " "FROM "CTS_TABLE_CONTACTS" WHERE deleted = 0", ctsvc_get_display_column()); if (0 < limit) { @@ -412,6 +414,10 @@ static int __ctsvc_db_simple_contact_get_records_with_query( contacts_query_h qu temp = ctsvc_stmt_get_text(stmt, i); contact->vibration = SAFE_STRDUP(temp); break; + case CTSVC_PROPERTY_CONTACT_MESSAGE_ALERT: + temp = ctsvc_stmt_get_text(stmt, i); + contact->message_alert = SAFE_STRDUP(temp); + break; case CTSVC_PROPERTY_CONTACT_CHANGED_TIME: contact->changed_time = ctsvc_stmt_get_int(stmt, i); break; @@ -486,8 +492,8 @@ static int __ctsvc_db_simple_contact_insert_record( contacts_record_h record, in snprintf(query, sizeof(query), "INSERT INTO "CTS_TABLE_CONTACTS"(contact_id, person_id, addressbook_id, is_favorite, " "created_ver, changed_ver, changed_time, " - "uid, ringtone_path, vibration, image_thumbnail_path) " - "VALUES(%d, %d, %d, %d, %d, %d, %d, ?, ?, ?, ?)", + "uid, ringtone_path, vibration, message_alert, image_thumbnail_path) " + "VALUES(%d, %d, %d, %d, %d, %d, %d, ?, ?, ?, ?, ?)", contact->contact_id, contact->person_id, contact->addressbook_id, contact->is_favorite, version, version, (int)time(NULL)); @@ -504,8 +510,10 @@ static int __ctsvc_db_simple_contact_insert_record( contacts_record_h record, in cts_stmt_bind_text(stmt, 2, contact->ringtone_path); if (contact->vibration) cts_stmt_bind_text(stmt, 3, contact->vibration); + if (contact->message_alert) + cts_stmt_bind_text(stmt, 4, contact->message_alert); if (contact->image_thumbnail_path) - cts_stmt_bind_text(stmt, 4, contact->image_thumbnail_path); + cts_stmt_bind_text(stmt, 5, contact->image_thumbnail_path); ret = cts_stmt_step(stmt); if (CONTACTS_ERROR_NONE != ret) { diff --git a/native/ctsvc_db_query.c b/native/ctsvc_db_query.c index 962ce84..fdfb9b2 100755 --- a/native/ctsvc_db_query.c +++ b/native/ctsvc_db_query.c @@ -31,6 +31,7 @@ #include "ctsvc_record.h" #include "ctsvc_utils.h" #include "ctsvc_normalize.h" +#include "ctsvc_number_utils.h" #include "ctsvc_db_init.h" #include "ctsvc_view.h" #include "ctsvc_inotify.h" @@ -289,9 +290,26 @@ static inline int __ctsvc_db_create_str_condition(ctsvc_composite_filter_s *com_ if (filter->value.s) { if (filter->property_id == CTSVC_PROPERTY_NUMBER_NUMBER_FILTER) { char dest[strlen(filter->value.s)+1]; - ret = ctsvc_normalize_number(filter->value.s, dest, sizeof(dest), ctsvc_get_phonenumber_min_match_digit()); - if (CONTACTS_ERROR_NONE == ret) - *bind_text = g_slist_append(*bind_text, __ctsvc_db_get_str_with_escape(dest, strlen(dest), with_escape)); + char normal_num[strlen(filter->value.s)+1]; + ret = ctsvc_normalize_number(filter->value.s, normal_num, sizeof(normal_num)); + if (0 < ret) { + ret = ctsvc_get_minmatch_number(normal_num, dest, sizeof(dest), ctsvc_get_phonenumber_min_match_digit()); + if (CONTACTS_ERROR_NONE == ret) + *bind_text = g_slist_append(*bind_text, __ctsvc_db_get_str_with_escape(dest, strlen(dest), with_escape)); + else + return CONTACTS_ERROR_INVALID_PARAMETER; + } + else + return CONTACTS_ERROR_INVALID_PARAMETER; + } + else if (filter->property_id == CTSVC_PROPERTY_NUMBER_NORMALIZED_NUMBER + || filter->property_id == CTSVC_PROPERTY_PHONELOG_NORMALIZED_ADDRESS + || filter->property_id == CTSVC_PROPERTY_SPEEDDIAL_NORMALIZED_NUMBER) { + char normal_num[strlen(filter->value.s)+1]; + ret = ctsvc_normalize_number(filter->value.s, normal_num, sizeof(normal_num)); + if (0 < ret) { + *bind_text = g_slist_append(*bind_text, __ctsvc_db_get_str_with_escape(normal_num, strlen(normal_num), with_escape)); + } else return CONTACTS_ERROR_INVALID_PARAMETER; } @@ -894,11 +912,38 @@ static char* __ctsvc_db_make_search_keyword(const char *keyword) } } -static int __ctsvc_db_append_search_query(const char *src, char *query, int size) +static int __ctsvc_db_append_search_query_range(char *query, int size, int range, char *name, char *number, char *data) +{ + bool first = true; + int ret = 0; + ret = snprintf(query, size, "'"); + if (range & CONTACTS_SEARCH_RANGE_NAME) { + ret += snprintf(query+ret, size-ret, "name:%s", name); + first = false; + } + + if (range & CONTACTS_SEARCH_RANGE_NUMBER) { + if (first == false) + ret += snprintf(query+ret, size-ret, " OR "); + ret += snprintf(query+ret, size-ret, "number:%s", number); + first = false; + } + + if (range & CONTACTS_SEARCH_RANGE_DATA) { + if (first == false) + ret += snprintf(query+ret, size-ret, " OR "); + ret += snprintf(query+ret, size-ret, "data:%s", data); + first = false; + } + + ret += snprintf(query+ret, size-ret, "' "); + return ret; +} + +static int __ctsvc_db_append_search_query(const char *src, char *query, int size, int range) { bool phonenumber = true; int ret; - int j = 0; int i = 0; int temp_len = 0; @@ -924,22 +969,34 @@ static int __ctsvc_db_append_search_query(const char *src, char *query, int size search_keyword = __ctsvc_db_make_search_keyword(keyword); if (phonenumber) { - char normalized_number[CTSVC_NUMBER_MAX_LEN]; - ctsvc_normalize_number(keyword, normalized_number, CTSVC_NUMBER_MAX_LEN, CTSVC_NUMBER_MAX_LEN -1); - - ret =snprintf(query, size, - "(SELECT contact_id FROM %s WHERE %s MATCH 'name:%s OR number:%s OR data:%s' " - "UNION " - "SELECT contact_id FROM %s WHERE number LIKE '%%%s%%') ", - CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX, - search_keyword, search_keyword, search_keyword, CTS_TABLE_PHONE_LOOKUP, normalized_number ); + ret = snprintf(query, size, + "(SELECT contact_id FROM %s WHERE %s MATCH ", + CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX); + ret += __ctsvc_db_append_search_query_range(query+ret, size-ret, + range, search_keyword, search_keyword, search_keyword); + + if (range & CONTACTS_SEARCH_RANGE_NUMBER) { + char normalized_number[CTSVC_NUMBER_MAX_LEN]; + char minmatch[CTSVC_NUMBER_MAX_LEN]; + int err = ctsvc_normalize_number(keyword, normalized_number, sizeof(normalized_number)); + if (0 < err) { + err = ctsvc_get_minmatch_number(normalized_number, minmatch, CTSVC_NUMBER_MAX_LEN, CTSVC_NUMBER_MAX_LEN-1); + if (err == CONTACTS_ERROR_NONE) { + ret += snprintf(query+ret, size-ret, + "UNION " + "SELECT contact_id FROM %s WHERE number LIKE '%%%s%%' ", + CTS_TABLE_PHONE_LOOKUP, minmatch); + } + } + } + ret += snprintf(query+ret, size-ret, ")"); } else { char *normalized_name = NULL; - char *saarch_normal_name = NULL; + char *search_normal_name = NULL; ret = ctsvc_normalize_str(keyword, &normalized_name); - saarch_normal_name = __ctsvc_db_make_search_keyword(normalized_name); + search_normal_name = __ctsvc_db_make_search_keyword(normalized_name); if (CTSVC_LANG_KOREAN == ret) { char *chosung = calloc(1, strlen(keyword) * 5); @@ -951,10 +1008,18 @@ static int __ctsvc_db_append_search_query(const char *src, char *query, int size search_chosung = __ctsvc_db_make_search_keyword(chosung); ret = snprintf(query, size, - "(SELECT contact_id FROM %s WHERE %s MATCH 'name:%s OR number:%s OR data:%s' " + "(SELECT contact_id FROM %s WHERE %s MATCH ", + CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX); + + ret += __ctsvc_db_append_search_query_range(query+ret, size-ret, + range, search_chosung, search_keyword, search_keyword); + + if (range & CONTACTS_SEARCH_RANGE_NAME) { + ret += snprintf(query+ret, size-ret, "INTERSECT SELECT contact_id FROM %s WHERE name GLOB '*%s*' ", - CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX, - search_chosung, search_keyword, search_keyword, CTS_TABLE_NAME_LOOKUP, korean_pattern); + CTS_TABLE_NAME_LOOKUP, korean_pattern); + } + free(chosung); free(korean_pattern); free(search_chosung); @@ -967,40 +1032,48 @@ static int __ctsvc_db_append_search_query(const char *src, char *query, int size search_hiragana = __ctsvc_db_make_search_keyword(hiragana); ret = snprintf(query, size, - "(SELECT contact_id FROM %s WHERE %s MATCH 'name:%s OR number:%s OR data:%s' ", - CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX, + "(SELECT contact_id FROM %s WHERE %s MATCH ", + CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX); + ret += __ctsvc_db_append_search_query_range(query+ret, size-ret, range, search_hiragana, search_hiragana, search_hiragana); free(hiragana); free(search_hiragana); } else if (CONTACTS_ERROR_NONE <= ret) { ret = snprintf(query, size, - "(SELECT contact_id FROM %s WHERE %s MATCH 'name:%s OR number:%s OR data:%s' ", - CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX, - saarch_normal_name, search_keyword, search_keyword); + "(SELECT contact_id FROM %s WHERE %s MATCH ", + CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX); + + ret += __ctsvc_db_append_search_query_range(query+ret, size-ret, range, + search_normal_name, search_keyword, search_keyword); } else { ret = snprintf(query, size, - "(SELECT contact_id FROM %s WHERE %s MATCH 'name:%s OR number:%s OR data:%s' ", - CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX, - search_keyword, search_keyword, search_keyword); + "(SELECT contact_id FROM %s WHERE %s MATCH '", + CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX); + ret += __ctsvc_db_append_search_query_range(query+ret, size-ret, + range, search_keyword, search_keyword, search_keyword); } - temp_len = strlen(keyword); - char temp_str[temp_len*2+1]; - for(i=0;i +#include + +#include "contacts.h" +#include "ctsvc_internal.h" +#include "ctsvc_setting.h" +#include "ctsvc_normalize.h" +#include "ctsvc_localize.h" +#include "ctsvc_number_utils.h" + +int ctsvc_normalize_number(const char *src, char *dest, int dest_size) +{ + int s_pos=0, d_pos=0; + + if (NULL == src) + CTS_ERR("The parameter(src) is NULL"); + else { + while (src[s_pos] != 0) { + int char_len; + char ch = 0x0; + if (d_pos > dest_size-2) break; + + char_len = ctsvc_check_utf8(src[s_pos]); + if (char_len == 3) { + if (src[s_pos] == 0xef) { + if (src[s_pos+1] == 0xbc) { + if (0x90 <= src[s_pos+2] && src[s_pos+2] <= 0x99) // ef bc 90 : '0' ~ ef bc 99 : '9' + ch = src[s_pos+2] - 0x60; + else if (0xa1 <= src[s_pos+2] && src[s_pos+2] <= 0xba) // ef bc a1 : 'A' ~ ef bc ba : 'Z' + ch = src[s_pos+2] - 0x60; + else if (0x8b == src[s_pos+2]) // ef bc 8b : '+' + ch = '+'; + } + else if (src[s_pos+1] == 0xbd + && (0x81 <= src[s_pos+2] && src[s_pos+2] <= 0x9a)) // ef bd 81 : 'a' ~ ef bd 9a : 'z' + ch = src[s_pos+2] - 0x40; + } + else { + s_pos += char_len; + continue; + } + } + else if (char_len == 1) { + if (0x41 <= src[s_pos] && src[s_pos] <= 0x5a) // 'A' ~ 'Z' + ch = src[s_pos]; + else if (0x61 <= src[s_pos] && src[s_pos] <= 0x7a) // 'a' ~ 'z' + ch = src[s_pos] - 0x20; + else + ch = src[s_pos]; + + if (s_pos == 0 && src[s_pos] == '0') { // remove first '0' + s_pos++; + continue; + } + } + + if ('0' <= ch && ch <= '9') + dest[d_pos++] = ch; + else if (s_pos == 0 && src[s_pos] == '+') + dest[d_pos++] = ch; + s_pos += char_len; + } + } + + dest[d_pos] = 0x0; + + return d_pos; +} + +static inline const char* __ctsvc_clean_country_code(const char *src) +{ + int ret = 1; + switch (src[ret++]-'0') + { + case 1: + case 7: + break; + case 2: + switch (src[ret++]-'0') + { + case 0: + case 7: + break; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 8: + case 9: + ret += 1; + break; + default: + CTS_ERR("The parameter(src:%s) has invalid character set", src); + } + break; + case 3: + switch (src[ret++]-'0') + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 6: + case 9: + break; + case 5: + case 7: + case 8: + ret += 1; + break; + default: + CTS_ERR("The parameter(src:%s) has invalid character set", src); + } + break; + case 4: + switch (src[ret++]-'0') + { + case 0: + case 1: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + break; + case 2: + ret += 1; + break; + default: + CTS_ERR("The parameter(src:%s) has invalid character set", src); + } + break; + case 5: + switch (src[ret++]-'0') + { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + break; + case 0: + case 9: + ret += 1; + break; + default: + CTS_ERR("The parameter(src:%s) has invalid character set", src); + } + break; + case 6: + switch (src[ret++]-'0') + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + break; + case 7: + case 8: + case 9: + ret += 1; + break; + default: + CTS_ERR("The parameter(src:%s) has invalid character set", src); + } + break; + case 8: + switch (src[ret++]-'0') + { + case 1: + case 2: + case 4: + case 6: + break; + case 0: + case 3: + case 5: + case 7: + case 8: + case 9: + ret += 1; + break; + default: + CTS_ERR("The parameter(src:%s) has invalid character set", src); + } + break; + case 9: + switch (src[ret++]-'0') + { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 8: + break; + case 6: + case 7: + case 9: + ret += 1; + break; + default: + CTS_ERR("The parameter(src:%s) has invalid character set", src); + } + break; + case 0: + default: + CTS_ERR("The parameter(src:%s) has invalid character set", src); + return src; + } + + return &src[ret]; +} + +static int __ctsvc_minmatch_number(const char *src, char *dest, int dest_size, int min_match) +{ + int i; + int len; + int d_pos = 0; + const char *temp_number; + + if ('+' == src[0]) + temp_number = __ctsvc_clean_country_code(src); + else if ('0' == src[0]) + temp_number = src+1; + else + temp_number = src; + + len = strlen(temp_number); + + if (0 < len) { + while(0 <= (len-d_pos-1) && temp_number[len-d_pos-1] + && d_pos < min_match) { + if (dest_size-d_pos == 0) { + CTS_ERR("Destination string buffer is not enough(%s)", src); + return CONTACTS_ERROR_INTERNAL; + } + + dest[d_pos] = temp_number[len-d_pos-1]; + d_pos++; + } + dest[d_pos] = 0; + + len = strlen(dest); + for(i=0; i '9') && keyword[i] != '+') { + CTS_ERR("keyword[%d]: %c is not number)", i, keyword[i]); + return false; + } + } + return true; +} + +#define UTF8_FULLWIDTH_LENGTH 3 +static bool __ctsvc_is_phonenumber_fullwidth(const char* keyword) +{ + int char_len = 1; + int str_len; + int i; + if (keyword == NULL || *keyword == '\0') + return false; + + str_len = strlen(keyword); + for (i=0;iringtone_path); if (person->vibration) vibration = SAFE_STRDUP(person->vibration); + if (person->message_alert) + message_alert = SAFE_STRDUP(person->message_alert); contacts_record_destroy((contacts_record_h)person, true); snprintf(query, sizeof(query), "SELECT contact_id, contacts.addressbook_id, %s, display_name_source, " - "image_thumbnail_path, ringtone_path, vibration, is_favorite " + "image_thumbnail_path, ringtone_path, vibration, message_alert, is_favorite " "FROM %s " "WHERE person_id = %d AND contacts.deleted = 0 " "ORDER BY contact_id", @@ -640,6 +643,7 @@ int ctsvc_person_aggregate(int person_id) free(image_thumbnail_path); free(ringtone_path); free(vibration); + free(message_alert); return CONTACTS_ERROR_DB; } @@ -655,6 +659,7 @@ int ctsvc_person_aggregate(int person_id) char *contact_ringtone_path = NULL; char *contact_image_thumbnail_path = NULL; char *contact_vibration = NULL; + char *contact_message_alert = NULL; bool is_favorite = false; char addr[10] = {0}; int addr_len = 0; @@ -671,6 +676,8 @@ 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); + temp = ctsvc_stmt_get_text(stmt, i++); + contact_message_alert = SAFE_STRDUP(temp); is_favorite = ctsvc_stmt_get_int(stmt, i++); link_count++; @@ -708,6 +715,10 @@ int ctsvc_person_aggregate(int person_id) if (!vibration && temp_str && strlen(temp_str)) vibration = SAFE_STRDUP(temp_str); + temp_str = contact_message_alert; + if (!contact_message_alert && temp_str && strlen(temp_str)) + contact_message_alert = SAFE_STRDUP(temp_str); + if (is_favorite) person_is_favorite = true; } @@ -720,7 +731,7 @@ 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, addressbook_ids = ?, ringtone_path=?, vibration=?, status=?, image_thumbnail_path=? " + "link_count = %d, addressbook_ids = ?, ringtone_path=?, vibration=?, message_alert=?, status=?, image_thumbnail_path=? " "WHERE person_id = %d ", name_contact_id, version, person_id, person_id, link_count, person_id); @@ -732,6 +743,7 @@ int ctsvc_person_aggregate(int person_id) free(image_thumbnail_path); free(ringtone_path); free(vibration); + free(message_alert); return CONTACTS_ERROR_DB; } @@ -741,10 +753,12 @@ int ctsvc_person_aggregate(int person_id) cts_stmt_bind_text(stmt, 2, ringtone_path); if (vibration) cts_stmt_bind_text(stmt, 3, vibration); + if (message_alert) + cts_stmt_bind_text(stmt, 4, message_alert); if (status) - cts_stmt_bind_text(stmt, 4, status); + cts_stmt_bind_text(stmt, 5, status); if (image_thumbnail_path) - cts_stmt_bind_text(stmt, 5, image_thumbnail_path); + cts_stmt_bind_text(stmt, 6, image_thumbnail_path); ret = cts_stmt_step(stmt); if (CONTACTS_ERROR_NONE != ret) { @@ -754,6 +768,7 @@ int ctsvc_person_aggregate(int person_id) free(image_thumbnail_path); free(ringtone_path); free(vibration); + free(message_alert); return ret; } @@ -763,6 +778,7 @@ int ctsvc_person_aggregate(int person_id) free(image_thumbnail_path); free(ringtone_path); free(vibration); + free(message_alert); if (!person_is_favorite) { snprintf(query, sizeof(query), diff --git a/native/ctsvc_service.c b/native/ctsvc_service.c index cce5c35..d6b554f 100644 --- a/native/ctsvc_service.c +++ b/native/ctsvc_service.c @@ -34,6 +34,7 @@ #include "ctsvc_inotify.h" #include "ctsvc_db_init.h" #include "ctsvc_setting.h" +#include "ctsvc_number_utils.h" static int ctsvc_connection = 0; static __thread int thread_connection = 0; diff --git a/packaging/contacts-service.spec b/packaging/contacts-service.spec index dd08ea4..8be812a 100644 --- a/packaging/contacts-service.spec +++ b/packaging/contacts-service.spec @@ -1,6 +1,6 @@ Name: contacts-service Summary: Contacts Service -Version: 0.9.103.1 +Version: 0.9.106.1 Release: 1 Group: TO_BE/FILLED_IN License: Apache-2.0 diff --git a/schema.sql b/schema.sql index a461482..ee8148e 100755 --- a/schema.sql +++ b/schema.sql @@ -31,6 +31,7 @@ CREATE TABLE persons changed_ver INTEGER NOT NULL, ringtone_path TEXT, vibration TEXT, + message_alert TEXT, image_thumbnail_path TEXT, image_path TEXT, link_count INTEGER, @@ -92,6 +93,7 @@ CREATE TABLE contacts uid TEXT, ringtone_path TEXT, vibration TEXT, + message_alert TEXT, image_thumbnail_path TEXT, image_path TEXT ); @@ -308,6 +310,7 @@ CREATE TABLE phonelogs id INTEGER PRIMARY KEY AUTOINCREMENT, number TEXT, normal_num TEXT, + minmatch TEXT, person_id INTEGER, --person_id log_type INTEGER, log_time INTEGER, diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 71235d1..fea11ef 100755 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -142,6 +142,7 @@ SET(SRCS ${CMAKE_SOURCE_DIR}/native/ctsvc_service.c ${CMAKE_SOURCE_DIR}/native/ctsvc_sqlite.c ${CMAKE_SOURCE_DIR}/native/ctsvc_utils.c + ${CMAKE_SOURCE_DIR}/native/ctsvc_number_utils.c ${CMAKE_SOURCE_DIR}/native/ctsvc_notification.c ${CMAKE_SOURCE_DIR}/native/ctsvc_setting.c diff --git a/server/ctsvc_ipc_server.c b/server/ctsvc_ipc_server.c index 036bd36..5d6eec9 100644 --- a/server/ctsvc_ipc_server.c +++ b/server/ctsvc_ipc_server.c @@ -144,7 +144,7 @@ void ctsvc_ipc_server_db_insert_record(pims_ipc_h ipc, pims_ipc_data_h indata, p CTS_ERR("outdata is NULL"); } goto DATA_FREE; - // goto 주의.. + ERROR_RETURN: if (outdata) { @@ -205,7 +205,6 @@ void ctsvc_ipc_server_db_get_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims ret = contacts_db_get_record(view_uri,id,&record); - // goto 주의.. ERROR_RETURN: if (outdata) { @@ -576,7 +575,6 @@ void ctsvc_ipc_server_db_get_all_records(pims_ipc_h ipc, pims_ipc_data_h indata, goto DATA_FREE; - // goto 주의.. ERROR_RETURN: if (outdata) { @@ -682,7 +680,6 @@ void ctsvc_ipc_server_db_get_records_with_query(pims_ipc_h ipc, pims_ipc_data_h } goto DATA_FREE; - // goto 주의.. ERROR_RETURN: if (outdata) { @@ -778,7 +775,6 @@ void ctsvc_ipc_server_db_get_count(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ } goto DATA_FREE; - // goto 주의.. ERROR_RETURN: if (outdata) { @@ -865,7 +861,6 @@ void ctsvc_ipc_server_db_get_count_with_query(pims_ipc_h ipc, pims_ipc_data_h in } goto DATA_FREE; - // goto 주의.. ERROR_RETURN: if (outdata) { @@ -1065,7 +1060,6 @@ void ctsvc_ipc_server_db_update_records(pims_ipc_h ipc, pims_ipc_data_h indata, } goto DATA_FREE; - // goto 주의.. ERROR_RETURN: if (outdata) { @@ -1384,7 +1378,6 @@ void ctsvc_ipc_server_db_get_changes_by_version(pims_ipc_h ipc, pims_ipc_data_h } goto DATA_FREE; - // goto 주의.. ERROR_RETURN: if (outdata) { @@ -1540,7 +1533,6 @@ void ctsvc_ipc_server_db_search_records(pims_ipc_h ipc, pims_ipc_data_h indata, } goto DATA_FREE; - // goto 주의.. ERROR_RETURN: if (outdata) { @@ -1573,6 +1565,107 @@ DATA_FREE: return; } +void ctsvc_ipc_server_db_search_records_with_range(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata) +{ + int ret = CONTACTS_ERROR_NONE; + char* view_uri = NULL; + char* keyword = NULL; + int offset = 0; + int limit = 0; + int range = 0; + contacts_list_h list = NULL; + + if (indata) { + ret = ctsvc_ipc_unmarshal_string(indata,&view_uri); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("ctsvc_ipc_unmarshal_record fail"); + goto ERROR_RETURN; + } + ret = ctsvc_ipc_unmarshal_string(indata,&keyword); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("ctsvc_ipc_unmarshal_record fail"); + goto ERROR_RETURN; + } + ret = ctsvc_ipc_unmarshal_int(indata,&offset); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("ctsvc_ipc_unmarshal_int fail"); + goto ERROR_RETURN; + } + ret = ctsvc_ipc_unmarshal_int(indata,&limit); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("ctsvc_ipc_unmarshal_int fail"); + goto ERROR_RETURN; + } + ret = ctsvc_ipc_unmarshal_int(indata,&range); + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("ctsvc_ipc_unmarshal_int fail"); + goto ERROR_RETURN; + } + } + else { + CTS_ERR("ctsvc_ipc_server_db_insert_record fail"); + goto ERROR_RETURN; + } + + ret = contacts_db_search_records_with_range(view_uri, keyword, offset,limit,range, &list); + + if (outdata) { + *outdata = pims_ipc_data_create(0); + if (!*outdata) { + CTS_ERR("pims_ipc_data_create fail"); + goto DATA_FREE; + } + if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0) { + pims_ipc_data_destroy(*outdata); + *outdata = NULL; + CTS_ERR("pims_ipc_data_put fail"); + goto DATA_FREE; + } + + if (CONTACTS_ERROR_NO_DATA == ret) { + CTS_DBG("no data"); + } + else if(CONTACTS_ERROR_NONE == ret) { + ret = ctsvc_ipc_marshal_list(list,*outdata); + + if (ret != CONTACTS_ERROR_NONE) { + CTS_ERR("ctsvc_ipc_unmarshal_int fail"); + goto DATA_FREE; + } + } + } + else { + CTS_ERR("outdata is NULL"); + } + goto DATA_FREE; + +ERROR_RETURN: + if (outdata) { + *outdata = pims_ipc_data_create(0); + if (!*outdata) { + CTS_ERR("pims_ipc_data_create fail"); + goto DATA_FREE; + } + if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0) { + pims_ipc_data_destroy(*outdata); + *outdata = NULL; + CTS_ERR("pims_ipc_data_put fail"); + goto DATA_FREE; + } + } + else { + CTS_ERR("outdata is NULL"); + } + +DATA_FREE: + + if (list) + contacts_list_destroy(list,true); + free(view_uri); + free(keyword); + return; +} + void ctsvc_ipc_server_db_search_records_with_query(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata) { int ret = CONTACTS_ERROR_NONE; @@ -1654,7 +1747,6 @@ void ctsvc_ipc_server_db_search_records_with_query(pims_ipc_h ipc, pims_ipc_data } goto DATA_FREE; - // goto 주의.. ERROR_RETURN: if (outdata) { diff --git a/server/ctsvc_ipc_server.h b/server/ctsvc_ipc_server.h index 370b5de..66c9c37 100644 --- a/server/ctsvc_ipc_server.h +++ b/server/ctsvc_ipc_server.h @@ -46,6 +46,7 @@ void ctsvc_ipc_server_db_get_changes_by_version(pims_ipc_h ipc, pims_ipc_data_h void ctsvc_ipc_server_db_get_current_version(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata); void ctsvc_ipc_server_db_search_records(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata); +void ctsvc_ipc_server_db_search_records_with_range(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata); void ctsvc_ipc_server_db_search_records_with_query(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata); diff --git a/server/ctsvc_server.c b/server/ctsvc_server.c index c7b747f..fd0e7e4 100644 --- a/server/ctsvc_server.c +++ b/server/ctsvc_server.c @@ -61,6 +61,7 @@ static int __server_main(void) if (pims_ipc_svc_register(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_CHANGES_BY_VERSION, ctsvc_ipc_server_db_get_changes_by_version, NULL) != 0) break; if (pims_ipc_svc_register(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_CURRENT_VERSION, ctsvc_ipc_server_db_get_current_version, NULL) != 0) break; if (pims_ipc_svc_register(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS, ctsvc_ipc_server_db_search_records, NULL) != 0) break; + if (pims_ipc_svc_register(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS_WITH_RANGE, ctsvc_ipc_server_db_search_records_with_range, NULL) != 0) break; if (pims_ipc_svc_register(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS_WITH_QUERY, ctsvc_ipc_server_db_search_records_with_query, NULL) != 0) break; if (pims_ipc_svc_register(CTSVC_IPC_ACTIVITY_MODULE, CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_CONTACT_ID, ctsvc_ipc_activity_delete_by_contact_id, NULL) != 0) break; -- cgit v1.2.3