2 * Copyright (c) 2014, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @brief On Screen Popup Window
15 #include <Ecore_Wayland.h>
16 #include "CicoOnScreen.h"
17 #include "CicoNotification.h"
18 #include "CicoOSPopWindow.h"
19 #include "ico_syc_type.h"
20 #include "ico_syc_appresctl.h"
24 //==========================================================================
26 //==========================================================================
28 //==========================================================================
30 //==========================================================================
32 //--------------------------------------------------------------------------
34 * @brief CicoOnScreen::CicoOnScreen
40 //--------------------------------------------------------------------------
41 CicoOSPopWindow::CicoOSPopWindow(notification_type_e type) : CicoNotification(type)
43 ICO_TRA("Enter type(%d)", (int)type);
52 CicoOSPopWindow::CicoOSPopWindow(notification_h noti) : CicoNotification(noti)
62 //--------------------------------------------------------------------------
64 * @brief CicoOnScreen::~CicoOnScreen
70 //--------------------------------------------------------------------------
71 CicoOSPopWindow::~CicoOSPopWindow(void)
74 if (NULL != m_window) {
75 ecore_evas_free(m_window);
78 // if (NULL != m_icon) /* import m_window */
80 // if (NULL != m_theme) /* import m_window */
82 if (NULL != m_context) {
83 int r = ico_syc_release_res(m_context);
84 ICO_DBG("_____ %d = ico_syc_release_res", r);
90 //--------------------------------------------------------------------------
92 * @brief CicoOnScreen::ShowPopup
98 //--------------------------------------------------------------------------
100 CicoOSPopWindow::showPopup()
103 if (NULL == m_window) {
104 if (false == InitializeWindow()) {
105 ICO_TRA("Leave false");
109 // get caller pachage name
110 const char *pkgname = GetPkgname();
113 int priv_id = GetPrivId();
116 const char *title = GetTitle();
119 const char *content = GetContent();
121 // Get execute option
122 const char *text = NULL;
123 bundle *service_handle = NULL;
124 (void)GetExecuteOption(NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, &text,
128 const char *icon = GetIconPath();
129 ICO_DBG("Received: %s : %i : %s : %s : %s : %x",
130 pkgname, priv_id, title, content,
131 text, (int)service_handle);
134 if (NULL != m_icon) {
135 evas_object_image_file_set(m_icon, icon, NULL);
136 evas_object_show(m_icon);
141 if (!edje_object_part_text_set(m_theme, "title_text", title)) {
142 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
147 if (strlen(content) <= 25) {
148 ICO_DBG("content text center");
149 if (!edje_object_part_text_set(m_theme, "content_text_center", content)) {
150 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
152 if (!edje_object_part_text_set(m_theme, "content_text_left", "")) {
153 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
157 ICO_DBG("content text left");
158 if (!edje_object_part_text_set(m_theme, "content_text_left", content)) {
159 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
161 if (!edje_object_part_text_set(m_theme, "content_text_center", "")) {
162 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
168 if (!edje_object_part_text_set(m_theme, "button_text", text)) {
169 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
173 if (!edje_object_part_text_set(m_theme, "button_text", "OK")) {
174 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
178 evas_object_show(m_theme);
179 ICO_TRA("Leave true");
184 CicoOSPopWindow::acquireRes()
187 if (NULL != m_context) {
188 ICO_TRA("Leave false");
191 ico_syc_res_window_t w;
193 m_context = ico_syc_acquire_res( &w, NULL, NULL, ICO_SYC_RES_ONSCREEN);
194 if (NULL == m_context) {
195 ICO_TRA("Leave false");
198 ICO_TRA("Leave true");
202 //--------------------------------------------------------------------------
204 * @brief CicoOnScreen::HidePopup
207 * @param[in] data The user data passed from the callback
208 * registration function
209 * @param[in] e The handle to the popup window
210 * @param[in] obj The handle to the Evas object
211 * @param[in] event_info Event information
214 //--------------------------------------------------------------------------
216 CicoOSPopWindow::hidePopup(void)
225 CicoOSPopWindow::releaseRes()
228 if (NULL != m_context) {
229 int r = ico_syc_release_res(m_context);
230 ICO_DBG("_____ %d = ico_syc_release_res", r);
231 if (ICO_SYC_ERR_NONE == r) {
233 ICO_TRA("Leave true");
237 ICO_TRA("Leave false");
242 //--------------------------------------------------------------------------
244 * @brief CicoOnScreen::InitializePopup
245 * Initialize popup window
250 //--------------------------------------------------------------------------
252 CicoOSPopWindow::InitializeWindow(void)
256 m_window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, "frame=0");
257 if (NULL == m_window) {
258 ICO_ERR("ecore_evas_new() error");
259 ICO_TRA("Leave(ERR)");
262 ecore_evas_show(m_window);
263 m_theme = edje_object_add(ecore_evas_get(m_window));
264 if (NULL == m_theme) {
265 ICO_ERR("could not create edje object!");
266 ICO_TRA("Leave(ERR)");
269 if (!edje_object_file_set(m_theme, ICO_OS_THEMES_EDJ_FILEPATH, "main")) {
270 Edje_Load_Error err = edje_object_load_error_get(m_theme);
271 const char *errmsg = edje_load_error_str(err);
272 ICO_ERR("could not load 'main' from onscreen.edj: %s", errmsg);
273 evas_object_del(m_theme);
278 m_icon = evas_object_image_filled_add(ecore_evas_get(m_window));
279 edje_object_part_swallow(m_theme, "icon", m_icon);
280 /* getting size of screen */
281 /* home screen size is full of display*/
282 int display_width = 0;
283 int display_height = 0;
284 ecore_wl_screen_size_get(&display_width, &display_height);
286 ICO_DBG("display size w/h=%d/%d", display_width, display_height);
287 int popup_x = (display_width / 2) - (POPUP_FRAME_WIDTH / 2);
288 int popup_y = (display_height / 2) - (POPUP_FRAME_HEIGHT/ 2);
289 ICO_DBG("popup postion x/y=%d/%d", popup_x, popup_y);
290 evas_object_move(m_theme, popup_x, popup_y);
291 evas_object_resize(m_theme, POPUP_FRAME_WIDTH, POPUP_FRAME_HEIGHT);
293 Evas_Object* obj = NULL;
294 obj = (Evas_Object*)edje_object_part_object_get(m_theme, "button_text");
296 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
297 evasMouseUpCB, this);
300 obj = (Evas_Object*)edje_object_part_object_get(m_theme, "button");
302 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
303 evasMouseUpCB, this);
305 evas_object_show(m_theme);
306 ICO_TRA("Leave(OK)");
310 //--------------------------------------------------------------------------
312 * @brief callback function of evas mouse up event
314 * @param [in] data The user data passed from the callback
315 * registration function
316 * @param [in] e The handle to the popup window
317 * @param [in] obj The handle to the Evas object
318 * @param [in] event_info Event information
321 //--------------------------------------------------------------------------
323 CicoOSPopWindow::evasMouseUpCB(void *data, Evas *e, Evas_Object *obj,
326 ICO_TRA("Enter %x, %x, %x, %x", data, e, obj, event_info);
328 ICO_DBG("_____ obj name=%s", evas_object_name_get(obj));
330 static_cast<CicoOSPopWindow*>(data)->hidePopup();
335 static char id0_ECU[] = "Center";
337 static char id00_display[] = "Center";
338 // static char id01_display[] = "Mid";
340 // static char id001_layer[] = "Application";
341 // static char id002_layer[] = "SoftKeyboard";
342 // static char id003_layer[] = "HomeScreen";
343 // static char id004_layer[] = "ControlBar";
344 // static char id005_layer[] = "InterruptApp";
345 static char id006_layer[] = "OnScreen";
346 // static char id007_layer[] = "Touch";
347 // static char id008_layer[] = "Cursor";
348 // static char id011_layer[] = "MainApp";
349 // static char id012_layer[] = "SubDispMainApp";
350 // static char id013_layer[] = "SubDispSubApp";
352 static char id00611_layout[] = "Whole";
353 // static char id00612_layout[] = "Half";
355 static char id006111_area[] = "Full";
356 // static char id006121_area[] = "Upper";
357 // static char id006122_area[] = "Lower";
359 static char role_incoming[] = "incoming";
360 static char role_message[] = "message";
362 CicoOSPopWindow::makeResWindowT(ico_syc_res_window_t& w)
365 w.display = id00_display;
366 w.layer = id006_layer;
367 w.layout = id00611_layout;
368 w.area = id006111_area;
369 w.dispatchApp = (char*)GetPkgname();
370 if (0 == strcmp(w.dispatchApp,"org.tizen.dialer")) {
371 w.role = role_incoming;
374 w.role = role_message;
376 w.resourceId = m_resourceId;
379 // vim: set expandtab ts=4 sw=4: