diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | data/view/channelinfo.edc | 218 | ||||
-rw-r--r-- | include/define.h | 4 | ||||
-rw-r--r-- | include/view.h | 1 | ||||
-rw-r--r-- | packaging/org.tizen.live-tv.spec | 1 | ||||
-rw-r--r-- | src/main.c | 15 | ||||
-rw-r--r-- | src/view_action_menu.c | 22 | ||||
-rw-r--r-- | src/view_pin.c | 215 |
8 files changed, 371 insertions, 109 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 729813b..6c9f097 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ SET(SRCS src/main.c src/view_channelnumber.c src/view_error.c src/view_action_menu.c + src/view_pin.c src/util.c) SET(TARGET_EDJ "${PROJECT_NAME}.edj") @@ -70,7 +71,8 @@ pkg_check_modules(PKGS REQUIRED vconf gobject-2.0 tv-service - tzsh-tvsrv) + tzsh-tvsrv + ui-gadget-1) FOREACH(flag ${PKGS_CFLAGS}) SET(EXTRA_CFLGAS "${EXTRA_CFLGAS} ${flag}") diff --git a/data/view/channelinfo.edc b/data/view/channelinfo.edc index 2c4b716..0ebf575 100644 --- a/data/view/channelinfo.edc +++ b/data/view/channelinfo.edc @@ -449,114 +449,120 @@ group { align, 1.0 0.0; fixed, 1 1; } + } - part { - name, PART_CHANNELINFO_LOCKED; - type, IMAGE; - scale, 1; - description { - state, "default" 0.0; - image.normal, "ic_thumbnail_lock_01_nor.png"; - rel1.relative, 1.0 0.0; - rel2.relative, 1.0 0.0; - min, 0 0; - align, 1.0 0.0; - fixed, 1 1; - visible, 0; - } - description { - state, "visible" 0.0; - inherit, "default" 0.0; - min, 28 28; - visible, 1; - } - description { - state, "focused" 0.0; - inherit, "default" 0.0; - image.normal, "ic_thumbnail_lock_01_foc.png"; - min, 28 28; - visible, 1; - } - } - part { - name, "padding.channelinfo.locked"; - type, SPACER; - scale, 1; - description { - state, "default" 0.0; - rel1 { - to, PART_CHANNELINFO_LOCKED; - relative, 0.0 0.0; - } - rel2 { - to, PART_CHANNELINFO_LOCKED; - relative, 0.0 0.0; - } - min, 0 0; - align, 1.0 0.0; - fixed, 1 1; - } - description { - state, "visible" 0.0; - inherit, "default" 0.0; - min, 10 0; - } - description { - state, "focused" 0.0; - inherit, "default" 0.0; - min, 10 0; - } - } - part { - name, PART_CHANNELINFO_FAVORITE; - type, IMAGE; - scale, 1; - description { - state, "default" 0.0; - image.normal, "ic_thumbnail_favorite_01.png"; - rel1 { - to, "padding.channelinfo.locked"; - relative, 0.0 0.0; - } - rel2 { - to, "padding.channelinfo.locked"; - relative, 0.0 0.0; - } - min, 0 0; - align, 1.0 0.0; - fixed, 1 1; - visible, 0; - } - description { - state, "visible" 0.0; - inherit, "default" 0.0; - min, 28 28; - visible, 1; - } - } - part { - name, "padding.channelinfo.favorite"; - type, SPACER; - scale, 1; - description { - state, "default" 0.0; - rel1 { - to, PART_CHANNELINFO_FAVORITE; - relative, 0.0 0.0; - } - rel2 { - to, PART_CHANNELINFO_FAVORITE; - relative, 0.0 0.0; - } - min, 0 0; - align, 1.0 0.0; - fixed, 1 1; - } - description { - state, "visible" 0.0; - inherit, "default" 0.0; - min, 10 0; + part { + name, PART_CHANNELINFO_LOCKED; + type, IMAGE; + scale, 1; + description { + state, "default" 0.0; + image.normal, "ic_thumbnail_lock_01_nor.png"; + rel1 { + to, PART_CHANNELINFO_STATUS; + relative, 1.0 0.0; + } + rel2 { + to, PART_CHANNELINFO_STATUS; + relative, 1.0 0.0; + } + min, 0 0; + align, 1.0 0.0; + fixed, 1 1; + visible, 0; + } + description { + state, "visible" 0.0; + inherit, "default" 0.0; + min, 28 28; + visible, 1; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + image.normal, "ic_thumbnail_lock_01_foc.png"; + min, 28 28; + visible, 1; + } + } + part { + name, "padding.channelinfo.locked"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, PART_CHANNELINFO_LOCKED; + relative, 0.0 0.0; } + rel2 { + to, PART_CHANNELINFO_LOCKED; + relative, 0.0 0.0; + } + min, 0 0; + align, 1.0 0.0; + fixed, 1 1; + } + description { + state, "visible" 0.0; + inherit, "default" 0.0; + min, 10 0; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + min, 10 0; + } + } + part { + name, PART_CHANNELINFO_FAVORITE; + type, IMAGE; + scale, 1; + description { + state, "default" 0.0; + image.normal, "ic_thumbnail_favorite_01.png"; + rel1 { + to, "padding.channelinfo.locked"; + relative, 0.0 0.0; + } + rel2 { + to, "padding.channelinfo.locked"; + relative, 0.0 0.0; + } + min, 0 0; + align, 1.0 0.0; + fixed, 1 1; + visible, 0; + } + description { + state, "visible" 0.0; + inherit, "default" 0.0; + min, 28 28; + visible, 1; + } + } + part { + name, "padding.channelinfo.favorite"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, PART_CHANNELINFO_FAVORITE; + relative, 0.0 0.0; + } + rel2 { + to, PART_CHANNELINFO_FAVORITE; + relative, 0.0 0.0; + } + min, 0 0; + align, 1.0 0.0; + fixed, 1 1; + } + description { + state, "visible" 0.0; + inherit, "default" 0.0; + min, 10 0; } } } diff --git a/include/define.h b/include/define.h index 5196c43..2229a34 100644 --- a/include/define.h +++ b/include/define.h @@ -115,4 +115,8 @@ #define PART_FAVORITE "part.favorite" #define PART_CHANNELINFO "part.channelinfo" +#define VIEW_PIN "VIEW_PIN" +#define MESSAGE_SUCCESS "success" +#define MESSAGE_FAIL "fail" + #endif /* __LIVETV_DEFINE_H__*/ diff --git a/include/view.h b/include/view.h index 7648f05..34abc88 100644 --- a/include/view.h +++ b/include/view.h @@ -39,5 +39,6 @@ view_class *view_channelnumber_get_vclass(void); view_class *view_channelinfo_get_vclass(void); view_class *view_error_get_vclass(void); view_class *view_action_menu_get_vclass(void); +view_class *view_pin_get_vclass(void); #endif /* __LIVETV_VIEW_H__*/ diff --git a/packaging/org.tizen.live-tv.spec b/packaging/org.tizen.live-tv.spec index 2c11982..67c2ce5 100644 --- a/packaging/org.tizen.live-tv.spec +++ b/packaging/org.tizen.live-tv.spec @@ -20,6 +20,7 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gobject-2.0) BuildRequires: pkgconfig(tv-service) BuildRequires: pkgconfig(tzsh-tvsrv) +BuildRequires: pkgconfig(ui-gadget-1) BuildRequires: gettext-devel BuildRequires: edje-bin @@ -21,6 +21,7 @@ #include <app_debug.h> #include <tzsh_tvsrv.h> #include <efl_util.h> +#include <ui-gadget.h> #include "define.h" #include "tv.h" @@ -90,6 +91,10 @@ static Eina_Bool _key_down_cb(void *data, int type, void *ei) if (!ad->is_channel) return ECORE_CALLBACK_DONE; + if (viewmgr_get_view_state(VIEW_PIN) == + VIEW_STATE_VISIBLE) + return ECORE_CALLBACK_PASS_ON; + if (!strcmp(ev->keyname, KEY_ENTER) || !strcmp(ev->keyname, KEY_ENTER_REMOTE)) { if (viewmgr_active_view_count() > 0) @@ -126,6 +131,10 @@ static Eina_Bool _key_up_cb(void *data, int type, void *ei) if (!ad->is_channel) return ECORE_CALLBACK_DONE; + if (viewmgr_get_view_state(VIEW_PIN) == + VIEW_STATE_VISIBLE) + return ECORE_CALLBACK_PASS_ON; + if (!strcmp(ev->keyname, KEY_ENTER) || !strcmp(ev->keyname, KEY_ENTER_REMOTE)) { if (viewmgr_active_view_count() > 0) @@ -308,6 +317,10 @@ static bool _create(void *data) 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); @@ -318,6 +331,7 @@ static bool _create(void *data) viewmgr_add_view(view_channelnumber_get_vclass(), NULL); viewmgr_add_view(view_error_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) { @@ -367,6 +381,7 @@ static void _terminate(void *data) viewmgr_remove_view(VIEW_CHANNELNUMBER); viewmgr_remove_view(VIEW_ERROR); viewmgr_remove_view(VIEW_ACTION_MENU); + viewmgr_remove_view(VIEW_PIN); viewmgr_destroy(); evas_object_del(ad->win); diff --git a/src/view_action_menu.c b/src/view_action_menu.c index a012383..4f36cf0 100644 --- a/src/view_action_menu.c +++ b/src/view_action_menu.c @@ -115,9 +115,27 @@ static int _fav_state(void) return r; } +static void _lock_clicked(void) +{ + viewmgr_show_view(VIEW_PIN); +} + static int _lock_state(void) { - return STATE_DISABLED; + 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; } struct _button { @@ -164,7 +182,7 @@ static struct _button buttons[] = { .selected = IMAGE_UNLOCK_SEL, .disabled = IMAGE_UNLOCK_DIS }, - .clicked = NULL, + .clicked = _lock_clicked, .state = _lock_state }, { diff --git a/src/view_pin.c b/src/view_pin.c new file mode 100644 index 0000000..bab97bc --- /dev/null +++ b/src/view_pin.c @@ -0,0 +1,215 @@ +/* + * 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) +{ + service_h service; + int r; + + r = service_create(&service); + if (r != SERVICE_ERROR_NONE) { + _ERR("failed to create service"); + return; + } + + r = service_add_extra_data(service, PARAM_PIN, result); + if (r != SERVICE_ERROR_NONE) { + _ERR("failed to add data"); + service_destroy(service); + return; + } + + ug_send_message(priv->ug, service); + + service_destroy(service); +} + +static void _check_pincode(struct _priv *priv, const 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, service_h result, void *p) +{ + char *pincode; + int r; + + if (!p) { + _ERR("Invalid argument"); + return; + } + + r = service_get_extra_data(result, PARAM_PIN, &pincode); + if (r != SERVICE_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; +} |