From: Jongkyu Koo Date: Tue, 5 Jan 2016 01:01:57 +0000 (+0900) Subject: fix contacts_db_remove_changed_cb()(delete contacts handle in noti_info) X-Git-Tag: accepted/tizen/mobile/20160108.071111~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F40%2F56140%2F3;p=platform%2Fcore%2Fpim%2Fcontacts-service.git fix contacts_db_remove_changed_cb()(delete contacts handle in noti_info) Change-Id: I83478f71d5a55b092464437d3cfde1d0ccaf0400 Signed-off-by: Jongkyu Koo --- diff --git a/client/ctsvc_client_db_notification.c b/client/ctsvc_client_db_notification.c index 2425725..6a47712 100644 --- a/client/ctsvc_client_db_notification.c +++ b/client/ctsvc_client_db_notification.c @@ -79,7 +79,6 @@ API int contacts_db_add_changed_cb(const char *view_uri, contacts_db_changed_cb void *user_data) { int ret; - contacts_h contact = NULL; RETV_IF(NULL == view_uri, CONTACTS_ERROR_INVALID_PARAMETER); RETV_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER); @@ -88,13 +87,7 @@ API int contacts_db_add_changed_cb(const char *view_uri, contacts_db_changed_cb RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_client_noti_check_read_permission() Fail(%d)", ret); - ret = ctsvc_client_handle_get_p(&contact); - if (CONTACTS_ERROR_NONE != ret) { - ERR("ctsvc_client_handle_get_p() Fail(%d)", ret); - return ret; - } - - ret = ctsvc_inotify_subscribe(contact, view_uri, cb, user_data); + ret = ctsvc_inotify_subscribe(view_uri, cb, user_data); if (CONTACTS_ERROR_NONE != ret) { ERR("ctsvc_inotify_subscribe(%s) Fail(%d)", view_uri, ret); return ret; @@ -107,18 +100,11 @@ API int contacts_db_remove_changed_cb(const char *view_uri, contacts_db_changed_ void *user_data) { int ret; - contacts_h contact = NULL; RETV_IF(NULL == view_uri, CONTACTS_ERROR_INVALID_PARAMETER); RETV_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER); - ret = ctsvc_client_handle_get_p(&contact); - if (CONTACTS_ERROR_NONE != ret) { - ERR("ctsvc_client_handle_get_p() Fail(%d)", ret); - return ret; - } - - ret = ctsvc_inotify_unsubscribe(contact, view_uri, cb, user_data); + ret = ctsvc_inotify_unsubscribe(view_uri, cb, user_data); if (CONTACTS_ERROR_NONE != ret) { ERR("ctsvc_inotify_unsubscribe(%s) Fail(%d)", view_uri, ret); return ret; diff --git a/client/ctsvc_client_service_helper.c b/client/ctsvc_client_service_helper.c index b42a801..4cc18ba 100644 --- a/client/ctsvc_client_service_helper.c +++ b/client/ctsvc_client_service_helper.c @@ -121,7 +121,7 @@ int ctsvc_client_connect(contacts_h contact) } if (1 == base->connection_count) - ctsvc_inotify_subscribe_ipc_ready(contact, _ctsvc_ipc_initialized_cb, NULL); + ctsvc_inotify_subscribe_ipc_ready(_ctsvc_ipc_initialized_cb, NULL); _ctsvc_connection++; ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION); @@ -145,7 +145,7 @@ int ctsvc_client_disconnect(contacts_h contact) ERR("ctsvc_ipc_disconnect() Fail(%d)", ret); return ret; } - ctsvc_inotify_unsubscribe_ipc_ready(contact); + ctsvc_inotify_unsubscribe_ipc_ready(); } base->connection_count--; @@ -214,7 +214,7 @@ int ctsvc_client_connect_on_thread(contacts_h contact) } if (1 == base->connection_count) - ctsvc_inotify_subscribe_ipc_ready(contact, _ctsvc_ipc_initialized_cb, NULL); + ctsvc_inotify_subscribe_ipc_ready(_ctsvc_ipc_initialized_cb, NULL); _ctsvc_connection_on_thread++; @@ -239,7 +239,7 @@ int ctsvc_client_disconnect_on_thread(contacts_h contact) ctsvc_mutex_unlock(CTS_MUTEX_CONNECTION); return ret; } - ctsvc_inotify_unsubscribe_ipc_ready(contact); + ctsvc_inotify_unsubscribe_ipc_ready(); } base->connection_count--; diff --git a/common/ctsvc_handle.c b/common/ctsvc_handle.c index e69a6b7..1926a58 100644 --- a/common/ctsvc_handle.c +++ b/common/ctsvc_handle.c @@ -55,24 +55,3 @@ int ctsvc_handle_clone(contacts_h contact, contacts_h *pcontact) 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; - } -} - diff --git a/common/ctsvc_handle.h b/common/ctsvc_handle.h index e1419cc..438c7ae 100644 --- a/common/ctsvc_handle.h +++ b/common/ctsvc_handle.h @@ -24,7 +24,5 @@ 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__ */ \ No newline at end of file diff --git a/common/ctsvc_inotify.c b/common/ctsvc_inotify.c index beac0f4..015ca8a 100644 --- a/common/ctsvc_inotify.c +++ b/common/ctsvc_inotify.c @@ -35,7 +35,6 @@ #endif typedef struct { - contacts_h contact; int wd; char *view_uri; contacts_db_changed_cb cb; @@ -264,7 +263,7 @@ static inline const char* __ctsvc_noti_get_file_path(const char *view_uri) return NULL; } -int ctsvc_inotify_subscribe_ipc_ready(contacts_h contact, void (*cb)(void *), void *user_data) +int ctsvc_inotify_subscribe_ipc_ready(void (*cb)(void *), void *user_data) { const char *noti_path = CTSVC_NOTI_IPC_READY; struct socket_init_noti_info *noti_info = NULL; @@ -304,7 +303,7 @@ int ctsvc_inotify_subscribe_ipc_ready(contacts_h contact, void (*cb)(void *), vo return CONTACTS_ERROR_NONE; } -int ctsvc_inotify_unsubscribe_ipc_ready(contacts_h contact) +int ctsvc_inotify_unsubscribe_ipc_ready() { const char *noti_path = CTSVC_NOTI_IPC_READY; struct socket_init_noti_info *noti_info = NULL; @@ -330,8 +329,7 @@ int ctsvc_inotify_unsubscribe_ipc_ready(contacts_h contact) } -int ctsvc_inotify_subscribe(contacts_h contact, const char *view_uri, - void *cb, void *data) +int ctsvc_inotify_subscribe(const char *view_uri, void *cb, void *data) { int ret, wd; noti_info *noti, *same_noti = NULL; @@ -359,8 +357,7 @@ int ctsvc_inotify_subscribe(contacts_h contact, const char *view_uri, 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 - && 0 == ctsvc_handle_compare(contact, same_noti->contact)) { + && same_noti->cb_data == data) { break; } else { same_noti = NULL; @@ -384,7 +381,6 @@ int ctsvc_inotify_subscribe(contacts_h contact, const char *view_uri, 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); @@ -392,8 +388,7 @@ int ctsvc_inotify_subscribe(contacts_h contact, const char *view_uri, return CONTACTS_ERROR_NONE; } -static inline int __ctsvc_del_noti(GSList **noti_list, contacts_h contact, int wd, - const char *view_uri, void *cb, void *user_data) +static inline int __ctsvc_del_noti(GSList **noti_list, int wd, const char *view_uri, void *cb, void *user_data) { int del_cnt, remain_cnt; GSList *it, *result; @@ -406,11 +401,9 @@ static inline int __ctsvc_del_noti(GSList **noti_list, contacts_h contact, int w 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) - && 0 == ctsvc_handle_compare(contact, noti->contact)) { + && STRING_EQUAL == strcmp(noti->view_uri, view_uri)) { it = it->next; result = g_slist_remove(result, noti); - ctsvc_handle_destroy(noti->contact); free(noti->view_uri); free(noti); del_cnt++; @@ -421,14 +414,14 @@ static inline int __ctsvc_del_noti(GSList **noti_list, contacts_h contact, int w } it = it->next; } - RETVM_IF(del_cnt == 0, CONTACTS_ERROR_NO_DATA, "No Data: nothing deleted"); + RETVM_IF(del_cnt == 0, CONTACTS_ERROR_NO_DATA, "No Data: nothing deleted, remain_cnt : %d", remain_cnt); *noti_list = result; return remain_cnt; } -int ctsvc_inotify_unsubscribe(contacts_h contact, const char *view_uri, void *cb, void *user_data) +int ctsvc_inotify_unsubscribe(const char *view_uri, void *cb, void *user_data) { int ret, wd; const char *path; @@ -449,7 +442,7 @@ int ctsvc_inotify_unsubscribe(contacts_h contact, const char *view_uri, void *cb return CONTACTS_ERROR_SYSTEM; } - ret = __ctsvc_del_noti(&__noti_list, contact, wd, view_uri, cb, user_data); + ret = __ctsvc_del_noti(&__noti_list, wd, view_uri, cb, user_data); WARN_IF(ret < CONTACTS_ERROR_NONE, "__ctsvc_del_noti() Fail(%d)", ret); if (0 == ret) @@ -462,7 +455,6 @@ static void __clear_nslot_list(gpointer data, gpointer user_data) { noti_info *noti = (noti_info *)data; - ctsvc_handle_destroy(noti->contact); free(noti->view_uri); free(noti); } diff --git a/common/ctsvc_inotify.h b/common/ctsvc_inotify.h index 42150ba..c4d0b32 100644 --- a/common/ctsvc_inotify.h +++ b/common/ctsvc_inotify.h @@ -23,10 +23,10 @@ int ctsvc_inotify_init(void); void ctsvc_inotify_close(void); -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); +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_ipc_ready(contacts_h contact, void (*cb)(void *), void *user_data); -int ctsvc_inotify_unsubscribe_ipc_ready(contacts_h contact); +int ctsvc_inotify_subscribe_ipc_ready(void (*cb)(void *), void *user_data); +int ctsvc_inotify_unsubscribe_ipc_ready(); #endif /* __CTSVC_INOTIFY_H__ */ diff --git a/server/ctsvc_server_bg.c b/server/ctsvc_server_bg.c index b842a04..8ce9422 100644 --- a/server/ctsvc_server_bg.c +++ b/server/ctsvc_server_bg.c @@ -60,7 +60,6 @@ GCond __ctsvc_server_bg_delete_cond; 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) { @@ -478,11 +477,11 @@ static bool __ctsvc_server_account_delete_cb(const char *event_type, int account void ctsvc_server_bg_add_cb() { int ret; - ctsvc_handle_create(&bg_contact); - ret = ctsvc_inotify_subscribe(bg_contact, _contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL); + + ret = ctsvc_inotify_subscribe(_contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL); 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); + ret = ctsvc_inotify_subscribe(_contacts_contact._uri, __ctsvc_server_contact_deleted_cb, NULL); DBG("call ctsvc_inotify_subscribe (_contacts_contact): return (%d)", ret); ret = account_subscribe_create(&account); @@ -499,9 +498,9 @@ void ctsvc_server_bg_remove_cb() { int ret; - ret = ctsvc_inotify_unsubscribe(bg_contact, _contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL); + ret = ctsvc_inotify_unsubscribe(_contacts_address_book._uri, __ctsvc_server_addressbook_deleted_cb, NULL); 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); + ret = ctsvc_inotify_unsubscribe(_contacts_contact._uri, __ctsvc_server_contact_deleted_cb, NULL); ERR("call ctsvc_inotify_unsubscribe (_contacts_contact) : return (%d)", ret); if (account) {