Add contact feature
[platform/core/pim/contacts-service.git] / client / ctsvc_client_handle.c
index 90951b7..aa9d878 100644 (file)
 
 static GHashTable *_ctsvc_handle_table = NULL;
 
-static int _ctsvc_client_handle_get_key(unsigned int id, char *key, int key_len)
+static int _client_handle_get_key(unsigned int id, char *key, int key_len)
 {
        RETV_IF(NULL == key, CONTACTS_ERROR_INVALID_PARAMETER);
 
        snprintf(key, key_len, "%d:%u", getuid(), id);
-       CTS_DBG("key[%s]", key);
+       DBG("key[%s]", key);
        return CONTACTS_ERROR_NONE;
 }
 
@@ -43,19 +43,21 @@ int ctsvc_client_handle_get_p_with_id(unsigned int id, contacts_h *p_contact)
        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");
+       RETV_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NO_DATA);
        RETV_IF(NULL == p_contact, CONTACTS_ERROR_INVALID_PARAMETER);
 
-       ret = _ctsvc_client_handle_get_key(id, key, sizeof(key));
-       RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+       ret = _client_handle_get_key(id, key, sizeof(key));
+       RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_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);
 
        if (NULL == contact) {
-               CTS_ERR("g_hash_table_lookup() Fail. key[%s]", key);
+               /* LCOV_EXCL_START */
+               ERR("g_hash_table_lookup() Fail. key[%s]", key);
                return CONTACTS_ERROR_NO_DATA;
+               /* LCOV_EXCL_STOP */
        }
 
        *p_contact = contact;
@@ -68,25 +70,24 @@ int ctsvc_client_handle_get_p(contacts_h *p_contact)
        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");
+       RETV_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NO_DATA);
        RETV_IF(NULL == p_contact, CONTACTS_ERROR_INVALID_PARAMETER);
 
-       ret = _ctsvc_client_handle_get_key(ctsvc_client_get_tid(), key, sizeof(key));
-       RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+       ret = _client_handle_get_key(ctsvc_client_get_tid(), key, sizeof(key));
+       RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_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);
 
        if (NULL == contact) {
-               ret = _ctsvc_client_handle_get_key(ctsvc_client_get_pid(), key, sizeof(key));
-               RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+               ret = _client_handle_get_key(ctsvc_client_get_pid(), key, sizeof(key));
+               RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_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() Fail. key[%s]", key);
+               RETVM_IF(NULL == contact, CONTACTS_ERROR_NO_DATA, "g_hash_table_lookup(%s) Fail", key);
        }
        *p_contact = contact;
        return CONTACTS_ERROR_NONE;
@@ -101,8 +102,8 @@ int ctsvc_client_handle_create(unsigned int id, contacts_h *p_contact)
        RETV_IF(NULL == p_contact, CONTACTS_ERROR_INVALID_PARAMETER);
        *p_contact = NULL;
 
-       ret = _ctsvc_client_handle_get_key(id, handle_key, sizeof(handle_key));
-       RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+       ret = _client_handle_get_key(id, handle_key, sizeof(handle_key));
+       RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_client_handle_get_key() Fail(%d)", ret);
 
        ret = ctsvc_handle_create(&contact);
        RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "ctsvc_handle_create() Fail(%d)", ret);
@@ -112,7 +113,7 @@ int ctsvc_client_handle_create(unsigned int id, contacts_h *p_contact)
                _ctsvc_handle_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
 
        g_hash_table_insert(_ctsvc_handle_table, strdup(handle_key), contact);
-       CTS_INFO("handle insert key[%s]", handle_key);
+       INFO("handle insert key[%s]", handle_key);
        ctsvc_mutex_unlock(CTS_MUTEX_HANDLE);
 
        *p_contact = contact;
@@ -123,14 +124,15 @@ int ctsvc_client_handle_remove(unsigned int id, 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(id, key, sizeof(key));
-       RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_ctsvc_client_handle_get_key() Fail(%d)", ret);
+       RETV_IF(NULL == _ctsvc_handle_table, CONTACTS_ERROR_NONE);
+
+       ret = _client_handle_get_key(id, key, sizeof(key));
+       RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "_client_handle_get_key() Fail(%d)", ret);
 
        ctsvc_mutex_lock(CTS_MUTEX_HANDLE);
        if (false == g_hash_table_remove(_ctsvc_handle_table, key))
-               CTS_ERR("g_hash_table_remove() Fail. key[%s]", key);
+               ERR("g_hash_table_remove() Fail. key[%s]", key);
 
        if (0 == g_hash_table_size(_ctsvc_handle_table)) {
                g_hash_table_destroy(_ctsvc_handle_table);