SET(LIBDIR "\${prefix}/lib")
SET(INCLUDEDIR "\${prefix}/${DEST_INCLUDE_DIR}")
SET(VERSION_MAJOR 0)
-SET(VERSION "${VERSION_MAJOR}.9.45.3")
+SET(VERSION "${VERSION_MAJOR}.9.52.1")
EXECUTE_PROCESS(COMMAND build-util/generator.sh)
if (flags & CONTACTS_CONNECT_FLAG_RETRY) {
int i;
int waiting_time = 500;
- for (i=0;i<7;i++) {
+ for (i=0;i<9;i++) {
usleep(waiting_time * 1000);
DBG("retry cnt=%d, ret=%x, %d",(i+1), ret, waiting_time);
ret = contacts_connect2();
if (ret == CONTACTS_ERROR_NONE)
break;
- waiting_time *= 2;
+ if (6 < i)
+ waiting_time += 30000;
+ else
+ waiting_time *= 2;
}
}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include "contacts.h"
-#include "ctsvc_internal.h"
-#include "ctsvc_ipc_define.h"
-#include "ctsvc_ipc_marshal.h"
-#include "ctsvc_client_ipc.h"
-#include <pims-ipc-data.h>
-
-API int contacts_sim_insert(contacts_record_h record, int *contact_id)
-{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
-
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- CTS_ERR("ipc data created fail!");
- ret = CONTACTS_ERROR_OUT_OF_MEMORY;
- return ret;
- }
-
- ret = ctsvc_ipc_marshal_record( record, indata );
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_SIM_MODULE, CTSVC_IPC_SERVER_SIM_INSERT_CONTACT, indata, &outdata) != 0)
- {
- pims_ipc_data_destroy(indata);
- CTS_ERR("ctsvc_ipc_call failed");
- return CONTACTS_ERROR_IPC;
- }
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- pims_ipc_data_destroy(outdata);
- }
-
- pims_ipc_data_destroy(indata);
-
- return ret;
-}
-
-API int contacts_sim_update(contacts_record_h record)
-{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
-
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- CTS_ERR("ipc data created fail!");
- ret = CONTACTS_ERROR_OUT_OF_MEMORY;
- return ret;
- }
-
- ret = ctsvc_ipc_marshal_record( record, indata );
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_SIM_MODULE, CTSVC_IPC_SERVER_SIM_UPDATE_CONTACT, indata, &outdata) != 0)
- {
- pims_ipc_data_destroy(indata);
- CTS_ERR("ctsvc_ipc_call failed");
- return CONTACTS_ERROR_IPC;
- }
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- pims_ipc_data_destroy(outdata);
- }
-
- pims_ipc_data_destroy(indata);
-
- return ret;
-}
-
-API int contacts_sim_delete(int person_id)
-{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(person_id <= 0,CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
-
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- CTS_ERR("ipc data created fail!");
- ret = CONTACTS_ERROR_OUT_OF_MEMORY;
- return ret;
- }
-
- ret = ctsvc_ipc_marshal_int( person_id, indata );
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_SIM_MODULE, CTSVC_IPC_SERVER_SIM_DELETE_CONTACT, indata, &outdata) != 0)
- {
- pims_ipc_data_destroy(indata);
- CTS_ERR("ctsvc_ipc_call failed");
- return CONTACTS_ERROR_IPC;
- }
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- pims_ipc_data_destroy(outdata);
- }
-
- pims_ipc_data_destroy(indata);
-
- return ret;
-}
#define CTSVC_JAPANESE_HALFWIDTH_AND_FULLWIDTH_FORMS_START 0xFF00
#define CTSVC_JAPANESE_HALFWIDTH_AND_FULLWIDTH_FORMS_END 0xFFEF
+/* japanese - halfwidth and fullwidth forms */
+#define CTSVC_ASCII_HALFWIDTH_AND_FULLWIDTH_FORMS_START 0xFF01
+#define CTSVC_ASCII_HALFWIDTH_AND_FULLWIDTH_FORMS_END 0xFF5E
+
/* japanese - hiragana */
#define CTSVC_JAPANESE_HIRAGANA_START 0x3040
#define CTSVC_JAPANESE_HIRAGANA_END 0x309F
int unicode_value1 = 0;
int unicode_value2 = 0;
- unicode_value1 = 0x30;
unicode_value2 = (0xFF & (src[i]));
if (CTSVC_COMPARE_BETWEEN(CTSVC_JAPANESE_KATAKANA_START, src[i], CTSVC_JAPANESE_KATAKANA_END)) {
+ unicode_value1 = 0x30;
if ((unicode_value2 >= 0xa1 && unicode_value2 <= 0xef )
|| (unicode_value2 == 0xF2 || unicode_value2 == 0xF3) ) {
unicode_value2 -= 0x60;
dest[j] = unicode_value1 << 8 | unicode_value2;
}
- else
+ else {
dest[j] = src[i];
+ }
}
else if (CTSVC_COMPARE_BETWEEN(CTSVC_JAPANESE_HALFWIDTH_AND_FULLWIDTH_FORMS_START, src[i], CTSVC_JAPANESE_HALFWIDTH_AND_FULLWIDTH_FORMS_END)) {
+ unicode_value1 = 0x30;
if (i+1 < len && (0xFF & (src[i+1])) == 0x9E
&& unicode_value2 >= 0x76 && unicode_value2 <= 0x89) {
unicode_value2 = japanese_halfwidth_katakana_sonant_to_hiragana[unicode_value2 - 0x76];
unicode_value2 = japanese_halfwidth_katakana_to_hiragana[unicode_value2 - 0x66];
dest[j] = unicode_value1 << 8 | unicode_value2;
}
- else
+ else {
dest[j] = src[i];
-
- } else
+ }
+ }
+ else if (CTSVC_COMPARE_BETWEEN(CTSVC_ASCII_HALFWIDTH_AND_FULLWIDTH_FORMS_START, src[i], CTSVC_ASCII_HALFWIDTH_AND_FULLWIDTH_FORMS_END)) {
+ unicode_value1 = 0x00;
+ unicode_value2 = unicode_value2 - 0x20;
+ dest[j] = unicode_value1 << 8 | unicode_value2;
+ } else {
dest[j] = src[i];
+ }
j++;
}
ret = CONTACTS_ERROR_SYSTEM;
goto DATA_FREE;
}
+
result = calloc(1, sizeof(UChar) * (size + 1));
__ctsvc_convert_japanese_to_hiragana(tmp_result, result, size + 1 );
}
DATA_FREE:
-
free(tmp_result);
free(result);
if (CTSVC_COMPARE_BETWEEN('0', word[0], '9')) {
type = CTSVC_LANG_NUMBER;
}
- else if (CTSVC_COMPARE_BETWEEN(0x41, word[0], 0x7A)) { /* english */
+ else if (CTSVC_COMPARE_BETWEEN(0x41, word[0], 0x7A) /* english */
+ || CTSVC_COMPARE_BETWEEN(0x0300, word[0], 0x036f)) { /* diacritical marks */
type = CTSVC_LANG_ENGLISH;
}
else if (is_hangul(word[0])){
CTS_ERR("__ctsvc_normalize_number(src) failed(%d)", src, ret);
return ret;
}
-
return CONTACTS_ERROR_NONE;
}
u_strFromUTF8(tmp_result, size + 1, NULL, src, -1, &status);
if (U_FAILURE(status)){
CTS_ERR("u_strFromUTF8 Failed(%s)", u_errorName(status));
+ free(tmp_result);
ucol_close(collator);
return CONTACTS_ERROR_SYSTEM;
}
size = ucol_getSortKey(collator, tmp_result, -1, (uint8_t *)*dest, size + 1);
ucol_close(collator);
-
+ free(tmp_result);
return CONTACTS_ERROR_NONE;
}
if (NULL == _record->properties_flags) {
unsigned int count = 0;
ctsvc_view_get_all_property_infos(_record->view_uri, &count);
- RETVM_IF(count < 0, CONTACTS_ERROR_INVALID_PARAMETER, "ctsvc_view_get_all_property_infos() Failed");
+ RETVM_IF(count <= 0, CONTACTS_ERROR_INVALID_PARAMETER, "ctsvc_view_get_all_property_infos() Failed");
_record->properties_flags = calloc(count, sizeof(char));
_record->property_max_count = count;
int ctsvc_record_set_projection_flags( contacts_record_h record, const unsigned int *projection, const unsigned int projection_count, const unsigned int property_max_count)
{
int i;
- unsigned int count;
- const property_info_s *property_info;
RETV_IF(record == NULL, CONTACTS_ERROR_INVALID_PARAMETER);
_record->property_max_count = property_max_count;
- property_info = ctsvc_view_get_all_property_infos(_record->view_uri, &count);
if (CTSVC_RECORD_RESULT == _record->r_type)
_record->property_flag |= CTSVC_PROPERTY_FLAG_PROJECTION;
else {
out_data->addressbook_id = src_data->addressbook_id;
out_data->changed_time = src_data->changed_time;
out_data->display_source_type = src_data->display_source_type;
+ out_data->display_name_language = src_data->display_name_language;
out_data->has_phonenumber = src_data->has_phonenumber;
out_data->has_email = src_data->has_email;
out_data->is_favorite = src_data->is_favorite;
- out_data->is_restricted = src_data->is_restricted;
out_data->display_name = SAFE_STRDUP(src_data->display_name);
out_data->reverse_display_name = SAFE_STRDUP(src_data->reverse_display_name);
out_data->vibration_changed = src_data->vibration_changed;
out_data->image_thumbnail_changed = src_data->image_thumbnail_changed;
out_data->ringtone_changed = src_data->ringtone_changed;
+ out_data->display_name_changed = src_data->display_name_changed;
out_data->contact_id = src_data->contact_id;
out_data->person_id = src_data->person_id;
out_data->has_phonenumber = src_data->has_phonenumber;
out_data->has_email = src_data->has_email;
out_data->is_favorite = src_data->is_favorite;
- // out_data->is_restricted = src_data->is_restricted;
out_data->display_name = SAFE_STRDUP(src_data->display_name);
out_data->uid = SAFE_STRDUP(src_data->uid);
free(my_profile->base.properties_flags);
free(my_profile->display_name);
+ free(my_profile->reverse_display_name);
free(my_profile->uid);
free(my_profile->image_thumbnail_path);
out_data->changed_time = src_data->changed_time;
out_data->display_name = SAFE_STRDUP(src_data->display_name);
+ out_data->reverse_display_name = SAFE_STRDUP(src_data->reverse_display_name);
out_data->uid = SAFE_STRDUP(src_data->uid);
out_data->image_thumbnail_path = SAFE_STRDUP(src_data->image_thumbnail_path);
bool image_thumbnail_changed;
bool ringtone_changed;
bool vibration_changed;
- bool is_restricted;
bool is_favorite;
int changed_time;
bool has_phonenumber;
bool image_thumbnail_changed;
bool ringtone_changed;
bool vibration_changed;
- bool is_restricted;
bool is_favorite;
int id;
int person_id;
typedef struct {
ctsvc_record_s base;
+ bool display_name_changed;
int id;
int addressbook_id;
int changed_time;
char *display_name;
+ char *reverse_display_name;
char *uid;
char *image_thumbnail_path;
ctsvc_list_s* name;
return NULL;
case '\r':
case ' ':
- case ':':
src++;
break;
default:
{
int ret;
char *temp;
+ char *start;
const char *separator = ",";
contacts_record_h nickname;
+ start = __ctsvc_get_content_value(val);
+ RETV_IF(NULL == start, CONTACTS_ERROR_NO_DATA);
+
ret = contacts_record_create(_contacts_nickname._uri, &nickname);
RETVM_IF(ret < CONTACTS_ERROR_NONE, ret, "contacts_record_create is failed(%d)", ret);
- temp = strtok(val, separator);
+ temp = strtok(start, separator);
while (temp) {
if ('\0' == *temp) continue;
{CTSVC_PROPERTY_COMPANY_NAME, CTSVC_SEARCH_PROPERTY_ALL, "data3"},
{CTSVC_PROPERTY_COMPANY_DEPARTMENT, CTSVC_SEARCH_PROPERTY_ALL, "data4"},
{CTSVC_PROPERTY_COMPANY_JOB_TITLE, CTSVC_SEARCH_PROPERTY_ALL, "data5"},
- {CTSVC_PROPERTY_COMPANY_ASSISTANT_NAME,CTSVC_SEARCH_PROPERTY_ALL, "data6"},
- {CTSVC_PROPERTY_COMPANY_ROLE, CTSVC_SEARCH_PROPERTY_ALL, "data7"},
+ {CTSVC_PROPERTY_COMPANY_ROLE, CTSVC_SEARCH_PROPERTY_ALL, "data6"},
+ {CTSVC_PROPERTY_COMPANY_ASSISTANT_NAME, CTSVC_SEARCH_PROPERTY_ALL, "data7"},
{CTSVC_PROPERTY_COMPANY_LOGO, CTSVC_SEARCH_PROPERTY_ALL, "data8"},
{CTSVC_PROPERTY_COMPANY_LOCATION, CTSVC_SEARCH_PROPERTY_ALL, "data9"},
{CTSVC_PROPERTY_COMPANY_DESCRIPTION, CTSVC_SEARCH_PROPERTY_ALL, "data10"},
CTSVC_PROPERTY_COMPANY_NAME = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +4,
CTSVC_PROPERTY_COMPANY_DEPARTMENT = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +5,
CTSVC_PROPERTY_COMPANY_JOB_TITLE = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +6,
- CTSVC_PROPERTY_COMPANY_ASSISTANT_NAME = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +7,
- CTSVC_PROPERTY_COMPANY_ROLE = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +8,
+ CTSVC_PROPERTY_COMPANY_ROLE = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +7,
+ CTSVC_PROPERTY_COMPANY_ASSISTANT_NAME = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +8,
CTSVC_PROPERTY_COMPANY_LOGO = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +9,
CTSVC_PROPERTY_COMPANY_LOCATION = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +10,
CTSVC_PROPERTY_COMPANY_DESCRIPTION = (CTSVC_PROPERTY_COMPANY | CTSVC_VIEW_DATA_TYPE_STR) +11,
if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->image_thumbnail_changed) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->ringtone_changed) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->vibration_changed) != CONTACTS_ERROR_NONE) break;
- if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->is_restricted) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->is_favorite) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->id) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->person_id) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_bool((pcontact->image_thumbnail_changed),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_bool((pcontact->ringtone_changed),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_bool((pcontact->vibration_changed),ipc_data) != CONTACTS_ERROR_NONE) break;
- if (ctsvc_ipc_marshal_bool((pcontact->is_restricted),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_bool((pcontact->is_favorite),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_int((pcontact->id),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_int((pcontact->person_id),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_int(ipc_data, &pmy_profile->changed_time) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_int(ipc_data, &pmy_profile->addressbook_id) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_string(ipc_data, &pmy_profile->display_name) != CONTACTS_ERROR_NONE) break;
+ if (ctsvc_ipc_unmarshal_string(ipc_data, &pmy_profile->reverse_display_name) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_string(ipc_data, &pmy_profile->uid) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_string(ipc_data, &pmy_profile->image_thumbnail_path) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_int((pcontact->changed_time),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_int((pcontact->addressbook_id),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->reverse_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_string((pcontact->image_thumbnail_path),ipc_data) != CONTACTS_ERROR_NONE) break;
ctsvc_simple_contact_s* pcontact = (ctsvc_simple_contact_s*) record;
do {
- if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->is_restricted) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->is_favorite) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_int(ipc_data, &pcontact->changed_time) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_unmarshal_bool(ipc_data, &pcontact->has_phonenumber) != CONTACTS_ERROR_NONE) break;
RETV_IF(ipc_data==NULL,CONTACTS_ERROR_NO_DATA);
RETV_IF(pcontact==NULL,CONTACTS_ERROR_NO_DATA);
do {
- if (ctsvc_ipc_marshal_bool((pcontact->is_restricted),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_bool((pcontact->is_favorite),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_int((pcontact->changed_time),ipc_data) != CONTACTS_ERROR_NONE) break;
if (ctsvc_ipc_marshal_bool((pcontact->has_phonenumber),ipc_data) != CONTACTS_ERROR_NONE) break;
</request>
</define>
<assign>
- <filesystem path="/usr/lib/libcontacts-service2.so.0.9.45.3" label="_"/>
+ <filesystem path="/usr/lib/libcontacts-service2.so.0.9.52.1" label="_"/>
<filesystem path="/usr/lib/libcontacts-service2.so.0" label="_"/>
- <filesystem path="/usr/lib/libcontacts-service3.so.0.9.45.3" label="_"/>
+ <filesystem path="/usr/lib/libcontacts-service3.so.0.9.52.1" label="_"/>
<filesystem path="/usr/lib/libcontacts-service3.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"/>
#include "ctsvc_sqlite.h"
#include "ctsvc_db_init.h"
#include "ctsvc_utils.h"
-#include "ctsvc_restriction.h"
#include "ctsvc_view.h"
#include "ctsvc_notification.h"
CTS_ERR("ctsvc_db_open() Failed(%d)", ret);
return ret;
}
- ret = ctsvc_restriction_init();
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_restriction_init() Failed(%d)", ret);
- return ret;
- }
#ifdef _CONTACTS_IPC_SERVER
ret = __ctsvc_db_create_views();
CTS_ERR("ctsvc_db_close() Failed(%d)", ret);
return ret;
}
- ctsvc_restriction_deinit();
return CONTACTS_ERROR_NONE;
}
static int __ctsvc_db_contact_delete_record( int id )
{
- CTS_FN_CALL;
- int ret, rel_changed;
- int addressbook_id;
- int person_id;
- int link_count = 0;
- char query[CTS_SQL_MAX_LEN] = {0};
- cts_stmt stmt = NULL;
-
- ret = ctsvc_begin_trans();
- RETVM_IF(ret, ret, "DB error : ctsvc_begin_trans() Failed(%d)", ret);
-
- snprintf(query, sizeof(query),
- "SELECT addressbook_id, person_id "
- "FROM "CTS_TABLE_CONTACTS" WHERE contact_id = %d AND deleted = 0", id);
-
- stmt = cts_query_prepare(query);
- if (NULL == stmt) {
- CTS_ERR("DB error : cts_query_prepare() Failed");
- ctsvc_end_trans(false);
- return CONTACTS_ERROR_DB;
- }
-
- ret = cts_stmt_step(stmt);
- if (1 != ret) {
- CTS_ERR("DB error : cts_stmt_step() Failed(%d)", ret);
- cts_stmt_finalize(stmt);
- ctsvc_end_trans(false);
- if (CONTACTS_ERROR_NONE == ret)
- return CONTACTS_ERROR_NO_DATA;
- else
- return ret;
- }
-
- addressbook_id = ctsvc_stmt_get_int(stmt, 0);
- person_id = ctsvc_stmt_get_int(stmt, 1);
- CTS_DBG("addressbook_id : %d, person_id : %d", addressbook_id, person_id);
- cts_stmt_finalize(stmt);
-
- snprintf(query, sizeof(query),
- "UPDATE %s SET member_changed_ver=%d "
- "WHERE group_id IN (SELECT group_id FROM %s WHERE contact_id = %d AND deleted = 0) ",
- CTS_TABLE_GROUPS, ctsvc_get_next_ver(), CTS_TABLE_GROUP_RELATIONS, 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;
- }
-
- rel_changed = cts_db_change();
- // images are deleted by db trigger callback function in ctsvc_db_contact_delete_callback
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE contact_id = %d",
- CTS_TABLE_CONTACTS, 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;
- }
-
- snprintf(query, sizeof(query), "SELECT link_count FROM "CTS_TABLE_PERSONS" WHERE person_id = %d", person_id);
- ret = ctsvc_query_get_first_int_result(query, &link_count);
- WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_query_get_first_int_result() Failed(%d)", ret);
- // set dirty bit to person by trigger : person will be aggregated in ctsvc_person_aggregate
- if (1 < link_count)
- ctsvc_person_aggregate(person_id);
- else
- ctsvc_set_person_noti();
-
- ctsvc_set_contact_noti();
- if (rel_changed > 0)
- ctsvc_set_group_rel_noti();
-
- ret = ctsvc_end_trans(true);
- if (ret < CONTACTS_ERROR_NONE)
- {
- CTS_ERR("DB error : ctsvc_end_trans() Failed(%d)", ret);
- return ret;
- }
- else
- return CONTACTS_ERROR_NONE;
+ return ctsvc_db_contact_delete(id);
}
static inline int __ctsvc_safe_strcmp(char *s1, char *s2)
char *number = NULL;
char *data = NULL;
+ char *normalized_data = NULL;
char *temp_number=NULL;
char *temp_data=NULL;
int buf_size=0;
contacts_list_h number_list = (contacts_list_h)contact->numbers;
ctsvc_number_s *number_record;
contacts_list_first(number_list);
- len = 0;
do {
contacts_list_get_current_record_p(number_list, (contacts_record_h*)&number_record);
if (NULL != number_record) {
}while(CONTACTS_ERROR_NONE == contacts_list_next(number_list));
}
- len = 0;
if (contact->emails) {
contacts_list_h email_list = (contacts_list_h)contact->emails;
ctsvc_email_s *email;
if (data)
snprintf(temp_data, buf_size, "%s %s ", data, nickname->nickname);
else
- snprintf(temp_data+len, buf_size, "%s ", nickname->nickname);
+ snprintf(temp_data, buf_size, "%s ", nickname->nickname);
free(data);
data = temp_data;
}
}while(CONTACTS_ERROR_NONE == contacts_list_next(address_list));
}
+ if (contact->note) {
+ contacts_list_h note_list = (contacts_list_h)contact->note;
+ ctsvc_note_s *note;
+ contacts_list_first(note_list);
+ do {
+ contacts_list_get_current_record_p(note_list, (contacts_record_h*)¬e);
+ if (NULL != note) {
+ buf_size = SAFE_STRLEN(data) + SAFE_STRLEN(note->note) + 3;
+ temp_data = calloc(1, buf_size);
+ if (data)
+ snprintf(temp_data, buf_size, "%s %s ",data, note->note);
+ else
+ snprintf(temp_data, buf_size, "%s",note->note);
+ free(data);
+ data = temp_data;
+ }
+ }while(CONTACTS_ERROR_NONE == contacts_list_next(note_list));
+ }
+
+ if (contact->messengers) {
+ contacts_list_h messenger_list = (contacts_list_h)contact->messengers;
+ ctsvc_messenger_s *messenger;
+ contacts_list_first(messenger_list);
+ do {
+ contacts_list_get_current_record_p(messenger_list, (contacts_record_h*)&messenger);
+ if (NULL != messenger) {
+ buf_size = SAFE_STRLEN(data) + SAFE_STRLEN(messenger->im_id) + 3;
+ temp_data = calloc(1, buf_size);
+ if (data)
+ snprintf(temp_data, buf_size, "%s %s ",data, messenger->im_id);
+ else
+ snprintf(temp_data, buf_size, "%s",messenger->im_id);
+ free(data);
+ data = temp_data;
+ }
+ }while(CONTACTS_ERROR_NONE == contacts_list_next(messenger_list));
+ }
+
+ if (contact->relationships) {
+ contacts_list_h relationship_list = (contacts_list_h)contact->relationships;
+ ctsvc_relationship_s *relationship;
+ contacts_list_first(relationship_list);
+ do {
+ contacts_list_get_current_record_p(relationship_list, (contacts_record_h*)&relationship);
+ if (NULL != relationship) {
+ buf_size = SAFE_STRLEN(data) + SAFE_STRLEN(relationship->name) + 3;
+ temp_data = calloc(1, buf_size);
+ if (data)
+ snprintf(temp_data, buf_size, "%s %s ",data, relationship->name);
+ else
+ snprintf(temp_data, buf_size, "%s",relationship->name);
+ free(data);
+ data = temp_data;
+ }
+ }while(CONTACTS_ERROR_NONE == contacts_list_next(relationship_list));
+ }
+
+ if (contact->company) {
+ contacts_list_h company_list = (contacts_list_h)contact->company;
+ ctsvc_company_s *company;
+ contacts_list_first(company_list);
+ do {
+ contacts_list_get_current_record_p(company_list, (contacts_record_h*)&company);
+ if (NULL != company) {
+ len =0;
+ buf_size = SAFE_STRLEN(data)
+ + SAFE_STRLEN(company->name)
+ + SAFE_STRLEN(company->department)
+ + SAFE_STRLEN(company->job_title)
+ + SAFE_STRLEN(company->role)
+ + SAFE_STRLEN(company->assistant_name)
+ + SAFE_STRLEN(company->location)
+ + SAFE_STRLEN(company->description)
+ + SAFE_STRLEN(company->phonetic_name)+ 10;
+ temp_data = calloc(1, buf_size);
+ if(data)
+ len += snprintf(temp_data + len, buf_size - len, "%s ", data);
+ if (company->name)
+ len += snprintf(temp_data + len, buf_size - len, "%s ", company->name);
+ if (company->department)
+ len += snprintf(temp_data + len, buf_size - len, "%s ", company->department);
+ if (company->job_title)
+ len += snprintf(temp_data + len, buf_size - len, "%s ", company->job_title);
+ if (company->role)
+ len += snprintf(temp_data + len, buf_size - len, "%s ", company->role);
+ if (company->assistant_name)
+ len += snprintf(temp_data + len, buf_size - len, "%s ", company->assistant_name);
+ if (company->location)
+ len += snprintf(temp_data + len, buf_size - len, "%s ", company->location);
+ if (company->description)
+ len += snprintf(temp_data + len, buf_size - len, "%s ", company->description);
+ if (company->phonetic_name)
+ len += snprintf(temp_data + len, buf_size - len, "%s ", company->phonetic_name);
+
+ free(data);
+ data = temp_data;
+ }
+ }while(CONTACTS_ERROR_NONE == contacts_list_next(company_list));
+ }
+
contacts_record_destroy((contacts_record_h)contact, true);
*search_number = number;
- *search_data = data;
+ if (data) {
+ ctsvc_normalize_str(data, &normalized_data);
+ *search_data = normalized_data;
+ free(data);
+ }
return CONTACTS_ERROR_NONE;
}
int ret, person_id = 0;
char query[CTS_SQL_MAX_LEN] = {0};
bool auto_link_enabled = true;
+ bool auto_linked = false;
ctsvc_contact_s *contact = (ctsvc_contact_s*)record;
int rel_changed = 0;
if (id)
*id = ret;
- DBG("B ctsvc_make_contact_display_name");
ctsvc_make_contact_display_name(contact);
- DBG("A ctsvc_make_contact_display_name");
+
__ctsvc_contact_check_default_data(contact);
//Insert Data
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;
+ auto_linked = true;
}
else {
ret = ctsvc_db_insert_person((contacts_record_h)contact);
}
snprintf(query, sizeof(query),
- "INSERT INTO "CTS_TABLE_CONTACTS"(contact_id, person_id, addressbook_id, is_restricted, "
+ "INSERT INTO "CTS_TABLE_CONTACTS"(contact_id, person_id, addressbook_id, is_favorite, "
"created_ver, changed_ver, changed_time, image_changed_ver, has_phonenumber, has_email, "
"display_name, reverse_display_name, display_name_source, display_name_language, "
"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, ?, ?, ?, ?, ?, ?, ?, ?)",
- contact->id, contact->person_id, contact->addressbook_id, contact->is_restricted,
+ contact->id, contact->person_id, contact->addressbook_id, contact->is_favorite,
version, version, (int)time(NULL), (NULL !=contact->image_thumbnail_path)?version:0, contact->has_phonenumber, contact->has_email,
contact->display_source_type, contact->display_name_language);
}
}
- DBG("B __ctsvc_contact_insert_search_data");
__ctsvc_contact_insert_search_data(contact->id);
- DBG("A __ctsvc_contact_insert_search_data");
+
+ // person aggregation when auto_linked
+ if (auto_linked)
+ ctsvc_person_aggregate(contact->person_id);
if (rel_changed)
ctsvc_set_group_rel_noti();
//#include "ctsvc_db_plugin_grouprelation_helper.h"
+#include "ctsvc_person.h"
#include "ctsvc_group.h"
-#define CTSVC_MY_IMAGE_LOCATION "/opt/usr/data/contacts-svc/img/my"
-
-int ctsvc_contact_add_image_file(ctsvc_img_e image_type, int parent_id, int img_id,
+int ctsvc_contact_add_image_file(int parent_id, int img_id,
char *src_img, char *dest_name, int dest_size)
{
int ret;
+ int version;
char *ext;
char dest[CTSVC_IMG_FULL_PATH_SIZE_MAX] = {0};
if (NULL == ext || strchr(ext, '/'))
ext = "";
- snprintf(dest, sizeof(dest), "%s/%d_%d-%d%s", CTS_IMG_FULL_LOCATION, parent_id, img_id, image_type, ext);
+ version = ctsvc_get_next_ver();
+ snprintf(dest, sizeof(dest), "%s/%d_%d-%d%s", CTS_IMG_FULL_LOCATION, parent_id, img_id, version, ext);
ret = ctsvc_copy_image(src_img, dest);
RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "cts_copy_file() Failed(%d)", ret);
- snprintf(dest_name, dest_size, "%d_%d-%d%s", parent_id, img_id, image_type, ext);
+ snprintf(dest_name, dest_size, "%d_%d-%d%s", parent_id, img_id, version, ext);
return CONTACTS_ERROR_NONE;
}
-static inline const char* __ctsvc_get_image_column_name(ctsvc_img_e image_type)
-{
- switch(image_type)
- {
- case CTSVC_IMG_NORMAL:
- return "image_thumbnail_path";
- default:
- CTS_ERR("Invalid parameter : The image_type(%d) is not supported", image_type);
- return NULL;
- }
-}
-
-static int __ctsvc_contact_delete_image_file(ctsvc_img_e image_type, int image_id)
+static int __ctsvc_contact_delete_image_file(int image_id)
{
int ret;
cts_stmt stmt;
return CONTACTS_ERROR_NONE;
}
-int ctsvc_contact_update_image_file(int image_type, int parent_id, int img_id,
+int ctsvc_contact_update_image_file(int parent_id, int img_id,
char *src_img, char *dest_name, int dest_size)
{
int ret;
return CONTACTS_ERROR_NONE;
}
- ret = __ctsvc_contact_delete_image_file(image_type, img_id);
+ ret = __ctsvc_contact_delete_image_file(img_id);
WARN_IF(CONTACTS_ERROR_NONE != ret && CONTACTS_ERROR_NO_DATA != ret,
"__ctsvc_contact_delete_image_file() Failed(%d)", ret);
if (src_img) {
- ret = ctsvc_contact_add_image_file(image_type, parent_id, img_id, src_img, dest_name, dest_size);
+ ret = ctsvc_contact_add_image_file(parent_id, img_id, src_img, dest_name, dest_size);
RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_contact_add_image_file() Failed(%d)", ret);
}
return CONTACTS_ERROR_NONE;
}
+int ctsvc_db_contact_delete(int contact_id)
+{
+ CTS_FN_CALL;
+ int ret, rel_changed;
+ int addressbook_id;
+ int person_id;
+ int link_count = 0;
+ char query[CTS_SQL_MAX_LEN] = {0};
+ cts_stmt stmt = NULL;
+ int version;
+
+ ret = ctsvc_begin_trans();
+ RETVM_IF(ret, ret, "DB error : ctsvc_begin_trans() Failed(%d)", ret);
+
+ snprintf(query, sizeof(query),
+ "SELECT addressbook_id, person_id "
+ "FROM "CTS_TABLE_CONTACTS" WHERE contact_id = %d AND deleted = 0", contact_id);
+
+ stmt = cts_query_prepare(query);
+ if (NULL == stmt) {
+ CTS_ERR("DB error : cts_query_prepare() Failed");
+ ctsvc_end_trans(false);
+ return CONTACTS_ERROR_DB;
+ }
+
+ ret = cts_stmt_step(stmt);
+ if (1 != ret) {
+ CTS_ERR("DB error : cts_stmt_step() Failed(%d)", ret);
+ cts_stmt_finalize(stmt);
+ ctsvc_end_trans(false);
+ if (CONTACTS_ERROR_NONE == ret)
+ return CONTACTS_ERROR_NO_DATA;
+ else
+ return ret;
+ }
+
+ addressbook_id = ctsvc_stmt_get_int(stmt, 0);
+ person_id = ctsvc_stmt_get_int(stmt, 1);
+ CTS_DBG("addressbook_id : %d, person_id : %d", addressbook_id, person_id);
+ cts_stmt_finalize(stmt);
+
+ version = ctsvc_get_next_ver();
+ snprintf(query, sizeof(query),
+ "UPDATE %s SET member_changed_ver=%d "
+ "WHERE group_id IN (SELECT group_id FROM %s WHERE contact_id = %d AND deleted = 0) ",
+ CTS_TABLE_GROUPS, version, CTS_TABLE_GROUP_RELATIONS, contact_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;
+ }
+
+ rel_changed = cts_db_change();
+ snprintf(query, sizeof(query),
+ "UPDATE %s SET deleted = 1, person_id = 0, changed_ver=%d WHERE contact_id = %d",
+ CTS_TABLE_CONTACTS, version, contact_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;
+ }
+
+ snprintf(query, sizeof(query), "SELECT link_count FROM "CTS_TABLE_PERSONS" WHERE person_id = %d", person_id);
+ ret = ctsvc_query_get_first_int_result(query, &link_count);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_query_get_first_int_result() Failed(%d)", ret);
+ // set dirty bit to person by trigger : person will be aggregated in ctsvc_person_aggregate
+
+ if (1 < link_count)
+ ctsvc_person_aggregate(person_id);
+ else
+ ctsvc_set_person_noti();
+
+ ctsvc_set_contact_noti();
+ if (rel_changed > 0)
+ ctsvc_set_group_rel_noti();
+
+ ret = ctsvc_end_trans(true);
+ if (ret < CONTACTS_ERROR_NONE)
+ {
+ CTS_ERR("DB error : ctsvc_end_trans() Failed(%d)", ret);
+ return ret;
+ }
+ else
+ return CONTACTS_ERROR_NONE;
+}
+
void ctsvc_make_contact_display_name(ctsvc_contact_s *contact)
{
char *display = NULL;
ctsvc_name_s *name = NULL;
+ free(contact->display_name);
+ contact->display_name = NULL;
+
+ free(contact->reverse_display_name);
+ contact->reverse_display_name = NULL;
+
contact->display_name_language = CTSVC_SORT_OTHERS;
if ( contact->name->count > 0 && contact->name->records != NULL && contact->name->records->data != NULL )
}
else
ret = ctsvc_db_number_insert(record, contact_id, is_my_profile, NULL);
- if (CONTACTS_ERROR_DB == ret){
+ if (CONTACTS_ERROR_DB == ret) {
CTS_ERR("DB error : return (%d)", ret);
break;
}
#include "ctsvc_struct.h"
#include "ctsvc_sqlite.h"
-typedef enum
-{
- CTSVC_IMG_NORMAL, /**< . */
-} ctsvc_img_e;
-
int ctsvc_db_contact_update_changed_time(int contact_id);
-int ctsvc_contact_add_image_file(ctsvc_img_e image_type, int parent_id, int img_id,
+int ctsvc_contact_add_image_file(int parent_id, int img_id,
char *src_img, char *dest_name, int dest_size);
-int ctsvc_contact_update_image_file(int image_type, int parent_id, int img_id,
+int ctsvc_contact_update_image_file(int parent_id, int img_id,
char *src_img, char *dest_name, int dest_size);
void ctsvc_make_contact_display_name(ctsvc_contact_s *contact);
+int ctsvc_db_contact_delete(int contact_id);
int ctsvc_contact_delete_image_file_with_path(const unsigned char* image_path);
int ctsvc_get_data_info_name(cts_stmt stmt, contacts_list_h name_list);
"Invalid parameter : id(%d), This record is already inserted", image->id);
image_id = cts_db_get_next_id(CTS_TABLE_DATA);
- ret = ctsvc_contact_add_image_file(CTSVC_IMG_NORMAL, contact_id, image_id, image->path, image_path, sizeof(image_path));
+ 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);
if (image->is_changed) {
char image_path[CTS_SQL_MAX_LEN] = {0};
- ret = ctsvc_contact_update_image_file(CTSVC_IMG_NORMAL, contact_id, image->id, image->path, image_path, sizeof(image_path));
+ ret = ctsvc_contact_update_image_file(contact_id, image->id, image->path, image_path, sizeof(image_path));
RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_contact_update_image_file() Failed(%d)", ret);
if (*image_path) {
return strcmp(s1, s2);
}
-static inline void __ctsvc_update_my_profile_display_name(ctsvc_my_profile_s *my_profile)
-{
- char *temp_display_name = NULL;
- char display[CTSVC_MY_PROFILE_DISPLAY_NAME_MAX_LEN] = {0};
- GList *cur;
- int len=0;
-
- ctsvc_name_s *name = NULL;
- if ( my_profile->name->count > 0 && my_profile->name->records != NULL && my_profile->name->records->data != NULL )
- {
- name = (ctsvc_name_s *)my_profile->name->records->data;
- }
-
- if ( name && ( name->first || name->last) ) {
- if (name->first && name->last){
- snprintf(display, sizeof(display), "%s %s",name->first,name->last);
- temp_display_name = strdup(display);
- }
- else if (name->first)
- temp_display_name = strdup(name->first);
- else
- temp_display_name = strdup(name->last);
-
- if (0 != __ctsvc_safe_strcmp(my_profile->display_name, temp_display_name)) {
- // make display name
- if(name->first)
- len += snprintf(display + len, sizeof(display) - len, "%s", name->first);
-
- if(name->addition) {
- if (*display)
- len += snprintf(display + len, sizeof(display) - len, " ");
- len += snprintf(display + len, sizeof(display) - len, "%s", name->addition);
- }
-
- if(name->last) {
- if (*display)
- len += snprintf(display + len, sizeof(display) - len, " ");
- len += snprintf(display + len, sizeof(display) - len, "%s", name->last);
- }
-
- if(name->suffix) {
- if (*display)
- len += snprintf(display + len, sizeof(display) - len, " ");
- len += snprintf(display + len, sizeof(display) - len, "%s", name->suffix);
- }
- my_profile->display_name = strdup(display);
- }
- free(temp_display_name);
- }
- else {
- if (my_profile->company && my_profile->company->records) {
- for (cur=my_profile->company->records;cur;cur=cur->next) {
- ctsvc_company_s *company = (ctsvc_company_s *)cur->data;
- if (company && company->name) {
- if (__ctsvc_safe_strcmp(my_profile->display_name, company->name)) {
- my_profile->display_name = SAFE_STRDUP(company->name);
- break;
- }
- }
- }
- }
- else if (my_profile->nicknames && my_profile->nicknames->records) {
- for (cur=my_profile->nicknames->records;cur;cur=cur->next) {
- ctsvc_nickname_s *nickname = (ctsvc_nickname_s *)cur->data;
- if (nickname && nickname->nickname) {
- if (__ctsvc_safe_strcmp(my_profile->display_name, nickname->nickname)) {
- my_profile->display_name = SAFE_STRDUP(nickname->nickname);
- break;
- }
- }
- }
- }
- else if (my_profile->numbers && my_profile->numbers->records) {
- for (cur=my_profile->numbers->records;cur;cur=cur->next) {
- ctsvc_number_s *number = (ctsvc_number_s *)cur->data;
- if (number && number->number) {
- if (__ctsvc_safe_strcmp(my_profile->display_name, number->number)) {
- my_profile->display_name = SAFE_STRDUP(number->number);
- break;
- }
- }
- }
- }
- else if (my_profile->emails && my_profile->emails->records) {
- for (cur=my_profile->emails->records;cur;cur=cur->next) {
- ctsvc_email_s *email = (ctsvc_email_s*)cur->data;
- if (email && email->email_addr) {
- if (__ctsvc_safe_strcmp(my_profile->display_name, email->email_addr)) {
- my_profile->display_name = SAFE_STRDUP(email->email_addr);
- break;
- }
- }
- }
- }
- }
- return;
-}
-
static inline int __ctsvc_my_profile_update_data(ctsvc_my_profile_s *my_profile)
{
int ret;
ctsvc_contact_check_default_image((contacts_list_h)my_profile->images);
}
+static void __ctsvc_make_my_profile_display_name(ctsvc_my_profile_s *my_profile)
+{
+ char *display = NULL;
+ GList *cur;
+ int len, display_len;
+
+ ctsvc_name_s *name = NULL;
+
+ free(my_profile->display_name);
+ my_profile->display_name = NULL;
+
+ free(my_profile->reverse_display_name);
+ my_profile->reverse_display_name = NULL;
+
+ if (my_profile->name->count > 0 && my_profile->name->records != NULL && my_profile->name->records->data != NULL) {
+ name = (ctsvc_name_s *)my_profile->name->records->data;
+ }
+
+ if (name && (name->first || name->last)) {
+ // make 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;
+ 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);
+ }
+
+ my_profile->display_name = display;
+
+ // 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 (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->suffix) {
+ if (*display)
+ len += snprintf(display + len, display_len - len, " ");
+ len += snprintf(display + len, display_len - len, "%s", name->suffix);
+ }
+
+ my_profile->reverse_display_name = display;
+ }
+ else {
+ if (my_profile->company && my_profile->company->records) {
+ for (cur=my_profile->company->records;cur;cur=cur->next) {
+ ctsvc_company_s *company = (ctsvc_company_s *)cur->data;
+ if (company && company->name) {
+ my_profile->display_name_changed = true;
+ my_profile->display_name = SAFE_STRDUP(company->name);
+ break;
+ }
+ }
+ }
+
+ if (!my_profile->display_name_changed && my_profile->nicknames && my_profile->nicknames->records) {
+ for (cur=my_profile->nicknames->records;cur;cur=cur->next) {
+ ctsvc_nickname_s *nickname = (ctsvc_nickname_s *)cur->data;
+ if (nickname && nickname->nickname) {
+ my_profile->display_name_changed = true;
+ my_profile->display_name = SAFE_STRDUP(nickname->nickname);
+ break;
+ }
+ }
+ }
+
+ if (!my_profile->display_name_changed && my_profile->numbers && my_profile->numbers->records) {
+ for (cur=my_profile->numbers->records;cur;cur=cur->next) {
+ ctsvc_number_s *number = (ctsvc_number_s *)cur->data;
+ if (number && number->number) {
+ my_profile->display_name_changed = true;
+ my_profile->display_name = SAFE_STRDUP(number->number);
+ break;
+ }
+ }
+ }
+
+ if (!my_profile->display_name_changed && my_profile->emails && my_profile->emails->records) {
+ for (cur=my_profile->emails->records;cur;cur=cur->next) {
+ ctsvc_email_s *email = (ctsvc_email_s *)cur->data;
+ if (email && email->email_addr) {
+ my_profile->display_name_changed = true;
+ my_profile->display_name = SAFE_STRDUP(email->email_addr);
+ break;
+ }
+ }
+ }
+
+ if (my_profile->display_name_changed) {
+ my_profile->reverse_display_name = SAFE_STRDUP(my_profile->display_name);
+ }
+ }
+ return;
+}
+
+
static int __ctsvc_db_my_profile_update_record( contacts_record_h record )
{
int ret, len;
return ret;
}
- __ctsvc_update_my_profile_display_name(my_profile);
+ __ctsvc_make_my_profile_display_name(my_profile);
__ctsvc_my_profile_check_default_data(my_profile);
//update data
len = snprintf(query, sizeof(query),
"UPDATE "CTS_TABLE_MY_PROFILES" SET changed_ver=%d, changed_time=%d, "
- "display_name=?, uid=?, image_thumbnail_path=?",
+ "display_name=?, reverse_display_name=?, uid=?, image_thumbnail_path=?",
ctsvc_get_next_ver(), (int)time(NULL));
snprintf(query+len, sizeof(query)-len, " WHERE my_profile_id=%d", my_profile->id);
}
cts_stmt_bind_text(stmt, 1, my_profile->display_name);
+ cts_stmt_bind_text(stmt, 2, my_profile->reverse_display_name);
if (my_profile->uid)
- cts_stmt_bind_text(stmt, 2, my_profile->uid);
+ cts_stmt_bind_text(stmt, 3, my_profile->uid);
if (my_profile->image_thumbnail_path)
- cts_stmt_bind_text(stmt, 3, my_profile->image_thumbnail_path);
+ cts_stmt_bind_text(stmt, 4, my_profile->image_thumbnail_path);
ret = cts_stmt_step(stmt);
if (CONTACTS_ERROR_NONE != ret) {
return CONTACTS_ERROR_NONE;
}
-void __ctsvc_make_my_profile_display_name(ctsvc_my_profile_s *my_profile)
-{
- char display[CTS_SQL_MAX_LEN]={0};
- GList *cur;
- int len;
-
- ctsvc_name_s *name = NULL;
-
- if ( my_profile->name->count > 0 && my_profile->name->records != NULL && my_profile->name->records->data != NULL ) {
- name = (ctsvc_name_s *)my_profile->name->records->data;
- }
-
- if ( name && ( name->first || name->last) ) {
-
- // make display name
- len=0;
- if(name->first)
- len += snprintf(display + len, sizeof(display) - len, "%s", name->first);
-
- if(name->addition) {
- if (*display)
- len += snprintf(display + len, sizeof(display) - len, " ");
- len += snprintf(display + len, sizeof(display) - len, "%s", name->addition);
- }
-
- if(name->last) {
- if (*display)
- len += snprintf(display + len, sizeof(display) - len, " ");
- len += snprintf(display + len, sizeof(display) - len, "%s", name->last);
- }
-
- if(name->suffix) {
- if (*display)
- len += snprintf(display + len, sizeof(display) - len, " ");
- len += snprintf(display + len, sizeof(display) - len, "%s", name->suffix);
- }
-
- my_profile->display_name = strdup(display);
- }
- else {
- if (my_profile->company && my_profile->company->records) {
- for (cur=my_profile->company->records;cur;cur=cur->next) {
- ctsvc_company_s *company = (ctsvc_company_s *)cur->data;
- if (company && company->name) {
- my_profile->display_name = SAFE_STRDUP(company->name);
- break;
- }
- }
- }
-
- if (NULL == my_profile->display_name && my_profile->nicknames->records) {
- for (cur=my_profile->nicknames->records;cur;cur=cur->next) {
- ctsvc_nickname_s *nickname = (ctsvc_nickname_s *)cur->data;
- if (nickname && nickname->nickname) {
- my_profile->display_name = SAFE_STRDUP(nickname->nickname);
- break;
- }
- }
- }
-
- if (NULL == my_profile->display_name && my_profile->numbers->records) {
- for (cur=my_profile->numbers->records;cur;cur=cur->next) {
- ctsvc_number_s *number = (ctsvc_number_s *)cur->data;
- if (number && number->number) {
- my_profile->display_name = SAFE_STRDUP(number->number);
- break;
- }
- }
- }
-
- if (NULL == my_profile->display_name && my_profile->emails->records) {
- for (cur=my_profile->emails->records;cur;cur=cur->next) {
- ctsvc_email_s *email = (ctsvc_email_s *)cur->data;
- if (email && email->email_addr) {
- my_profile->display_name = SAFE_STRDUP(email->email_addr);
- break;
- }
- }
- }
- }
- return;
-}
-
static int __ctsvc_db_my_profile_insert_record( contacts_record_h record, int *id)
{
CTS_FN_CALL;
snprintf(query, sizeof(query),
"INSERT INTO "CTS_TABLE_MY_PROFILES"(my_profile_id, addressbook_id, "
"created_ver, changed_ver, changed_time, "
- "display_name, uid, image_thumbnail_path) "
- "VALUES(%d, %d, %d, %d, %d, ?, ?, ?)",
+ "display_name, reverse_display_name, uid, image_thumbnail_path) "
+ "VALUES(%d, %d, %d, %d, %d, ?, ?, ?, ?)",
my_profile->id, my_profile->addressbook_id, version, version, (int)time(NULL));
stmt = cts_query_prepare(query);
if (my_profile->display_name)
cts_stmt_bind_text(stmt, 1, my_profile->display_name);
+ if (my_profile->reverse_display_name)
+ cts_stmt_bind_text(stmt, 2, my_profile->reverse_display_name);
if (my_profile->uid)
- cts_stmt_bind_text(stmt, 2, my_profile->uid);
+ cts_stmt_bind_text(stmt, 3, my_profile->uid);
if (my_profile->image_thumbnail_path)
- cts_stmt_bind_text(stmt, 3, my_profile->image_thumbnail_path);
+ cts_stmt_bind_text(stmt, 4, my_profile->image_thumbnail_path);
ret = cts_stmt_step(stmt);
if (CONTACTS_ERROR_NONE != ret) {
int ret, len = 0;
cts_stmt stmt = NULL;
ctsvc_name_s *name = (ctsvc_name_s*)record;
- char *tmp_first, *tmp_last;
char query[CTS_SQL_MAX_LEN]={0};
char *normal_name[CTSVC_NN_MAX]={NULL}; //insert name search info
char *temp_normal_first = NULL;
stmt = cts_query_prepare(query);
RETVM_IF(NULL == stmt, CONTACTS_ERROR_DB, "DB error : cts_query_prepare() Failed");
- tmp_first = name->first;
- tmp_last = name->last;
-
ret = __ctsvc_normalize_name(name, normal_name);
if (ret < CONTACTS_ERROR_NONE) {
CTS_ERR("__ctsvc_normalize_name() Failed(%d)", ret);
case CTSVC_LANG_ENGLISH:
default:
if (normal_name[CTSVC_NN_FIRST] && normal_name[CTSVC_NN_FIRST][0])
- temp_normal_first = normal_name[CTSVC_NN_FIRST];
- else
- name->first = NULL;
+ temp_normal_first = SAFE_STRDUP(normal_name[CTSVC_NN_FIRST]);
if (normal_name[CTSVC_NN_LAST] && normal_name[CTSVC_NN_LAST][0])
- temp_normal_last = normal_name[CTSVC_NN_LAST];
- else
- name->last = NULL;
+ temp_normal_last = SAFE_STRDUP(normal_name[CTSVC_NN_LAST]);
+
break;
}
else
name->language_type = ret;
- name->first = tmp_first;
- name->last = tmp_last;
__ctsvc_make_name_lookup(CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST,
temp_normal_first, temp_normal_last, &name->lookup);
__ctsvc_make_name_lookup(CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST,
temp_normal_first, temp_normal_last, &name->reverse_lookup);
+ free(temp_normal_first);
+ free(temp_normal_last);
free(normal_name[CTSVC_NN_FIRST]);
free(normal_name[CTSVC_NN_LAST]);
return CONTACTS_ERROR_NONE;
}
-static inline int __ctsvc_db_person_set_favorite(int person_id, bool set)
-{
- int ret;
- double prio = 0.0;
- cts_stmt stmt = NULL;
- char query[CTS_SQL_MIN_LEN] = {0};
-
- if (set) {
- snprintf(query, sizeof(query),
- "SELECT MAX(favorite_prio) FROM "CTS_TABLE_FAVORITES);
-
- stmt = cts_query_prepare(query);
- RETVM_IF(NULL == stmt, CONTACTS_ERROR_DB, "cts_query_prepare() Failed");
-
- ret = cts_stmt_step(stmt);
- if (1 /*CTS_TRUE*/ == ret) {
- prio = ctsvc_stmt_get_dbl(stmt, 0);
- }
- else if (CONTACTS_ERROR_NONE != ret) {
- CTS_ERR("cts_stmt_step() Failed(%d)", ret);
- cts_stmt_finalize(stmt);
- return ret;
- }
- cts_stmt_finalize(stmt);
-
- prio = prio + 1.0;
- snprintf(query, sizeof(query),
- "INSERT OR REPLACE INTO "CTS_TABLE_FAVORITES" values(%d, %f)", person_id, prio);
- }
- else {
- snprintf(query, sizeof(query),
- "DELETE FROM "CTS_TABLE_FAVORITES" WHERE person_id = %d", person_id);
- }
-
- ret = ctsvc_query_exec(query);
- if (CONTACTS_ERROR_NONE != ret) {
- CTS_ERR("cts_query_exec() Failed(%d)", ret);
- return ret;
- }
-
- ret = cts_db_change();
-
- snprintf(query, sizeof(query),
- "UPDATE "CTS_TABLE_CONTACTS" SET is_favorite = %d "
- "WHERE person_id=%d AND deleted = 0", set?1:0, person_id);
- ret = ctsvc_query_exec(query);
- if (CONTACTS_ERROR_NONE != ret) {
- CTS_ERR("cts_query_exec() Failed(%d)", ret);
- return ret;
- }
-
- return CONTACTS_ERROR_NONE;
-}
-
static int __ctsvc_db_person_update_record( contacts_record_h record )
{
int ret, i, len;
int index_favorite = CTSVC_PROPERTY_PERSON_IS_FAVORITE & 0x000000FF;
if (person->base.properties_flags &&
CTSVC_PROPERTY_FLAG_DIRTY == person->base.properties_flags[index_favorite]) {
- ret = __ctsvc_db_person_set_favorite(person->person_id, person->is_favorite);
+ ret = ctsvc_db_person_set_favorite(person->person_id, person->is_favorite, true);
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("cts_stmt_step() Failed(%d)", ret);
ctsvc_end_trans(false);
return ret;
}
person->base.properties_flags[index_favorite] = 0;
+ ctsvc_set_contact_noti();
}
do {
int ret, rel_changed;
int person_id;
char query[CTS_SQL_MAX_LEN] = {0};
+ int version;
ret = ctsvc_begin_trans();
RETVM_IF(ret, ret, "DB error : ctsvc_begin_trans() Failed(%d)", ret);
return ret;
}
+ version = ctsvc_get_next_ver();
snprintf(query, sizeof(query),
"UPDATE "CTS_TABLE_GROUPS" SET member_changed_ver=%d "
"WHERE group_id IN (SELECT distinct group_id "
"FROM "CTS_TABLE_CONTACTS" C, "CTS_TABLE_GROUP_RELATIONS" R "
"ON C.contact_id=R.contact_id AND R.deleted = 0 AND C.deleted = 0 "
"WHERE person_id = %d)",
- ctsvc_get_next_ver(), id);
+ version, id);
ret = ctsvc_query_exec(query);
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("ctsvc_query_exec() Failed(%d)", ret);
rel_changed = cts_db_change();
// images are deleted by db trigger callback function in ctsvc_db_contact_delete_callback
- snprintf(query, sizeof(query), "DELETE FROM "CTS_TABLE_CONTACTS" WHERE person_id = %d", id);
+ snprintf(query, sizeof(query),
+ "UPDATE "CTS_TABLE_CONTACTS" SET deleted = 1, person_id = 0, changed_ver=%d WHERE person_id = %d",
+ version, id);
ret = ctsvc_query_exec(query);
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("ctsvc_query_exec() Failed(%d)", ret);
return src+pos;
}
+int ctsvc_db_person_set_favorite(int person_id, bool set, bool propagate)
+{
+ int ret;
+ double prio = 0.0;
+ cts_stmt stmt = NULL;
+ char query[CTS_SQL_MIN_LEN] = {0};
+
+ if (set) {
+ snprintf(query, sizeof(query),
+ "SELECT MAX(favorite_prio) FROM "CTS_TABLE_FAVORITES);
+
+ stmt = cts_query_prepare(query);
+ RETVM_IF(NULL == stmt, CONTACTS_ERROR_DB, "cts_query_prepare() Failed");
+
+ ret = cts_stmt_step(stmt);
+ if (1 /*CTS_TRUE*/ == ret) {
+ prio = ctsvc_stmt_get_dbl(stmt, 0);
+ }
+ else if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("cts_stmt_step() Failed(%d)", ret);
+ cts_stmt_finalize(stmt);
+ return ret;
+ }
+ cts_stmt_finalize(stmt);
+
+ prio = prio + 1.0;
+ snprintf(query, sizeof(query),
+ "INSERT OR REPLACE INTO "CTS_TABLE_FAVORITES" values(%d, %f)", person_id, prio);
+ }
+ else {
+ snprintf(query, sizeof(query),
+ "DELETE FROM "CTS_TABLE_FAVORITES" WHERE person_id = %d", person_id);
+ }
+
+ ret = ctsvc_query_exec(query);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("cts_query_exec() Failed(%d)", ret);
+ return ret;
+ }
+
+ if (propagate) {
+ snprintf(query, sizeof(query),
+ "UPDATE "CTS_TABLE_CONTACTS" SET is_favorite = %d "
+ "WHERE person_id=%d AND deleted = 0", set?1:0, person_id);
+ ret = ctsvc_query_exec(query);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("cts_query_exec() Failed(%d)", ret);
+ return ret;
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
int ctsvc_db_insert_person(contacts_record_h record)
{
int ret, index;
if (1 == cts_stmt_step(stmt))
status = SAFE_STRDUP(ctsvc_stmt_get_text(stmt, 0));
-
- sqlite3_finalize(stmt);
+ cts_stmt_finalize(stmt);
version = ctsvc_get_next_ver();
snprintf(query, sizeof(query),
return ret;
}
+ // set favorite
+ if (contact->is_favorite) {
+ ret = ctsvc_db_person_set_favorite(index, contact->is_favorite, false);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("cts_stmt_step() Failed(%d)", ret);
+ return ret;
+ }
+ }
+
free(status);
ctsvc_set_person_noti();
#ifdef _CONTACTS_IPC_SERVER
return contact_id;
}
-
int ctsvc_db_update_person(contacts_record_h record)
{
int ret, i=1, len=0;
ctsvc_contact_s *contact = (ctsvc_contact_s*)record;
bool has_phonenumber=false, has_email=false;
int thumbnail_contact_id = 0;
+ int person_id = 0;
ret = ctsvc_begin_trans();
RETVM_IF(ret, ret, "ctsvc_begin_trans() Failed(%d)", ret);
ctsvc_end_trans(false);
return ret;
}
-
cts_stmt_finalize(stmt);
+
+ // update favorite
+ snprintf(query, sizeof(query),
+ "SELECT person_id FROM "CTS_TABLE_FAVORITES" WHERE person_id =%d ", contact->person_id);
+ ret = ctsvc_query_get_first_int_result(query, &person_id);
+ if (CONTACTS_ERROR_NO_DATA == ret && contact->is_favorite) {
+ ret = ctsvc_db_person_set_favorite(contact->person_id, true, false);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_db_person_set_favorite() Failed(%d)", ret);
+ ctsvc_end_trans(false);
+ return ret;
+ }
+ }
+ else if (CONTACTS_ERROR_NONE == ret && !contact->is_favorite) {
+ snprintf(query, sizeof(query),
+ "SELECT person_id FROM "CTS_TABLE_CONTACTS" WHERE person_id =%d AND is_favorite = 1", contact->person_id);
+ ret = ctsvc_query_get_first_int_result(query, &person_id);
+ if (CONTACTS_ERROR_NO_DATA == ret) {
+ ret = ctsvc_db_person_set_favorite(contact->person_id, false, false);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_db_person_set_favorite() Failed(%d)", ret);
+ ctsvc_end_trans(false);
+ return ret;
+ }
+ }
+ else if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_query_get_first_int_result() Failed(%d)", ret);
+ ctsvc_end_trans(false);
+ return ret;
+ }
+ }
+ else if (ret < CONTACTS_ERROR_NONE && CONTACTS_ERROR_NO_DATA != ret) {
+ CTS_ERR("ctsvc_query_get_first_int_result() Failed(%d)", ret);
+ ctsvc_end_trans(false);
+ return ret;
+ }
+
ctsvc_set_person_noti();
#ifdef _CONTACTS_IPC_SERVER
int ctsvc_db_person_create_record_from_stmt_with_query(cts_stmt stmt, contacts_query_h query, contacts_record_h *record);
int ctsvc_db_person_create_record_from_stmt_with_projection(cts_stmt stmt, unsigned int *projection, int projection_count, contacts_record_h *record);
void ctsvc_db_normalize_str_callback(sqlite3_context * context, int argc, sqlite3_value ** argv);
+int ctsvc_db_person_set_favorite(int person_id, bool set, bool propagate);
#endif // __CTSVC_DB_PLUGIN_PERSON_HELPER_H__
RETV_IF(NULL == out_record, CONTACTS_ERROR_INVALID_PARAMETER);
*out_record = NULL;
-// if (0 == id)
-// return ctsvc_get_myprofile(contact);
len = snprintf(query, sizeof(query),
"SELECT contact_id, addressbook_id, person_id, changed_time, %s, "
if (0 == img_id) {
img_id = cts_db_get_next_id(CTS_TABLE_DATA);
- ret = ctsvc_contact_add_image_file(CTSVC_IMG_NORMAL, contact->contact_id, img_id, contact->image_thumbnail_path,
+ ret = ctsvc_contact_add_image_file(contact->contact_id, img_id, contact->image_thumbnail_path,
image, sizeof(image));
}
else {
- ret = ctsvc_contact_update_image_file(CTSVC_IMG_NORMAL, contact->contact_id, img_id,
+ ret = ctsvc_contact_update_image_file(contact->contact_id, img_id,
contact->image_thumbnail_path, image, sizeof(image));
}
if (*image) {
static int __ctsvc_db_simple_contact_delete_record( int id )
{
- int ret;
- int addressbook_id;
- char query[CTS_SQL_MAX_LEN] = {0};
-
- ret = ctsvc_begin_trans();
- RETVM_IF(ret, ret, "ctsvc_begin_trans() Failed(%d)", ret);
-
- snprintf(query, sizeof(query),
- "SELECT addressbook_id FROM "CTS_TABLE_CONTACTS" WHERE contact_id = %d AND deleted = 0", id);
- ret = ctsvc_query_get_first_int_result(query, &addressbook_id);
- if (CONTACTS_ERROR_NONE != ret) {
- CTS_ERR("DB error : cts_stmt_step() Failed(%d)", ret);
- ctsvc_end_trans(false);
- return ret;
- }
-
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE contact_id = %d AND deleted = 0",
- CTS_TABLE_CONTACTS, id);
-
- ret = ctsvc_query_exec(query);
- if (CONTACTS_ERROR_NONE != ret) {
- CTS_ERR("cts_query_exec() Failed(%d)", ret);
- ctsvc_end_trans(false);
- return ret;
- }
-
- ctsvc_set_contact_noti();
- ret = ctsvc_end_trans(true);
- if (ret < CONTACTS_ERROR_NONE)
- return ret;
- else
- return CONTACTS_ERROR_NONE;
+ return ctsvc_db_contact_delete(id);
}
static int __ctsvc_db_simple_contact_get_all_records( int offset, int limit,
int image_id;
image[0] = '\0';
image_id = __ctsvc_db_simple_contact_get_default_image_id(contact->contact_id);
- ret = ctsvc_contact_add_image_file(CTSVC_IMG_NORMAL, contact->contact_id, image_id, contact->image_thumbnail_path,
+ ret = ctsvc_contact_add_image_file(contact->contact_id, image_id, contact->image_thumbnail_path,
image, sizeof(image));
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("ctsvc_contact_add_image_file(NORMAL) Failed(%d)", ret);
contact->person_id = ret;
snprintf(query, sizeof(query),
- "INSERT INTO "CTS_TABLE_CONTACTS"(contact_id, person_id, addressbook_id, is_restricted, "
+ "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, ?, ?, ?, ?)",
- contact->contact_id, contact->person_id, contact->addressbook_id, contact->is_restricted,
+ contact->contact_id, contact->person_id, contact->addressbook_id, contact->is_favorite,
version, version, (int)time(NULL));
stmt = cts_query_prepare(query);
#include "ctsvc_record.h"
#include "ctsvc_utils.h"
#include "ctsvc_normalize.h"
-#include "ctsvc_restriction.h"
#include "ctsvc_db_init.h"
#include "ctsvc_view.h"
#include "ctsvc_inotify.h"
if (0 <= addressbook_id) {
snprintf(query, sizeof(query),
- "SELECT %d, contact_id, changed_ver, created_ver, addressbook_id, image_changed_ver FROM %s "
- "WHERE changed_ver > %d AND addressbook_id = %d AND deleted = 0 "
+ "SELECT %d, contact_id, changed_ver, created_ver, addressbook_id, image_changed_ver "
+ "FROM "CTS_TABLE_CONTACTS" "
+ "WHERE changed_ver > %d AND addressbook_id = %d AND deleted = 0 "
"UNION "
- "SELECT %d, contact_id, deleted_ver, -1, addressbook_id, 0 FROM %s "
- "WHERE deleted_ver > %d AND created_ver <= %d AND addressbook_id = %d "
+ "SELECT %d, contact_id, deleted_ver, -1, addressbook_id, 0 "
+ "FROM "CTS_TABLE_DELETEDS" "
+ "WHERE deleted_ver > %d AND created_ver <= %d AND addressbook_id = %d "
"UNION "
- "SELECT %d, contact_id, changed_ver, -1, addressbook_id, 0 FROM %s "
- "WHERE changed_ver > %d AND addressbook_id = %d AND deleted = 1",
- CONTACTS_CHANGE_UPDATED, CTS_TABLE_CONTACTS, version, addressbook_id,
- CONTACTS_CHANGE_DELETED, CTS_TABLE_DELETEDS, version, version, addressbook_id,
- CONTACTS_CHANGE_DELETED, CTS_TABLE_CONTACTS, version, addressbook_id);
+ "SELECT %d, contact_id, changed_ver, -1, addressbook_id, 0 "
+ "FROM "CTS_TABLE_CONTACTS" "
+ "WHERE changed_ver > %d AND created_ver <= %d AND addressbook_id = %d AND deleted = 1 "
+ "AND addressbook_id = (SELECT addressbook_id FROM "CTS_TABLE_ADDRESSBOOKS" WHERE addressbook_id = %d)",
+ CONTACTS_CHANGE_UPDATED, version, addressbook_id,
+ CONTACTS_CHANGE_DELETED, version, version, addressbook_id,
+ CONTACTS_CHANGE_DELETED, version, version, addressbook_id, addressbook_id);
}
else {
snprintf(query, sizeof(query),
- "SELECT %d, contact_id, changed_ver, created_ver, addressbook_id, image_changed_ver FROM %s "
- "WHERE changed_ver > %d AND deleted = 0 "
+ "SELECT %d, contact_id, changed_ver, created_ver, addressbook_id, image_changed_ver "
+ "FROM "CTS_TABLE_CONTACTS" "
+ "WHERE changed_ver > %d AND deleted = 0 "
"UNION "
- "SELECT %d, contact_id, deleted_ver, -1, addressbook_id, 0 FROM %s "
- "WHERE deleted_ver > %d AND created_ver <= %d "
+ "SELECT %d, contact_id, deleted_ver, -1, addressbook_id, 0 "
+ "FROM "CTS_TABLE_DELETEDS" "
+ "WHERE deleted_ver > %d AND created_ver <= %d "
"UNION "
- "SELECT %d, contact_id, changed_ver, -1, addressbook_id, 0 FROM %s "
- "WHERE changed_ver > %d AND deleted = 1",
- CONTACTS_CHANGE_UPDATED, CTS_TABLE_CONTACTS, version,
- CONTACTS_CHANGE_DELETED, CTS_TABLE_DELETEDS, version, version,
- CONTACTS_CHANGE_DELETED, CTS_TABLE_CONTACTS, version);
+ "SELECT %d, contact_id, changed_ver, -1, "CTS_TABLE_CONTACTS".addressbook_id, 0 "
+ "FROM "CTS_TABLE_CONTACTS", "CTS_TABLE_ADDRESSBOOKS" "
+ "WHERE changed_ver > %d AND created_ver <= %d AND deleted = 1 "
+ "AND "CTS_TABLE_CONTACTS".addressbook_id = "CTS_TABLE_ADDRESSBOOKS".addressbook_id",
+ CONTACTS_CHANGE_UPDATED, version,
+ CONTACTS_CHANGE_DELETED, version, version,
+ CONTACTS_CHANGE_DELETED, version ,version);
}
stmt = cts_query_prepare(query);
int link_count;
int id = 0;
int account_ids[DISPLAY_ACCOUNT_MAX] = {0};
- char addressbook_ids[100] = {0};
+ char *addressbook_ids = NULL;
+ int addressbooks_len = 100;
int name_contact_id = 0;
int person_name_contact_id = 0;
int display_name_source_type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_INVALID;
char *contact_image_thumbnail_path = NULL;
char *contact_vibration = NULL;
bool is_favorite = false;
+ char addr[10] = {0};
+ int addr_len = 0;
contact_id = ctsvc_stmt_get_int(stmt, i++);
addressbook_id = ctsvc_stmt_get_int(stmt, i++);
name_contact_id = person_name_contact_id;
}
- len += snprintf(addressbook_ids + len, sizeof(addressbook_ids)-len, "%d ", addressbook_id );
+ addr_len = snprintf(addr, sizeof(addr), "%d ", addressbook_id);
+ if (NULL == addressbook_ids)
+ addressbook_ids = calloc(addressbooks_len, sizeof(char));
+ else if (addressbooks_len <= strlen(addressbook_ids)+addr_len) {
+ addressbooks_len *= 2;
+ addressbook_ids = realloc(addressbook_ids, addressbooks_len);
+ }
+
+ len += snprintf(addressbook_ids + len, addressbooks_len -len, "%d ", addressbook_id );
- if (contact_image_thumbnail_path && *contact_image_thumbnail_path) {
+ if (!image_thumbnail_path && contact_image_thumbnail_path && *contact_image_thumbnail_path) {
temp = __cts_get_image_filename(contact_image_thumbnail_path);
image_thumbnail_path = SAFE_STRDUP(temp);
// update data table : is_primary_default
stmt = cts_query_prepare(query);
if (NULL == stmt) {
ERR("DB error : cts_query_prepare() Failed");
+ free(addressbook_ids);
free(image_thumbnail_path);
free(ringtone_path);
free(vibration);
return CONTACTS_ERROR_DB;
}
- cts_stmt_bind_text(stmt, 1, addressbook_ids);
-
- if(ringtone_path)
+ if (addressbook_ids)
+ cts_stmt_bind_text(stmt, 1, addressbook_ids);
+ if (ringtone_path)
cts_stmt_bind_text(stmt, 2, ringtone_path);
- if(vibration)
+ if (vibration)
cts_stmt_bind_text(stmt, 3, vibration);
- if(status)
+ if (status)
cts_stmt_bind_text(stmt, 4, status);
- if(image_thumbnail_path)
+ if (image_thumbnail_path)
cts_stmt_bind_text(stmt, 5, image_thumbnail_path);
ret = cts_stmt_step(stmt);
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("cts_stmt_step() Failed(%d)", ret);
cts_stmt_finalize(stmt);
+ free(addressbook_ids);
free(image_thumbnail_path);
free(ringtone_path);
free(vibration);
cts_stmt_finalize(stmt);
+ free(addressbook_ids);
free(image_thumbnail_path);
free(ringtone_path);
free(vibration);
+++ /dev/null
-/*
- * Contacts Service
- *
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Youngjae Shin <yj99.shin@samsung.com>
- *
- * 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.
- *
- */
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "contacts.h"
-#include "ctsvc_internal.h"
-#include "ctsvc_sqlite.h"
-#include "ctsvc_schema.h"
-
-static const char *CTS_RESTRICTION_CHECK_FILE="/opt/usr/data/contacts-svc/.CONTACTS_SVC_RESTRICTION_CHECK";
-static TLS int ctsvc_restriction_permit;
-
-int ctsvc_restriction_init(void)
-{
- if (!ctsvc_restriction_permit) {
- int fd = open(CTS_RESTRICTION_CHECK_FILE, O_RDONLY);
- if (0 <= fd) {
- close(fd);
- ctsvc_restriction_permit = TRUE;
- } else {
- CTS_ERR("Restriction Mode");
- }
- }
- if (!ctsvc_restriction_permit) {
- int ret;
- const char *query;
- query = "CREATE TEMP VIEW "CTS_TABLE_RESTRICTED_DATA_VIEW" AS SELECT * FROM "CTS_TABLE_DATA" WHERE is_restricted != 1 AND is_my_profile = 0";
-
- ret = ctsvc_query_exec(query);
- RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "cts_query_exec() Failed(%d)", ret);
- }
- return CONTACTS_ERROR_NONE;
-}
-
-void ctsvc_restriction_deinit(void)
-{
- ctsvc_restriction_permit = FALSE;
-}
-
-int ctsvc_restriction_get_permit(void)
-{
- return ctsvc_restriction_permit;
-}
-#if 0
-/**
- * This function make restricted contact.
- * If process does not have permission for restriction, this function will be failed.
- *
- * @param[in] contact The contacts service struct
- * @return #CTS_SUCCESS on success, Negative value(#cts_error) on error
- */
-API int contacts_svc_struct_set_restriction(CTSstruct *contact)
-{
- contact_t *record = (contact_t *)contact;
-
- RETV_IF(NULL == contact, CTS_ERR_ARG_NULL);
- RETV_IF(FALSE == ctsvc_restriction_permit, CTS_ERR_ENV_INVALID);
-
- record->is_restricted = TRUE;
-
- return CONTACTS_ERROR_NONE;
-}
-#endif
+++ /dev/null
-/*
- * Contacts Service
- *
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Youngjae Shin <yj99.shin@samsung.com>
- *
- * 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_RESTRICTION_H__
-#define __TIZEN_SOCIAL_CTSVC_RESTRICTION_H__
-
-int ctsvc_restriction_init(void);
-void ctsvc_restriction_deinit(void);
-
-int ctsvc_restriction_get_permit(void);
-
-#endif //__TIZEN_SOCIAL_CTSVC_RESTRICTION_H__
-
#define CTS_TABLE_ACTIVITIES "activities"
#define CTS_TABLE_ACTIVITY_PHOTOS "activity_photos"
-#define CTS_TABLE_RESTRICTED_DATA_VIEW "restricted_data"
-
// DB views /////////////////////////////////////////////////////////////////////
#define CTSVC_DB_VIEW_PERSON "view_person"
#define CTSVC_DB_VIEW_CONTACT "view_contact"
return CONTACTS_ERROR_NONE;
}
-API int contacts_connect_with_flags(unsigned int flags)
-{
- CTS_FN_CALL;
- int ret = CONTACTS_ERROR_NONE;
-
- ret = contacts_connect2();
- if (ret == CONTACTS_ERROR_NONE)
- return ret;
-
- if (flags & CONTACTS_CONNECT_FLAG_RETRY) {
- int i;
- int waiting_time = 500;
- for (i=0;i<7;i++) {
- usleep(waiting_time * 1000);
- DBG("retry cnt=%d, ret=%x, %d",(i+1), ret, waiting_time);
- ret = contacts_connect2();
- if (ret == CONTACTS_ERROR_NONE)
- break;
- waiting_time *= 2;
- }
- }
-
- return ret;
-}
-
API int contacts_disconnect2()
{
if (1 == thread_connection)
return CONTACTS_ERROR_NONE;
}
+#ifdef _CONTACTS_NATIVE
+API int contacts_connect_with_flags(unsigned int flags)
+{
+ CTS_FN_CALL;
+ int ret = CONTACTS_ERROR_NONE;
+
+ ret = contacts_connect2();
+ if (ret == CONTACTS_ERROR_NONE)
+ return ret;
+
+ if (flags & CONTACTS_CONNECT_FLAG_RETRY) {
+ int i;
+ int waiting_time = 500;
+ for (i=0;i<9;i++) {
+ usleep(waiting_time * 1000);
+ DBG("retry cnt=%d, ret=%x, %d",(i+1), ret, waiting_time);
+ ret = contacts_connect2();
+ if (ret == CONTACTS_ERROR_NONE)
+ break;
+ if (6 < i)
+ waiting_time += 30000;
+ else
+ waiting_time *= 2;
+ }
+ }
+ return ret;
+}
+
API int contacts_connect_on_thread()
{
int ret;
return CONTACTS_ERROR_NONE;
}
+#endif
+
CTS_ERR("DB error : sqlite3_prepare_v2() Failed(%d, %s)", ret, sqlite3_errmsg(ctsvc_db));
if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
- usleep(50*1000); // 50 ms
gettimeofday(&now, NULL);
timersub(&now, &from, &diff);
retry = (diff.tv_sec < 1)? true:false; // retry it during 1 second
- }
+ if (retry)
+ usleep(50*1000); // 50 ms
+ } else
+ retry = false;
}while(retry);
return stmt;
CTS_ERR("DB error : sqlite3_step() Failed(%d, %s)", ret, sqlite3_errmsg(ctsvc_db));
if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
- usleep(50*1000); // 50 ms
gettimeofday(&now, NULL);
timersub(&now, &from, &diff);
retry = (diff.tv_sec < 1)? true:false; // retry it during 1 second
+ if (retry)
+ usleep(50*1000); // 50 ms
}
+ else
+ retry = false;
}while(retry);
switch (ret) {
return "display_name_language, reverse_sortkey";
}
-// This function is for MY profile and group image.
-char* ctsvc_get_image(const char *dir, int index, char *dest, int dest_size)
+static char* __ctsvc_get_image(const char *dir, int index, char *dest, int dest_size)
{
DIR *dp;
char *ret_val;
return CONTACTS_ERROR_NONE;
}
+// This function is for group image.
int ctsvc_change_image(const char *dir, int index, const char *path, char *image, int image_len)
{
int ret;
char dest[CTSVC_IMG_FULL_PATH_SIZE_MAX] = {0};
- if (ctsvc_get_image(dir, index, dest, sizeof(dest))) {
+ if (__ctsvc_get_image(dir, index, dest, sizeof(dest))) {
if (path && 0 == strcmp(dest, path))
return CONTACTS_ERROR_NONE;
ret = unlink(dest);
int ctsvc_get_current_version( int* out_current_version );\r
int ctsvc_get_transaction_ver(void);\r
\r
-char* ctsvc_get_image(const char *dir, int index, char *dest, int dest_size);\r
int ctsvc_change_image(const char *dir, int index, const char *path, char *image, int image_len);\r
int ctsvc_copy_image(const char *src, const char *dest);\r
\r
Name: contacts-service
Summary: Contacts Service
-Version: 0.9.45.3
+Version: 0.9.52.1
Release: 1
Group: TO_BE/FILLED_IN
License: Apache-2.0
chmod 660 /opt/usr/data/contacts-svc/.CONTACTS_SVC_*
vconftool set -t int file/private/contacts-service/default_lang 100
-chown :6016 /opt/usr/data/contacts-svc/.CONTACTS_SVC_RESTRICTION_CHECK
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
%postun -p /sbin/ldconfig
addressbook_id INTEGER NOT NULL DEFAULT 0,
has_phonenumber INTEGER,
has_email INTEGER,
- is_restricted INTEGER DEFAULT 0,
is_favorite INTEGER DEFAULT 0,
deleted INTEGER DEFAULT 0,
display_name TEXT,
CREATE INDEX contacts_idx3 ON contacts(display_name_language, sortkey);
CREATE INDEX contacts_idx4 ON contacts(display_name_language, reverse_sortkey);
+-- There are three case of deleting contact logically
+-- Case 1 : delete contact
+-- Case 2 : delete addressbook
+-- Case 3 : delete person
+-- In all Case, the deleted contacts(deleted=1) are really deleted in the background.
CREATE TRIGGER trg_contacts_del AFTER DELETE ON contacts
BEGIN
DELETE FROM data WHERE contact_id = old.contact_id AND is_my_profile = 0;
UPDATE persons SET dirty=1 WHERE person_id = old.person_id AND link_count > 1;
END;
+-- It is triggered during really deleting contact in the background (deleted = 1).
+-- Deleted version(changed_ver) is already set when updating deleted field as 1.
CREATE TRIGGER trg_contacts_del2 AFTER DELETE ON contacts
- WHEN old.addressbook_id IN (SELECT addressbook_id from addressbooks WHERE addressbook_id = old.addressbook_id)
+ WHEN old.addressbook_id = (SELECT addressbook_id from addressbooks WHERE addressbook_id = old.addressbook_id) AND old.deleted = 1
BEGIN
- INSERT INTO contact_deleteds VALUES(old.contact_id, old.addressbook_id, old.created_ver, (SELECT ver FROM cts_version) + 1);
+ INSERT INTO contact_deleteds VALUES(old.contact_id, old.addressbook_id, old.created_ver, old.changed_ver);
END;
+-- CREATE TRIGGER trg_contacts_del3 AFTER DELETE ON contacts
+-- WHEN old.addressbook_id = (SELECT addressbook_id from addressbooks WHERE addressbook_id = old.addressbook_id) AND old.deleted = 0
+-- BEGIN
+-- INSERT INTO contact_deleteds VALUES(old.contact_id, old.addressbook_id, old.created_ver, (SELECT ver FROM cts_version) + 1);
+-- END;
+
CREATE TRIGGER trg_contacts_update AFTER UPDATE ON contacts
WHEN new.deleted = 1
BEGIN
my_profile_id INTEGER PRIMARY KEY AUTOINCREMENT,
addressbook_id INTEGER NOT NULL DEFAULT 0,
display_name TEXT,
+ reverse_display_name TEXT,
created_ver INTEGER NOT NULL,
changed_ver INTEGER NOT NULL,
changed_time INTEGER NOT NULL,
${CMAKE_SOURCE_DIR}/native/ctsvc_person.c
${CMAKE_SOURCE_DIR}/native/ctsvc_phonelog.c
- ${CMAKE_SOURCE_DIR}/native/ctsvc_restriction.c
${CMAKE_SOURCE_DIR}/native/ctsvc_service.c
${CMAKE_SOURCE_DIR}/native/ctsvc_sqlite.c
${CMAKE_SOURCE_DIR}/native/ctsvc_utils.c
g_cond_signal(&__ctsvc_server_bg_delete_cond);\r
}\r
\r
-void __ctsvc_server_addressbook_deleted_cb(const char *view_uri, void *data)\r
+static void __ctsvc_server_addressbook_deleted_cb(const char *view_uri, void *data)
{\r
ctsvc_server_bg_delete_start();\r
}\r
\r
-int ctsvc_server_bg_add_cb()\r
+static void __ctsvc_server_contact_deleted_cb(const char *view_uri, void *data)
{\r
- return contacts_db_add_changed_cb(_contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL);\r
+ ctsvc_server_bg_delete_start();
}\r
\r
-int ctsvc_server_bg_remove_cb()\r
+void ctsvc_server_bg_add_cb()
{\r
- return contacts_db_remove_changed_cb(_contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL);\r
+ int ret;
+ ret = contacts_db_add_changed_cb(_contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL);
+ SERVER_DBG("call contacts_db_add_changed_cb (_contacts_address_book) : return (%d)", ret);
+ ret = contacts_db_add_changed_cb(_contacts_contact._uri, __ctsvc_server_contact_deleted_cb, NULL);
+ SERVER_DBG("call contacts_db_add_changed_cb (_contacts_contact): return (%d)", ret);
+}
+
+void ctsvc_server_bg_remove_cb()
+{
+ int ret;
+ ret = contacts_db_remove_changed_cb(_contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL);
+ SERVER_DBG("call contacts_db_remove_changed_cb (_contacts_address_book): return (%d)", ret);
+ ret = contacts_db_remove_changed_cb(_contacts_contact._uri, __ctsvc_server_contact_deleted_cb, NULL);
+ SERVER_DBG("call contacts_db_remove_changed_cb (_contacts_contact) : return (%d)", ret);
}\r
\r
#define __CTSVC_SERVER_BG_H__\r
\r
void ctsvc_server_bg_delete_start();\r
-int ctsvc_server_bg_add_cb();\r
-int ctsvc_server_bg_remove_cb();\r
+void ctsvc_server_bg_add_cb();\r
+void ctsvc_server_bg_remove_cb();\r
\r
#endif /* __CTSVC_SERVER_BG_H__ */\r
unsigned int (*get_index_max)(void *);
unsigned int (*get_text_max)(void *);
unsigned int (*get_unused_count)(void *);
- void (*increase_used_count)(void *);
void (*set)(void *,int ,int ,int );
}sim_file_s;
return ((sim_file_s*)this)->text_max;
}
-static inline void increase_used_count(void *this)
-{
- ((sim_file_s*)this)->used_count++;
-}
-
static inline void set(void *this,int index,int text,int used_count)
{
((sim_file_s*)this)->index_max = index;
gfile_record[i].get_unused_count = get_unused_count;
gfile_record[i].get_text_max = get_text_max;
gfile_record[i].set = set;
- gfile_record[i].increase_used_count = increase_used_count;
gfile_record[i].index_max = 0;
gfile_record[i].text_max = 0;
gfile_record[i].used_count = 0;