"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
}
]
#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;
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 */
};
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__ */
#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)
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) {
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);
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;
free(di->title);
free(di->icon);
free(di->focus_icon);
- free(di->package);
+ free(di->parameter);
free(di);
}
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)
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);
}
struct bar_item {
Evas_Object *eo;
+ struct datamgr_item *di;
struct _priv *priv;
};
bi->priv = priv;
bi->eo = eo;
+ bi->di = di;
return bi;
err:
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 */