SET(EXEC_PREFIX "\${prefix}")
SET(INCLUDEDIR "\${prefix}/${DEST_INCLUDE_DIR}")
SET(VERSION_MAJOR 0)
-SET(VERSION "${VERSION_MAJOR}.9.82.2")
+SET(VERSION "${VERSION_MAJOR}.9.84.1")
EXECUTE_PROCESS(COMMAND build-util/generator.sh)
char *str = NULL;\r
subscribe_info_s *info = user_data;\r
\r
- INFO("(%x) subscribe_callback(%p)", (unsigned int)pthread_self(), ipc);\r
- if (data) {\r
+ if (data)
str = (char*)pims_ipc_data_get(data, &size);\r
- if (!str) {\r
- CTS_ERR("pims_ipc_data_get fail()");\r
- return;\r
- }\r
+
+ if (!str) {
+ CTS_ERR("There is no changed data");
+ return;
}\r
+
if (info) {\r
GSList *l;\r
for (l = info->callbacks;l;l=l->next) {\r
}
ret = ctsvc_check_language(result);
- ctsvc_extra_normalize(result, size/sizeof(UChar));
+ ctsvc_extra_normalize(result, size);
u_strToUTF8(NULL, 0, &size, result, -1, &status);
status = U_ZERO_ERROR;
ctsvc_convert_japanese_to_hiragana_unicode(temp_haystack, hiragana_haystack, 2 );
- ctsvc_convert_japanese_to_hiragana_unicode(temp_haystack, hiragana_needle, 2);
+ ctsvc_convert_japanese_to_hiragana_unicode(temp_needle, hiragana_needle, 2);
if (hiragana_haystack[0] == hiragana_needle[0])
ret = true;
#include "ctsvc_vcard.h"
#include "ctsvc_localize.h"
+#define DEFAULT_ADDRESS_BOOK_ID 0
+
#define SMART_STRDUP(src) (src && *src)?strdup(src):NULL
#define CTSVC_VCARD_PHOTO_MAX_SIZE 1024*1024
#define CTSVC_VCARD_IMAGE_LOCATION "/opt/usr/data/contacts-svc/img/vcard"
RETV_IF(len < 0, len);
}
- if (contact->uid) {
+ if (contact->uid && DEFAULT_ADDRESS_BOOK_ID == contact->addressbook_id) {
CTSVC_VCARD_APPEND_STR(buf, buf_size, len, content_name[CTSVC_VCARD_VALUE_UID]);
CTSVC_VCARD_APPEND_CONTENT(buf, buf_size, len, contact->uid);
}
RETV_IF(len < 0, len);
}
- if (my_profile->uid) {
+ if (my_profile->uid && DEFAULT_ADDRESS_BOOK_ID == my_profile->addressbook_id) {
CTSVC_VCARD_APPEND_STR(buf, buf_size, len, content_name[CTSVC_VCARD_VALUE_UID]);
CTSVC_VCARD_APPEND_CONTENT(buf, buf_size, len, my_profile->uid);
}
for(cursor=list_contacts->records;cursor;cursor=cursor->next) {
contact = (ctsvc_contact_s *)cursor->data;
- if (contact && contact->uid) {
+ if (contact && contact->uid && DEFAULT_ADDRESS_BOOK_ID == contact->addressbook_id) {
CTSVC_VCARD_APPEND_STR(buf, buf_size, len, content_name[CTSVC_VCARD_VALUE_UID]);
CTSVC_VCARD_APPEND_CONTENT(buf, buf_size, len, contact->uid);
}
<domain name="contacts-service" />
<provide>
<label name="contacts-service::db"/>
+ <label name="contacts-service::svc"/>
+ <label name="contacts-service::phonelog"/>
+ <label name="contacts-service::vconf"/>
+ <label name="contacts-service::vconf-private"/>
</provide>
<request>
<smack request="sys-assert::core" type="rwxat"/>
</request>
</define>
<assign>
- <filesystem path="/usr/lib/libcontacts-service2.so.0.9.82.2" label="_"/>
+ <filesystem path="/usr/lib/libcontacts-service2.so.0.9.84.1" label="_"/>
<filesystem path="/usr/lib/libcontacts-service2.so.0" label="_"/>
<filesystem path="/opt/usr/dbspace/.contacts-svc.db" label="contacts-service::db"/>
<filesystem path="/opt/usr/dbspace/.contacts-svc.db-journal" label="contacts-service::db"/>
* <tr><td>string</td><td>uid</td><td>read, write</td><td></td></tr>
* <tr><td>string</td><td>vibration</td><td>read, write</td><td></td></tr>
* <tr><td>integer</td><td>changed_time</td><td>read only</td><td></td></tr>
- * <tr><td>integer</td><td>link_mode</td><td>read, write</td><td></td></tr>
+ * <tr><td>integer</td><td>link_mode</td><td>read, write</td><td> contacts_contact_link_mode_e </td></tr>
* <tr><td>record</td><td>name</td><td>read, write</td><td></td></tr>
* <tr><td>record</td><td>company</td><td>read, write</td><td></td></tr>
* <tr><td>record</td><td>note</td><td>read, write</td><td></td></tr>
* <tr><td>integer</td><td> id </td><td>read only</td><td> </td></tr>
* <tr><td>integer</td><td> account_id </td><td>read, write once</td><td> </td></tr>
* <tr><td>string</td><td> name </td><td>read, write</td><td> It can not be NULL. Duplicate names are not allowed. </td></tr>
- * <tr><td>integer</td><td> mode </td><td>read, write</td><td> </td></tr>
+ * <tr><td>integer</td><td> mode </td><td>read, write</td><td> contacts_address_book_mode_e </td></tr>
* </table>
*
* @section CAPI_SOCIAL_CONTACTS_SVC_VIEW_MODULE_contacts_group _contacts_group view
* <tr><td>integer</td><td> person_id </td><td>read, write once </td><td> </td></tr>
* <tr><td>string</td><td> address </td><td>read, write once </td><td> </td></tr>
* <tr><td>integer</td><td> log_time </td><td>read, write once</td><td> </td></tr>
- * <tr><td>integer</td><td> log_type </td><td>read, write</td><td> </td></tr>
+ * <tr><td>integer</td><td> log_type </td><td>read, write</td><td>contacts_phone_log_type_e </td></tr>
* <tr><td>integer</td><td> extra_data1 </td><td>read, write once</td><td> You can set the related integer data(e.g. message_id, email_id) or duration of call. </td></tr>
* <tr><td>string</td><td> extra_data2 </td><td>read, write once</td><td> You can set the related string data. e.g.) short message, subject</td></tr>
* </table>
* <tr><td>boolean</td><td> is_favorite </td><td></td><td> </td></tr>
* <tr><td>boolean</td><td> has_phonenumber </td><td></td>><td> </td></tr>
* <tr><td>boolean</td><td> has_email </td><td></td><td> </td></tr>
- * <tr><td>integer</td><td> usage_type </td><td></td>*<td> </td></tr>
+ * <tr><td>integer</td><td> usage_type </td><td>*</td><td>contacts_usage_type_e </td></tr>
* <tr><td>integer</td><td> times_used </td><td></td><td> </td></tr>
* </table>
*
#define _CONTACTS_PROPERTY_CHILD_SINGLE(property_id_name) unsigned int property_id_name;
#define _CONTACTS_PROPERTY_CHILD_MULTIPLE(property_id_name) unsigned int property_id_name;
+
#define _CONTACTS_PROPERTY_FILTER_INT(property_id_name) unsigned int property_id_name;
#define _CONTACTS_PROPERTY_FILTER_STR(property_id_name) unsigned int property_id_name;
#define _CONTACTS_PROPERTY_FILTER_BOOL(property_id_name) unsigned int property_id_name;
}contacts_display_name_source_type_e;
typedef enum {
- CONTACTS_ADDRESS_BOOK_MODE_NONE, /**< .*/
- CONTACTS_ADDRESS_BOOK_MODE_READONLY, /**< .*/
+ CONTACTS_ADDRESS_BOOK_MODE_NONE, /**< All module can read and write contacts of this address_book */
+ CONTACTS_ADDRESS_BOOK_MODE_READONLY, /**< All module can only read contacts of this address_book*/
}contacts_address_book_mode_e;
typedef enum{
int ctsvc_db_init();
int ctsvc_db_deinit();
-int ctsvc_db_get_table_name(const char *view_uri, const char **out_table);
-ctsvc_db_plugin_info_s* ctsvc_db_get_plugin_info(ctsvc_record_type_e type);
+
int ctsvc_db_plugin_init();
int ctsvc_db_plugin_deinit();
+int ctsvc_db_get_table_name(const char *view_uri, const char **out_table);
+ctsvc_db_plugin_info_s* ctsvc_db_get_plugin_info(ctsvc_record_type_e type);
#endif // __TIZEN_SOCIAL_CTSVC_DB_INIT_H__
"data3, data4, data5, data6, data7, data8, data9, data10, data11, data12 "
"FROM "CTS_TABLE_DATA", "CTSVC_DB_VIEW_CONTACT" "
"ON "CTS_TABLE_DATA".contact_id = "CTSVC_DB_VIEW_CONTACT".contact_id "
- "WHERE data.contact_id = %d AND is_my_profile = 0", id);
+ "WHERE data.contact_id = %d AND is_my_profile = 0 "
+ "ORDER BY is_default DESC", id);
stmt = cts_query_prepare(query);
RETVM_IF(NULL == stmt, CONTACTS_ERROR_DB, "DB error : cts_query_prepare() Failed");
return CONTACTS_ERROR_NONE;
}
-inline static int __ctsvc_find_person_to_link_with_number(const char *normalized_number, int *person_id)
+inline static int __ctsvc_find_person_to_link_with_number(const char *normalized_number, int addressbook_id, int *person_id)
{
int ret;
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, normal_num);
+ CTSVC_DATA_NUMBER, addressbook_id, normal_num);
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);
return CONTACTS_ERROR_INVALID_PARAMETER;
}
-inline static int __ctsvc_find_person_to_link_with_email(const char *email_addr, int *person_id)
+inline static int __ctsvc_find_person_to_link_with_email(const char *email_addr, int addressbook_id, int *person_id)
{
int ret;
char query[CTS_SQL_MIN_LEN] = {0};
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.data3='%s' AND D.is_my_profile = 0",
- CTSVC_DATA_EMAIL, email_addr);
+ CTSVC_DATA_EMAIL, addressbook_id, email_addr);
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);
}
-inline static int __ctsvc_find_person_to_link(contacts_record_h record, int *person_id)
+inline static int __ctsvc_find_person_to_link(contacts_record_h record, int addressbook_id, int *person_id)
{
int ret;
ctsvc_contact_s *contact = (ctsvc_contact_s*)record;
for(cursor = contact->numbers->records;cursor;cursor=cursor->next) {
number_data = (ctsvc_number_s *)cursor->data;
if (number_data && number_data->number && number_data->number[0]){
- ret = __ctsvc_find_person_to_link_with_number(number_data->number, person_id);
+ ret = __ctsvc_find_person_to_link_with_number(number_data->number, addressbook_id, person_id);
if (ret == CONTACTS_ERROR_NONE && *person_id > 0)
return ret;
for(cursor = contact->emails->records;cursor;cursor=cursor->next) {
email_data = (ctsvc_email_s *)cursor->data;
if (email_data && email_data->email_addr && email_data->email_addr[0]){
- ret = __ctsvc_find_person_to_link_with_email(email_data->email_addr, person_id);
+ ret = __ctsvc_find_person_to_link_with_email(email_data->email_addr, addressbook_id, person_id);
if (ret == CONTACTS_ERROR_NONE && *person_id > 0)
return ret;
version = ctsvc_get_next_ver();
if (auto_link_enabled) {
- ret = __ctsvc_find_person_to_link((contacts_record_h)contact, &person_id);
+ ret = __ctsvc_find_person_to_link((contacts_record_h)contact, contact->addressbook_id, &person_id);
CTS_DBG("__ctsvc_find_person_to_link return %d , person_id(%d)", ret, person_id);
if (ret == CONTACTS_ERROR_NONE && person_id > 0) {
contact->person_id = person_id;
}
if ( name && ( name->first || name->last || name->prefix || name->addition || name->suffix) ) {
- // make display name
+ int reverse_lang_type = -1;
+
+ // make reverse display name
display_len = SAFE_STRLEN(name->prefix)
+ SAFE_STRLEN(name->first)
+ SAFE_STRLEN(name->addition)
+ SAFE_STRLEN(name->last)
- + SAFE_STRLEN(name->suffix) + 5;
+ + SAFE_STRLEN(name->suffix) + 6;
display = calloc(1, display_len);
len=0;
if(name->prefix)
len += snprintf(display + len, display_len - len, "%s", name->prefix);
- if(name->first) {
- if (*display)
- len += snprintf(display + len, display_len - len, " ");
- len += snprintf(display + len, display_len - len, "%s", name->first);
- }
-
- if(name->addition) {
- if (*display)
- len += snprintf(display + len, display_len - len, " ");
- len += snprintf(display + len, display_len - len, "%s", name->addition);
- }
-
- if(name->last) {
- if (*display)
- len += snprintf(display + len, display_len - len, " ");
- len += snprintf(display + len, display_len - len, "%s", name->last);
- }
-
- if(name->suffix) {
- if (*display)
- len += snprintf(display + len, display_len - len, " ");
- len += snprintf(display + len, display_len - len, "%s", name->suffix);
- }
-
- contact->display_name = display;
-
- display_len += 1; // ","
- // make reverse_display_name
- display = calloc(1, display_len);
- len = 0;
-
- if(name->prefix)
- len += snprintf(display + len, display_len - len, "%s", name->prefix);
-
if(name->last) {
if (*display)
len += snprintf(display + len, display_len - len, " ");
len += snprintf(display + len, display_len - len, "%s", name->last);
- if(name->first || name->addition)
- len += snprintf(display + len, display_len - len, ",");
+ if (reverse_lang_type < 0 )
+ reverse_lang_type = ctsvc_check_language_type(display);
+
+ if (reverse_lang_type != CTSVC_LANG_KOREAN &&
+ reverse_lang_type != CTSVC_LANG_JAPANESE) {
+ if(name->first || name->addition)
+ len += snprintf(display + len, display_len - len, ",");
+ }
}
if(name->first) {
- if (*display)
- len += snprintf(display + len, display_len - len, " ");
+ if (*display) {
+ if (reverse_lang_type < 0 )
+ reverse_lang_type = ctsvc_check_language_type(display);
+
+ if (reverse_lang_type != CTSVC_LANG_KOREAN)
+ len += snprintf(display + len, display_len - len, " ");
+ }
len += snprintf(display + len, display_len - len, "%s", name->first);
}
if(name->addition) {
- if (*display)
- len += snprintf(display + len, display_len - len, " ");
+ if (*display) {
+ if (reverse_lang_type < 0 )
+ reverse_lang_type = ctsvc_check_language_type(display);
+
+ if (reverse_lang_type != CTSVC_LANG_KOREAN)
+ len += snprintf(display + len, display_len - len, " ");
+ }
len += snprintf(display + len, display_len - len, "%s", name->addition);
}
if(name->suffix) {
- if (*display)
+ if (*display) {
+ if (reverse_lang_type < 0 )
+ reverse_lang_type = ctsvc_check_language_type(display);
+
+ if (reverse_lang_type != CTSVC_LANG_KOREAN)
len += snprintf(display + len, display_len - len, " ");
+ }
len += snprintf(display + len, display_len - len, "%s", name->suffix);
}
+ contact->reverse_display_name = display;
+
+ // make display name
+ if (reverse_lang_type == CTSVC_LANG_KOREAN ||
+ reverse_lang_type == CTSVC_LANG_JAPANESE)
+ contact->display_name = strdup(display);
+ else {
+ display_len -= 1; // ","
+ // make reverse_display_name
+ display = calloc(1, display_len);
+ len = 0;
+
+ if(name->prefix)
+ len += snprintf(display + len, display_len - len, "%s", name->prefix);
+
+ if(name->first) {
+ if (*display)
+ len += snprintf(display + len, display_len - len, " ");
+ len += snprintf(display + len, display_len - len, "%s", name->first);
+ }
+
+ if(name->addition) {
+ if (*display)
+ len += snprintf(display + len, display_len - len, " ");
+ len += snprintf(display + len, display_len - len, "%s", name->addition);
+ }
+
+ if(name->last) {
+ if (*display)
+ len += snprintf(display + len, display_len - len, " ");
+ len += snprintf(display + len, display_len - len, "%s", name->last);
+ }
+
+ if(name->suffix) {
+ if (*display)
+ len += snprintf(display + len, display_len - len, " ");
+ len += snprintf(display + len, display_len - len, "%s", name->suffix);
+ }
+ contact->display_name = display;
+ }
ctsvc_record_set_property_flag((ctsvc_record_s *)contact, _contacts_contact.display_name, CTSVC_PROPERTY_FLAG_DIRTY);
- contact->reverse_display_name = display;
contact->sort_name = SAFE_STRDUP(contact->display_name);
contact->reverse_sort_name = SAFE_STRDUP(contact->reverse_display_name);
contact->display_source_type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NAME;
ret = CTSVC_SORT_OTHERS;
if (contact->display_name)
ret = ctsvc_get_name_sort_type(contact->display_name);
- WARN_IF( ret < 0, "ctsvc_check_language_type Failed(%d)", ret);
+ WARN_IF( ret < 0, "ctsvc_get_name_sort_type Failed(%d)", ret);
switch (ret)
{
ret = CTSVC_SORT_OTHERS;
if (contact->reverse_display_name)
ret = ctsvc_get_name_sort_type(contact->reverse_display_name);
- WARN_IF( ret < 0, "ctsvc_check_language_type Failed(%d)", ret);
+ WARN_IF( ret < 0, "ctsvc_get_name_sort_type Failed(%d)", ret);
switch (ret)
{
case CTSVC_SORT_CJK:
else if (properties[i].property_id == CTSVC_PROPERTY_PERSON_DISPLAY_NAME_INDEX) {
snprintf(temp, sizeof(temp), "_NORMALIZE_INDEX_(%s)", ctsvc_get_sort_name_column());
field_name = temp;
- CTS_DBG("field_name : %s", field_name);
}
else
field_name = ctsvc_get_display_column();
return false;
}
+static char* __ctsvc_db_make_search_keyword(const char*keyword)
+{
+ int size = strlen(keyword);
+
+ if (keyword == NULL)
+ return NULL;
+
+ if (strstr(keyword, " ") != NULL) {
+ int i = 0;
+ int j = 0;
+ char search_keyword[size * 2+1];
+ for(i=0;i<size;i++) {
+ if (j>0 && keyword[i] == ' ') {
+ if (search_keyword[j-1] != ' ' )
+ search_keyword[j++] = '*';
+ }
+ search_keyword[j++] = keyword[i];
+ }
+ if (j > 0 && search_keyword[j-1] != ' ')
+ search_keyword[j++] = '*';
+ search_keyword[j] = '\0';
+ return strdup(search_keyword);
+ }
+ else {
+ char search_keyword[size+2];
+ snprintf(search_keyword, sizeof(search_keyword), "%s*", keyword);
+ return strdup(search_keyword);
+ }
+}
+
static int __ctsvc_db_append_search_query(const char *keyword, char *query, int size)
{
- bool emailaddress = false;
bool phonenumber = false;
int ret;
int len = 0, i;
- if (strstr(keyword, "@") != NULL) {
- emailaddress = true;
- }
- else {
- len = strlen(keyword);
- phonenumber = true;
- for(i=0; i<len; i++) {
- if (keyword[i] < '0' || keyword[i] > '9') {
- phonenumber = false;
- break;
- }
+ len = strlen(keyword);
+ phonenumber = true;
+ for(i=0; i<len; i++) {
+ if (keyword[i] < '0' || keyword[i] > '9') {
+ phonenumber = false;
+ break;
}
}
- if (emailaddress) {
- ret = snprintf(query, size,
- "(SELECT contact_id FROM %s WHERE %s MATCH 'data:%s*') ",
- CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX,
- keyword );
- }
- else if (phonenumber) {
+ 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*' "
+ "(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,
}
else {
char *normalized_name = NULL;
+ char *search_keyword = NULL;
+ char *saarch_normal_name = NULL;
ret = ctsvc_normalize_str(keyword, &normalized_name);
+ search_keyword = __ctsvc_db_make_search_keyword(keyword);
+ saarch_normal_name = __ctsvc_db_make_search_keyword(normalized_name);
+
if (CTSVC_LANG_KOREAN == ret) {
char *chosung = calloc(1, strlen(keyword) * 5);
char *korean_pattern = calloc(1, strlen(keyword) * 5);
+ char *search_chosung = NULL;
ctsvc_get_chosung(keyword, chosung, strlen(keyword) * 5 );
ctsvc_get_korean_search_pattern(keyword, korean_pattern, strlen(keyword) * 5 );
+
+ 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*' "
- "INTERSECT "
- "SELECT contact_id FROM %s WHERE name GLOB '*%s*') ",
+ "(SELECT contact_id FROM %s WHERE %s MATCH 'name:%s OR number:%s OR data:%s' "
+ "INTERSECT SELECT contact_id FROM %s WHERE name GLOB '*%s*' ",
CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX,
- chosung, keyword, keyword, CTS_TABLE_NAME_LOOKUP, korean_pattern );
+ search_chosung, search_keyword, search_keyword, CTS_TABLE_NAME_LOOKUP, korean_pattern);
free(chosung);
free(korean_pattern);
+ free(search_chosung);
}
- else if (CTSVC_LANG_JAPANESE == ret){
+ else if (CTSVC_LANG_JAPANESE == ret) {
char *hiragana = NULL;
+ char *search_hiragana = NULL;
ctsvc_convert_japanese_to_hiragana(keyword, &hiragana);
+ 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*') ",
+ "(SELECT contact_id FROM %s WHERE %s MATCH 'name:%s OR number:%s OR data:%s' ",
CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX,
- hiragana, hiragana, hiragana);
+ 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*') ",
+ "(SELECT contact_id FROM %s WHERE %s MATCH 'name:%s OR number:%s OR data:%s' ",
CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX,
- normalized_name, keyword, keyword);
+ saarch_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*') ",
+ "(SELECT contact_id FROM %s WHERE %s MATCH 'name:%s OR number:%s OR data:%s' ",
CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX,
- keyword, keyword, keyword);
+ search_keyword, search_keyword, search_keyword);
+ }
+
+ if (strstr(keyword, "@") != NULL) {
+ ret += snprintf(query+ret, size-ret,
+ " UNION "
+ "SELECT contact_id FROM %s WHERE %s MATCH 'data:%s' ) ",
+ CTS_TABLE_SEARCH_INDEX, CTS_TABLE_SEARCH_INDEX, search_keyword);
}
+ else
+ ret += snprintf(query+ret, size-ret,") ");
+
free(normalized_name);
+ free(search_keyword);
+ free(saarch_normal_name);
}
return ret;
}
else { // CTSVC_VIEW_URI_PERSON
len = snprintf(query, sizeof(query), "SELECT %s FROM %s, "
- "(SELECT person_id person_id_in_contact "
+ "(SELECT person_id person_id_in_contact, addressbook_id "
"FROM "CTS_TABLE_CONTACTS " "
"WHERE deleted = 0 AND contact_id IN ",
projection, table);
RETVM_IF(false == can_keyword_search, CONTACTS_ERROR_INVALID_PARAMETER,
"Invalid parameter : can not keyword search");
- if (s_query->filter) {
- ret = __ctsvc_db_create_composite_condition(s_query->filter, &condition, &bind_text);
- RETVM_IF (CONTACTS_ERROR_NONE != ret, ret, "__ctsvc_db_create_composite_condition is failed(%s)", ret);
- }
-
ret = __ctsvc_db_create_projection(s_query->properties, s_query->property_count,
s_query->projection, s_query->projection_count, &projection);
RETVM_IF (CONTACTS_ERROR_NONE != ret, ret, "__ctsvc_db_create_projection is failed(%s)", ret);
+ if (s_query->filter) {
+ ret = __ctsvc_db_create_composite_condition(s_query->filter, &condition, &bind_text);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("__ctsvc_db_create_composite_condition is failed(%s)", ret);
+ free(projection);
+ return ret;
+ }
+ }
+
ret = __ctsvc_db_search_records_with_query_exec(s_query, projection, condition, bind_text, keyword, offset, limit, out_list);
- RETVM_IF (CONTACTS_ERROR_NONE != ret, ret, "__ctsvc_db_search_records_with_query_exec is failed(%s)", ret);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("__ctsvc_db_search_records_with_query_exec is failed(%s)", ret);
+ for (cursor=bind_text;cursor;cursor=cursor->next)
+ free(cursor->data);
+ g_slist_free(bind_text);
+
+ free(condition);
+ free(projection);
+ return ret;
+ }
for (cursor=bind_text;cursor;cursor=cursor->next)
free(cursor->data);
int ret;
char *condition = NULL;
char *projection;
- ctsvc_query_s *query_s;
+ ctsvc_query_s *s_query;
GSList *bind_text = NULL;
GSList *cursor;
RETV_IF(NULL == query, CONTACTS_ERROR_INVALID_PARAMETER);
- query_s = (ctsvc_query_s *)query;
+ s_query = (ctsvc_query_s *)query;
- if (query_s->filter) {
- ret = __ctsvc_db_create_composite_condition(query_s->filter, &condition, &bind_text);
+ if (s_query->filter) {
+ ret = __ctsvc_db_create_composite_condition(s_query->filter, &condition, &bind_text);
RETVM_IF (CONTACTS_ERROR_NONE != ret, ret, "__ctsvc_db_create_composite_condition is failed(%s)", ret);
}
- ret = __ctsvc_db_create_projection(query_s->properties, query_s->property_count,
- query_s->projection, query_s->projection_count, &projection);
+ ret = __ctsvc_db_create_projection(s_query->properties, s_query->property_count,
+ s_query->projection, s_query->projection_count, &projection);
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("__ctsvc_db_create_projection is failed(%d)", ret);
for (cursor=bind_text;cursor;cursor=cursor->next)
return ret;
}
- ret = __ctsvc_db_get_count_with_query_exec(query_s, projection, condition, bind_text, out_count);
+ ret = __ctsvc_db_get_count_with_query_exec(s_query, projection, condition, bind_text, out_count);
for (cursor=bind_text;cursor;cursor=cursor->next)
free(cursor->data);
g_slist_free(bind_text);
static inline int __ctsvc_put_person_default_data(int person_id, int id, int datatype)
{
int ret;
- int is_default;
+ int is_default = 0;
+ int contact_id = 0;
+ int name_contact_id = 0;
char query[CTS_SQL_MAX_LEN] = {0};
+ cts_stmt stmt = NULL;
+ contacts_display_name_source_type_e source_type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID;
snprintf(query, sizeof(query),
- "SELECT D.is_default FROM %s D, %s C "
+ "SELECT D.is_default, D.contact_id FROM %s D, %s C "
"ON (D.contact_id=C.contact_id AND C.deleted = 0) "
"WHERE D.datatype=%d AND C.person_id=%d AND D.id=%d",
CTS_TABLE_DATA, CTS_TABLE_CONTACTS, datatype, person_id, id);
- ret = ctsvc_query_get_first_int_result(query, &is_default);
- RETVM_IF(ret < CONTACTS_ERROR_NONE, ret, "ctsvc_query_get_first_int_result() Failed(%d)", ret);
+ stmt = cts_query_prepare(query);
+ if (NULL == stmt) {
+ CTS_ERR("cts_query_prepare Fail(stmt NULL)");
+ return CONTACTS_ERROR_DB;
+ }
+ ret = cts_stmt_step(stmt);
+ if (1 != ret) {
+ CTS_ERR("cts_stmt_step Fail(%d)", ret);
+ cts_stmt_finalize(stmt);
+ return ret;
+ }
+
+ is_default = ctsvc_stmt_get_int(stmt, 0);
+ contact_id = ctsvc_stmt_get_int(stmt, 1);
+
+ cts_stmt_finalize(stmt);
ret = ctsvc_begin_trans();
RETVM_IF(CONTACTS_ERROR_NONE > ret, ret, "DB error : ctsvc_begin_trans() Failed(%d)", ret);
"UPDATE "CTS_TABLE_DATA" SET is_primary_default=1, is_default=1 WHERE id=%d ", id);
ret = ctsvc_query_exec(query);
- if( CONTACTS_ERROR_NONE != ret ) {
+ if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR( "ctsvc_query_exec() Failed(%d)", ret);
ctsvc_end_trans(false);
return ret;
}
+ if (datatype == CTSVC_DATA_NUMBER)
+ source_type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NUMBER;
+ else if (datatype == CTSVC_DATA_EMAIL)
+ source_type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_EMAIL;
+
+ if (CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID != source_type)
+ ctsvc_contact_update_display_name(contact_id, source_type);
+
+ snprintf(query, sizeof(query),
+ "SELECT name_contact_id FROM "CTS_TABLE_PERSONS" WHERE person_id = %d", person_id);
+ ret = ctsvc_query_get_first_int_result(query, &name_contact_id);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR( "ctsvc_query_get_first_int_result() Failed(%d)", ret);
+ ctsvc_end_trans(false);
+ return ret;
+ }
+
+ if (name_contact_id != contact_id) {
+ int org_source_type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID;
+ snprintf(query, sizeof(query),
+ "SELECT display_name_source FROM "CTS_TABLE_CONTACTS" WHERE contact_id = %d", name_contact_id);
+ ret = ctsvc_query_get_first_int_result(query, &org_source_type);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR( "ctsvc_query_get_first_int_result() Failed(%d)", ret);
+ ctsvc_end_trans(false);
+ return ret;
+ }
+
+ if (org_source_type <= source_type) {
+ snprintf(query, sizeof(query),
+ "UPDATE %s SET name_contact_id=%d WHERE person_id=%d",
+ CTS_TABLE_PERSONS, contact_id, person_id);
+ ret = ctsvc_query_exec(query);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR( "ctsvc_query_exec() Failed(%d)", ret);
+ ctsvc_end_trans(false);
+ return ret;
+ }
+ }
+ }
+
ret = ctsvc_end_trans(true);
if (ret < CONTACTS_ERROR_NONE)
{
ret = sqlite3_step(stmt);
if (SQLITE_ROW != ret) {
sqlite3_finalize(stmt);
+ CTS_DBG("query : %s", query);
if (SQLITE_DONE == ret) {
- INFO("sqlite3_step() return with SQLITE_DONE (it means NO_DATA) (%s, %d, %s)",
- query, ret, sqlite3_errmsg(ctsvc_db));
-
+ CTS_INFO("sqlite3_step() return with SQLITE_DONE (it means NO_DATA) (%d, %s)",
+ ret, sqlite3_errmsg(ctsvc_db));
return CONTACTS_ERROR_NO_DATA /*CONTACTS_ERR_DB_RECORD_NOT_FOUND*/;
}
-
- CTS_ERR("sqlite3_step() Failed(%s, %d, %s)",
- query, ret, sqlite3_errmsg(ctsvc_db));
-
+ CTS_ERR("sqlite3_step() Failed(%d, %s)", ret, sqlite3_errmsg(ctsvc_db));
return CONTACTS_ERROR_DB;
}
return false;
}
-static int __ctsvc_get_exif_info(const char *path)
+static image_util_rotation_e __ctsvc_get_rotation_info(const char *path)
{
ExifData *ed = NULL;
ExifEntry *entry;
+ image_util_rotation_e rotation = IMAGE_UTIL_ROTATION_NONE;
+ int orientation = 0;
ed = exif_data_new_from_file(path);
if (ed == NULL) {
CTS_ERR("exif_data_new_from_file : ExifData is NULL");
- return 0;
+ return IMAGE_UTIL_ROTATION_NONE;
}
entry = exif_data_get_entry(ed, EXIF_TAG_ORIENTATION);
if (entry) {
ExifByteOrder mByteOrder = exif_data_get_byte_order(ed);
- int orientation = (int)exif_get_short(entry->data, mByteOrder);
- if (orientation >= 0 && orientation <= 8)
- return orientation;
- else
- return 0;
+ orientation = (int)exif_get_short(entry->data, mByteOrder);
+ if (orientation < 0 && orientation > 8)
+ orientation = 0;
}
- return 0;
+
+ if (ed)
+ exif_data_unref(ed);
+
+ switch(orientation) {
+ case 1: // Top-left
+ rotation = IMAGE_UTIL_ROTATION_NONE;
+ break;
+ case 2: // Top-right
+ rotation = IMAGE_UTIL_ROTATION_FLIP_HORZ;
+ break;
+ case 3: // Bottom-right
+ rotation = IMAGE_UTIL_ROTATION_180;
+ break;
+ case 4: // Bottom-left
+ rotation = IMAGE_UTIL_ROTATION_FLIP_VERT;
+ break;
+ case 6: // Right-top
+ rotation = IMAGE_UTIL_ROTATION_90;
+ break;
+ case 8: // Left-bottom
+ rotation = IMAGE_UTIL_ROTATION_270;
+ break;
+ case 5: // Left-top
+ case 7: // Right-bottom
+ case 0:
+ default:
+ break;
+ };
+
+ return rotation;
}
static int image_size = 480;
unsigned char * img_target = 0;
unsigned char * img_source = 0;
int dest_fd;
- int orientation = 0;
image_util_rotation_e rotation;
// temporary code
return true;
}
- rotation = IMAGE_UTIL_ROTATION_NONE;
- orientation = __ctsvc_get_exif_info(info->src);
- switch(orientation) {
- case 1:
- rotation = IMAGE_UTIL_ROTATION_NONE;
- break;
- case 2:
- rotation = IMAGE_UTIL_ROTATION_FLIP_HORZ;
- break;
- case 3:
- rotation = IMAGE_UTIL_ROTATION_180;
- break;
- case 4:
- rotation = IMAGE_UTIL_ROTATION_FLIP_VERT;
- break;
- case 6:
- rotation = IMAGE_UTIL_ROTATION_90;
- break;
- case 8:
- rotation = IMAGE_UTIL_ROTATION_270;
- break;
- case 5:
- case 7:
- case 0:
- default:
- break;
- };
+ rotation = __ctsvc_get_rotation_info(info->src);
// load jpeg sample file
CTS_DBG("colorspace %d src : %s, dest : %s", colorspace, info->src, info->dest);
Name: contacts-service
Summary: Contacts Service
-Version: 0.9.82.2
+Version: 0.9.84.1
Release: 1
Group: TO_BE/FILLED_IN
License: Apache-2.0
chmod 770 -R /opt/usr/data/contacts-svc/img/
chmod 660 /opt/usr/data/contacts-svc/.CONTACTS_SVC_*
-vconftool set -t int file/private/contacts-service/default_lang 0 -g 6005
-vconftool set -t int db/contacts-svc/name_sorting_order 0 -g 6005
-vconftool set -t int db/contacts-svc/name_display_order 0 -g 6005
-vconftool set -t int db/contacts-svc/phonenumber_min_match_digit 8 -g 6005
+vconftool set -t int file/private/contacts-service/default_lang 0 -g 6005 -s contacts-service::vconf-private
+vconftool set -t int db/contacts-svc/name_sorting_order 0 -g 6005 -s contacts-service::vconf
+vconftool set -t int db/contacts-svc/name_display_order 0 -g 6005 -s contacts-service::vconf
+vconftool set -t int db/contacts-svc/phonenumber_min_match_digit 8 -g 6005 -s contacts-service::vconf
%postun -p /sbin/ldconfig
#include "ctsvc_server_sim.h"
#include "ctsvc_utils.h"
-#define PHONE_ADDRESSBOOK_ID 0
+#define DEFAULT_ADDRESS_BOOK_ID 0
#define CTSVC_TAPI_SIM_PB_MAX 0xFFFF
#define CTSVC_SIM_DATA_MAX_LENGTH (255+1)
case TAPI_SIM_PB_ADN:
case TAPI_SIM_PB_3GSIM:
record = __ctsvc_server_sim_create_contact_record(sim_info);
- ret = __ctsvc_server_insert_contact_to_db(record, &contact_id,PHONE_ADDRESSBOOK_ID);
+ ret = __ctsvc_server_insert_contact_to_db(record, &contact_id,DEFAULT_ADDRESS_BOOK_ID);
ctsvc_server_sim_destroy_contact_record(record);
if(ret < CONTACTS_ERROR_NONE || contact_id <= 0) {
CTS_ERR("__ctsvc_server_insert_or_update_contact_to_db is fail(%d)",ret);