summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHyerim Kim <rimi.kim@samsung.com>2017-09-05 21:13:14 +0900
committerHyerim Kim <rimi.kim@samsung.com>2017-09-06 16:24:08 +0900
commitb6609f50613e23d1882331fa5911adca5836b7f9 (patch)
treecf3632c7140369494fd8c831bb745f45b180d714 /src
parentf0e37edfb011436627c84eef75af65014a57ad6d (diff)
downloadair_livetv-accepted/tizen_4.0_unified.tar.gz
air_livetv-accepted/tizen_4.0_unified.tar.bz2
air_livetv-accepted/tizen_4.0_unified.zip
Modifies Live-tv application for displaying background image on Hometizen_8.0_m2_releasetizen_7.0_m2_releasetizen_6.5.m2_releasetizen_6.0.m2_releasetizen_5.5.m2_releasetizen_4.0.m2_releasetizen_4.0.IoT.p2_releasetizen_4.0.IoT.p1_releasesubmit/tizen_6.5/20211029.140001submit/tizen_6.5/20211028.164001submit/tizen_6.0_hotfix/20201103.115105submit/tizen_6.0_hotfix/20201102.192905submit/tizen_6.0/20201029.205505submit/tizen_5.5_wearable_hotfix/20201026.184309submit/tizen_5.5_mobile_hotfix/20201026.185109submit/tizen_5.5/20191031.000013submit/tizen_5.5/20191031.000011submit/tizen_5.5/20191031.000009submit/tizen_5.0/20181106.000001submit/tizen_5.0/20181101.000009submit/tizen_4.0/20170907.043947submit/tizen/20170906.103347accepted/tizen/unified/20170911.155614accepted/tizen/8.0/unified/20231005.100105accepted/tizen/7.0/unified/hotfix/20221116.112006accepted/tizen/7.0/unified/20221110.061740accepted/tizen/6.0/unified/hotfix/20201103.044959accepted/tizen/6.0/unified/20201030.103300accepted/tizen/5.5/unified/wearable/hotfix/20201027.095200accepted/tizen/5.5/unified/mobile/hotfix/20201027.071204accepted/tizen/5.5/unified/20191031.034729accepted/tizen/5.0/unified/20181106.202933accepted/tizen/4.0/unified/20170911.154210tizen_8.0tizen_7.0_hotfixtizen_7.0tizen_6.5tizen_6.0_hotfixtizen_6.0tizen_5.5_wearable_hotfixtizen_5.5_tvtizen_5.5_mobile_hotfixtizen_5.5tizen_5.0tizen_4.0tizenaccepted/tizen_unifiedaccepted/tizen_8.0_unifiedaccepted/tizen_7.0_unified_hotfixaccepted/tizen_7.0_unifiedaccepted/tizen_6.0_unified_hotfixaccepted/tizen_6.0_unifiedaccepted/tizen_5.5_unified_wearable_hotfixaccepted/tizen_5.5_unified_mobile_hotfixaccepted/tizen_5.5_unifiedaccepted/tizen_5.0_unifiedaccepted/tizen_4.0_unified
Change-Id: I4081ad312fd6e77169e55d33a3c9a3755ec8770e Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/layout_channelinfo.c208
-rw-r--r--src/layout_channelinfo_list.c465
-rw-r--r--src/layout_channelinfo_search.c303
-rwxr-xr-x[-rw-r--r--]src/main.c315
-rw-r--r--src/tv.c1169
-rw-r--r--src/util.c414
-rw-r--r--src/view_action_menu.c885
-rwxr-xr-x[-rw-r--r--]src/view_bgimage.c (renamed from src/view_error.c)34
-rw-r--r--src/view_channelinfo.c237
-rw-r--r--src/view_channelnumber.c437
-rw-r--r--src/view_pin.c215
11 files changed, 7 insertions, 4675 deletions
diff --git a/src/layout_channelinfo.c b/src/layout_channelinfo.c
deleted file mode 100644
index 83ef39e..0000000
--- a/src/layout_channelinfo.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2014 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 <Elementary.h>
-#include <layoutmgr.h>
-#include <inputmgr.h>
-#include <viewmgr.h>
-#include <app_debug.h>
-
-#include "define.h"
-#include "tv.h"
-#include "view.h"
-#include "util.h"
-
-static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Down *ev);
-
-struct _priv {
- Evas_Object *base;
- Evas_Object *layout;
- Evas_Object *channel;
-
- layoutmgr *lmgr;
- const struct tv_channel_info *channel_info;
-};
-
-static input_handler key_handler = {
- .key_down = _key_down_cb,
-};
-
-static void _update_channel_info(struct _priv *priv)
-{
- if (priv->channel_info) {
- tv_channel_del_info(priv->channel_info);
- priv->channel_info = NULL;
- }
-
- priv->channel_info = tv_channel_get_info();
- if (!priv->channel_info) {
- _ERR("failed to get channel info");
-
- return;
- }
-
- util_draw_channel_info(priv->channel, priv->channel_info);
-}
-
-static bool _draw_channel_layout(struct _priv *priv)
-{
- priv->channel = elm_layout_add(priv->base);
- if (!priv->channel) {
- _ERR("failed to create channel layout");
- return false;
- }
-
- elm_layout_file_set(priv->channel, EDJEFILE, GRP_CHANNELINFO);
- elm_object_content_set(priv->base, priv->channel);
-
- return true;
-}
-
-static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Down *ev)
-{
- if (!strcmp(ev->keyname, KEY_BACK) ||
- !strcmp(ev->keyname, KEY_ESC) ||
- !strcmp(ev->keyname, KEY_EXIT))
- viewmgr_hide_view(VIEW_CHANNELINFO);
-}
-
-static void _hide_finished_cb(void *data, Evas_Object *obj,
- const char *emission, const char *source)
-{
- struct _priv *priv;
-
- if (!data)
- return;
-
- priv = data;
-
- evas_object_hide(priv->base);
-}
-
-static bool _create(layoutmgr *lmgr, void *data)
-{
- struct _priv *priv;
- Evas_Object *win;
-
- priv = calloc(1, sizeof(*priv));
- if (!priv) {
- _ERR("failed to allocate priv");
- return false;
- }
-
- win = layoutmgr_get_base(lmgr);
-
- priv->base = elm_layout_add(win);
- if (!priv->base) {
- _ERR("failed to create layout");
- free(priv);
-
- return false;
- }
-
- elm_layout_file_set(priv->base, EDJEFILE, GRP_LAYOUT_CHANNELINFO);
- evas_object_size_hint_weight_set(priv->base,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, priv->base);
- elm_object_focus_allow_set(priv->base, EINA_TRUE);
-
- if (!_draw_channel_layout(priv)) {
- _ERR("failed to create channel layout");
-
- evas_object_del(priv->base);
- free(priv);
-
- return false;
- }
-
- inputmgr_add_callback(priv->base, 0, &key_handler, priv);
- elm_layout_signal_callback_add(priv->base, SIGNAL_HIDE_FINISHED,
- SOURCE_ELM, _hide_finished_cb, priv);
- layoutmgr_set_layout_data(lmgr, LAYOUT_CHANNELINFO, priv);
-
- priv->lmgr = lmgr;
-
- return true;
-}
-
-static void _destroy(void *layout_data)
-{
- struct _priv *priv;
-
- if (!layout_data)
- return;
-
- priv = layout_data;
-
- if (priv->channel_info) {
- tv_channel_del_info(priv->channel_info);
- priv->channel_info = NULL;
- }
-
- elm_layout_signal_callback_del(priv->base, SIGNAL_HIDE_FINISHED,
- SOURCE_ELM, _hide_finished_cb);
-
- evas_object_del(priv->base);
- free(priv);
-}
-
-static void _show(void *layout_data)
-{
- struct _priv *priv;
-
- if (!layout_data)
- return;
-
- priv = layout_data;
-
- _update_channel_info(priv);
-
- evas_object_show(priv->base);
-
- elm_object_focus_set(priv->base, EINA_TRUE);
-}
-
-static void _hide(void *layout_data)
-{
- struct _priv *priv;
-
- if (!layout_data)
- return;
-
- priv = layout_data;
-
- elm_layout_signal_emit(priv->base, SIGNAL_HIDE, SOURCE_ELM);
-}
-
-static void _update(void *layout_data, int update_type, void *data)
-{
-}
-
-static layout_class lclass = {
- .layout_id = LAYOUT_CHANNELINFO,
- .create = _create,
- .show = _show,
- .hide = _hide,
- .destroy = _destroy,
- .update = _update,
-};
-
-layout_class *layout_channelinfo_get_lclass(void)
-{
- return &lclass;
-}
diff --git a/src/layout_channelinfo_list.c b/src/layout_channelinfo_list.c
deleted file mode 100644
index be1e03b..0000000
--- a/src/layout_channelinfo_list.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Copyright (c) 2014 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 <Elementary.h>
-#include <layoutmgr.h>
-#include <inputmgr.h>
-#include <viewmgr.h>
-#include <app_debug.h>
-
-#include "define.h"
-#include "util.h"
-#include "tv.h"
-#include "view.h"
-
-#define TUNE_WAIT_TIME 0.1
-#define CHANNEL_PADDING_X 0
-#define CHANNEL_PADDING_Y 5
-
-static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Down *ev);
-
-enum _order {
- CHANNEL_NEXT,
- CHANNEL_PREV
-};
-
-struct _priv {
- Evas_Object *base;
- Evas_Object *prev_channel;
- Evas_Object *current_channel;
- Evas_Object *next_channel;
- Ecore_Timer *tune_timer;
-
- const struct tv_channel_info *channel_info;
- layoutmgr *lmgr;
-};
-
-static input_handler key_handler = {
- .key_down = _key_down_cb,
-};
-
-static int _set_next_channel(struct _priv *priv, int order)
-{
- const struct tv_channel_info *next, *current, *channel;
- Eina_List *channel_list, *l;
-
- if (priv->channel_info)
- current = priv->channel_info;
- else {
- current = tv_channel_get_info();
- if (!current) {
- _ERR("failed to get channel info");
-
- return -1;
- }
-
- priv->channel_info = current;
- }
-
- channel_list = tv_channel_get_list();
- if (!channel_list) {
- _ERR("failed to get channel list");
- return -1;
- }
-
- if (order == CHANNEL_PREV)
- channel_list = eina_list_reverse(channel_list);
-
- next = NULL;
- EINA_LIST_FOREACH(channel_list, l, channel) {
- if (channel->service_id == current->service_id) {
- next = eina_list_data_get(eina_list_next(l));
- break;
- }
- }
-
- if (!next)
- next = eina_list_data_get(channel_list);
-
- priv->channel_info = tv_channel_clone_info(next);
-
- tv_channel_del_info(current);
- tv_channel_del_list(channel_list);
-
- return 0;
-}
-
-static bool _get_next_channel(
- const struct tv_channel_info *current,
- const struct tv_channel_info **prev,
- const struct tv_channel_info **next)
-{
- const struct tv_channel_info *channel;
- Eina_List *channel_list, *l;
-
- if (!current) {
- _ERR("failed to get current channel");
-
- return false;
- }
-
- channel_list = tv_channel_get_list();
- if (!channel_list) {
- _ERR("failed to get channel list");
-
- return false;
- }
-
- *prev = NULL;
- *next = NULL;
- EINA_LIST_FOREACH(channel_list, l, channel) {
- if (channel->service_id == current->service_id) {
- *prev = eina_list_data_get(eina_list_prev(l));
- *next = eina_list_data_get(eina_list_next(l));
- break;
- }
- }
-
- if (!*prev)
- *prev = eina_list_data_get(eina_list_last(channel_list));
-
- if (!*next)
- *next = eina_list_data_get(channel_list);
-
- *prev = tv_channel_clone_info(*prev);
- *next = tv_channel_clone_info(*next);
-
- tv_channel_del_list(channel_list);
-
- return true;
-}
-
-static void _draw_channel_info(Evas_Object *box,
- const struct tv_channel_info *current, char *grp)
-{
- const struct tv_channel_info *prev, *next;
- Evas_Object *layout;
-
- if (!current) {
- _ERR("failed to get current channel");
-
- return;
- }
-
- prev = NULL;
- next = NULL;
- if (!_get_next_channel(current, &prev, &next) ||
- !prev || !next) {
- _ERR("failed to get next channel");
-
- goto err;
- }
-
- elm_box_clear(box);
-
- layout = util_add_layout(box, grp);
- util_draw_channel_info(layout, next);
- elm_box_pack_end(box, layout);
-
- layout = util_add_layout(box, grp);
- util_draw_channel_info(layout, current);
- elm_box_pack_end(box, layout);
-
- layout = util_add_layout(box, grp);
- util_draw_channel_info(layout, prev);
- elm_box_pack_end(box, layout);
-
-err:
- tv_channel_del_info(prev);
- tv_channel_del_info(next);
-}
-
-static void _update_channel_info(struct _priv *priv)
-{
- const struct tv_channel_info *prev, *current, *next;
-
- if (priv->channel_info)
- current = priv->channel_info;
- else {
- current = tv_channel_get_info();
- if (!current) {
- _ERR("failed to get channel info");
-
- return;
- }
-
- priv->channel_info = current;
- }
-
- if (!_get_next_channel(current, &prev, &next)) {
- _ERR("failed to get next channel");
-
- return;
- }
-
- _draw_channel_info(priv->prev_channel, prev, GRP_CHANNELINFO_SIMPLE);
- _draw_channel_info(priv->current_channel, current, GRP_CHANNELINFO);
- _draw_channel_info(priv->next_channel, next, GRP_CHANNELINFO_SIMPLE);
-
- if (prev)
- tv_channel_del_info(prev);
-
- if (next)
- tv_channel_del_info(next);
-}
-
-static bool _draw_channel_layout(struct _priv *priv)
-{
- priv->next_channel = util_add_box(priv->base, EINA_FALSE);
- if (!priv->next_channel)
- return false;
- elm_box_padding_set(priv->next_channel,
- ELM_SCALE_SIZE(CHANNEL_PADDING_X),
- ELM_SCALE_SIZE(CHANNEL_PADDING_Y));
- elm_object_part_content_set(priv->base,
- PART_CHANNELINFO_LIST_NEXT, priv->next_channel);
-
- priv->current_channel = util_add_box(priv->base, EINA_FALSE);
- if (!priv->current_channel)
- return false;
- elm_object_part_content_set(priv->base,
- PART_CHANNELINFO_LIST_CURRENT, priv->current_channel);
-
-
- priv->prev_channel = util_add_box(priv->base, EINA_FALSE);
- if (!priv->prev_channel)
- return false;
- elm_box_padding_set(priv->prev_channel,
- ELM_SCALE_SIZE(CHANNEL_PADDING_X),
- ELM_SCALE_SIZE(CHANNEL_PADDING_Y));
- elm_object_part_content_set(priv->base,
- PART_CHANNELINFO_LIST_PREV, priv->prev_channel);
-
- return true;
-}
-
-static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Down *ev)
-{
- if (!strcmp(ev->keyname, KEY_BACK) ||
- !strcmp(ev->keyname, KEY_ESC) ||
- !strcmp(ev->keyname, KEY_EXIT)) {
- viewmgr_hide_view(VIEW_CHANNELINFO);
- }
-}
-
-static void _hide_finished_cb(void *data, Evas_Object *obj,
- const char *emission, const char *source)
-{
- struct _priv *priv;
-
- if (!data)
- return;
-
- priv = data;
-
- evas_object_hide(priv->base);
-}
-
-Eina_Bool _tune_timer(void *data)
-{
- struct _priv *priv;
-
- if (!data)
- return ECORE_CALLBACK_CANCEL;
-
- priv = data;
-
- tv_channel_tune_with_service_id(
- priv->channel_info->service_id);
-
- priv->tune_timer = NULL;
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static void _anim_finished_cb(void *data, Evas_Object *obj,
- const char *emission, const char *source)
-{
- struct _priv *priv;
-
- if (!data)
- return;
-
- priv = data;
-
- if (priv->tune_timer)
- ecore_timer_reset(priv->tune_timer);
- else
- priv->tune_timer = ecore_timer_add(TUNE_WAIT_TIME,
- _tune_timer, priv);
-}
-
-static bool _create(layoutmgr *lmgr, void *data)
-{
- struct _priv *priv;
- Evas_Object *win;
-
- priv = calloc(1, sizeof(*priv));
- if (!priv) {
- _ERR("failed to allocate priv");
- return false;
- }
-
- win = layoutmgr_get_base(lmgr);
-
- priv->base = elm_layout_add(win);
- if (!priv->base) {
- _ERR("failed to create base layout");
- free(priv);
-
- return false;
- }
-
- elm_layout_file_set(priv->base, EDJEFILE, GRP_LAYOUT_CHANNELINFO_LIST);
-
- evas_object_size_hint_weight_set(priv->base,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, priv->base);
- elm_object_focus_allow_set(priv->base, EINA_TRUE);
-
- if (!_draw_channel_layout(priv)) {
- _ERR("failed to create channel layout");
-
- evas_object_del(priv->base);
- free(priv);
-
- return false;
- }
-
- priv->lmgr = lmgr;
- layoutmgr_set_layout_data(lmgr, LAYOUT_CHANNELINFO_LIST, priv);
-
- inputmgr_add_callback(priv->base, 0, &key_handler, priv);
- elm_layout_signal_callback_add(priv->base, SIGNAL_HIDE_FINISHED,
- SOURCE_ELM, _hide_finished_cb, priv);
- elm_layout_signal_callback_add(priv->base, SIGNAL_ANIM_FINISHED,
- SOURCE_ELM, _anim_finished_cb, priv);
-
- return true;
-}
-
-static void _destroy(void *layout_data)
-{
- struct _priv *priv;
-
- if (!layout_data)
- return;
-
- priv = layout_data;
-
- if (priv->channel_info)
- tv_channel_del_info(priv->channel_info);
-
- if (priv->tune_timer)
- ecore_timer_del(priv->tune_timer);
-
- elm_layout_signal_callback_del(priv->base, SIGNAL_HIDE_FINISHED,
- SOURCE_ELM, _hide_finished_cb);
- elm_layout_signal_callback_del(priv->base, SIGNAL_ANIM_FINISHED,
- SOURCE_ELM, _anim_finished_cb);
-
- evas_object_del(priv->base);
- free(priv);
-}
-
-static void _show(void *layout_data)
-{
- struct _priv *priv;
-
- if (!layout_data)
- return;
-
- priv = layout_data;
-
- evas_object_show(priv->base);
-
- elm_object_focus_set(priv->base, EINA_TRUE);
-}
-
-static void _hide(void *layout_data)
-{
- struct _priv *priv;
-
- if (!layout_data)
- return;
-
- priv = layout_data;
-
- if (priv->channel_info) {
- tv_channel_del_info(priv->channel_info);
- priv->channel_info = NULL;
- }
-
- elm_layout_signal_emit(priv->base, SIGNAL_HIDE, SOURCE_ELM);
-}
-
-static void _update(void *layout_data, int type, void *data)
-{
- struct _priv *priv;
- int r;
-
- if (!layout_data) {
- _ERR("failed to get layout_data and ev");
- return;
- }
-
- priv = layout_data;
-
- if (type == UPDATE_TYPE_INPUT_KEY_DOWN) {
- Evas_Event_Key_Down *ev = data;
-
- if (!ev) {
- _ERR("failed to get ev");
- return;
- }
-
- if (!strcmp(ev->keyname, KEY_CHANNELUP)) {
- _update_channel_info(priv);
-
- elm_object_signal_emit(priv->base,
- SIGNAL_ANIM_MOVE_UP, SOURCE_PROGRAM);
-
- r = _set_next_channel(priv, CHANNEL_NEXT);
- if (r < 0)
- _ERR("failed to set next channel");
- } else if (!strcmp(ev->keyname, KEY_CHANNELDOWN)) {
- _update_channel_info(priv);
-
- elm_object_signal_emit(priv->base,
- SIGNAL_ANIM_MOVE_DOWN, SOURCE_PROGRAM);
-
- r = _set_next_channel(priv, CHANNEL_PREV);
- if (r < 0)
- _ERR("failed to set prev channel");
- }
- }
-}
-
-static layout_class lclass = {
- .layout_id = LAYOUT_CHANNELINFO_LIST,
- .create = _create,
- .show = _show,
- .hide = _hide,
- .destroy = _destroy,
- .update = _update,
-};
-
-layout_class *layout_channelinfo_list_get_lclass(void)
-{
- return &lclass;
-}
diff --git a/src/layout_channelinfo_search.c b/src/layout_channelinfo_search.c
deleted file mode 100644
index cf0a97f..0000000
--- a/src/layout_channelinfo_search.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright (c) 2014 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 <Elementary.h>
-#include <layoutmgr.h>
-#include <inputmgr.h>
-#include <viewmgr.h>
-#include <app_debug.h>
-
-#include "define.h"
-#include "util.h"
-#include "tv.h"
-#include "view.h"
-
-#define DIVIDER_WIDTH 536
-#define DIVIDER_HEIGHT 1
-#define DIVIDER_COLOR_R 154
-#define DIVIDER_COLOR_G 154
-#define DIVIDER_COLOR_B 154
-#define DIVIDER_COLOR_A 255
-
-struct _priv {
- Evas_Object *base;
- Evas_Object *scroll;
- Evas_Object *box;
-
- layoutmgr *lmgr;
-};
-
-static void _tune_channel(void *data)
-{
- int service_id;
- int r;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
-
- service_id = (int) data;
- if (service_id < 0) {
- _ERR("failed to get service id");
- return;
- }
-
- r = tv_channel_tune_with_service_id(service_id);
- if (r < 0)
- _ERR("failed to tune with service id");
-
- viewmgr_hide_view(VIEW_CHANNELINFO);
-}
-
-static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Down *ev)
-{
- int op;
-
- if (!strcmp(ev->keyname, KEY_ENTER)) {
- ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
-
- _tune_channel(data);
- } else if (!strcmp(ev->keyname, KEY_BACK) ||
- !strcmp(ev->keyname, KEY_ESC) ||
- !strcmp(ev->keyname, KEY_EXIT)) {
- viewmgr_hide_view(VIEW_CHANNELINFO);
- } else if (!strcmp(ev->keyname, KEY_UP) ||
- !strcmp(ev->keyname, KEY_DOWN)) {
- op = START_HIDE_TIMER;
- viewmgr_update_view(VIEW_CHANNELINFO,
- UPDATE_TYPE_TIMER, &op);
- }
-}
-
-static void _mouse_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Mouse_Down *ev)
-{
- _tune_channel(data);
-}
-
-static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Mouse_Move *ev)
-{
- int op;
-
- op = START_HIDE_TIMER;
- viewmgr_update_view(VIEW_CHANNELINFO,
- UPDATE_TYPE_TIMER, &op);
-}
-
-static input_handler channel_handler = {
- .key_down = _key_down_cb,
- .mouse_down = _mouse_down_cb,
- .mouse_move = _mouse_move_cb,
-};
-
-static void _load_channel_list(struct _priv *priv, Eina_List *channel_list)
-{
- Evas_Object *ly, *divider, *first;
- Evas *e;
- Eina_List *l;
- const struct tv_channel_info *channel_info;
- int r;
- int current_service;
-
- r = tv_get_current_service_id(&current_service);
- if (r < 0)
- current_service = -1;
-
- e = evas_object_evas_get(priv->base);
-
- divider = evas_object_rectangle_add(e);
- evas_object_color_set(divider, DIVIDER_COLOR_R,
- DIVIDER_COLOR_G, DIVIDER_COLOR_B, DIVIDER_COLOR_A);
- evas_object_size_hint_min_set(divider,
- ELM_SCALE_SIZE(DIVIDER_WIDTH),
- ELM_SCALE_SIZE(DIVIDER_HEIGHT));
- evas_object_show(divider);
-
- elm_box_clear(priv->box);
-
- first = NULL;
- ly = NULL;
- EINA_LIST_FOREACH(channel_list, l, channel_info) {
- if (!channel_info->remembered)
- continue;
-
- ly = util_add_layout(priv->box, GRP_CHANNELINFO);
- if (!ly)
- continue;
- elm_object_focus_allow_set(ly, EINA_TRUE);
- util_draw_channel_info(ly, channel_info);
- elm_box_pack_end(priv->box, ly);
-
- inputmgr_add_callback(ly, 0, &channel_handler,
- (void *) channel_info->service_id);
-
- if (eina_list_next(l))
- elm_box_pack_end(priv->box, divider);
-
- if (channel_info->service_id == current_service)
- elm_object_focus_set(ly, EINA_TRUE);
-
- if (!first)
- first = ly;
- }
-
- if (first && ly) {
- elm_object_focus_next_object_set(first, ly, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(ly, first, ELM_FOCUS_DOWN);
- }
-}
-
-static bool _draw_channel_layout(struct _priv *priv)
-{
- priv->scroll = util_add_scroller(priv->base, NULL);
- if (!priv->scroll) {
- _ERR("failed to create scroll");
- return false;
- }
-
- priv->box = util_add_box(priv->scroll, false);
- if (!priv->box) {
- _ERR("failed to create box");
- evas_object_del(priv->scroll);
-
- return false;
- }
- elm_box_align_set(priv->box, 0.0, 0.5);
-
- return true;
-}
-
-static void _update_channel_list(struct _priv *priv)
-{
- Eina_List *channel_list;
-
- if (!priv) {
- _ERR("failed to get priv");
- return;
- }
-
- channel_list = tv_channel_get_list();
- if (!channel_list) {
- _ERR("failed to get channel list");
- return;
- }
-
- _load_channel_list(priv, channel_list);
-
- tv_channel_del_list(channel_list);
-}
-
-static bool _create(layoutmgr *lmgr, void *data)
-{
- struct _priv *priv;
- Evas_Object *win;
-
- priv = calloc(1, sizeof(*priv));
- if (!priv) {
- _ERR("failed to allocate priv");
- return false;
- }
-
- win = layoutmgr_get_base(lmgr);
-
- priv->base = elm_layout_add(win);
- if (!priv->base) {
- _ERR("failed to create layout");
- free(priv);
-
- return false;
- }
-
- elm_layout_file_set(priv->base, EDJEFILE,
- GRP_LAYOUT_CHANNELINFO_SEARCH);
- evas_object_size_hint_weight_set(priv->base,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, priv->base);
-
- if (!_draw_channel_layout(priv)) {
- _ERR("failed to create channel layout");
-
- evas_object_del(priv->base);
- free(priv);
-
- return false;
- }
-
- priv->lmgr = lmgr;
- layoutmgr_set_layout_data(lmgr, LAYOUT_CHANNELINFO_SEARCH, priv);
-
- return true;
-}
-
-static void _destroy(void *layout_data)
-{
- struct _priv *priv;
-
- if (!layout_data)
- return;
-
- priv = layout_data;
-
- evas_object_del(priv->base);
- free(priv);
-}
-
-static void _show(void *layout_data)
-{
- struct _priv *priv;
-
- if (!layout_data)
- return;
-
- priv = layout_data;
-
- _update_channel_list(priv);
-
- evas_object_show(priv->base);
-}
-
-static void _hide(void *layout_data)
-{
- struct _priv *priv;
-
- if (!layout_data)
- return;
-
- priv = layout_data;
-
- evas_object_hide(priv->base);
-}
-
-static void _update(void *layout_data, int update_type, void *data)
-{
-}
-
-static layout_class lclass = {
- .layout_id = LAYOUT_CHANNELINFO_SEARCH,
- .create = _create,
- .show = _show,
- .hide = _hide,
- .destroy = _destroy,
- .update = _update,
-};
-
-layout_class *layout_channelinfo_search_get_lclass(void)
-{
- return &lclass;
-}
diff --git a/src/main.c b/src/main.c
index 6df8345..d74bc47 100644..100755
--- a/src/main.c
+++ b/src/main.c
@@ -17,121 +17,20 @@
#include <app.h>
#include <Elementary.h>
#include <viewmgr.h>
-#include <inputmgr.h>
#include <app_debug.h>
#include <app_define.h>
-#include <tzsh_tvsrv.h>
#include <efl_util.h>
-#include <ui-gadget.h>
#include "define.h"
-#include "tv.h"
-#include "util.h"
#include "view.h"
-#define KEY_MAX 256
-#define PAUSE_WAIT_TIME 0.5
-
SET_TAG(PACKAGE)
struct _appdata {
const char *name;
Evas_Object *win;
- Ecore_Event_Handler *key_down;
- Ecore_Event_Handler *key_up;
- tzsh_h tzsh;
- tzsh_tvsrv_h ta;
- Ecore_Timer *pause_timer;
- int service_id;
-
- int is_signal;
- int is_channel;
- int is_tuned;
};
-struct key_map {
- const char *view;
- const char *key[KEY_MAX];
-};
-
-static struct key_map g_kmap[] = {
- {
- VIEW_CHANNELINFO,
- {
- KEY_ENTER,
- KEY_CHANNELUP,
- KEY_CHANNELDOWN,
- KEY_PREVIOUS,
- }
- },
- {
- VIEW_CHANNELNUMBER,
- {
- KEY_0, KEY_1, KEY_2, KEY_3,
- KEY_4, KEY_5, KEY_6, KEY_7,
- KEY_8, KEY_9, KEY_MINUS
- }
- },
- {
- VIEW_ACTION_MENU,
- {
- }
- },
-};
-
-static Eina_Bool _event(void *data, Evas_Object *obj, Evas_Object *src,
- Evas_Callback_Type type, void *ei)
-{
- struct _appdata *ad;
- size_t i, j;
- char *keyname;
- int update_type;
-
- if (type == EVAS_CALLBACK_KEY_DOWN &&
- !strcmp(((Evas_Event_Key_Down *)ei)->keyname,
- KEY_SUPER_L)) {
- util_launch_home();
- return EINA_TRUE;
- }
-
- if (!data) {
- _ERR("failed to get data");
- return EINA_FALSE;
- }
-
- ad = data;
-
- if (!ad->is_channel)
- return EINA_TRUE;
-
- switch (type) {
- case EVAS_CALLBACK_KEY_DOWN:
- keyname = ((Evas_Event_Key_Down *)ei)->keyname;
- update_type = UPDATE_TYPE_INPUT_KEY_DOWN;
- break;
- case EVAS_CALLBACK_KEY_UP:
- keyname = ((Evas_Event_Key_Up *)ei)->keyname;
- update_type = UPDATE_TYPE_INPUT_KEY_UP;
- break;
- default:
- return EINA_FALSE;
- }
-
- for (i = 0; i < sizeof(g_kmap) / sizeof(*g_kmap); i++) {
- j = 0;
- while (g_kmap[i].key[j]) {
- if (!strcmp(keyname, g_kmap[i].key[j])) {
- viewmgr_update_view(g_kmap[i].view,
- update_type, ei);
- return EINA_TRUE;
- }
- j++;
- }
- }
-
- return EINA_FALSE;
-}
-
static Evas_Object *_add_win(const char *name)
{
Evas_Object *win;
@@ -151,140 +50,10 @@ static Evas_Object *_add_win(const char *name)
return win;
}
-static tzsh_tvsrv_h _bind_win(Evas_Object *win, tzsh_h tzsh)
-{
- tzsh_window tz_win;
- tzsh_tvsrv_h ta;
-
- tz_win = elm_win_window_id_get(win);
- if (!tz_win) {
- _ERR("failed to get window ID");
- return NULL;
- }
-
- ta = tzsh_tvsrv_create(tzsh, tz_win);
- if (!ta) {
- _ERR("failed to create tvsrv");
- return NULL;
- }
- tzsh_tvsrv_bind(ta);
-
- return ta;
-}
-
-static void _tv_signal_cb(void *data, int is_signal)
-{
- struct _appdata *ad;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
-
- ad = data;
-
- ad->is_signal = is_signal;
- ad->is_tuned = true;
-
- if (is_signal) {
- viewmgr_hide_view(VIEW_ERROR);
- } else {
- viewmgr_show_view(VIEW_ERROR);
- viewmgr_update_view(VIEW_ERROR, UPDATE_TYPE_NOSIGNAL, NULL);
- }
-}
-
-Eina_Bool _tv_pause(void *data)
-{
- struct _appdata *ad;
- int r;
-
- if (!data) {
- _ERR("failed to get data");
- return ECORE_CALLBACK_CANCEL;
- }
-
- ad = data;
-
- r = tv_pause();
- if (r < 0)
- _ERR("Pause tv service failed");
-
- ad->pause_timer = NULL;
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static void _pause(void *data)
-{
- struct _appdata *ad;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
-
- ad = data;
-
- ad->pause_timer = ecore_timer_add(PAUSE_WAIT_TIME, _tv_pause, ad);
-}
-
-static void _resume(void *data)
-{
- struct _appdata *ad;
- int r;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
-
- ad = data;
-
- if (ad->pause_timer) {
- ecore_timer_del(ad->pause_timer);
- ad->pause_timer = NULL;
- }
-
- r = tv_resume();
- if (r < 0) {
- _ERR("Resume tv service failed");
- ui_app_exit();
-
- return;
- } else if (r > 0) {
- ad->is_tuned = false;
- }
-
- /* Try to tune with service id if supplied from app control */
- if (ad->service_id > 0) {
- r = tv_channel_tune_with_service_id(ad->service_id);
- ad->service_id = 0;
-
- if (!r) {
- ad->is_channel = true;
- return;
- }
- }
-
- if (ad->is_tuned)
- return;
-
- r = tv_channel_tune();
- if (r < 0) {
- ad->is_channel = false;
- viewmgr_show_view(VIEW_ERROR);
- viewmgr_update_view(VIEW_ERROR, UPDATE_TYPE_NOCHANNEL, NULL);
- } else {
- ad->is_channel = true;
- }
-}
-
static bool _create(void *data)
{
struct _appdata *ad;
Evas_Object *win;
- int r;
if (!data) {
_ERR("failed to get data");
@@ -294,13 +63,6 @@ static bool _create(void *data)
ad = data;
elm_app_base_scale_set(APP_BASE_SCALE);
- elm_theme_overlay_add(NULL, THEMEFILE);
-
- ad->tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL);
- if (!ad->tzsh) {
- _ERR("failed to create tzsh");
- return false;
- }
win = _add_win(ad->name);
if (!win) {
@@ -308,42 +70,16 @@ static bool _create(void *data)
return false;
}
- ad->ta = _bind_win(win, ad->tzsh);
- if (!ad->ta) {
- _ERR("failed to bind win object");
- evas_object_del(win);
- return false;
- }
-
- r = ug_init_efl(win, UG_OPT_INDICATOR_ENABLE);
- if (r < 0)
- _ERR("failed to init ug");
-
if (!viewmgr_create(win)) {
_ERR("failed to initialize viewmgr");
evas_object_del(win);
return false;
}
- viewmgr_add_view(view_error_get_vclass(), NULL);
- viewmgr_add_view(view_channelinfo_get_vclass(), NULL);
- viewmgr_add_view(view_channelnumber_get_vclass(), NULL);
- viewmgr_add_view(view_action_menu_get_vclass(), NULL);
- viewmgr_add_view(view_pin_get_vclass(), NULL);
-
- r = tv_create();
- if (r < 0) {
- _ERR("Create TV failed");
- evas_object_del(win);
- return false;
- }
-
+ viewmgr_add_view(view_bgimage_get_vclass(), NULL);
ad->win = win;
- tv_signal_cb_set(_tv_signal_cb, ad);
- elm_object_event_callback_add(win, _event, ad);
-
- elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_IN);
+ viewmgr_show_view(VIEW_BGIMAGE);
return true;
}
@@ -359,53 +95,11 @@ static void _terminate(void *data)
ad = data;
- if (ad->pause_timer) {
- ecore_timer_del(ad->pause_timer);
- ad->pause_timer = NULL;
- }
-
if (ad->win) {
- tv_destroy();
-
- elm_object_event_callback_del(ad->win, _event, ad);
-
- viewmgr_remove_view(VIEW_CHANNELINFO);
- viewmgr_remove_view(VIEW_CHANNELNUMBER);
- viewmgr_remove_view(VIEW_ERROR);
- viewmgr_remove_view(VIEW_ACTION_MENU);
- viewmgr_remove_view(VIEW_PIN);
- viewmgr_destroy();
-
+ viewmgr_remove_view(VIEW_BGIMAGE);
evas_object_del(ad->win);
ad->win = NULL;
-
- if (ad->ta)
- tzsh_tvsrv_destroy(ad->ta);
-
- if (ad->tzsh)
- tzsh_destroy(ad->tzsh);
- }
-}
-
-static void _control(app_control_h control, void *data)
-{
- struct _appdata *ad;
- char *svcid;
- int r;
-
- if (!data) {
- _ERR("failed to get data");
- return;
}
-
- ad = data;
-
- r = app_control_get_extra_data(control, KEY_SVCID, &svcid);
- if (r != APP_CONTROL_ERROR_NONE)
- return;
-
- ad->service_id = atoll(svcid);
- free(svcid);
}
int main(int argc, char *argv[])
@@ -414,9 +108,6 @@ int main(int argc, char *argv[])
ui_app_lifecycle_callback_s cbs = {
.create = _create,
.terminate = _terminate,
- .pause = _pause,
- .resume = _resume,
- .app_control = _control,
};
memset(&ad, 0x00, sizeof(ad));
diff --git a/src/tv.c b/src/tv.c
deleted file mode 100644
index cfd92dc..0000000
--- a/src/tv.c
+++ /dev/null
@@ -1,1169 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * 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 <stdio.h>
-#include <app.h>
-#include <iconv.h>
-#include <math.h>
-#include <app_debug.h>
-#include <app_contents.h>
-
-#include <tv_service_proxy.h>
-#include <tv_service_proxy_epg.h>
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "define.h"
-#include "tv.h"
-
-#define DEFAULT_SERVICE 1
-
-struct _channel_history {
- int service_id[2];
- unsigned int idx;
-};
-
-/**
- * The Storage structure to used by tv related functions and events.
- */
-struct _tv_info {
- /**< The handle to use tv service live api. */
- TvServiceLive live_svc;
- /**< The handle to use tv service epg api. */
- TvServiceEpg epg_svc;
-
- /**< Stores service id if tune to locked channel was succeeded. */
- int viewing_locked_channel;
- /**< Stores previous service id. */
- struct _channel_history history;
-
- /**< The function pointer to pass tv signal event */
- void (*signal_cb)(void *data, int is_signal);
- /**< An Additional data to passed to tv signal event */
- void *signal_cb_data;
-};
-
-static struct _tv_info g_tv_info;
-
-/**
- * Gets the tv_channel_info with supplied TvServiceChannel.
- *
- * Abstracts tv service data structure.
- *
- * @param channel The channel data defined by tv service
- * @return Channel information, or NULL if fails
- */
-static struct tv_channel_info *_tv_channel_get_info(TvServiceChannel *channel)
-{
- struct tv_channel_info *channel_info = NULL;
-
- if (!channel) {
- _ERR("failed to get channel");
- return NULL;
- }
-
- channel_info = calloc(1, sizeof(*channel_info));
- if (!channel_info) {
- _ERR("failed to calloc channel info");
- return NULL;
- }
-
- channel_info->service_id = channel->service_id;
- channel_info->channel_major = channel->major;
- channel_info->channel_minor = channel->minor;
- channel_info->channel_type = channel->channel_type;
- channel_info->locked = channel->locked;
- channel_info->digital = channel->digital;
- channel_info->favorite = channel->favorite;
- channel_info->remembered = channel->remembered;
- strncpy(channel_info->channel_name, channel->program_name,
- CHANNEL_NAME_MAX);
-
- if (channel->service_id == g_tv_info.viewing_locked_channel)
- channel_info->tune_locked = EINA_TRUE;
-
- return channel_info;
-}
-
-/**
- * Clones the tv_channel_info.
- *
- * @param channel_info tv_channel_info pointer to be cloned
- * @return Channel information, or NULL if fails
- */
-const struct tv_channel_info *tv_channel_clone_info(
- const struct tv_channel_info *channel_info)
-{
- struct tv_channel_info *new_channel_info = NULL;
-
- if (!channel_info) {
- _ERR("failed to get channel info");
- return NULL;
- }
-
- new_channel_info = calloc(1, sizeof(*channel_info));
- if (!new_channel_info) {
- _ERR("failed to calloc channel info");
- return NULL;
- }
-
- memcpy(new_channel_info, channel_info, sizeof(*new_channel_info));
-
- return new_channel_info;
-}
-
-/**
- * Frees the tv_channel_info.
- *
- * @param channel_info tv_channel_info pointer to be freed
- */
-void tv_channel_del_info(const struct tv_channel_info *channel_info)
-{
- if (!channel_info) {
- _ERR("failed to get channel info");
- return;
- }
-
- free((void *)channel_info);
-}
-
-/**
- * Gets current channel's TvServiceChannel data from tv service.
- *
- * @param channel The pointer to store TvServiceChannel
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-static int _tv_get_channel(TvServiceChannel *channel)
-{
- gint svc_id;
- int r;
-
- if (!g_tv_info.live_svc) {
- _ERR("failed to get live service");
- return -1;
- }
-
- r = tv_service_live_get_service_id(g_tv_info.live_svc, &svc_id);
- if (r < 0) {
- _ERR("failed to get service id");
- return -1;
- }
-
- r = tv_service_get_channel(svc_id, channel);
- if (r < 0) {
- _ERR("failed to get channel");
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Returns current channel's info.
- *
- * tv_channel_get_info retrieves current channel's information
- * from tv service.
- *
- * @return Returns current channel info, or NULL if fails
- */
-const struct tv_channel_info *tv_channel_get_info(void)
-{
- const struct tv_channel_info *channel_info;
- TvServiceChannel channel;
- int r;
-
- r = _tv_get_channel(&channel);
- if (r < 0) {
- _ERR("failed to get channel");
- return NULL;
- }
-
- channel_info = _tv_channel_get_info(&channel);
-
- return channel_info;
-}
-
-/**
- * Returns tv_program_info with supplied TvServiceEpgEventData.
- *
- * Abstracts tv service data structure.
- *
- * @param prog TvServiceEpgEventData passed from tv service
- * @return Returns tv_program_info, or NULL if fails
- */
-static struct tv_program_info *_tv_get_program_info(TvServiceEpgEventData *prog)
-{
- struct tv_program_info *prog_info;
-
- prog_info = calloc(1, sizeof(*prog_info));
- if (!prog_info) {
- _ERR("failed to calloc program info");
- return NULL;
- }
-
- prog_info->service_id = prog->service_id;
- prog_info->start_time = prog->start_time;
- prog_info->end_time = prog->start_time + prog->length_in_seconds;
- prog_info->duration = prog->length_in_seconds;
- prog_info->current_time = prog->current_time;
- strncpy(prog_info->prog_title, (char *)prog->title_text,
- sizeof(prog_info->prog_title) - 1);
- strncpy(prog_info->prog_description, (char *)prog->extended_text,
- sizeof(prog_info->prog_description) - 1);
-
- return prog_info;
-}
-
-/**
- * Gets current channel's service id from tv service.
- *
- * @param service_id The pointer to store service id
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_get_current_service_id(int *service_id)
-{
- int r;
-
- if (!g_tv_info.live_svc) {
- _ERR("failed to get live service");
- return -1;
- }
-
- r = tv_service_live_get_service_id(g_tv_info.live_svc, service_id);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to get current service info");
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Frees epg list.
- *
- * @param epg_list Eina_List to be freed
- */
-static void _tv_epg_del_list(Eina_List *epg_list)
-{
- struct tv_program_info *data;
-
- EINA_LIST_FREE(epg_list, data)
- free(data);
-}
-
-/**
- * Callback function to get EPG program list from tv service.
- *
- * _tv_epg_event_cb is called from tv service when banner
- * have requested to get program data.
- * If this function is called, then derives program list from epg_list
- * and calls banner's callback function which included in user_data.
- *
- * @param type Event type
- * @param epg_list EPG program list
- * @param user_data tv_program_request to handle request
- */
-static void _tv_epg_event_cb(tvs_epg_event_e type, GList *epg_list,
- void *user_data)
-{
- int i;
- Eina_List *list = NULL;
- TvServiceEpgEventData *epg_data;
- struct tv_program_info *prog_info;
- struct tv_program_request *request;
-
- if (!user_data) {
- _ERR("failed to get user_data");
- return;
- }
-
- for (i = 0; i < g_list_length(epg_list); i++) {
- epg_data = (TvServiceEpgEventData *)
- g_list_nth_data(epg_list, i);
-
- if (!epg_data)
- continue;
-
- prog_info = _tv_get_program_info(epg_data);
- if (prog_info)
- list = eina_list_append(list, prog_info);
- }
-
- request = (struct tv_program_request *) user_data;
- if (request->tv_program_cb)
- request->tv_program_cb(list, request->user_data);
-
- if (list)
- _tv_epg_del_list(list);
-
- free(request);
-}
-
-/**
- * Send a request to tv service to get a current program with supplied service_id.
- *
- * Beware that service_id should be current tuned channel.
- * If not, calling this function may cause unexpected behavior.
- * And note that get a EPG program is asynchronous operation.
- * So tv_program_request should be supplied to get a result from tv service.
- *
- * @param service_id The channel id to get current program
- * @param request The structure for return program data which contains function pointer
- * and additional data for banner
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_epg_get_program(int service_id, struct tv_program_request *request)
-{
- int r;
-
- if (!g_tv_info.epg_svc) {
- _ERR("failed to get epg service");
- return -1;
- }
-
- if (!request) {
- _ERR("failed to get tv_program_request");
- return -1;
- }
-
- r = tv_service_epg_get_current_program(g_tv_info.epg_svc, service_id,
- (TvServiceEpgCallback) _tv_epg_event_cb, request);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to get epg get current program : %d", service_id);
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Gets a cached current program with supplied service_id from tv service.
- *
- * Note that this function is vaild only when tv service having a cached data
- * on that channel.
- * To have a cached data, the channel ever been tuned before calling
- * this function.
- *
- * @param service_id The channel id to get current program
- * @param request The structure for return program data which contains
- * function pointer and additional data for banner
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_epg_get_cache_program(int service_id, struct tv_program_request *request)
-{
- Eina_List *list = NULL;
- TvServiceEpgEventData epg_data;
- struct tv_program_info *prog_info;
-
- int r;
-
- if (!g_tv_info.epg_svc) {
- _ERR("failed to get epg service");
- return -1;
- }
-
- if (!request) {
- _ERR("failed to get tv_program_request");
- return -1;
- }
-
- r = tv_service_epg_get_cache_current_program(
- g_tv_info.epg_svc, service_id, &epg_data);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to get epg get cached current program : %d",
- service_id);
- return -1;
- }
-
- prog_info = _tv_get_program_info(&epg_data);
- if (prog_info)
- list = eina_list_append(list, prog_info);
-
- if (request->tv_program_cb)
- request->tv_program_cb(list, request->user_data);
-
- if (list)
- _tv_epg_del_list(list);
-
- free(request);
-
- return 0;
-}
-
-/**
- * Sends a request to tv service to get programs with supplied service_id.
- *
- * Beware that service_id should be current tuned channel.
- * If not, calling this function may cause unexpected behavior.
- * And note that get a EPG program is asynchronous operation.
- * So tv_program_request should be supplied to get a result from tv service.
- *
- * @param service_id The channel id to get current program
- * @param request The structure for return program data which contains function pointer and additional data for banner
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_epg_get_program_list(int service_id,
- struct tv_program_request *request)
-{
- int r;
-
- if (!g_tv_info.epg_svc) {
- _ERR("failed to get epg service");
- return -1;
- }
-
- if (!request) {
- _ERR("failed to get tv_program_request");
- return -1;
- }
-
- r = tv_service_epg_get_program_list(g_tv_info.epg_svc, service_id,
- TVS_EPG_CURRENT_TIME, EPG_PROGRAM_OFFSET,
- (TvServiceEpgCallback) _tv_epg_event_cb, request);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to get epg get current program");
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Frees the TvServiceFilterNode.
- *
- * @param data TvServiceFilterNode pointer to be freed
- */
-static void _tv_channel_free_filter(gpointer data)
-{
- TvServiceFilterNode *filter_node;
-
- if (!data)
- return;
-
- filter_node = (TvServiceFilterNode *) data;
-
- g_value_unset(filter_node->value);
- g_free(filter_node->value);
- g_free(filter_node);
-}
-
-/**
- * Gets a available channel list.
- *
- * Note that deleted channels and service channels are excluded by default.
- *
- * @return Available channel list, or NULL if fails
- */
-Eina_List *tv_channel_get_list()
-{
- GList *tvs_list = NULL;
- Eina_List *channel_list = NULL;
- TvServiceChannel *tvs_data = NULL;
- const struct tv_channel_info *channel_info;
- int r, i;
-
- r = tv_service_get_channel_list(
- TV_SERVICE_CHANNEL_MODE_DIGITAL_ANALOG,
- TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to get channel list");
- return NULL;
- }
-
- for (i = 0; i < g_list_length(tvs_list); i++) {
- tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
- if (tvs_data) {
- channel_info = _tv_channel_get_info(tvs_data);
- if (channel_info)
- channel_list = eina_list_append(channel_list,
- channel_info);
- }
- }
-
- tv_service_free_channel_list(tvs_list);
-
- return channel_list;
-}
-
-/**
- * Gets a favorite channel list.
- *
- * @return Favorite channel list, or NULL if fails
- */
-Eina_List *tv_channel_get_favorite_list()
-{
- GList *tvs_list = NULL;
- Eina_List *channel_list = NULL;
- TvServiceChannel *tvs_data = NULL;
- const struct tv_channel_info *channel_info;
- int r, i;
-
- r = tv_service_get_channel_list(
- TV_SERVICE_CHANNEL_MODE_FAVORITE,
- TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to get channel list");
- return NULL;
- }
-
- for (i = 0; i < g_list_length(tvs_list); i++) {
- tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
- if (tvs_data) {
- channel_info = _tv_channel_get_info(tvs_data);
- if (channel_info)
- channel_list = eina_list_append(channel_list,
- channel_info);
- }
- }
-
- tv_service_free_channel_list(tvs_list);
-
- return channel_list;
-}
-
-TvServiceFilterNode *_tv_channel_get_filter(
- TvServiceChannelDataAttr attribute, int type, void *data)
-{
- TvServiceFilterNode *filter;
- GValue *value;
-
- filter = g_malloc0(sizeof(*filter));
- if (!filter)
- return NULL;
-
- filter->attribute = attribute;
-
- value = g_malloc0(sizeof(GValue));
- if (!value) {
- g_free(filter);
- return NULL;
- }
-
- switch (type) {
- case G_TYPE_STRING:
- g_value_init(value, G_TYPE_STRING);
- g_value_set_string(value, data);
-
- filter->match_type = CHANNEL_FILTER_MATCH_CONTAIN;
- break;
- case G_TYPE_INT:
- g_value_init(value, G_TYPE_INT);
- g_value_set_int(value, (gint) data);
-
- filter->match_type = CHANNEL_FILTER_MATCH_EQUAL;
- break;
- }
- filter->value = value;
-
- return filter;
-}
-
-/**
- * Search channels that are starts with supplied major and minor number.
- *
- * Note that deleted channels and service channels are excluded by default.
- *
- * @param major Major channel number to search
- * @param minor Minor channel number to search
- * @return Found channel list, or NULL if fails
- */
-Eina_List *tv_channel_search_by_number(long major, long minor)
-{
- char buf[CHANNEL_FILTER_STRING_MAX_LEN];
- GList *tvs_list = NULL, *filter = NULL;
- TvServiceFilterNode *filter_node;
- TvServiceChannel *tvs_data;
- Eina_List *channel_list = NULL;
- const struct tv_channel_info *channel_info;
- int i, r;
-
- if (major > 0 && major < MAJOR_MAX) {
- snprintf(buf, CHANNEL_FILTER_STRING_MAX_LEN, "%ld", major);
-
- filter_node = _tv_channel_get_filter(
- TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER,
- G_TYPE_STRING, buf);
- if (filter_node)
- filter = g_list_append(filter, (gpointer)filter_node);
- }
-
- if (minor > 0 && minor < MINOR_MAX) {
- snprintf(buf, CHANNEL_FILTER_STRING_MAX_LEN, "%ld", minor);
-
- filter_node = _tv_channel_get_filter(
- TV_SERVICE_CHANNEL_DATA_MINOR_NUMBER,
- G_TYPE_STRING, buf);
- if (filter_node)
- filter = g_list_append(filter, (gpointer)filter_node);
- }
-
- if (!filter) {
- _ERR("failed to get filter");
- return NULL;
- }
-
- r = tv_service_get_channel_list_ex(
- TV_SERVICE_CHANNEL_MODE_ALL_DIGITAL_ANALOG,
- TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list, filter, 0);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to get channel list");
- goto free;
- }
-
- for (i = 0; i < g_list_length(tvs_list); i++) {
- tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
- if (!tvs_data)
- continue;
-
- channel_info = _tv_channel_get_info(tvs_data);
- if (channel_info)
- channel_list = eina_list_append(channel_list,
- channel_info);
- }
-
-free:
- tv_service_free_channel_list(tvs_list);
-
- g_list_foreach(filter, (GFunc) _tv_channel_free_filter, NULL);
- g_list_free(filter);
-
- return channel_list;
-}
-
-/**
- * Frees the tv_channel_info.
- *
- * @param channel_list channel_list pointer to be freed
- */
-void tv_channel_del_list(Eina_List *channel_list)
-{
- struct tv_channel_info *data;
-
- EINA_LIST_FREE(channel_list, data)
- free(data);
-}
-
-static void _tv_channel_add_history(int service_id)
-{
- char buf[128];
-
- g_tv_info.history.service_id[g_tv_info.history.idx++ % 2]
- = service_id;
-
- snprintf(buf, sizeof(buf), "%d", service_id);
- app_contents_recent_add(CONTENTS_CHANNEL, buf);
-}
-
-static int _tv_channel_get_history(void)
-{
- int service_id;
-
- service_id = g_tv_info.history.service_id[g_tv_info.history.idx % 2];
-
- return service_id;
-}
-
-/**
- * Tunes to specific channel with service id.
- *
- * @param service_id The channel id
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_tune_with_service_id(int service_id)
-{
- int r;
-
- if (!g_tv_info.live_svc) {
- _ERR("failed to get live service");
- return -1;
- }
-
- r = tv_service_live_tune(g_tv_info.live_svc, service_id);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to set service");
- return -1;
- }
-
- _tv_channel_add_history(service_id);
-
- g_tv_info.viewing_locked_channel = -1;
-
- return 0;
-}
-
-/**
- * Tunes to last viewed channel.
- *
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_tune(void)
-{
- int service_id;
- int r;
-
- if (!g_tv_info.live_svc) {
- _ERR("failed to get live service");
- return -1;
- }
-
- r = tv_service_live_get_last_channel(&service_id);
- if (r < 0 || service_id < 1) {
- _ERR("failed to get current service id");
- service_id = DEFAULT_SERVICE;
- }
-
- r = tv_service_live_tune(g_tv_info.live_svc, service_id);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to set service");
- return -1;
- }
-
- _tv_channel_add_history(service_id);
-
- g_tv_info.viewing_locked_channel = -1;
-
- return 0;
-}
-
-/**
- * Tunes to previously viewed channel.
- *
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_tune_prev_channel(void)
-{
- int service_id;
- int r;
-
- if (!g_tv_info.live_svc) {
- _ERR("failed to get live service");
- return -1;
- }
-
- service_id = _tv_channel_get_history();
- if (service_id < 1) {
- _ERR("no previous channel");
- return -1;
- }
-
- r = tv_service_live_tune(g_tv_info.live_svc, service_id);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to set service");
- return -1;
- }
-
- _tv_channel_add_history(service_id);
-
- g_tv_info.viewing_locked_channel = -1;
-
- return 0;
-}
-
-/**
- * Tunes to specific channel with major and minor.
- *
- * @param service_id The channel id
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_direct_tune(long major, long minor)
-{
- GList *tvs_list = NULL, *filter = NULL;
- TvServiceFilterNode *filter_node;
- TvServiceChannel *tvs_data;
- int r;
-
- if (!g_tv_info.live_svc) {
- _ERR("failed to get live service");
- return -1;
- }
-
- if (major > 0 && major < MAJOR_MAX) {
- filter_node = _tv_channel_get_filter(
- TV_SERVICE_CHANNEL_DATA_MAJOR_NUMBER,
- G_TYPE_INT, (void *) major);
- if (filter_node)
- filter = g_list_append(filter, (gpointer)filter_node);
- }
-
- if (minor > 0 && minor < MINOR_MAX) {
- filter_node = _tv_channel_get_filter(
- TV_SERVICE_CHANNEL_DATA_MINOR_NUMBER,
- G_TYPE_INT, (void *) minor);
- if (filter_node)
- filter = g_list_append(filter, (gpointer)filter_node);
- }
-
- if (!filter) {
- _ERR("failed to get filter");
- return -1;
- }
-
- r = tv_service_get_channel_list_ex(
- TV_SERVICE_CHANNEL_MODE_ALL_DIGITAL_ANALOG,
- TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list, filter, 0);
- if (r != TVS_ERROR_OK)
- goto free;
-
- tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, 0);
- if (tvs_data)
- r = tv_channel_tune_with_service_id(tvs_data->service_id);
- else {
- _ERR("failed to get tvs_data");
- r = -1;
- }
-
- if (r == TVS_ERROR_OK)
- g_tv_info.viewing_locked_channel = -1;
-
- tv_service_free_channel_list(tvs_list);
-
-free:
- g_list_foreach(filter, (GFunc) _tv_channel_free_filter, NULL);
- g_list_free(filter);
-
- return r;
-}
-
-/**
- * Tunes to locked channel.
- *
- * @param service_id The channel id
- * @param password 4 digit password
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_tune_locked_channel(int service_id, char *password)
-{
- int r;
-
- if (!g_tv_info.live_svc) {
- _ERR("failed to get live service");
- return -1;
- }
-
- r = tv_service_live_tune_locked_channel(g_tv_info.live_svc,
- service_id, password);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to set service");
- return -1;
- }
-
- _tv_channel_add_history(service_id);
-
- g_tv_info.viewing_locked_channel = service_id;
-
- return 0;
-}
-
-/**
- * Sets the channel's favorite status.
- *
- * @param service_id The channel id
- * @param flag The value to be set
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_set_favorite(int service_id, Eina_Bool flag)
-{
- int r;
-
- if (flag) {
- r = tv_service_add_favorite_channel(service_id);
- if (r < 0) {
- _ERR("failed to add favorite channel");
- return -1;
- }
- } else {
- r = tv_service_delete_favorite_channel(service_id);
- if (r < 0) {
- _ERR("failed to delete favorite channel");
- return -1;
- }
- }
-
- return 0;
-}
-
-/**
- * Adds the channel.
- *
- * If channel is added, the channel will be included at
- * tv_channel_next, tv_channel_prev and tv_channel_get_list.
- *
- * @param service_id The channel id
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_add_channel(int service_id)
-{
- int r;
-
- r = tv_service_add_channel(service_id);
- if (r < 0) {
- _ERR("failed to add channel");
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Deletes the channel.
- *
- * If channel is deleted, the channel will be omitted at
- * tv_channel_next, tv_channel_prev and tv_channel_get_list.
- *
- * @param service_id The channel id
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_del_channel(int service_id)
-{
- int r;
-
- r = tv_service_delete_channel(service_id);
- if (r < 0) {
- _ERR("failed to delete channel");
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Locks the channel.
- *
- * @param service_id The channel id
- * @param password 4 digits password
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_lock_channel(int service_id, char *password)
-{
- int r;
-
- r = tv_service_lock_channel(service_id, password);
- if (r < 0) {
- _ERR("failed to lock channel");
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Unlocks the channel.
- *
- * @param service_id The channel id
- * @param password 4 digits password
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_channel_unlock_channel(int service_id, char *password)
-{
- int r;
-
- r = tv_service_unlock_channel(service_id, password);
- if (r < 0) {
- _ERR("failed to unlock channel");
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Callback function for receives tv service events.
- *
- * @param event Event type
- * @param user_data Not in use
- * @param data Event specific detailed data
- */
-void _tv_service_event_cb(TvServiceLiveEvent event,
- gpointer user_data, const gpointer data)
-{
- gboolean *lock_status;
-
- switch (event) {
- case TV_SERVICE_LIVE_EVENT_TUNER_LOCK:
- if (!data) {
- _ERR("failed to get data");
- break;
- }
-
- lock_status = (gboolean *) data;
- if (g_tv_info.signal_cb)
- g_tv_info.signal_cb(g_tv_info.signal_cb_data,
- *lock_status);
- break;
- case TV_SERVICE_LIVE_EVENT_AUTO_DESTROY:
- g_tv_info.live_svc = NULL;
- break;
- case TV_SERVICE_LIVE_EVENT_RESOLUTION:
- case TV_SERVICE_LIVE_EVENT_BEGIN:
- case TV_SERVICE_LIVE_EVENT_CHANNEL_LOCK:
- case TV_SERVICE_LIVE_EVENT_CHANNEL_UNLOCK:
- break;
- }
-}
-
-/**
- * Sets tv signal callback function.
- *
- * @param cb The function pointer to get callback
- * @param data An Additional data to passed to callback
- */
-void tv_signal_cb_set(void (*cb)(void *data, int is_signal), void *data)
-{
- g_tv_info.signal_cb = cb;
- g_tv_info.signal_cb_data = data;
-}
-
-/**
- * Destory the tv service handles.
- *
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_destroy(void)
-{
- int r;
-
- if (g_tv_info.live_svc)
- g_tv_info.live_svc = NULL;
-
- r = tv_service_channel_info_destroy();
- if (r < 0)
- _ERR("failed to destroy channel info service");
-
- if (g_tv_info.epg_svc) {
- r = tv_service_epg_destroy(g_tv_info.epg_svc);
- if (r != 0)
- _ERR("failed to destroy epg service");
- g_tv_info.epg_svc = NULL;
- }
-
- return 0;
-}
-
-/**
- * Create the tv service handles.
- *
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_create(void)
-{
- int r;
-
- r = tv_service_live_create(&g_tv_info.live_svc);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to create live service");
- goto err;
- }
-
- r = tv_service_live_register_callback(g_tv_info.live_svc,
- _tv_service_event_cb, NULL);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to register live callback");
- goto err;
- }
-
- r = tv_service_channel_info_create();
- if (r != TVS_ERROR_OK) {
- _ERR("failed to create channel info service");
- goto err;
- }
-
- /*
- r = tv_service_epg_create(&g_tv_info.epg_svc);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to create epg service");
- goto err;
- }
- */
-
- memset(&g_tv_info.history, 0, sizeof(g_tv_info.history));
-
- return 0;
-err:
- tv_destroy();
- return -1;
-}
-
-/**
- * Pause the tv service handles.
- *
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_pause(void)
-{
- int r;
-
- if (g_tv_info.live_svc) {
- r = tv_service_live_tune_pause(g_tv_info.live_svc);
- if (r != TVS_ERROR_OK)
- _ERR("failed to pause live service");
- }
-
- return 0;
-}
-
-/**
- * Resume the tv service handles.
- *
- * Live service could be destroyed by tv service while app is pausing.
- * If live service is destroyed, then _tv_service_event_cb sets
- * g_tv_info.live_svc to NULL.
- * So if g_tv_info.live_svc is NULL, then recreates live service and returns 1.
- * Therefore, if tv_resume returns 1, then app needs to be set overlay and tune.
- * Or returns 0, then app just needs to set overlay.
- *
- * @return 0 if successful; 1 if live service was destroyed; otherwise negative value is returned
- */
-int tv_resume(void)
-{
- int r;
-
- if (!g_tv_info.live_svc) {
- r = tv_service_live_create(&g_tv_info.live_svc);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to create live service");
- goto err;
- }
-
- r = tv_service_live_register_callback(g_tv_info.live_svc,
- _tv_service_event_cb, NULL);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to register live callback");
- goto err;
- }
-
- return 1;
- }
-
- r = tv_service_live_tune_resume(g_tv_info.live_svc);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to create live service");
- goto err;
- }
-
- r = tv_service_live_register_callback(g_tv_info.live_svc,
- _tv_service_event_cb, NULL);
- if (r != TVS_ERROR_OK) {
- _ERR("failed to register live callback");
- goto err;
- }
-
- return 0;
-
-err:
- tv_destroy();
- return -1;
-}
diff --git a/src/util.c b/src/util.c
deleted file mode 100644
index b1a0711..0000000
--- a/src/util.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * 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 <app.h>
-#include <Elementary.h>
-#include <app_debug.h>
-#include <app_define.h>
-#include <viewmgr.h>
-
-#include "define.h"
-#include "view.h"
-
-#define BUF_MAX 128
-#define TOAST_TIMEOUT 5.0
-#define STYLE_TOAST "toast"
-
-Evas_Object *util_add_layout(Evas_Object *parent, const char *group)
-{
- Evas_Object *ly;
-
- if (!parent) {
- _ERR("failed to get parent");
- return NULL;
- }
-
- ly = elm_layout_add(parent);
- if (!ly) {
- _ERR("failed to create layout");
- return NULL;
- }
- elm_layout_file_set(ly, EDJEFILE, group);
-
- evas_object_show(ly);
-
- return ly;
-}
-
-Evas_Object *util_add_box(Evas_Object *parent, bool horizon)
-{
- Evas_Object *box;
-
- if (!parent) {
- _ERR("failed to get parent");
- return NULL;
- }
-
- box = elm_box_add(parent);
- if (!box) {
- _ERR("failed to create box");
- return NULL;
- }
-
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_object_content_set(parent, box);
- if (horizon)
- elm_box_horizontal_set(box, EINA_TRUE);
- else
- elm_box_horizontal_set(box, EINA_FALSE);
-
- evas_object_show(box);
-
- return box;
-}
-
-Evas_Object *util_add_scroller(Evas_Object *parent, const char *part)
-{
- Evas_Object *scroll;
-
- if (!parent) {
- _ERR("failed to get parent");
- return NULL;
- }
-
- scroll = elm_scroller_add(parent);
- if (!scroll) {
- _ERR("failed to create scroll");
- return NULL;
- }
-
- evas_object_size_hint_weight_set(scroll, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_scroller_policy_set(scroll, ELM_SCROLLER_POLICY_OFF,
- ELM_SCROLLER_POLICY_OFF);
-
- elm_object_part_content_set(parent, part, scroll);
-
- evas_object_show(scroll);
-
- return scroll;
-}
-
-Evas_Object *util_add_icon(Evas_Object *parent, const char *file,
- const char *part)
-{
- Evas_Object *ic;
-
- if (!parent) {
- _ERR("failed to get parent");
- return NULL;
- }
-
- ic = elm_icon_add(parent);
- if (!ic) {
- _ERR("failed to create icon");
- return NULL;
- }
-
- if (file)
- elm_image_file_set(ic, file, NULL);
-
- if (part)
- elm_object_part_content_set(parent, part, ic);
-
- elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE);
-
- evas_object_show(ic);
-
- return ic;
-}
-
-Evas_Object *util_add_button(Evas_Object *parent, const char *part,
- const char *text, const char *style)
-{
- Evas_Object *btn;
-
- if (!parent) {
- _ERR("Invalid argument.");
- return NULL;
- }
-
- btn = elm_button_add(parent);
- if (!btn) {
- _ERR("elm_button_add failed.");
- return NULL;
- }
-
- if (part)
- elm_object_part_content_set(parent, part, btn);
- if (text)
- elm_object_text_set(btn, text);
- if (style)
- elm_object_style_set(btn, style);
-
- evas_object_show(btn);
-
- return btn;
-}
-
-static void _notify_timeout_cb(void *data, Evas_Object *obj, void *ei)
-{
- if (!obj)
- return;
-
- evas_object_del(obj);
-}
-
-Evas_Object *util_add_toast(Evas_Object *parent, char *text)
-{
- Evas_Object *toast, *content;
-
- if (!parent) {
- _ERR("Invalid argument.");
- return NULL;
- }
-
- toast = elm_notify_add(parent);
- if (!toast) {
- _ERR("elm_popup_add failed");
- return NULL;
- }
-
- elm_object_style_set(toast, STYLE_TOAST);
- elm_notify_align_set(toast, 0.0, 1.0);
- elm_notify_timeout_set(toast, TOAST_TIMEOUT);
- evas_object_smart_callback_add(toast, SIGNAL_TIMEOUT,
- _notify_timeout_cb, NULL);
-
- content = elm_label_add(toast);
- if (!content) {
- _ERR("elm_label_add failed");
- evas_object_del(toast);
- return NULL;
- }
-
- elm_object_text_set(content, text);
- elm_object_style_set(content, STYLE_TOAST);
- elm_object_content_set(toast, content);
- evas_object_show(content);
-
- evas_object_show(toast);
-
- return toast;
-}
-
-static int _get_program_time(char *buf, int buf_len, time_t start_time,
- time_t end_time)
-{
- struct tm tm;
- int r;
-
- if (start_time >= end_time) {
- _ERR("invalid time");
- return -1;
- }
-
- localtime_r(&start_time, &tm);
- r = strftime(buf, buf_len, "%I:%M %P -", &tm);
- if (r <= 0)
- return -1;
-
- localtime_r(&end_time, &tm);
- r = strftime(buf + r, buf_len - r, " %I:%M %P", &tm);
- if (r <= 0)
- return -1;
-
- return 0;
-}
-
-static void _set_icon_box(Evas_Object *obj,
- const struct tv_channel_info *channel_info)
-{
- elm_object_signal_emit(obj, SIGNAL_RESET, SOURCE_PROGRAM);
-
- if (channel_info->locked)
- elm_object_signal_emit(obj, SIGNAL_LOCKED, SOURCE_PROGRAM);
- if (channel_info->favorite)
- elm_object_signal_emit(obj, SIGNAL_FAVORITE, SOURCE_PROGRAM);
-}
-
-static void _load_channel_text(Evas_Object *obj,
- const struct tv_channel_info *channel_info)
-{
- char buf[BUF_MAX];
-
- if (channel_info->channel_minor > 0 &&
- channel_info->channel_minor < MINOR_MAX)
- snprintf(buf, sizeof(buf), "%lu-%lu %s",
- channel_info->channel_major,
- channel_info->channel_minor,
- channel_info->channel_name);
- else
- snprintf(buf, sizeof(buf), "%lu %s",
- channel_info->channel_major,
- channel_info->channel_name);
-
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_CHANNEL, buf);
-
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_TITLE,
- STR_NOTITLE);
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_TIME,
- STR_NOTIME);
-}
-
-static void _load_program_info(Evas_Object *obj,
- const struct tv_program_info *prog)
-{
- char buf[BUF_MAX];
- int r, service_id;
-
- service_id = (int) evas_object_data_get(obj, KEY_SVCID);
- if (service_id != prog->service_id)
- return;
-
- if (prog->start_time && prog->end_time) {
- r = _get_program_time(buf, sizeof(buf),
- prog->start_time,
- prog->end_time);
- if (!r)
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_TIME, buf);
- }
-
- if (strlen(prog->prog_title) > 0)
- elm_object_part_text_set(obj,
- PART_CHANNELINFO_TITLE, prog->prog_title);
-}
-
-static void _tv_program_cb(Eina_List *prog_list, void *data)
-{
- int op;
- Evas_Object *obj;
- struct tv_program_info *prog = NULL;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
-
- obj = data;
-
- prog = (struct tv_program_info *) eina_list_nth(prog_list, 0);
- if (prog)
- _load_program_info(obj, prog);
- else
- _ERR("failed to get tv_program_info");
-
- if (viewmgr_get_view_state(VIEW_CHANNELINFO) == VIEW_STATE_VISIBLE) {
- op = START_HIDE_TIMER;
- viewmgr_update_view(VIEW_CHANNELINFO,
- UPDATE_TYPE_TIMER, &op);
- }
-}
-
-void util_draw_channel_info(Evas_Object *obj,
- const struct tv_channel_info *channel_info)
-{
- struct tv_program_request *prog_req;
- int r, op;
- int current_service;
-
- if (!obj || !channel_info) {
- _ERR("Invalid argument");
-
- return;
- }
-
- r = tv_get_current_service_id(&current_service);
- if (r < 0)
- current_service = -1;
-
- if (viewmgr_get_view_state(VIEW_CHANNELINFO) == VIEW_STATE_VISIBLE) {
- op = STOP_HIDE_TIMER;
- viewmgr_update_view(VIEW_CHANNELINFO,
- UPDATE_TYPE_TIMER, &op);
- }
-
- _load_channel_text(obj, channel_info);
- _set_icon_box(obj, channel_info);
- evas_object_data_set(obj, KEY_SVCID, (void *)channel_info->service_id);
-
- prog_req = calloc(1, sizeof(*prog_req));
- if (!prog_req)
- goto err;
- prog_req->tv_program_cb = _tv_program_cb;
- prog_req->user_data = obj;
-
- r = tv_epg_get_cache_program(channel_info->service_id,
- prog_req);
- if (r < 0)
- free(prog_req);
-
- if (channel_info->service_id == current_service) {
- prog_req = calloc(1, sizeof(*prog_req));
- if (!prog_req)
- goto err;
-
- prog_req->tv_program_cb = _tv_program_cb;
- prog_req->user_data = obj;
- r = tv_epg_get_program(channel_info->service_id, prog_req);
- if (r < 0)
- free(prog_req);
- }
-
-err:
- if (r < 0 && viewmgr_get_view_state(VIEW_CHANNELINFO) ==
- VIEW_STATE_VISIBLE) {
- op = START_HIDE_TIMER;
- viewmgr_update_view(VIEW_CHANNELINFO,
- UPDATE_TYPE_TIMER, &op);
- }
-}
-
-void util_launch_home(void)
-{
- app_control_h app_ctrl;
- int r;
-
- r = app_control_create(&app_ctrl);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to create app control handle");
- return;
- }
-
- r = app_control_set_operation(app_ctrl, APP_CONTROL_OPERATION_DEFAULT);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to set app control operation");
- app_control_destroy(app_ctrl);
- return;
- }
-
- r = app_control_set_app_id(app_ctrl, APP_ID_HOME);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to set app control app id");
- app_control_destroy(app_ctrl);
- return;
- }
-
- r = app_control_send_launch_request(app_ctrl, NULL, NULL);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to send app control launch request");
- app_control_destroy(app_ctrl);
- return;
- }
-
- app_control_destroy(app_ctrl);
-}
-
diff --git a/src/view_action_menu.c b/src/view_action_menu.c
deleted file mode 100644
index 65804e5..0000000
--- a/src/view_action_menu.c
+++ /dev/null
@@ -1,885 +0,0 @@
-/*
- * 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 <Elementary.h>
-#include <viewmgr.h>
-#include <inputmgr.h>
-#include <app_control.h>
-#include <app_debug.h>
-#include <app_define.h>
-#include <app_contents.h>
-
-#include "define.h"
-#include "util.h"
-#include "view.h"
-
-#define BUF_MAX 128
-#define BUTTON_MAX 16
-#define BUTTON_BORDER 1
-#define ITEMS_IN_ROW 4
-#define FAVORITE_PADDING_Y 32
-#define FAVORITE_MAX 10
-#define SCROLLER_STEP_SIZE 334
-
-#define KEY_BUTTON "KEY_BUTTON"
-
-#define STYLE_LIVETV_BTN "style.livetv.button"
-#define STYLE_MORE_BTN "style.more.button"
-#define STYLE_ACTION_MENU_BTN "style.action.menu.button"
-#define STYLE_ACTION_MENU_FAVORITE "style.action.menu.favorite"
-
-#define UNTOGGLE 0
-#define TOGGLE 1
-
-enum _button_id {
- BUTTON_INVALID = -1,
- BUTTON_LIVETV,
- BUTTON_MORE,
- BUTTON_FAV,
- BUTTON_LOCK,
- BUTTON_CHANNEL,
-};
-
-enum _button_state {
- STATE_INVALID = -1,
- STATE_UNTOGGLE,
- STATE_TOGGLE,
- STATE_DISABLED,
-};
-
-struct _priv {
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *scroller;
- Evas_Object *box;
- Evas_Object *menu;
- Evas_Object *channel_info;
- Evas_Object *menu_btn[BUTTON_MAX];
- Evas_Object *favorite;
-};
-
-struct _button_data {
- const char *text;
- const char *normal;
- const char *focused;
- const char *selected;
- const char *disabled;
-};
-
-static void _fav_clicked(void)
-{
- const struct tv_channel_info *channel_info;
- int r;
-
- channel_info = tv_channel_get_info();
- if (!channel_info) {
- _ERR("failed to get channel info");
- return;
- }
-
- r = tv_channel_set_favorite(channel_info->service_id,
- !channel_info->favorite);
- if (r < 0)
- _ERR("failed to set favorite");
- else {
- if (channel_info->favorite)
- viewmgr_update_view(VIEW_ACTION_MENU,
- UPDATE_TYPE_SHOW_TOAST,
- STR_UNFAVORITE_TOAST);
- else
- viewmgr_update_view(VIEW_ACTION_MENU,
- UPDATE_TYPE_SHOW_TOAST,
- STR_FAVORITE_TOAST);
- }
-
- tv_channel_del_info(channel_info);
-
- viewmgr_hide_view(VIEW_ACTION_MENU);
-}
-
-static int _fav_state(void)
-{
- const struct tv_channel_info *channel_info;
- int r;
-
- channel_info = tv_channel_get_info();
- if (!channel_info) {
- _ERR("failed to get channel info");
- return STATE_INVALID;
- }
-
- r = channel_info->favorite ? STATE_TOGGLE : STATE_UNTOGGLE;
-
- tv_channel_del_info(channel_info);
-
- return r;
-}
-
-static void _lock_clicked(void)
-{
- viewmgr_show_view(VIEW_PIN);
-}
-
-static int _lock_state(void)
-{
- return STATE_DISABLED;
-
- /*
- FIXME: Temporal fix until video mute is ready.
-
- const struct tv_channel_info *channel_info;
- int r;
-
- channel_info = tv_channel_get_info();
- if (!channel_info) {
- _ERR("failed to get channel info");
- return STATE_INVALID;
- }
-
- r = channel_info->locked ? STATE_TOGGLE : STATE_UNTOGGLE;
-
- tv_channel_del_info(channel_info);
-
- return r;
- */
-}
-
-static void _channel_clicked(void)
-{
- const struct tv_channel_info *channel_info;
- int r;
-
- channel_info = tv_channel_get_info();
- if (!channel_info) {
- _ERR("failed to get channel info");
- return;
- }
-
- if (channel_info->remembered)
- r = tv_channel_del_channel(channel_info->service_id);
- else
- r = tv_channel_add_channel(channel_info->service_id);
-
- if (r < 0)
- _ERR("failed to set channel");
- else {
- if (channel_info->remembered)
- viewmgr_update_view(VIEW_ACTION_MENU,
- UPDATE_TYPE_SHOW_TOAST,
- STR_REMOVE_CHANNEL_TOAST);
- else
- viewmgr_update_view(VIEW_ACTION_MENU,
- UPDATE_TYPE_SHOW_TOAST,
- STR_ADD_CHANNEL_TOAST);
- }
-
- tv_channel_del_info(channel_info);
-
- viewmgr_hide_view(VIEW_ACTION_MENU);
-}
-
-static int _channel_state(void)
-{
- const struct tv_channel_info *channel_info;
- int r;
-
- channel_info = tv_channel_get_info();
- if (!channel_info) {
- _ERR("failed to get channel info");
- return STATE_INVALID;
- }
-
- r = channel_info->remembered ? STATE_TOGGLE : STATE_UNTOGGLE;
-
- tv_channel_del_info(channel_info);
-
- return r;
-}
-
-struct _button {
- int id;
- const char *style;
- struct _button_data data[2];
-
- void (*clicked)(void);
- int (*state)(void);
-};
-
-static struct _button buttons[] = {
- {
- .id = BUTTON_FAV,
- .style = STYLE_ACTION_MENU_BTN,
- .data[UNTOGGLE] = {
- .text = STR_BUTTON_FAVORITE,
- .normal = IMAGE_UNFAV_NOR,
- .focused = IMAGE_UNFAV_FOC,
- .selected = IMAGE_UNFAV_SEL,
- .disabled = IMAGE_UNFAV_DIS
- },
- .data[TOGGLE] = {
- .text = STR_BUTTON_FAVORITE,
- .normal = IMAGE_FAV_NOR,
- .focused = IMAGE_FAV_FOC,
- .selected = IMAGE_FAV_SEL,
- .disabled = IMAGE_FAV_DIS
- },
- .clicked = _fav_clicked,
- .state = _fav_state
- },
- {
- .id = BUTTON_LOCK,
- .style = STYLE_ACTION_MENU_BTN,
- .data[UNTOGGLE] = {
- .text = STR_BUTTON_LOCK,
- .normal = IMAGE_UNLOCK_NOR,
- .focused = IMAGE_UNLOCK_FOC,
- .selected = IMAGE_UNLOCK_SEL,
- .disabled = IMAGE_UNLOCK_DIS
- },
- .data[TOGGLE] = {
- .text = STR_BUTTON_UNLOCK,
- .normal = IMAGE_LOCK_NOR,
- .focused = IMAGE_LOCK_FOC,
- .selected = IMAGE_LOCK_SEL,
- .disabled = IMAGE_LOCK_DIS
- },
- .clicked = _lock_clicked,
- .state = _lock_state
- },
- {
- .id = BUTTON_CHANNEL,
- .style = STYLE_ACTION_MENU_BTN,
- .data[UNTOGGLE] = {
- .text = STR_BUTTON_ADD_CHANNEL,
- .normal = IMAGE_REMOVE_CH_NOR,
- .focused = IMAGE_REMOVE_CH_FOC,
- .selected = IMAGE_REMOVE_CH_SEL,
- .disabled = IMAGE_REMOVE_CH_DIS
- },
- .data[TOGGLE] = {
- .text = STR_BUTTON_REMOVE_CHANNEL,
- .normal = IMAGE_ADD_CH_NOR,
- .focused = IMAGE_ADD_CH_FOC,
- .selected = IMAGE_ADD_CH_SEL,
- .disabled = IMAGE_ADD_CH_DIS
- },
- .clicked = _channel_clicked,
- .state = _channel_state
- },
- {
- .id = BUTTON_INVALID
- }
-};
-
-static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Down *ev)
-{
- if (!strcmp(ev->keyname, KEY_BACK) ||
- !strcmp(ev->keyname, KEY_ESC))
- viewmgr_hide_view(VIEW_ACTION_MENU);
-
- ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
-}
-
-static input_handler key_handler = {
- .key_down = _key_down_cb,
-};
-
-static void _update_button_state(Evas_Object *obj, struct _button *button)
-{
- int state;
-
- if (!obj || !button->state) {
- _ERR("failed to get button state");
- return;
- }
-
- state = button->state();
-
- switch (state) {
- case STATE_UNTOGGLE:
- elm_object_signal_emit(obj, SIGNAL_UNTOGGLE, SOURCE_ELM);
- break;
- case STATE_TOGGLE:
- elm_object_signal_emit(obj, SIGNAL_TOGGLE, SOURCE_ELM);
- break;
- case STATE_DISABLED:
- elm_object_disabled_set(obj, EINA_TRUE);
- break;
- case STATE_INVALID:
- break;
- }
-}
-
-static void _launch_favorite(void)
-{
- app_control_h app_ctrl;
- int r;
-
- r = app_control_create(&app_ctrl);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to create app control handle");
- return;
- }
-
- r = app_control_set_operation(app_ctrl, APP_CONTROL_OPERATION_DEFAULT);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to set app control operation");
- app_control_destroy(app_ctrl);
- return;
- }
-
- r = app_control_set_app_id(app_ctrl, APP_ID_FAVORITE);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to set app control app id");
- app_control_destroy(app_ctrl);
- return;
- }
-
- r = app_control_send_launch_request(app_ctrl, NULL, NULL);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to send app control launch request");
- app_control_destroy(app_ctrl);
- return;
- }
-
- app_control_destroy(app_ctrl);
-}
-
-static void _button_clicked(Evas_Object *obj, int id, void *data)
-{
- struct _button *button;
-
- switch (id) {
- case BUTTON_MORE:
- _launch_favorite();
-
- viewmgr_hide_view(VIEW_ACTION_MENU);
- break;
- case BUTTON_FAV:
- case BUTTON_LOCK:
- case BUTTON_CHANNEL:
- button = evas_object_data_get(obj, KEY_BUTTON);
- if (!button) {
- _ERR("failed to get button");
- return;
- }
-
- if (button->clicked)
- button->clicked();
-
- _update_button_state(obj, button);
-
- break;
- }
-}
-
-static void _button_key_up_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Up *ev)
-{
- if (!strcmp(ev->keyname, KEY_ENTER))
- _button_clicked(obj, id, data);
-}
-
-static void _button_mouse_up_cb(int id, void *data, Evas *e,
- Evas_Object *obj, Evas_Event_Mouse_Up *ev)
-{
- _button_clicked(obj, id, data);
-}
-
-static void _button_mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Mouse_Move *ev)
-{
- if (!obj)
- return;
-
- if (!elm_object_focus_get(obj))
- elm_object_focus_set(obj, EINA_TRUE);
-}
-
-static input_handler button_handler = {
- .key_up = _button_key_up_cb,
- .mouse_up = _button_mouse_up_cb,
- .mouse_move = _button_mouse_move_cb,
-};
-
-static void _favorite_clicked_cb(int id, void *data, Evas_Object *obj)
-{
- if (id > 0)
- tv_channel_tune_with_service_id(id);
-
- viewmgr_hide_view(VIEW_ACTION_MENU);
-}
-
-static input_handler favorite_handler = {
- .clicked = _favorite_clicked_cb,
-};
-
-static void _update_channel_info(struct _priv *priv)
-{
- const struct tv_channel_info *channel_info;
-
- channel_info = tv_channel_get_info();
- if (!channel_info) {
- _ERR("failed to get channel info");
- return;
- }
-
- util_draw_channel_info(priv->channel_info, channel_info);
-
- tv_channel_del_info(channel_info);
-}
-
-static void _add_favorite_bg(Evas_Object *btn, char *str)
-{
- Evas_Object *bg;
- struct color_data bright, dark;
-
- app_contents_get_color(str, &bright, &dark);
- bg = evas_object_rectangle_add(btn);
- if (!bg) {
- _ERR("failed to add content bg");
- return;
- }
- evas_object_color_set(bg, bright.r, bright.g,
- bright.b, bright.a);
- elm_object_part_content_set(btn, PART_CONTENT_BG, bg);
-
- bg = evas_object_rectangle_add(btn);
- if (!bg) {
- _ERR("failed to add text bg");
- return;
- }
- evas_object_color_set(bg, dark.r, dark.g,
- dark.b, dark.a);
- elm_object_part_content_set(btn, PART_TEXT_BG, bg);
-}
-
-static void _update_favorite(struct _priv *priv)
-{
- Eina_List *channel_list, *l;
- const struct tv_channel_info *channel_info;
- Evas_Object *btn, *no_favorite;
- char buf[BUF_MAX];
- int i;
-
- channel_list = tv_channel_get_favorite_list();
-
- elm_box_clear(priv->favorite);
-
- if (!channel_list) {
- no_favorite = util_add_layout(priv->favorite,
- GRP_ACTION_MENU_NO_FAVORITE);
- if (!no_favorite) {
- _ERR("failed to create no favorite layout");
- return;
- }
-
- elm_box_pack_end(priv->favorite, no_favorite);
-
- return;
- }
-
- i = 0;
- EINA_LIST_FOREACH(channel_list, l, channel_info) {
- if (channel_info->channel_minor > 0 &&
- channel_info->channel_minor < MINOR_MAX)
- snprintf(buf, sizeof(buf), "%lu-%lu %s",
- channel_info->channel_major,
- channel_info->channel_minor,
- channel_info->channel_name);
- else
- snprintf(buf, sizeof(buf), "%lu %s",
- channel_info->channel_major,
- channel_info->channel_name);
- btn = util_add_button(priv->menu, NULL, buf,
- STYLE_ACTION_MENU_FAVORITE);
- if (!btn) {
- _ERR("failed to create favorite item");
- continue;
- }
-
- util_add_icon(btn, IMAGE_FAVORITE_DEFAULT, PART_CONTENT);
- _add_favorite_bg(btn, buf);
-
- inputmgr_add_callback(btn, channel_info->service_id,
- &favorite_handler, NULL);
-
- elm_box_pack_end(priv->favorite, btn);
-
- if (++i == FAVORITE_MAX)
- break;
- }
-
- tv_channel_del_list(channel_list);
-}
-
-static void _update_menu(struct _priv *priv)
-{
- int i;
-
- i = 0;
- while (i < BUTTON_MAX && buttons[i].id != BUTTON_INVALID) {
- _update_button_state(priv->menu_btn[i], &buttons[i]);
- i++;
- }
-}
-
-static bool _draw_channel_info(struct _priv *priv)
-{
- Evas_Object *layout;
-
- layout = util_add_layout(priv->base, GRP_CHANNELINFO);
- if (!layout) {
- _ERR("failed to create channel info layout");
- return false;
- }
-
- elm_object_part_content_set(priv->base, PART_CHANNELINFO, layout);
-
- priv->channel_info = layout;
-
- return true;
-}
-
-static bool _draw_action_area(struct _priv *priv)
-{
- Evas_Object *table, *btn;
- int i, row, col;
-
- table = elm_table_add(priv->menu);
- if (!table) {
- _ERR("failed to create action table");
- return false;
- }
- elm_table_padding_set(table,
- ELM_SCALE_SIZE(BUTTON_BORDER),
- ELM_SCALE_SIZE(BUTTON_BORDER));
- evas_object_show(table);
- elm_object_part_content_set(priv->menu, PART_MENU, table);
-
- i = 0;
- while (i < BUTTON_MAX && buttons[i].id != BUTTON_INVALID) {
- btn = util_add_button(priv->menu, NULL,
- buttons[i].data[UNTOGGLE].text,
- buttons[i].style);
- if (!btn) {
- _ERR("failed to create action button");
- evas_object_del(table);
- return false;
- }
-
- util_add_icon(btn, buttons[i].data[UNTOGGLE].normal,
- PART_ICON);
- util_add_icon(btn, buttons[i].data[UNTOGGLE].focused,
- PART_ICON_FOCUSED);
- util_add_icon(btn, buttons[i].data[UNTOGGLE].selected,
- PART_ICON_SELECTED);
- util_add_icon(btn, buttons[i].data[UNTOGGLE].disabled,
- PART_ICON_DISABLED);
- elm_object_part_text_set(btn, PART_TEXT_1,
- buttons[i].data[TOGGLE].text);
- util_add_icon(btn, buttons[i].data[TOGGLE].normal,
- PART_ICON_1);
- util_add_icon(btn, buttons[i].data[TOGGLE].focused,
- PART_ICON_1_FOCUSED);
- util_add_icon(btn, buttons[i].data[TOGGLE].selected,
- PART_ICON_1_SELECTED);
- util_add_icon(btn, buttons[i].data[TOGGLE].disabled,
- PART_ICON_1_DISABLED);
- evas_object_data_set(btn, KEY_BUTTON, &buttons[i]);
- inputmgr_add_callback(btn, buttons[i].id,
- &button_handler, priv);
-
- col = i % ITEMS_IN_ROW;
- row = i / ITEMS_IN_ROW;
- elm_table_pack(table, btn, col, row, 1, 1);
-
- priv->menu_btn[i] = btn;
-
- i++;
- }
-
- while (col + 1 != ITEMS_IN_ROW) {
- btn = util_add_button(priv->menu, NULL, NULL,
- STYLE_ACTION_MENU_BTN);
- if (!btn) {
- _ERR("failed to create action button");
- evas_object_del(table);
- return false;
- }
-
- elm_object_disabled_set(btn, EINA_TRUE);
-
- col = i % ITEMS_IN_ROW;
-
- elm_table_pack(table, btn, col, row, 1, 1);
-
- i++;
- }
-
- return true;
-}
-
-static bool _draw_top_area(struct _priv *priv)
-{
- Evas_Object *layout, *btn;
-
- layout = util_add_layout(priv->box, GRP_ACTION_MENU_TOP);
- if (!layout) {
- _ERR("failed to create menu layout");
- return false;
- }
- elm_box_pack_end(priv->box, layout);
-
- btn = util_add_button(layout,
- PART_TOP_BUTTON, STR_LIVETV, STYLE_LIVETV_BTN);
- if (!btn) {
- _ERR("failed to create live button");
- return false;
- }
-
- elm_object_disabled_set(btn, EINA_TRUE);
-
- priv->menu = layout;
-
- return _draw_action_area(priv);
-}
-
-static bool _draw_favorite_area(struct _priv *priv)
-{
- Evas_Object *box;
-
- box = elm_box_add(priv->box);
- if (!box) {
- _ERR("failed to create favorite box");
- return false;
- }
- elm_box_padding_set(box, 0, ELM_SCALE_SIZE(FAVORITE_PADDING_Y));
- evas_object_show(box);
- elm_box_pack_end(priv->box, box);
-
- priv->favorite = box;
-
- return true;
-}
-
-static bool _draw_bottom_area(struct _priv *priv)
-{
- Evas_Object *layout, *btn;
-
- layout = util_add_layout(priv->box, GRP_ACTION_MENU_BOTTOM);
- if (!layout) {
- _ERR("failed to create menu layout");
- return false;
- }
- elm_box_pack_end(priv->box, layout);
-
- btn = util_add_button(layout,
- PART_MORE_BUTTON, STR_BUTTON_MORE, STYLE_MORE_BTN);
- if (!btn) {
- _ERR("failed to create more button");
- return false;
- }
- inputmgr_add_callback(btn, BUTTON_MORE,
- &button_handler, priv);
-
- return true;
-}
-
-static void _draw_view_content(struct _priv *priv)
-{
- if (!_draw_channel_info(priv)) {
- _ERR("failed to draw channel info");
- return;
- }
-
- if (!_draw_top_area(priv)) {
- _ERR("failed to draw top");
- return;
- }
-
- if (!_draw_favorite_area(priv)) {
- _ERR("failed to draw favorite");
- return;
- }
-
- if (!_draw_bottom_area(priv))
- _ERR("failed to draw bottom");
-}
-
-static void _hide_finished_cb(void *data, Evas_Object *obj,
- const char *emission, const char *source)
-{
- struct _priv *priv;
-
- if (!data)
- return;
-
- priv = data;
-
- evas_object_hide(priv->base);
-}
-
-static Evas_Object *_create(Evas_Object *win, void *data)
-{
- struct _priv *priv;
- Evas_Object *base, *scroller, *box;
-
- if (!win) {
- _ERR("failed to get win object");
- return NULL;
- }
-
- priv = calloc(1, sizeof(*priv));
- if (!priv) {
- _ERR("failed to allocate priv");
- return NULL;
- }
-
- base = elm_layout_add(win);
- if (!base) {
- _ERR("failed to create base object");
- free(priv);
- return NULL;
- }
- elm_layout_file_set(base, EDJEFILE, GRP_VIEW_ACTION_MENU);
- evas_object_size_hint_weight_set(base,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, base);
-
- scroller = util_add_scroller(base, NULL);
- elm_scroller_step_size_set(scroller,
- 0, ELM_SCALE_SIZE(SCROLLER_STEP_SIZE));
-
- box = util_add_box(scroller, NULL);
- elm_box_align_set(box, 0.5, 0.0);
-
- priv->box = box;
- priv->scroller = scroller;
- priv->base = base;
- priv->win = win;
-
- _draw_view_content(priv);
-
- viewmgr_set_view_data(VIEW_ACTION_MENU, priv);
- inputmgr_add_callback(priv->base, 0, &key_handler, priv);
- elm_layout_signal_callback_add(priv->base, SIGNAL_HIDE_FINISHED,
- SOURCE_ELM, _hide_finished_cb, priv);
-
- return base;
-}
-
-static void _show(void *data)
-{
- struct _priv *priv;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
- priv = data;
-
- _update_channel_info(priv);
- _update_menu(priv);
- _update_favorite(priv);
-
- elm_scroller_region_show(priv->scroller, 0, 0, 0, 0);
-
- evas_object_show(priv->base);
-
- elm_object_focus_set(priv->menu_btn[0], EINA_TRUE);
-}
-
-static void _hide(void *data)
-{
- struct _priv *priv;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
- priv = data;
-
- elm_layout_signal_emit(priv->base, SIGNAL_HIDE, SOURCE_ELM);
-}
-
-static void _destroy(void *data)
-{
- struct _priv *priv;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
- priv = data;
-
- elm_layout_signal_callback_del(priv->base, SIGNAL_HIDE_FINISHED,
- SOURCE_ELM, _hide_finished_cb);
-
- evas_object_del(priv->base);
-
- free(priv);
-}
-
-static void _update(void *view_data, int type, void *data)
-{
- struct _priv *priv;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- switch (type) {
- case UPDATE_TYPE_INPUT_KEY_DOWN:
- {
- Evas_Event_Key_Down *ev = data;
-
- if (!ev) {
- _ERR("failed to get ev");
- return;
- }
-
- viewmgr_show_view(VIEW_ACTION_MENU);
- break;
- }
- case UPDATE_TYPE_SHOW_TOAST:
- if (!data) {
- _ERR("failed to get data");
- return;
- }
-
- util_add_toast(priv->win, data);
- break;
- }
-}
-
-static view_class _vclass = {
- .view_id = VIEW_ACTION_MENU,
- .create = _create,
- .show = _show,
- .hide = _hide,
- .destroy = _destroy,
- .update = _update
-};
-
-view_class *view_action_menu_get_vclass(void)
-{
- return &_vclass;
-}
diff --git a/src/view_error.c b/src/view_bgimage.c
index 2983c25..b4cc1f3 100644..100755
--- a/src/view_error.c
+++ b/src/view_bgimage.c
@@ -46,13 +46,13 @@ static Evas_Object *_create(Evas_Object *win, void *data)
free(priv);
return NULL;
}
- elm_layout_file_set(priv->base, EDJEFILE, GRP_VIEW_ERROR);
+ elm_layout_file_set(priv->base, EDJEFILE, GRP_VIEW_BGIMAGE);
evas_object_size_hint_weight_set(priv->base,
EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, priv->base);
- viewmgr_set_view_data(VIEW_ERROR, priv);
+ viewmgr_set_view_data(VIEW_BGIMAGE, priv);
return priv->base;
}
@@ -67,7 +67,6 @@ static void _show(void *view_data)
}
priv = view_data;
-
evas_object_show(priv->base);
}
@@ -101,40 +100,15 @@ static void _destroy(void *view_data)
free(priv);
}
-static void _update(void *view_data, int type, void *data)
-{
- struct _priv *priv;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- if (type == UPDATE_TYPE_NOCHANNEL) {
- elm_object_part_text_set(priv->base,
- PART_ERROR_TITLE, STR_NOCHANNEL_TITLE);
- elm_object_part_text_set(priv->base,
- PART_ERROR_TEXT, STR_NOCHANNEL_TEXT);
- } else if (type == UPDATE_TYPE_NOSIGNAL) {
- elm_object_part_text_set(priv->base,
- PART_ERROR_TITLE, STR_NOSIGNAL_TITLE);
- elm_object_part_text_set(priv->base,
- PART_ERROR_TEXT, STR_NOSIGNAL_TEXT);
- }
-}
-
static view_class vclass = {
- .view_id = VIEW_ERROR,
+ .view_id = VIEW_BGIMAGE,
.create = _create,
.show = _show,
.hide = _hide,
.destroy = _destroy,
- .update = _update,
};
-view_class *view_error_get_vclass(void)
+view_class *view_bgimage_get_vclass(void)
{
return &vclass;
}
diff --git a/src/view_channelinfo.c b/src/view_channelinfo.c
deleted file mode 100644
index 66af50e..0000000
--- a/src/view_channelinfo.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * 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 <Elementary.h>
-#include <viewmgr.h>
-#include <layoutmgr.h>
-#include <inputmgr.h>
-#include <app_debug.h>
-
-#include "define.h"
-#include "tv.h"
-#include "view.h"
-#include "layout_channelinfo.h"
-#include "layout_channelinfo_list.h"
-#include "layout_channelinfo_search.h"
-
-#define HIDE_DUR 10.0
-
-struct _priv {
- Evas_Object *base;
- Ecore_Timer *hide_timer;
- const char *current_layout;
-
- layoutmgr *lmgr;
-};
-
-static void _hide_current_layout(struct _priv *priv)
-{
- if (!priv->current_layout)
- return;
-
- layoutmgr_hide_layout(priv->lmgr, priv->current_layout);
- priv->current_layout = NULL;
-}
-
-static void _set_current_layout(struct _priv *priv, const char *layout_id)
-{
- if (!layout_id)
- return;
-
- if (priv->current_layout && strcmp(priv->current_layout, layout_id))
- layoutmgr_hide_layout(priv->lmgr, priv->current_layout);
-
- layoutmgr_show_layout(priv->lmgr, layout_id);
- priv->current_layout = layout_id;
-}
-
-static Eina_Bool _hide_timer(void *data)
-{
- struct _priv *priv;
-
- if (!data)
- return ECORE_CALLBACK_CANCEL;
-
- priv = data;
-
- priv->hide_timer = NULL;
-
- viewmgr_hide_view(VIEW_CHANNELINFO);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static void _start_hide_timer(struct _priv *priv)
-{
- if (priv->hide_timer)
- ecore_timer_reset(priv->hide_timer);
- else
- priv->hide_timer = ecore_timer_add(HIDE_DUR, _hide_timer, priv);
-}
-
-static void _stop_hide_timer(struct _priv *priv)
-{
- if (priv->hide_timer) {
- ecore_timer_del(priv->hide_timer);
- priv->hide_timer = NULL;
- }
-}
-
-static Evas_Object *_create(Evas_Object *win, void *data)
-{
- struct _priv *priv;
-
- if (!win) {
- _ERR("failed to get win object");
- return NULL;
- }
-
- priv = calloc(1, sizeof(*priv));
- if (!priv) {
- _ERR("failed to allocate priv");
- return NULL;
- }
-
- priv->lmgr = layoutmgr_create(win);
- layoutmgr_add_layout(priv->lmgr, layout_channelinfo_get_lclass(), NULL);
- layoutmgr_add_layout(priv->lmgr,
- layout_channelinfo_list_get_lclass(), NULL);
- layoutmgr_add_layout(priv->lmgr,
- layout_channelinfo_search_get_lclass(), NULL);
-
- viewmgr_set_view_data(VIEW_CHANNELINFO, priv);
-
- return win;
-}
-
-static void _show(void *view_data)
-{
- struct _priv *priv;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- if (!priv->current_layout)
- _set_current_layout(priv, LAYOUT_CHANNELINFO);
-}
-
-static void _hide(void *view_data)
-{
- struct _priv *priv;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- _hide_current_layout(priv);
-}
-
-static void _destroy(void *view_data)
-{
- struct _priv *priv;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO);
- layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO_LIST);
- layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO_SEARCH);
- layoutmgr_destroy(priv->lmgr);
-
- free(priv);
-}
-
-static void _update(void *view_data, int type, void *data)
-{
- struct _priv *priv;
- int r;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- if (type == UPDATE_TYPE_TIMER) {
- switch (*(int *) data) {
- case START_HIDE_TIMER:
- _start_hide_timer(priv);
- break;
- case STOP_HIDE_TIMER:
- _stop_hide_timer(priv);
- break;
- }
- } else if (type == UPDATE_TYPE_INPUT_KEY_DOWN) {
- Evas_Event_Key_Down *ev = data;
-
- if (!ev) {
- _ERR("failed to get ev");
- return;
- }
-
- if (!strcmp(ev->keyname, KEY_ENTER)) {
- if (!priv->current_layout)
- _set_current_layout(priv, LAYOUT_CHANNELINFO);
- else
- _set_current_layout(priv,
- LAYOUT_CHANNELINFO_SEARCH);
- } else if (!strcmp(ev->keyname, KEY_CHANNELUP) ||
- !strcmp(ev->keyname, KEY_CHANNELDOWN)) {
- if (priv->current_layout &&
- !strcmp(priv->current_layout,
- LAYOUT_CHANNELINFO_SEARCH))
- return;
-
- _set_current_layout(priv, LAYOUT_CHANNELINFO_LIST);
- layoutmgr_update_layout(priv->lmgr,
- LAYOUT_CHANNELINFO_LIST, type, ev);
- } else if (!strcmp(ev->keyname, KEY_PREVIOUS)) {
- r = tv_channel_tune_prev_channel();
- if (r < 0)
- _ERR("failed to tune prev channel");
-
- _set_current_layout(priv, LAYOUT_CHANNELINFO);
- }
-
- viewmgr_show_view(VIEW_CHANNELINFO);
- }
-}
-
-static view_class vclass = {
- .view_id = VIEW_CHANNELINFO,
- .create = _create,
- .show = _show,
- .hide = _hide,
- .destroy = _destroy,
- .update = _update
-};
-
-view_class *view_channelinfo_get_vclass(void)
-{
- return &vclass;
-}
diff --git a/src/view_channelnumber.c b/src/view_channelnumber.c
deleted file mode 100644
index 9e395ac..0000000
--- a/src/view_channelnumber.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * 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 <Elementary.h>
-#include <viewmgr.h>
-#include <inputmgr.h>
-#include <app_debug.h>
-
-#include "define.h"
-#include "util.h"
-#include "tv.h"
-#include "view.h"
-
-#define HIDE_DUR 3.0
-#define BUF_MAX 128
-#define INPUT_MAX 4
-#define NUMBER_MAX 2
-
-struct _priv {
- Evas_Object *base;
- Evas_Object *list;
- Ecore_Timer *hide_timer;
-
- int major;
- int minor;
- char number[INPUT_MAX+1];
-};
-
-static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Down *ev)
-{
- if (!strcmp(ev->keyname, KEY_BACK) ||
- !strcmp(ev->keyname, KEY_ESC))
- viewmgr_hide_view(VIEW_CHANNELNUMBER);
-}
-
-static input_handler key_handler = {
- .key_down = _key_down_cb,
-};
-
-static void _stop_hide_timer(struct _priv *priv)
-{
- if (priv->hide_timer) {
- ecore_timer_del(priv->hide_timer);
- priv->hide_timer = NULL;
- }
-}
-
-static Eina_Bool _done_input(void *data)
-{
- struct _priv *priv;
- int r;
-
- if (!data)
- return ECORE_CALLBACK_CANCEL;
-
- priv = data;
-
- r = tv_channel_direct_tune(priv->major, priv->minor);
- if (r < 0)
- _ERR("invalid channel");
-
- viewmgr_hide_view(VIEW_CHANNELNUMBER);
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-static void _start_hide_timer(struct _priv *priv)
-{
- if (priv->hide_timer)
- ecore_timer_reset(priv->hide_timer);
- else
- priv->hide_timer = ecore_timer_add(HIDE_DUR, _done_input, priv);
-}
-
-static void _tune_channel(void *data)
-{
- int service_id;
- int r;
-
- if (!data) {
- _ERR("failed to get data");
- return;
- }
-
- service_id = (int) data;
- if (service_id < 0) {
- _ERR("failed to get service id");
- return;
- }
-
- r = tv_channel_tune_with_service_id(service_id);
- if (r < 0)
- _ERR("failed to tune with service id");
-
- viewmgr_hide_view(VIEW_CHANNELNUMBER);
-}
-
-static void _channel_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Down *ev)
-{
- if (!strcmp(ev->keyname, KEY_ENTER)) {
- ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
-
- _tune_channel(data);
- }
-}
-
-static void _channel_mouse_down_cb(int id, void *data, Evas *e,
- Evas_Object *obj, Evas_Event_Mouse_Down *ev)
-{
- _tune_channel(data);
-}
-
-static void _channel_focused_cb(int id, void *data,
- Evas_Object *obj, Elm_Object_Item *it)
-{
- viewmgr_update_view(VIEW_CHANNELNUMBER,
- UPDATE_TYPE_TIMER, 0);
-}
-
-static input_handler channel_handler = {
- .key_down = _channel_key_down_cb,
- .mouse_down = _channel_mouse_down_cb,
- .focused = _channel_focused_cb,
-};
-
-static void _update_channel_list(struct _priv *priv)
-{
- Evas_Object *ly, *first;
- Eina_List *channel_list, *l;
- const struct tv_channel_info *channel_info;
- char buf[BUF_MAX];
-
- channel_list = tv_channel_search_by_number(priv->major, priv->minor);
-
- elm_box_clear(priv->list);
-
- if (!channel_list) {
- evas_object_hide(priv->list);
- return;
- }
-
- evas_object_show(priv->list);
-
- first = NULL;
- ly = NULL;
- EINA_LIST_FOREACH(channel_list, l, channel_info) {
- ly = util_add_layout(priv->list, GRP_CHANNELNUMBER_LIST_ITEM);
- if (!ly) {
- _ERR("failed to create layout");
- return;
- }
-
- elm_object_focus_allow_set(ly, EINA_TRUE);
-
- if (channel_info->channel_minor > 0 &&
- channel_info->channel_minor < MINOR_MAX)
- snprintf(buf, sizeof(buf), "%lu-%lu %s",
- channel_info->channel_major,
- channel_info->channel_minor,
- channel_info->channel_name);
- else
- snprintf(buf, sizeof(buf), "%lu %s",
- channel_info->channel_major,
- channel_info->channel_name);
-
- elm_object_text_set(ly, buf);
-
- inputmgr_add_callback(ly, 0, &channel_handler,
- (void *) channel_info->service_id);
-
- elm_box_pack_end(priv->list, ly);
-
- if (!first) {
- first = ly;
- elm_object_focus_set(ly, EINA_TRUE);
- elm_object_signal_emit(ly, SIGNAL_FIRST, "");
- }
- }
-
- if (first && ly) {
- elm_object_focus_next_object_set(first, ly, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(ly, first, ELM_FOCUS_DOWN);
- elm_object_signal_emit(ly, SIGNAL_LAST, "");
- }
-
- if (channel_list)
- tv_channel_del_list(channel_list);
-}
-
-static void _update_number_info(struct _priv *priv)
-{
- char buf[BUF_MAX] = "\0";
-
- if (strlen(priv->number) > NUMBER_MAX) {
- strncpy(buf, priv->number, NUMBER_MAX);
- strncat(buf, "-", 1);
- strncat(buf, priv->number + NUMBER_MAX, NUMBER_MAX);
- elm_object_part_text_set(priv->base,
- PART_CHANNELNUMBER_NUMBER, buf);
- } else {
- elm_object_part_text_set(priv->base,
- PART_CHANNELNUMBER_NUMBER, priv->number);
- }
-
- _update_channel_list(priv);
-}
-
-static int _get_number(const char *keyname)
-{
- static const char * const keys[] = {
- KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
- KEY_5, KEY_6, KEY_7, KEY_8, KEY_9
- };
-
- int i;
-
- if (!keyname) {
- _ERR("failed to get keyname");
- return -1;
- }
-
- for (i = 0; i < sizeof(keys) / sizeof(*keys); i++) {
- if (!strcmp(keyname, keys[i]))
- return i;
- }
-
- return -1;
-}
-
-static void _number_reset(struct _priv *priv)
-{
- memset(priv->number, '\0', sizeof(char) * INPUT_MAX + 1);
- priv->major = 0;
- priv->minor = 0;
-
- elm_box_clear(priv->list);
-}
-
-static void _number_tuning(struct _priv *priv, const char *keyname)
-{
- char buf[BUF_MAX] = "\0";
-
- if (!keyname) {
- _ERR("failed to get keyname");
- return;
- }
-
- strncat(priv->number, keyname, 1);
- strncpy(buf, priv->number, INPUT_MAX);
-
- priv->minor = atoi(buf + NUMBER_MAX);
- buf[NUMBER_MAX] = '\0';
- priv->major = atoi(buf);
-
- _update_number_info(priv);
-
- if (strlen(priv->number) >= INPUT_MAX)
- _done_input(priv);
-}
-
-static Evas_Object *_create(Evas_Object *win, void *data)
-{
- struct _priv *priv;
- Evas_Object *scroll = NULL;
-
- if (!win) {
- _ERR("failed to get win object");
- return NULL;
- }
-
- priv = calloc(1, sizeof(*priv));
- if (!priv) {
- _ERR("failed to allocate priv");
- return NULL;
- }
-
- priv->base = elm_layout_add(win);
- if (!priv->base) {
- _ERR("failed to create base object");
- goto error;
- }
- elm_layout_file_set(priv->base, EDJEFILE, GRP_VIEW_CHANNELNUMBER);
-
- evas_object_size_hint_weight_set(priv->base,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, priv->base);
- elm_object_focus_allow_set(priv->base, EINA_TRUE);
-
- scroll = util_add_scroller(priv->base, PART_CHANNELNUMBER_LIST);
- if (!scroll) {
- _ERR("failed to create scroll");
- goto error;
- }
-
- priv->list = util_add_box(scroll, false);
- if (!priv->list) {
- _ERR("failed to create box");
- goto error;
- }
- elm_box_align_set(priv->list, 0.5, 0.0);
-
- viewmgr_set_view_data(VIEW_CHANNELNUMBER, priv);
-
- inputmgr_add_callback(priv->base, 0, &key_handler, priv);
-
- return priv->base;
-
-error:
- _ERR("failed to create view");
-
- if (priv->list)
- evas_object_del(priv->list);
- if (scroll)
- evas_object_del(scroll);
- if (priv->base)
- evas_object_del(priv->base);
-
- free(priv);
-
- return NULL;
-}
-
-static void _show(void *view_data)
-{
- struct _priv *priv;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- _start_hide_timer(priv);
-
- evas_object_show(priv->base);
-
- viewmgr_hide_view(VIEW_CHANNELINFO);
- elm_object_focus_set(priv->base, EINA_TRUE);
-}
-
-static void _hide(void *view_data)
-{
- struct _priv *priv;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- _stop_hide_timer(priv);
- _number_reset(priv);
-
- evas_object_hide(priv->base);
-}
-
-static void _destroy(void *view_data)
-{
- struct _priv *priv;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- evas_object_del(priv->base);
-
- free(priv);
-}
-
-static void _update(void *view_data, int type, void *data)
-{
- struct _priv *priv;
-
- if (!view_data) {
- _ERR("failed to get view data");
- return;
- }
-
- priv = view_data;
-
- if (type == UPDATE_TYPE_TIMER) {
- _start_hide_timer(priv);
- } else if (type == UPDATE_TYPE_INPUT_KEY_DOWN) {
- Evas_Event_Key_Down *ev = data;
-
- if (!ev) {
- _ERR("failed to get ev");
- return;
- }
-
- viewmgr_show_view(VIEW_CHANNELNUMBER);
-
- if (_get_number(ev->keyname) != -1)
- _number_tuning(priv, ev->keyname);
- } else if (type == UPDATE_TYPE_INPUT_KEY_UP) {
- Evas_Event_Key_Up *ev = data;
-
- if (!ev) {
- _ERR("failed to get ev");
- return;
- }
- }
-}
-
-static view_class vclass = {
- .view_id = VIEW_CHANNELNUMBER,
- .create = _create,
- .show = _show,
- .hide = _hide,
- .destroy = _destroy,
- .update = _update
-};
-
-view_class *view_channelnumber_get_vclass(void)
-{
- return &vclass;
-}
diff --git a/src/view_pin.c b/src/view_pin.c
deleted file mode 100644
index aa65d5e..0000000
--- a/src/view_pin.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * 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 <Elementary.h>
-#include <ui-gadget.h>
-#include <app_debug.h>
-#include <viewmgr.h>
-#include <inputmgr.h>
-#include <app_define.h>
-
-#include "define.h"
-#include "view.h"
-#include "tv.h"
-
-struct _priv {
- Evas_Object *win;
- ui_gadget_h ug;
-};
-
-static void _send_message(struct _priv *priv, const char *result)
-{
- app_control_h app_control;
- int r;
-
- r = app_control_create(&app_control);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to create app_control");
- return;
- }
-
- r = app_control_add_extra_data(app_control, PARAM_PIN, result);
- if (r != APP_CONTROL_ERROR_NONE) {
- _ERR("failed to add data");
- app_control_destroy(app_control);
- return;
- }
-
- ug_send_message(priv->ug, app_control);
-
- app_control_destroy(app_control);
-}
-
-static void _check_pincode(struct _priv *priv, char *pincode)
-{
- const struct tv_channel_info *channel_info;
- int r;
-
- channel_info = tv_channel_get_info();
- if (!channel_info) {
- _ERR("failed to get channel info");
- return;
- }
-
- if (channel_info->locked)
- r = tv_channel_unlock_channel(channel_info->service_id,
- pincode);
- else
- r = tv_channel_lock_channel(channel_info->service_id, pincode);
-
- if (r < 0) {
- _send_message(priv, MESSAGE_FAIL);
- } else {
- if (channel_info->locked)
- viewmgr_update_view(VIEW_ACTION_MENU,
- UPDATE_TYPE_SHOW_TOAST,
- STR_UNLOCK_TOAST);
- else
- viewmgr_update_view(VIEW_ACTION_MENU,
- UPDATE_TYPE_SHOW_TOAST,
- STR_LOCK_TOAST);
-
- viewmgr_hide_view(VIEW_PIN);
- viewmgr_hide_view(VIEW_ACTION_MENU);
- }
-
- tv_channel_del_info(channel_info);
-}
-
-static void _ug_result_cb(ui_gadget_h ug, app_control_h result, void *p)
-{
- char *pincode;
- int r;
-
- if (!p) {
- _ERR("Invalid argument");
- return;
- }
-
- r = app_control_get_extra_data(result, PARAM_PIN, &pincode);
- if (r != APP_CONTROL_ERROR_NONE || !pincode) {
- _ERR("failed to get data");
- return;
- }
-
- _check_pincode(p, pincode);
-
- free(pincode);
-}
-
-static void _ug_destroy_cb(ui_gadget_h ug, void *p)
-{
- viewmgr_hide_view(VIEW_PIN);
-}
-
-static ui_gadget_h _load_ug(struct _priv *priv)
-{
- ui_gadget_h ug;
- struct ug_cbs cb = {0,};
-
- cb.result_cb = _ug_result_cb;
- cb.destroy_cb = _ug_destroy_cb;
- cb.priv = priv;
-
- ug = ug_create(NULL, UG_ID_PIN, UG_MODE_FRAMEVIEW, NULL, &cb);
-
- return ug;
-}
-
-static Evas_Object *_create(Evas_Object *win, void *data)
-{
- struct _priv *priv;
-
- if (!win) {
- _ERR("Invalid argument");
- return NULL;
- }
-
- priv = calloc(1, sizeof(*priv));
- if (!priv) {
- _ERR("failed to calloc priv");
- return NULL;
- }
-
- priv->win = win;
-
- viewmgr_set_view_data(VIEW_PIN, priv);
-
- return win;
-}
-
-static void _show(void *data)
-{
- struct _priv *priv;
- ui_gadget_h ug;
-
- if (!data) {
- _ERR("Invalid argument");
- return;
- }
-
- priv = data;
-
- ug = _load_ug(priv);
- if (!ug) {
- _ERR("failed to create ug");
- return;
- }
-
- priv->ug = ug;
-}
-
-static void _hide(void *data)
-{
- struct _priv *priv;
-
- if (!data) {
- _ERR("Invalid argument");
- return;
- }
-
- priv = data;
-
- if (priv->ug)
- ug_destroy(priv->ug);
-}
-
-static void _destroy(void *data)
-{
- struct _priv *priv;
-
- if (!data) {
- _ERR("Invalid argument");
- return;
- }
-
- priv = data;
-
- free(priv);
-}
-
-static view_class vclass = {
- .view_id = VIEW_PIN,
- .create = _create,
- .show = _show,
- .hide = _hide,
- .destroy = _destroy
-};
-
-view_class *view_pin_get_vclass(void)
-{
- return &vclass;
-}