SET(SRCS
ctsvc_client_activity.c
ctsvc_client_db.c
+ ctsvc_client_db_notification.c
ctsvc_client_group.c
ctsvc_client_person.c
ctsvc_client_service.c
ctsvc_client_ipc.c
ctsvc_client_noti.c
ctsvc_client_setting.c
+ ctsvc_client_handle.c
+
+ ctsvc_client_service_helper.c
+ ctsvc_client_db_helper.c
+ ctsvc_client_activity_helper.c
+ ctsvc_client_person_helper.c
+ ctsvc_client_group_helper.c
+ ctsvc_client_phonelog_helper.c
${CMAKE_SOURCE_DIR}/common/ipc/ctsvc_ipc_marshal.c
${CMAKE_SOURCE_DIR}/common/ipc/ctsvc_ipc_addressbook.c
${CMAKE_SOURCE_DIR}/common/ipc/ctsvc_ipc_extension.c
${CMAKE_SOURCE_DIR}/common/ipc/ctsvc_ipc_profile.c
- ${CMAKE_SOURCE_DIR}/common/ctsvc_db_notification.c
${CMAKE_SOURCE_DIR}/common/ctsvc_filter.c
${CMAKE_SOURCE_DIR}/common/ctsvc_inotify.c
${CMAKE_SOURCE_DIR}/common/ctsvc_list.c
${CMAKE_SOURCE_DIR}/common/ctsvc_socket.c
${CMAKE_SOURCE_DIR}/common/ctsvc_vcard.c
${CMAKE_SOURCE_DIR}/common/ctsvc_view.c
+ ${CMAKE_SOURCE_DIR}/common/ctsvc_handle.c
${CMAKE_SOURCE_DIR}/common/ipc/ctsvc_ipc_sdn.c
${CMAKE_SOURCE_DIR}/common/ctsvc_record_sdn.c
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 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.
*
*/
-#include <glib.h>
-#include <pims-ipc-data.h>
-
#include "contacts.h"
#include "ctsvc_internal.h"
-#include "ctsvc_ipc_define.h"
-#include "ctsvc_ipc_marshal.h"
-#include "ctsvc_client_ipc.h"
+#include "ctsvc_client_handle.h"
+#include "ctsvc_client_activity_helper.h"
API int contacts_activity_delete_by_contact_id(int contact_id)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(contact_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(contact_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
+ int ret;
+ contacts_h contact = NULL;
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_ACTIVITY_MODULE, CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_CONTACT_ID, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_activity_delete_by_contact_id(contact, contact_id);
return ret;
}
API int contacts_activity_delete_by_account_id(int account_id)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(account_id <= 0,CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
+ int ret;
+ contacts_h contact = 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_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- ret = ctsvc_ipc_marshal_int(account_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_ACTIVITY_MODULE, CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_ACCOUNT_ID, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_activity_delete_by_account_id(contact, account_id);
return ret;
-}
\ No newline at end of file
+}
+
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2015 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 <glib.h>
+#include <pims-ipc-data.h>
+
+#include "contacts.h"
+#include "ctsvc_internal.h"
+#include "ctsvc_ipc_define.h"
+#include "ctsvc_ipc_marshal.h"
+#include "ctsvc_client_ipc.h"
+
+static const char CONTACTS_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.read";
+static const char CONTACTS_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.write";
+static const char PHONELOG_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.read";
+static const char PHONELOG_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.write";
+
+
+int ctsvc_client_activity_delete_by_contact_id(contacts_h contact, int contact_id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(contact_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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_int(contact_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_ACTIVITY_MODULE, CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_CONTACT_ID, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_activity_delete_by_account_id(contacts_h contact, int account_id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(account_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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_int(account_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_ACTIVITY_MODULE, CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_ACCOUNT_ID, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CTSVC_CLIENT_ACTIVITY_HELPER_H__
+#define __CTSVC_CLIENT_ACTIVITY_HELPER_H__
+
+#include "contacts_types.h"
+
+int ctsvc_client_activity_delete_by_contact_id(contacts_h contact, int contact_id);
+int ctsvc_client_activity_delete_by_account_id(contacts_h contact, int account_id);
+
+#endif /* __CTSVC_CLIENT_ACTIVITY_HELPER_H__ */
\ No newline at end of file
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Dohyung Jin <dh.jin@samsung.com>
* Jongwon Lee <gogosing.lee@samsung.com>
*
*/
-#include <glib.h>
-#include <pims-ipc.h>
-#include <pims-ipc-data.h>
-
#include "contacts.h"
-#include "contacts_internal.h"
-
#include "ctsvc_internal.h"
-#include "ctsvc_list.h"
-#include "ctsvc_record.h"
-#include "ctsvc_inotify.h"
-
-#include "ctsvc_ipc_define.h"
-#include "ctsvc_ipc_marshal.h"
-#include "ctsvc_view.h"
-
-#include "ctsvc_client_ipc.h"
-
-#include "ctsvc_mutex.h"
-
+#include "ctsvc_client_handle.h"
+#include "ctsvc_client_db_helper.h"
API int contacts_db_insert_record(contacts_record_h record, int *id)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- if (id)
- *id = 0;
-
- RETVM_IF(record==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"record is 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_DB_MODULE, CTSVC_IPC_SERVER_DB_INSERT_RECORD, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
-
- if (id)
- *id = *(int*)pims_ipc_data_get(outdata,&size);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_insert_record(contact, record, id);
return ret;
}
API int contacts_db_get_record(const char* view_uri, int id, contacts_record_h* out_record)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- RETVM_IF(id<0,CONTACTS_ERROR_INVALID_PARAMETER,"id<0");
- RETVM_IF(out_record==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"record is NULL");
- *out_record = 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_string(view_uri,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(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_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_RECORD, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_record(outdata,out_record);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_get_record(contact, view_uri, id, out_record);
return ret;
}
API int contacts_db_update_record(contacts_record_h record)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(record==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"record is 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_DB_MODULE, CTSVC_IPC_SERVER_DB_UPDATE_RECORD, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
- if (CONTACTS_ERROR_NONE == ret) {
- CTSVC_RECORD_RESET_PROPERTY_FLAGS((ctsvc_record_s *)record);
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_update_record(contact, record);
return ret;
}
API int contacts_db_delete_record(const char* view_uri, int id)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- RETVM_IF(id<=0,CONTACTS_ERROR_INVALID_PARAMETER,"id <= 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_string(view_uri,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(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_DB_MODULE, CTSVC_IPC_SERVER_DB_DELETE_RECORD, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_delete_record(contact, view_uri, id);
return ret;
}
API int contacts_db_replace_record(contacts_record_h record, int id)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter : record is 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;
- }
- ret = ctsvc_ipc_marshal_int(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_DB_MODULE,
- CTSVC_IPC_SERVER_DB_REPLACE_RECORD, indata, &outdata) != 0) {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata) {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_replace_record(contact, record, id);
return ret;
+
}
API int contacts_db_get_all_records(const char* view_uri, int offset, int limit, contacts_list_h* out_list)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(out_list==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"list is NULL");
- *out_list = NULL;
- RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is 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_string(view_uri,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(offset,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(limit,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_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_ALL_RECORDS, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
- }
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_get_all_records(contact, view_uri, offset, limit, out_list);
return ret;
}
API int contacts_db_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(out_list==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"list is NULL");
- *out_list = NULL;
- RETVM_IF(query==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"query is 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_query(query,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(offset,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(limit,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- return ret;
- }
-
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_RECORDS_WITH_QUERY, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_get_records_with_query(contact, query, offset, limit, out_list);
return ret;
}
+
API int contacts_db_get_count(const char* view_uri, int *out_count)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- RETVM_IF(out_count==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"count pointer is NULL");
- *out_count = 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_string(view_uri,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_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_COUNT, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_int(outdata,out_count);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_get_count(contact, view_uri, out_count);
return ret;
}
API int contacts_db_get_count_with_query(contacts_query_h query, int *out_count)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(query==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"record is NULL");
- RETVM_IF(out_count==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"count pointer is NULL");
- *out_count = 0;
-
- 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_query(query,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_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_COUNT_WITH_QUERY, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_int(outdata,out_count);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_get_count_with_query(contact, query, out_count);
return ret;
}
API int contacts_db_insert_records(contacts_list_h list, int **ids, int *count)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- if (ids)
- *ids = NULL;
- if (count)
- *count = 0;
-
- RETVM_IF(list==NULL,CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
-
- 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_list(list,indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_INSERT_RECORDS,
- indata, &outdata) != 0) {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata) {
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
-
- if (ids && count) {
- int i = 0;
- int *id = NULL;
- int c;
- c = *(int*)pims_ipc_data_get(outdata, &size);
- id = calloc(c, sizeof(int));
- for(i=0;i<c;i++)
- id[i] = *(int*) pims_ipc_data_get(outdata, &size);
- *ids = id;
- *count = c;
- }
- }
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_insert_records(contact, list, ids, count);
return ret;
}
API int contacts_db_update_records(contacts_list_h list)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(NULL == list, CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
-
- 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_list(list,indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_UPDATE_RECORDS,
- indata, &outdata) != 0) {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata) {
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_update_records(contact, list);
return ret;
}
API int contacts_db_delete_records(const char* view_uri, int ids[], int count)
{
- int i;
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(view_uri == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "view_uri is NULL");
-
- 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_string(view_uri,indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- ret = ctsvc_ipc_marshal_int(count,indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- for (i=0;i<count;i++) {
- ret = ctsvc_ipc_marshal_int(ids[i],indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- }
-
- if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_DELETE_RECORDS,
- indata, &outdata) != 0) {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata) {
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_delete_records(contact, view_uri, ids, count);
return ret;
}
API int contacts_db_replace_records(contacts_list_h list, int ids[], int count)
{
- int i;
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(NULL == list,CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
- RETVM_IF(NULL == ids, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter");
- RETVM_IF(0 == count, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // 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_list(list, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- ret = ctsvc_ipc_marshal_int(count, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- for (i=0;i<count;i++) {
- ret = ctsvc_ipc_marshal_int(ids[i], indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- }
-
- if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_REPLACE_RECORDS,
- indata, &outdata) != 0) {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata) {
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_replace_records(contact, list, ids, count);
return ret;
}
API int contacts_db_get_changes_by_version(const char* view_uri, int addressbook_id,
int contacts_db_version, contacts_list_h* record_list, int* current_contacts_db_version)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(record_list==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"record_list is NULL");
- *record_list = NULL;
- RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- RETVM_IF(current_contacts_db_version==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"current_contacts_db_version is 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_string(view_uri,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(addressbook_id,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(contacts_db_version,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_DB_MODULE, CTSVC_IPC_SERVER_DB_CHANGES_BY_VERSION, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_list(outdata,record_list);
-
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_int(outdata,current_contacts_db_version);
- }
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_get_changes_by_version(contact, view_uri, addressbook_id, contacts_db_version, record_list, current_contacts_db_version);
return ret;
}
API int contacts_db_get_current_version(int* contacts_db_version)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(contacts_db_version==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"contacts_db_version is null");
- *contacts_db_version = 0;
-
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_CURRENT_VERSION, NULL, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- return CONTACTS_ERROR_IPC;
- }
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_int(outdata,contacts_db_version);
- }
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_get_current_version(contact, contacts_db_version);
return ret;
+
}
API int contacts_db_search_records(const char* view_uri, const char *keyword,
int offset, int limit, contacts_list_h* out_list)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(out_list == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
- *out_list = NULL;
-
- // 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_string(view_uri,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_string(keyword,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(offset,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(limit,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_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_search_records(contact, view_uri, keyword, offset, limit, out_list);
return ret;
}
API int contacts_db_search_records_with_range(const char* view_uri, const char *keyword,
int offset, int limit, int range, contacts_list_h* out_list)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(out_list == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
- *out_list = NULL;
- RETVM_IF(range == 0, CONTACTS_ERROR_INVALID_PARAMETER, "range is 0");
-
- indata = pims_ipc_data_create(0);
- if (indata == NULL) {
- CTS_ERR("ipc data created fail !");
- return CONTACTS_ERROR_OUT_OF_MEMORY;
- }
-
- ret = ctsvc_ipc_marshal_string(view_uri, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- goto DATA_FREE;
- }
- ret = ctsvc_ipc_marshal_string(keyword, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- goto DATA_FREE;
- }
- ret = ctsvc_ipc_marshal_int(offset, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- goto DATA_FREE;
- }
- ret = ctsvc_ipc_marshal_int(limit, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- goto DATA_FREE;
- }
- ret = ctsvc_ipc_marshal_int(range, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("marshal fail");
- goto DATA_FREE;
- }
-
- if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS_WITH_RANGE, indata, &outdata) != 0) {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata) {
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE)
- ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
- return ret;
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_search_records_with_range(contact, view_uri, keyword, offset, limit, range, out_list);
-DATA_FREE:
- pims_ipc_data_destroy(indata);
return ret;
}
API int contacts_db_search_records_with_query(contacts_query_h query, const char *keyword,
int offset, int limit, contacts_list_h* out_list)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(out_list==NULL, CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
- *out_list = NULL;
- RETVM_IF(query==NULL, CONTACTS_ERROR_INVALID_PARAMETER, "query is 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_query(query,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_string(keyword,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(offset,indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(limit,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_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS_WITH_QUERY, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CONTACTS_ERROR_NONE)
- {
- ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_search_records_with_query(contact, query, keyword, offset, limit, out_list);
return ret;
}
API int contacts_db_get_last_change_version(int* last_version)
{
- int ret = CONTACTS_ERROR_NONE;
- bool result = false;
+ int ret;
+ contacts_h contact = NULL;
- RETVM_IF(NULL == last_version, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter");
- *last_version = 0;
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- ret = ctsvc_ipc_client_check_permission(CTSVC_PERMISSION_CONTACT_READ, &result);
- RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
- if (result == false) {
- ret = ctsvc_ipc_client_check_permission(CTSVC_PERMISSION_PHONELOG_READ, &result);
- RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
- RETVM_IF(result == false, CONTACTS_ERROR_PERMISSION_DENIED, "Permission denied");
- }
+ ret = ctsvc_client_db_get_last_change_version(contact, last_version);
- *last_version = ctsvc_client_ipc_get_change_version();
return ret;
}
-typedef struct
+API int contacts_db_get_status(contacts_db_status_e *status)
{
- contacts_db_status_changed_cb cb;
- void *user_data;
-}status_callback_info_s;
+ int ret;
+ contacts_h contact = NULL;
-static GSList *__status_change_subscribe_list = NULL;
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
-static void __ctsvc_db_status_subscriber_callback(pims_ipc_h ipc, pims_ipc_data_h data, void *user_data)
-{
- int status = -1;
- unsigned int size = 0;
- GSList *l;
-
- if (data)
- status = *(int*)pims_ipc_data_get(data, &size);
-
- for (l = __status_change_subscribe_list;l;l=l->next) {
- status_callback_info_s *cb_info = l->data;
- if (cb_info->cb)
- cb_info->cb(status, cb_info->user_data);
- }
-}
-
-API int contacts_db_get_status(contacts_db_status_e *status)
-{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(status == NULL, CONTACTS_ERROR_INVALID_PARAMETER,"The out param is NULL");
- *status = 0;
-
- if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_STATUS, NULL, &outdata) != 0) {
- CTS_ERR("ctsvc_ipc_call Fail");
- return CONTACTS_ERROR_IPC;
- }
-
- if (outdata) {
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
- if (CONTACTS_ERROR_NONE == ret) {
- *status = *(int*) pims_ipc_data_get(outdata, &size);
- }
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_db_get_status(contact, status);
return ret;
}
API int contacts_db_add_status_changed_cb(
contacts_db_status_changed_cb cb, void* user_data)
{
- status_callback_info_s *cb_info = NULL;
- RETVM_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER,
- "Invalid parameter : callback is null");
-
- ctsvc_mutex_lock(CTS_MUTEX_PIMS_IPC_PUBSUB);
-
- if (pims_ipc_subscribe(ctsvc_ipc_get_handle_for_change_subsciption(),
- CTSVC_IPC_SUBSCRIBE_MODULE, CTSVC_IPC_SERVER_DB_STATUS_CHANGED,
- __ctsvc_db_status_subscriber_callback, NULL) != 0) {
- CTS_ERR("pims_ipc_subscribe error\n");
- ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
- return CONTACTS_ERROR_IPC;
- }
-
- cb_info = calloc(1, sizeof(status_callback_info_s));
- cb_info->user_data = user_data;
- cb_info->cb = cb;
- __status_change_subscribe_list = g_slist_append(__status_change_subscribe_list, cb_info);
-
- ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
- return CONTACTS_ERROR_NONE;
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_add_status_changed_cb(contact, cb, user_data);
+
+ return ret;
}
API int contacts_db_remove_status_changed_cb(
contacts_db_status_changed_cb cb, void* user_data)
{
- GSList *l;
-
- RETVM_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER,
- "Invalid parameter : callback is null");
-
- ctsvc_mutex_lock(CTS_MUTEX_PIMS_IPC_PUBSUB);
- for(l = __status_change_subscribe_list;l;l=l->next) {
- status_callback_info_s *cb_info = l->data;
- if (cb == cb_info->cb && user_data == cb_info->user_data) {
- __status_change_subscribe_list = g_slist_remove(__status_change_subscribe_list, cb_info);
- break;
- }
- }
-
- if (g_slist_length(__status_change_subscribe_list) == 0) {
- pims_ipc_unsubscribe(ctsvc_ipc_get_handle_for_change_subsciption(),
- CTSVC_IPC_SUBSCRIBE_MODULE, CTSVC_IPC_SERVER_DB_STATUS_CHANGED);
- g_slist_free(__status_change_subscribe_list);
- __status_change_subscribe_list = NULL;
- }
-
- ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
- return CONTACTS_ERROR_NONE;
+ int ret;
+ contacts_h contact = NULL;
+
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_client_db_remove_status_changed_cb(contact, cb, user_data);
+
+ return ret;
}
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Dohyung Jin <dh.jin@samsung.com>
+ * Jongwon Lee <gogosing.lee@samsung.com>
+ * Donghee Ye <donghee.ye@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 <glib.h>
+#include <pims-ipc.h>
+#include <pims-ipc-data.h>
+
+#include "contacts.h"
+
+#include "ctsvc_internal.h"
+#include "ctsvc_list.h"
+#include "ctsvc_record.h"
+#include "ctsvc_inotify.h"
+#include "ctsvc_ipc_define.h"
+#include "ctsvc_ipc_marshal.h"
+#include "ctsvc_view.h"
+#include "ctsvc_client_ipc.h"
+#include "ctsvc_mutex.h"
+#include "ctsvc_handle.h"
+#include "ctsvc_client_db_helper.h"
+
+int ctsvc_client_db_insert_record(contacts_h contact, contacts_record_h record, int *id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ if (id)
+ *id = 0;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(record==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"record is 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_handle(contact, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ 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_DB_MODULE, CTSVC_IPC_SERVER_DB_INSERT_RECORD, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+
+ if (id)
+ *id = *(int*)pims_ipc_data_get(outdata,&size);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_get_record(contacts_h contact, const char* view_uri, int id, contacts_record_h* out_record)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ RETVM_IF(id<0,CONTACTS_ERROR_INVALID_PARAMETER,"id<0");
+ RETVM_IF(out_record==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"record is NULL");
+ *out_record = 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_handle(contact, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_string(view_uri,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(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_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_RECORD, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE)
+ {
+ ret = ctsvc_ipc_unmarshal_record(outdata,out_record);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_update_record(contacts_h contact, contacts_record_h record)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(record==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"record is 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_handle(contact, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ 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_DB_MODULE, CTSVC_IPC_SERVER_DB_UPDATE_RECORD, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (CONTACTS_ERROR_NONE == ret) {
+ CTSVC_RECORD_RESET_PROPERTY_FLAGS((ctsvc_record_s *)record);
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_delete_record(contacts_h contact, const char* view_uri, int id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ RETVM_IF(id<=0,CONTACTS_ERROR_INVALID_PARAMETER,"id <= 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_string(view_uri,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(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_DB_MODULE, CTSVC_IPC_SERVER_DB_DELETE_RECORD, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_replace_record(contacts_h contact, contacts_record_h record, int id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact,CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter : record is 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ 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;
+ }
+ ret = ctsvc_ipc_marshal_int(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_DB_MODULE,
+ CTSVC_IPC_SERVER_DB_REPLACE_RECORD, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_get_all_records(contacts_h contact, const char* view_uri, int offset, int limit, contacts_list_h* out_list)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(NULL == out_list,CONTACTS_ERROR_INVALID_PARAMETER,"list is NULL");
+ *out_list = NULL;
+ RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_string(view_uri,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(offset,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(limit,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_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_ALL_RECORDS, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+ return ret;
+}
+
+int ctsvc_client_db_get_records_with_query(contacts_h contact, contacts_query_h query, int offset, int limit, contacts_list_h* out_list)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(NULL == out_list,CONTACTS_ERROR_INVALID_PARAMETER,"list is NULL");
+ *out_list = NULL;
+ RETVM_IF(NULL == query,CONTACTS_ERROR_INVALID_PARAMETER,"query is 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_query(query,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_int(offset,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(limit,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ return ret;
+ }
+
+ /* ipc call */
+ if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_RECORDS_WITH_QUERY, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+
+int ctsvc_client_db_get_count(contacts_h contact, const char* view_uri, int *out_count)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ RETVM_IF(out_count==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"count pointer is NULL");
+ *out_count = 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_string(view_uri,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_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_COUNT, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ ret = ctsvc_ipc_unmarshal_int(outdata,out_count);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_get_count_with_query(contacts_h contact, contacts_query_h query, int *out_count)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(NULL == query,CONTACTS_ERROR_INVALID_PARAMETER,"record is NULL");
+ RETVM_IF(out_count==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"count pointer is NULL");
+ *out_count = 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_query(query,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_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_COUNT_WITH_QUERY, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ ret = ctsvc_ipc_unmarshal_int(outdata,out_count);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_insert_records(contacts_h contact, contacts_list_h list, int **ids, int *count)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ if (ids)
+ *ids = NULL;
+ if (count)
+ *count = 0;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(list==NULL,CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
+
+ 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_list(list,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_INSERT_RECORDS,
+ indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+
+ if (ids && count) {
+ int i = 0;
+ int *id = NULL;
+ int c;
+ c = *(int*)pims_ipc_data_get(outdata, &size);
+ id = calloc(c, sizeof(int));
+ for(i=0;i<c;i++)
+ id[i] = *(int*) pims_ipc_data_get(outdata, &size);
+ *ids = id;
+ *count = c;
+ }
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_update_records(contacts_h contact, contacts_list_h list)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contct is NULL");
+ RETVM_IF(NULL == list, CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
+
+ 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_list(list,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_UPDATE_RECORDS,
+ indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_delete_records(contacts_h contact, const char* view_uri, int ids[], int count)
+{
+ int i;
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(view_uri == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "view_uri is NULL");
+
+ 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_string(view_uri,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_int(count,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ for (i=0;i<count;i++) {
+ ret = ctsvc_ipc_marshal_int(ids[i],indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ }
+
+ if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_DELETE_RECORDS,
+ indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_replace_records(contacts_h contact, contacts_list_h list, int ids[], int count)
+{
+ int i;
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact,CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(NULL == list,CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
+ RETVM_IF(NULL == ids, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ RETVM_IF(0 == count, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ /* 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_list(list, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_int(count, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ for (i=0;i<count;i++) {
+ ret = ctsvc_ipc_marshal_int(ids[i], indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ }
+
+ if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_REPLACE_RECORDS,
+ indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_get_changes_by_version(contacts_h contact, const char* view_uri, int addressbook_id, int contacts_db_version, contacts_list_h* record_list, int* current_contacts_db_version)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(record_list==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"record_list is NULL");
+ *record_list = NULL;
+ RETVM_IF(view_uri==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ RETVM_IF(current_contacts_db_version==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"current_contacts_db_version is 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_string(view_uri,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(addressbook_id,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(contacts_db_version,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_DB_MODULE, CTSVC_IPC_SERVER_DB_CHANGES_BY_VERSION, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ ret = ctsvc_ipc_unmarshal_list(outdata,record_list);
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ ret = ctsvc_ipc_unmarshal_int(outdata,current_contacts_db_version);
+ }
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_get_current_version(contacts_h contact, int* contacts_db_version)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is null");
+ RETVM_IF(contacts_db_version==NULL,CONTACTS_ERROR_INVALID_PARAMETER,"contacts_db_version is null");
+ *contacts_db_version = 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ /* ipc call */
+ if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_CURRENT_VERSION, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (ret == CONTACTS_ERROR_NONE) {
+ ret = ctsvc_ipc_unmarshal_int(outdata,contacts_db_version);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_search_records(contacts_h contact, const char* view_uri, const char *keyword,
+ int offset, int limit, contacts_list_h* out_list)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(out_list == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
+ *out_list = NULL;
+
+ /* make indata */
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL) {
+ CTS_ERR("pims_ipc_data_create() Fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_string(view_uri,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_string(keyword,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(offset,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(limit,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_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE)
+ {
+ ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_search_records_with_range(contacts_h contact, const char* view_uri, const char *keyword,
+ int offset, int limit, int range, contacts_list_h* out_list)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(contact == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(out_list == NULL, CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
+ RETVM_IF(range == 0, CONTACTS_ERROR_INVALID_PARAMETER, "range is 0");
+ *out_list = NULL;
+
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL) {
+ CTS_ERR("pims_ipc_data_create() Fail");
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ ret = ctsvc_ipc_marshal_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_string(view_uri, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_string() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_string(keyword, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_string() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(offset, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(limit, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(range, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_int() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ if (0 != ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS_WITH_RANGE, indata, &outdata)) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE)
+ ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_search_records_with_query(contacts_h contact, contacts_query_h query, const char *keyword,
+ int offset, int limit, contacts_list_h* out_list)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(NULL == out_list, CONTACTS_ERROR_INVALID_PARAMETER, "list is NULL");
+ RETVM_IF(NULL == query, CONTACTS_ERROR_INVALID_PARAMETER, "query is NULL");
+ *out_list = NULL;
+
+ /* make indata */
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL) {
+ CTS_ERR("pims_ipc_data_create() Fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_query(query,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_string(keyword,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(offset,indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(limit,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_DB_MODULE, CTSVC_IPC_SERVER_DB_SEARCH_RECORDS_WITH_QUERY, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CONTACTS_ERROR_NONE) {
+ ret = ctsvc_ipc_unmarshal_list(outdata,out_list);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_get_last_change_version(contacts_h contact, int* last_version)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ bool result = false;
+
+ RETVM_IF(NULL == last_version, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ *last_version = 0;
+
+ ret = ctsvc_ipc_client_check_permission(CTSVC_PERMISSION_CONTACT_READ, &result);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ if (result == false) {
+ ret = ctsvc_ipc_client_check_permission(CTSVC_PERMISSION_PHONELOG_READ, &result);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ RETVM_IF(result == false, CONTACTS_ERROR_PERMISSION_DENIED, "Permission denied");
+ }
+
+ *last_version = ctsvc_client_ipc_get_change_version(contact);
+ return ret;
+}
+
+typedef struct
+{
+ contacts_db_status_changed_cb cb;
+ void *user_data;
+}status_callback_info_s;
+
+static GSList *__status_change_subscribe_list = NULL;
+
+static void __ctsvc_client_db_free_cb_info(status_callback_info_s *cb_info)
+{
+ if (NULL == cb_info)
+ return;
+ free(cb_info);
+}
+
+static void __ctsvc_db_status_subscriber_callback(pims_ipc_h ipc, pims_ipc_data_h data, void *user_data)
+{
+ int ret;
+ int status = -1;
+ GSList *l;
+
+ if (data) {
+ ret = ctsvc_ipc_unmarshal_int(data, &status);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
+ }
+
+ for (l = __status_change_subscribe_list;l;l=l->next) {
+ status_callback_info_s *cb_info = l->data;
+ /* TODO: Fixme - check zone_name */
+ if (cb_info->cb)
+ cb_info->cb(status, cb_info->user_data);
+ }
+}
+
+int ctsvc_client_db_get_status(contacts_h contact, contacts_db_status_e *status)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h outdata = NULL;
+ pims_ipc_data_h indata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(status == NULL, CONTACTS_ERROR_INVALID_PARAMETER,"The out param is NULL");
+ *status = 0;
+
+ /* make indata */
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL) {
+ CTS_ERR("pims_ipc_data_create() Fail");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ if (ctsvc_ipc_call(CTSVC_IPC_DB_MODULE, CTSVC_IPC_SERVER_DB_GET_STATUS, indata, &outdata) != 0) {
+ pims_ipc_data_destroy(indata);
+ CTS_ERR("ctsvc_ipc_call failed");
+ return CONTACTS_ERROR_IPC;
+ }
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+ if (CONTACTS_ERROR_NONE == ret) {
+ *status = *(int*) pims_ipc_data_get(outdata, &size);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_db_add_status_changed_cb(contacts_h contact,
+ contacts_db_status_changed_cb cb, void* user_data)
+{
+ status_callback_info_s *cb_info = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : callback is null");
+
+ ctsvc_mutex_lock(CTS_MUTEX_PIMS_IPC_PUBSUB);
+
+ if (pims_ipc_subscribe(ctsvc_ipc_get_handle_for_change_subsciption(),
+ CTSVC_IPC_SUBSCRIBE_MODULE, CTSVC_IPC_SERVER_DB_STATUS_CHANGED,
+ __ctsvc_db_status_subscriber_callback, NULL) != 0) {
+ CTS_ERR("pims_ipc_subscribe error\n");
+ ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ cb_info = calloc(1, sizeof(status_callback_info_s));
+ if (NULL == cb_info) {
+ CTS_ERR("calloc() Fail");
+ ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ cb_info->user_data = user_data;
+ cb_info->cb = cb;
+ __status_change_subscribe_list = g_slist_append(__status_change_subscribe_list, cb_info);
+
+ ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_client_db_remove_status_changed_cb(contacts_h contact,
+ contacts_db_status_changed_cb cb, void* user_data)
+{
+ GSList *l;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : callback is null");
+
+ ctsvc_mutex_lock(CTS_MUTEX_PIMS_IPC_PUBSUB);
+ for (l = __status_change_subscribe_list;l;l=l->next) {
+ status_callback_info_s *cb_info = l->data;
+ if (cb == cb_info->cb && user_data == cb_info->user_data) {
+ __status_change_subscribe_list = g_slist_remove(__status_change_subscribe_list, cb_info);
+ __ctsvc_client_db_free_cb_info(cb_info);
+ break;
+ }
+ }
+
+ if (g_slist_length(__status_change_subscribe_list) == 0) {
+ pims_ipc_unsubscribe(ctsvc_ipc_get_handle_for_change_subsciption(),
+ CTSVC_IPC_SUBSCRIBE_MODULE, CTSVC_IPC_SERVER_DB_STATUS_CHANGED);
+ g_slist_free(__status_change_subscribe_list);
+ __status_change_subscribe_list = NULL;
+ }
+
+ ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
+ return CONTACTS_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CTSVC_CLIENT_DB_HELPER_H__
+#define __CTSVC_CLIENT_DB_HELPER_H__
+
+#include "contacts_types.h"
+
+int ctsvc_client_db_insert_record(contacts_h contact, contacts_record_h record, int *id);
+int ctsvc_client_db_get_record(contacts_h contact, const char* view_uri, int id, contacts_record_h* out_record);
+int ctsvc_client_db_update_record(contacts_h contact, contacts_record_h record);
+int ctsvc_client_db_delete_record(contacts_h contact, const char* view_uri, int id);
+int ctsvc_client_db_replace_record(contacts_h contact, contacts_record_h record, int id);
+int ctsvc_client_db_get_all_records(contacts_h contact, const char* view_uri, int offset, int limit, contacts_list_h* out_list);
+int ctsvc_client_db_get_records_with_query(contacts_h contact, contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
+int ctsvc_client_db_get_count(contacts_h contact, const char* view_uri, int *out_count);
+int ctsvc_client_db_get_count_with_query(contacts_h contact, contacts_query_h query, int *out_count);
+int ctsvc_client_db_insert_records(contacts_h contact, contacts_list_h list, int **ids, int *count);
+int ctsvc_client_db_update_records(contacts_h contact, contacts_list_h list);
+int ctsvc_client_db_delete_records(contacts_h contact, const char* view_uri, int ids[], int count);
+int ctsvc_client_db_replace_records(contacts_h contact, contacts_list_h list, int ids[], int count);
+int ctsvc_client_db_get_changes_by_version(contacts_h contact, const char* view_uri, int addressbook_id, int ctsvc_client_db_version, contacts_list_h* record_list, int* current_ctsvc_client_db_version);
+int ctsvc_client_db_get_current_version(contacts_h contact, int* ctsvc_client_db_version);
+int ctsvc_client_db_search_records(contacts_h contact, const char* view_uri, const char *keyword, int offset, int limit, contacts_list_h* out_list);
+int ctsvc_client_db_search_records_with_range(contacts_h contact, const char* view_uri, const char *keyword, int offset, int limit, int range, contacts_list_h* out_list);
+int ctsvc_client_db_search_records_with_query(contacts_h contact, contacts_query_h query, const char *keyword, int offset, int limit, contacts_list_h* out_list);
+int ctsvc_client_db_get_last_change_version(contacts_h contact, int* last_version);
+int ctsvc_client_db_get_status(contacts_h contact, contacts_db_status_e *status);
+int ctsvc_client_db_add_status_changed_cb(contacts_h contact, contacts_db_status_changed_cb cb, void* user_data);
+int ctsvc_client_db_remove_status_changed_cb(contacts_h contact, contacts_db_status_changed_cb cb, void* user_data);
+
+#endif /* __CTSVC_CLIENT_DB_HELPER_H__ */
\ No newline at end of file
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 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.
#include "contacts.h"
#include "ctsvc_internal.h"
#include "ctsvc_inotify.h"
+#include "ctsvc_client_handle.h"
API int contacts_db_add_changed_cb(const char* view_uri, contacts_db_changed_cb cb,
void* user_data)
{
int ret;
+ contacts_h contact = NULL;
RETVM_IF(NULL == view_uri, CONTACTS_ERROR_INVALID_PARAMETER,
"Invalid parameter : view_uri is null");
RETVM_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER,
"Invalid parameter : callback is null");
- ret = ctsvc_inotify_subscribe(view_uri, cb, user_data);
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_inotify_subscribe(contact, view_uri, cb, user_data);
RETVM_IF(CONTACTS_ERROR_NONE != ret, ret,
"ctsvc_inotify_subscribe(%s) Fail(%d)", view_uri, ret);
void* user_data)
{
int ret;
+ contacts_h contact = NULL;
RETVM_IF(NULL == view_uri, CONTACTS_ERROR_INVALID_PARAMETER,
"Invalid parameter : view_uri is null");
RETVM_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER,
"Invalid parameter : callback is null");
- ret = ctsvc_inotify_unsubscribe(view_uri, cb, user_data);
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+
+ ret = ctsvc_inotify_unsubscribe(contact, view_uri, cb, user_data);
RETVM_IF(CONTACTS_ERROR_NONE != ret, ret,
"ctsvc_inotify_unsubscribe(%s) Fail(%d)", view_uri, ret);
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 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.
*
*/
-#include <glib.h>
-
#include "contacts.h"
#include "ctsvc_internal.h"
-#include "ctsvc_ipc_define.h"
-#include "ctsvc_client_ipc.h"
-#include <pims-ipc-data.h>
-#include "ctsvc_ipc_marshal.h"
+#include "ctsvc_client_handle.h"
+#include "ctsvc_client_group_helper.h"
API int contacts_group_add_contact(int group_id, int contact_id)
{
- int ret = CONTACTS_ERROR_NONE;
-
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(group_id <= 0 || contact_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(group_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(contact_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_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_ADD_CONTACT, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
+ int ret;
+ contacts_h contact = NULL;
- pims_ipc_data_destroy(indata);
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_group_add_contact(contact, group_id, contact_id);
return ret;
}
API int contacts_group_remove_contact(int group_id, int contact_id)
{
- int ret = CONTACTS_ERROR_NONE;
-
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(group_id <= 0 || contact_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(group_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(contact_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
+ int ret;
+ contacts_h contact = NULL;
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_REMOVE_CONTACT, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_group_remove_contact(contact, group_id, contact_id);
return ret;
}
API int contacts_group_set_group_order(int group_id, int previous_group_id, int next_group_id)
{
- int ret = CONTACTS_ERROR_NONE;
-
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(group_id <= 0 || previous_group_id < 0 || next_group_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;
- }
+ int ret;
+ contacts_h contact = NULL;
- ret = ctsvc_ipc_marshal_int(group_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(previous_group_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(next_group_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_SET_GROUP_ORDER, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_group_set_group_order(contact, group_id, previous_group_id, next_group_id);
return ret;
-
}
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2015 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_client_ipc.h"
+#include <pims-ipc-data.h>
+#include "ctsvc_ipc_marshal.h"
+
+
+static const char CONTACTS_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.read";
+static const char CONTACTS_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.write";
+static const char PHONELOG_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.read";
+static const char PHONELOG_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.write";
+
+int ctsvc_client_group_add_contact(contacts_h contact, int group_id, int contact_id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(group_id <= 0 || contact_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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_int(group_id, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(contact_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_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_ADD_CONTACT, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_group_remove_contact(contacts_h contact, int group_id, int contact_id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(group_id <= 0 || contact_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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+
+ ret = ctsvc_ipc_marshal_int(group_id, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(contact_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_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_REMOVE_CONTACT, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_group_set_group_order(contacts_h contact, int group_id, int previous_group_id, int next_group_id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(group_id <= 0 || previous_group_id < 0 || next_group_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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_int(group_id, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(previous_group_id, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(next_group_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_GROUP_MODULE, CTSVC_IPC_SERVER_GROUP_SET_GROUP_ORDER, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+
+}
+
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CTSVC_CLIENT_GROUP_HELPER_H__
+#define __CTSVC_CLIENT_GROUP_HELPER_H__
+
+#include "contacts_types.h"
+
+int ctsvc_client_group_add_contact(contacts_h contact, int group_id, int contact_id);
+int ctsvc_client_group_remove_contact(contacts_h contact, int group_id, int contact_id);
+int ctsvc_client_group_set_group_order(contacts_h contact, int group_id, int previous_group_id, int next_group_id);
+
+#endif /* __CTSVC_CLIENT_GROUP_HELPER_H__ */
+
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2015 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 <unistd.h>
+#include <pthread.h>
+#include <glib.h>
+
+#include "ctsvc_internal.h"
+#include "ctsvc_handle.h"
+#include "ctsvc_mutex.h"
+#include "ctsvc_client_handle.h"
+
+static GHashTable *_ctsvc_handle_table = NULL;
+
+static int _ctsvc_client_handle_get_key(char *key, int key_len)
+{
+ int ret;
+ int len;
+
+ ret = gethostname(key, key_len);
+ RETVM_IF(0 != ret, CONTACTS_ERROR_SYSTEM, "gethostname() Failed(%d)", errno);
+
+ len = strlen(key);
+ snprintf(key+len, key_len-len, ":%d", (int)pthread_self());
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_client_handle_get_current_p(contacts_h *p_contact)
+{
+ int ret;
+ char key[CTSVC_STR_SHORT_LEN] = {0};
+ contacts_h contact = NULL;
+
+ RETVM_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NO_DATA, "_ctsvc_handle_table is NULL");
+
+ ret = _ctsvc_client_handle_get_key(key, sizeof(key));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+
+ ctsvc_mutex_lock(CTS_MUTEX_HANDLE);
+ contact = g_hash_table_lookup(_ctsvc_handle_table, key);
+ ctsvc_mutex_unlock(CTS_MUTEX_HANDLE);
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_NO_DATA, "g_hash_table_lookup() return NULL");
+
+ *p_contact = contact;
+ return CONTACTS_ERROR_NONE;
+}
+
+static int _ctsvc_client_handle_add(contacts_h contact)
+{
+ int ret;
+ char key[CTSVC_STR_SHORT_LEN] = {0};
+
+ if (NULL == _ctsvc_handle_table)
+ _ctsvc_handle_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
+
+ ret = _ctsvc_client_handle_get_key(key, sizeof(key));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+
+ g_hash_table_insert(_ctsvc_handle_table, strdup(key), contact);
+
+ ctsvc_mutex_unlock(CTS_MUTEX_HANDLE);
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_client_handle_create(contacts_h *p_contact)
+{
+ int ret;
+ contacts_h contact = NULL;
+
+ RETVM_IF(NULL == p_contact, CONTACTS_ERROR_INVALID_PARAMETER, "p_contact is NULL");
+ *p_contact = NULL;
+
+ ret = ctsvc_handle_create(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_handle_create() Fail(%d)", ret);
+
+ ret = _ctsvc_client_handle_add(contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("_ctsvc_client_handle_add() Fail(%d)", ret);
+ ctsvc_handle_destroy(contact);
+ return ret;
+ }
+
+ *p_contact = contact;
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_client_handle_remove(contacts_h contact)
+{
+ int ret;
+ char key[CTSVC_STR_SHORT_LEN] = {0};
+ RETVM_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NONE, "_ctsvc_handle_table is NULL");
+
+ ret = _ctsvc_client_handle_get_key(key, sizeof(key));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+
+ ctsvc_mutex_lock(CTS_MUTEX_HANDLE);
+ g_hash_table_remove(_ctsvc_handle_table, key);
+ if (0 == g_hash_table_size(_ctsvc_handle_table)) {
+ g_hash_table_destroy(_ctsvc_handle_table);
+ _ctsvc_handle_table = NULL;
+ }
+ ctsvc_mutex_unlock(CTS_MUTEX_HANDLE);
+ ctsvc_handle_destroy(contact);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CTSVC_CLIENT_HANDLE_H__
+#define __CTSVC_CLIENT_HANDLE_H__
+#include "contacts_types.h"
+
+int ctsvc_client_handle_get_current_p(contacts_h *p_contact);
+int ctsvc_client_handle_remove(contacts_h contact);
+int ctsvc_client_handle_create(contacts_h *p_contact);
+
+#endif /* __CTSVC_CLIENT_HANDLE_H__ */
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 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.
*
*/
-#include <glib.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <glib.h>
#include <pims-ipc-data.h>
#include "ctsvc_client_ipc.h"
#include "ctsvc_ipc_marshal.h"
#include "ctsvc_view.h"
#include "ctsvc_mutex.h"
+#include "ctsvc_handle.h"
static __thread pims_ipc_h __contacts_ipc = NULL;
static pims_ipc_h __contacts_global_ipc = NULL;
-static __thread int __contacts_change_version = 0;
-static int __contacts_global_change_version = 0;
-
-int ctsvc_ipc_connect_on_thread(void)
+int ctsvc_ipc_connect_on_thread(contacts_h contact)
{
int ret = CONTACTS_ERROR_NONE;
pims_ipc_data_h outdata = NULL;
}
}
}
- else {
- CTS_DBG("contacts already connected");
- return CONTACTS_ERROR_NONE;
- }
+
// ipc call
if (pims_ipc_call(__contacts_ipc, CTSVC_IPC_MODULE, CTSVC_IPC_SERVER_CONNECT, NULL, &outdata) != 0) {
return ret;
}
-int ctsvc_ipc_disconnect_on_thread(void)
+int ctsvc_ipc_disconnect_on_thread(contacts_h contact, int connection_count)
{
int ret = CONTACTS_ERROR_NONE;
pims_ipc_data_h outdata = NULL;
if (ret != CONTACTS_ERROR_NONE)
CTS_ERR("[GLOBAL_IPC_CHANNEL] pims_ipc didn't destroyed!!!(%d)", ret);
- pims_ipc_destroy(__contacts_ipc);
- __contacts_ipc = NULL;
+ if (1 == connection_count) {
+ pims_ipc_destroy(__contacts_ipc);
+ __contacts_ipc = NULL;
+ }
}
else {
CTS_ERR("pims_ipc_call out data is NULL");
return ret;
}
-int ctsvc_ipc_connect(void)
+int ctsvc_ipc_connect(contacts_h contact)
{
int ret = CONTACTS_ERROR_NONE;
pims_ipc_data_h outdata = NULL;
}
}
}
- else {
- CTS_DBG("[GLOBAL_IPC_CHANNEL] contacts already connected");
- return CONTACTS_ERROR_NONE;
- }
/* ipc call */
if (pims_ipc_call(__contacts_global_ipc, CTSVC_IPC_MODULE, CTSVC_IPC_SERVER_CONNECT, NULL, &outdata) != 0) {
goto DATA_FREE;
}
}
+
return ret;
DATA_FREE:
}
-int ctsvc_ipc_disconnect(void)
+int ctsvc_ipc_disconnect(contacts_h contact, int connection_count)
{
int ret = CONTACTS_ERROR_NONE;
pims_ipc_data_h outdata = NULL;
return ret;
}
- pims_ipc_destroy(__contacts_global_ipc);
- __contacts_global_ipc = NULL;
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+ base->connection_count--;
+
+ if (1 == connection_count) {
+ pims_ipc_destroy(__contacts_global_ipc);
+ __contacts_global_ipc = NULL;
+ }
}
else {
CTS_ERR("pims_ipc_call out data is NULL");
return ret;
}
-void ctsvc_client_ipc_set_change_version(int version)
+void ctsvc_client_ipc_set_change_version(contacts_h contact, int version)
{
- if (__contacts_ipc == NULL) {
- __contacts_global_change_version = version;
- CTS_DBG("change_version = %d", version);
- return;
- }
- __contacts_change_version = version;
- CTS_DBG("change_version = %d", version);
+ RETM_IF(NULL == contact, "contact is NULL");
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+ base->version = version;
}
-int ctsvc_client_ipc_get_change_version(void)
+int ctsvc_client_ipc_get_change_version(contacts_h contact)
{
- if (__contacts_ipc == NULL)
- return __contacts_global_change_version;
-
- return __contacts_change_version;
+ RETVM_IF(NULL == contact, -1, "contact is NULL");
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+ return base->version;
}
int ctsvc_ipc_client_check_permission(int permission, bool *result)
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 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.
#define __CTSVC_CLIENT_IPC_H__
#include <pims-ipc.h>
+#include "contacts_types.h"
pims_ipc_h ctsvc_get_ipc_handle();
-int ctsvc_ipc_connect(void);
-int ctsvc_ipc_disconnect(void);
+int ctsvc_ipc_connect(contacts_h contact);
+int ctsvc_ipc_disconnect(contacts_h contact, int connection_count);
-int ctsvc_ipc_connect_on_thread(void);
-int ctsvc_ipc_disconnect_on_thread(void);
+int ctsvc_ipc_connect_on_thread(contacts_h contact);
+int ctsvc_ipc_disconnect_on_thread(contacts_h contact, int connection_count);
bool ctsvc_ipc_is_busy();
int ctsvc_ipc_call(char *module, char *function, pims_ipc_h data_in, pims_ipc_data_h *data_out);
-void ctsvc_client_ipc_set_change_version(int version);
-int ctsvc_client_ipc_get_change_version(void);
+void ctsvc_client_ipc_set_change_version(contacts_h contact, int version);
+int ctsvc_client_ipc_get_change_version(contacts_h contact);
int ctsvc_ipc_client_check_permission(int permission, bool *result);
*
*/
+#include <stdio.h>
+#include <unistd.h>
#include <pims-ipc.h>
#include <pims-ipc-svc.h>
#include <pims-ipc-data.h>
#include "contacts.h"
#include "ctsvc_internal.h"
#include "ctsvc_ipc_define.h"
+#include "ctsvc_ipc_marshal.h"
#include "ctsvc_mutex.h"
#include "ctsvc_client_ipc.h"
#include "contacts_extension.h"
static void __ctsvc_db_subscriber_callback(pims_ipc_h ipc, pims_ipc_data_h data, void *user_data)
{
- unsigned int size = 0;
+ int ret;
char *str = NULL;
subscribe_info_s *info = user_data;
- if (data)
- str = (char*)pims_ipc_data_get(data, &size);
+ if (data) {
+ ret = ctsvc_ipc_unmarshal_string(data, &str);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_ipc_unmarshal_string() Fail(%d)", ret);
+ }
if (NULL == str) {
CTS_ERR("There is no changed data");
- return;
+ goto DATA_FREE;
}
if (info) {
}
}
}
+DATA_FREE:
+ free(str);
}
/* This API should be called in CTS_MUTEX_PIMS_IPC_PUBSUB mutex */
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 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.
*
*/
-#include <glib.h>
-#include <pims-ipc-data.h>
-
#include "contacts.h"
#include "ctsvc_internal.h"
-#include "ctsvc_ipc_define.h"
-#include "ctsvc_client_ipc.h"
-#include "ctsvc_ipc_marshal.h"
+#include "ctsvc_client_handle.h"
+#include "ctsvc_client_person_helper.h"
API int contacts_person_link_person(int base_person_id, int person_id)
{
+ int ret;
+ contacts_h contact = NULL;
- int ret = CONTACTS_ERROR_NONE;
-
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(base_person_id <= 0 || 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!");
- return CONTACTS_ERROR_OUT_OF_MEMORY;
- }
-
- bool success = false;
- do {
- if (ctsvc_ipc_marshal_int(base_person_id, indata) != CONTACTS_ERROR_NONE) break;
- if (ctsvc_ipc_marshal_int(person_id, indata) != CONTACTS_ERROR_NONE) break;
-
- success = true;
- } while(0);
-
- if (success == false) {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
-/*
- ret = ctsvc_ipc_marshal_int(base_person_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(person_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- return ret;
- }
-*/
-
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_LINK_PERSON, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_person_link_person(contact, base_person_id, person_id);
return ret;
}
API int contacts_person_unlink_contact(int person_id, int contact_id, int* unlinked_person_id)
{
- int ret = CONTACTS_ERROR_NONE;
+ int ret;
+ contacts_h contact = NULL;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- RETVM_IF(person_id <= 0 || contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
-
- if (unlinked_person_id)
- *unlinked_person_id = 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;
- }
- ret = ctsvc_ipc_marshal_int(contact_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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_UNLINK_CONTACT, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
-
- if (unlinked_person_id)
- *unlinked_person_id = *(int*)pims_ipc_data_get(outdata,&size);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_person_unlink_contact(contact, person_id, contact_id, unlinked_person_id);
return ret;
+
}
API int contacts_person_reset_usage(int person_id, contacts_usage_type_e type)
{
- 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,"contact_id should be greater than 0");
+ int ret;
+ contacts_h contact = 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_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", 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;
- }
- ret = ctsvc_ipc_marshal_int((int)type, 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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_RESET_USAGE, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_person_reset_usage(contact, person_id, type);
return ret;
}
API int contacts_person_set_favorite_order(int person_id, int previous_person_id, int next_person_id)
{
- int ret = CONTACTS_ERROR_NONE;
-
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(person_id <= 0 || previous_person_id < 0 || next_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;
- }
- ret = ctsvc_ipc_marshal_int(previous_person_id, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(next_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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_SET_FAVORITE_ORDER, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
+ int ret;
+ contacts_h contact = NULL;
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_person_set_favorite_order(contact, person_id, previous_person_id, next_person_id);
return ret;
-
}
API int contacts_person_set_default_property(contacts_person_property_e property,
int person_id, int id)
{
- int ret = CONTACTS_ERROR_NONE;
-
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(person_id <= 0 || 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;
- }
- ret = ctsvc_ipc_marshal_unsigned_int(property, indata);
- if (ret != CONTACTS_ERROR_NONE)
- {
- CTS_ERR("marshal fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- ret = ctsvc_ipc_marshal_int(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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_SET_DEFAULT_PROPERTY, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
+ int ret;
+ contacts_h contact = NULL;
- pims_ipc_data_destroy(indata);
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_person_set_default_property(contact, property, person_id, id);
return ret;
}
API int contacts_person_get_default_property(contacts_person_property_e property,
int person_id, int *id)
{
- int ret = CONTACTS_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- RETVM_IF(person_id <= 0 || id == NULL, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
- *id = 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;
- }
-
- ret = ctsvc_ipc_marshal_unsigned_int(property, 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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_GET_DEFAULT_PROPERTY,
- indata, &outdata) != 0) {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
+ int ret;
+ contacts_h contact = NULL;
- pims_ipc_data_destroy(indata);
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- if (outdata) {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
- if (ret == CONTACTS_ERROR_NONE) {
- if (id)
- *id = *(int*)pims_ipc_data_get(outdata,&size);
- }
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_person_get_default_property(contact, property, person_id, id);
return ret;
}
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2015 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 <pims-ipc-data.h>
+
+#include "contacts.h"
+#include "ctsvc_internal.h"
+#include "ctsvc_ipc_define.h"
+#include "ctsvc_client_ipc.h"
+#include "ctsvc_ipc_marshal.h"
+
+static const char CONTACTS_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.read";
+static const char CONTACTS_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.write";
+static const char PHONELOG_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.read";
+static const char PHONELOG_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.write";
+
+int ctsvc_client_person_link_person(contacts_h contact, int base_person_id, int person_id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(base_person_id <= 0 || 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!");
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ ret = ctsvc_ipc_marshal_handle(contact, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_handle Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ bool success = false;
+ do {
+ if (ctsvc_ipc_marshal_int(base_person_id, indata) != CONTACTS_ERROR_NONE) break;
+ if (ctsvc_ipc_marshal_int(person_id, indata) != CONTACTS_ERROR_NONE) break;
+
+ success = true;
+ } while (0);
+
+ if (success == false) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+/*
+ ret = ctsvc_ipc_marshal_int(base_person_id, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(person_id, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ return ret;
+ }
+*/
+
+ /* ipc call */
+ if (ctsvc_ipc_call(CTSVC_IPC_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_LINK_PERSON, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_person_unlink_contact(contacts_h contact, int person_id, int contact_id, int* unlinked_person_id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(person_id <= 0 || contact_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
+
+ if (unlinked_person_id)
+ *unlinked_person_id = 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_handle(contact, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_handle Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ 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;
+ }
+ ret = ctsvc_ipc_marshal_int(contact_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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_UNLINK_CONTACT, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+
+ if (unlinked_person_id)
+ *unlinked_person_id = *(int*)pims_ipc_data_get(outdata,&size);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_person_reset_usage(contacts_h contact, int person_id, contacts_usage_type_e type)
+{
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(person_id <= 0, CONTACTS_ERROR_INVALID_PARAMETER,"contact_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_handle(contact, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_handle Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ 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;
+ }
+ ret = ctsvc_ipc_marshal_int((int)type, 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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_RESET_USAGE, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_person_set_favorite_order(contacts_h contact, int person_id, int previous_person_id, int next_person_id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(person_id <= 0 || previous_person_id < 0 || next_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_handle(contact, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_handle Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ 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;
+ }
+ ret = ctsvc_ipc_marshal_int(previous_person_id, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(next_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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_SET_FAVORITE_ORDER, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+
+}
+
+int ctsvc_client_person_set_default_property(contacts_h contact, contacts_person_property_e property,
+ int person_id, int id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(person_id <= 0 || 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_handle(contact, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_handle Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ 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;
+ }
+ ret = ctsvc_ipc_marshal_unsigned_int(property, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ ret = ctsvc_ipc_marshal_int(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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_SET_DEFAULT_PROPERTY, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+int ctsvc_client_person_get_default_property(contacts_h contact, contacts_person_property_e property,
+ int person_id, int *id)
+{
+ int ret = CONTACTS_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+ RETVM_IF(person_id <= 0 || id == NULL, CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
+ *id = 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_handle(contact, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_handle Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ 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;
+ }
+
+ ret = ctsvc_ipc_marshal_unsigned_int(property, 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_PERSON_MODULE, CTSVC_IPC_SERVER_PERSON_GET_DEFAULT_PROPERTY,
+ indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+ if (ret == CONTACTS_ERROR_NONE) {
+ if (id)
+ *id = *(int*)pims_ipc_data_get(outdata,&size);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CTSVC_CLIENT_PERSON_HELPER_H__
+#define __CTSVC_CLIENT_PERSON_HELPER_H__
+
+#include "contacts_types.h"
+
+int ctsvc_client_person_link_person(contacts_h contact, int base_person_id, int person_id);
+int ctsvc_client_person_unlink_contact(contacts_h contact, int person_id, int contact_id, int* unlinked_person_id);
+int ctsvc_client_person_reset_usage(contacts_h contact, int person_id, contacts_usage_type_e type);
+int ctsvc_client_person_set_favorite_order(contacts_h contact, int person_id, int previous_person_id, int next_person_id);
+int ctsvc_client_person_set_default_property(contacts_h contact, contacts_person_property_e property, int person_id, int id);
+int ctsvc_client_person_get_default_property(contacts_h contact, contacts_person_property_e property, int person_id, int *id);
+
+#endif /* __CTSVC_CLIENT_PERSON_HELPER_H__ */
\ No newline at end of file
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 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.
*
*/
-#include <glib.h>
-#include <pims-ipc-data.h>
-
#include "contacts.h"
-#include "contacts_phone_log_internal.h"
#include "ctsvc_internal.h"
-#include "ctsvc_ipc_define.h"
-#include "ctsvc_client_ipc.h"
-#include "ctsvc_ipc_marshal.h"
+#include "ctsvc_client_handle.h"
+#include "ctsvc_client_phonelog_helper.h"
API int contacts_phone_log_reset_statistics(void)
{
-#ifndef ENABLE_LOG_FEATURE
- return CONTACTS_ERROR_NOT_SUPPORTED;
-#endif // ENABLE_LOG_FEATURE
-
- 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;
- }
-
- // ipc call
- if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE, CTSVC_IPC_SERVER_PHONELOG_RESET_STATISTICS, indata, &outdata) != 0)
- {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
+ int ret;
+ contacts_h contact = NULL;
- pims_ipc_data_destroy(indata);
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- if (outdata)
- {
- // check result
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ ret = ctsvc_client_phone_log_reset_statistics(contact);
return ret;
-
}
API int contacts_phone_log_delete(contacts_phone_log_delete_e op, ...)
{
-#ifndef ENABLE_LOG_FEATURE
- return CONTACTS_ERROR_NOT_SUPPORTED;
-#endif // ENABLE_LOG_FEATURE
-
- int ret = CONTACTS_ERROR_NONE;
+ int ret;
+ contacts_h contact = NULL;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
- char *number = NULL;
- int extra_data1;
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
va_list args;
-
- indata = pims_ipc_data_create(0);
- if (indata == NULL) {
- CTS_ERR("ipc data created fail!");
- ret = CONTACTS_ERROR_OUT_OF_MEMORY;
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- ret = ctsvc_ipc_marshal_int(op, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_ipc_marshal_int fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
-
- switch(op) {
- case CONTACTS_PHONE_LOG_DELETE_BY_ADDRESS:
- va_start(args, op);
- number = va_arg(args, char *);
- va_end(args);
- if (NULL == number) {
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
- ret = ctsvc_ipc_marshal_string(number, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_ipc_marshal_string fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- break;
- case CONTACTS_PHONE_LOG_DELETE_BY_MESSAGE_EXTRA_DATA1:
- case CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1:
- va_start(args, op);
- extra_data1 = va_arg(args, int);
- va_end(args);
- ret = ctsvc_ipc_marshal_int(extra_data1, indata);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_ipc_marshal_int fail");
- pims_ipc_data_destroy(indata);
- return ret;
- }
- break;
- default:
- CTS_ERR("Invalid parameter : operation is not proper (%d)", ret);
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
-
- if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE,
- CTSVC_IPC_SERVER_PHONELOG_DELETE, indata, &outdata) != 0) {
- CTS_ERR("ctsvc_ipc_call Fail");
- pims_ipc_data_destroy(indata);
- return CONTACTS_ERROR_IPC;
- }
-
- pims_ipc_data_destroy(indata);
-
- if (outdata) {
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata, &size);
-
- if (CONTACTS_ERROR_NONE == ret) {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- ctsvc_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
+ va_start(args, op);
+ ret = ctsvc_client_phone_log_delete(contact, op, args);
+ va_end(args);
return ret;
}
--- /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 <pims-ipc-data.h>
+
+#include "contacts.h"
+#include "contacts_phone_log_internal.h"
+#include "ctsvc_internal.h"
+#include "ctsvc_ipc_define.h"
+#include "ctsvc_client_ipc.h"
+#include "ctsvc_ipc_marshal.h"
+
+
+static const char CONTACTS_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.read";
+static const char CONTACTS_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/contact.write";
+static const char PHONELOG_READ_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.read";
+static const char PHONELOG_WRITE_PRIVILEGE_ID[] = "http://tizen.org/privilege/callhistory.write";
+
+int ctsvc_client_phone_log_reset_statistics(contacts_h contact)
+{
+#ifndef ENABLE_LOG_FEATURE
+ return CONTACTS_ERROR_NOT_SUPPORTED;
+#endif /* ENABLE_LOG_FEATURE */
+
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is 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_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ /* ipc call */
+ if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE, CTSVC_IPC_SERVER_PHONELOG_RESET_STATISTICS, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ // check result
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+
+}
+
+int ctsvc_client_phone_log_delete(contacts_h contact, contacts_phone_log_delete_e op, va_list args)
+{
+#ifndef ENABLE_LOG_FEATURE
+ return CONTACTS_ERROR_NOT_SUPPORTED;
+#endif /* ENABLE_LOG_FEATURE */
+
+ int ret = CONTACTS_ERROR_NONE;
+
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+ char *number = NULL;
+ int extra_data1;
+
+ RETVM_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER, "contact is NULL");
+
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL) {
+ CTS_ERR("ipc data created fail!");
+ ret = CONTACTS_ERROR_OUT_OF_MEMORY;
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_handle(contact, indata);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_marshal_handle() Fail(%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ ret = ctsvc_ipc_marshal_int(op, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_int fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ switch(op) {
+ case CONTACTS_PHONE_LOG_DELETE_BY_ADDRESS:
+ number = va_arg(args, char *);
+ if (NULL == number) {
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+ ret = ctsvc_ipc_marshal_string(number, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_string fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ break;
+ case CONTACTS_PHONE_LOG_DELETE_BY_MESSAGE_EXTRA_DATA1:
+ case CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1:
+ extra_data1 = va_arg(args, int);
+ ret = ctsvc_ipc_marshal_int(extra_data1, indata);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_marshal_int fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+ break;
+ default:
+ CTS_ERR("Invalid parameter : operation is not proper (%d)", ret);
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (ctsvc_ipc_call(CTSVC_IPC_PHONELOG_MODULE,
+ CTSVC_IPC_SERVER_PHONELOG_DELETE, indata, &outdata) != 0) {
+ CTS_ERR("ctsvc_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CONTACTS_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata, &size);
+
+ if (CONTACTS_ERROR_NONE == ret) {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ ctsvc_client_ipc_set_change_version(contact, transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef __CTSVC_CLIENT_PHONELOG_HELPER_H__
+#define __CTSVC_CLIENT_PHONELOG_HELPER_H__
+
+#include "contacts_types.h"
+#include "contacts_phone_log_internal.h"
+
+int ctsvc_client_phone_log_reset_statistics(contacts_h contact);
+int ctsvc_client_phone_log_delete(contacts_h contact, contacts_phone_log_delete_e op, va_list args);
+
+
+#endif /* __CTSVC_CLIENT_PHONELOG_HELPER_H__ */
\ No newline at end of file
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Dohyung Jin <dh.jin@samsung.com>
* Jongwon Lee <gogosing.lee@samsung.com>
* limitations under the License.
*
*/
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <unistd.h>
-#include <pims-ipc-data.h>
-
#include "contacts.h"
#include "ctsvc_internal.h"
-#include "ctsvc_socket.h"
-#include "ctsvc_mutex.h"
-#include "ctsvc_inotify.h"
#include "ctsvc_client_ipc.h"
-
-static int ctsvc_connection = 0;
-
-static __thread int ctsvc_connection_on_thread = 0;
+#include "ctsvc_client_handle.h"
+#include "ctsvc_client_service_helper.h"
API int contacts_connect_with_flags(unsigned int flags)
{
CTS_FN_CALL;
- int ret = CONTACTS_ERROR_NONE;
-
- // If new flag is defined, errer check should be updated
- RETVM_IF(flags & 0x11111110, CONTACTS_ERROR_INVALID_PARAMETER, "flags is invalid");
+ int ret;
+ contacts_h contact = NULL;
- ret = contacts_connect();
- if (ret == CONTACTS_ERROR_PERMISSION_DENIED)
- return ret;
- else if (ret == CONTACTS_ERROR_NONE)
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ if (CONTACTS_ERROR_NO_DATA == ret) {
+ ret = ctsvc_client_handle_create(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_create() Fail(%d)", ret);
+ }
+ else if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_client_handle_get_current_p() Fail(%d)", ret);
return ret;
-
- if (flags & CONTACTS_CONNECT_FLAG_RETRY) {
- int i;
- int waiting_time = 500;
- for (i=0;i<9;i++) {
- usleep(waiting_time * 1000);
- CTS_DBG("retry cnt=%d, ret=%x, %d",(i+1), ret, waiting_time);
- ret = contacts_connect();
- if (ret == CONTACTS_ERROR_NONE)
- break;
- if (6 < i)
- waiting_time += 30000;
- else
- waiting_time *= 2;
- }
}
+ ret = ctsvc_client_connect_with_flags(contact, flags);
+
return ret;
}
{
CTS_FN_CALL;
int ret;
+ contacts_h contact = NULL;
- ctsvc_mutex_lock(CTS_MUTEX_CONNECTION);
- if (0 == ctsvc_connection) {
- ret = ctsvc_ipc_connect();
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_ipc_connect() Fail(%d)", ret);
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- return ret;
- }
-
- ret = ctsvc_socket_init();
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_socket_init() Fail(%d)", ret);
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- return ret;
- }
-
- ret = ctsvc_inotify_init();
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_inotify_init() Fail(%d)", ret);
- ctsvc_socket_final();
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- return ret;
- }
-
- ctsvc_view_uri_init();
- ctsvc_ipc_create_for_change_subscription();
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ if (CONTACTS_ERROR_NO_DATA == ret) {
+ ret = ctsvc_client_handle_create(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_create() Fail(%d)", ret);
}
- else
- CTS_DBG("System : Contacts service has been already connected(%d)", ctsvc_connection + 1);
-
- ctsvc_connection++;
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ else if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+ return ret;
+ }
+ ret = ctsvc_client_connect(contact);
- return CONTACTS_ERROR_NONE;
+ return ret;
}
API int contacts_disconnect(void)
{
- int ret;
-
CTS_FN_CALL;
+ int ret;
+ contacts_h contact = NULL;
- ctsvc_mutex_lock(CTS_MUTEX_CONNECTION);
- if (1 == ctsvc_connection) {
- ctsvc_ipc_destroy_for_change_subscription();
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETV_IF(CONTACTS_ERROR_NO_DATA == ret, CONTACTS_ERROR_NONE);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- ret = ctsvc_ipc_disconnect();
- if (ret != CONTACTS_ERROR_NONE) {
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- CTS_ERR("ctsvc_ipc_disconnect() Fail(%d)", ret);
- return ret;
- }
+ ret = ctsvc_client_disconnect(contact);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_disconnect() Fail(%d)", ret);
- ctsvc_view_uri_deinit();
- ctsvc_inotify_close();
- ctsvc_socket_final();
- }
- else if (1 < ctsvc_connection)
- CTS_DBG("System : connection count is %d", ctsvc_connection);
- else {
- CTS_DBG("System : please call contacts_connect(), connection count is (%d)", ctsvc_connection);
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- return CONTACTS_ERROR_DB;
- }
-
- ctsvc_connection--;
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
-
- return CONTACTS_ERROR_NONE;
+ return ret;
}
API int contacts_connect_on_thread(void)
{
+ CTS_FN_CALL;
int ret;
+ contacts_h contact = NULL;
- ctsvc_mutex_lock(CTS_MUTEX_CONNECTION);
-
- if (0 == ctsvc_connection_on_thread) {
- ret = ctsvc_ipc_connect_on_thread();
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_ipc_connect_on_thread() Fail(%d)", ret);
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- return ret;
- }
-
- ret = ctsvc_socket_init();
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_socket_init() Fail(%d)", ret);
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- return ret;
- }
-
- ret = ctsvc_inotify_init();
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_inotify_init() Fail(%d)", ret);
- ctsvc_socket_final();
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- return ret;
- }
-
- ctsvc_view_uri_init();
- ctsvc_ipc_create_for_change_subscription();
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ if (CONTACTS_ERROR_NO_DATA == ret) {
+ ret = ctsvc_client_handle_create(&contact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_create() Fail(%d)", ret);
+ }
+ else if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_client_handle_get_current_p() Fail(%d)", ret);
+ return ret;
}
- else if (0 < ctsvc_connection_on_thread)
- CTS_DBG("System : Contacts service has been already connected");
-
- ctsvc_connection_on_thread++;
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ ret = ctsvc_client_connect_on_thread(contact);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_connect_on_thread() Fail(%d)", ret);
- return CONTACTS_ERROR_NONE;
+ return ret;
}
API int contacts_disconnect_on_thread(void)
{
+ CTS_FN_CALL;
int ret;
+ contacts_h contact = NULL;
- ctsvc_mutex_lock(CTS_MUTEX_CONNECTION);
+ ret = ctsvc_client_handle_get_current_p(&contact);
+ RETV_IF(CONTACTS_ERROR_NO_DATA == ret, CONTACTS_ERROR_NONE);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_client_handle_get_current_p() Fail(%d)", ret);
- if (1 == ctsvc_connection_on_thread) {
- ctsvc_ipc_destroy_for_change_subscription();
+ ret = ctsvc_client_disconnect_on_thread(contact);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_disconnect_on_thread() Fail(%d)", ret);
- ret = ctsvc_ipc_disconnect_on_thread();
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_ipc_disconnect_on_thread() Fail(%d)", ret);
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- return ret;
- }
-
- ctsvc_view_uri_deinit();
- ctsvc_inotify_close();
- ctsvc_socket_final();
- CTS_DBG("System : connection_on_thread was destroyed successfully");
- }
- else if (1 < ctsvc_connection_on_thread) {
- CTS_DBG("System : connection count is %d", ctsvc_connection_on_thread);
- }
- else {
- CTS_DBG("System : please call contacts_connect_on_thread(), connection count is (%d)", ctsvc_connection_on_thread);
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
- return CONTACTS_ERROR_DB;
- }
-
- ctsvc_connection_on_thread--;
-
- ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
-
- return CONTACTS_ERROR_NONE;
+ return ret;
}
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Dohyung Jin <dh.jin@samsung.com>
+ * Jongwon Lee <gogosing.lee@samsung.com>
+ * Donghee Ye <donghee.ye@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 <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+#include "contacts.h"
+#include "ctsvc_internal.h"
+#include "ctsvc_socket.h"
+#include "ctsvc_mutex.h"
+#include "ctsvc_inotify.h"
+#include "ctsvc_client_ipc.h"
+#include "ctsvc_client_handle.h"
+#include "ctsvc_client_service_helper.h"
+
+static int ctsvc_connection = 0;
+static __thread int ctsvc_connection_on_thread = 0;
+
+int ctsvc_client_connect_with_flags(contacts_h contact, unsigned int flags)
+{
+ CTS_FN_CALL;
+ int ret = CONTACTS_ERROR_NONE;
+
+ /* If new flag is defined, errer check should be updated */
+ RETVM_IF(flags & 0x11111110, CONTACTS_ERROR_INVALID_PARAMETER, "flags is invalid");
+
+ ret = ctsvc_client_connect(contact);
+ if (ret == CONTACTS_ERROR_PERMISSION_DENIED)
+ return ret;
+ else 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);
+ CTS_DBG("retry cnt=%d, ret=%x, %d",(i+1), ret, waiting_time);
+ ret = ctsvc_client_connect(contact);
+ if (ret == CONTACTS_ERROR_NONE)
+ break;
+ if (6 < i)
+ waiting_time += 30000;
+ else
+ waiting_time *= 2;
+ }
+ }
+
+ return ret;
+}
+
+int ctsvc_client_connect(contacts_h contact)
+{
+ CTS_FN_CALL;
+ int ret;
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+
+ ctsvc_mutex_lock(CTS_MUTEX_CONNECTION);
+ if (0 == base->connection_count) {
+ ret = ctsvc_ipc_connect(contact);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_connect() Fail(%d)", ret);
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ return ret;
+ }
+ }
+ base->connection_count++;
+
+ if (0 == ctsvc_connection) {
+ ret = ctsvc_socket_init();
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_socket_init() Fail(%d)", ret);
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ return ret;
+ }
+
+ ret = ctsvc_inotify_init();
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_inotify_init() Fail(%d)", ret);
+ ctsvc_socket_final();
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ return ret;
+ }
+
+ ctsvc_view_uri_init();
+ ctsvc_ipc_create_for_change_subscription();
+ }
+ else
+ CTS_DBG("System : Contacts service has been already connected(%d)", ctsvc_connection + 1);
+
+ ctsvc_connection++;
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_client_disconnect(contacts_h contact)
+{
+ CTS_FN_CALL;
+ int ret;
+ ctsvc_mutex_lock(CTS_MUTEX_CONNECTION);
+
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+ if (1 == base->connection_count) {
+ ret = ctsvc_ipc_disconnect(contact, ctsvc_connection);
+ if (ret != CONTACTS_ERROR_NONE) {
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ CTS_ERR("ctsvc_ipc_disconnect() Fail(%d)", ret);
+ return ret;
+ }
+ ctsvc_client_handle_remove((contacts_h)base);
+ }
+ else {
+ base->connection_count--;
+ }
+
+ if (1 == ctsvc_connection) {
+ ctsvc_ipc_destroy_for_change_subscription();
+ ctsvc_view_uri_deinit();
+ ctsvc_inotify_close();
+ ctsvc_socket_final();
+ }
+ else if (1 < ctsvc_connection)
+ CTS_DBG("System : connection count is %d", ctsvc_connection);
+ else {
+ CTS_DBG("System : please call contacts_connect(), connection count is (%d)", ctsvc_connection);
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ ctsvc_connection--;
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_client_connect_on_thread(contacts_h contact)
+{
+ int ret;
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+
+ ctsvc_mutex_lock(CTS_MUTEX_CONNECTION);
+
+ if (0 == base->connection_count) {
+ ret = ctsvc_ipc_connect_on_thread(contact);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_connect_on_thread() Fail(%d)", ret);
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ return ret;
+ }
+ }
+ base->connection_count++;
+
+ if (0 == ctsvc_connection_on_thread) {
+ ret = ctsvc_socket_init();
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_socket_init() Fail(%d)", ret);
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ return ret;
+ }
+
+ ret = ctsvc_inotify_init();
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_inotify_init() Fail(%d)", ret);
+ ctsvc_socket_final();
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ return ret;
+ }
+
+ ctsvc_view_uri_init();
+ ctsvc_ipc_create_for_change_subscription();
+ }
+ else if (0 < ctsvc_connection_on_thread)
+ CTS_DBG("System : Contacts service has been already connected");
+
+ ctsvc_connection_on_thread++;
+
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_client_disconnect_on_thread(contacts_h contact)
+{
+ int ret;
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+
+ ctsvc_mutex_lock(CTS_MUTEX_CONNECTION);
+
+ if (1 == base->connection_count) {
+ ret = ctsvc_ipc_disconnect_on_thread(contact, ctsvc_connection_on_thread);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_disconnect_on_thread() Fail(%d)", ret);
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ return ret;
+ }
+ ctsvc_client_handle_remove((contacts_h)base);
+
+ }
+ else {
+ base->connection_count--;
+ }
+
+ if (1 == ctsvc_connection_on_thread) {
+ ctsvc_ipc_destroy_for_change_subscription();
+ ctsvc_view_uri_deinit();
+ ctsvc_inotify_close();
+ ctsvc_socket_final();
+ CTS_DBG("System : connection_on_thread was destroyed successfully");
+ }
+ else if (1 < ctsvc_connection_on_thread) {
+ CTS_DBG("System : connection count is %d", ctsvc_connection_on_thread);
+ }
+ else {
+ CTS_DBG("System : please call contacts_connect_on_thread(), connection count is (%d)", ctsvc_connection_on_thread);
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ ctsvc_connection_on_thread--;
+
+ ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION);
+
+ return CONTACTS_ERROR_NONE;
+}
+
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Dohyung Jin <dh.jin@samsung.com>
+ * Jongwon Lee <gogosing.lee@samsung.com>
+ * Donghee Ye <donghee.ye@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 __CTSVC_CLIENT_SERVICE_HELPER_H__
+#define __CTSVC_CLIENT_SERVICE_HELPER_H__
+
+int ctsvc_client_connect_with_flags(contacts_h contact, unsigned int flags);
+int ctsvc_client_connect(contacts_h contact);
+int ctsvc_client_disconnect(contacts_h contact);
+int ctsvc_client_connect_on_thread(contacts_h contact);
+int ctsvc_client_disconnect_on_thread(contacts_h contact);
+
+#endif /* __CTSVC_CLIENT_SERVICE_HELPER_H__ */
\ No newline at end of file
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 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.
static void __ctsvc_setting_name_display_order_subscriber_callback(pims_ipc_h ipc, pims_ipc_data_h data, void *user_data)
{
+ int ret;
int value = -1;
- unsigned int size = 0;
- if (data)
- value = *(int*)pims_ipc_data_get(data, &size);
+ if (data) {
+ ret = ctsvc_ipc_unmarshal_int(data, &value);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
+ }
if (__setting_name_display_order_subscribe_list) {
GSList *l;
for (l = __setting_name_display_order_subscribe_list;l;l=l->next) {
ctsvc_name_display_order_changed_cb_info_s *cb_info = l->data;
if (cb_info->cb == cb && cb_info->user_data == user_data) {
CTS_ERR("The same callback(%s) is already exist");
+ ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_INVALID_PARAMETER;
}
}
static void __ctsvc_setting_name_sorting_order_subscriber_callback(pims_ipc_h ipc, pims_ipc_data_h data, void *user_data)
{
+ int ret;
int value = -1;
- unsigned int size = 0;
- if (data)
- value = *(int*)pims_ipc_data_get(data, &size);
+
+ if (data) {
+ ret = ctsvc_ipc_unmarshal_int(data, &value);
+ WARN_IF(CONTACTS_ERROR_NONE != ret, "() Fail(%d)", ret);
+ }
if (__setting_name_sorting_order_subscribe_list) {
GSList *l;
ctsvc_name_sorting_order_changed_cb_info_s *cb_info = l->data;
if (cb_info->cb == cb && cb_info->user_data == user_data) {
CTS_ERR("The same callback(%s) is already exist");
+ ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_INVALID_PARAMETER;
}
}
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2015 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 "ctsvc_internal.h"
+#include "ctsvc_handle.h"
+
+int ctsvc_handle_create(contacts_h *contact)
+{
+ RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
+ ctsvc_base_s *base = calloc(1, sizeof(ctsvc_base_s));
+ *contact = (contacts_h)base;
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_handle_destroy(contacts_h contact)
+{
+ RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+ free(base);
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_handle_clone(contacts_h contact, contacts_h *pcontact)
+{
+ RETV_IF(NULL == contact, CONTACTS_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == pcontact, CONTACTS_ERROR_INVALID_PARAMETER);
+
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+ ctsvc_base_s *clone = calloc(1, sizeof(ctsvc_base_s));
+ clone->connection_count = base->connection_count;
+ clone->version = base->version;
+
+ *pcontact = (contacts_h)clone;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_handle_compare(contacts_h contact1, contacts_h contact2)
+{
+ if (NULL == contact1 && NULL == contact2)
+ return 0;
+ else if (NULL == contact1)
+ return 1;
+ else if (NULL == contact2)
+ return 1;
+
+ ctsvc_base_s *base1 = (ctsvc_base_s *)contact1;
+ ctsvc_base_s *base2 = (ctsvc_base_s *)contact2;
+
+ if ((base1->connection_count == base2->connection_count) &&
+ (base1->version == base2->version))
+ return 0;
+ else
+ return 1;
+}
+
--- /dev/null
+/*
+ * Contacts Service
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef __CTSVC_HANDLE_H__
+#define __CTSVC_HANDLE_H__
+
+#include "contacts_types.h"
+
+int ctsvc_handle_create(contacts_h *contact);
+int ctsvc_handle_destroy(contacts_h contact);
+int ctsvc_handle_clone(contacts_h contact, contacts_h *pcontact);
+int ctsvc_handle_compare(contacts_h contact1, contacts_h contact2);
+
+
+#endif // __CTSVC_HANDLE_H__
#include "ctsvc_internal.h"
#include "ctsvc_notify.h"
#include "ctsvc_view.h"
+#include "ctsvc_handle.h"
#include <stdbool.h>
typedef struct
{
+ contacts_h contact;
int wd;
char *view_uri;
contacts_db_changed_cb cb;
return CTSVC_NOTI_SDN_CHANGED;
case CTSVC_RECORD_RESULT:
default:
- CTS_ERR("Invalid parameter : The type(%d) is not supported", view_uri);
+ CTS_ERR("Invalid parameter : The type(%s) is not supported", view_uri);
return NULL;
}
return NULL;
}
-int ctsvc_inotify_subscribe(const char *view_uri,
- contacts_db_changed_cb cb, void *data)
+int ctsvc_inotify_subscribe(contacts_h contact, const char *view_uri,
+ void *cb, void *data)
{
int ret, wd;
noti_info *noti, *same_noti = NULL;
if (it->data) {
same_noti = it->data;
if (same_noti->wd == wd && same_noti->cb == cb &&
- STRING_EQUAL == strcmp(same_noti->view_uri, view_uri) && same_noti->cb_data == data)
+ STRING_EQUAL == strcmp(same_noti->view_uri, view_uri) && same_noti->cb_data == data &&
+ 0 == ctsvc_handle_compare(contact, same_noti->contact))
break;
else
same_noti = NULL;
noti->view_uri = strdup(view_uri);
noti->cb_data = data;
noti->cb = cb;
+ ctsvc_handle_clone(contact, &(noti->contact));
noti->blocked = false;
__noti_list = g_slist_append(__noti_list, noti);
return CONTACTS_ERROR_NONE;
}
-static inline int __ctsvc_del_noti(GSList **noti_list, int wd,
- const char *view_uri, contacts_db_changed_cb cb, void *user_data)
+static inline int __ctsvc_del_noti(GSList **noti_list, contacts_h contact, int wd,
+ const char *view_uri, void *cb, void *user_data)
{
int del_cnt, remain_cnt;
GSList *it, *result;
noti_info *noti = it->data;
if (noti && wd == noti->wd) {
if (cb == noti->cb && user_data == noti->cb_data
- && STRING_EQUAL == strcmp(noti->view_uri, view_uri)) {
+ && STRING_EQUAL == strcmp(noti->view_uri, view_uri)
+ && 0 == ctsvc_handle_compare(contact, noti->contact)) {
it = it->next;
result = g_slist_remove(result, noti);
+ ctsvc_handle_destroy(noti->contact);
free(noti->view_uri);
free(noti);
del_cnt++;
return remain_cnt;
}
-int ctsvc_inotify_unsubscribe(const char *view_uri, contacts_db_changed_cb cb, void *user_data)
+int ctsvc_inotify_unsubscribe(contacts_h contact, const char *view_uri, void *cb, void *user_data)
{
int ret, wd;
const char *path;
return CONTACTS_ERROR_SYSTEM;
}
- ret = __ctsvc_del_noti(&__noti_list, wd, view_uri, cb, user_data);
+ ret = __ctsvc_del_noti(&__noti_list, contact, wd, view_uri, cb, user_data);
WARN_IF(ret < CONTACTS_ERROR_NONE, "__ctsvc_del_noti() Fail(%d)", ret);
if (0 == ret)
__inoti_fd = -1;
}
}
+
/*
* Contacts Service
*
- * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Youngjae Shin <yj99.shin@samsung.com>
*
int ctsvc_inotify_init(void);
void ctsvc_inotify_close(void);
-int ctsvc_inotify_subscribe(const char *view_uri, contacts_db_changed_cb cb, void *data);
-int ctsvc_inotify_unsubscribe(const char *view_uri, contacts_db_changed_cb cb, void *user_data);
+int ctsvc_inotify_subscribe(contacts_h contact, const char *view_uri, contacts_db_changed_cb cb, void *data);
+int ctsvc_inotify_unsubscribe(contacts_h contact, const char *view_uri, contacts_db_changed_cb cb, void *user_data);
#endif /* __CTSVC_INOTIFY_H__ */
static pthread_mutex_t ipc_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t ipc_pubsub_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t access_control_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t handle_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t socket_client_info_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t cynara_mutex = PTHREAD_MUTEX_INITIALIZER;
case CTS_MUTEX_ACCESS_CONTROL:
ret_val = &access_control_mutex;
break;
+ case CTS_MUTEX_HANDLE:
+ ret_val = &handle_mutex;
+ break;
case CTS_MUTEX_SOCKET_CLIENT_INFO:
ret_val = &socket_client_info_mutex;
break;
CTS_MUTEX_PIMS_IPC_CALL,
CTS_MUTEX_PIMS_IPC_PUBSUB,
CTS_MUTEX_ACCESS_CONTROL,
+ CTS_MUTEX_HANDLE,
CTS_MUTEX_CYNARA,
CTS_MUTEX_SOCKET_CLIENT_INFO,
};
#include "contacts_views.h"
#define CTSVC_SOCK_PATH "/run/user/%d"
-#define CTSVC_PATH_MAX_LEN 1024
-
#define CTSVC_IMG_FULL_PATH_SIZE_MAX 1024 /* current max length file path is 256 */
+#define CTSVC_PATH_MAX_LEN 1024
+#define CTSVC_STR_SHORT_LEN 1024
#define STRING_EQUAL 0
#define SAFE_STR(src) (src)?src:""
GSList *values;
}ctsvc_result_s;
+typedef struct {
+ int version;
+ int connection_count;
+}ctsvc_base_s;
#endif /* __CTSVC_STRUCT_H__ */
CTSVC_VCARD_APPEND_STR(buf, buf_size, len, CTSVC_CRLF);
if (name->first && name->last) {
- contacts_name_display_order_e order;
+ contacts_name_display_order_e order = CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST;
+#ifdef _CONTACTS_IPC_CLIENT
contacts_setting_get_name_display_order(&order);
+#endif
if (CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST == order) {
snprintf(display, sizeof(display), "%s %s", name->first, name->last);
}
-#ifdef _CONTACTS_IPC_CLIENT
else {
/* CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST */
snprintf(display, sizeof(display), "%s, %s", name->last, name->first);
}
-#endif
}
else
snprintf(display, sizeof(display), "%s%s", SAFE_STR(name->first), SAFE_STR(name->last));
return __ctsvc_vcard_make_from_my_profile(my_profile, vcard_stream);
}
-
+#ifdef _CONTACTS_IPC_CLIENT
static int __ctsvc_vcard_append_person(ctsvc_person_s *person, ctsvc_list_s *list_contacts, char **buf, int *buf_size, int len)
{
int changed_time = 0;
#endif
return len;
}
+#endif // _CONTACTS_IPC_CLIENT
+#ifdef _CONTACTS_IPC_CLIENT
static int __ctsvc_vcard_make_from_person(ctsvc_person_s *person, ctsvc_list_s *list_contacts,
char **vcard_stream)
{
return CONTACTS_ERROR_NONE;
}
+#endif // _CONTACTS_IPC_CLIENT
+#ifdef _CONTACTS_IPC_CLIENT
API int contacts_vcard_make_from_person(contacts_record_h record, char **vcard_stream)
{
int ret;
contacts_list_destroy(list, true);
return ret;
}
+#endif
static inline char* __ctsvc_vcard_remove_empty_line(char *src)
{
}
}
+#ifdef _CONTACTS_IPC_CLIENT
contacts_setting_get_name_display_order(&name_display_order);
+#endif
if (CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST == name_display_order) {
contact->display_name = display;
free(reverse_display);
}
-#ifdef _CONTACTS_IPC_CLIENT
else {
contact->display_name = reverse_display;
free(display);
}
-#endif
contact->display_source_type = CONTACTS_DISPLAY_NAME_SOURCE_TYPE_NAME;
}
#include "contacts_filter.h"
#include "contacts_list.h"
#include "ctsvc_list.h"
+#include "ctsvc_handle.h"
extern ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_contact_plugin_cb;
extern ctsvc_ipc_marshal_record_plugin_cb_s _ctsvc_ipc_record_my_profile_plugin_cb;
return CONTACTS_ERROR_NONE;
}
+int ctsvc_ipc_marshal_handle(const contacts_h contact, pims_ipc_data_h ipc_data)
+{
+ int ret;
+ ctsvc_base_s *base = (ctsvc_base_s *)contact;
+
+ ret = ctsvc_ipc_marshal_int(base->version, ipc_data);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_ipc_marshal_int() Fail(%d)", ret);
+
+ ret = ctsvc_ipc_marshal_int(base->connection_count, ipc_data);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_ipc_marshal_int() Fail(%d)", ret);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int ctsvc_ipc_unmarshal_handle(const pims_ipc_data_h ipc_data, contacts_h *pcontact)
+{
+ int ret;
+ ctsvc_base_s *base = NULL;
+
+ ret = ctsvc_handle_create(pcontact);
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_handle_create() Fail(%d)", ret);
+
+ base = (ctsvc_base_s *)*pcontact;
+
+ ret = ctsvc_ipc_unmarshal_int(ipc_data, &(base->version));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
+
+ ret = ctsvc_ipc_unmarshal_int(ipc_data, &(base->connection_count));
+ RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_ipc_unmarshal_int() Fail(%d)", ret);
+
+ return CONTACTS_ERROR_NONE;
+}
int ctsvc_ipc_unmarshal_record(const pims_ipc_data_h ipc_data, contacts_record_h* precord)
{
int ctsvc_ipc_unmarshal_record(const pims_ipc_data_h ipc_data, contacts_record_h* precord);
int ctsvc_ipc_marshal_record(const contacts_record_h record, pims_ipc_data_h ipc_data);
+int ctsvc_ipc_marshal_handle(const contacts_h contact, pims_ipc_data_h ipc_data);
+int ctsvc_ipc_unmarshal_handle(const pims_ipc_data_h ipc_data, contacts_h *pcontact);
+
/*
* string
* char의 경우 NULL 설정의 이슈로 인하여, [int:string length]+[char*] 로 넘길 수 있도록 설정..
_CONTACTS_HANDLE(contacts_filter_h)
_CONTACTS_HANDLE(contacts_list_h)
_CONTACTS_HANDLE(contacts_query_h)
+_CONTACTS_HANDLE(contacts_h)
/**
* @file contacts_types.h
${CMAKE_SOURCE_DIR}/common/ipc/ctsvc_ipc_speeddial.c
${CMAKE_SOURCE_DIR}/common/ctsvc_filter.c
- ${CMAKE_SOURCE_DIR}/common/ctsvc_db_notification.c
${CMAKE_SOURCE_DIR}/common/ctsvc_inotify.c
${CMAKE_SOURCE_DIR}/common/ctsvc_list.c
${CMAKE_SOURCE_DIR}/common/ctsvc_localize_utils.c
${CMAKE_SOURCE_DIR}/common/ctsvc_view.c
${CMAKE_SOURCE_DIR}/common/ctsvc_record_speeddial.c
${CMAKE_SOURCE_DIR}/common/ctsvc_record_sdn.c
+ ${CMAKE_SOURCE_DIR}/common/ctsvc_handle.c
db/ctsvc_db_access_control.c
db/ctsvc_db_init.c
#include <pims-ipc-svc.h>
#include "contacts.h"
+#include "ctsvc_handle.h"
#include "ctsvc_server_service.h"
#include "ctsvc_db_init.h"
#include "ctsvc_db_query.h"
{
CTS_FN_CALL;
int ret = CONTACTS_ERROR_NONE;
+ contacts_h contact = NULL;
- ret = contacts_connect();
+ if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (ret != CONTACTS_ERROR_NONE) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else {
+ CTS_ERR("There is no indata fail");
+ ret = CONTACTS_ERROR_SYSTEM;
+ goto ERROR_RETURN;
+ }
+
+ ret = ctsvc_connect();
if (CONTACTS_ERROR_NONE == ret) {
char *smack = NULL;
free(smack);
}
+ERROR_RETURN:
if (outdata) {
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
}
else {
CTS_ERR("outdata is NULL");
}
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
}
void ctsvc_ipc_server_disconnect(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
int ret = CONTACTS_ERROR_NONE;
+ contacts_h contact = NULL;
- ret = contacts_disconnect();
+ if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
+ ret = CONTACTS_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+ }
- // related data will be freed in __ctsvc_client_disconnected_cb
-// if (ret == CONTACTS_ERROR_NONE)
-// ctsvc_unset_client_access_info();
+ ret = ctsvc_disconnect();
- if (outdata)
- {
+ERROR_RETURN:
+ if (outdata) {
*outdata = pims_ipc_data_create(0);
- if (NULL == *outdata)
- {
+ if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
}
- else
- {
+ else {
CTS_ERR("outdata is NULL");
}
- return;
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
+ ctsvc_server_trim_memory();
}
void ctsvc_ipc_server_check_permission(pims_ipc_h ipc, pims_ipc_data_h indata,
int ret = CONTACTS_ERROR_NONE;
contacts_record_h record = NULL;
int id = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
+ ret = CONTACTS_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_record(indata,&record);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
goto ERROR_RETURN;
}
- ret = contacts_db_insert_record(record, &id);
+ ret = ctsvc_db_insert_record(record, &id);
if (outdata) {
*outdata = pims_ipc_data_create(0);
}
DATA_FREE:
- if (record)
- {
- contacts_record_destroy(record,true);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_record_destroy(record,true);
+ ctsvc_server_trim_memory();
return;
}
char* view_uri = NULL;
int id = 0;
contacts_record_h record = NULL;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
+ ret = CONTACTS_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_string(indata,&view_uri);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_string fail");
goto ERROR_RETURN;
}
- ret = contacts_db_get_record(view_uri,id,&record);
+ ret = ctsvc_db_get_record(view_uri,id,&record);
ERROR_RETURN:
if (outdata) {
CTS_ERR("outdata is NULL");
}
DATA_FREE:
- if (record)
- {
- contacts_record_destroy(record,true);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_record_destroy(record,true);
CONTACTS_FREE(view_uri);
return;
}
{
int ret = CONTACTS_ERROR_NONE;
contacts_record_h record = NULL;
+ contacts_h contact = NULL;
- if (indata)
- {
+ if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
+ ret = CONTACTS_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_record(indata,&record);
- if (ret != CONTACTS_ERROR_NONE)
- {
+ if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
goto ERROR_RETURN;
}
}
- else
- {
+ else {
CTS_ERR("ctsvc_ipc_server_db_insert_record fail");
goto ERROR_RETURN;
}
goto ERROR_RETURN;
}
- ret = contacts_db_update_record(record);
+ ret = ctsvc_db_update_record(record);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
- if (record)
- {
- contacts_record_destroy(record,true);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_record_destroy(record,true);
+ ctsvc_server_trim_memory();
return;
}
int ret = CONTACTS_ERROR_NONE;
char* view_uri = NULL;
int id = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
+ ret = CONTACTS_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_string(indata,&view_uri);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
goto ERROR_RETURN;
}
- ret = contacts_db_delete_record(view_uri,id);
+ ret = ctsvc_db_delete_record(view_uri,id);
if (outdata) {
*outdata = pims_ipc_data_create(0);
DATA_FREE:
+ ctsvc_handle_destroy(contact);
CONTACTS_FREE(view_uri);
return;
}
int ret = CONTACTS_ERROR_NONE;
contacts_record_h record = NULL;
int id = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
+ ret = CONTACTS_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_record(indata, &record);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
}
- ret = contacts_db_replace_record(record, id);
+ ret = ctsvc_db_replace_record(record, id);
if (outdata) {
*outdata = pims_ipc_data_create(0);
}
DATA_FREE:
- if (record)
- contacts_record_destroy(record, true);
+ ctsvc_handle_destroy(contact);
+ contacts_record_destroy(record, true);
return;
}
int offset = 0;
int limit = 0;
contacts_list_h list = NULL;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle() Fail(%d)", ret);
+ ret = CONTACTS_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_string(indata,&view_uri);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
goto ERROR_RETURN;
}
- ret = contacts_db_get_all_records(view_uri,offset,limit,&list);
+ ret = ctsvc_db_get_all_records(view_uri,offset,limit,&list);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
-
- if (list)
- {
- contacts_list_destroy(list,true);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_list_destroy(list,true);
CONTACTS_FREE(view_uri);
return;
}
int offset = 0;
int limit = 0;
contacts_list_h list = NULL;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_query(indata,&query);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
goto ERROR_RETURN;
}
- ret = contacts_db_get_records_with_query(query,offset,limit,&list);
+ ret = ctsvc_db_get_records_with_query(query,offset,limit,&list);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
-
- if (list)
- {
- contacts_list_destroy(list,true);
- }
- if (query)
- {
- contacts_query_destroy(query);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_list_destroy(list,true);
+ contacts_query_destroy(query);
return;
}
int ret = CONTACTS_ERROR_NONE;
char* view_uri = NULL;
int count = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_string(indata,&view_uri);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
goto ERROR_RETURN;
}
- ret = contacts_db_get_count(view_uri,&count);
+ ret = ctsvc_db_get_count(view_uri,&count);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
+ ctsvc_handle_destroy(contact);
CONTACTS_FREE(view_uri);
return;
}
int ret = CONTACTS_ERROR_NONE;
contacts_query_h query = NULL;
int count = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_query(indata,&query);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
goto ERROR_RETURN;
}
- ret = contacts_db_get_count_with_query(query,&count);
+ ret = ctsvc_db_get_count_with_query(query,&count);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
- if (query)
- {
- contacts_query_destroy(query);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_query_destroy(query);
return;
}
{
int ret = CONTACTS_ERROR_NONE;
contacts_list_h list = NULL;
- unsigned int id_count = 0;
+ int id_count = 0;
int *ids = NULL;
int i=0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_list(indata,&list);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_list fail");
CTS_ERR("outdata is NULL");
}
DATA_FREE:
- if (list)
- {
- contacts_list_destroy(list,true);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_list_destroy(list,true);
CONTACTS_FREE(ids);
return;
}
{
int ret = CONTACTS_ERROR_NONE;
contacts_list_h list = NULL;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_list(indata,&list);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_list fail");
contacts_list_first(list);
}
- ret = contacts_db_update_records(list);
+ ret = ctsvc_db_update_records(list);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
- if (list)
- {
- contacts_list_destroy(list,true);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_list_destroy(list,true);
return;
}
int *ids = NULL;
char *uri = NULL;
int i = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_string(indata,&uri);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_string fail");
goto ERROR_RETURN;
}
- ret = contacts_db_delete_records(uri, ids, count);
+ ret = ctsvc_db_delete_records(uri, ids, count);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
+ ctsvc_handle_destroy(contact);
CONTACTS_FREE(uri);
CONTACTS_FREE(ids);
return;
int count = 0;
int *ids = NULL;
int i=0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_list(indata, &list);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_list fail");
CTS_ERR("outdata is NULL");
}
DATA_FREE:
- if (list) {
- contacts_list_destroy(list,true);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_list_destroy(list,true);
CONTACTS_FREE(ids);
return;
}
int contacts_db_version = 0;
contacts_list_h record_list = NULL;
int current_contacts_db_version = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+
ret = ctsvc_ipc_unmarshal_string(indata,&view_uri);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_string fail");
goto ERROR_RETURN;
}
- ret = contacts_db_get_changes_by_version(view_uri, address_book_id,contacts_db_version,&record_list,¤t_contacts_db_version);
+ ret = ctsvc_db_get_changes_by_version(view_uri, address_book_id,contacts_db_version,&record_list,¤t_contacts_db_version);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
- if (record_list)
- {
- contacts_list_destroy(record_list,true);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_list_destroy(record_list,true);
CONTACTS_FREE(view_uri);
return;
}
{
int ret = CONTACTS_ERROR_NONE;
int contacts_db_version = 0;
+ contacts_h contact = NULL;
+
+ if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+ }
if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_CONTACT_READ) &&
!ctsvc_have_permission(ipc, CTSVC_PERMISSION_PHONELOG_READ)) {
goto ERROR_RETURN;
}
- ret = contacts_db_get_current_version(&contacts_db_version);
+ ret = ctsvc_db_get_current_version(&contacts_db_version);
ERROR_RETURN:
if (outdata) {
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (CONTACTS_ERROR_NO_DATA == ret) {
ret = ctsvc_ipc_marshal_int(contacts_db_version,*outdata);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
+
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
int offset = 0;
int limit = 0;
contacts_list_h list = NULL;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_string(indata,&view_uri);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
goto ERROR_RETURN;
}
- ret = contacts_db_search_records(view_uri, keyword, offset,limit,&list);
+ ret = ctsvc_db_search_records(view_uri, keyword, offset,limit,&list);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
-
- if (list)
- {
- contacts_list_destroy(list,true);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_list_destroy(list,true);
CONTACTS_FREE(view_uri);
CONTACTS_FREE(keyword);
return;
int limit = 0;
int range = 0;
contacts_list_h list = NULL;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_string(indata,&view_uri);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
goto ERROR_RETURN;
}
- ret = contacts_db_search_records_with_range(view_uri, keyword, offset,limit,range, &list);
+ ret = ctsvc_db_search_records_with_range(view_uri, keyword, offset,limit,range, &list);
if (outdata) {
*outdata = pims_ipc_data_create(0);
}
DATA_FREE:
-
- if (list)
- contacts_list_destroy(list,true);
+ ctsvc_handle_destroy(contact);
+ contacts_list_destroy(list,true);
free(view_uri);
free(keyword);
return;
int offset = 0;
int limit = 0;
contacts_list_h list = NULL;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_query(indata,&query);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_record fail");
}
- ret = contacts_db_search_records_with_query(query, keyword, offset,limit,&list);
+ ret = ctsvc_db_search_records_with_query(query, keyword, offset,limit,&list);
if (outdata) {
*outdata = pims_ipc_data_create(0);
CTS_ERR("outdata is NULL");
}
DATA_FREE:
-
- if (list)
- {
- contacts_list_destroy(list,true);
- }
- if (query)
- {
- contacts_query_destroy(query);
- }
+ ctsvc_handle_destroy(contact);
+ contacts_list_destroy(list,true);
+ contacts_query_destroy(query);
CONTACTS_FREE(keyword);
-
return;
}
{
int ret = CONTACTS_ERROR_NONE;
contacts_db_status_e status;
+ contacts_h contact = NULL;
- RETM_IF(outdata == NULL, "outdata is NULL");
-
- *outdata = pims_ipc_data_create(0);
- if (!*outdata) {
- CTS_ERR("pims_ipc_data_create fail");
- return;
+ if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
}
- ret = contacts_db_get_status(&status);
- if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- CTS_ERR("pims_ipc_data_put fail (return value)");
- return;
- }
+ ret = ctsvc_db_get_status(&status);
- if (pims_ipc_data_put(*outdata, (void*)&status, sizeof(int)) != 0) {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- CTS_ERR("pims_ipc_data_put fail (id)");
- return;
- }
+ERROR_RETURN:
+ if (outdata) {
+ *outdata = pims_ipc_data_create(0);
+ if (NULL == *outdata) {
+ CTS_ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ CTS_ERR("pims_ipc_data_put fail (return value)");
+ goto DATA_FREE;
+ }
+
+ if (pims_ipc_data_put(*outdata, (void*)&status, sizeof(int)) != 0) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ CTS_ERR("pims_ipc_data_put fail (id)");
+ goto DATA_FREE;
+ }
+ }
+ else {
+ CTS_ERR("outdata is NULL");
+ }
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
#include "ctsvc_server_service.h"
#include "ctsvc_db_init.h"
-#include "ctsvc_db_access_control.h"
+#include "ctsvc_server_activity.h"
+#include "ctsvc_server_person.h"
+#include "ctsvc_server_group.h"
+#include "ctsvc_server_phonelog.h"
+#include "ctsvc_server_setting.h"
+
+#include "ctsvc_db_access_control.h"
#include "ctsvc_ipc_marshal.h"
#include "ctsvc_internal.h"
#include "ctsvc_ipc_server.h"
#include "ctsvc_db_utils.h"
+#include "ctsvc_handle.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)
{
int ret = CONTACTS_ERROR_NONE;
int contact_id = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &contact_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
ret = CONTACTS_ERROR_PERMISSION_DENIED;
goto ERROR_RETURN;
}
- ret = contacts_activity_delete_by_contact_id(contact_id);
+ ret = ctsvc_activity_delete_by_contact_id(contact_id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
{
int ret = CONTACTS_ERROR_NONE;
int account_id = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &account_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
ret = CONTACTS_ERROR_PERMISSION_DENIED;
goto ERROR_RETURN;
}
- ret = contacts_activity_delete_by_account_id(account_id);
+ ret = ctsvc_activity_delete_by_account_id(account_id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
int ret = CONTACTS_ERROR_NONE;
int group_id = 0;
int contact_id = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &group_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
goto ERROR_RETURN;
}
- ret = contacts_group_add_contact(group_id, contact_id);
+ ret = ctsvc_group_add_contact(group_id, contact_id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
int ret = CONTACTS_ERROR_NONE;
int group_id = 0;
int contact_id = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &group_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
}
- ret = contacts_group_remove_contact(group_id, contact_id);
+ ret = ctsvc_group_remove_contact(group_id, contact_id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
int transaction_ver = ctsvc_get_transaction_ver();
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
int previous_group_id;
int next_group_id;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &group_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
goto ERROR_RETURN;
}
- ret = contacts_group_set_group_order(group_id, previous_group_id, next_group_id);
+ ret = ctsvc_group_set_group_order(group_id, previous_group_id, next_group_id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
int transaction_ver = ctsvc_get_transaction_ver();
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
int base_person_id = 0;
int person_id = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &base_person_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
goto ERROR_RETURN;
}
- ret = contacts_person_link_person(base_person_id, person_id);
+ ret = ctsvc_person_link_person(base_person_id, person_id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
int transaction_ver = ctsvc_get_transaction_ver();
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
void ctsvc_ipc_person_unlink_contact(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
int person_id = 0;
int contact_id = 0;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &person_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
}
int unlinked_person_id;
- ret = contacts_person_unlink_contact(person_id, contact_id, &unlinked_person_id);
+ ret = ctsvc_person_unlink_contact(person_id, contact_id, &unlinked_person_id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
int transaction_ver = ctsvc_get_transaction_ver();
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
if (pims_ipc_data_put(*outdata, (void*)&unlinked_person_id, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
void ctsvc_ipc_person_reset_usage(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
int ret = CONTACTS_ERROR_NONE;
int person_id = 0;
contacts_usage_type_e type;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &person_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
goto ERROR_RETURN;
}
- ret = contacts_person_reset_usage(person_id, type);
+ ret = ctsvc_person_reset_usage(person_id, type);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
int transaction_ver = ctsvc_get_transaction_ver();
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
void ctsvc_ipc_person_set_favorite_order(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
int person_id = 0;
int previous_person_id;
int next_person_id;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &person_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
goto ERROR_RETURN;
}
- ret = contacts_person_set_favorite_order(person_id, previous_person_id, next_person_id);
+ ret = ctsvc_person_set_favorite_order(person_id, previous_person_id, next_person_id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
int transaction_ver = ctsvc_get_transaction_ver();
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
int person_id = 0;
int id;
contacts_person_property_e property;
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &person_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
goto ERROR_RETURN;
}
- ret = contacts_person_set_default_property(property, person_id, id);
+ ret = ctsvc_person_set_default_property(property, person_id, id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
int transaction_ver = ctsvc_get_transaction_ver();
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
int person_id = 0;
int id;
contacts_person_property_e op;
-
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, &person_id);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
goto ERROR_RETURN;
}
- ret = contacts_person_get_default_property(op, person_id, &id);
+ ret = ctsvc_person_get_default_property(op, person_id, &id);
ERROR_RETURN:
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail (return value)");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&id, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail (id)");
- return;
+ goto DATA_FREE;
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
void ctsvc_ipc_phone_log_reset_statistics(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
int ret;
+ contacts_h contact = NULL;
+
+ if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
+ }
if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_PHONELOG_WRITE)) {
ret = CONTACTS_ERROR_PERMISSION_DENIED;
goto ERROR_RETURN;
}
- ret = contacts_phone_log_reset_statistics();
+ ret = ctsvc_phone_log_reset_statistics();
ERROR_RETURN:
if (outdata) {
*outdata = pims_ipc_data_create(0);
if (NULL == *outdata) {
CTS_ERR("pims_ipc_data_create fail");
- return;
+ goto DATA_FREE;
}
if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("pims_ipc_data_put fail");
- return;
+ goto DATA_FREE;
}
if (ret == CONTACTS_ERROR_NONE) {
int transaction_ver = ctsvc_get_transaction_ver();
pims_ipc_data_destroy(*outdata);
*outdata = NULL;
CTS_ERR("ctsvc_ipc_marshal_int fail");
- return;
+ goto DATA_FREE;
}
}
}
else {
CTS_ERR("outdata is NULL");
}
-
+DATA_FREE:
+ ctsvc_handle_destroy(contact);
return;
}
int extra_data1;
char *number = NULL;
contacts_phone_log_delete_e op;
-
- if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_PHONELOG_WRITE)) {
- ret = CONTACTS_ERROR_PERMISSION_DENIED;
- goto ERROR_RETURN;
- }
+ contacts_h contact = NULL;
if (indata) {
+ ret = ctsvc_ipc_unmarshal_handle(indata, &contact);
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_ipc_unmarshal_handle Fail(%d)", ret);
+ goto ERROR_RETURN;
+ }
ret = ctsvc_ipc_unmarshal_int(indata, (int*)&op);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
goto ERROR_RETURN;
+ if (!ctsvc_have_permission(ipc, CTSVC_PERMISSION_PHONELOG_WRITE)) {
+ ret = CONTACTS_ERROR_PERMISSION_DENIED;
+ goto ERROR_RETURN;
+ }
+
}
switch(op) {
CTS_ERR("ctsvc_ipc_unmarshal_string fail");
goto ERROR_RETURN;
}
- ret = contacts_phone_log_delete(op, number);
+ ret = ctsvc_phone_log_delete(op, number);
break;
case CONTACTS_PHONE_LOG_DELETE_BY_MESSAGE_EXTRA_DATA1:
case CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1:
CTS_ERR("ctsvc_ipc_unmarshal_int fail");
goto ERROR_RETURN;
}
- ret = contacts_phone_log_delete(op, extra_data1);
+ ret = ctsvc_phone_log_delete(op, extra_data1);
break;
default:
CTS_ERR("Invalid parameter : the operation is not proper (op : %d)", op);
}
}
DATA_FREE:
+ ctsvc_handle_destroy(contact);
free(number);
return;
goto ERROR_RETURN;
}
- ret = contacts_setting_get_name_display_order(&order);
+ ret = ctsvc_setting_get_name_display_order(&order);
ERROR_RETURN:
if (outdata) {
goto ERROR_RETURN;
}
- ret = contacts_setting_get_name_sorting_order(&order);
+ ret = ctsvc_setting_get_name_sorting_order(&order);
ERROR_RETURN:
if (outdata) {
goto ERROR_RETURN;
}
- ret = contacts_setting_set_name_display_order((contacts_name_display_order_e)order);
+ ret = ctsvc_setting_set_name_display_order((contacts_name_display_order_e)order);
ERROR_RETURN:
if (outdata) {
goto ERROR_RETURN;
}
- ret = contacts_setting_set_name_sorting_order((contacts_name_sorting_order_e)order);
+ ret = ctsvc_setting_set_name_sorting_order((contacts_name_sorting_order_e)order);
ERROR_RETURN:
if (outdata) {
char* ctsvc_get_langset()
{
- return langset;
+ return SAFE_STR(langset);
}
void ctsvc_set_langset(char *new_langset)
#include "ctsvc_server_utils.h"
#include "ctsvc_server_bg.h"
#include "ctsvc_server_update.h"
+#include "ctsvc_server_service.h"
+
#include "ctsvc_db_access_control.h"
#include "ctsvc_ipc_define.h"
snprintf(sock_file, sizeof(sock_file), CTSVC_SOCK_PATH"/.%s_for_subscribe", getuid(), CTSVC_IPC_SERVICE);
pims_ipc_svc_init_for_publish(sock_file, CTS_SECURITY_FILE_GROUP, 0660);
- ret = contacts_connect();
+ ret = ctsvc_connect();
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("contacts_connect fail(%d)", ret);
break;
ctsvc_unset_client_access_info();
- ret = contacts_disconnect();
+ ret = ctsvc_disconnect();
if (CONTACTS_ERROR_NONE != ret)
CTS_DBG("%d", ret);
void ctsvc_create_rep_set_permission(const char* directory, mode_t mode)
{
- if (-1 == access (directory, F_OK))
- {
+ if (-1 == access (directory, F_OK)) {
mkdir(directory, mode);
}
}
#include "ctsvc_notification.h"
#include "ctsvc_db_access_control.h"
-API int contacts_activity_delete_by_contact_id(int contact_id)
+int ctsvc_activity_delete_by_contact_id(int contact_id)
{
char query[CTS_SQL_MAX_LEN] = {0};
return ret;
}
-API int contacts_activity_delete_by_account_id(int account_id)
+int ctsvc_activity_delete_by_account_id(int account_id)
{
char query[CTS_SQL_MAX_LEN] = {0};
#ifndef __CTSVC_SERVER_ACTIVITY_H__
#define __CTSVC_SERVER_ACTIVITY_H__
+int ctsvc_activity_delete_by_contact_id(int contact_id);
+int ctsvc_activity_delete_by_account_id(int account_id);
+
+
#endif /* __CTSVC_SERVER_ACTIVITY_H__ */
#include "contacts.h"
#include "ctsvc_internal.h"
+#include "ctsvc_inotify.h"
+#include "ctsvc_handle.h"
#include "ctsvc_db_schema.h"
#include "ctsvc_db_sqlite.h"
+#include "ctsvc_server_service.h"
#include "ctsvc_server_bg.h"
#include "ctsvc_server_utils.h"
#include "ctsvc_db_utils.h"
GMutex __ctsvc_server_bg_delete_mutex;
account_subscribe_h account = NULL;
+contacts_h bg_contact;
static int __ctsvc_server_bg_contact_delete_step1(__ctsvc_delete_data_s* data)
{
}
result = calloc(1, sizeof(process_stat));
- if (NULL == result)
- {
+ if (NULL == result) {
CTS_ERR("calloc() Fail");
return NULL;
}
}
callback_data->step = STEP_1;
- ret = contacts_connect();
+ ret = ctsvc_connect();
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("contacts_connect() fail(%d)", ret);
free(callback_data);
ctsvc_unset_client_access_info();
- ret = contacts_disconnect();
+ ret = ctsvc_disconnect();
if (CONTACTS_ERROR_NONE != ret)
CTS_ERR("contacts_disconnect Fail(%d)", ret);
void ctsvc_server_bg_add_cb()
{
int ret;
- ret = contacts_db_add_changed_cb(_contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL);
- CTS_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);
- CTS_DBG("call contacts_db_add_changed_cb (_contacts_contact): return (%d)", ret);
+ ctsvc_handle_create(&bg_contact);
+ ret = ctsvc_inotify_subscribe(bg_contact, _contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL);
+ CTS_DBG("call ctsvc_inotify_subscribe (_contacts_address_book) : return (%d)", ret);
+
+ ret = ctsvc_inotify_subscribe(bg_contact, _contacts_contact._uri, __ctsvc_server_contact_deleted_cb, NULL);
+ CTS_DBG("call ctsvc_inotify_subscribe (_contacts_contact): return (%d)", ret);
ret = account_subscribe_create(&account);
if (ACCOUNT_ERROR_NONE == 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);
- CTS_ERR("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);
- CTS_ERR("call contacts_db_remove_changed_cb (_contacts_contact) : return (%d)", ret);
+
+ ret = ctsvc_inotify_unsubscribe(bg_contact, _contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL);
+ CTS_ERR("call ctsvc_inotify_unsubscribe (_contacts_address_book): return (%d)", ret);
+ ret = ctsvc_inotify_unsubscribe(bg_contact, _contacts_contact._uri, __ctsvc_server_contact_deleted_cb, NULL);
+ CTS_ERR("call ctsvc_inotify_unsubscribe (_contacts_contact) : return (%d)", ret);
if (account) {
account_unsubscribe_notification(account); /* unsubscirbe & destroy */
int info_len = 0;
char changed_info[30] = {0};
- if (!__phone_log_chanaged_info) {
+ if (NULL == __phone_log_chanaged_info) {
__phone_log_chanaged_info = (char*)calloc(CTSVC_SUBSCRIBE_MAX_LEN, sizeof(char));
__phone_log_buf_size = CTSVC_SUBSCRIBE_MAX_LEN;
__phone_log_chanaged_info[0] = '\0';
return ret;
}
-API int contacts_group_add_contact(int group_id, int contact_id)
+int ctsvc_group_add_contact(int group_id, int contact_id)
{
int ret;
int addressbook_id;
return CONTACTS_ERROR_NONE;
}
-API int contacts_group_remove_contact(int group_id, int contact_id)
+int ctsvc_group_remove_contact(int group_id, int contact_id)
{
int ret;
int addressbook_id;
}
-API int contacts_group_set_group_order(int group_id, int previous_group_id, int next_group_id)
+int ctsvc_group_set_group_order(int group_id, int previous_group_id, int next_group_id)
{
int ret;
double previous_prio = 0.0;
#define __CTSVC_SERVER_GROUP_H__
int ctsvc_group_add_contact_in_transaction(int group_id, int contact_id);
-
int ctsvc_group_remove_contact_in_transaction(int group_id, int contact_id);
+int ctsvc_group_add_contact(int group_id, int contact_id);
+int ctsvc_group_remove_contact(int group_id, int contact_id);
+int ctsvc_group_set_group_order(int group_id, int previous_group_id, int next_group_id);
+
+
/*
int ctsvc_group_add_contacts_in_person(int group_id, int person_id);
int ctsvc_group_remove_contacts_in_person(int group_id, int person_id);
return false;
}
-API int contacts_person_link_person(int base_person_id, int person_id)
+int ctsvc_person_link_person(int base_person_id, int person_id)
{
int ret;
char query[CTS_SQL_MIN_LEN] = {0};
return CONTACTS_ERROR_NONE;
}
-API int contacts_person_unlink_contact(int person_id, int contact_id, int* out_person_id)
+int ctsvc_person_unlink_contact(int person_id, int contact_id, int* out_person_id)
{
int ret;
int id;
return CONTACTS_ERROR_NONE;
}
-API int contacts_person_reset_usage(int person_id, contacts_usage_type_e type)
+int ctsvc_person_reset_usage(int person_id, contacts_usage_type_e type)
{
int ret ;
char query[CTS_SQL_MAX_LEN] = {0};
return CONTACTS_ERROR_NONE;
}
-API int contacts_person_set_favorite_order(int person_id, int front_person_id, int back_person_id)
+int ctsvc_person_set_favorite_order(int person_id, int front_person_id, int back_person_id)
{
int ret;
double front_prio = 0.0;
return CONTACTS_ERROR_NONE;
}
-API int contacts_person_set_default_property(contacts_person_property_e property, int person_id,
+int ctsvc_person_set_default_property(contacts_person_property_e property, int person_id,
int id)
{
int ret;
return ret;
}
-API int contacts_person_get_default_property(contacts_person_property_e property, int person_id,
+int ctsvc_person_get_default_property(contacts_person_property_e property, int person_id,
int *id)
{
int ret = CONTACTS_ERROR_NONE;
int ctsvc_person_do_garbage_collection(void);
int ctsvc_person_aggregate(int person_id);
void ctsvc_db_person_delete_callback(sqlite3_context * context, int argc, sqlite3_value ** argv);
+int ctsvc_person_link_person(int base_person_id, int person_id);
+int ctsvc_person_unlink_contact(int person_id, int contact_id, int* out_person_id );
+int ctsvc_person_reset_usage(int person_id, contacts_usage_type_e type);
+int ctsvc_person_set_favorite_order(int person_id, int front_person_id, int back_person_id);
+int ctsvc_person_set_default_property(contacts_person_property_e property, int person_id, int id);
+int ctsvc_person_get_default_property(contacts_person_property_e property, int person_id, int *id);
#endif /* __CTSVC_SERVER_PERSON_H__ */
#include "ctsvc_server_sim.h"
#endif /* _CONTACTS_IPC_SERVER */
-API int contacts_phone_log_reset_statistics()
+int ctsvc_phone_log_reset_statistics()
{
char query[CTS_SQL_MIN_LEN] = {0};
snprintf(query, sizeof(query),"DELETE FROM "CTS_TABLE_PHONELOG_STAT);
return ctsvc_query_exec(query);
}
-API int contacts_phone_log_delete(contacts_phone_log_delete_e op, ...)
+int ctsvc_phone_log_delete(contacts_phone_log_delete_e op, ...)
{
int ret;
int extra_data1;
#define __CTSVC_SERVER_PHONELOG_H__
#include "ctsvc_db_sqlite.h"
+#include "contacts_phone_log_internal.h"
+
+int ctsvc_phone_log_reset_statistics();
+int ctsvc_phone_log_delete(contacts_phone_log_delete_e op, ...);
void ctsvc_db_phone_log_delete_callback(sqlite3_context * context,
int argc, sqlite3_value ** argv);
int ctsvc_db_phone_log_update_person_id(const char *number, int old_person_id, int candidate_person_id, bool person_link);
static int ctsvc_connection = 0;
static __thread int thread_connection = 0;
-API int contacts_connect()
+int ctsvc_connect()
{
CTS_FN_CALL;
int ret;
return CONTACTS_ERROR_NONE;
}
-API int contacts_disconnect()
+int ctsvc_disconnect()
{
ctsvc_mutex_lock(CTS_MUTEX_CONNECTION);
#ifndef __CTSVC_SERVER_SERVICE_H__
#define __CTSVC_SERVER_SERVICE_H__
+int ctsvc_connect();
+int ctsvc_disconnect();
int ctsvc_contacts_internal_disconnect();
#endif /* __CTSVC_SERVER_SERVICE_H__ */
#include "ctsvc_server_change_subject.h"
#endif
-#ifdef _CONTACTS_NATIVE
-static int __ctsvc_vconf_ref_count = 0;
-#endif
-
static int primary_sort = -1;
static int secondary_sort = -1;
static const char *CTSVC_VCONF_SORTING_ORDER = VCONFKEY_CONTACTS_SVC_NAME_SORTING_ORDER;
static const char *CTSVC_VCONF_PHONENUMBER_MIN_MATCH_DIGIT = VCONFKEY_CONTACTS_SVC_PHONENUMBER_MIN_MATCH_DIGIT;
-API int contacts_setting_get_name_display_order(contacts_name_display_order_e *order)
+int ctsvc_setting_get_name_display_order(contacts_name_display_order_e *order)
{
int ret;
return CONTACTS_ERROR_NONE;
}
-API int contacts_setting_set_name_display_order(contacts_name_display_order_e order)
+int ctsvc_setting_set_name_display_order(contacts_name_display_order_e order)
{
int ret;
RETVM_IF(CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST != order && CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST != order,
return CONTACTS_ERROR_NONE;
}
-API int contacts_setting_get_name_sorting_order(contacts_name_sorting_order_e *order)
+int ctsvc_setting_get_name_sorting_order(contacts_name_sorting_order_e *order)
{
int ret;
if (name_sorting_order < 0) {
return CONTACTS_ERROR_NONE;
}
-API int contacts_setting_set_name_sorting_order(contacts_name_sorting_order_e order)
+int ctsvc_setting_set_name_sorting_order(contacts_name_sorting_order_e order)
{
int ret;
RETVM_IF(CONTACTS_NAME_SORTING_ORDER_FIRSTLAST != order && CONTACTS_NAME_SORTING_ORDER_LASTFIRST != order,
{
int ret;
-#ifdef _CONTACTS_NATIVE
- __ctsvc_vconf_ref_count++;
- if (__ctsvc_vconf_ref_count != 1)
- return;
-#endif
// display order
ret = vconf_get_int(CTSVC_VCONF_DISPLAY_ORDER, &name_display_order);
{
int ret;
-#ifdef _CONTACTS_NATIVE
- __ctsvc_vconf_ref_count--;
- if (__ctsvc_vconf_ref_count != 0)
- return;
-#endif
ret = vconf_ignore_key_changed(CTSVC_VCONF_DISPLAY_ORDER, ctsvc_vconf_display_order_cb);
RETM_IF(ret<0,"vconf_ignore_key_changed(display order) Fail(%d)", ret);
return phonenumber_min_match_digit;
}
+void ctsvc_set_phonenumber_min_match_digit(int min)
+{
+ phonenumber_min_match_digit = min;
+}
+
+
const char* ctsvc_get_default_sort_vconfkey(void)
{
return "file/private/contacts-service/default_lang";
return secondary_sort;
}
-#ifdef _CONTACTS_NATIVE
-API int contacts_setting_add_name_display_order_changed_cb(
- contacts_setting_name_display_order_changed_cb cb, void* user_data)
-{
- CTS_ERR("Please use contacts-service2 instead of contacts-service3");
- return CONTACTS_ERROR_INTERNAL;
-}
-
-API int contacts_setting_remove_name_display_order_changed_cb(
- contacts_setting_name_display_order_changed_cb cb, void* user_data)
-{
- CTS_ERR("Please use contacts-service2 instead of contacts-service3");
- return CONTACTS_ERROR_INTERNAL;
-
-}
-
-API int contacts_setting_add_name_sorting_order_changed_cb(
- contacts_setting_name_sorting_order_changed_cb cb, void* user_data)
-{
- CTS_ERR("Please use contacts-service2 instead of contacts-service3");
- return CONTACTS_ERROR_INTERNAL;
-}
-
-
-API int contacts_setting_remove_name_sorting_order_changed_cb(
- contacts_setting_name_sorting_order_changed_cb cb, void* user_data)
-{
- CTS_ERR("Please use contacts-service2 instead of contacts-service3");
- return CONTACTS_ERROR_INTERNAL;
-}
-
-#endif
#ifndef __CTSVC_SERVER_SETTING_H__
#define __CTSVC_SERVER_SETTING_H__
+int ctsvc_setting_get_name_display_order(contacts_name_display_order_e *order);
+int ctsvc_setting_set_name_display_order(contacts_name_display_order_e order);
+int ctsvc_setting_get_name_sorting_order(contacts_name_sorting_order_e *order);
+int ctsvc_setting_set_name_sorting_order(contacts_name_sorting_order_e order);
+
int ctsvc_register_vconf(void);
void ctsvc_deregister_vconf(void);
int ctsvc_get_phonenumber_min_match_digit(void);
+void ctsvc_set_phonenumber_min_match_digit(int min);
int ctsvc_get_primary_sort(void);
int ctsvc_get_secondary_sort(void);
const char *ctsvc_get_default_sort_vconfkey(void);
#include "ctsvc_db_utils.h"
#include "ctsvc_list.h"
#include "ctsvc_db_access_control.h"
+#include "ctsvc_db_query.h"
/* #define CTSVC_SIM_FIELD_FULL_SUPPORT// support ANR,EMAIL2,3,NICK NAME */
#define DEFAULT_ADDRESS_BOOK_ID 0
RETVM_IF(-1 == sockfd, CONTACTS_ERROR_SYSTEM, "socket() Fail(errno = %d)", errno);
ret = bind(sockfd, (struct sockaddr *)&addr, sizeof(addr));
- RETVM_IF(-1 == ret, CONTACTS_ERROR_SYSTEM, "bind() Fail(errno = %d)", errno);
+ if (-1 == ret){
+ close(sockfd);
+ CTS_ERR("bind() Failed(errno = %d)", errno);
+ return CONTACTS_ERROR_SYSTEM;
+ }
ret = chown(sock_file, getuid(), CTS_SECURITY_FILE_GROUP);
if (0 != ret)
static int __ctsvc_db_activity_delete_record(int id);
static int __ctsvc_db_activity_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_activity_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-/* static int __ctsvc_db_activity_insert_records(const contacts_list_h in_list, int **ds); */
-/* static int __ctsvc_db_activity_update_records(const contacts_list_h in_list); */
-/* static int __ctsvc_db_activity_delete_records(int ids[], int count); */
ctsvc_db_plugin_info_s ctsvc_db_plugin_activity = {
.is_query_only = false,
.delete_record = __ctsvc_db_activity_delete_record,
.get_all_records = __ctsvc_db_activity_get_all_records,
.get_records_with_query = __ctsvc_db_activity_get_records_with_query,
- .insert_records = NULL, //__ctsvc_db_activity_insert_records,
- .update_records = NULL, //__ctsvc_db_activity_update_records,
- .delete_records = NULL, //__ctsvc_db_activity_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
return ret;
}
activity_id = ctsvc_stmt_get_int(stmt, 0);
- ret = contacts_db_get_record(_contacts_activity._uri, activity_id, &record);
+ ret = ctsvc_db_get_record(_contacts_activity._uri, activity_id, &record);
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("DB error : contacts_db_get_record() Fail(%d)", ret);
ctsvc_stmt_finalize(stmt);
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-//static int __ctsvc_db_activity_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_activity_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_activity_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_address_delete_record(int id);
static int __ctsvc_db_address_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_address_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_address_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_address_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_address_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_address = {
.is_query_only = false,
.delete_record = __ctsvc_db_address_delete_record,
.get_all_records = __ctsvc_db_address_get_all_records,
.get_records_with_query = __ctsvc_db_address_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_address_insert_records,
- .update_records = NULL,//__ctsvc_db_address_update_records,
- .delete_records = NULL,//__ctsvc_db_address_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_address_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_address_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_address_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_addressbook_delete_record(int id);
static int __ctsvc_db_addressbook_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_addressbook_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_addressbook_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_addressbook_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_addressbook_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_addressbook = {
.is_query_only = false,
.delete_record = __ctsvc_db_addressbook_delete_record,
.get_all_records = __ctsvc_db_addressbook_get_all_records,
.get_records_with_query = __ctsvc_db_addressbook_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_addressbook_insert_records,
- .update_records = NULL,//__ctsvc_db_addressbook_update_records,
- .delete_records = NULL,//__ctsvc_db_addressbook_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
return CONTACTS_ERROR_NONE;
}
-#if 0
-static int __ctsvc_db_addressbook_insert_records(const contacts_list_h in_list, int **ids)
-{
- return CONTACTS_ERROR_NONE;
-}
-
-static int __ctsvc_db_addressbook_update_records(const contacts_list_h in_list)
-{
- return CONTACTS_ERROR_NONE;
-}
-
-static int __ctsvc_db_addressbook_delete_records(int ids[], int count)
-{
- return CONTACTS_ERROR_NONE;
-}
-#endif
static int __ctsvc_db_company_delete_record(int id);
static int __ctsvc_db_company_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_company_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_company_insert_records(const contacts_list_h in_list, int **ds);
-//static int __ctsvc_db_company_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_company_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_company = {
.is_query_only = false,
.delete_record = __ctsvc_db_company_delete_record,
.get_all_records = __ctsvc_db_company_get_all_records,
.get_records_with_query = __ctsvc_db_company_get_records_with_query,
- .insert_records = NULL, /* __ctsvc_db_company_insert_records, */
- .update_records = NULL, /* __ctsvc_db_company_update_records, */
- .delete_records = NULL, /* __ctsvc_db_company_delete_records, */
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_company_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_company_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_company_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_contact_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_contact_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_contact_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_contact_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_contact_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_contact = {
.is_query_only = false,
.delete_record = __ctsvc_db_contact_delete_record,
.get_all_records = __ctsvc_db_contact_get_all_records,
.get_records_with_query = __ctsvc_db_contact_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_contact_insert_records,
- .update_records = NULL,//__ctsvc_db_contact_update_records,
- .delete_records = NULL,//__ctsvc_db_contact_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = __ctsvc_db_contact_replace_record,
return CONTACTS_ERROR_NONE;
}
-/*
- * static int __ctsvc_db_contact_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
- * static int __ctsvc_db_contact_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
- * static int __ctsvc_db_contact_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
- */
static int __ctsvc_contact_insert_data(ctsvc_contact_s *contact)
{
static int __ctsvc_db_email_delete_record(int id);
static int __ctsvc_db_email_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_email_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_email_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_email_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_email_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_email = {
.is_query_only = false,
.delete_record = __ctsvc_db_email_delete_record,
.get_all_records = __ctsvc_db_email_get_all_records,
.get_records_with_query = __ctsvc_db_email_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_email_insert_records,
- .update_records = NULL,//__ctsvc_db_email_update_records,
- .delete_records = NULL,//__ctsvc_db_email_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_email_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_email_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_email_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_event_delete_record(int id);
static int __ctsvc_db_event_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_event_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_event_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_event_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_event_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_event = {
.is_query_only = false,
.delete_record = __ctsvc_db_event_delete_record,
.get_all_records = __ctsvc_db_event_get_all_records,
.get_records_with_query = __ctsvc_db_event_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_event_insert_records,
- .update_records = NULL,//__ctsvc_db_event_update_records,
- .delete_records = NULL,//__ctsvc_db_event_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_event_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_event_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_event_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_extension_delete_record(int id);
static int __ctsvc_db_extension_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_extension_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_extension_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_extension_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_extension_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_extension = {
.is_query_only = false,
.delete_record = __ctsvc_db_extension_delete_record,
.get_all_records = __ctsvc_db_extension_get_all_records,
.get_records_with_query = __ctsvc_db_extension_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_extension_insert_records,
- .update_records = NULL,//__ctsvc_db_extension_update_records,
- .delete_records = NULL,//__ctsvc_db_extension_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_extension_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_extension_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_extension_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_group_delete_record(int id);
static int __ctsvc_db_group_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_group_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_group_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_group_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_group_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_group = {
.is_query_only = false,
.delete_record = __ctsvc_db_group_delete_record,
.get_all_records = __ctsvc_db_group_get_all_records,
.get_records_with_query = __ctsvc_db_group_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_group_insert_records,
- .update_records = NULL,//__ctsvc_db_group_update_records,
- .delete_records = NULL,//__ctsvc_db_group_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
return CONTACTS_ERROR_NONE;
}
-//static int __ctsvc_db_group_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_group_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_group_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
-
static int __ctsvc_db_grouprelation_delete_record(int id);
static int __ctsvc_db_grouprelation_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_grouprelation_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_grouprelation_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_grouprelation_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_grouprelation_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_grouprelation = {
.is_query_only = false,
.delete_record = __ctsvc_db_grouprelation_delete_record,
.get_all_records = __ctsvc_db_grouprelation_get_all_records,
.get_records_with_query = __ctsvc_db_grouprelation_get_records_with_query,
- .insert_records = NULL, //__ctsvc_db_grouprelation_insert_records,
- .update_records = NULL, //__ctsvc_db_grouprelation_update_records,
- .delete_records = NULL, //__ctsvc_db_grouprelation_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_grouprelation_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_grouprelation_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_grouprelation_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_image_delete_record(int id);
static int __ctsvc_db_image_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_image_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_image_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_image_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_image_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_image = {
.is_query_only = false,
.delete_record = __ctsvc_db_image_delete_record,
.get_all_records = __ctsvc_db_image_get_all_records,
.get_records_with_query = __ctsvc_db_image_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_image_insert_records,
- .update_records = NULL,//__ctsvc_db_image_update_records,
- .delete_records = NULL,//__ctsvc_db_image_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_image_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_image_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_image_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_messenger_delete_record(int id);
static int __ctsvc_db_messenger_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_messenger_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_messenger_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_messenger_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_messenger_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_messenger = {
.is_query_only = false,
.delete_record = __ctsvc_db_messenger_delete_record,
.get_all_records = __ctsvc_db_messenger_get_all_records,
.get_records_with_query = __ctsvc_db_messenger_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_messenger_insert_records,
- .update_records = NULL,//__ctsvc_db_messenger_update_records,
- .delete_records = NULL,//__ctsvc_db_messenger_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
return CONTACTS_ERROR_NONE;
}
-//static int __ctsvc_db_messenger_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_messenger_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_messenger_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
return ret;
}
my_profile_id = ctsvc_stmt_get_int(stmt, 0);
- ret = contacts_db_get_record(_contacts_my_profile._uri, my_profile_id, &record);
+ ret = ctsvc_db_get_record(_contacts_my_profile._uri, my_profile_id, &record);
if (CONTACTS_ERROR_NONE != ret) {
CTS_ERR("DB error : contacts_db_get_record() Fail(%d)", ret);
ctsvc_stmt_finalize(stmt);
return CONTACTS_ERROR_NONE;
}
-//static int __ctsvc_db_my_profile_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_my_profile_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_my_profile_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
-
static int __ctsvc_my_profile_insert_data(ctsvc_my_profile_s *contact)
{
int ret;
static int __ctsvc_db_name_delete_record(int id);
static int __ctsvc_db_name_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_name_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_name_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_name_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_name_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_name = {
.is_query_only = false,
.delete_record = __ctsvc_db_name_delete_record,
.get_all_records = __ctsvc_db_name_get_all_records,
.get_records_with_query = __ctsvc_db_name_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_name_insert_records,
- .update_records = NULL,//__ctsvc_db_name_update_records,
- .delete_records = NULL,//__ctsvc_db_name_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_name_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_name_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_name_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_nickname_delete_record(int id);
static int __ctsvc_db_nickname_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_nickname_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_nickname_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_nickname_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_nickname_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_nickname = {
.is_query_only = false,
.delete_record = __ctsvc_db_nickname_delete_record,
.get_all_records = __ctsvc_db_nickname_get_all_records,
.get_records_with_query = __ctsvc_db_nickname_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_nickname_insert_records,
- .update_records = NULL,//__ctsvc_db_nickname_update_records,
- .delete_records = NULL,//__ctsvc_db_nickname_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_nickname_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_nickname_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_nickname_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_note_delete_record(int id);
static int __ctsvc_db_note_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_note_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_note_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_note_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_note_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_note = {
.is_query_only = false,
.delete_record = __ctsvc_db_note_delete_record,
.get_all_records = __ctsvc_db_note_get_all_records,
.get_records_with_query = __ctsvc_db_note_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_note_insert_records,
- .update_records = NULL,//__ctsvc_db_note_update_records,
- .delete_records = NULL,//__ctsvc_db_note_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_note_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_note_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_note_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_number_delete_record(int id);
static int __ctsvc_db_number_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_number_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_number_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_number_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_number_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_number = {
.is_query_only = false,
.delete_record = __ctsvc_db_number_delete_record,
.get_all_records = __ctsvc_db_number_get_all_records,
.get_records_with_query = __ctsvc_db_number_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_number_insert_records,
- .update_records = NULL,//__ctsvc_db_number_update_records,
- .delete_records = NULL,//__ctsvc_db_number_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_number_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_number_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_number_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_person_delete_record(int id);
static int __ctsvc_db_person_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_person_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_person_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_person_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_person_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_person = {
.is_query_only = false,
.delete_record = __ctsvc_db_person_delete_record,
.get_all_records = __ctsvc_db_person_get_all_records,
.get_records_with_query = __ctsvc_db_person_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_person_insert_records,
- .update_records = NULL,//__ctsvc_db_person_update_records,
- .delete_records = NULL,//__ctsvc_db_person_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
return CONTACTS_ERROR_NONE;
}
-#if 0
-static int __ctsvc_db_person_insert_records(const contacts_list_h in_list, int **ids)
-{
- return CONTACTS_ERROR_NONE;
-}
-
-static int __ctsvc_db_person_update_records(const contacts_list_h in_list)
-{
- return CONTACTS_ERROR_NONE;
-}
-
-static int __ctsvc_db_person_delete_records(int ids[], int count)
-{
- return CONTACTS_ERROR_NONE;
-}
-#endif
static int __ctsvc_db_phonelog_delete_record(int id);
static int __ctsvc_db_phonelog_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_phonelog_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_phonelog_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_phonelog_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_phonelog_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_phonelog = {
.is_query_only = false,
.delete_record = __ctsvc_db_phonelog_delete_record,
.get_all_records = __ctsvc_db_phonelog_get_all_records,
.get_records_with_query = __ctsvc_db_phonelog_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_phonelog_insert_records,
- .update_records = NULL,//__ctsvc_db_phonelog_update_records,
- .delete_records = NULL,//__ctsvc_db_phonelog_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
return CONTACTS_ERROR_NONE;
}
-//static int __ctsvc_db_phonelog_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_phonelog_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_phonelog_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
-
static int __ctsvc_db_phonelog_increase_outgoing_count(ctsvc_phonelog_s *phonelog)
{
int ret;
static int __ctsvc_db_profile_delete_record(int id);
static int __ctsvc_db_profile_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_profile_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_profile_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_profile_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_profile_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_profile = {
.is_query_only = false,
.delete_record = __ctsvc_db_profile_delete_record,
.get_all_records = __ctsvc_db_profile_get_all_records,
.get_records_with_query = __ctsvc_db_profile_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_profile_insert_records,
- .update_records = NULL,//__ctsvc_db_profile_update_records,
- .delete_records = NULL,//__ctsvc_db_profile_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_profile_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_profile_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_profile_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_relationship_delete_record(int id);
static int __ctsvc_db_relationship_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_relationship_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_relationship_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_relationship_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_relationship_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_relationship = {
.is_query_only = false,
.delete_record = __ctsvc_db_relationship_delete_record,
.get_all_records = __ctsvc_db_relationship_get_all_records,
.get_records_with_query = __ctsvc_db_relationship_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_relationship_insert_records,
- .update_records = NULL,//__ctsvc_db_relationship_update_records,
- .delete_records = NULL,//__ctsvc_db_relationship_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_relationship_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_relationship_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_relationship_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
#include "ctsvc_notification.h"
#include "ctsvc_server_utils.h"
-//static int __ctsvc_db_sdn_insert_record(contacts_record_h record, int *id);
static int __ctsvc_db_sdn_get_record(int id, contacts_record_h* record);
-//static int __ctsvc_db_sdn_update_record(contacts_record_h record);
-//static int __ctsvc_db_sdn_delete_record(int id);
static int __ctsvc_db_sdn_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_sdn_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_sdn_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_sdn_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_sdn_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_sdn = {
.is_query_only = false,
- .insert_record = NULL,//__ctsvc_db_sdn_insert_record,
+ .insert_record = NULL,
.get_record = __ctsvc_db_sdn_get_record,
- .update_record = NULL,//__ctsvc_db_sdn_update_record,
- .delete_record = NULL,//__ctsvc_db_sdn_delete_record,
+ .update_record = NULL,
+ .delete_record = NULL,
.get_all_records = __ctsvc_db_sdn_get_all_records,
.get_records_with_query = __ctsvc_db_sdn_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_sdn_insert_records,
- .update_records = NULL,//__ctsvc_db_sdn_update_records,
- .delete_records = NULL,//__ctsvc_db_sdn_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
return CONTACTS_ERROR_NONE;
}
-#if 0
-static int __ctsvc_db_sdn_insert_record(contacts_record_h record, int *id)
-{
- int ret;
- ctsvc_sdn_s *sdn = (ctsvc_sdn_s*)record;
-
- RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == sdn->name, CONTACTS_ERROR_INVALID_PARAMETER);
- RETVM_IF(CTSVC_RECORD_SDN != sdn->base.r_type, CONTACTS_ERROR_INVALID_PARAMETER,
- "Invalid parameter : record is invalid type(%d)", sdn->base.r_type);
-
- cts_stmt stmt = NULL;
- char query[CTS_SQL_MAX_LEN] = {0};
-
- snprintf(query, sizeof(query),
- "INSERT INTO "CTS_TABLE_SDN"(name, number, sim_slot_no) VALUES(?, ?, ?)");
-
- ret = ctsvc_query_prepare(query, &stmt);
- RETVM_IF(NULL == stmt, ret, "DB error : ctsvc_query_prepare() Fail(%d)", ret);
-
- ctsvc_stmt_bind_text(stmt, 1, sdn->name);
- ctsvc_stmt_bind_text(stmt, 2, sdn->number);
- ctsvc_stmt_bind_int(stmt, 3, sdn->sim_slot_no);
-
- ret = ctsvc_begin_trans();
- if (ret < CONTACTS_ERROR_NONE) {
- CTS_ERR("DB error : ctsvc_begin_trans() Fail(%d)", ret);
- ctsvc_stmt_finalize(stmt);
- return ret;
- }
-
- ret = ctsvc_stmt_step(stmt);
- if (CONTACTS_ERROR_NONE != ret) {
- CTS_ERR("DB error : ctsvc_stmt_step() Fail(%d)", ret);
- ctsvc_stmt_finalize(stmt);
- ctsvc_end_trans(false);
- return ret;
- }
-
- //sdn->id = ctsvc_db_get_last_insert_id();
- if (id)
- *id = ctsvc_db_get_last_insert_id();
- ctsvc_stmt_finalize(stmt);
-
- ctsvc_set_sdn_noti();
- ret = ctsvc_end_trans(true);
- if (ret < CONTACTS_ERROR_NONE) {
- CTS_ERR("DB error : ctsvc_end_trans() Fail(%d)", ret);
- return ret;
- }
-
- return CONTACTS_ERROR_NONE;
-}
-
-static int __ctsvc_db_sdn_update_record(contacts_record_h record)
-{
- int sdn_id;
- int ret = CONTACTS_ERROR_NONE;
- char* set = NULL;
- GSList *bind_text = NULL;
- GSList *cursor = NULL;
- ctsvc_sdn_s *sdn = (ctsvc_sdn_s*)record;
- char query[CTS_SQL_MIN_LEN] = {0};
-
- RETV_IF(NULL == record, CONTACTS_ERROR_INVALID_PARAMETER);
- RETVM_IF(CTSVC_RECORD_SDN != sdn->base.r_type, CONTACTS_ERROR_INVALID_PARAMETER,
- "Invalid parameter : record is invalid type(%d)", sdn->base.r_type);
- RETVM_IF(!sdn->id, CONTACTS_ERROR_INVALID_PARAMETER, "sdn of contact has no ID.");
- RETV_IF(NULL == sdn->name, CONTACTS_ERROR_INVALID_PARAMETER);
- RETVM_IF(CTSVC_PROPERTY_FLAG_DIRTY != (sdn->base.property_flag & CTSVC_PROPERTY_FLAG_DIRTY), CONTACTS_ERROR_NONE, "No update");
-
- ret = ctsvc_begin_trans();
- RETVM_IF(ret < CONTACTS_ERROR_NONE, ret, "DB error : ctsvc_begin_trans() Fail(%d)", ret);
-
- snprintf(query, sizeof(query),
- "SELECT id FROM "CTS_TABLE_SDN" WHERE id = %d", sdn->id);
- ret = ctsvc_query_get_first_int_result(query, &sdn_id);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_query_get_first_int_result Fail(%d)", ret);
- ctsvc_end_trans(false);
- return ret;
- }
-
- do {
- if (CONTACTS_ERROR_NONE != (ret = ctsvc_db_create_set_query(record, &set, &bind_text))) break;
- if (CONTACTS_ERROR_NONE != (ret = ctsvc_db_update_record_with_set_query(set, bind_text, CTS_TABLE_SDN, sdn->id))) break;
- ctsvc_set_sdn_noti();
- } while (0);
-
- CTSVC_RECORD_RESET_PROPERTY_FLAGS((ctsvc_record_s *)record);
- CONTACTS_FREE(set);
- if (bind_text) {
- for (cursor=bind_text;cursor;cursor=cursor->next)
- CONTACTS_FREE(cursor->data);
- g_slist_free(bind_text);
- }
-
- ret = ctsvc_end_trans(true);
- RETVM_IF(ret < CONTACTS_ERROR_NONE, ret, "DB error : ctsvc_end_trans() Fail(%d)", ret);
-
- return CONTACTS_ERROR_NONE;
-}
-
-static int __ctsvc_db_sdn_delete_record(int sdn_id)
-{
- int ret;
- int id;
- char query[CTS_SQL_MAX_LEN] = {0};
-
- ret = ctsvc_begin_trans();
- RETVM_IF(ret < CONTACTS_ERROR_NONE, ret, "DB error : ctsvc_begin_trans() Fail(%d)", ret);
-
- snprintf(query, sizeof(query),
- "SELECT id FROM "CTS_TABLE_SDN" WHERE id = %d", sdn_id);
- ret = ctsvc_query_get_first_int_result(query, &id);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("ctsvc_query_get_first_int_result Fail(%d)", ret);
- ctsvc_end_trans(false);
- return ret;
- }
-
- snprintf(query, sizeof(query), "DELETE FROM "CTS_TABLE_SDN" WHERE id = %d", sdn_id);
- ret = ctsvc_query_exec(query);
- if (CONTACTS_ERROR_NONE != ret) {
- CTS_ERR("DB error : ctsvc_query_exec() Fail(%d)", ret);
- ctsvc_end_trans(false);
- return ret;
- }
-
- ret = ctsvc_db_change();
- if (ret <= 0) {
- ret = CONTACTS_ERROR_NO_DATA;
- ctsvc_end_trans(false);
- return ret;
- }
-
- ctsvc_set_sdn_noti();
- ret = ctsvc_end_trans(true);
- if (ret != CONTACTS_ERROR_NONE) {
- CTS_ERR("DB error : ctsvc_end_trans() Fail(%d)", ret);
- return ret;
- }
-
- return CONTACTS_ERROR_NONE;
-}
-#endif
-
static int __ctsvc_db_sdn_get_all_records(int offset, int limit,
contacts_list_h* out_list)
{
return CONTACTS_ERROR_NONE;
}
-#if 0
-static int __ctsvc_db_sdn_insert_records(const contacts_list_h in_list, int **ids)
-{
- return CONTACTS_ERROR_NONE;
-}
-
-static int __ctsvc_db_sdn_update_records(const contacts_list_h in_list)
-{
- return CONTACTS_ERROR_NONE;
-}
-
-static int __ctsvc_db_sdn_delete_records(int ids[], int count)
-{
- return CONTACTS_ERROR_NONE;
-}
-#endif
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_simple_contact_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_simple_contact_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_simple_contact_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_speeddial_delete_record(int id);
static int __ctsvc_db_speeddial_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_speeddial_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_speeddial_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_speeddial_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_speeddial_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_speeddial = {
.is_query_only = false,
.delete_record = __ctsvc_db_speeddial_delete_record,
.get_all_records = __ctsvc_db_speeddial_get_all_records,
.get_records_with_query = __ctsvc_db_speeddial_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_speeddial_insert_records,
- .update_records = NULL,//__ctsvc_db_speeddial_update_records,
- .delete_records = NULL,//__ctsvc_db_speeddial_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_speeddial_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_speeddial_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_speeddial_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
static int __ctsvc_db_url_delete_record(int id);
static int __ctsvc_db_url_get_all_records(int offset, int limit, contacts_list_h* out_list);
static int __ctsvc_db_url_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list);
-//static int __ctsvc_db_url_insert_records(const contacts_list_h in_list, int **ids);
-//static int __ctsvc_db_url_update_records(const contacts_list_h in_list);
-//static int __ctsvc_db_url_delete_records(int ids[], int count);
ctsvc_db_plugin_info_s ctsvc_db_plugin_url = {
.is_query_only = false,
.delete_record = __ctsvc_db_url_delete_record,
.get_all_records = __ctsvc_db_url_get_all_records,
.get_records_with_query = __ctsvc_db_url_get_records_with_query,
- .insert_records = NULL,//__ctsvc_db_url_insert_records,
- .update_records = NULL,//__ctsvc_db_url_update_records,
- .delete_records = NULL,//__ctsvc_db_url_delete_records
+ .insert_records = NULL,
+ .update_records = NULL,
+ .delete_records = NULL,
.get_count = NULL,
.get_count_with_query = NULL,
.replace_record = NULL,
*out_list = list;
return CONTACTS_ERROR_NONE;
}
-
-//static int __ctsvc_db_url_insert_records(const contacts_list_h in_list, int **ids) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_url_update_records(const contacts_list_h in_list) { return CONTACTS_ERROR_NONE; }
-//static int __ctsvc_db_url_delete_records(int ids[], int count) { return CONTACTS_ERROR_NONE; }
#include "ctsvc_db_plugin_person_helper.h"
#include "ctsvc_db_plugin_group_helper.h"
#include "ctsvc_db_plugin_company_helper.h"
+#include "ctsvc_db_query.h"
#ifdef _CONTACTS_IPC_SERVER
#include "ctsvc_server_sim.h"
filter->match = CONTACTS_MATCH_EXACTLY;
ret = __ctsvc_db_add_str_matching_rule(field_name, filter->match, &temp, &with_escape);
- RETVM_IF(ret <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
- "__ctsvc_db_add_str_matching_rule Fail");
+ if(ret <= 0 ){
+ free(temp);
+ CTS_ERR("__ctsvc_db_add_str_matching_rule Fail");
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
cond_len = snprintf(out_cond, sizeof(out_cond), "%s", temp);
free(temp);
temp = NULL;
ret = ctsvc_clean_number(filter->value.s, clean_num, sizeof(clean_num), false);
if (0 < ret) {
ret = ctsvc_normalize_number(clean_num, normal_num, sizeof(normal_num), false);
+ normal_num[sizeof(normal_num) -1] = '\0';
if (0 < ret) {
char min_match[strlen(filter->value.s)+1+5]; /* for cc */
ret = ctsvc_get_minmatch_number(normal_num, min_match, sizeof(min_match), ctsvc_get_phonenumber_min_match_digit());
if (add_condition)
cond_len += snprintf(out_cond+cond_len, sizeof(out_cond)-cond_len, " OR ");
ret = __ctsvc_db_add_str_matching_rule(clean_field, filter->match, &temp, &with_escape);
- RETVM_IF(ret <= 0, CONTACTS_ERROR_INVALID_PARAMETER,
- "__ctsvc_db_add_str_matching_rule Fail");
+ if(ret <= 0){
+ free(temp);
+ CTS_ERR("__ctsvc_db_add_str_matching_rule Fail");
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
cond_len += snprintf(out_cond+cond_len, sizeof(out_cond)-cond_len, "%s", temp);
free(temp);
temp = NULL;
contacts_name_sorting_order_e order;
const char *field = NULL;
char *temp_keyword = NULL;
- contacts_setting_get_name_sorting_order(&order);
+ ctsvc_setting_get_name_sorting_order(&order);
if (CONTACTS_NAME_SORTING_ORDER_FIRSTLAST == order)
field = "display_name";
return ret;
}
- ret = contacts_db_insert_record(record, &id[index++]);
+ ret = ctsvc_db_insert_record(record, &id[index++]);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("contacts_db_insert_record is faild(%d)", ret);
ctsvc_end_trans(false);
index = 0;
do {
- ret = contacts_db_delete_record(view_uri, ids[index++]);
+ ret = ctsvc_db_delete_record(view_uri, ids[index++]);
if (CONTACTS_ERROR_NO_DATA == ret) {
CTS_DBG("the record is not exist : %d", ret);
continue;
return ret;
}
- ret = contacts_db_update_record(record);
+ ret = ctsvc_db_update_record(record);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("contacts_db_update_record is faild(%d)", ret);
ctsvc_end_trans(false);
return ret;
}
-API int contacts_db_get_records_with_query(contacts_query_h query, int offset, int limit,
+int ctsvc_db_get_records_with_query(contacts_query_h query, int offset, int limit,
contacts_list_h* out_list)
{
int ret = CONTACTS_ERROR_NONE;
return CONTACTS_ERROR_NONE;
}
-API int contacts_db_get_changes_by_version(const char* view_uri, int addressbook_id,
+int ctsvc_db_get_changes_by_version(const char* view_uri, int addressbook_id,
int version, contacts_list_h* out_list, int* out_current_version)
{
int ret;
return CONTACTS_ERROR_INVALID_PARAMETER;
}
-API int contacts_db_get_current_version(int* out_current_version)
+int ctsvc_db_get_current_version(int* out_current_version)
{
RETVM_IF(NULL == out_current_version, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter");
return ctsvc_get_current_version(out_current_version);
}
-API int contacts_db_search_records(const char* view_uri, const char *keyword,
+int ctsvc_db_search_records(const char* view_uri, const char *keyword,
int offset, int limit, contacts_list_h* out_list)
{
RETV_IF(NULL == out_list, CONTACTS_ERROR_INVALID_PARAMETER);
return __ctsvc_db_search_records(view_uri, keyword, offset, limit, out_list);
}
-API int contacts_db_search_records_with_range(const char* view_uri, const char *keyword,
+int ctsvc_db_search_records_with_range(const char* view_uri, const char *keyword,
int offset, int limit, int range, contacts_list_h* out_list)
{
RETV_IF(NULL == out_list, CONTACTS_ERROR_INVALID_PARAMETER);
return __ctsvc_db_search_records_with_range(view_uri, keyword, offset, limit, range, out_list);
}
-API int contacts_db_search_records_with_query(contacts_query_h query, const char *keyword,
+int ctsvc_db_search_records_with_query(contacts_query_h query, const char *keyword,
int offset, int limit, contacts_list_h* out_list)
{
RETV_IF(NULL == out_list, CONTACTS_ERROR_INVALID_PARAMETER);
return __ctsvc_db_search_records_with_query(query, keyword, offset, limit, out_list);
}
-API int contacts_db_get_count(const char* view_uri, int *out_count)
+int ctsvc_db_get_count(const char* view_uri, int *out_count)
{
int ret;
ctsvc_db_plugin_info_s* plugin_info = NULL;
return __ctsvc_db_get_count(view_uri, out_count);
}
-API int contacts_db_get_count_with_query(contacts_query_h query, int *out_count)
+int ctsvc_db_get_count_with_query(contacts_query_h query, int *out_count)
{
int ret = CONTACTS_ERROR_NONE;
ctsvc_record_type_e type = CTSVC_RECORD_INVALID;
return __ctsvc_db_get_count_with_query(query, out_count);
}
-API int contacts_db_insert_record(contacts_record_h record, int *id)
+int ctsvc_db_insert_record(contacts_record_h record, int *id)
{
ctsvc_db_plugin_info_s* plugin_info = NULL;
return plugin_info->insert_record(record, id);
}
-API int contacts_db_update_record(contacts_record_h record)
+int ctsvc_db_update_record(contacts_record_h record)
{
ctsvc_db_plugin_info_s* plugin_info = NULL;
return plugin_info->update_record(record);
}
-API int contacts_db_delete_record(const char* view_uri, int id)
+int ctsvc_db_delete_record(const char* view_uri, int id)
{
ctsvc_record_type_e type = CTSVC_RECORD_INVALID;
ctsvc_db_plugin_info_s* plugin_info = NULL;
return plugin_info->delete_record(id);
}
-API int contacts_db_get_record(const char* view_uri, int id, contacts_record_h* out_record)
+int ctsvc_db_get_record(const char* view_uri, int id, contacts_record_h* out_record)
{
ctsvc_record_type_e type = CTSVC_RECORD_INVALID;
ctsvc_db_plugin_info_s* plugin_info = NULL;
return plugin_info->get_record(id, out_record);
}
-API int contacts_db_replace_record(contacts_record_h record, int id)
+int ctsvc_db_replace_record(contacts_record_h record, int id)
{
ctsvc_db_plugin_info_s* plugin_info = NULL;
return plugin_info->replace_record(record, id);
}
-API int contacts_db_get_all_records(const char* view_uri, int offset, int limit, contacts_list_h* out_list)
+int ctsvc_db_get_all_records(const char* view_uri, int offset, int limit, contacts_list_h* out_list)
{
int ret = CONTACTS_ERROR_NONE;
ctsvc_record_type_e type = CTSVC_RECORD_INVALID;
return ret;
}
- ret = contacts_db_replace_record(record, ids[i++]);
+ ret = ctsvc_db_replace_record(record, ids[i++]);
if (ret != CONTACTS_ERROR_NONE) {
CTS_ERR("contacts_db_replace_record is faild(%d)", ret);
ctsvc_end_trans(false);
return ret;
}
-int ctsvc_db_replace_records(contacts_list_h list, int ids[], unsigned int count)
+
+int ctsvc_db_replace_records(contacts_list_h list, int ids[], int count)
{
int ret = CONTACTS_ERROR_NONE;
ctsvc_db_plugin_info_s* plugin_info = NULL;
return __ctsvc_db_replace_records(list, ids, count);
}
-API int contacts_db_insert_records(contacts_list_h record_list, int **ids, int *count)
-{
- return ctsvc_db_insert_records(record_list, ids, count);
-}
-
-API int contacts_db_update_records(contacts_list_h record_list)
-{
- return ctsvc_db_update_records(record_list);
-}
-
-API int contacts_db_delete_records(const char* view_uri, int record_id_array[], int count)
-{
- return ctsvc_db_delete_records(view_uri, record_id_array, count);
-}
-
-API int contacts_db_replace_records(contacts_list_h list, int record_id_array[], int count)
-{
- return ctsvc_db_replace_records(list, record_id_array, count);
-}
-
-API int contacts_db_get_last_change_version(int* last_version)
-{
- int ret = CONTACTS_ERROR_NONE;
-
- RETVM_IF(NULL == last_version, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter");
- *last_version = ctsvc_get_transaction_ver();
- return ret;
-}
-
-API int contacts_db_get_status(contacts_db_status_e *status)
+int ctsvc_db_get_status(contacts_db_status_e *status)
{
*status = __db_status;
return CONTACTS_ERROR_NONE;
{
__db_status = status;
-#ifdef _CONTACTS_IPC_SERVER
ctsvc_change_subject_publish_status(status);
-#endif
return;
}
*
*/
-#ifndef __CTSVC_DB_SCHEMA_H__
-#define __CTSVC_DB_SCHEMA_H__
+#ifndef __CTSVC_DB_QUERY_H__
+#define __CTSVC_DB_QUERY_H__
#include "contacts.h"
#include "contacts_db_status.h"
#include "ctsvc_struct.h"
#include "ctsvc_db_sqlite.h"
-int ctsvc_db_insert_records(contacts_list_h list, int **ids, unsigned int *count);
+int ctsvc_db_insert_record(contacts_record_h record, int *id);
+int ctsvc_db_get_record(const char* view_uri, int id, contacts_record_h* out_record);
+int ctsvc_db_update_record(contacts_record_h record);
+int ctsvc_db_delete_record(const char* view_uri, int id);
+int ctsvc_db_replace_record(contacts_record_h record, int id);
+int ctsvc_db_get_all_records(const char* view_uri, int offset, int limit, contacts_list_h* out_list );
+int ctsvc_db_get_records_with_query(contacts_query_h query, int offset, int limit, contacts_list_h* out_list );
+int ctsvc_db_get_count(const char* view_uri, int *out_count);
+int ctsvc_db_get_count_with_query(contacts_query_h query, int *out_count);
+int ctsvc_db_get_changes_by_version(const char* view_uri, int addressbook_id, int version, contacts_list_h* out_list, int* out_current_version );
+int ctsvc_db_get_current_version(int* out_current_version);
+int ctsvc_db_search_records(const char* view_uri, const char *keyword, int offset, int limit, contacts_list_h* out_list);
+int ctsvc_db_search_records_with_range(const char* view_uri, const char *keyword, int offset, int limit, int range, contacts_list_h* out_list);
+int ctsvc_db_search_records_with_query(contacts_query_h query, const char *keyword, int offset, int limit, contacts_list_h* out_list);
+int ctsvc_db_get_status(contacts_db_status_e *status);
+int ctsvc_db_insert_records_with_vcard(const char* vcard_stream, int **record_id_array, int *count);
+int ctsvc_db_replace_records_with_vcard(const char* vcard_stream, int *record_id_array, int count);
+
+
+int ctsvc_db_insert_records(contacts_list_h list, int **ids, int *count);
int ctsvc_db_update_records(contacts_list_h list);
int ctsvc_db_delete_records(const char* view_uri, int *ids, int count);
-int ctsvc_db_replace_records(contacts_list_h list, int ids[], unsigned int count);
+int ctsvc_db_replace_records(contacts_list_h list, int ids[], int count);
int ctsvc_db_make_get_records_query_stmt(ctsvc_query_s *s_query, int offset, int limit, cts_stmt *stmt);
int ctsvc_db_create_set_query(contacts_record_h record, char **set, GSList **bind_text);
void ctsvc_db_set_status(contacts_db_status_e status);
-#endif /* __CTSVC_DB_SCHEMA_H__ */
+#endif /* __CTSVC_DB_QUERY_H__ */
static __thread sqlite3 *ctsvc_db = NULL;
-int ctsvc_db_open(void) {
+int ctsvc_db_open(void)
+{
CTS_FN_CALL;
int ret;
return CONTACTS_ERROR_NONE /*CTS_SUCCESS*/;
}
-int ctsvc_db_close(void) {
+int ctsvc_db_close(void)
+{
int ret = 0;
if (ctsvc_db) {
return CONTACTS_ERROR_NONE /*CTS_SUCCESS*/;
}
-int ctsvc_db_change(void) {
+int ctsvc_db_change(void)
+{
return sqlite3_changes(ctsvc_db);
}
-int ctsvc_db_get_last_insert_id(void) {
+int ctsvc_db_get_last_insert_id(void)
+{
return sqlite3_last_insert_rowid(ctsvc_db);
}
-int ctsvc_db_get_next_id(const char *table) {
+int ctsvc_db_get_next_id(const char *table)
+{
int id;
int ret;
char query[CTS_SQL_MAX_LEN] = { 0 };
}
}
-int ctsvc_query_get_first_int_result(const char *query, int *result) {
+int ctsvc_query_get_first_int_result(const char *query, int *result)
+{
int ret;
struct timeval from, now, diff;
bool retry = false;
return CONTACTS_ERROR_NONE;
}
-int ctsvc_query_exec(const char *query) {
+int ctsvc_query_exec(const char *query)
+{
int ret;
cts_stmt stmt = NULL;
char *err_msg = NULL;
return ret;
}
-int ctsvc_query_prepare(char *query, cts_stmt *stmt) {
+int ctsvc_query_prepare(char *query, cts_stmt *stmt)
+{
int ret = -1;
struct timeval from, now, diff;
bool retry = false;
return CONTACTS_ERROR_DB;
}
-int ctsvc_stmt_get_first_int_result(cts_stmt stmt, int *result) {
+int ctsvc_stmt_get_first_int_result(cts_stmt stmt, int *result)
+{
int ret;
struct timeval from, now, diff;
bool retry = false;
return CONTACTS_ERROR_NONE;
}
-int ctsvc_stmt_step(cts_stmt stmt) {
+int ctsvc_stmt_step(cts_stmt stmt)
+{
int ret = CONTACTS_ERROR_NONE;
struct timeval from, now, diff;
bool retry = false;
return ret;
}
-void ctsvc_stmt_reset(cts_stmt stmt) {
+void ctsvc_stmt_reset(cts_stmt stmt)
+{
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
}
-void ctsvc_stmt_finalize(cts_stmt stmt) {
+void ctsvc_stmt_finalize(cts_stmt stmt)
+{
int ret;
if (NULL == stmt)
if (false == is_success) {
ctsvc_nofitication_cancel();
-#ifdef _CONTACTS_IPC_SERVER
ctsvc_change_subject_clear_changed_info();
-#endif
ret = ctsvc_query_exec("ROLLBACK TRANSACTION");
return CONTACTS_ERROR_NONE;
int tmp_ret;
CTS_ERR("ctsvc_query_exec() Fail(%d)", ret);
ctsvc_nofitication_cancel();
-#ifdef _CONTACTS_IPC_SERVER
ctsvc_change_subject_clear_changed_info();
-#endif
tmp_ret = ctsvc_query_exec("ROLLBACK TRANSACTION");
WARN_IF(CONTACTS_ERROR_NONE != tmp_ret, "ctsvc_query_exec(ROLLBACK) Fail(%d)", tmp_ret);
return ret;
}
ctsvc_notification_send();
-#ifdef _CONTACTS_IPC_SERVER
ctsvc_change_subject_publish_changed_info();
-#endif
CTS_DBG("Transaction shut down! : (%d)\n", transaction_ver);
{
contacts_name_display_order_e order;
- contacts_setting_get_name_display_order(&order);
+ ctsvc_setting_get_name_display_order(&order);
if (CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST == order)
return "display_name";
else
{
contacts_name_sorting_order_e order;
- contacts_setting_get_name_sorting_order(&order);
+ ctsvc_setting_get_name_sorting_order(&order);
if (CONTACTS_NAME_SORTING_ORDER_FIRSTLAST == order)
return "sort_name, display_name_language";
else
{
contacts_name_sorting_order_e order;
- contacts_setting_get_name_sorting_order(&order);
+ ctsvc_setting_get_name_sorting_order(&order);
if (CONTACTS_NAME_SORTING_ORDER_FIRSTLAST == order)
return "display_name_language, sortkey";
else