add bundle for saving arguments of launching 52/49152/3
authorSoohye Shin <soohye.shin@samsung.com>
Wed, 7 Oct 2015 08:18:00 +0000 (17:18 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Wed, 7 Oct 2015 09:27:04 +0000 (18:27 +0900)
Change-Id: I212a7d4596110880c0f3830bf6462a6550e49695
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
CMakeLists.txt
include/datamgr.h
include/defs.h
include/utils.h
packaging/org.tizen.home.spec
src/data/data_home.c
src/data/data_recent.c
src/main.c
src/utils.c
src/view/view_action_menu.c

index 3cc2b1e..030e495 100644 (file)
@@ -75,6 +75,7 @@ pkg_check_modules(PKGS REQUIRED
                tv-service
                ecore-wayland
                ui-gadget-1
+               bundle
                capi-web-history
                capi-appfw-application)
 
index 81b5fc2..2cfde9a 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <Eina.h>
 #include <stdbool.h>
+#include <bundle.h>
 
 enum datamgr_item_select_action {
        ITEM_SELECT_ACTION_LAUNCH,
@@ -62,13 +63,12 @@ struct datamgr_item {
        char *icon;
        char *focus_icon;
        char *parameter;
-       char *key;
-       char *value;
        bool noti;
        enum datamgr_item_select_action action;
        int type;
        time_t time;
        struct thumbnail_data *thumbnail;
+       bundle *b;
 };
 
 struct data_class {
index f7752d0..854ab26 100644 (file)
 
 #define FORMAT_PNG "png"
 
+#define BUNDLE_APP_KEY "app_key"
+#define BUNDLE_APP_VALUE "app_value"
+#define BUNDLE_URI "uri"
+
 #endif /* __AIR_HOME_DEFS_H__ */
index a09d665..ce8db57 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <stdbool.h>
 #include <Evas.h>
+#include <bundle.h>
 
 struct icon_info {
        const char *icon_file;
@@ -50,7 +51,8 @@ Evas_Object *utils_add_entry(Evas_Object *base, bool password, bool scroll,
 Evas_Object *utils_add_popup(Evas_Object *base, char *title, char *message);
 Evas_Object *utils_add_rectangle(Evas_Object *base, int r, int g, int b, int a);
 Evas_Object *utils_add_toast(Evas_Object *base, char *message);
-bool utils_launch_app(const char *pkg, const char *key, const char *value);
+bundle *utils_add_bundle(char *key, char *value, char *uri);
+bool utils_launch_app(const char *pkg, bundle *b);
 int utils_get_notification_count(void);
 
 #endif /* __AIR_HOME_UTILS_H__ */
index ebbbefd..ed39194 100644 (file)
@@ -22,6 +22,7 @@ BuildRequires: pkgconfig(notification)
 BuildRequires: pkgconfig(ecore-wayland)
 BuildRequires: pkgconfig(ui-gadget-1)
 BuildRequires: pkgconfig(capi-web-history)
+BuildRequires: pkgconfig(bundle)
 BuildRequires: edje-bin
 BuildRequires: gettext-devel
 
index 1bf9b23..be234bc 100644 (file)
@@ -327,7 +327,7 @@ static int _select(struct datamgr_item *di)
        r = ITEM_SELECT_ERROR_INVALID_OPERATION;
        switch (di->action) {
        case ITEM_SELECT_ACTION_LAUNCH:
-               if (utils_launch_app(di->parameter, NULL, NULL))
+               if (utils_launch_app(di->parameter, NULL))
                        r = ITEM_SELECT_ERROR_NONE;
                break;
        case ITEM_SELECT_ACTION_PUSH:
index 5b0de58..4c8dc3c 100644 (file)
@@ -29,6 +29,7 @@
 #include <web/web_history.h>
 #include <time.h>
 #include <ctype.h>
+#include <bundle.h>
 
 #include "data_recent.h"
 #include "datamgr.h"
@@ -39,8 +40,8 @@
 #define MAX_BUF 64
 
 static struct datamgr_item *_new_datamgr_item(char *title, char *subtitle,
-               char *parameter, char *key, char *value, char *icon, int type,
-               time_t time)
+               char *parameter, char *key, char *value, char *uri, char *icon,
+               int type, time_t time)
 {
        struct datamgr_item *di;
 
@@ -59,10 +60,9 @@ static struct datamgr_item *_new_datamgr_item(char *title, char *subtitle,
 
        if (subtitle)
                di->subtitle = strdup(subtitle);
-       if (key && value) {
-               di->key = strdup(key);
-               di->value = strdup(value);
-       }
+
+       if ((key && value) || uri)
+               di->b = utils_add_bundle(key, value, uri);
 
        return di;
 }
@@ -114,7 +114,7 @@ static void _app_list_foreach(gpointer data, gpointer user_data)
        if (!thumb || !strcmp(thumb, ""))
                thumb = IMAGE_RECENT_THUMB_APP;
 
-       di = _new_datamgr_item(label, NULL, rdata->id, NULL, NULL,
+       di = _new_datamgr_item(label, NULL, rdata->id, NULL, NULL, NULL,
                        IMAGE_RECENT_ICON_APP, 0, rdata->time);
        if (di) {
                thumbnail = calloc(1, sizeof(*thumbnail));
@@ -190,7 +190,7 @@ static void _channel_list_foreach(gpointer data, gpointer user_data)
        _get_program(atoi(rdata->id), &program);
 
        di = _new_datamgr_item(buf, program, APP_ID_LIVETV, PARAM_SERVICE_ID,
-                       rdata->id, IMAGE_RECENT_ICON_CHANNEL, 1, rdata->time);
+                       rdata->id, NULL, IMAGE_RECENT_ICON_CHANNEL, 1, rdata->time);
        if (di) {
                thumbnail = calloc(1, sizeof(*thumbnail));
                if (thumbnail) {
@@ -258,7 +258,7 @@ static void _gallery_list_foreach(gpointer data, gpointer user_data)
        snprintf(buf, sizeof(buf), "%s, %s", day, date);
 
        di = _new_datamgr_item(buf, NULL, APP_ID_MEDIAHUB, PARAM_MEDIA_ID,
-                       rdata->id, IMAGE_RECENT_ICON_GALLERY, 1, rdata->time);
+                       rdata->id, NULL, IMAGE_RECENT_ICON_GALLERY, 1, rdata->time);
        if (di) {
                thumbnail = calloc(1, sizeof(*thumbnail));
                if (thumbnail) {
@@ -333,7 +333,7 @@ static void _movie_list_foreach(gpointer data, gpointer user_data)
                _get_duration(aminfo->video->duration, dur, sizeof(dur));
 
        di = _new_datamgr_item(aminfo->title, dur, APP_ID_MEDIAHUB,
-                       PARAM_MEDIA_ID, rdata->id, IMAGE_RECENT_ICON_MOVIE, 1,
+                       PARAM_MEDIA_ID, rdata->id, NULL, IMAGE_RECENT_ICON_MOVIE, 1,
                        rdata->time);
        if (di) {
                thumbnail = calloc(1, sizeof(*thumbnail));
@@ -390,7 +390,7 @@ static void _music_list_foreach(gpointer data, gpointer user_data)
        }
 
        di = _new_datamgr_item(aminfo->title, aminfo->audio->artist,
-                       APP_ID_MEDIAHUB, PARAM_MEDIA_ID, rdata->id,
+                       APP_ID_MEDIAHUB, PARAM_MEDIA_ID, rdata->id, NULL,
                        IMAGE_RECENT_ICON_MUSIC, 1, rdata->time);
        if (di) {
                thumbnail = calloc(1, sizeof(*thumbnail));
@@ -456,7 +456,7 @@ static void _web_list_foreach(gpointer data, gpointer user_data)
                goto err;
        }
 
-       di = _new_datamgr_item(title, url, APP_ID_BROWSER, NULL, NULL,
+       di = _new_datamgr_item(title, url, APP_ID_BROWSER, NULL, NULL, url,
                        IMAGE_RECENT_ICON_WEB, 1, time);
        if (!di)
                goto err;
@@ -520,11 +520,12 @@ static void _unload_recent(struct datamgr *dm)
                free(di->icon);
                free(di->focus_icon);
                free(di->parameter);
-               free(di->key);
-               free(di->value);
 
                _unload_thumbnail(di->thumbnail);
 
+               if (di->b)
+                       bundle_free(di->b);
+
                free(di);
        }
 
@@ -568,7 +569,7 @@ static bool _load_recent_notification(struct datamgr *dm)
        }
 
        di = _new_datamgr_item(MESSAGE_NOTIFICATION, buf, APP_ID_INFOSQUARE,
-                       NULL, NULL, IMAGE_RECENT_ICON_APP, 0, time);
+                       NULL, NULL, NULL, IMAGE_RECENT_ICON_APP, 0, time);
        if (di) {
                thumbnail = calloc(1, sizeof(*thumbnail));
                if (thumbnail) {
@@ -665,7 +666,7 @@ static int _select(struct datamgr_item *di)
        r = ITEM_SELECT_ERROR_INVALID_OPERATION;
        switch (di->action) {
        case ITEM_SELECT_ACTION_LAUNCH:
-               if (utils_launch_app(di->parameter, di->key, di->value))
+               if (utils_launch_app(di->parameter, di->b))
                        r = ITEM_SELECT_ERROR_NONE;
                break;
        default:
index 7414ae3..1dd86b3 100644 (file)
@@ -22,6 +22,7 @@
 #include <app_define.h>
 #include <Ecore_Wayland.h>
 #include <ui-gadget.h>
+#include <bundle.h>
 
 #include "defs.h"
 #include "view.h"
@@ -82,6 +83,7 @@ static Eina_Bool _key_down(void *data, int type, void *ei)
 {
        struct _appdata *ad;
        Evas_Event_Key_Down *ev;
+       bundle *b;
 
        if (!data || !ei) {
                _ERR("Invalid argument");
@@ -92,10 +94,13 @@ static Eina_Bool _key_down(void *data, int type, void *ei)
        ad = data;
 
        if (!strcmp(ev->keyname, KEY_POWER)) {
-               utils_launch_app(APP_ID_INFOSQUARE, PARAM_LAUNCH_TYPE,
-                               VALUE_INFOSQUARE);
+               b = utils_add_bundle(PARAM_LAUNCH_TYPE, VALUE_INFOSQUARE, NULL);
+               if (b) {
+                       utils_launch_app(APP_ID_INFOSQUARE, b);
+                       bundle_free(b);
+               }
        } else if (!strcmp(ev->keyname, KEY_TV)) {
-               utils_launch_app(APP_ID_LIVETV, NULL, NULL);
+               utils_launch_app(APP_ID_LIVETV, NULL);
        } else if (!strcmp(ev->keyname, KEY_HOME) ||
                        !strcmp(ev->keyname, KEY_HOMEPAGE)) {
                if (!ad->activated)
index ff271bc..ed88fd6 100644 (file)
@@ -21,6 +21,7 @@
 #include <notification.h>
 #include <notification_internal.h>
 #include <app_contents.h>
+#include <bundle.h>
 
 #include "utils.h"
 #include "defs.h"
@@ -460,10 +461,31 @@ Evas_Object *utils_add_toast(Evas_Object *base, char *message)
        return notify;
 }
 
-bool utils_launch_app(const char *pkg, const char *key, const char *value)
+bundle *utils_add_bundle(char *key, char *value, char *uri)
+{
+       bundle *b;
+
+       b = bundle_create();
+       if (!b) {
+               _ERR("failed create bundle");
+               return NULL;
+       }
+
+       if (key)
+               bundle_add(b, BUNDLE_APP_KEY, key);
+       if (value)
+               bundle_add(b, BUNDLE_APP_VALUE, value);
+       if (uri)
+               bundle_add(b, BUNDLE_URI, uri);
+
+       return b;
+}
+
+bool utils_launch_app(const char *pkg, bundle *b)
 {
        app_control_h app_control;
        int r;
+       const char *key, *value, *uri, *operation;
 
        if (!pkg) {
                _ERR("Invalid argument");
@@ -471,9 +493,22 @@ bool utils_launch_app(const char *pkg, const char *key, const char *value)
        }
 
        app_control_create(&app_control);
-       app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
-       if (key && value)
-               app_control_add_extra_data(app_control, key, value);
+
+       operation = APP_CONTROL_OPERATION_DEFAULT;
+       if (b) {
+               key = bundle_get_val(b, BUNDLE_APP_KEY);
+               value = bundle_get_val(b, BUNDLE_APP_VALUE);
+               uri = bundle_get_val(b, BUNDLE_URI);
+
+               if (key && value) {
+                       app_control_add_extra_data(app_control, key, value);
+               } else if (uri) {
+                       operation = APP_CONTROL_OPERATION_VIEW;
+                       app_control_set_uri(app_control, uri);
+               }
+       }
+
+       app_control_set_operation(app_control, operation);
        app_control_set_app_id(app_control, pkg);
 
        r = app_control_send_launch_request(app_control, NULL, NULL);
index 4d74570..9ba2acf 100644 (file)
@@ -239,7 +239,7 @@ static void _select(int id, void *data, Evas_Object *obj)
                viewmgr_hide_view(VIEW_ACTION_MENU);
                viewmgr_hide_view(VIEW_USER_EDIT);
 
-               utils_launch_app(APP_ID_LIVETV, NULL, NULL);
+               utils_launch_app(APP_ID_LIVETV, NULL);
                break;
        case INPUT_HANDLER_TYPE_MENU_RESET:
                _add_popup(priv, MESSAGE_RESET, MESSAGE_RESET_CONTENTS,
@@ -260,7 +260,7 @@ static void _select(int id, void *data, Evas_Object *obj)
                viewmgr_hide_view(VIEW_USER_EDIT);
                _delete_popup(priv);
 
-               utils_launch_app(APP_ID_LIVETV, NULL, NULL);
+               utils_launch_app(APP_ID_LIVETV, NULL);
                break;
        case INPUT_HANDLER_TYPE_POPUP_RESET:
                viewmgr_update_view(VIEW_USER_EDIT, UPDATE_TYPE_RESET, NULL);