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)
73 ICO_TRA("Enter sur:%d, priv_id:%d", m_resourceId, GetPrivId());
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)
255 if (false == createMainWindow()) {
256 ICO_TRA("Leave(ERR)");
259 m_theme = edje_object_add(ecore_evas_get(m_window));
260 if (NULL == m_theme) {
261 ICO_ERR("could not create edje object!");
262 ICO_TRA("Leave(ERR)");
265 if (!edje_object_file_set(m_theme, ICO_OS_THEMES_EDJ_FILEPATH, "main")) {
266 Edje_Load_Error err = edje_object_load_error_get(m_theme);
267 const char *errmsg = edje_load_error_str(err);
268 ICO_ERR("could not load 'main' from onscreen.edj: %s", errmsg);
269 evas_object_del(m_theme);
274 m_icon = evas_object_image_filled_add(ecore_evas_get(m_window));
275 edje_object_part_swallow(m_theme, "icon", m_icon);
276 /* getting size of screen */
277 /* home screen size is full of display*/
278 int display_width = 0;
279 int display_height = 0;
280 ecore_wl_screen_size_get(&display_width, &display_height);
282 ICO_DBG("display size w/h=%d/%d", display_width, display_height);
283 int popup_x = (display_width / 2) - (POPUP_FRAME_WIDTH / 2);
284 int popup_y = (display_height / 2) - (POPUP_FRAME_HEIGHT/ 2);
285 ICO_DBG("popup postion x/y=%d/%d", popup_x, popup_y);
286 evas_object_move(m_theme, popup_x, popup_y);
287 evas_object_resize(m_theme, POPUP_FRAME_WIDTH, POPUP_FRAME_HEIGHT);
289 Evas_Object* obj = NULL;
290 obj = (Evas_Object*)edje_object_part_object_get(m_theme, "button_text");
292 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
293 evasMouseUpCB, this);
296 obj = (Evas_Object*)edje_object_part_object_get(m_theme, "button");
298 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
299 evasMouseUpCB, this);
301 evas_object_show(m_theme);
302 ICO_TRA("Leave(OK)");
307 CicoOSPopWindow::createMainWindow()
311 m_window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, "frame=0");
312 if (NULL == m_window) {
313 ICO_ERR("ecore_evas_new() error");
314 ICO_TRA("Leave(ERR)");
317 ecore_evas_show(m_window);
322 //--------------------------------------------------------------------------
324 * @brief callback function of evas mouse up event
326 * @param [in] data The user data passed from the callback
327 * registration function
328 * @param [in] e The handle to the popup window
329 * @param [in] obj The handle to the Evas object
330 * @param [in] event_info Event information
333 //--------------------------------------------------------------------------
335 CicoOSPopWindow::evasMouseUpCB(void *data, Evas *e, Evas_Object *obj,
338 ICO_TRA("Enter %x, %x, %x, %x", data, e, obj, event_info);
340 ICO_DBG("_____ obj name=%s", evas_object_name_get(obj));
342 static_cast<CicoOSPopWindow*>(data)->hidePopup();
347 static char id0_ECU[] = "Center";
349 static char id00_display[] = "Center";
350 // static char id01_display[] = "Mid";
352 // static char id001_layer[] = "Application";
353 // static char id002_layer[] = "SoftKeyboard";
354 // static char id003_layer[] = "HomeScreen";
355 // static char id004_layer[] = "ControlBar";
356 // static char id005_layer[] = "InterruptApp";
357 static char id006_layer[] = "OnScreen";
358 // static char id007_layer[] = "Touch";
359 // static char id008_layer[] = "Cursor";
360 // static char id011_layer[] = "MainApp";
361 // static char id012_layer[] = "SubDispMainApp";
362 // static char id013_layer[] = "SubDispSubApp";
364 static char id00611_layout[] = "Whole";
365 // static char id00612_layout[] = "Half";
367 static char id006111_area[] = "Full";
368 // static char id006121_area[] = "Upper";
369 // static char id006122_area[] = "Lower";
371 static char role_incoming[] = "incoming";
372 static char role_message[] = "message";
374 CicoOSPopWindow::makeResWindowT(ico_syc_res_window_t& w)
377 w.display = id00_display;
378 w.layer = id006_layer;
379 w.layout = id00611_layout;
380 w.area = id006111_area;
381 w.dispatchApp = (char*)GetPkgname();
382 if (0 == strcmp(w.dispatchApp,"org.tizen.dialer")) {
383 w.role = role_incoming;
386 w.role = role_message;
388 w.resourceId = m_resourceId;
391 // vim: set expandtab ts=4 sw=4: