Fix duplicated code for button click callbacks 76/281176/2
authorSangYoun Kwak <sy.kwak@samsung.com>
Wed, 14 Sep 2022 05:22:58 +0000 (14:22 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Wed, 14 Sep 2022 05:34:40 +0000 (14:34 +0900)
Change-Id: I1c8a302cd43a3d4ac244a2f475b294a5efe0bcd2
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
apps/extended-sd/src/es-internal-storage-page.c

index 38c6974..265328b 100644 (file)
@@ -211,10 +211,8 @@ _continue_click_cb(void *data, Evas_Object* obj, void *event_info)
 }
 
 static void
-_move_files_button_click_cb(void *data, Evas_Object* obj, void *event_info)
+_cb_app_control_send_launch_request(const char *app_id, const char *viewtype)
 {
-       FUNC_BEGIN();
-
        app_control_h app_control = NULL;
        int ret_app;
 
@@ -222,45 +220,38 @@ _move_files_button_click_cb(void *data, Evas_Object* obj, void *event_info)
        if (ret_app != APP_CONTROL_ERROR_NONE)
                return;
 
-       ret_app = app_control_set_app_id(app_control, MYFILES_APP_ID);
+       ret_app = app_control_set_app_id(app_control, app_id);
        if (ret_app != APP_CONTROL_ERROR_NONE) {
                app_control_destroy(app_control);
                return;
        }
 
+       if (viewtype != NULL)
+               app_control_add_extra_data(app_control, VIEWTYPE_KEY, viewtype);
+
        ret_app = app_control_send_launch_request(app_control, NULL, NULL);
        if (ret_app != APP_CONTROL_ERROR_NONE)
                DMSG_ERR("Failed to app_control_send_launch_request(): %d", ret_app);
 
        app_control_destroy(app_control);
-
-       FUNC_END();
 }
 
 static void
-_move_apps_button_click_cb(void *data, Evas_Object* obj, void *event_info)
+_move_files_button_click_cb(void *data, Evas_Object* obj, void *event_info)
 {
        FUNC_BEGIN();
 
-       app_control_h app_control = NULL;
-       int ret_app;
+       _cb_app_control_send_launch_request(MYFILES_APP_ID, NULL);
 
-       ret_app = app_control_create(&app_control);
-       if (ret_app != APP_CONTROL_ERROR_NONE)
-               return;
-
-       ret_app = app_control_set_app_id(app_control, SETTING_APP_ID);
-       if (ret_app != APP_CONTROL_ERROR_NONE) {
-               app_control_destroy(app_control);
-               return;
-       }
+       FUNC_END();
+}
 
-       app_control_add_extra_data(app_control, VIEWTYPE_KEY, APPSELECT);
-       ret_app = app_control_send_launch_request(app_control, NULL, NULL);
-       if (ret_app != APP_CONTROL_ERROR_NONE)
-               DMSG_ERR("Failed to app_control_send_launch_request(): %d", ret_app);
+static void
+_move_apps_button_click_cb(void *data, Evas_Object* obj, void *event_info)
+{
+       FUNC_BEGIN();
 
-       app_control_destroy(app_control);
+       _cb_app_control_send_launch_request(SETTING_APP_ID, APPSELECT);
 
        FUNC_END();
 }
@@ -270,25 +261,7 @@ _set_default_button_click_cb(void *data, Evas_Object* obj, void *event_info)
 {
        FUNC_BEGIN();
 
-       app_control_h app_control = NULL;
-       int ret_app;
-
-       ret_app = app_control_create(&app_control);
-       if (ret_app != APP_CONTROL_ERROR_NONE)
-               return;
-
-       ret_app = app_control_set_app_id(app_control, SETTING_APP_ID);
-       if (ret_app != APP_CONTROL_ERROR_NONE) {
-               app_control_destroy(app_control);
-               return;
-       }
-
-       app_control_add_extra_data(app_control, VIEWTYPE_KEY, DEFAULT_STORAGE);
-       ret_app = app_control_send_launch_request(app_control, NULL, NULL);
-       if (ret_app != APP_CONTROL_ERROR_NONE)
-               DMSG_ERR("Failed to app_control_send_launch_request(): %d", ret_app);
-
-       app_control_destroy(app_control);
+       _cb_app_control_send_launch_request(SETTING_APP_ID, DEFAULT_STORAGE);
 
        FUNC_END();
 }