glib-2.0
capi-web-bookmark
tv-service
+ ui-gadget-1
)
IF(NOT DEFINED PACKAGE_NAME)
src/common/utils.c
src/view/view_base.c
src/view/view_action_menu.c
+ src/view/view_pin.c
src/grid/grid_tv.c
src/grid/grid_movie.c
src/grid/grid_gallery.c
DATA_ARTIST,
DATA_ALBUM_NAME,
DATA_DURATION,
+ DATA_SUBTITLE,
+ DATA_DESCRIPTION,
};
enum action_type {
void (*free_favorites)(Eina_List *list);
int (*get_count)(enum item_type type);
char *(*get_data)(void *data, enum data_type type);
- bool (*action)(Elm_Object_Item *it, enum action_type type);
+ bool (*action)(Elm_Object_Item *it, enum action_type type, void *data);
bool (*data_updated)(void *data1, void *data2);
+ bool (*data_locked)(Elm_Object_Item *it, bool *locked);
};
struct datamgr *get_channel_datamgr(void);
#define __AIR_FAVORITE_DEFINE_H__
/* View ID */
-#define VIEW_ID_BASE "VIEW_ID_BASE"
-#define VIEW_ID_ACTION_MENU "VIEW_ID_ACTION_MENU"
+#define VIEW_BASE "VIEW_BASE"
+#define VIEW_ACTION_MENU "VIEW_ACTION_MENU"
+#define VIEW_PIN "VIEW_PIN"
+
+/* Grid ID */
+#define GRID_TV "TV"
+#define GRID_MOVIE "Movie"
+#define GRID_GALLERY "Gallery"
+#define GRID_MUSIC "Music"
+#define GRID_APP "Apps"
+#define GRID_WEB "Web"
/* Group */
#define GRP_VIEW_BASE "grp.view.base"
#define GRP_VIEW_ACTION_MENU "grp.view.action.menu"
+#define GRP_TV_BANNER "grp.tv.banner"
/* Part for edc file */
#define PART_TOP_TITLE "part.top.title"
#define PART_TEXT_BG "part.text.bg"
#define PART_THUMB_ICON "part.thumb.icon"
#define PART_THUMB_TEXT "part.thumb.text"
+#define PART_THUMB_TEXT_BR "part.thumb.text.browser"
#define PART_THUMB_SUBTEXT1 "part.thumb.subtext1"
#define PART_THUMB_SUBTEXT2 "part.thumb.subtext2"
#define PART_THUMB_PLAY_ICON "part.thumb.play.icon"
#define PART_THUMB_DEFAULT_TV_ICON "part.thumb.default.tv.icon"
#define PART_LIVETV_BTN "part.livetv.button"
#define PART_ACTION_MENU "part.action.menu"
+#define PART_BANNER "part.banner"
+#define PART_TITLE "part.title"
+#define PART_SUBTITLE "part.subtitle"
+#define PART_DESCRIPT "part.description"
/* Style */
#define STYLE_MENU_BTN "style.menu.button"
#define STYLE_LIVETV_BTN "style.livetv.button"
#define STYLE_ACTION_MENU_FAV_BTN "style.action.menu.favorite.button"
#define STYLE_ACTION_MENU_LOCK_BTN "style.action.menu.lock.button"
+#define STYLE_TOAST "style.toast"
/* Signal */
#define SIG_FOCUSED "focused"
#define SIG_INVISIBLE "invisible"
#define SIG_DISABLE "elm,state,disabled"
#define SIG_TOGGLE "toggle"
+#define SIG_TIMEOUT "timeout"
/* Source */
#define SRC_EDC "edc"
#define SRC_MENU_BTN "menubtn"
#define SRC_ACTION_BTN "source.action.btn"
+#define SRC_LOCK_ICON "source.lock.icon"
/* Transition */
#define TRANSITION_FOCUS DECELERATE 0.20
#define STR_CNT_WEBS "bookmark"
#define STR_BROWSER "Web Browser"
#define STR_LIVETV "Live TV"
+#define STR_REMOVE_FAVORITE "Removed from your favorite."
+#define STR_SUCCESS "success"
+#define STR_FAIL "fail"
+#define STR_LOCKED "Content is locked."
+#define STR_UNLOCKED "Content is unlocked."
/* Font */
#define FONT_TIZENSANS_REGULAR "TizenSans"
#define COLOR_TEXT_BG 113 128 147 255
#define COLOR_ITEM_FOCUS 0 119 246 255
#define COLOR_ITEM_FOCUS_0 0 119 246 0
+#define COLOR_BR_R 255
+#define COLOR_BR_G 255
+#define COLOR_BR_B 255
+#define COLOR_BR_A 255
/* Size */
#define SIZE_BOX_PAD_H (40 + 40)
#define SIZE_APP_ICON_MAX 100
#define SIZE_ACTION_TABLE_BORDER 0
#define SIZE_COL_MAX 4
+#define SIZE_TOAST_TIMEOUT 5.0
/* Count */
#define COUNT_MENU 6
#define COUNT_ACTION 2
+#define COUNT_BANNER 1
/* Image */
#define PLAY_ICON_PNG "ic_thumbnail_play.png"
#define ACTION_LOCK_FOC_PNG "btn_menu_lock_foc.png"
#define ACTION_LOCK_SEL_PNG "btn_menu_lock_sel.png"
#define ACTION_LOCK_DIS_PNG "btn_menu_lock_dis.png"
+#define LOCK_ICON_PNG "ic_thumbnail_lock_01.png"
/* Path */
#define PATH_PLAY_ICON_PNG IMGDIR"/ic_thumbnail_play.png"
Eina_List *(*create_item_list)(void);
void (*destroy_item_list)(Eina_List *list);
- bool (*item_action)(Elm_Object_Item *it, enum action_type type);
+ bool (*item_action)(Elm_Object_Item *it,
+ enum action_type type, void *data);
bool (*item_updated)(void *pre_data, void *new_data);
+ bool (*item_locked)(Elm_Object_Item *it, bool *locked);
+ bool (*load_item_banner)(Evas_Object *banner, void *data);
};
struct grid_data *get_tv_grid_data(void);
#define __AIR_FAVORITE_UTILS_H__
Evas_Object *utils_add_window(const char *name);
-Evas_Object *utils_add_layout(Evas_Object *parent, const char *group);
+Evas_Object *utils_add_layout(Evas_Object *parent, const char *group,
+ Eina_Bool resize);
Evas_Object *utils_add_gengrid(Evas_Object *parent,
int item_size_x, int item_size_y);
Evas_Object *utils_add_box(Evas_Object *parent, const char *part,
view_class *view_base_get_vclass(void);
view_class *view_action_menu_get_vclass(void);
+view_class *view_pin_get_vclass(void);
enum update_type {
UPDATE_DATA = 0,
UPDATE_GRID,
+ UPDATE_SHOW_TOAST,
+ UPDATE_LOCK,
+ UPDATE_UNLOCK,
+ UPDATE_MENU,
};
#endif /* __AIR_APPS_VIEW_H__ */
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(capi-web-bookmark)
BuildRequires: pkgconfig(tv-service)
+BuildRequires: pkgconfig(ui-gadget-1)
%define _appdir /usr/apps/%{name}
%define _bindir %{_appdir}/bin
fixed, 1 1;
}
}
+
+ part {
+ name, "padding.info.banner";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 40 40;
+ rel2.relative, 0.0 0.0;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+
+ part {
+ name, PART_BANNER;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 536 174;
+ rel1 {
+ to, "padding.info.banner";
+ relative, 1.0 1.0;
+ }
+ rel2.to, "padding.info.banner";
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+ }
+ }
+
+ group {
+ name, GRP_TV_BANNER;
+ parts {
+ part {
+ name, "bg";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 255 255 255 255;
+ }
+ }
+
+ part {
+ name, "padding.title.left.top";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 28 26;
+ rel2.relative, 0.0 0.0;
+ align, 0.0 0.0;
+ fixed, 1 1;
+ }
+ }
+
+ part {
+ name, "padding.title.right.top";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 28 26;
+ rel1.relative, 1.0 0.0;
+ rel2.relative, 1.0 0.0;
+ align, 1.0 0.0;
+ fixed, 1 1;
+ }
+ }
+
+ part {
+ name, PART_TITLE;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 51 51 51 255;
+ min, 0 32;
+ rel1 {
+ to, "padding.title.left.top";
+ relative, 1.0 1.0;
+ }
+ rel2 {
+ to, "padding.title.right.top";
+ relative, 0.0 1.0;
+ }
+ align, 0.5 0.0;
+ fixed, 0 1;
+ text {
+ font, FONT_TIZENSANS_LIGHT;
+ size, 28;
+ align, 0.0 0.5;
+ }
+ }
+ }
+
+ part {
+ name, "padding.text";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 6;
+ rel1 {
+ to, "part.title";
+ relative, 0.0 1.0;
+ }
+ rel2.to, "part.title";
+ align, 0.5 0.0;
+ fixed, 0 1;
+ }
+ }
+
+ part {
+ name, PART_SUBTITLE;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 51 51 51 255;
+ min, 0 32;
+ rel1 {
+ to, "padding.text";
+ relative, 0.0 1.0;
+ }
+ rel2.to, "padding.text";
+ align, 0.5 0.0;
+ fixed, 0 1;
+ text {
+ font, FONT_TIZENSANS_LIGHT;
+ size, 28;
+ align, 0.0 0.5;
+ }
+ }
+ }
+
+ part {
+ name, "padding.description";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 24;
+ rel1 {
+ to, "part.subtitle";
+ relative, 0.0 1.0;
+ }
+ rel2.to, "part.subtitle";
+ align, 0.5 0.0;
+ fixed, 0 1;
+ }
+ }
+
+ part {
+ name, PART_DESCRIPT;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 112 112 112 255;
+ min, 0 28;
+ rel1 {
+ to, "padding.description";
+ relative, 0.0 1.0;
+ }
+ rel2.to, "padding.description";
+ align, 0.5 0.0;
+ fixed, 0 1;
+ text {
+ font, FONT_TIZENSANS_LIGHT;
+ size, 28;
+ align, 0.0 0.5;
+ }
+ }
+ }
}
}
}
group {
name, "elm/gengrid/item/style.apps/default";
data.item, "focus_highlight" "on";
- data.item, "texts" "part.thumb.text";
+ data.item, "texts" "part.thumb.text part.thumb.text.browser";
data.item, "contents" "part.thumb.icon part.thumb.bg part.text.bg";
+ data.item, "states" "is_browser";
parts {
part {
name, "padding.bottom.right";
state, "default" 0.0;
rel1.to, "part.bg";
rel2 {
- to, "part.bg";
+ to, PART_TEXT_BG;
relative, 1.0 0.0;
}
- min, 0 212;
- align, 0.5 0.0;
- fixed, 0 1;
map {
perspective_on, 1;
perspective, "map";
scale, 1;
description {
state, "default" 0.0;
+ min, 0 82;
rel1 {
- to, PART_THUMB_BG;
+ to, "part.bg";
relative, 0.0 1.0;
}
- rel2.to, PART_THUMB_BG;
- min, 0 82;
- align, 0.5 0.0;
+ rel2.to, "part.bg";
+ align, 0.5 1.0;
fixed, 0 1;
map {
perspective_on, 1;
}
part {
+ name, "part.inside.line.up";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 194 194 194 255;
+ min, 0 1;
+ rel1.to, "part.bg";
+ rel2 {
+ to, "part.bg";
+ relative, 1.0 0.0;
+ }
+ align, 0.5 0.0;
+ fixed, 0 1;
+ visible, 0;
+ }
+ description {
+ state, "visible" 0.0;
+ inherit, "default" 0.0;
+ visible, 1;
+ }
+ }
+
+ part {
+ name, "part.inside.line.left";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 194 194 194 255;
+ min, 1 0;
+ rel1 {
+ to, "part.inside.line.up";
+ relative, 0.0 1.0;
+ }
+ rel2 {
+ to, "part.bg";
+ relative, 0.0 1.0;
+ }
+ align, 0.0 0.5;
+ fixed, 1 0;
+ visible, 0;
+ }
+ description {
+ state, "visible" 0.0;
+ inherit, "default" 0.0;
+ visible, 1;
+ }
+ }
+
+ part {
+ name, "part.inside.line.right";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 194 194 194 255;
+ min, 1 0;
+ rel1 {
+ to, "part.inside.line.up";
+ relative, 1.0 1.0;
+ }
+ rel2.to, "part.bg";
+ align, 1.0 0.5;
+ fixed, 1 0;
+ visible, 0;
+ }
+ description {
+ state, "visible" 0.0;
+ inherit, "default" 0.0;
+ visible, 1;
+ }
+ }
+
+ part {
+ name, "part.inside.line.down";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 194 194 194 255;
+ min, 0 1;
+ rel1 {
+ to, "part.inside.line.left";
+ relative, 1.0 1.0;
+ }
+ rel2 {
+ to, "part.inside.line.right";
+ relative, 0.0 1.0;
+ }
+ align, 0.5 1.0;
+ fixed, 0 1;
+ visible, 0;
+ }
+ description {
+ state, "visible" 0.0;
+ inherit, "default" 0.0;
+ visible, 1;
+ }
+ }
+
+ part {
+ name, "part.divide.line";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 194 194 194 255;
+ min, 0 1;
+ rel1.to, PART_TEXT_BG;
+ rel2 {
+ to, PART_TEXT_BG;
+ relative, 1.0 0.0;
+ }
+ align, 0.5 0.0;
+ fixed, 0 1;
+ visible, 0;
+ }
+ description {
+ state, "visible" 0.0;
+ inherit, "default" 0.0;
+ visible, 1;
+ }
+ }
+
+ part {
name, "part.focus.up";
type, RECT;
scale, 1;
}
part {
- name, "padding.thumb.text";
+ name, "padding.thumb.text.left";
type, SPACER;
scale, 1;
description {
}
part {
+ name, "padding.thumb.text.right";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 18 0;
+ rel1 {
+ to, "part.focus.down";
+ relative, 1.0 0.0;
+ }
+ rel2.to, "part.focus.down";
+ align, 1.0 0.5;
+ fixed, 1 0;
+ }
+ }
+
+ part {
name, PART_THUMB_TEXT;
type, TEXT;
scale, 1;
description {
state, "default" 0.0;
color, 255 255 255 255;
- min, 176 82;
rel1 {
- to, "padding.thumb.text";
+ to, "padding.thumb.text.left";
relative, 1.0 0.0;
}
rel2 {
- to, "padding.thumb.text";
+ to, "padding.thumb.text.right";
+ relative, 0.0 1.0;
+ }
+ text {
+ font, FONT_TIZENSANS_LIGHT;
+ size, 28;
+ align, 0.0 0.5;
+ }
+ map {
+ perspective_on, 1;
+ perspective, "map";
+ }
+ }
+ description {
+ state, "focused" 0.0;
+ inherit, "default" 0.0;
+ map.on, 1;
+ }
+ description {
+ state, "focused_0" 0.0;
+ inherit, "focused" 0.0;
+ }
+ }
+
+ part {
+ name, PART_THUMB_TEXT_BR;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ color, 92 92 92 255;
+ rel1 {
+ to, "padding.thumb.text.left";
relative, 1.0 0.0;
}
- align, 0.0 0.0;
- fixed, 1 1;
+ rel2 {
+ to, "padding.thumb.text.right";
+ relative, 0.0 1.0;
+ }
text {
font, FONT_TIZENSANS_LIGHT;
size, 28;
state, "focused" 0.0;
inherit, "default" 0.0;
map.on, 1;
+ color, 255 255 255 255;
}
description {
state, "focused_0" 0.0;
target, "part.focus.down";
target, "part.focus.right";
target, PART_THUMB_TEXT;
+ target, PART_THUMB_TEXT_BR;
after, "focus.in.anim";
}
source, "elm";
action, STATE_SET "default" 0.0;
target, PART_THUMB_TEXT;
+ target, PART_THUMB_TEXT_BR;
after, "focus.out.anim";
}
name, "item_selected";
action, SIGNAL_EMIT SIG_ITEM_SELECTED SRC_EDC;
}
+
+ program {
+ signal, "elm,state,is_browser,active";
+ source, "elm";
+ action, STATE_SET "visible" 0.0;
+ target, "part.inside.line.up";
+ target, "part.inside.line.left";
+ target, "part.inside.line.down";
+ target, "part.inside.line.right";
+ target, "part.divide.line";
+ }
}
}
data.item, "focus_highlight" "on";
data.item, "texts" "part.thumb.text";
data.item, "contents" "part.thumb.icon part.thumb.default.tv.icon part.thumb.bg part.text.bg";
+ images {
+ image, LOCK_ICON_PNG COMP;
+ }
+
parts {
part {
name, "padding.bottom.right";
inherit, "focused" 0.0;
}
}
+
+ part {
+ name, "padding.lock.icon";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 14 18;
+ rel1 {
+ to, "part.bg";
+ relative, 1.0 0.0;
+ }
+ rel2 {
+ to, "part.bg";
+ relative, 1.0 0.0;
+ }
+ align, 1.0 0.0;
+ fixed, 1 1;
+ }
+ }
+
+ part {
+ name, "part.lock.icon";
+ type, IMAGE;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 40 40;
+ rel1 {
+ to, "padding.lock.icon";
+ relative, 0.0 1.0;
+ }
+ rel2 {
+ to, "padding.lock.icon";
+ relative, 0.0 1.0;
+ }
+ align, 1.0 0.0;
+ fixed, 1 1;
+ image.normal, LOCK_ICON_PNG;
+ visible, 0;
+ }
+ description {
+ state, "visible" 0.0;
+ inherit, "default" 0.0;
+ visible, 1;
+ }
+ }
}
programs {
name, "item_selected";
action, SIGNAL_EMIT SIG_ITEM_SELECTED SRC_EDC;
}
+
+ program {
+ name, SIG_VISIBLE;
+ signal, SIG_VISIBLE;
+ source, SRC_LOCK_ICON;
+ action, STATE_SET "visible" 0.0;
+ target, "part.lock.icon";
+ }
+
+ program {
+ name, SIG_INVISIBLE;
+ signal, SIG_INVISIBLE;
+ source, SRC_LOCK_ICON;
+ action, STATE_SET "default" 0.0;
+ target, "part.lock.icon";
+ }
}
}
#include <app_debug.h>
#include "define.h"
+#include "datamgr.h"
Evas_Object *utils_add_window(const char *name)
{
return win;
}
-Evas_Object *utils_add_layout(Evas_Object *parent, const char *group)
+Evas_Object *utils_add_layout(Evas_Object *parent, const char *group,
+ Eina_Bool resize)
{
Evas_Object *layout;
- if (!parent || !group) {
+ if (!parent) {
_ERR("Invalid argument.");
return NULL;
}
return NULL;
}
- elm_layout_file_set(layout, EDJEFILE, group);
+ if (group)
+ elm_layout_file_set(layout, EDJEFILE, group);
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
- elm_win_resize_object_add(parent, layout);
+
+ if (resize)
+ elm_win_resize_object_add(parent, layout);
return layout;
}
return table;
}
+static void _notify_timeout_cb(void *data, Evas_Object *obj, void *ei)
+{
+ if (!obj)
+ return;
+
+ evas_object_del(obj);
+}
+
Evas_Object *utils_add_notify(Evas_Object *parent, const char *text,
const char *noti_style, const char *label_style, int timeout)
{
if (text)
elm_object_text_set(lbl, text);
+ evas_object_smart_callback_add(notify, SIG_TIMEOUT,
+ _notify_timeout_cb, NULL);
evas_object_show(notify);
return notify;
}
}
-static bool _action(Elm_Object_Item *it, enum action_type type)
+static bool _action(Elm_Object_Item *it, enum action_type type, void *data)
{
struct app_data *adata;
int r;
/* It will fixed after tv-service's implementation */
return NULL;
+ case DATA_SUBTITLE:
+ /* It will be implemented as GUI guide */
+ return NULL;
+
+ case DATA_DESCRIPTION:
+ /* It will be implemented as GUI guide */
+ return NULL;
+
default:
_ERR("Invalid data type.");
return NULL;
return true;
}
-static bool _action(Elm_Object_Item *it, enum action_type type)
+static bool _update_lock(struct channel_data *cdata, void *data)
+{
+ TvServiceChannel channel;
+ char *pincode;
+ int r;
+
+ if (!data)
+ return false;
+
+ pincode = data;
+
+ r = tv_service_channel_info_create();
+ if (r != TVS_ERROR_OK) {
+ _ERR("Tv Service channel info create failed.");
+ return false;
+ }
+
+ r = tv_service_get_channel(cdata->id, &channel);
+ if (r != TVS_ERROR_OK) {
+ tv_service_channel_info_destroy();
+ return false;
+ }
+
+ if (channel.locked)
+ r = tv_service_unlock_channel(cdata->id, pincode);
+ else
+ r = tv_service_lock_channel(cdata->id, pincode);
+
+ tv_service_channel_info_destroy();
+
+ if (r < 0)
+ return false;
+
+ return true;
+}
+
+static bool _action(Elm_Object_Item *it, enum action_type type, void *data)
{
struct channel_data *cdata;
char str[SIZE_STR];
break;
case ACTION_UPDATE_LOCK:
- /* It will implemented later. */
+ if (!_update_lock(cdata, data)) {
+ _ERR("Update lock status failed.");
+ return false;
+ }
+
break;
default:
return true;
}
+static bool _data_locked(Elm_Object_Item *it, bool *locked)
+{
+ struct channel_data *cdata;
+ TvServiceChannel channel;
+ int r;
+
+ if (!it) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ cdata = elm_object_item_data_get(it);
+ if (!cdata)
+ return false;
+
+ r = tv_service_channel_info_create();
+ if (r != TVS_ERROR_OK) {
+ _ERR("Tv Service channel info create failed.");
+ return false;
+ }
+
+ r = tv_service_get_channel(cdata->id, &channel);
+ if (r != TVS_ERROR_OK) {
+ tv_service_channel_info_destroy();
+ return false;
+ }
+
+ *locked = channel.locked;
+
+ tv_service_channel_info_destroy();
+
+ return true;
+}
+
static struct datamgr _dmgr = {
.get_data = _get_data,
.get_count = NULL,
.free_favorites = _free_favorites,
.action = _action,
.data_updated = _data_updated,
+ .data_locked = _data_locked,
};
struct datamgr *get_channel_datamgr(void)
}
}
-static bool _action(Elm_Object_Item *it, enum action_type type)
+static bool _action(Elm_Object_Item *it, enum action_type type, void *data)
{
app_media *am;
app_media_info *minfo;
}
}
-static bool _action(Elm_Object_Item *it, enum action_type type)
+static bool _action(Elm_Object_Item *it, enum action_type type, void *data)
{
/* It will be implemented later. */
#include "define.h"
#include "grid.h"
-#define STR_APPS "Apps"
#define STYLE_APPS "style.apps"
#define ITEM_APPS_X (212 + 26)
#define ITEM_APPS_Y (294 + 26)
if (!name)
return NULL;
- return strdup(name);
+ if ((!strcmp(name, STR_BROWSER)
+ && !strcmp(part, PART_THUMB_TEXT_BR))
+ || (strcmp(name, STR_BROWSER)
+ && !strcmp(part, PART_THUMB_TEXT)))
+ return strdup(name);
+
+ return NULL;
}
static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *part)
return NULL;
}
+ if (!strcmp(name, STR_BROWSER)) {
+ evas_object_color_set(rect, COLOR_BR_R, COLOR_BR_G,
+ COLOR_BR_B, COLOR_BR_A);
+ return rect;
+ }
+
app_contents_get_color(name, &bright, &dark);
evas_object_color_set(rect, bright.r, bright.g,
bright.b, bright.a);
return NULL;
}
+ if (!strcmp(name, STR_BROWSER)) {
+ evas_object_color_set(rect, COLOR_BR_R, COLOR_BR_G,
+ COLOR_BR_B, COLOR_BR_A);
+ return rect;
+ }
+
app_contents_get_color(name, &bright, &dark);
evas_object_color_set(rect, dark.r, dark.g, dark.b, dark.a);
return NULL;
}
+static Eina_Bool _state_get(void *data, Evas_Object *obj, const char *part)
+{
+ struct datamgr *dmgr;
+ char *name;
+
+ if (!data) {
+ _ERR("Data is NULL.");
+ return EINA_FALSE;
+ }
+
+ dmgr = get_apps_datamgr();
+ if (!dmgr || !dmgr->get_data)
+ return EINA_FALSE;
+
+ name = dmgr->get_data(data, DATA_NAME);
+ if (!name)
+ return EINA_FALSE;
+
+ if (!strcmp(name, STR_BROWSER))
+ return EINA_TRUE;
+
+ return EINA_FALSE;
+}
+
static struct grid_class _gclass = {
.item_style = STYLE_APPS,
.text_get = _text_get,
.content_get = _content_get,
- .state_get = NULL,
+ .state_get = _state_get,
.del = NULL,
};
dmgr->free_favorites(list);
}
-static bool _item_action(Elm_Object_Item *it, enum action_type type)
+static bool _item_action(Elm_Object_Item *it, enum action_type type, void *data)
{
struct datamgr *dmgr;
if (!dmgr || !dmgr->action)
return false;
- if (!dmgr->action(it, type)) {
+ if (!dmgr->action(it, type, data)) {
_ERR("The item action failed.");
return false;
}
}
static struct grid_data _gdata = {
- .id = STR_APPS,
+ .id = GRID_APP,
.item_size_x = ITEM_APPS_X,
.item_size_y = ITEM_APPS_Y,
.gclass = &_gclass,
#include "define.h"
#include "grid.h"
-#define STR_GALLERY "Gallery"
#define STYLE_GALLERY "style.gallery"
#define ITEM_GALLERY_X (200 + 6)
#define ITEM_GALLERY_Y (200 + 6)
dmgr->free_favorites(list);
}
-static bool _item_action(Elm_Object_Item *it, enum action_type type)
+static bool _item_action(Elm_Object_Item *it, enum action_type type, void *data)
{
struct datamgr *dmgr;
if (!dmgr || !dmgr->action)
return false;
- if (!dmgr->action(it, type)) {
+ if (!dmgr->action(it, type, data)) {
_ERR("The item action failed.");
return false;
}
}
static struct grid_data _gdata = {
- .id = STR_GALLERY,
+ .id = GRID_GALLERY,
.item_size_x = ITEM_GALLERY_X,
.item_size_y = ITEM_GALLERY_Y,
.gclass = &_gclass,
#include "define.h"
#include "grid.h"
-#define STR_MOVIE "Movie"
#define STYLE_MOVIE "style.movie"
#define ITEM_MOVIE_X (378 + 26)
#define ITEM_MOVIE_Y (294 + 26)
dmgr->free_favorites(list);
}
-static bool _item_action(Elm_Object_Item *it, enum action_type type)
+static bool _item_action(Elm_Object_Item *it, enum action_type type, void *data)
{
struct datamgr *dmgr;
if (!dmgr || !dmgr->action)
return false;
- if (!dmgr->action(it, type)) {
+ if (!dmgr->action(it, type, data)) {
_ERR("The item action failed.");
return false;
}
}
static struct grid_data _gdata = {
- .id = STR_MOVIE,
+ .id = GRID_MOVIE,
.item_size_x = ITEM_MOVIE_X,
.item_size_y = ITEM_MOVIE_Y,
.gclass = &_gclass,
#include "define.h"
#include "grid.h"
-#define STR_MUSIC "Music"
#define STYLE_MUSIC "style.music"
#define ITEM_MUSIC_X (488 + 26)
#define ITEM_MUSIC_Y (134 + 26)
dmgr->free_favorites(list);
}
-static bool _item_action(Elm_Object_Item *it, enum action_type type)
+static bool _item_action(Elm_Object_Item *it, enum action_type type, void *data)
{
struct datamgr *dmgr;
if (!dmgr || !dmgr->action)
return false;
- if (!dmgr->action(it, type)) {
+ if (!dmgr->action(it, type, data)) {
_ERR("The item action failed.");
return false;
}
}
static struct grid_data _gdata = {
- .id = STR_MUSIC,
+ .id = GRID_MUSIC,
.item_size_x = ITEM_MUSIC_X,
.item_size_y = ITEM_MUSIC_Y,
.gclass = &_gclass,
#include "grid.h"
#include "datamgr.h"
-#define STR_TV "TV"
#define STYLE_TV "style.tv"
#define ITEM_TV_X (378 + 26)
#define ITEM_TV_Y (294 + 26)
dmgr->free_favorites(list);
}
-static bool _item_action(Elm_Object_Item *it, enum action_type type)
+static bool _item_action(Elm_Object_Item *it, enum action_type type, void *data)
{
struct datamgr *dmgr;
if (!dmgr || !dmgr->action)
return false;
- if (!dmgr->action(it, type)) {
+ if (!dmgr->action(it, type, data)) {
_ERR("The item action failed.");
return false;
}
return dmgr->data_updated(pre_data, new_data);
}
+static bool _item_locked(Elm_Object_Item *it, bool *locked)
+{
+ struct datamgr *dmgr;
+
+ if (!it) {
+ _ERR("Invalid argument.");
+ return false;
+ }
+
+ dmgr = get_channel_datamgr();
+ if (!dmgr || !dmgr->data_locked)
+ return false;
+
+ if (!dmgr->data_locked(it, locked)) {
+ _ERR("Get lock status failed.");
+ return false;
+ }
+
+ return true;
+}
+
+static bool _load_item_banner(Evas_Object *banner, void *data)
+{
+ struct datamgr *dmgr;
+ char *title, *subtitle, *description;
+
+ if (!banner || !data) {
+ _ERR("Invaild argument.");
+ return false;
+ }
+
+ dmgr = get_channel_datamgr();
+ if (!dmgr || !dmgr->get_data)
+ return false;
+
+ elm_layout_file_set(banner, EDJEFILE, GRP_TV_BANNER);
+
+ title = dmgr->get_data(data, DATA_NAME);
+ if (title)
+ elm_object_part_text_set(banner, PART_TITLE, title);
+
+ subtitle = dmgr->get_data(data, DATA_SUBTITLE);
+ if (subtitle)
+ elm_object_part_text_set(banner, PART_SUBTITLE, subtitle);
+
+ description = dmgr->get_data(data, DATA_DESCRIPTION);
+ if (description)
+ elm_object_part_text_set(banner, PART_DESCRIPT, description);
+
+ return true;
+}
+
static struct grid_data _gdata = {
- .id = STR_TV,
+ .id = GRID_TV,
.item_size_x = ITEM_TV_X,
.item_size_y = ITEM_TV_Y,
.gclass = &_gclass,
.destroy_item_list = _destroy_item_list,
.item_action = _item_action,
.item_updated = _item_updated,
+ .item_locked = _item_locked,
+ .load_item_banner = _load_item_banner,
};
struct grid_data *get_tv_grid_data(void)
#include "define.h"
#include "grid.h"
-#define STR_WEBS "Web"
#define STYLE_WEBS "style.webs"
#define ITEM_WEBS_X (378 + 26)
#define ITEM_WEBS_Y (294 + 26)
}
static struct grid_data _gdata = {
- .id = STR_WEBS,
+ .id = GRID_WEB,
.item_size_x = ITEM_WEBS_X,
.item_size_y = ITEM_WEBS_Y,
.gclass = &_gclass,
#include <app.h>
#include <Elementary.h>
#include <viewmgr.h>
+#include <inputmgr.h>
+#include <ui-gadget.h>
+#include <app_define.h>
#include <app_debug.h>
#include "define.h"
return false;
}
+ if (ug_init_efl(win, UG_OPT_INDICATOR_ENABLE) < 0) {
+ _ERR("Fail to init ug");
+ evas_object_del(win);
+ return false;
+ }
+
if (!viewmgr_create(win)) {
_ERR("Create viewmgr failed.");
evas_object_del(win);
return false;
}
+ if (!viewmgr_add_view(view_pin_get_vclass(), NULL)) {
+ _ERR("Add view faild.");
+ viewmgr_destroy();
+ evas_object_del(win);
+ return false;
+ }
+
ad->win = win;
return true;
ad->win = NULL;
}
- viewmgr_remove_view(VIEW_ID_BASE);
- viewmgr_remove_view(VIEW_ID_ACTION_MENU);
+ viewmgr_remove_view(VIEW_BASE);
+ viewmgr_remove_view(VIEW_ACTION_MENU);
+ viewmgr_remove_view(VIEW_PIN);
viewmgr_destroy();
}
static void _app_control(app_control_h control, void *data)
{
struct _appdata *ad;
+ char *category;
+ int r;
if (!data) {
_ERR("Get data failed.");
if (ad->win)
elm_win_activate(ad->win);
- if (!viewmgr_push_view(VIEW_ID_BASE))
+ r = app_control_get_extra_data(control, PARAM_CATEGORY, &category);
+ if (r != APP_CONTROL_ERROR_NONE)
+ category = NULL;
+
+ if (category)
+ viewmgr_update_view(VIEW_BASE, UPDATE_MENU, category);
+
+ if (!viewmgr_push_view(VIEW_BASE))
_ERR("Push view failed.");
}
+static void _pause(void *data)
+{
+ view_state state;
+
+ state = viewmgr_get_view_state(VIEW_ACTION_MENU);
+ if (state == VIEW_STATE_VISIBLE)
+ viewmgr_hide_view(VIEW_ACTION_MENU);
+
+ state = viewmgr_get_view_state(VIEW_PIN);
+ if (state == VIEW_STATE_VISIBLE)
+ viewmgr_hide_view(VIEW_PIN);
+
+ inputmgr_enable(EINA_FALSE);
+}
+
+static void _resume(void *data)
+{
+ inputmgr_enable(EINA_TRUE);
+}
+
int main(int argc, char *argv[])
{
struct _appdata ad;
.create = _create,
.terminate = _terminate,
.app_control = _app_control,
+ .pause = _pause,
+ .resume = _resume,
};
memset(&ad, 0x00, sizeof(ad));
Evas_Object *base;
Evas_Object *live_btn;
Evas_Object *menu_btn[COUNT_ACTION];
+ Evas_Object *banner;
struct grid_data *gdata;
};
int id;
const char *title;
const char *style;
- Eina_Bool disable;
};
static struct _action_info action_info[] = {
{
.id = BTN_FAVORITE,
.title = STR_FAVORITE,
- .style = STYLE_ACTION_MENU_FAV_BTN,
- .disable = EINA_FALSE
+ .style = STYLE_ACTION_MENU_FAV_BTN
},
{
.id = BTN_LOCK,
.title = STR_LOCK,
- .style = STYLE_ACTION_MENU_LOCK_BTN,
- .disable = EINA_TRUE
+ .style = STYLE_ACTION_MENU_LOCK_BTN
}
};
return;
}
- viewmgr_hide_view(VIEW_ID_ACTION_MENU);
+ viewmgr_hide_view(VIEW_ACTION_MENU);
}
static void _favorite_selected(struct grid_data *gdata)
{
- if (!gdata->item_action(gdata->focused_item, ACTION_UPDATE_FAVORITE)) {
+ if (!gdata->item_action(gdata->focused_item,
+ ACTION_UPDATE_FAVORITE, NULL)) {
_ERR("Unfavorite failed.");
return;
}
- viewmgr_update_view(VIEW_ID_BASE, UPDATE_GRID, gdata);
- viewmgr_hide_view(VIEW_ID_ACTION_MENU);
+ viewmgr_update_view(VIEW_BASE, UPDATE_GRID, gdata);
+ viewmgr_update_view(VIEW_BASE, UPDATE_SHOW_TOAST, STR_REMOVE_FAVORITE);
+ viewmgr_hide_view(VIEW_ACTION_MENU);
+}
+
+static void _lock_selected(struct grid_data *gdata)
+{
+ if (!gdata->item_action || !gdata->item_locked)
+ return;
+
+ viewmgr_update_view(VIEW_PIN, UPDATE_DATA, gdata);
+ viewmgr_show_view(VIEW_PIN);
}
static void _clicked_cb(int id, void *data, Evas_Object *obj)
break;
case BTN_LOCK:
- /* It is not supported yet. */
+ _lock_selected(priv->gdata);
break;
default:
if (!strcmp(ev->keyname, KEY_BACK)
|| !strcmp(ev->keyname, KEY_BACK_REMOTE))
- viewmgr_hide_view(VIEW_ID_ACTION_MENU);
+ viewmgr_hide_view(VIEW_ACTION_MENU);
}
static input_handler _btn_input_handler = {
inputmgr_add_callback(btn, BTN_LIVETV, &_btn_input_handler, priv);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_RIGHT);
-
priv->live_btn = btn;
return true;
}
+static void _set_focus_policy(struct _priv *priv)
+{
+ int i;
+
+ elm_object_focus_next_object_set(priv->live_btn, priv->live_btn,
+ ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(priv->live_btn, priv->live_btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(priv->live_btn, priv->live_btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(priv->live_btn, priv->menu_btn[0],
+ ELM_FOCUS_DOWN);
+
+ elm_object_focus_next_object_set(priv->menu_btn[0], priv->menu_btn[0],
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(priv->menu_btn[COUNT_ACTION - 1],
+ priv->menu_btn[COUNT_ACTION - 1], ELM_FOCUS_RIGHT);
+
+ for (i = 0; i < COUNT_ACTION; i++)
+ elm_object_focus_next_object_set(priv->menu_btn[i],
+ priv->menu_btn[i], ELM_FOCUS_DOWN);
+}
+
+static void _set_action_state(int idx, Evas_Object *btn, struct _priv *priv)
+{
+ struct grid_data *gdata;
+ bool locked;
+
+ if (!priv->gdata)
+ return;
+
+ gdata = priv->gdata;
+
+ if (action_info[idx].id == BTN_LOCK) {
+ /* Channel can only be locked */
+ if (!strcmp(gdata->id, GRID_TV) && gdata->item_locked) {
+ gdata->item_locked(gdata->focused_item, &locked);
+
+ if (locked)
+ elm_object_signal_emit(btn, SIG_TOGGLE,
+ SRC_ACTION_BTN);
+
+ return;
+ }
+
+ elm_object_disabled_set(btn, EINA_TRUE);
+ }
+}
+
static bool _draw_action_area(struct _priv *priv)
{
Evas_Object *table, *btn;
inputmgr_add_callback(btn, action_info[i].id,
&_btn_input_handler, priv);
- if (action_info[i].disable)
- elm_object_disabled_set(btn, EINA_TRUE);
+ _set_action_state(i, btn, priv);
col = i % SIZE_COL_MAX;
row = i / SIZE_COL_MAX;
priv->menu_btn[i] = btn;
}
- /* 'Favorite' can only be focused now. */
- elm_object_focus_next_object_set(priv->menu_btn[0],
- priv->menu_btn[0], ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(priv->menu_btn[0],
- priv->menu_btn[0], ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(priv->menu_btn[0],
- priv->menu_btn[0], ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(priv->live_btn, priv->menu_btn[0],
- ELM_FOCUS_DOWN);
+ _set_focus_policy(priv);
+
+ return true;
+}
+
+static bool _draw_banner_area(struct _priv *priv)
+{
+ Evas_Object *banner;
+ void *data;
+
+ data = elm_object_item_data_get(priv->gdata->focused_item);
+ if (!data)
+ return false;
+
+ banner = utils_add_layout(priv->base, NULL, EINA_FALSE);
+ if (!banner) {
+ _ERR("Add layout failed.");
+ return false;
+ }
+
+ if (!priv->gdata->load_item_banner ||
+ !priv->gdata->load_item_banner(banner, data))
+ return false;
+
+ elm_object_part_content_set(priv->base, PART_BANNER, banner);
+
+ priv->banner = banner;
return true;
}
return NULL;
}
- base = utils_add_layout(win, GRP_VIEW_ACTION_MENU);
+ base = utils_add_layout(win, GRP_VIEW_ACTION_MENU, EINA_TRUE);
if (!base) {
_ERR("Add layout failed.");
free(priv);
priv->win = win;
priv->base = base;
- if (!viewmgr_set_view_data(VIEW_ID_ACTION_MENU, priv)) {
+ if (!viewmgr_set_view_data(VIEW_ACTION_MENU, priv)) {
_ERR("Set view data failed.");
evas_object_del(base);
free(priv);
}
_draw_livetv_area(priv);
- _draw_action_area(priv);
return base;
}
}
priv = data;
+ if (priv->banner)
+ evas_object_del(priv->banner);
+
if (priv->base)
evas_object_hide(priv->base);
}
}
priv = view_data;
- if (update_type == UPDATE_DATA)
+ if (update_type == UPDATE_DATA) {
+ if (!data)
+ return;
+
priv->gdata = data;
+ _draw_action_area(priv);
+ _draw_banner_area(priv);
+ }
}
static void _destroy(void *data)
}
static view_class _vclass = {
- .view_id = VIEW_ID_ACTION_MENU,
+ .view_id = VIEW_ACTION_MENU,
.create = _create,
.show = _show,
.hide = _hide,
Evas_Object *base;
Evas_Object *box;
Evas_Object *menu[COUNT_MENU];
+ Evas_Object *notify;
int cur_menu_id;
};
gdata = data;
if (gdata->item_action)
- gdata->item_action(it, ACTION_LAUNCH);
+ gdata->item_action(it, ACTION_LAUNCH, NULL);
elm_gengrid_item_selected_set(it, EINA_FALSE);
}
if (!gdata)
return;
- viewmgr_update_view(VIEW_ID_ACTION_MENU, UPDATE_DATA, gdata);
- viewmgr_show_view(VIEW_ID_ACTION_MENU);
+ viewmgr_update_view(VIEW_ACTION_MENU, UPDATE_DATA, gdata);
+ viewmgr_show_view(VIEW_ACTION_MENU);
}
}
priv->menu[i] = btn;
}
- elm_object_focus_next_object_set(priv->menu[0],
- priv->menu[COUNT_MENU - 1], ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(priv->menu[COUNT_MENU - 1],
- priv->menu[0], ELM_FOCUS_RIGHT);
-
elm_object_focus_set(priv->menu[0], EINA_TRUE);
return true;
return NULL;
}
- base = utils_add_layout(win, GRP_VIEW_BASE);
+ base = utils_add_layout(win, GRP_VIEW_BASE, EINA_TRUE);
if (!base) {
_ERR("Add layout failed.");
free(priv);
}
}
- if (!viewmgr_set_view_data(VIEW_ID_BASE, priv)) {
+ if (!viewmgr_set_view_data(VIEW_BASE, priv)) {
_ERR("Set view data failed.");
gridmgr_destroy(gmgr);
goto err;
static void _update(void *view_data, int update_type, void *data)
{
+ struct _priv *priv;
+ struct grid_data *gdata;
+ char *menu_category;
+ int i;
+
if (!view_data) {
_ERR("Get data failed.");
return;
}
+ priv = view_data;
+
+ switch (update_type) {
+ case UPDATE_MENU:
+ if (!data)
+ return;
+
+ menu_category = data;
+
+ for (i = 0; i < COUNT_MENU; i++) {
+ gdata = _get_grid_data[i]();
+
+ if (gdata && gdata->id
+ && !strcmp(gdata->id, menu_category)) {
+ elm_object_focus_set(priv->menu[i], EINA_TRUE);
+ break;
+ }
+ }
+
+ break;
+
+ case UPDATE_GRID:
+ _update_current_grid(priv);
+ break;
- if (update_type == UPDATE_GRID)
- _update_current_grid(view_data);
+ case UPDATE_SHOW_TOAST:
+ priv->notify = utils_add_notify(priv->base, (char *)data,
+ STYLE_TOAST, STYLE_TOAST, SIZE_TOAST_TIMEOUT);
+
+ break;
+
+ case UPDATE_LOCK:
+ if (!data)
+ return;
+
+ gdata = data;
+
+ elm_object_item_signal_emit(gdata->focused_item, SIG_VISIBLE,
+ SRC_LOCK_ICON);
+
+ break;
+
+ case UPDATE_UNLOCK:
+ if (!data)
+ return;
+
+ gdata = data;
+
+ elm_object_item_signal_emit(gdata->focused_item, SIG_INVISIBLE,
+ SRC_LOCK_ICON);
+
+ break;
+ default:
+ _ERR("Unhandled update type.");
+ }
}
static void _destroy(void *data)
}
static view_class _vclass = {
- .view_id = VIEW_ID_BASE,
+ .view_id = VIEW_BASE,
.create = _create,
.show = _show,
.hide = _hide,
--- /dev/null
+/* Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Elementary.h>
+#include <viewmgr.h>
+#include <ui-gadget.h>
+#include <app_define.h>
+#include <app_debug.h>
+
+#include "grid.h"
+#include "view.h"
+#include "define.h"
+
+struct _priv {
+ Evas_Object *win;
+ ui_gadget_h ug;
+ struct grid_data *gdata;
+};
+
+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("Fail to create service");
+ return;
+ }
+
+ r = service_add_extra_data(service, PARAM_PIN, result);
+ if (r != SERVICE_ERROR_NONE) {
+ _ERR("Fail to add data");
+ service_destroy(service);
+ return;
+ }
+
+ ug_send_message(priv->ug, service);
+ service_destroy(service);
+}
+
+static void _pincode_checked(struct _priv *priv, char *pincode)
+{
+ bool locked;
+
+ if (!priv->gdata->item_action(priv->gdata->focused_item,
+ ACTION_UPDATE_LOCK, pincode)) {
+ _ERR("Update lock failed.");
+ _send_message(priv, STR_FAIL);
+ return;
+ }
+
+ if (!priv->gdata->item_locked(priv->gdata->focused_item, &locked)) {
+ _ERR("Get lock status failed.");
+ goto end;
+ }
+
+
+ if (locked) {
+ viewmgr_update_view(VIEW_BASE, UPDATE_LOCK, priv->gdata);
+ viewmgr_update_view(VIEW_BASE, UPDATE_SHOW_TOAST, STR_LOCKED);
+ } else {
+ viewmgr_update_view(VIEW_BASE, UPDATE_UNLOCK, priv->gdata);
+ viewmgr_update_view(VIEW_BASE, UPDATE_SHOW_TOAST, STR_UNLOCKED);
+ }
+
+end:
+ viewmgr_hide_view(VIEW_PIN);
+ viewmgr_hide_view(VIEW_ACTION_MENU);
+}
+
+static void _ug_result_cb(ui_gadget_h ug, service_h result, void *priv)
+{
+ char *pincode;
+ int r;
+
+ if (!priv) {
+ _ERR("Invalid argument.");
+ return;
+ }
+
+ r = service_get_extra_data(result, PARAM_PIN, &pincode);
+ if (r != SERVICE_ERROR_NONE || !pincode) {
+ _ERR("Fail to get data");
+ return;
+ }
+
+ _pincode_checked(priv, pincode);
+
+ free(pincode);
+}
+
+static void _ug_destroy_cb(ui_gadget_h ug, void *priv)
+{
+ viewmgr_hide_view(VIEW_PIN);
+}
+
+static ui_gadget_h _load_pin_ug(struct _priv *priv)
+{
+ ui_gadget_h ug;
+ struct ug_cbs cbs = {0,};
+
+ cbs.result_cb = _ug_result_cb;
+ cbs.destroy_cb = _ug_destroy_cb;
+ cbs.priv = priv;
+
+ ug = ug_create(NULL, UG_ID_PIN, UG_MODE_FRAMEVIEW, NULL, &cbs);
+
+ return ug;
+}
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+ struct _priv *priv;
+
+ if (!win) {
+ _ERR("Get window object failed.");
+ return NULL;
+ }
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
+ _ERR("Calloc failed.");
+ return NULL;
+ }
+
+ priv->win = win;
+
+ if (!viewmgr_set_view_data(VIEW_PIN, priv)) {
+ _ERR("Set view data failed.");
+ free(priv);
+ return NULL;
+ }
+
+ return win;
+}
+
+static void _show(void *data)
+{
+ struct _priv *priv;
+ ui_gadget_h ug;
+
+ if (!data) {
+ _ERR("Get data failed.");
+ return;
+ }
+ priv = data;
+
+ ug = _load_pin_ug(priv);
+ if (!ug) {
+ _ERR("Create pin ug failed.");
+ return;
+ }
+
+ priv->ug = ug;
+}
+
+static void _hide(void *data)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Get data failed.");
+ return;
+ }
+ priv = data;
+
+ if (priv->ug)
+ ug_destroy(priv->ug);
+}
+
+static void _update(void *view_data, int update_type, void *data)
+{
+ struct _priv *priv;
+
+ if (!view_data) {
+ _ERR("Get data failed.");
+ return;
+ }
+ priv = view_data;
+
+ if (update_type == UPDATE_DATA)
+ priv->gdata = data;
+}
+
+static void _destroy(void *data)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Get data failed.");
+ return;
+ }
+ priv = data;
+
+ if (priv->ug)
+ ug_destroy(priv->ug);
+
+ free(priv);
+}
+
+static view_class _vclass = {
+ .view_id = VIEW_PIN,
+ .create = _create,
+ .show = _show,
+ .hide = _hide,
+ .update = _update,
+ .destroy = _destroy,
+};
+
+view_class *view_pin_get_vclass(void)
+{
+ return &_vclass;
+}