static GHashTable *_ctsvc_ipc_table = NULL;
static bool _ctsvc_ipc_disconnected = false;
-static int disconnected_cb_count = 0;
static pims_ipc_h _ctsvc_get_ipc_handle()
{
pims_ipc_h ipc_handle;
if (true == ctsvc_ipc_get_disconnected()) {
+ ctsvc_ipc_set_disconnected(false);
ctsvc_ipc_recovery();
ctsvc_ipc_recover_for_change_subscription();
- ctsvc_ipc_set_disconnected(false);
}
ipc_handle = _ctsvc_get_ipc_handle();
return ret;
}
-
-
-int ctsvc_ipc_set_disconnected_cb(void (*cb)(void *), void *user_data)
+int ctsvc_ipc_set_disconnected_cb(pims_ipc_h ipc, void (*cb)(void *), void *user_data)
{
- if (0 == disconnected_cb_count++)
- return pims_ipc_set_server_disconnected_cb(cb, user_data);
- return CONTACTS_ERROR_NONE;
+ return pims_ipc_add_server_disconnected_cb(ipc, cb, user_data);
}
-int ctsvc_ipc_unset_disconnected_cb()
+int ctsvc_ipc_unset_disconnected_cb(pims_ipc_h ipc)
{
- if (1 == disconnected_cb_count--)
- return pims_ipc_unset_server_disconnected_cb();
- return CONTACTS_ERROR_NONE;
+ return pims_ipc_remove_server_disconnected_cb(ipc);
}
void ctsvc_ipc_set_disconnected(bool is_disconnected)
int ctsvc_ipc_client_check_permission(int permission, bool *result);
-int ctsvc_ipc_set_disconnected_cb(void (*cb)(void *), void *user_data);
-int ctsvc_ipc_unset_disconnected_cb();
+int ctsvc_ipc_set_disconnected_cb(pims_ipc_h ipc, void (*cb)(void *), void *user_data);
+int ctsvc_ipc_unset_disconnected_cb(pims_ipc_h ipc);
void ctsvc_ipc_set_disconnected(bool is_disconnected);
int ctsvc_ipc_get_disconnected();
void ctsvc_ipc_recovery();
static pims_ipc_h __ipc = NULL;
static GSList *__db_change_subscribe_list = NULL;
+static void _ctsvc_ipc_disconnected_cb(void *user_data)
+{
+ ctsvc_ipc_set_disconnected(true);
+}
+
static void __ctsvc_db_subscriber_callback(pims_ipc_h ipc, pims_ipc_data_h data, void *user_data)
{
int ret;
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_IPC;
}
+ ctsvc_ipc_set_disconnected_cb(__ipc, _ctsvc_ipc_disconnected_cb, NULL);
}
__ipc_pubsub_ref++;
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_NONE;
}
+ if (__ipc)
+ ctsvc_ipc_unset_disconnected_cb(__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");
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_IPC;
}
+ ctsvc_ipc_set_disconnected_cb(__ipc, _ctsvc_ipc_disconnected_cb, NULL);
ctsvc_mutex_unlock(CTS_MUTEX_PIMS_IPC_PUBSUB);
return CONTACTS_ERROR_NONE;
}
if (1 == __ipc_pubsub_ref) {
pims_ipc_destroy_for_subscribe(__ipc);
+ ctsvc_ipc_unset_disconnected_cb(__ipc);
__ipc = NULL;
}
else if (1 < __ipc_pubsub_ref) {
return ret;
}
-static void _ctsvc_ipc_disconnected_cb(void *user_data)
-{
- ctsvc_ipc_set_disconnected(true);
-}
-
static void _ctsvc_ipc_initialized_cb(void *user_data)
{
CTS_FN_CALL;
if (true == ctsvc_ipc_get_disconnected()) {
+ ctsvc_ipc_set_disconnected(false);
ctsvc_ipc_recovery();
ctsvc_ipc_recover_for_change_subscription();
- ctsvc_ipc_set_disconnected(false);
}
}
}
ctsvc_view_uri_init();
ctsvc_ipc_create_for_change_subscription();
- ctsvc_ipc_set_disconnected_cb(_ctsvc_ipc_disconnected_cb, NULL);
}
else
CTS_DBG("System : Contacts service has been already connected(%d)", _ctsvc_connection + 1);
ctsvc_view_uri_deinit();
ctsvc_inotify_close();
ctsvc_socket_final();
- ctsvc_ipc_unset_disconnected_cb();
+
}
else if (1 < _ctsvc_connection)
CTS_DBG("System : connection count is %d", _ctsvc_connection);
}
ctsvc_view_uri_init();
ctsvc_ipc_create_for_change_subscription();
- ctsvc_ipc_set_disconnected_cb(_ctsvc_ipc_disconnected_cb, NULL);
}
else if (0 < _ctsvc_connection_on_thread)
CTS_DBG("System : Contacts service has been already connected");
ctsvc_view_uri_deinit();
ctsvc_inotify_close();
ctsvc_socket_final();
- ctsvc_ipc_unset_disconnected_cb();
CTS_DBG("System : connection_on_thread was destroyed successfully");
}
else if (1 < _ctsvc_connection_on_thread) {