Refactor ipc init logic 71/129071/2
authorSeungha Son <seungha.son@samsung.com>
Sat, 13 May 2017 15:01:22 +0000 (00:01 +0900)
committerSeungha Son <seungha.son@samsung.com>
Mon, 15 May 2017 02:17:07 +0000 (11:17 +0900)
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: I7b0f460c9213c433dc71de1e863171aaa93b5a5e

lib/src/shortcut_manager.c

index 2ef372d6230fd932287742201ee0dddbaf4ac546..efba17aa4933e138d44c23ddafa33524a97c8afd 100755 (executable)
 #define SHORTCUT_IS_WIDGET_SIZE(size)           (!!((size) & WIDGET_SIZE_DEFAULT))
 #define REQUEST_ID_LEN 40
 
-EAPI int shortcut_set_request_cb(shortcut_request_cb request_cb, void *data)
+static int __shortcut_init_ipc_process()
 {
        int ret;
 
-       if (request_cb == NULL)
-               return SHORTCUT_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_LINE */
-
        ret = _dbus_init();
        if (ret != SHORTCUT_ERROR_NONE) {
                /* LCOV_EXCL_START */
@@ -75,6 +72,20 @@ EAPI int shortcut_set_request_cb(shortcut_request_cb request_cb, void *data)
                /* LCOV_EXCL_STOP */
        }
 
+       return SHORTCUT_ERROR_NONE;
+}
+
+EAPI int shortcut_set_request_cb(shortcut_request_cb request_cb, void *data)
+{
+       int ret;
+
+       if (request_cb == NULL)
+               return SHORTCUT_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_LINE */
+
+       ret = __shortcut_init_ipc_process();
+       if (ret != SHORTCUT_ERROR_NONE)
+               return ret;
+
        _set_request_cb(request_cb, data);
 
        return SHORTCUT_ERROR_NONE;
@@ -92,37 +103,9 @@ EAPI int shortcut_set_remove_cb(shortcut_remove_cb remove_cb, void *data)
        if (remove_cb == NULL)
                return SHORTCUT_ERROR_INVALID_PARAMETER;
 
-       ret = _dbus_init();
-       if (ret != SHORTCUT_ERROR_NONE) {
-               /* LCOV_EXCL_START */
-               SHORTCUT_ERR("Can't init dbus %d", ret);
-               return ret;
-               /* LCOV_EXCL_STOP */
-       }
-
-       ret = _dbus_signal_init();
-       if (ret != SHORTCUT_ERROR_NONE) {
-               /* LCOV_EXCL_START */
-               SHORTCUT_ERR("Can't init dbus_signal %d", ret);
-               return ret;
-               /* LCOV_EXCL_STOP */
-       }
-
-       ret = _send_service_register();
-       if (ret != SHORTCUT_ERROR_NONE) {
-               /* LCOV_EXCL_START */
-               SHORTCUT_ERR("Can't init ipc_monitor_register %d", ret);
-               return ret;
-               /* LCOV_EXCL_STOP */
-       }
-
-       ret = _dbus_set_watch_name();
-       if (ret != SHORTCUT_ERROR_NONE) {
-               /* LCOV_EXCL_START */
-               SHORTCUT_ERR("Can't init _dbus_set_watch_name %d", ret);
+       ret = __shortcut_init_ipc_process();
+       if (ret != SHORTCUT_ERROR_NONE)
                return ret;
-               /* LCOV_EXCL_STOP */
-       }
 
        _set_remove_cb(remove_cb, data);