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 <appsvc/appsvc.h>
17 #include "CicoOnScreen.h"
18 #include "CicoNotification.h"
19 #include "CicoOSPopWindow.h"
20 #include "ico_syc_type.h"
21 #include "ico_syc_appresctl.h"
22 #include "CicoOSClient.h"
24 #include "CicoSystemConfig.h"
28 //==========================================================================
30 //==========================================================================
32 //==========================================================================
34 //==========================================================================
36 //--------------------------------------------------------------------------
38 * @brief CicoOnScreen::CicoOnScreen
44 //--------------------------------------------------------------------------
45 CicoOSPopWindow::CicoOSPopWindow(notification_type_e type) : CicoNotification(type)
47 ICO_TRA("Enter type(%d)", (int)type);
53 m_buttonTouch = false;
57 CicoOSPopWindow::CicoOSPopWindow(notification_h noti) : CicoNotification(noti)
65 m_buttonTouch = false;
68 //--------------------------------------------------------------------------
70 * @brief CicoOnScreen::~CicoOnScreen
76 //--------------------------------------------------------------------------
77 CicoOSPopWindow::~CicoOSPopWindow(void)
79 ICO_TRA("Enter sur:%d, priv_id:%d", m_resourceId, GetPrivId());
80 if (NULL != m_window) {
81 ecore_evas_free(m_window);
84 // if (NULL != m_icon) /* import m_window */
86 // if (NULL != m_theme) /* import m_window */
88 if (NULL != m_context) {
89 int r = ico_syc_release_res(m_context);
90 ICO_DBG("_____ %d = ico_syc_release_res", r);
93 ICO_DBG("_____ %d, %d", (int)m_buttonTouch, (int)m_appsvc_pkgname.empty());
95 if ((true == m_buttonTouch) && (false == m_appsvc_pkgname.empty())) {
96 CicoOSClient* cosc = CicoOSClient::getInstance();
98 int r = cosc->sendLaunchMessage(m_appsvc_pkgname);
99 ICO_DBG("_____ SendMsg:%d, %s", r, m_appsvc_pkgname.c_str());
106 //--------------------------------------------------------------------------
108 * @brief CicoOnScreen::ShowPopup
114 //--------------------------------------------------------------------------
116 CicoOSPopWindow::showPopup()
119 if (NULL == m_window) {
120 if (false == InitializeWindow()) {
121 ICO_TRA("Leave false");
125 // get caller pachage name
126 const char *pkgname = GetPkgname();
129 int priv_id = GetPrivId();
132 const char *title = GetTitle();
135 const char *content = GetContent();
137 // Get execute option
138 const char *text = NULL;
139 bundle *service_handle = NULL;
140 (void)GetExecuteOption(NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, &text,
144 const char *icon = GetIconPath();
145 ICO_DBG("Received: %s : %i : %s : %s : %s : %x",
146 pkgname, priv_id, title, content,
147 text, (int)service_handle);
149 if (NULL != service_handle) {
150 const char* pn = appsvc_get_pkgname(service_handle);
152 ICO_DBG("Received: appsvc_get_pkgname:%s", pn);
153 m_appsvc_pkgname = pn;
154 m_buttonTouch = false;
159 if (NULL != m_icon) {
160 evas_object_image_file_set(m_icon, icon, NULL);
161 evas_object_show(m_icon);
166 if (!edje_object_part_text_set(m_theme, "title_text", title)) {
167 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
172 if (strlen(content) <= 25) {
173 ICO_DBG("content text center");
174 if (!edje_object_part_text_set(m_theme, "content_text_center", content)) {
175 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
177 if (!edje_object_part_text_set(m_theme, "content_text_left", "")) {
178 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
182 ICO_DBG("content text left");
183 if (!edje_object_part_text_set(m_theme, "content_text_left", content)) {
184 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
186 if (!edje_object_part_text_set(m_theme, "content_text_center", "")) {
187 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
193 if (!edje_object_part_text_set(m_theme, "button_text", text)) {
194 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
198 if (!edje_object_part_text_set(m_theme, "button_text", "OK")) {
199 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
203 evas_object_show(m_theme);
204 ICO_TRA("Leave true");
209 CicoOSPopWindow::acquireRes()
212 if (NULL != m_context) {
213 ICO_TRA("Leave false");
216 ico_syc_res_window_t w;
218 m_context = ico_syc_acquire_res( &w, NULL, NULL, ICO_SYC_RES_ONSCREEN);
219 if (NULL == m_context) {
220 ICO_TRA("Leave false");
223 ICO_TRA("Leave true");
227 //--------------------------------------------------------------------------
229 * @brief CicoOnScreen::HidePopup
232 * @param[in] data The user data passed from the callback
233 * registration function
234 * @param[in] e The handle to the popup window
235 * @param[in] obj The handle to the Evas object
236 * @param[in] event_info Event information
239 //--------------------------------------------------------------------------
241 CicoOSPopWindow::hidePopup(bool buttonTouch)
243 ICO_TRA("Enter %s", buttonTouch? "true": "false");
244 m_buttonTouch = buttonTouch;
250 CicoOSPopWindow::releaseRes()
253 if (NULL != m_context) {
254 int r = ico_syc_release_res(m_context);
255 ICO_DBG("_____ %d = ico_syc_release_res", r);
256 if (ICO_SYC_ERR_NONE == r) {
258 ICO_TRA("Leave true");
262 ICO_TRA("Leave false");
267 //--------------------------------------------------------------------------
269 * @brief CicoOnScreen::InitializePopup
270 * Initialize popup window
275 //--------------------------------------------------------------------------
277 CicoOSPopWindow::InitializeWindow(void)
280 if (false == createMainWindow()) {
281 ICO_TRA("Leave(ERR)");
284 m_theme = edje_object_add(ecore_evas_get(m_window));
285 if (NULL == m_theme) {
286 ICO_ERR("could not create edje object!");
287 ICO_TRA("Leave(ERR)");
290 if (!edje_object_file_set(m_theme, ICO_OS_THEMES_EDJ_FILEPATH, "main")) {
291 Edje_Load_Error err = edje_object_load_error_get(m_theme);
292 const char *errmsg = edje_load_error_str(err);
293 ICO_ERR("could not load 'main' from onscreen.edj: %s", errmsg);
294 evas_object_del(m_theme);
299 m_icon = evas_object_image_filled_add(ecore_evas_get(m_window));
300 edje_object_part_swallow(m_theme, "icon", m_icon);
301 /* getting size of screen */
302 /* home screen size is full of display*/
303 int display_width = 0;
304 int display_height = 0;
305 ecore_wl_screen_size_get(&display_width, &display_height);
307 ICO_DBG("display size w/h=%d/%d", display_width, display_height);
309 #if 1 /* 2014/07/16 ecore_wl_screen_size_get() bug */
310 if ((display_width <= 0) || (display_height <= 0)) {
311 const CicoSCDisplayConf* dispconf = CicoSystemConfig::getInstance()
312 ->findDisplayConfbyId(0);
314 // if Ecore has no full screen size, get from configuration
315 display_width = dispconf->width;
316 display_height = dispconf->height;
317 ICO_DBG("Screen size w/h=%d/%d from Config", display_width, display_height);
320 // if Ecore and config has no full screen size, fixed vaule
321 display_width = 1080;
322 display_height = 1920;
323 ICO_DBG("Screen size w/h=1080/1920 fixed");
326 #endif /* 2014/07/16 ecore_wl_screen_size_get() bug */
328 int popup_x = (display_width / 2) - (POPUP_FRAME_WIDTH / 2);
329 int popup_y = (display_height / 2) - (POPUP_FRAME_HEIGHT/ 2);
330 ICO_DBG("popup postion x/y=%d/%d", popup_x, popup_y);
331 evas_object_move(m_theme, popup_x, popup_y);
332 evas_object_resize(m_theme, POPUP_FRAME_WIDTH, POPUP_FRAME_HEIGHT);
334 Evas_Object* obj = NULL;
335 obj = (Evas_Object*)edje_object_part_object_get(m_theme, "button_text");
337 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
338 evasMouseUpCB, this);
341 obj = (Evas_Object*)edje_object_part_object_get(m_theme, "button");
343 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
344 evasMouseUpCB, this);
346 evas_object_show(m_theme);
347 ICO_TRA("Leave(OK)");
352 CicoOSPopWindow::createMainWindow()
356 m_window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, "frame=0");
357 if (NULL == m_window) {
358 ICO_ERR("ecore_evas_new() error");
359 ICO_TRA("Leave(ERR)");
362 ecore_evas_alpha_set(m_window, EINA_TRUE);
363 ecore_evas_show(m_window);
368 //--------------------------------------------------------------------------
370 * @brief callback function of evas mouse up event
372 * @param [in] data The user data passed from the callback
373 * registration function
374 * @param [in] e The handle to the popup window
375 * @param [in] obj The handle to the Evas object
376 * @param [in] event_info Event information
379 //--------------------------------------------------------------------------
381 CicoOSPopWindow::evasMouseUpCB(void *data, Evas *e, Evas_Object *obj,
384 ICO_TRA("Enter %x, %x, %x, %x", data, e, obj, event_info);
386 ICO_DBG("_____ obj name=%s", evas_object_name_get(obj));
388 static_cast<CicoOSPopWindow*>(data)->hidePopup(true);
393 static char id0_ECU[] = "Center";
395 static char id00_display[] = "Center";
396 // static char id01_display[] = "Mid";
398 // static char id001_layer[] = "Application";
399 // static char id002_layer[] = "SoftKeyboard";
400 // static char id003_layer[] = "HomeScreen";
401 // static char id004_layer[] = "ControlBar";
402 // static char id005_layer[] = "InterruptApp";
403 static char id006_layer[] = "OnScreen";
404 // static char id007_layer[] = "Touch";
405 // static char id008_layer[] = "Cursor";
406 // static char id011_layer[] = "MainApp";
407 // static char id012_layer[] = "SubDispMainApp";
408 // static char id013_layer[] = "SubDispSubApp";
410 static char id00611_layout[] = "Whole";
411 // static char id00612_layout[] = "Half";
413 static char id006111_area[] = "Full";
414 // static char id006121_area[] = "Upper";
415 // static char id006122_area[] = "Lower";
417 static char role_incoming[] = "incoming";
418 static char role_message[] = "message";
420 CicoOSPopWindow::makeResWindowT(ico_syc_res_window_t& w)
423 w.display = id00_display;
424 w.layer = id006_layer;
425 w.layout = id00611_layout;
426 w.area = id006111_area;
427 w.dispatchApp = (char*)GetPkgname();
428 if (0 == strcmp(w.dispatchApp,"org.tizen.dialer")) {
429 w.role = role_incoming;
432 w.role = role_message;
434 w.resourceId = m_resourceId;
437 // vim: set expandtab ts=4 sw=4: