#include "ctsvc_ipc_marshal.h"
#include "ctsvc_mutex.h"
#include "ctsvc_client_ipc.h"
+#include "ctsvc_client_setting.h"
#include "contacts_extension.h"
typedef struct
free(str);
}
+int __ctsvc_db_recover_for_change_subscription()
+{
+ GSList *it = NULL;
+ subscribe_info_s *info = NULL;
+
+ for (it=__db_change_subscribe_list;it;it=it->next) {
+ if (NULL == it->data) continue;
+
+ info = it->data;
+ if (info->view_uri) {
+ if (pims_ipc_subscribe(__ipc, CTSVC_IPC_SUBSCRIBE_MODULE, info->view_uri,
+ __ctsvc_db_subscriber_callback, (void*)info) != 0) {
+ CTS_ERR("pims_ipc_subscribe() Fail");
+ return CONTACTS_ERROR_IPC;
+ }
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+
/* This API should be called in CTS_MUTEX_PIMS_IPC_PUBSUB mutex */
pims_ipc_h ctsvc_ipc_get_handle_for_change_subsciption()
{
snprintf(sock_file, sizeof(sock_file), CTSVC_SOCK_PATH"/.%s_for_subscribe", getuid(), CTSVC_IPC_SERVICE);
__ipc = pims_ipc_create_for_subscribe(sock_file);
if (NULL == __ipc) {
- CTS_ERR("pims_ipc_create_for_subscribe error\n");
+ CTS_ERR("pims_ipc_create_for_subscribe() Fail");
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_IPC;
}
int ctsvc_ipc_recover_for_change_subscription()
{
+ int ret;
ctsvc_mutex_lock(CTS_MUTEX_PIMS_IPC_PUBSUB);
if (__ipc_pubsub_ref <= 0) {
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_NONE;
}
+
+ pims_ipc_destroy_for_subscribe(__ipc);
__ipc = pims_ipc_create_for_subscribe(CTSVC_IPC_SOCKET_PATH_FOR_CHANGE_SUBSCRIPTION);
- if (!__ipc) {
- CTS_ERR("pims_ipc_create_for_subscribe error\n");
+ if (NULL == __ipc) {
+ CTS_ERR("pims_ipc_create_for_subscribe() Fail");
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_IPC;
}
+ ret = ctsvc_setting_recover_for_change_subscription();
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("ctsvc_setting_recover_for_change_subscription() Fail(%d)", ret);
+ ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
+ return ret;
+ }
+ ret = __ctsvc_db_recover_for_change_subscription();
+ if (CONTACTS_ERROR_NONE != ret) {
+ CTS_ERR("__ctsvc_db_recover_changed_cb_with_info() Fail(%d)", ret);
+ ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
+ return ret;
+ }
+
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_NONE;
}
if (STRING_EQUAL == strncmp(view_uri, CTSVC_VIEW_URI_PHONELOG, strlen(CTSVC_VIEW_URI_PHONELOG))) {
ret = ctsvc_ipc_client_check_permission(CTSVC_PERMISSION_PHONELOG_READ, &result);
- RETVM_IF(ret != CONTACTS_ERROR_NONE, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ RETVM_IF(ret != CONTACTS_ERROR_NONE, ret, "ctsvc_ipc_client_check_permission() Fail(%d)", ret);
RETVM_IF(result == false, CONTACTS_ERROR_PERMISSION_DENIED, "Permission denied (phonelog read)");
}
else if (STRING_EQUAL == strncmp(view_uri, CTSVC_VIEW_URI_PERSON, strlen(CTSVC_VIEW_URI_PERSON))) {
ret = ctsvc_ipc_client_check_permission(CTSVC_PERMISSION_CONTACT_READ, &result);
- RETVM_IF(ret != CONTACTS_ERROR_NONE, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ RETVM_IF(ret != CONTACTS_ERROR_NONE, ret, "ctsvc_ipc_client_check_permission() Fail(%d)", ret);
RETVM_IF(result == false, CONTACTS_ERROR_PERMISSION_DENIED, "Permission denied (contact read)");
}
else {
if (pims_ipc_subscribe(__ipc, CTSVC_IPC_SUBSCRIBE_MODULE, (char*)view_uri,
__ctsvc_db_subscriber_callback, (void*)info) != 0) {
- CTS_ERR("pims_ipc_subscribe error\n");
+ CTS_ERR("pims_ipc_subscribe() Fail");
free(info);
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_IPC;
cb_info = calloc(1, sizeof(db_callback_info_s));
if (NULL == cb_info) {
- CTS_ERR("calloc() Failed");
+ CTS_ERR("calloc() Fail");
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_OUT_OF_MEMORY;
}
#include "ctsvc_client_ipc.h"
#include "ctsvc_mutex.h"
+typedef struct
+{
+ contacts_setting_name_display_order_changed_cb cb;
+ void *user_data;
+}ctsvc_name_display_order_changed_cb_info_s;
+
+typedef struct
+{
+ contacts_setting_name_sorting_order_changed_cb cb;
+ void *user_data;
+}ctsvc_name_sorting_order_changed_cb_info_s;
+
+static GSList *__setting_name_display_order_subscribe_list = NULL;
+static GSList *__setting_name_sorting_order_subscribe_list = NULL;
+
API int contacts_setting_get_name_display_order(contacts_name_display_order_e *name_display_order)
{
int ret = CONTACTS_ERROR_NONE;
return ret;
}
-typedef struct
-{
- contacts_setting_name_display_order_changed_cb cb;
- void *user_data;
-}ctsvc_name_display_order_changed_cb_info_s;
-
-static GSList *__setting_name_display_order_subscribe_list = NULL;
-
static void __ctsvc_setting_name_display_order_subscriber_callback(pims_ipc_h ipc, pims_ipc_data_h data, void *user_data)
{
int ret;
}
}
+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;
+
+ 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;
+ for (l = __setting_name_sorting_order_subscribe_list;l;l=l->next) {
+ ctsvc_name_sorting_order_changed_cb_info_s *cb_info = l->data;
+ if (cb_info->cb)
+ cb_info->cb((contacts_name_sorting_order_e)value, cb_info->user_data);
+ }
+ }
+}
+
+int ctsvc_setting_recover_for_change_subscription()
+{
+ GSList *it;
+
+ for (it = __setting_name_display_order_subscribe_list; it; it=it->next) {
+ ctsvc_name_display_order_changed_cb_info_s *cb_info = it->data;
+ if (cb_info->cb) {
+ if (pims_ipc_subscribe(ctsvc_ipc_get_handle_for_change_subsciption(),
+ CTSVC_IPC_SUBSCRIBE_MODULE, CTSVC_SETTING_DISPLAY_ORDER_CHANGED,
+ __ctsvc_setting_name_display_order_subscriber_callback, NULL) != 0) {
+ CTS_ERR("pims_ipc_subscribe() Fail");
+ return CONTACTS_ERROR_IPC;
+ }
+ break;
+ }
+ }
+
+ for (it = __setting_name_sorting_order_subscribe_list; it; it=it->next) {
+ ctsvc_name_sorting_order_changed_cb_info_s *cb_info = it->data;
+ if (cb_info->cb) {
+ if (pims_ipc_subscribe(ctsvc_ipc_get_handle_for_change_subsciption(),
+ CTSVC_IPC_SUBSCRIBE_MODULE, CTSVC_SETTING_SORTING_ORDER_CHANGED,
+ __ctsvc_setting_name_sorting_order_subscriber_callback, NULL) != 0) {
+ CTS_ERR("pims_ipc_subscribe() Fail");
+ return CONTACTS_ERROR_IPC;
+ }
+ break;
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
API int contacts_setting_add_name_display_order_changed_cb(
contacts_setting_name_display_order_changed_cb cb, void* user_data)
{
if (pims_ipc_subscribe(ctsvc_ipc_get_handle_for_change_subsciption(),
CTSVC_IPC_SUBSCRIBE_MODULE, CTSVC_SETTING_DISPLAY_ORDER_CHANGED,
__ctsvc_setting_name_display_order_subscriber_callback, NULL) != 0) {
- CTS_ERR("pims_ipc_subscribe error\n");
+ CTS_ERR("pims_ipc_subscribe() Fail");
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_IPC;
}
return CONTACTS_ERROR_NONE;
}
-typedef struct
-{
- contacts_setting_name_sorting_order_changed_cb cb;
- void *user_data;
-}ctsvc_name_sorting_order_changed_cb_info_s;
-
-static GSList *__setting_name_sorting_order_subscribe_list = NULL;
-
-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;
-
- 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;
- for (l = __setting_name_sorting_order_subscribe_list;l;l=l->next) {
- ctsvc_name_sorting_order_changed_cb_info_s *cb_info = l->data;
- if (cb_info->cb)
- cb_info->cb((contacts_name_sorting_order_e)value, cb_info->user_data);
- }
- }
-}
-
API int contacts_setting_add_name_sorting_order_changed_cb(
contacts_setting_name_sorting_order_changed_cb cb, void* user_data)
{
if (pims_ipc_subscribe(ctsvc_ipc_get_handle_for_change_subsciption(),
CTSVC_IPC_SUBSCRIBE_MODULE, CTSVC_SETTING_SORTING_ORDER_CHANGED,
__ctsvc_setting_name_sorting_order_subscriber_callback, NULL) != 0) {
- CTS_ERR("pims_ipc_subscribe error\n");
+ CTS_ERR("pims_ipc_subscribe() Fail");
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_IPC;
}
--- /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_SETTING_H__
+#define __CTSVC_CLIENT_SETTING_H__
+
+int ctsvc_setting_recover_for_change_subscription();
+
+#endif /* __CTSVC_CLIENT_SETTING_H__ */