add to datamgr_select_item for deciding the action when focused item is pressed by... 23/42023/3
authorSoohye Shin <soohye.shin@samsung.com>
Mon, 22 Jun 2015 06:02:19 +0000 (15:02 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Mon, 22 Jun 2015 08:08:09 +0000 (17:08 +0900)
- enum DATAMGR_ITEM_SELECT_ACTION

Change-Id: I17afc5988a90655f3e0597578e2191cbd4a39969
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
config/home.json.in
include/datamgr.h
src/data/data_home.c
src/data/datamgr.c
src/view/view_home.c

index da33bc7..67d77c8 100644 (file)
@@ -4,42 +4,48 @@
                        "name": "Owner",
                        "icon": "@IMAGEDIR@/ic_user_08_nor.png",
                        "focus_icon": "@IMAGEDIR@/ic_user_08_foc.png",
-                       "package": "",
+                       "select_action": "push",
+                       "parameter": "VIEW_USER",
                        "notification": false
                },
                {
                        "name": "Favorites",
                        "icon": "@IMAGEDIR@/btn_menu_favorite_nor.png",
                        "focus_icon": "@IMAGEDIR@/btn_menu_favorite_foc.png",
-                       "package": "org.tizen.app-launcher-tv-ref",
+                       "select_action": "launch",
+                       "parameter": "org.tizen.favorite",
                        "notification": false
                },
                {
                        "name": "Media Hub",
                        "icon": "@IMAGEDIR@/btn_menu_media_nor.png",
                        "focus_icon": "@IMAGEDIR@/btn_menu_media_foc.png",
-                       "package": "org.tizen.gallery-tv-ref",
+                       "select_action": "launch",
+                       "parameter": "org.tizen.mediahub",
                        "notification": false
                },
                {
                        "name": "APP",
                        "icon": "@IMAGEDIR@/btn_menu_app_nor.png",
                        "focus_icon": "@IMAGEDIR@/btn_menu_app_foc.png",
-                       "package": "org.tizen.app-launcher-tv-ref",
+                       "select_action": "launch",
+                       "parameter": "org.tizen.apps",
                        "notification": false
                },
                {
                        "name": "Notification",
                        "icon": "@IMAGEDIR@/btn_menu_notification_nor.png",
                        "focus_icon": "@IMAGEDIR@/btn_menu_notification_foc.png",
-                       "package": "org.tizen.music-player-tv-ref",
+                       "select_action": "launch",
+                       "parameter": "org.tizen.infosquare",
                        "notification": true
                },
                {
                        "name": "Settings",
                        "icon": "@IMAGEDIR@/btn_menu_setting_nor.png",
                        "focus_icon": "@IMAGEDIR@/btn_menu_setting_foc.png",
-                       "package": "org.tizen.file-broswer-tv-ref",
+                       "select_action": "launch",
+                       "parameter": "org.tizen.settings",
                        "notification": false
                }
        ]
index 3d8c38e..9ca5fd4 100644 (file)
 #include <Eina.h>
 #include <stdbool.h>
 
+enum datamgr_item_select_action {
+       ITEM_SELECT_ACTION_LAUNCH,
+       ITEM_SELECT_ACTION_PUSH,
+       ITEM_SELECT_ACTION_SWITCH,
+       ITEM_SELECT_ACTION_MAX
+};
+
 struct datamgr {
        Eina_List *list;
        const char *view_id;
@@ -32,14 +39,15 @@ struct datamgr_item {
        char *icon;
        char *focus_icon;
        char *thumbnail;
-       char *package;
+       char *parameter;
        bool noti;
+       enum datamgr_item_select_action action;
 };
 
 struct data_class {
        bool (*init)(struct datamgr *dm);
        void (*fini)(struct datamgr *dm);
-       void (*launch)(struct datamgr *dm);
+       void (*select)(struct datamgr_item *di);
        Eina_List *(*get_items)(struct datamgr *dm);
        /* It should be added later */
 };
@@ -47,6 +55,6 @@ struct data_class {
 struct datamgr *datamgr_init(struct data_class *dclass, const char *view_id);
 void datamgr_fini(struct datamgr *dm);
 Eina_List *datamgr_get_items(struct datamgr *dm);
-void datamgr_launch(struct datamgr *dm);
+void datamgr_select_item(struct datamgr *dm, struct datamgr_item *di);
 
 #endif /* __AIR_HOME_DATAMGR_H__ */
index a81135a..335ee02 100644 (file)
 #include <app_debug.h>
 #include <Eina.h>
 #include <stdbool.h>
+#include <Evas.h>
+#include <viewmgr.h>
 
 #include "data_home.h"
 #include "datamgr.h"
+#include "utils.h"
+
+#define STR_SELECT_ACTION_PUSH "push"
+#define STR_SELECT_ACTION_LAUNCH "launch"
 
 #define OBJECT_MEMBERS "item"
 #define MEMBER_STR_NAME "name"
 #define MEMBER_STR_ICON "icon"
 #define MEMBER_STR_FOCUS_ICON "focus_icon"
-#define MEMBER_STR_PACKAGE "package"
+#define MEMBER_STR_SELECT_ACTION "select_action"
+#define MEMBER_STR_PARAMETER "parameter"
 #define MEMBER_INT_NOTIFICATION "notification"
 
 static inline char *_read_string(JsonReader *reader, char *member)
@@ -64,7 +71,7 @@ static inline gboolean _read_boolean(JsonReader *reader, char *member)
 static struct datamgr_item *_pack_home_item(JsonReader *reader, int i)
 {
        struct datamgr_item *di;
-       char *name, *icon, *package, *focus_icon;
+       char *name, *icon, *parameter, *focus_icon, *action;
        gboolean noti;
 
        if (!reader) {
@@ -89,7 +96,8 @@ static struct datamgr_item *_pack_home_item(JsonReader *reader, int i)
        if (!focus_icon)
                goto err;
 
-       package = _read_string(reader, MEMBER_STR_PACKAGE);
+       action = _read_string(reader, MEMBER_STR_SELECT_ACTION);
+       parameter = _read_string(reader, MEMBER_STR_PARAMETER);
        noti = _read_boolean(reader, MEMBER_INT_NOTIFICATION);
 
        json_reader_end_element(reader);
@@ -100,10 +108,17 @@ static struct datamgr_item *_pack_home_item(JsonReader *reader, int i)
                return NULL;
        }
 
+       if (!strcmp(action, STR_SELECT_ACTION_PUSH))
+               di->action = ITEM_SELECT_ACTION_PUSH;
+       else if (!strcmp(action, STR_SELECT_ACTION_LAUNCH))
+               di->action = ITEM_SELECT_ACTION_LAUNCH;
+       else
+               di->action = ITEM_SELECT_ACTION_MAX;
+
        di->title = strdup(name);
        di->icon = strdup(icon);
        di->focus_icon = strdup(focus_icon);
-       di->package = strdup(package);
+       di->parameter = strdup(parameter);
        di->noti = noti;
 
        return di;
@@ -168,7 +183,7 @@ static void _fini(struct datamgr *dm)
                free(di->title);
                free(di->icon);
                free(di->focus_icon);
-               free(di->package);
+               free(di->parameter);
 
                free(di);
        }
@@ -219,10 +234,29 @@ static bool _init(struct datamgr *dm)
        return true;
 }
 
+static void _select(struct datamgr_item *di)
+{
+       if (!di || !di->parameter)
+               return;
+
+       switch (di->action) {
+       case ITEM_SELECT_ACTION_LAUNCH:
+               utils_launch_app(di->parameter);
+               break;
+       case ITEM_SELECT_ACTION_PUSH:
+               viewmgr_push_view(di->parameter);
+               break;
+       default:
+               _ERR("Invalid state");
+               return;
+       }
+}
+
 static struct data_class dclass = {
        .init = _init,
        .fini = _fini,
-       .get_items = _get_items
+       .get_items = _get_items,
+       .select = _select
 };
 
 struct data_class *datamgr_home_get_dclass(void)
index 30579e1..a9d398b 100644 (file)
@@ -73,15 +73,15 @@ Eina_List *datamgr_get_items(struct datamgr *dm)
        return dm->dclass->get_items(dm);
 }
 
-void datamgr_launch(struct datamgr *dm)
+void datamgr_select_item(struct datamgr *dm, struct datamgr_item *di)
 {
-       if (!dm || !dm->dclass) {
+       if (!dm || !dm->dclass || !di) {
                _ERR("Invalid argument");
                return;
        }
 
-       if (!dm->dclass->launch)
+       if (!dm->dclass->select)
                return;
 
-       dm->dclass->launch(dm);
+       dm->dclass->select(di);
 }
index ac19b22..f1900b2 100644 (file)
@@ -38,6 +38,7 @@ struct _priv {
 struct bar_item {
        Evas_Object *eo;
 
+       struct datamgr_item *di;
        struct _priv *priv;
 };
 
@@ -144,6 +145,7 @@ static struct bar_item *_pack_bar_item(struct _priv *priv, Evas_Object *box,
 
        bi->priv = priv;
        bi->eo = eo;
+       bi->di = di;
 
        return bi;
 err:
@@ -222,18 +224,22 @@ static bool _add_home(struct _priv *priv, Evas_Object *base)
 static void _key_down(int id, void *data, Evas *e, Evas_Object *obj,
                Evas_Event_Key_Down *ev)
 {
+       struct _priv *priv;
+
        if (!data) {
                _ERR("Invalid argument");
                return;
        }
 
+       priv = data;
+
        if (!strcmp(ev->keyname, KEY_DOWN)) {
                viewmgr_push_view(VIEW_RECENT);
        } else if (!strcmp(ev->keyname, KEY_UP)) {
                /* It should be implemented later */
        } else if (!strcmp(ev->keyname, KEY_ENTER) ||
                        !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
-               /* It should be implemented later */
+               datamgr_select_item(priv->dm, priv->foc->di);
        } else if (!strcmp(ev->keyname, KEY_BACK) ||
                        !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
                /* It should be implemented later */