summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rwxr-xr-x[-rw-r--r--]src/main.c315
1 files changed, 3 insertions, 312 deletions
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));