2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <Elementary.h>
20 #include <app_debug.h>
21 #include <app_define.h>
28 #define MEDIAHUB_WIN_TITLE PACKAGE
30 #define APP_ID_FAVORITE "org.tizen.favorite"
31 #define APP_ID_RECENT "org.tizen.home"
40 static Evas_Object *_add_win(const char *name)
45 win = elm_win_add(NULL, name, ELM_WIN_BASIC);
49 elm_win_title_set(win, MEDIAHUB_WIN_TITLE);
50 elm_win_alpha_set(win, EINA_TRUE);
51 elm_win_role_set(win, "video");
52 elm_win_screen_size_get(win, NULL, NULL, &w, &h);
53 evas_object_resize(win, w, h);
54 efl_util_set_window_opaque_state(win, 1);
56 evas_object_show(win);
61 static bool _create(void *data)
67 _ERR("failed to get data");
73 elm_app_base_scale_set(APP_BASE_SCALE);
74 elm_theme_overlay_add(NULL, THEMEFILE);
75 elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK);
77 win = _add_win(ad->name);
79 _ERR("failed to create win object");
83 if (!viewmgr_create(win)) {
84 _ERR("failed to initialize viewmgr");
89 viewmgr_add_view(view_base_get_vclass(), NULL);
90 viewmgr_add_view(view_detail_get_vclass(), NULL);
91 viewmgr_add_view(view_viewer_get_vclass(), NULL);
92 viewmgr_add_view(view_mplayer_get_vclass(), NULL);
93 viewmgr_add_view(view_action_menu_get_vclass(), NULL);
94 viewmgr_add_view(view_zoom_get_vclass(), NULL);
96 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
97 elm_win_focus_highlight_style_set(win, STYLE_INVISIBLE);
104 static void _terminate(void *data)
109 _ERR("failed to get data");
115 viewmgr_remove_view(VIEW_BASE);
116 viewmgr_remove_view(VIEW_DETAIL);
117 viewmgr_remove_view(VIEW_VIEWER);
118 viewmgr_remove_view(VIEW_MPLAYER);
119 viewmgr_remove_view(VIEW_ACTION_MENU);
120 viewmgr_remove_view(VIEW_ZOOM);
125 evas_object_del(ad->win);
130 static void _app_control(app_control_h app_control, void *data)
138 _ERR("failed to get data");
145 elm_win_activate(ad->win);
147 r = app_control_get_caller(app_control, &caller_id);
148 if (r != APP_CONTROL_ERROR_NONE)
151 r = app_control_get_extra_data(app_control, PARAM_MEDIA_ID, &media_id);
152 if (r != APP_CONTROL_ERROR_NONE)
155 if (media_id && caller_id) {
156 if (!strcmp(caller_id, APP_ID_FAVORITE)) {
157 while (viewmgr_active_view_count() > 0)
160 viewmgr_update_view(VIEW_BASE,
161 UPDATE_FAVORITE, media_id);
162 } else if (!strcmp(caller_id, APP_ID_RECENT)) {
163 viewmgr_push_view(VIEW_BASE);
164 viewmgr_update_view(VIEW_BASE,
165 UPDATE_RECENT, media_id);
168 viewmgr_push_view(VIEW_BASE);
174 static void _pause(void *data)
176 inputmgr_enable(EINA_FALSE);
180 static void _resume(void *data)
182 inputmgr_enable(EINA_TRUE);
186 int main(int argc, char **argv)
189 ui_app_lifecycle_callback_s cb = {
191 .terminate = _terminate,
192 .app_control = _app_control,
197 memset(&ad, 0x0, sizeof(ad));
200 ui_app_main(argc, argv, &cb, &ad);