X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=client%2Fctsvc_client_service.c;h=ab2ad214a0bc04fcd378941aa236b9d5067fdd85;hb=45d355ad34500e52686f5e4df3f832f19cbd6251;hp=ea2675a71d7dc000eb28ee08b6605e8d1be8ee99;hpb=4a90c54efc35c130e622397ecf1a219946131109;p=platform%2Fcore%2Fpim%2Fcontacts-service.git diff --git a/client/ctsvc_client_service.c b/client/ctsvc_client_service.c index ea2675a..ab2ad21 100644 --- a/client/ctsvc_client_service.c +++ b/client/ctsvc_client_service.c @@ -3,9 +3,6 @@ * * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Dohyung Jin - * Jongwon Lee - * Donghee Ye * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,16 +32,23 @@ API int contacts_connect_with_flags(unsigned int flags) unsigned int id = ctsvc_client_get_pid(); ret = ctsvc_client_handle_get_p_with_id(id, &contact); - if (NULL == contact) { + if (CONTACTS_ERROR_NO_DATA == ret) { ret = ctsvc_client_handle_create(id, &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_p_with_id() Fail(%d)", ret); + if (CONTACTS_ERROR_NONE != ret) { + ERR("ctsvc_client_handle_create() Fail(%d)", ret); + if (CONTACTS_ERROR_INVALID_PARAMETER == ret) + return CONTACTS_ERROR_INTERNAL; + return ret; + } + } else if (CONTACTS_ERROR_NONE != ret) { + ERR("ctsvc_client_handle_get_p_with_id() Fail(%d)", ret); return ret; } ret = ctsvc_client_connect_with_flags(contact, flags); + if ((CONTACTS_ERROR_IPC_NOT_AVALIABLE == ret) + || (CONTACTS_ERROR_PERMISSION_DENIED == ret)) + return CONTACTS_ERROR_IPC; return ret; } @@ -57,15 +61,22 @@ API int contacts_connect(void) unsigned int id = ctsvc_client_get_pid(); ret = ctsvc_client_handle_get_p_with_id(id, &contact); - if (NULL == contact) { + if (CONTACTS_ERROR_NO_DATA == ret) { ret = ctsvc_client_handle_create(id, &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_p_with_id() Fail(%d)", ret); + if (CONTACTS_ERROR_NONE != ret) { + ERR("ctsvc_client_handle_create() Fail(%d)", ret); + if (CONTACTS_ERROR_INVALID_PARAMETER == ret) + return CONTACTS_ERROR_INTERNAL; + return ret; + } + } else if (CONTACTS_ERROR_NONE != ret) { + ERR("ctsvc_client_handle_get_p_with_id() Fail(%d)", ret); return ret; } ret = ctsvc_client_connect(contact); + if ((CONTACTS_ERROR_IPC_NOT_AVALIABLE == ret) + || (CONTACTS_ERROR_PERMISSION_DENIED == ret)) + return CONTACTS_ERROR_IPC; return ret; } @@ -83,11 +94,8 @@ API int contacts_disconnect(void) ret = ctsvc_client_disconnect(contact); WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_disconnect() Fail(%d)", ret); - - if (0 == ((ctsvc_base_s *)contact)->connection_count) { - ret = ctsvc_client_handle_remove(id, contact); - WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_handle_remove() Fail(%d)", ret); - } + if (CONTACTS_ERROR_INVALID_PARAMETER == ret) + ret = CONTACTS_ERROR_IPC; return ret; } @@ -100,17 +108,24 @@ API int contacts_connect_on_thread(void) unsigned int id = ctsvc_client_get_tid(); ret = ctsvc_client_handle_get_p_with_id(id, &contact); - if (NULL == contact) { + if (CONTACTS_ERROR_NO_DATA == ret) { ret = ctsvc_client_handle_create(id, &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_p_with_id() Fail(%d)", ret); + if (CONTACTS_ERROR_NONE != ret) { + ERR("ctsvc_client_handle_create() Fail(%d)", ret); + if (CONTACTS_ERROR_INVALID_PARAMETER == ret) + return CONTACTS_ERROR_INTERNAL; + return ret; + } + } else if (CONTACTS_ERROR_NONE != ret) { + ERR("ctsvc_client_handle_get_p_with_id() Fail(%d)", ret); return ret; } ret = ctsvc_client_connect_on_thread(contact); WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_connect_on_thread() Fail(%d)", ret); + if ((CONTACTS_ERROR_IPC_NOT_AVALIABLE == ret) + || (CONTACTS_ERROR_PERMISSION_DENIED == ret)) + return CONTACTS_ERROR_IPC; return ret; } @@ -128,11 +143,8 @@ API int contacts_disconnect_on_thread(void) ret = ctsvc_client_disconnect_on_thread(contact); WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_disconnect_on_thread() Fail(%d)", ret); - - if (0 == ((ctsvc_base_s *)contact)->connection_count) { - ret = ctsvc_client_handle_remove(id, contact); - WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_client_handle_remove() Fail(%d)", ret); - } + if (CONTACTS_ERROR_INVALID_PARAMETER == ret) + ret = CONTACTS_ERROR_IPC; return ret; }