TizenRefApp-9508 [App Shortcut Widget] Change data processing params for Edit widget... 79/153979/1
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 4 Oct 2017 12:40:06 +0000 (15:40 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 4 Oct 2017 13:07:00 +0000 (16:07 +0300)
Change-Id: Iabda9bd84de6fdedb9bd2ef4dbaba7978cf0963b

apptray-widget-app/src/apptray_wgt_app.c
apptray-widget/src/apptray_widget.c

index e194740e21ec817536a75238e2f7c61d3e51bc36..96b103388bf87a0e1310053b2235049b2a6f32a1 100755 (executable)
@@ -18,7 +18,6 @@
 #include <widget_service.h>
 #include <widget_errno.h>
 #include <feedback.h>
-#include <bundle.h>
 #include <efl_extension.h>
 #include <system_settings.h>
 #include <app.h>
@@ -37,7 +36,6 @@
 #define ATW_APP_WIDGET_CONTENT_KEY         "org.tizen.apptray-widget"
 
 #define ATW_BUNDLE_KEY_SHORTCUT_LIST       "shortcut_list"
-#define ATW_BUNDLE_KEY_WIDGET_INSTANCE_ID  "instance_id"
 
 #define ATW_APP_SLOTS_MAX_COUNT            4
 #define ATW_GENLIST_ITEM_ICON_DIMENSION    76
@@ -344,8 +342,11 @@ static void _app_pause(void *data);
 static void _app_resume(void *data);
 static void _app_control(app_control_h service, void *data);
 static void _app_lang_changed(app_event_info_h event_info, void *user_data);
-static bool _app_process_pick_operation(appdata_s *info);
-static bool _app_process_main_operation(appdata_s *info, const char *app_list);
+
+static bool _init_widget_instance_id(appdata_s *info, app_control_h service);
+static bool _init_widget_app_list(appdata_s *info, app_control_h service);
+static bool _process_app_control_operation(appdata_s *info,
+               app_control_h service);
 
 static void _activate_view_rotary_state(appdata_s *info,
                _apptray_wgt_view_type_e view_type);
@@ -393,6 +394,7 @@ static void _update_content(void)
        int res = 0;
        char content[ATW_BUF_SIZE_BIG] = { 0 };
        int slot_mask = 0;
+       bundle *b_tmp = NULL;
 
        if (!g_info) {
                _E("g_info is NULL");
@@ -414,7 +416,7 @@ static void _update_content(void)
                        g_info->appid_list[_output_slot_conv[slot_mask].slot_seq_arr[2]],
                        g_info->appid_list[_output_slot_conv[slot_mask].slot_seq_arr[3]]);
 
-       bundle *b_tmp = bundle_create();
+       b_tmp = bundle_create();
        if (!b_tmp) {
                _E("bundle_create failed");
                return;
@@ -2163,28 +2165,6 @@ static bool _show_view(appdata_s *info, _apptray_wgt_view_type_e view_type)
        return true;
 }
 
-static bool _app_process_main_operation(appdata_s *info, const char *app_list)
-{
-       _ENTER;
-
-       retv_if(!info, false);
-       retv_if(!app_list, false);
-
-       info->init_app_list = strdup(app_list);
-       retv_if(!info->init_app_list, false);
-
-       return _show_view(info, APPTRAY_WGT_APP_VIEW_EDIT);
-}
-
-static bool _app_process_pick_operation(appdata_s *info)
-{
-       _ENTER;
-
-       retv_if(!info, false);
-
-       return _show_view(g_info, APPTRAY_WGT_APP_VIEW_SELECT);
-}
-
 static Evas_Object *_create_conformant(Evas_Object *win)
 {
        Evas_Object *eo = NULL;
@@ -2362,45 +2342,83 @@ static void _app_resume(void *data)
        _ENTER;
 }
 
-static void _app_control(app_control_h service, void *data)
+static bool _init_widget_instance_id(appdata_s *info, app_control_h service)
 {
-       _ENTER;
+       int ret = app_control_get_extra_data(service,
+                       APP_CONTROL_DATA_WIDGET_INSTANCE_ID, &info->widget_instance_id);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               _E("app_control_get_extra_data() failed. ret[%d]", ret);
+               return false;
+       }
 
-       appdata_s *info = data;
+       return true;
+}
+
+static bool _init_widget_app_list(appdata_s *info, app_control_h service)
+{
+       char *content_info = NULL;
+
+       int ret = app_control_get_extra_data(service,
+                       APP_CONTROL_DATA_WIDGET_CONTENT, &content_info);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               _E("app_control_get_extra_data() failed. ret[%d]", ret);
+               return false;
+       }
+
+       bundle *tmp = bundle_decode((const bundle_raw *)content_info,
+                       strlen(content_info));
+       if (!tmp) {
+               _E("bundle_decode() failed");
+               free(content_info);
+               return false;
+       }
+
+       ret = bundle_get_str(tmp, ATW_BUNDLE_KEY_SHORTCUT_LIST,
+                       &info->init_app_list);
+       if (ret != BUNDLE_ERROR_NONE) {
+               _E("bundle_get_str() failed");
+               free(content_info);
+               return false;
+       }
+
+       return true;
+}
+
+static bool _process_app_control_operation(appdata_s *info,
+               app_control_h service)
+{
        char *operation = NULL;
-       char *content_val = NULL;
-       char *tmp = NULL;
-       char *app_list = NULL;
-       bool res = false;
-
-       app_control_get_extra_data(service, "content_info", &content_val);
-       if (content_val) {
-               bundle *tmp_b = bundle_decode((const bundle_raw *)content_val,
-                               strlen(content_val));
-               if (tmp_b) {
-                       bundle_get_str(tmp_b, ATW_BUNDLE_KEY_WIDGET_INSTANCE_ID, &tmp);
-                       _D("Widget instance id [%s]", tmp);
-                       info->widget_instance_id = strdup_s(tmp);
-                       bundle_get_str(tmp_b, ATW_BUNDLE_KEY_SHORTCUT_LIST, &tmp);
-                       _D("App shortcuts [%s]", tmp);
-                       app_list = strdup_s(tmp);
-               }
-               bundle_free(tmp_b);
+
+       int ret = app_control_get_operation(service, &operation);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               _E("app_control_get_operation() failed. ret[%d]", ret);
+               return false;
        }
 
-       app_control_get_operation(service, &operation);
        _D("Operation [%s]", operation);
+
        if (!operation || !strcmp(operation, APP_CONTROL_OPERATION_MAIN)) {
+               if (!_init_widget_app_list(info, service)) {
+                       _E("_init_widget_app_list() failed");
+                       free(operation);
+                       return false;
+               }
                info->launch_type = APPTRAY_WGT_APP_LAUNCH_TYPE_MAIN;
-               res = _app_process_main_operation(info, app_list);
+               return _show_view(info, APPTRAY_WGT_APP_VIEW_EDIT);
        } else if (!strcmp(operation, APP_CONTROL_OPERATION_PICK)) {
                info->launch_type = APPTRAY_WGT_APP_LAUNCH_TYPE_PICK;
-               res = _app_process_pick_operation(info);
+               return _show_view(info, APPTRAY_WGT_APP_VIEW_SELECT);
        }
 
-       free(app_list);
+       return false;
+}
+
+static void _app_control(app_control_h service, void *data)
+{
+       _ENTER;
 
-       if (!res) {
+       if (!_init_widget_instance_id(data, service) ||
+                       !_process_app_control_operation(data, service)) {
                ui_app_exit();
        }
 }
index 4c4ba5e493ecc57ff4b4602edecd8005571a9f6c..c45b2975e98e72bb29bf28ea02ccd6fd6de91c36 100755 (executable)
@@ -30,9 +30,7 @@
 
 #define ATW_SLOT_INDEX_BUFF_SIZE 10
 
-#define ATW_BUNDLE_KEY_SHORTCUT_LIST       "shortcut_list"
-#define ATW_BUNDLE_KEY_WIDGET_INSTANCE_ID  "instance_id"
-#define ATW_BUNDLE_KEY_CONTENT_INFO        "content_info"
+#define ATW_BUNDLE_KEY_SHORTCUT_LIST   "shortcut_list"
 
 static Eina_List *s_instance_list = NULL;
 package_manager_h s_pkg_manager = NULL;
@@ -782,12 +780,12 @@ static void _process_add_apps_request(_instance_h instance)
        int bndl_raw_len = 0;
        bundle_encode(instance->content, &bndl_raw, &bndl_raw_len);
        app_control_add_extra_data(service,
-                       ATW_BUNDLE_KEY_CONTENT_INFO,
+                       APP_CONTROL_DATA_WIDGET_CONTENT,
                        (const char *)bndl_raw);
        free(bndl_raw);
 
        app_control_add_extra_data(service,
-                       ATW_BUNDLE_KEY_WIDGET_INSTANCE_ID,
+                       APP_CONTROL_DATA_WIDGET_INSTANCE_ID,
                        instance->id);
 
        int ret = app_control_send_launch_request(service, NULL, NULL);
@@ -1112,15 +1110,10 @@ static _instance_h  _create_widget_instance(widget_context_h context,
        if (content) {
                _D("Widget instance content exists");
                instance->content = bundle_dup(content);
-               bundle_del(instance->content,
-                               ATW_BUNDLE_KEY_WIDGET_INSTANCE_ID);
        } else {
                _D("Widget instance content not exists. Create new one");
                instance->content = bundle_create();
        }
-       bundle_add_str(instance->content,
-                       ATW_BUNDLE_KEY_WIDGET_INSTANCE_ID,
-                       instance_id);
 
        _D("Set widget instance content");
        ret = widget_app_context_set_content_info(instance->context,