summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorJinkun Jang <jinkun.jang@samsung.com>2013-03-16 01:17:42 +0900
committerJinkun Jang <jinkun.jang@samsung.com>2013-03-16 01:17:42 +0900
commit46f12fa934d40fa935ecdeb8a5b4b8248f0caa2d (patch)
tree26e56989aeee39877b63bdc6b1999dbbcb66b45c /server
parent11a3f117dca9ddd520fc76650858c60f69d2bdb5 (diff)
downloadcontacts-service-46f12fa934d40fa935ecdeb8a5b4b8248f0caa2d.tar.gz
contacts-service-46f12fa934d40fa935ecdeb8a5b4b8248f0caa2d.tar.bz2
contacts-service-46f12fa934d40fa935ecdeb8a5b4b8248f0caa2d.zip
merge with master
Diffstat (limited to 'server')
-rw-r--r--server/ctsvc_ipc_server.c157
-rw-r--r--server/ctsvc_ipc_server2.c185
-rw-r--r--server/ctsvc_ipc_server2.h1
-rwxr-xr-xserver/ctsvc_schema_recovery.c36
-rw-r--r--server/ctsvc_server.c1
-rwxr-xr-xserver/ctsvc_server_sim.c101
-rwxr-xr-xserver/ctsvc_server_sqlite.c93
-rwxr-xr-xserver/ctsvc_server_sqlite.h2
-rwxr-xr-xserver/ctsvc_server_utils.c128
-rwxr-xr-xserver/ctsvc_server_utils.h1
-rwxr-xr-xserver/internal.h1
11 files changed, 555 insertions, 151 deletions
diff --git a/server/ctsvc_ipc_server.c b/server/ctsvc_ipc_server.c
index fa38d82..246dc38 100644
--- a/server/ctsvc_ipc_server.c
+++ b/server/ctsvc_ipc_server.c
@@ -26,6 +26,7 @@
#include "ctsvc_ipc_marshal.h"
#include "ctsvc_internal.h"
#include "ctsvc_ipc_server.h"
+#include "ctsvc_utils.h"
void ctsvc_ipc_server_connect(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
@@ -124,13 +125,20 @@ void ctsvc_ipc_server_db_insert_record(pims_ipc_h ipc, pims_ipc_data_h indata, p
ERR("pims_ipc_data_put fail");
goto DATA_FREE;
}
- if (ret == CONTACTS_ERROR_NONE)
- {
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
if (ctsvc_ipc_marshal_int(id,*outdata) != CONTACTS_ERROR_NONE)
{
pims_ipc_data_destroy(*outdata);
ERR("ctsvc_ipc_marshal fail");
- ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
goto ERROR_RETURN;
}
}
@@ -269,7 +277,36 @@ void ctsvc_ipc_server_db_update_record(pims_ipc_h ipc, pims_ipc_data_h indata, p
ret = contacts_db_update_record(record);
- // goto 주의..
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ }
+ }
+
+ goto DATA_FREE;
+
ERROR_RETURN:
if (outdata)
{
@@ -328,7 +365,36 @@ void ctsvc_ipc_server_db_delete_record(pims_ipc_h ipc, pims_ipc_data_h indata, p
ret = contacts_db_delete_record(view_uri,id);
- // goto 주의..
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ }
+ }
+
+ goto DATA_FREE;
+
ERROR_RETURN:
if (outdata)
{
@@ -350,6 +416,7 @@ ERROR_RETURN:
{
ERR("outdata is NULL");
}
+
DATA_FREE:
CONTACTS_FREE(view_uri);
@@ -383,6 +450,35 @@ void ctsvc_ipc_server_db_replace_record(pims_ipc_h ipc, pims_ipc_data_h indata,
ret = contacts_db_replace_record(record, id);
+ if (outdata) {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata) {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ }
+ }
+ else {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
+
ERROR_RETURN:
if (outdata) {
*outdata = pims_ipc_data_create(0);
@@ -845,9 +941,16 @@ void ctsvc_ipc_server_db_insert_records(pims_ipc_h ipc, pims_ipc_data_h indata,
goto DATA_FREE;
}
- if(ret == CONTACTS_ERROR_NONE)
- {
+ if(ret == CONTACTS_ERROR_NONE) {
contacts_record_h record = NULL;
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
// marshal : id_count+property_id+[ids]*id_count
// id_count
if (pims_ipc_data_put(*outdata,(void*)&id_count,sizeof(int)) != 0)
@@ -855,9 +958,10 @@ void ctsvc_ipc_server_db_insert_records(pims_ipc_h ipc, pims_ipc_data_h indata,
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
- ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
goto ERROR_RETURN;
}
+
for(i=0;i<id_count;i++)
{
record = NULL;
@@ -867,7 +971,7 @@ void ctsvc_ipc_server_db_insert_records(pims_ipc_h ipc, pims_ipc_data_h indata,
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
- ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
goto ERROR_RETURN;
}
}
@@ -879,7 +983,6 @@ void ctsvc_ipc_server_db_insert_records(pims_ipc_h ipc, pims_ipc_data_h indata,
}
goto DATA_FREE;
- // goto 주의..
ERROR_RETURN:
if (outdata)
{
@@ -948,6 +1051,17 @@ void ctsvc_ipc_server_db_update_records(pims_ipc_h ipc, pims_ipc_data_h indata,
ERR("pims_ipc_data_put fail");
goto DATA_FREE;
}
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ }
}
else
{
@@ -1044,6 +1158,18 @@ void ctsvc_ipc_server_db_delete_records(pims_ipc_h ipc, pims_ipc_data_h indata,
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
}
}
else
@@ -1053,7 +1179,6 @@ void ctsvc_ipc_server_db_delete_records(pims_ipc_h ipc, pims_ipc_data_h indata,
goto DATA_FREE;
- // goto 주의..
ERROR_RETURN:
if (outdata)
{
@@ -1136,6 +1261,16 @@ void ctsvc_ipc_server_db_replace_records(pims_ipc_h ipc, pims_ipc_data_h indata,
ERR("pims_ipc_data_put fail");
goto DATA_FREE;
}
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ }
}
else {
ERR("outdata is NULL");
diff --git a/server/ctsvc_ipc_server2.c b/server/ctsvc_ipc_server2.c
index f737743..e2a8622 100644
--- a/server/ctsvc_ipc_server2.c
+++ b/server/ctsvc_ipc_server2.c
@@ -25,6 +25,7 @@
#include "ctsvc_ipc_marshal.h"
#include "ctsvc_internal.h"
#include "ctsvc_ipc_server.h"
+#include "ctsvc_utils.h"
void ctsvc_ipc_activity_delete_by_contact_id(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
@@ -65,6 +66,17 @@ ERROR_RETURN:
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
else
@@ -112,6 +124,17 @@ ERROR_RETURN:
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
else
@@ -166,6 +189,17 @@ ERROR_RETURN:
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
else
@@ -220,6 +254,88 @@ ERROR_RETURN:
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
+ }
+
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+
+ return;
+}
+
+void ctsvc_ipc_group_set_group_order(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ int group_id = 0;
+ int previous_group_id;
+ int next_group_id;
+
+ if (indata)
+ {
+ ret = ctsvc_ipc_unmarshal_int(indata, &group_id);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ ERR("ctsvc_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ ret = ctsvc_ipc_unmarshal_int(indata, &previous_group_id);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ ERR("ctsvc_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ ret = ctsvc_ipc_unmarshal_int(indata, &next_group_id);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ ERR("ctsvc_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ERR("ctsvc_ipc_group_link_group fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = contacts_group_set_group_order(group_id, previous_group_id, next_group_id );
+
+ERROR_RETURN:
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ return;
+ }
+ if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ return;
+ }
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
else
@@ -274,6 +390,16 @@ ERROR_RETURN:
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
else
@@ -330,6 +456,15 @@ ERROR_RETURN:
ERR("pims_ipc_data_put fail");
return;
}
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
+ }
if (pims_ipc_data_put(*outdata, (void*)&unlinked_person_id, sizeof(int)) != 0)
{
pims_ipc_data_destroy(*outdata);
@@ -391,6 +526,16 @@ ERROR_RETURN:
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
else
@@ -451,6 +596,16 @@ ERROR_RETURN:
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
else
@@ -512,6 +667,16 @@ ERROR_RETURN:
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
else
@@ -594,6 +759,16 @@ void ctsvc_ipc_phone_log_reset_statistics(pims_ipc_h ipc, pims_ipc_data_h indata
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
else
@@ -655,6 +830,16 @@ ERROR_RETURN:
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
ERR("pims_ipc_data_put fail");
+ return;
+ }
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = ctsvc_get_transaction_ver();
+ if (ctsvc_ipc_marshal_int(transaction_ver, *outdata) != CONTACTS_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("ctsvc_ipc_marshal_int fail");
+ return;
+ }
}
}
}
diff --git a/server/ctsvc_ipc_server2.h b/server/ctsvc_ipc_server2.h
index a5486f9..e9a9c37 100644
--- a/server/ctsvc_ipc_server2.h
+++ b/server/ctsvc_ipc_server2.h
@@ -26,6 +26,7 @@ void ctsvc_ipc_activity_delete_by_account_id(pims_ipc_h ipc, pims_ipc_data_h ind
void ctsvc_ipc_group_add_contact(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
void ctsvc_ipc_group_remove_contact(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
+void ctsvc_ipc_group_set_group_order(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
void ctsvc_ipc_person_link_person(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
void ctsvc_ipc_person_unlink_contact(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
diff --git a/server/ctsvc_schema_recovery.c b/server/ctsvc_schema_recovery.c
index e4e9642..d564543 100755
--- a/server/ctsvc_schema_recovery.c
+++ b/server/ctsvc_schema_recovery.c
@@ -26,6 +26,7 @@
#include "internal.h"
#include "ctsvc_server_sqlite.h"
#include "schema.h"
+#include "ctsvc_sqlite.h"
#include "ctsvc_schema_recovery.h"
#include "ctsvc_schema.h"
@@ -81,10 +82,45 @@ static inline int __ctsvc_server_remake_db_file()
return CONTACTS_ERROR_NONE;
}
+static int __ctsvc_server_check_table()
+{
+ int ret;
+ sqlite3 *db;
+ char query[CTS_SQL_MAX_LEN] = {0};
+ cts_stmt stmt = NULL;
+
+ ret = ctsvc_server_db_open(&db);
+ h_retvm_if(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_server_db_open() Failed(%d)", ret);
+
+ snprintf(query, sizeof(query),
+ "SELECT name FROM sqlite_master WHERE type='table' AND name='%s'",
+ CTS_TABLE_CONTACTS);
+ ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+ if (SQLITE_OK != ret) {
+ ERR("DB error : sqlite3_prepare_v2(%s) Failed(%s)", query, sqlite3_errmsg(db));
+ ctsvc_server_db_close();
+ return CONTACTS_ERROR_DB;
+ }
+
+ ret = sqlite3_step(stmt);
+ if (SQLITE_ROW != ret) {
+ ERR("contacts table does not exist in contacts DB file : %s", sqlite3_errmsg(db));
+ sqlite3_finalize(stmt);
+ ctsvc_server_db_close();
+ return CTSVC_ERR_NO_TABLE;
+ }
+
+ sqlite3_finalize(stmt);
+ ctsvc_server_db_close();
+ return CONTACTS_ERROR_NONE;
+}
+
int ctsvc_server_check_schema(void)
{
if (CTSVC_ERR_NO_DB_FILE == __ctsvc_server_check_db_file())
__ctsvc_server_remake_db_file();
+ else if (CTSVC_ERR_NO_TABLE == __ctsvc_server_check_table())
+ __ctsvc_server_remake_db_file();
return CONTACTS_ERROR_NONE;
}
diff --git a/server/ctsvc_server.c b/server/ctsvc_server.c
index 593c1fc..0488aec 100644
--- a/server/ctsvc_server.c
+++ b/server/ctsvc_server.c
@@ -73,6 +73,7 @@ static int __server_main(void)
if (pims_ipc_svc_register(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_ADD_CONTACT, ctsvc_ipc_group_add_contact, NULL) != 0) break;
if (pims_ipc_svc_register(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_REMOVE_CONTACT, ctsvc_ipc_group_remove_contact, NULL) != 0) break;
+ if (pims_ipc_svc_register(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_SET_GROUP_ORDER, ctsvc_ipc_group_set_group_order, NULL) != 0) break;
if (pims_ipc_svc_register(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_LINK_PERSON, ctsvc_ipc_person_link_person, NULL) != 0) break;
if (pims_ipc_svc_register(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_UNLINK_CONTACT, ctsvc_ipc_person_unlink_contact, NULL) != 0) break;
diff --git a/server/ctsvc_server_sim.c b/server/ctsvc_server_sim.c
index 9729deb..e30537a 100755
--- a/server/ctsvc_server_sim.c
+++ b/server/ctsvc_server_sim.c
@@ -37,7 +37,7 @@
#define PHONE_ADDRESSBOOK_ID 0
#define CTSVC_TAPI_SIM_PB_MAX 0xFFFF
-//#define CTSVC_SIM_DATA_MAX_LENGTH 1024
+#define CTSVC_SIM_DATA_MAX_LENGTH (255+1)
#define TAPI_PB_MAX_FILE_CNT TAPI_PB_3G_PBC+1
#define TAPI_PB_NAME_INDEX TAPI_PB_3G_NAME
@@ -224,15 +224,44 @@ static inline void* __ctsvc_server_get_return_data(void)
static sim_contact_s * __ctsvc_server_sim_create_contact_record(TelSimPbRecord_t *sim_record)
{
+ char temp[CTSVC_SIM_DATA_MAX_LENGTH] = {0,};
+
sim_contact_s *record = calloc(1,sizeof(sim_contact_s));
record->sim_index = sim_record->index;
record->next_index = sim_record->next_index;
record->name = SAFE_STRDUP((char*)sim_record->name);
record->nickname = SAFE_STRDUP((char*)sim_record->sne);
- record->number = SAFE_STRDUP((char*)sim_record->number);
- record->anr1 = SAFE_STRDUP((char*)sim_record->anr1);
- record->anr2 = SAFE_STRDUP((char*)sim_record->anr2);
- record->anr3 = SAFE_STRDUP((char*)sim_record->anr3);
+ if(sim_record->ton == TAPI_SIM_TON_INTERNATIONAL){
+ snprintf(temp,sizeof(temp),"+%s",sim_record->number);
+ record->number = strdup(temp);
+ }
+ else
+ record->number = SAFE_STRDUP((char*)sim_record->number);
+
+ memset(temp,0,sizeof(temp));
+ if(sim_record->anr1_ton == TAPI_SIM_TON_INTERNATIONAL){
+ snprintf(temp,sizeof(temp),"+%s",sim_record->anr1);
+ record->anr1 = strdup(temp);
+ }
+ else
+ record->anr1 = SAFE_STRDUP((char*)sim_record->anr1);
+
+ memset(temp,0,sizeof(temp));
+ if(sim_record->anr2_ton == TAPI_SIM_TON_INTERNATIONAL){
+ snprintf(temp,sizeof(temp),"+%s",sim_record->anr2);
+ record->anr2 = strdup(temp);
+ }
+ else
+ record->anr2 = SAFE_STRDUP((char*)sim_record->anr2);
+
+ memset(temp,0,sizeof(temp));
+ if(sim_record->anr3_ton == TAPI_SIM_TON_INTERNATIONAL){
+ snprintf(temp,sizeof(temp),"+%s",sim_record->anr3);
+ record->anr3 = strdup(temp);
+ }
+ else
+ record->anr3 = SAFE_STRDUP((char*)sim_record->anr3);
+
record->email1 = SAFE_STRDUP((char*)sim_record->email1);
record->email2 = SAFE_STRDUP((char*)sim_record->email2);
record->email3 = SAFE_STRDUP((char*)sim_record->email3);
@@ -280,10 +309,10 @@ static int __ctsvc_server_insert_contact_to_db(sim_contact_s *record,int* contac
contacts_record_h name = NULL;
contacts_record_h number = NULL;
contacts_record_h email = NULL;
- contacts_record_h nick = NULL;
+// contacts_record_h nick = NULL;
- h_retvm_if(record == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid paramter : record is NULL");
- h_retvm_if(contact_id == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid paramter : contact_id is NULL");
+ h_retvm_if(record == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter : record is NULL");
+ h_retvm_if(contact_id == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter : contact_id is NULL");
h_retvm_if(record->sim_index <= 0, CONTACTS_ERROR_INVALID_PARAMETER, "The index(%d) is invalid", record->sim_index);
SERVER_DBG("insert record -> sim_index %d",record->sim_index);
@@ -302,7 +331,7 @@ static int __ctsvc_server_insert_contact_to_db(sim_contact_s *record,int* contac
}
SERVER_DBG("insert record -> name %s", record->name);
- if (record->nickname) {
+/* if (record->nickname) {
contacts_record_create(_contacts_nickname._uri, &nick);
if (nick) {
contacts_record_set_str(nick, _contacts_nickname.name, (char *)record->nickname);
@@ -310,7 +339,7 @@ static int __ctsvc_server_insert_contact_to_db(sim_contact_s *record,int* contac
}
}
SERVER_DBG("insert record -> nick name %s", record->nickname);
-
+*/
if (record->number) {
contacts_record_create(_contacts_number._uri, &number);
if (number) {
@@ -321,7 +350,7 @@ static int __ctsvc_server_insert_contact_to_db(sim_contact_s *record,int* contac
}
SERVER_DBG("insert record ->number %s", record->number);
- ret = __ctsvc_server_insert_db_num(&number, (char *)record->anr1);
+/* ret = __ctsvc_server_insert_db_num(&number, (char *)record->anr1);
if (CONTACTS_ERROR_NONE == ret)
contacts_record_add_child_record(contact, _contacts_contact.number, number);
SERVER_DBG("insert record ->anr1 %s", record->anr1);
@@ -335,12 +364,12 @@ static int __ctsvc_server_insert_contact_to_db(sim_contact_s *record,int* contac
if (CONTACTS_ERROR_NONE == ret)
contacts_record_add_child_record(contact, _contacts_contact.number, number);
SERVER_DBG("insert record ->anr3 %s", record->anr3);
-
+*/
ret = __ctsvc_server_insert_db_email(&email, (char *)record->email1);
if (CONTACTS_ERROR_NONE == ret)
contacts_record_add_child_record(contact, _contacts_contact.email, email);
SERVER_DBG("insert record ->email1 %s", record->email1);
-
+/*
ret = __ctsvc_server_insert_db_email(&email, (char *)record->email2);
if (CONTACTS_ERROR_NONE == ret)
contacts_record_add_child_record(contact, _contacts_contact.email, email);
@@ -355,7 +384,7 @@ static int __ctsvc_server_insert_contact_to_db(sim_contact_s *record,int* contac
if (CONTACTS_ERROR_NONE == ret)
contacts_record_add_child_record(contact, _contacts_contact.email, email);
SERVER_DBG("insert record ->email4 %s", record->email4);
-
+*/
contacts_record_set_int(contact, _contacts_contact.address_book_id, addressbook_id);
ret = contacts_db_insert_record(contact, contact_id);
h_warn_if(ret < CONTACTS_ERROR_NONE, "contacts_db_insert_record() Failed(%d)", ret);
@@ -528,18 +557,34 @@ static void __ctsvc_server_sim_sdn_read_cb(TapiHandle *handle, int result, void
}
}
else {
- // read SDN done ( success )
- // sim_data = NULL;
ctsvc_server_trim_memory();
}
return;
ERROR_RETURN:
- // sim_data = NULL;
ctsvc_server_trim_memory();
return;
}
+static void __ctsvc_server_sim_sdn_meta_info_cb(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ SERVER_FN_CALL;
+ TelSimPbAccessResult_t sec_rt = result;
+ int ret=0;
+
+ if (TAPI_SIM_PB_SUCCESS != sec_rt) {
+ ERR("__ctsvc_server_sim_sdn_meta_info_cb() Failed(%d)", sec_rt);
+ goto ERROR_RETURN;
+ }
+ ret = tel_read_sim_pb_record(__ctsvc_server_get_tapi_handle(), TAPI_SIM_PB_SDN,1, __ctsvc_server_sim_sdn_read_cb, NULL);
+ if(TAPI_API_SUCCESS != ret) {
+ ERR("tel_read_sim_pb_record() Failed(%d)", ret);
+ goto ERROR_RETURN;
+ }
+ERROR_RETURN:
+ ctsvc_server_trim_memory();
+ return;
+}
int ctsvc_server_sim_read_sdn(void* data)
{
SERVER_FN_CALL;
@@ -570,13 +615,15 @@ int ctsvc_server_sim_read_sdn(void* data)
goto ERROR_RETURN;
}
- ret = tel_read_sim_pb_record(__ctsvc_server_get_tapi_handle(), TAPI_SIM_PB_SDN,
- 1, __ctsvc_server_sim_sdn_read_cb, NULL);
+ ret = tel_get_sim_pb_meta_info(__ctsvc_server_get_tapi_handle(), TAPI_SIM_PB_SDN, __ctsvc_server_sim_sdn_meta_info_cb, NULL);
+ h_retvm_if(ret != TAPI_API_SUCCESS, CONTACTS_ERROR_SYSTEM, "tel_get_sim_(usim)_meta_info =%d",ret);
if(TAPI_API_SUCCESS != ret) {
- ERR("tel_read_sim_pb_record() Failed(%d)", ret);
- ret = CONTACTS_ERROR_SYSTEM;
+ ERR("tel_get_sim_pb_meta_info() Failed(%d)", ret);
goto ERROR_RETURN;
}
+
+ else
+ ERR("sim_status Failed(%d)", sim_status);
}
return CONTACTS_ERROR_NONE;
@@ -632,19 +679,9 @@ static void __ctsvc_server_sim_initialize_cb(TapiHandle *handle, int result, voi
int ctsvc_server_sim_initialize(void)
{
SERVER_FN_CALL;
- contacts_error_e err = CONTACTS_ERROR_NONE;
__ctsvc_server_get_tapi_handle();
__ctsvc_server_set_sim_type();
-
- err = contacts_connect2();
- if(err != CONTACTS_ERROR_NONE ){
- if (ghandle){
- tel_deinit(ghandle);
- ghandle = NULL;
- }
- ERR("contacts_connect2 fail");
- return err;
- }
+ contacts_connect2();
int ret = TAPI_API_SUCCESS;
TelSimPbType_t sim_type;
diff --git a/server/ctsvc_server_sqlite.c b/server/ctsvc_server_sqlite.c
index b0b40f7..902ecdf 100755
--- a/server/ctsvc_server_sqlite.c
+++ b/server/ctsvc_server_sqlite.c
@@ -27,10 +27,13 @@
#include "ctsvc_sqlite.h"
#include "ctsvc_notify.h"
#include "ctsvc_normalize.h"
+#include "ctsvc_localize.h"
#include "ctsvc_server_utils.h"
#include "ctsvc_notification.h"
-#include "ctsvc_db_plugin_contact_helper.h"
+#include "ctsvc_db_plugin_image_helper.h"
+#include "ctsvc_db_plugin_company_helper.h"
+
#include "ctsvc_person.h"
#include "ctsvc_phonelog.h"
@@ -46,14 +49,18 @@ int ctsvc_server_db_open(sqlite3 **db)
h_retvm_if(ret != SQLITE_OK, CONTACTS_ERROR_DB,
"db_util_open() Failed(%d)", ret);
- ret = sqlite3_create_function(server_db, "_CONTACT_DELETE_", 3, SQLITE_UTF8, NULL,
- ctsvc_db_contact_delete_callback, NULL, NULL);
- h_retvm_if(SQLITE_OK != ret, CONTACTS_ERROR_DB,
- "sqlite3_create_function() Failed(%d)", ret);
ret = sqlite3_create_function(server_db, "_DATA_DELETE_", 2, SQLITE_UTF8, NULL,
ctsvc_db_data_delete_callback, NULL, NULL);
h_retvm_if(SQLITE_OK != ret, CONTACTS_ERROR_DB,
"sqlite3_create_function() Failed(%d)", ret);
+ ret = sqlite3_create_function(server_db, "_DATA_IMAGE_DELETE_", 1, SQLITE_UTF8, NULL,
+ ctsvc_db_data_image_delete_callback, NULL, NULL);
+ h_retvm_if(SQLITE_OK != ret, CONTACTS_ERROR_DB,
+ "sqlite3_create_function() Failed(%d)", ret);
+ ret = sqlite3_create_function(server_db, "_DATA_COMPANY_DELETE_", 1, SQLITE_UTF8, NULL,
+ ctsvc_db_data_company_delete_callback, NULL, NULL);
+ h_retvm_if(SQLITE_OK != ret, CONTACTS_ERROR_DB,
+ "sqlite3_create_function() Failed(%d)", ret);
ret = sqlite3_create_function(server_db, "_PHONE_LOG_DELETE_", 1, SQLITE_UTF8, NULL,
ctsvc_db_phone_log_delete_callback, NULL, NULL);
h_retvm_if(SQLITE_OK != ret, CONTACTS_ERROR_DB,
@@ -132,7 +139,7 @@ int ctsvc_server_end_trans(bool success)
return CONTACTS_ERROR_NONE;
}
-int ctsvc_server_update_default_language(int prev_lang, int new_lang, int second_lang)
+int ctsvc_server_update_default_language(int prev_sort_primary, int prev_sort_secondary, int new_sort_primary, int new_sort_secondary)
{
SERVER_FN_CALL;
int ret;
@@ -146,14 +153,8 @@ int ctsvc_server_update_default_language(int prev_lang, int new_lang, int second
ret = ctsvc_server_begin_trans();
h_retvm_if(ret, ret, "ctsvc_server_begin_trans() Failed(%d)", ret);
- if (prev_lang == second_lang) {
- snprintf(query, sizeof(query), "UPDATE %s SET display_name_language=%d WHERE display_name_language =%d" ,
- CTS_TABLE_CONTACTS, CTSVC_LANG_SECONDARY, CTSVC_LANG_DEFAULT);
- }
- else {
- snprintf(query, sizeof(query), "UPDATE %s SET display_name_language=%d WHERE display_name_language = %d" ,
- CTS_TABLE_CONTACTS, prev_lang, CTSVC_LANG_DEFAULT);
- }
+ snprintf(query, sizeof(query), "UPDATE %s SET display_name_language=%d WHERE display_name_language =%d" ,
+ CTS_TABLE_CONTACTS, prev_sort_primary, CTSVC_SORT_PRIMARY);
ret = sqlite3_exec(db, query, NULL, NULL, &errmsg);
if (SQLITE_OK != ret) {
ERR("sqlite3_exec(%s) Failed(%d, %s)", query, ret, errmsg);
@@ -163,14 +164,30 @@ int ctsvc_server_update_default_language(int prev_lang, int new_lang, int second
return CONTACTS_ERROR_DB;
}
- if (new_lang == second_lang) {
- snprintf(query, sizeof(query), "UPDATE %s SET display_name_language=%d WHERE display_name_language=%d",
- CTS_TABLE_CONTACTS, CTSVC_LANG_DEFAULT, CTSVC_LANG_SECONDARY);
+ snprintf(query, sizeof(query), "UPDATE %s SET display_name_language=%d WHERE display_name_language = %d" ,
+ CTS_TABLE_CONTACTS, prev_sort_secondary, CTSVC_SORT_SECONDARY);
+ ret = sqlite3_exec(db, query, NULL, NULL, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("sqlite3_exec(%s) Failed(%d, %s)", query, ret, errmsg);
+ sqlite3_free(errmsg);
+ ctsvc_server_end_trans(false);
+ ctsvc_server_db_close();
+ return CONTACTS_ERROR_DB;
}
- else {
- snprintf(query, sizeof(query), "UPDATE %s SET display_name_language=%d WHERE display_name_language=%d",
- CTS_TABLE_CONTACTS, CTSVC_LANG_DEFAULT, new_lang);
+
+ snprintf(query, sizeof(query), "UPDATE %s SET display_name_language=%d WHERE display_name_language=%d",
+ CTS_TABLE_CONTACTS, CTSVC_SORT_PRIMARY, new_sort_primary);
+ ret = sqlite3_exec(db, query, NULL, NULL, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("sqlite3_exec(%s) Failed(%d, %s)", query, ret, errmsg);
+ sqlite3_free(errmsg);
+ ctsvc_server_end_trans(false);
+ ctsvc_server_db_close();
+ return CONTACTS_ERROR_DB;
}
+
+ snprintf(query, sizeof(query), "UPDATE %s SET display_name_language=%d WHERE display_name_language =%d" ,
+ CTS_TABLE_CONTACTS, CTSVC_SORT_SECONDARY, new_sort_secondary);
ret = sqlite3_exec(db, query, NULL, NULL, &errmsg);
if (SQLITE_OK != ret) {
ERR("sqlite3_exec(%s) Failed(%d, %s)", query, ret, errmsg);
@@ -180,13 +197,19 @@ int ctsvc_server_update_default_language(int prev_lang, int new_lang, int second
return CONTACTS_ERROR_DB;
}
- ret = ctsvc_server_set_default_language(new_lang);
+ ret = ctsvc_server_set_default_language(new_sort_primary);
if (CONTACTS_ERROR_NONE != ret) {
ctsvc_server_end_trans(false);
ctsvc_server_db_close();
return ret;
}
ret = ctsvc_server_end_trans(true);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int fd = open(CTSVC_NOTI_PERSON_CHANGED, O_TRUNC | O_RDWR);
+ if (0 <= fd)
+ close(fd);
+ }
ctsvc_server_db_close();
return ret;
@@ -229,12 +252,6 @@ int ctsvc_server_update_secondary_language(int prev_lang, int new_lang)
return CONTACTS_ERROR_DB;
}
- ret = ctsvc_server_set_secondary_language(new_lang);
- if (CONTACTS_ERROR_NONE != ret) {
- ctsvc_server_end_trans(false);
- ctsvc_server_db_close();
- return ret;
- }
ret = ctsvc_server_end_trans(true);
ctsvc_server_db_close();
@@ -339,7 +356,7 @@ int ctsvc_server_update_collation()
}
snprintf(query, sizeof(query),
- "SELECT contact_id, display_name, reverse_display_name "
+ "SELECT contact_id, sort_name, reverse_sort_name "
"FROM "CTS_TABLE_CONTACTS" WHERE deleted = 0");
ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
if(SQLITE_OK != ret) {
@@ -364,19 +381,23 @@ int ctsvc_server_update_collation()
while (SQLITE_ROW == (ret = sqlite3_step(stmt))) {
int contact_id = sqlite3_column_int(stmt, 0);
- char *display_name = (char*)sqlite3_column_text(stmt, 1);
- char *reverse_display_name = (char*)sqlite3_column_text(stmt, 2);
+ char *sort_name = (char*)sqlite3_column_text(stmt, 1);
+ char *reverse_sort_name = (char*)sqlite3_column_text(stmt, 2);
char *sortkey = NULL;
char *reverse_sortkey = NULL;
+ if (sort_name) {
+ ret = ctsvc_collation_str(sort_name, &sortkey);
+ if (CONTACTS_ERROR_NONE == ret && sortkey)
+ sqlite3_bind_text(update_stmt, 1, sortkey, strlen(sortkey), SQLITE_STATIC);
+ }
- ret = ctsvc_collation_str(display_name, &sortkey);
- if (CONTACTS_ERROR_NONE == ret && sortkey)
- sqlite3_bind_text(update_stmt, 1, sortkey, strlen(sortkey), SQLITE_STATIC);
+ if (reverse_sort_name) {
+ ret = ctsvc_collation_str(reverse_sort_name, &reverse_sortkey);
+ if (CONTACTS_ERROR_NONE == ret && reverse_sortkey)
+ sqlite3_bind_text(update_stmt, 2, reverse_sortkey, strlen(reverse_sortkey), SQLITE_STATIC);
+ }
- ret = ctsvc_collation_str(reverse_display_name, &reverse_sortkey);
- if (CONTACTS_ERROR_NONE == ret && reverse_sortkey)
- sqlite3_bind_text(update_stmt, 2, reverse_sortkey, strlen(reverse_sortkey), SQLITE_STATIC);
sqlite3_bind_int(update_stmt, 3, contact_id);
ret = sqlite3_step(update_stmt);
diff --git a/server/ctsvc_server_sqlite.h b/server/ctsvc_server_sqlite.h
index 80bab7e..56be9db 100755
--- a/server/ctsvc_server_sqlite.h
+++ b/server/ctsvc_server_sqlite.h
@@ -23,7 +23,7 @@
int ctsvc_server_db_open(sqlite3 **db);
int ctsvc_server_db_close(void);
-int ctsvc_server_update_default_language(int system_lang, int default_lang, int second_lang);
+int ctsvc_server_update_default_language(int prev_sort_primary, int prev_sort_secondary, int new_sort_primary, int new_sort_secondary);
int ctsvc_server_update_secondary_language(int prev_lang, int new_lang);
int ctsvc_server_insert_sdn_contact(const char *name, const char *number);
int ctsvc_server_delete_sdn_contact(void);
diff --git a/server/ctsvc_server_utils.c b/server/ctsvc_server_utils.c
index 2de84f7..eae5f87 100755
--- a/server/ctsvc_server_utils.c
+++ b/server/ctsvc_server_utils.c
@@ -33,61 +33,66 @@ static const char *CTSVC_SERVER_VCONF_TAPI_SIM_PB_INIT = VCONFKEY_TELEPHONY_SIM_
static const char *CTSVC_SERVER_VCONF_SYSTEM_LANGUAGE = VCONFKEY_LANGSET;
-static int default_language = -1;
+static int primary_sort = -1;
static int system_language = -1;
-static int secondary_language = -1;
+static int secondary_sort = -1;
inline int ctsvc_server_set_default_language(int lang)
{
int ret = vconf_set_int(ctsvc_get_default_language_vconfkey(), lang);
h_retvm_if(ret<0, CONTACTS_ERROR_INTERNAL, "vconf_set_int() Failed(%d)", ret);
- default_language = lang;
- return CONTACTS_ERROR_NONE;
-}
+ primary_sort = lang;
-inline int ctsvc_server_set_secondary_language(int lang)
-{
- int ret = vconf_set_int(ctsvc_get_secondary_language_vconfkey(), lang);
- h_retvm_if(ret<0, CONTACTS_ERROR_SYSTEM, "vconf_set_int() Failed(%d)", ret);
-
- secondary_language = lang;
+ {
+ if (primary_sort==CTSVC_SORT_KOREAN)
+ secondary_sort = CTSVC_SORT_WESTERN;
+ else if (primary_sort==CTSVC_SORT_WESTERN)
+ secondary_sort = CTSVC_SORT_KOREAN;
+ else
+ secondary_sort = CTSVC_SORT_WESTERN;
+ }
+ DBG("primary %d second %d", primary_sort, secondary_sort);
return CONTACTS_ERROR_NONE;
}
static void ctsvc_server_change_language_cb(keynode_t *key, void *data)
{
int ret = -1;
+ int new_primary_sort, new_secondary_sort;
const char *langset;
langset = vconf_keynode_get_str(key);
- if (!default_language) {
- ret = vconf_get_int(ctsvc_get_default_language_vconfkey(), &default_language);
- h_retm_if(ret<0, "vconf_get_int() Failed(%d)", ret);
- }
-
-
system_language = ctsvc_get_language_type(langset);
- DBG("system language(%d, %s)", system_language, langset);
- if (system_language != default_language)
- ret = ctsvc_server_update_default_language(default_language, system_language, secondary_language);
-}
-
-static void ctsvc_server_change_secondary_language_cb(keynode_t *key, void *data)
-{
- int ret = -1;
- const char *langset;
- int lang_type;
+ switch(system_language)
+ {
+ case CTSVC_LANG_KOREAN:
+ new_primary_sort = CTSVC_SORT_KOREAN;
+ break;
+ case CTSVC_LANG_JAPANESE:
+ new_primary_sort = CTSVC_SORT_JAPANESE;
+ break;
+ default:
+ new_primary_sort = CTSVC_SORT_WESTERN;
+ break;
+ }
- langset = vconf_keynode_get_str(key);
- if (!secondary_language) {
- ret = vconf_get_int(ctsvc_get_secondary_language_vconfkey(), &secondary_language);
+ if (primary_sort ==-1) {
+ ret = vconf_get_int(ctsvc_get_default_language_vconfkey(), &primary_sort);
h_retm_if(ret<0, "vconf_get_int() Failed(%d)", ret);
}
- lang_type = ctsvc_get_language_type(langset);
- if (lang_type != secondary_language)
- ret = ctsvc_server_update_secondary_language(secondary_language, lang_type);
+ {
+ if (new_primary_sort==CTSVC_SORT_KOREAN)
+ new_secondary_sort = CTSVC_SORT_WESTERN;
+ else if (new_primary_sort==CTSVC_SORT_WESTERN)
+ new_secondary_sort = CTSVC_SORT_KOREAN;
+ else
+ new_secondary_sort = CTSVC_SORT_WESTERN;
+ }
+
+ if (new_primary_sort != primary_sort)
+ ret = ctsvc_server_update_default_language(primary_sort, secondary_sort, new_primary_sort, new_secondary_sort);
}
static void ctsvc_server_update_collation_cb(keynode_t *key, void *data)
@@ -100,9 +105,6 @@ static void ctsvc_server_tapi_sim_complete_cb(keynode_t *key, void *data)
int ret, init_stat;
init_stat = vconf_keynode_get_int(key);
if (VCONFKEY_TELEPHONY_SIM_PB_INIT_COMPLETED == init_stat) {
- ret = ctsvc_server_sim_read_sdn(NULL);
- h_warn_if(CONTACTS_ERROR_NONE != ret, "ctsvc_server_sim_read_sdn() Failed(%d)", ret);
-
ret = ctsvc_server_sim_initialize();
h_warn_if(CONTACTS_ERROR_NONE != ret, "ctsvc_server_sim_initialize() Failed(%d)", ret);
@@ -126,57 +128,43 @@ int ctsvc_server_init_configuration(void)
{
int ret, sim_stat=-1;
const char *langset;
- int lang_type;
+ int sort_type;
- ret = vconf_get_int(ctsvc_get_default_language_vconfkey(), &default_language);
- if (ret < 0) {
+ langset = vconf_get_str(CTSVC_SERVER_VCONF_SYSTEM_LANGUAGE);
+ h_warn_if(NULL == langset, "vconf_get_str(%s) return NULL", CTSVC_SERVER_VCONF_SYSTEM_LANGUAGE);
+ system_language = ctsvc_get_language_type(langset);
+
+ ret = vconf_get_int(ctsvc_get_default_language_vconfkey(), &sort_type);
+ if (ret < 0 || sort_type == CTSVC_SORT_OTHERS) {
ERR("vconf_get_int(%s) Failed(%d)", ctsvc_get_default_language_vconfkey() ,ret);
- default_language = 0;
- }
- ret = vconf_get_int(ctsvc_get_secondary_language_vconfkey(), &secondary_language);
- if (ret < 0) {
- ERR("vconf_get_int(%s) Failed(%d)", ctsvc_get_secondary_language_vconfkey(),ret);
- secondary_language = 0;
+ switch(system_language)
+ {
+ case CTSVC_LANG_KOREAN:
+ sort_type = CTSVC_SORT_KOREAN;
+ break;
+ case CTSVC_LANG_JAPANESE:
+ sort_type = CTSVC_SORT_JAPANESE;
+ break;
+ default:
+ sort_type = CTSVC_SORT_WESTERN;
+ }
}
+ ctsvc_server_set_default_language(sort_type);
+
ret = vconf_notify_key_changed(CTSVC_SERVER_VCONF_SYSTEM_LANGUAGE,
ctsvc_server_change_language_cb, NULL);
h_retvm_if(ret<0, CONTACTS_ERROR_SYSTEM, "vconf_notify_key_changed(%s) Failed(%d)",
CTSVC_SERVER_VCONF_SYSTEM_LANGUAGE, ret);
- ret = vconf_notify_key_changed(VCONFKEY_CONTACTS_SVC_SECONDARY_LANGUAGE,
- ctsvc_server_change_secondary_language_cb, NULL);
- h_retvm_if(ret<0, CONTACTS_ERROR_SYSTEM, "vconf_notify_key_changed(%s) Failed(%d)",
- VCONFKEY_CONTACTS_SVC_SECONDARY_LANGUAGE, ret);
-
ret = vconf_notify_key_changed(VCONFKEY_REGIONFORMAT,
ctsvc_server_update_collation_cb, NULL);
h_retvm_if(ret<0, CONTACTS_ERROR_SYSTEM, "vconf_notify_key_changed(%s) Failed(%d)",
VCONFKEY_REGIONFORMAT, ret);
- langset = vconf_get_str(CTSVC_SERVER_VCONF_SYSTEM_LANGUAGE);
- h_warn_if(NULL == langset, "vconf_get_str(%s) return NULL", CTSVC_SERVER_VCONF_SYSTEM_LANGUAGE);
- system_language = ctsvc_get_language_type(langset);
-
- langset = vconf_get_str(VCONFKEY_CONTACTS_SVC_SECONDARY_LANGUAGE);
- h_warn_if(NULL == langset, "vconf_get_str(%s) return NULL", CTSVC_SERVER_VCONF_SYSTEM_LANGUAGE);
- lang_type = ctsvc_get_language_type(langset);
- if (secondary_language != lang_type) {
- ERR("system lang(%s, %d), default lang(%d)", langset, lang_type, secondary_language);
- ctsvc_server_update_secondary_language(secondary_language, lang_type);
- }
-
- if (system_language != default_language) {
- ERR("system lang(%s, %d), default lang(%d)", langset, system_language, default_language);
- ctsvc_server_update_default_language(default_language, system_language, secondary_language);
- }
-
ret = vconf_get_int(CTSVC_SERVER_VCONF_TAPI_SIM_PB_INIT, &sim_stat);
if (VCONFKEY_TELEPHONY_SIM_PB_INIT_COMPLETED == sim_stat) {
- ret = ctsvc_server_sim_read_sdn(NULL);
- h_warn_if(CONTACTS_ERROR_NONE != ret, "ctsvc_server_sim_read_sdn() Failed(%d)", ret);
-
ret = ctsvc_server_sim_initialize();
h_warn_if(CONTACTS_ERROR_NONE != ret, "ctsvc_server_sim_initialize() Failed(%d)", ret);
}
diff --git a/server/ctsvc_server_utils.h b/server/ctsvc_server_utils.h
index 38c0cbb..9ec7bdf 100755
--- a/server/ctsvc_server_utils.h
+++ b/server/ctsvc_server_utils.h
@@ -24,7 +24,6 @@ void ctsvc_server_final_configuration(void);
int ctsvc_server_get_default_language(void);
int ctsvc_server_set_default_language(int lang);
-int ctsvc_server_set_secondary_language(int lang);
void ctsvc_server_trim_memory(void);
diff --git a/server/internal.h b/server/internal.h
index f99e8fe..6a55fb0 100755
--- a/server/internal.h
+++ b/server/internal.h
@@ -28,6 +28,7 @@
// Additional Error
enum {
CTSVC_ERR_NO_DB_FILE = -10000,
+ CTSVC_ERR_NO_TABLE,
};
#define SERVER_DLOG_OUT