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"
26 //==========================================================================
28 //==========================================================================
30 //==========================================================================
32 //==========================================================================
34 //--------------------------------------------------------------------------
36 * @brief CicoOnScreen::CicoOnScreen
42 //--------------------------------------------------------------------------
43 CicoOSPopWindow::CicoOSPopWindow(notification_type_e type) : CicoNotification(type)
45 ICO_TRA("Enter type(%d)", (int)type);
51 m_buttonTouch = false;
55 CicoOSPopWindow::CicoOSPopWindow(notification_h noti) : CicoNotification(noti)
63 m_buttonTouch = false;
66 //--------------------------------------------------------------------------
68 * @brief CicoOnScreen::~CicoOnScreen
74 //--------------------------------------------------------------------------
75 CicoOSPopWindow::~CicoOSPopWindow(void)
77 ICO_TRA("Enter sur:%d, priv_id:%d", m_resourceId, GetPrivId());
78 if (NULL != m_window) {
79 ecore_evas_free(m_window);
82 // if (NULL != m_icon) /* import m_window */
84 // if (NULL != m_theme) /* import m_window */
86 if (NULL != m_context) {
87 int r = ico_syc_release_res(m_context);
88 ICO_DBG("_____ %d = ico_syc_release_res", r);
91 ICO_DBG("_____ %d, %d", (int)m_buttonTouch, (int)m_appsvc_pkgname.empty());
93 if ((true == m_buttonTouch) && (false == m_appsvc_pkgname.empty())) {
94 CicoOSClient* cosc = CicoOSClient::getInstance();
96 int r = cosc->sendLaunchMessage(m_appsvc_pkgname);
97 ICO_DBG("_____ SendMsg:%d, %s", r, m_appsvc_pkgname.c_str());
104 //--------------------------------------------------------------------------
106 * @brief CicoOnScreen::ShowPopup
112 //--------------------------------------------------------------------------
114 CicoOSPopWindow::showPopup()
117 if (NULL == m_window) {
118 if (false == InitializeWindow()) {
119 ICO_TRA("Leave false");
123 // get caller pachage name
124 const char *pkgname = GetPkgname();
127 int priv_id = GetPrivId();
130 const char *title = GetTitle();
133 const char *content = GetContent();
135 // Get execute option
136 const char *text = NULL;
137 bundle *service_handle = NULL;
138 (void)GetExecuteOption(NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, &text,
142 const char *icon = GetIconPath();
143 ICO_DBG("Received: %s : %i : %s : %s : %s : %x",
144 pkgname, priv_id, title, content,
145 text, (int)service_handle);
147 if (NULL != service_handle) {
148 const char* pn = appsvc_get_pkgname(service_handle);
150 ICO_DBG("Received: appsvc_get_pkgname:%s", pn);
151 m_appsvc_pkgname = pn;
152 m_buttonTouch = false;
157 if (NULL != m_icon) {
158 evas_object_image_file_set(m_icon, icon, NULL);
159 evas_object_show(m_icon);
164 if (!edje_object_part_text_set(m_theme, "title_text", title)) {
165 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
170 if (strlen(content) <= 25) {
171 ICO_DBG("content text center");
172 if (!edje_object_part_text_set(m_theme, "content_text_center", content)) {
173 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
175 if (!edje_object_part_text_set(m_theme, "content_text_left", "")) {
176 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
180 ICO_DBG("content text left");
181 if (!edje_object_part_text_set(m_theme, "content_text_left", content)) {
182 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
184 if (!edje_object_part_text_set(m_theme, "content_text_center", "")) {
185 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
191 if (!edje_object_part_text_set(m_theme, "button_text", text)) {
192 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
196 if (!edje_object_part_text_set(m_theme, "button_text", "OK")) {
197 ICO_WRN("could not set the text. Maybe part 'text' does not exist?");
201 evas_object_show(m_theme);
202 ICO_TRA("Leave true");
207 CicoOSPopWindow::acquireRes()
210 if (NULL != m_context) {
211 ICO_TRA("Leave false");
214 ico_syc_res_window_t w;
216 m_context = ico_syc_acquire_res( &w, NULL, NULL, ICO_SYC_RES_ONSCREEN);
217 if (NULL == m_context) {
218 ICO_TRA("Leave false");
221 ICO_TRA("Leave true");
225 //--------------------------------------------------------------------------
227 * @brief CicoOnScreen::HidePopup
230 * @param[in] data The user data passed from the callback
231 * registration function
232 * @param[in] e The handle to the popup window
233 * @param[in] obj The handle to the Evas object
234 * @param[in] event_info Event information
237 //--------------------------------------------------------------------------
239 CicoOSPopWindow::hidePopup(bool buttonTouch)
241 ICO_TRA("Enter %s", buttonTouch? "true": "false");
242 m_buttonTouch = buttonTouch;
248 CicoOSPopWindow::releaseRes()
251 if (NULL != m_context) {
252 int r = ico_syc_release_res(m_context);
253 ICO_DBG("_____ %d = ico_syc_release_res", r);
254 if (ICO_SYC_ERR_NONE == r) {
256 ICO_TRA("Leave true");
260 ICO_TRA("Leave false");
265 //--------------------------------------------------------------------------
267 * @brief CicoOnScreen::InitializePopup
268 * Initialize popup window
273 //--------------------------------------------------------------------------
275 CicoOSPopWindow::InitializeWindow(void)
278 if (false == createMainWindow()) {
279 ICO_TRA("Leave(ERR)");
282 m_theme = edje_object_add(ecore_evas_get(m_window));
283 if (NULL == m_theme) {
284 ICO_ERR("could not create edje object!");
285 ICO_TRA("Leave(ERR)");
288 if (!edje_object_file_set(m_theme, ICO_OS_THEMES_EDJ_FILEPATH, "main")) {
289 Edje_Load_Error err = edje_object_load_error_get(m_theme);
290 const char *errmsg = edje_load_error_str(err);
291 ICO_ERR("could not load 'main' from onscreen.edj: %s", errmsg);
292 evas_object_del(m_theme);
297 m_icon = evas_object_image_filled_add(ecore_evas_get(m_window));
298 edje_object_part_swallow(m_theme, "icon", m_icon);
299 /* getting size of screen */
300 /* home screen size is full of display*/
301 int display_width = 0;
302 int display_height = 0;
303 ecore_wl_screen_size_get(&display_width, &display_height);
305 ICO_DBG("display size w/h=%d/%d", display_width, display_height);
306 int popup_x = (display_width / 2) - (POPUP_FRAME_WIDTH / 2);
307 int popup_y = (display_height / 2) - (POPUP_FRAME_HEIGHT/ 2);
308 ICO_DBG("popup postion x/y=%d/%d", popup_x, popup_y);
309 evas_object_move(m_theme, popup_x, popup_y);
310 evas_object_resize(m_theme, POPUP_FRAME_WIDTH, POPUP_FRAME_HEIGHT);
312 Evas_Object* obj = NULL;
313 obj = (Evas_Object*)edje_object_part_object_get(m_theme, "button_text");
315 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
316 evasMouseUpCB, this);
319 obj = (Evas_Object*)edje_object_part_object_get(m_theme, "button");
321 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
322 evasMouseUpCB, this);
324 evas_object_show(m_theme);
325 ICO_TRA("Leave(OK)");
330 CicoOSPopWindow::createMainWindow()
334 m_window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, "frame=0");
335 if (NULL == m_window) {
336 ICO_ERR("ecore_evas_new() error");
337 ICO_TRA("Leave(ERR)");
340 ecore_evas_alpha_set(m_window, EINA_TRUE);
341 ecore_evas_show(m_window);
346 //--------------------------------------------------------------------------
348 * @brief callback function of evas mouse up event
350 * @param [in] data The user data passed from the callback
351 * registration function
352 * @param [in] e The handle to the popup window
353 * @param [in] obj The handle to the Evas object
354 * @param [in] event_info Event information
357 //--------------------------------------------------------------------------
359 CicoOSPopWindow::evasMouseUpCB(void *data, Evas *e, Evas_Object *obj,
362 ICO_TRA("Enter %x, %x, %x, %x", data, e, obj, event_info);
364 ICO_DBG("_____ obj name=%s", evas_object_name_get(obj));
366 static_cast<CicoOSPopWindow*>(data)->hidePopup(true);
371 static char id0_ECU[] = "Center";
373 static char id00_display[] = "Center";
374 // static char id01_display[] = "Mid";
376 // static char id001_layer[] = "Application";
377 // static char id002_layer[] = "SoftKeyboard";
378 // static char id003_layer[] = "HomeScreen";
379 // static char id004_layer[] = "ControlBar";
380 // static char id005_layer[] = "InterruptApp";
381 static char id006_layer[] = "OnScreen";
382 // static char id007_layer[] = "Touch";
383 // static char id008_layer[] = "Cursor";
384 // static char id011_layer[] = "MainApp";
385 // static char id012_layer[] = "SubDispMainApp";
386 // static char id013_layer[] = "SubDispSubApp";
388 static char id00611_layout[] = "Whole";
389 // static char id00612_layout[] = "Half";
391 static char id006111_area[] = "Full";
392 // static char id006121_area[] = "Upper";
393 // static char id006122_area[] = "Lower";
395 static char role_incoming[] = "incoming";
396 static char role_message[] = "message";
398 CicoOSPopWindow::makeResWindowT(ico_syc_res_window_t& w)
401 w.display = id00_display;
402 w.layer = id006_layer;
403 w.layout = id00611_layout;
404 w.area = id006111_area;
405 w.dispatchApp = (char*)GetPkgname();
406 if (0 == strcmp(w.dispatchApp,"org.tizen.dialer")) {
407 w.role = role_incoming;
410 w.role = role_message;
412 w.resourceId = m_resourceId;
415 // vim: set expandtab ts=4 sw=4: