SET(THEME_EDJ "${PROJECT_NAME}-theme.edj")
SET(SRCS
src/main.c
+ src/data/datamgr.c
+ src/data/data_home.c
src/view/view_recent.c
src/view/view_home.c)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
"item": [
{
"name": "Owner",
- "icon": "@IMAGEDIR@/ico_man.png",
+ "icon": "@IMAGEDIR@/ic_user_08_nor.png",
+ "focus_icon": "@IMAGEDIR@/ic_user_08_foc.png",
"package": "",
"notification": false
},
{
"name": "Favorites",
- "icon": "@IMAGEDIR@/icn_app_foc.png",
+ "icon": "@IMAGEDIR@/btn_menu_favorite_nor.png",
+ "focus_icon": "@IMAGEDIR@/btn_menu_favorite_foc.png",
"package": "org.tizen.app-launcher-tv-ref",
"notification": false
},
{
"name": "Media Hub",
- "icon": "@IMAGEDIR@/icn_movie_foc.png",
+ "icon": "@IMAGEDIR@/btn_menu_media_nor.png",
+ "focus_icon": "@IMAGEDIR@/btn_menu_media_foc.png",
"package": "org.tizen.gallery-tv-ref",
"notification": false
},
{
"name": "APP",
- "icon": "@IMAGEDIR@/icn_app_foc.png",
+ "icon": "@IMAGEDIR@/btn_menu_app_nor.png",
+ "focus_icon": "@IMAGEDIR@/btn_menu_app_foc.png",
"package": "org.tizen.app-launcher-tv-ref",
"notification": false
},
{
"name": "Notification",
- "icon": "@IMAGEDIR@/icn_noti_foc.png",
+ "icon": "@IMAGEDIR@/btn_menu_notification_nor.png",
+ "focus_icon": "@IMAGEDIR@/btn_menu_notification_foc.png",
"package": "org.tizen.music-player-tv-ref",
"notification": true
},
{
"name": "Settings",
- "icon": "@IMAGEDIR@/icn_history_foc.png",
+ "icon": "@IMAGEDIR@/btn_menu_setting_nor.png",
+ "focus_icon": "@IMAGEDIR@/btn_menu_setting_foc.png",
"package": "org.tizen.file-broswer-tv-ref",
"notification": false
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AIR_HOME_DATA_HOME_H__
+#define __AIR_HOME_DATA_HOME_H__
+
+#include <datamgr.h>
+
+struct data_class *datamgr_home_get_dclass(void);
+
+#endif /* __AIR_HOME_DATA_HOME_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AIR_HOME_DATAMGR_H__
+#define __AIR_HOME_DATAMGR_H__
+
+#include <Eina.h>
+#include <stdbool.h>
+
+struct datamgr {
+ Eina_List *list;
+ const char *view_id;
+ struct data_class *dclass;
+};
+
+struct datamgr_item {
+ char *title;
+ char *subtitle;
+ char *icon;
+ char *focus_icon;
+ char *thumbnail;
+ char *package;
+ bool noti;
+};
+
+struct data_class {
+ bool (*init)(struct datamgr *dm);
+ void (*fini)(struct datamgr *dm);
+ void (*launch)(struct datamgr *dm);
+ 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);
+
+#endif /* __AIR_HOME_DATAMGR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <json-glib/json-glib.h>
+#include <app_debug.h>
+#include <Eina.h>
+#include <stdbool.h>
+
+#include "data_home.h"
+#include "datamgr.h"
+
+#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_INT_NOTIFICATION "notification"
+
+static inline char *_read_string(JsonReader *reader, char *member)
+{
+ char *val;
+
+ if (!reader || !member) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ json_reader_read_member(reader, member);
+ val = (char *)json_reader_get_string_value(reader);
+ json_reader_end_member(reader);
+
+ return val;
+}
+
+static inline gboolean _read_boolean(JsonReader *reader, char *member)
+{
+ gboolean val;
+
+ if (!reader || !member) {
+ _ERR("Invalid argument");
+ return false;
+ }
+
+ json_reader_read_member(reader, member);
+ val = json_reader_get_boolean_value(reader);
+ json_reader_end_member(reader);
+
+ return val;
+}
+
+static struct datamgr_item *_pack_home_item(JsonReader *reader, int i)
+{
+ struct datamgr_item *di;
+ char *name, *icon, *package, *focus_icon;
+ gboolean noti;
+
+ if (!reader) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ if (!json_reader_read_element(reader, i)) {
+ _ERR("failed to reader %dth element", i);
+ return NULL;
+ }
+
+ name = _read_string(reader, MEMBER_STR_NAME);
+ if (!name)
+ goto err;
+
+ icon = _read_string(reader, MEMBER_STR_ICON);
+ if (!icon)
+ goto err;
+
+ focus_icon = _read_string(reader, MEMBER_STR_FOCUS_ICON);
+ if (!focus_icon)
+ goto err;
+
+ package = _read_string(reader, MEMBER_STR_PACKAGE);
+ noti = _read_boolean(reader, MEMBER_INT_NOTIFICATION);
+
+ json_reader_end_element(reader);
+
+ di = calloc(1, sizeof(*di));
+ if (!di) {
+ _ERR("failed to calloc home item");
+ return NULL;
+ }
+
+ di->title = strdup(name);
+ di->icon = strdup(icon);
+ di->focus_icon = strdup(focus_icon);
+ di->package = strdup(package);
+ di->noti = noti;
+
+ return di;
+err:
+ json_reader_end_element(reader);
+ return NULL;
+}
+
+static Eina_List *_load_home_data(JsonReader *reader)
+{
+ struct datamgr_item *di;
+ int cnt, i;
+ Eina_List *list;
+
+ if (!reader) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ json_reader_read_member(reader, OBJECT_MEMBERS);
+ if (!json_reader_is_array(reader)) {
+ _ERR(OBJECT_MEMBERS" is not array");
+ json_reader_end_member(reader);
+ return NULL;
+ }
+
+ list = NULL;
+ cnt = json_reader_count_elements(reader);
+ for (i = 0; i < cnt; i++) {
+ di = _pack_home_item(reader, i);
+ if (!di)
+ continue;
+
+ list = eina_list_append(list, di);
+ }
+
+ json_reader_end_member(reader);
+
+ return list;
+}
+
+static Eina_List *_get_items(struct datamgr *dm)
+{
+ if (!dm) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ return dm->list;
+}
+
+static void _fini(struct datamgr *dm)
+{
+ struct datamgr_item *di;
+
+ if (!dm) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ EINA_LIST_FREE(dm->list, di) {
+ free(di->title);
+ free(di->icon);
+ free(di->focus_icon);
+ free(di->package);
+
+ free(di);
+ }
+
+ dm->list = NULL;
+}
+
+static bool _init(struct datamgr *dm)
+{
+ JsonParser *parser;
+ JsonReader *reader;
+
+ if (!dm) {
+ _ERR("Invalid argument");
+ return false;
+ }
+
+ parser = json_parser_new();
+ if (!parser) {
+ _ERR("failed to new parser");
+ return false;
+ }
+
+ if (!json_parser_load_from_file(parser, DEFCONFIG, NULL)) {
+ _ERR("failed to load from file");
+ g_object_unref(parser);
+ return false;
+ }
+
+ reader = json_reader_new(json_parser_get_root(parser));
+ if (!reader) {
+ _ERR("failed to new reader");
+ g_object_unref(parser);
+ return false;
+ }
+
+ dm->list = _load_home_data(reader);
+ if (!dm->list) {
+ _ERR("failed to load home data");
+ g_object_unref(reader);
+ g_object_unref(parser);
+ return false;
+ }
+
+ g_object_unref(reader);
+ g_object_unref(parser);
+
+ return true;
+}
+
+static struct data_class dclass = {
+ .init = _init,
+ .fini = _fini,
+ .get_items = _get_items
+};
+
+struct data_class *datamgr_home_get_dclass(void)
+{
+ return &dclass;
+}
+
--- /dev/null
+/*
+
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <Eina.h>
+#include <app_debug.h>
+
+#include "datamgr.h"
+#include "defs.h"
+
+struct datamgr *datamgr_init(struct data_class *dclass, const char *view_id)
+{
+ struct datamgr *dm;
+
+ if (!view_id || !dclass) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ dm = calloc(1, sizeof(*dm));
+ if (!dm) {
+ _ERR("failed to calloc dm");
+ return NULL;
+ }
+
+ dm->view_id = view_id;
+ dm->dclass = dclass;
+
+ if (!dm->dclass->init(dm)) {
+ _ERR("failed to initialize dclass");
+ free(dm);
+ return NULL;
+ }
+
+ return dm;
+}
+
+void datamgr_fini(struct datamgr *dm)
+{
+ if (!dm) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ dm->dclass->fini(dm);
+
+ free(dm);
+}
+
+Eina_List *datamgr_get_items(struct datamgr *dm)
+{
+ if (!dm || !dm->dclass) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ if (!dm->dclass->get_items)
+ return NULL;
+
+ return dm->dclass->get_items(dm);
+}
+
+void datamgr_launch(struct datamgr *dm)
+{
+ if (!dm || !dm->dclass) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ if (!dm->dclass->launch)
+ return;
+
+ dm->dclass->launch(dm);
+}
#include "defs.h"
#include "view_home.h"
+#include "data_home.h"
+#include "datamgr.h"
struct _priv {
Evas_Object *win;
Evas_Object *base;
+
+ struct datamgr *dm;
};
static inline Evas_Object *_add_layout(Evas_Object *base, const char *group,
static Evas_Object *_create(Evas_Object *win, void *data)
{
struct _priv *priv;
+ struct datamgr *dm;
Evas_Object *base;
if (!win) {
return NULL;
}
+ dm = datamgr_init(datamgr_home_get_dclass(), VIEW_HOME);
+ if (!dm) {
+ _ERR("failed to initialize datamgr");
+ free(priv);
+ return NULL;
+ }
+
base =_add_layout(win, GRP_HOME, false);
if (!base) {
_ERR("failed to create base");
+ datamgr_fini(dm);
free(priv);
return NULL;
}
priv->win = win;
priv->base = base;
+ priv->dm = dm;
if (!_add_home(priv, base)) {
_ERR("failed to load home");
+ datamgr_fini(dm);
evas_object_del(base);
free(priv);
return NULL;
priv = data;
+ datamgr_fini(priv->dm);
evas_object_del(priv->base);
free(priv);
}