From: hoejoo lee Date: Thu, 11 Jun 2015 05:48:48 +0000 (+0900) Subject: merge from 2.4 , block compile error X-Git-Tag: submit/tizen_mobile/20150623.021839 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Fsubmit%2Ftizen_mobile%2F20150623.021839;p=apps%2Fcore%2Fpreloaded%2Fquickpanel.git merge from 2.4 , block compile error Change-Id: I2408a20ba7ce2de87ec104341cdb6cb2923017e8 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c09a7b..229c91d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(quickpanel C) -FILE(GLOB_RECURSE DAEMON_SRCS daemon/*.c) -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/test TEST_SRCS) -SET(SRCS ${DAEMON_SRCS} ${TEST_SRCS}) - SET(VENDOR "org.tizen") SET(PACKAGE ${PROJECT_NAME}) SET(PKGNAME "${VENDOR}.${PACKAGE}") @@ -15,8 +11,10 @@ SET(LOCALEDIR "${RESDIR}/locale") SET(ICONDIR "${RESDIR}/icons") SET(EDJDIR "${RESDIR}/edje") SET(DATADIR "${PREFIX}/data") +SET(DATADIR_RW "${PREFIX_RW}/data") SET(DESKTOPDIR "/usr/share/applications") SET(MANIFESTXMLDIR "/usr/share/packages") +SET(SHARED_DIR "${PREFIX}/shared/res") IF("${CMAKE_BUILD_TYPE}" STREQUAL "") SET(CMAKE_BUILD_TYPE "Release") @@ -25,46 +23,77 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/daemon + ${CMAKE_CURRENT_SOURCE_DIR}/daemon/minictrl ${CMAKE_CURRENT_SOURCE_DIR}/daemon/notifications ${CMAKE_CURRENT_SOURCE_DIR}/daemon/service + ${CMAKE_CURRENT_SOURCE_DIR}/daemon/settings + ${CMAKE_CURRENT_SOURCE_DIR}/daemon/settings/modules + ${CMAKE_CURRENT_SOURCE_DIR}/daemon/vi + ${CMAKE_CURRENT_SOURCE_DIR}/daemon/page + ${CMAKE_CURRENT_SOURCE_DIR}/daemon/datetime ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_SOURCE_DIR}/test ) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED + +IF(X11_SUPPORT) +pkg_check_modules(extra_pkgs REQUIRED + ecore-x + x11 + xi + utilX + inputproto +) +ENDIF(X11_SUPPORT) + +IF(WAYLAND_SUPPORT) +pkg_check_modules(extra_pkgs REQUIRED + ecore-wayland +) +ENDIF(WAYLAND_SUPPORT) + +pkg_check_modules(pkgs REQUIRED capi-appfw-application - capi-appfw-app-manager capi-system-runtime-info capi-system-info capi-system-device capi-network-tethering + capi-network-bluetooth + capi-network-connection + capi-network-wifi capi-media-player + capi-media-sound-manager + capi-media-metadata-extractor + capi-system-system-settings + capi-base-utils-i18n + capi-ui-efl-util + tapi feedback appcore-common notification + badge vconf - appsvc - devman_haptic libprivilege-control - ecore-x edbus evas ecore edje ecore-input icu-i18n - enotify elementary + efl-assist dlog syspopup-caller minicontrol-viewer minicontrol-monitor - utilX -# deviced + pkgmgr + pkgmgr-info + iniparser + alarm-service ) -FOREACH(flag ${pkgs_CFLAGS}) +FOREACH(flag ${pkgs_CFLAGS} ${extra_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) @@ -79,13 +108,18 @@ IF("${ARCH}" STREQUAL "arm") MESSAGE("add -DTARGET") ENDIF("${ARCH}" STREQUAL "arm") -ADD_DEFINITIONS("-fpie") -ADD_DEFINITIONS("-DQP_INDICATOR_WIDGET_ENABLE") -ADD_DEFINITIONS("-DQP_BRIGHTNESS_ENABLE") -ADD_DEFINITIONS("-DQP_MINICTRL_ENABLE") -ADD_DEFINITIONS("-DQP_ANIMATED_IMAGE_ENABLE") -#ADD_DEFINITIONS("-DQP_SERVICE_NOTI_LED_ENABLE") - +IF("${VENDOR}" STREQUAL "org.tizen") + ADD_DEFINITIONS("-DQP_SETTING_ENABLE") + ADD_DEFINITIONS("-DQP_BRIGHTNESS_ENABLE") + ADD_DEFINITIONS("-DQP_MINICTRL_ENABLE") + ADD_DEFINITIONS("-DQP_SCREENREADER_ENABLE") + ADD_DEFINITIONS("-DQP_SMART_ALERT_ENABLE") + ADD_DEFINITIONS("-DQP_SERVICE_NOTI_LED_ENABLE") + ADD_DEFINITIONS("-DQP_ANIMATED_IMAGE_ENABLE") + ADD_DEFINITIONS("-DQP_REMINDER_ENABLE") + ADD_DEFINITIONS("-DQP_EMERGENCY_MODE_ENABLE") +ENDIF("${VENDOR}" STREQUAL "org.tizen") +MESSAGE("##### VENDOR: ${VENDOR}") ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"") ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") @@ -96,21 +130,123 @@ ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"") ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"") ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"") - +ADD_DEFINITIONS("-DDATADIR_RW=\"${DATADIR_RW}\"") +ADD_DEFINITIONS("-DSHARED_DIR=\"${SHARED_DIR}\"") #ADD_DEFINITIONS("-DFILE_DEBUG") ADD_DEFINITIONS("-D_DLOG_USED") + +SET(BUILD_COMMON_SOURCE + ${BUILD_COMMON_SOURCE} + daemon/accessibility.c + daemon/common.c + daemon/datetime/datetime.c + daemon/datetime/util-time.c + daemon/dbus_utility.c + daemon/device/brightness.c + daemon/handler_controller.c + daemon/list_util.c + daemon/media.c + daemon/minictrl/minictrl.c + daemon/modules.c + daemon/notifications/activenoti.c + daemon/notifications/animated_image.c + daemon/notifications/noti_box.c + daemon/notifications/noti.c + daemon/notifications/noti_gridbox.c + daemon/notifications/noti_listbox.c + daemon/notifications/noti_list_item.c + daemon/notifications/noti_node.c + daemon/notifications/noti_section.c + daemon/notifications/noti_util.c + daemon/notifications/noti_view_boxtype.c + daemon/notifications/noti_view.c + daemon/notifications/noti_view_listype.c + daemon/notifications/noti_view_ongoing.c + daemon/page/page_base.c + daemon/page/page_edit.c + daemon/page/pager.c + daemon/page/page_setting_all.c + daemon/preference.c + daemon/service/animated_icon.c + daemon/service/configuration.c + daemon/service/emergency_mode.c + daemon/service/keyboard.c + daemon/service/noti_led.c + daemon/service/reminder.c + daemon/service/smart_alert.c + daemon/service/uninstall.c + daemon/settings/modules/assistive_light.c + daemon/settings/modules/bluetooth.c + daemon/settings/modules/flightmode.c + daemon/settings/modules/gps.c + daemon/settings/modules/mobile_data.c + daemon/settings/modules/rotate-lock.c + daemon/settings/modules/sound-profile.c + daemon/settings/modules/tethering.c + daemon/settings/modules/ultra_power_saving.c + daemon/settings/modules/wifi.c + daemon/settings/setting_module_api.c + daemon/settings/settings.c + daemon/settings/settings_gridbox.c + daemon/settings/settings_icon_common.c + daemon/settings/settings_ipc.c + daemon/settings/settings_view_all.c + daemon/settings/settings_view_featured.c + daemon/sim_controller.c + daemon/vi/vi_manager.c +) + +IF(X11_SUPPORT) ADD_DEFINITIONS("-DHAVE_X") +SET(BUILD_SOURCE + ${BUILD_SOURCE} + daemon/common_uic_x11.c + daemon/notifications/noti_win_x11.c + daemon/page/pager_common_x11.c + daemon/quickpanel-ui_x11.c + daemon/service/keyboard_x_x11.c + daemon/settings/setting_utils_x11.c +) +ENDIF(X11_SUPPORT) + +IF(WAYLAND_SUPPORT) +ADD_DEFINITIONS("-DHAVE_WAYLAND") +SET(BUILD_SOURCE + ${BUILD_SOURCE} + daemon/common_uic.c + daemon/notifications/noti_win.c + daemon/page/pager_common.c + daemon/quickpanel-ui.c + daemon/service/keyboard_x.c + daemon/settings/setting_utils.c +) +ENDIF(WAYLAND_SUPPORT) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/test TEST_SRCS) + +SET(SRCS ${BUILD_COMMON_SOURCE} ${BUILD_SOURCE} ${TEST_SRCS}) SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") + ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-pie") -#-lefence +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${extra_pkgs_LDFLAGS} "-pie") +#-lefence INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) -INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/icons DESTINATION ${RESDIR}) INSTALL(DIRECTORY DESTINATION ${DATADIR}) +INSTALL(DIRECTORY DESTINATION ${DATADIR_RW}) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/icons/quickpanel_icon_default.png DESTINATION ${RESDIR}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PKGNAME}.efl DESTINATION /etc/smack/accesses.d) + +# icon for setting +INSTALL(FILES ${CMAKE_SOURCE_DIR}/icons/settings_noti_panel.png DESTINATION ${SHARED_DIR}/icons) + +# icons for notification +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/data/images_noti_icons/ DESTINATION ${SHARED_DIR}/noti_icons FILES_MATCHING PATTERN "*.png") + +# License +INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME ${PKGNAME}) # i18n ADD_SUBDIRECTORY(data) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..54b213e --- /dev/null +++ b/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/LICENSE.Flora b/LICENSE.Flora deleted file mode 100644 index 571fe79..0000000 --- a/LICENSE.Flora +++ /dev/null @@ -1,206 +0,0 @@ -Flora License - -Version 1.1, April, 2013 - -http://floralicense.org/license/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, -and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by -the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and -all other entities that control, are controlled by, or are -under common control with that entity. For the purposes of -this definition, "control" means (i) the power, direct or indirect, -to cause the direction or management of such entity, -whether by contract or otherwise, or (ii) ownership of fifty percent (50%) -or more of the outstanding shares, or (iii) beneficial ownership of -such entity. - -"You" (or "Your") shall mean an individual or Legal Entity -exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, -including but not limited to software source code, documentation source, -and configuration files. - -"Object" form shall mean any form resulting from mechanical -transformation or translation of a Source form, including but -not limited to compiled object code, generated documentation, -and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, -made available under the License, as indicated by a copyright notice -that is included in or attached to the work (an example is provided -in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, -that is based on (or derived from) the Work and for which the editorial -revisions, annotations, elaborations, or other modifications represent, -as a whole, an original work of authorship. For the purposes of this License, -Derivative Works shall not include works that remain separable from, -or merely link (or bind by name) to the interfaces of, the Work and -Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original -version of the Work and any modifications or additions to that Work or -Derivative Works thereof, that is intentionally submitted to Licensor -for inclusion in the Work by the copyright owner or by an individual or -Legal Entity authorized to submit on behalf of the copyright owner. -For the purposes of this definition, "submitted" means any form of -electronic, verbal, or written communication sent to the Licensor or -its representatives, including but not limited to communication on -electronic mailing lists, source code control systems, and issue -tracking systems that are managed by, or on behalf of, the Licensor -for the purpose of discussing and improving the Work, but excluding -communication that is conspicuously marked or otherwise designated -in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity -on behalf of whom a Contribution has been received by Licensor and -subsequently incorporated within the Work. - -"Tizen Certified Platform" shall mean a software platform that complies -with the standards set forth in the Tizen Compliance Specification -and passes the Tizen Compliance Tests as defined from time to time -by the Tizen Technical Steering Group and certified by the Tizen -Association or its designated agent. - -2. Grant of Copyright License. Subject to the terms and conditions of -this License, each Contributor hereby grants to You a perpetual, -worldwide, non-exclusive, no-charge, royalty-free, irrevocable -copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the -Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of -this License, each Contributor hereby grants to You a perpetual, -worldwide, non-exclusive, no-charge, royalty-free, irrevocable -(except as stated in this section) patent license to make, have made, -use, offer to sell, sell, import, and otherwise transfer the Work -solely as incorporated into a Tizen Certified Platform, where such -license applies only to those patent claims licensable by such -Contributor that are necessarily infringed by their Contribution(s) -alone or by combination of their Contribution(s) with the Work solely -as incorporated into a Tizen Certified Platform to which such -Contribution(s) was submitted. If You institute patent litigation -against any entity (including a cross-claim or counterclaim -in a lawsuit) alleging that the Work or a Contribution incorporated -within the Work constitutes direct or contributory patent infringement, -then any patent licenses granted to You under this License for that -Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the -Work or Derivative Works thereof pursuant to the copyright license -above, in any medium, with or without modifications, and in Source or -Object form, provided that You meet the following conditions: - - 1. You must give any other recipients of the Work or Derivative Works - a copy of this License; and - 2. You must cause any modified files to carry prominent notices stating - that You changed the files; and - 3. You must retain, in the Source form of any Derivative Works that - You distribute, all copyright, patent, trademark, and attribution - notices from the Source form of the Work, excluding those notices - that do not pertain to any part of the Derivative Works; and - 4. If the Work includes a "NOTICE" text file as part of its distribution, - then any Derivative Works that You distribute must include a readable - copy of the attribution notices contained within such NOTICE file, - excluding those notices that do not pertain to any part of - the Derivative Works, in at least one of the following places: - within a NOTICE text file distributed as part of the Derivative Works; - within the Source form or documentation, if provided along with the - Derivative Works; or, within a display generated by the Derivative Works, - if and wherever such third-party notices normally appear. - The contents of the NOTICE file are for informational purposes only - and do not modify the License. You may add Your own attribution notices - within Derivative Works that You distribute, alongside or as an addendum - to the NOTICE text from the Work, provided that such additional attribution - notices cannot be construed as modifying the License. You may add Your own - copyright statement to Your modifications and may provide additional or - different license terms and conditions for use, reproduction, or - distribution of Your modifications, or for any such Derivative Works - as a whole, provided Your use, reproduction, and distribution of - the Work otherwise complies with the conditions stated in this License - and your own copyright statement or terms and conditions do not conflict - the conditions stated in the License including section 3. - -5. Submission of Contributions. Unless You explicitly state otherwise, -any Contribution intentionally submitted for inclusion in the Work -by You to the Licensor shall be under the terms and conditions of -this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify -the terms of any separate license agreement you may have executed -with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade -names, trademarks, service marks, or product names of the Licensor, -except as required for reasonable and customary use in describing the -origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or -agreed to in writing, Licensor provides the Work (and each -Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied, including, without limitation, any warranties or conditions -of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A -PARTICULAR PURPOSE. You are solely responsible for determining the -appropriateness of using or redistributing the Work and assume any -risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, -whether in tort (including negligence), contract, or otherwise, -unless required by applicable law (such as deliberate and grossly -negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, -incidental, or consequential damages of any character arising as a -result of this License or out of the use or inability to use the -Work (including but not limited to damages for loss of goodwill, -work stoppage, computer failure or malfunction, or any and all -other commercial damages or losses), even if such Contributor -has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing -the Work or Derivative Works thereof, You may choose to offer, -and charge a fee for, acceptance of support, warranty, indemnity, -or other liability obligations and/or rights consistent with this -License. However, in accepting such obligations, You may act only -on Your own behalf and on Your sole responsibility, not on behalf -of any other Contributor, and only if You agree to indemnify, -defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason -of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Flora License to your work - -To apply the Flora License to your work, attach the following -boilerplate notice, with the fields enclosed by brackets "[]" -replaced with your own identifying information. (Don't include -the brackets!) The text should be enclosed in the appropriate -comment syntax for the file format. We also recommend that a -file or class name and description of purpose be included on the -same "printed page" as the copyright notice for easier -identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Flora License, Version 1.1 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://floralicense.org/license/ - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/NOTICE b/NOTICE index 94d56df..177464e 100644 --- a/NOTICE +++ b/NOTICE @@ -1,3 +1 @@ -Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. -Except as noted, this software is licensed under Flora License, Version 1.1 -Please, see the LICENSE.Flora file for Flora License, Version 1.1 terms and conditions. +Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. \ No newline at end of file diff --git a/daemon/accessibility.c b/daemon/accessibility.c new file mode 100644 index 0000000..a85bebb --- /dev/null +++ b/daemon/accessibility.c @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include +#include "common.h" +#include "quickpanel-ui.h" +#include "accessibility.h" + +HAPI Evas_Object * +quickpanel_accessibility_screen_reader_object_get(void *obj, screen_reader_object_type_e type, const char *part, Evas_Object *parent) +{ + Evas_Object *to = NULL; + Evas_Object *ao = NULL; + + retif(obj == NULL, NULL, "invalid parameter"); + retif(type == SCREEN_READER_OBJ_TYPE_EDJ_OBJECT && !part, NULL, "invalid parameter"); + + switch (type) { + case SCREEN_READER_OBJ_TYPE_ELM_OBJECT: + if (part != NULL) { + to = (Evas_Object *)elm_object_part_content_get(obj, part); + ao = (Evas_Object *)to; + } else { + ao = (Evas_Object *)obj; + } + break; + + case SCREEN_READER_OBJ_TYPE_EDJ_OBJECT: + to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get((Evas_Object *)obj), part); + break; + + default:// evas, icon + to = (Evas_Object *)obj; + } + + if (!ao && to && parent) { // edj, evas, icon, elm_object_item + ao = elm_access_object_get(to); + if (ao == NULL) { + ao = elm_access_object_register(to, parent); + } + } + + return ao; +} + +HAPI Evas_Object *quickpanel_accessibility_ui_get_focus_object(Evas_Object *parent) +{ + Evas_Object *focus = elm_button_add(parent); + retif(focus == NULL, NULL, "failed to create focus object"); + + elm_object_style_set(focus, "focus"); + + elm_access_info_set(focus, ELM_ACCESS_INFO, ""); + elm_access_info_set(focus, ELM_ACCESS_TYPE, ""); + + return focus; +} + +HAPI char *quickpanel_accessibility_info_cb(void *data, Evas_Object *obj) +{ + char *str = NULL; + retif(data == NULL, NULL, "invalid parameter"); + + str = _((const char *)data); + if (str != NULL) { + return strdup(str); + } + + return NULL; +} + +HAPI char *quickpanel_accessibility_info_cb_s(void *data, Evas_Object *obj) +{ + char *str = NULL; + retif(data == NULL, NULL, "invalid parameter"); + + // system string is not supported. data should be DID from application po files. + str = _(data); + if (str != NULL) { + return strdup(str); + } + + return NULL; +} + +HAPI void +quickpanel_accessibility_screen_reader_data_set(Evas_Object *view, const char *part, char *type, char *info) +{ + Evas_Object *ao = NULL; + retif(view == NULL, , "invalid parameter"); + retif(part == NULL, , "invalid parameter"); + + ao = quickpanel_accessibility_screen_reader_object_get(view, + SCREEN_READER_OBJ_TYPE_ELM_OBJECT, part, view); + if (ao != NULL) { + elm_access_info_set(ao, ELM_ACCESS_TYPE, type); + elm_access_info_set(ao, ELM_ACCESS_INFO, info); + } +} diff --git a/daemon/accessibility.h b/daemon/accessibility.h new file mode 100644 index 0000000..bf49a18 --- /dev/null +++ b/daemon/accessibility.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + + +#ifndef __ACCESSIBILITY_H__ +#define __ACCESSIBILITY_H__ + +typedef enum { + SCREEN_READER_OBJ_TYPE_ELM_OBJECT, + SCREEN_READER_OBJ_TYPE_EDJ_OBJECT, +} screen_reader_object_type_e; + +Evas_Object * +quickpanel_accessibility_screen_reader_object_get(void *obj, screen_reader_object_type_e type, const char *part, Evas_Object *parent); +Evas_Object *quickpanel_accessibility_ui_get_focus_object(Evas_Object *parent); +char *quickpanel_accessibility_info_cb(void *data, Evas_Object *obj); +char *quickpanel_accessibility_info_cb_s(void *data, Evas_Object *obj); +void quickpanel_accessibility_screen_reader_data_set(Evas_Object *view, const char *part, char *type, char *info); + +#endif /* __ACCESSIBILITY_H__ */ diff --git a/daemon/common.c b/daemon/common.c index d1c21df..40370b7 100755 --- a/daemon/common.c +++ b/daemon/common.c @@ -1,23 +1,89 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.1 (the License); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://floralicense.org + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * */ + +#include #include "common.h" #include "quickpanel-ui.h" -HAPI void quickpanel_util_char_replace(char *text, char s, char t) { +static inline int _is_space( char in ) +{ + if ( ( in == _SPACE )) { + return 1; + } else { + return 0; + } +} + +static inline int _l_trim( char *in ) +{ + int i, j; + short int done; + + i = 0; + done = 0; + + while ( !done && in[i] != '\0') { + if ( _is_space( in[i] ) ) { + i++; + } else { + done = 1; + } + } + + j = 0; + while ( in[i] != '\0' ) { + in[j++] = in[i++]; + } + + in[j] = '\0'; + + return 0; +} + +static inline int _r_trim( char *in ) +{ + int i; + short int done; + + i = strlen(in) - 1; + done = 0; + + while ( !done && !( i < 0 ) ) { + if ( _is_space( in[i] ) ) { + in[i--] = '\0'; + } else { + done = 1; + } + } + + return(0); +} + +HAPI void quickpanel_common_util_char_trim(char *text) +{ + retif(text == NULL, , "invalid argument"); + + _l_trim(text); + _r_trim(text); +} + +HAPI void quickpanel_common_util_char_replace(char *text, char s, char t) +{ retif(text == NULL, , "invalid argument"); int i = 0, text_len = 0; @@ -31,6 +97,123 @@ HAPI void quickpanel_util_char_replace(char *text, char s, char t) { } } +HAPI void quickpanel_common_util_add_char_to_each_charactor(char *dst, const char *src, char t) +{ + retif(dst == NULL, , "invalid argument"); + retif(src == NULL, , "invalid argument"); + + int i = 0, text_len = 0; + + text_len = strlen(src); + + for (i = 0; i < text_len; i++) { + *(dst + (i * 2)) = *(src + i); + *(dst + ((i * 2) + 1)) = t; + } +} + +static void _char_set(char *dst, char s, int index, int size) +{ + if (index < size) { + *(dst + index) = s; + } +} + +HAPI void quickpanel_common_util_phone_number_tts_make(char *dst, const char *src, int size) +{ + retif(dst == NULL, , "invalid argument"); + retif(src == NULL, , "invalid argument"); + + int no_op = 0; + int i = 0, j = 0, text_len = 0; + + text_len = strlen(src); + + for (i = 0, j= 0; i < text_len; i++) { + if (no_op == 1) { + _char_set(dst, *(src + i), j++, size); + } else { + if (isdigit(*(src + i))) { + if (i + 1 < text_len) { + if (*(src + i + 1) == '-' || *(src + i + 1) == _SPACE) { + _char_set(dst, *(src + i), j++, size); + } else { + _char_set(dst, *(src + i), j++, size); + _char_set(dst, _SPACE, j++, size); + } + } else { + _char_set(dst, *(src + i), j++, size); + _char_set(dst, _SPACE, j++, size); + } + } else if (*(src + i) == '-') { + no_op = 1; + _char_set(dst, *(src + i), j++, size); + } else { + _char_set(dst, *(src + i), j++, size); + } + } + } +} + +HAPI int quickpanel_common_util_is_phone_number(const char *address) +{ + int digit_count = 0; + retif(address == NULL, 0, "address is NULL"); + + int addr_len = 0; + addr_len = strlen(address); + + if (addr_len == 0) { + return 0; + } + + /* length check phone address should be longer than 2 and shorter than 40 */ + if (addr_len > 2 && addr_len <= QP_UTIL_PHONE_NUMBER_MAX_LEN) { + const char *pszOneChar = address; + + while (*pszOneChar) { + if (isdigit(*pszOneChar)) { + digit_count++; + } + + ++pszOneChar; + } + + pszOneChar = address; + + if (*pszOneChar == '+') { + ++pszOneChar; + } + + while (*pszOneChar) { + if (!isdigit(*pszOneChar) + && (*pszOneChar != '*') && (*pszOneChar != '#') + && (*pszOneChar != ' ') + && !((*pszOneChar == '-') && digit_count >= 7)) { + return 0; + } + + ++pszOneChar; + } + + return 1; + } else { + DBG("invalid address length [%d]", addr_len); + return 0; + } +} + +static void _current_popup_default_backkey_cb(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Object *popup = data; + retif(popup == NULL, , "invalid argument"); + + if (popup!= NULL) { + evas_object_del(popup); + popup = NULL; + } +} + static void _current_popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { retif(obj == NULL, , "obj is NULL"); @@ -45,7 +228,8 @@ static void _current_popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, voi } } -HAPI void quickpanel_ui_set_current_popup(Evas_Object *popup) { +HAPI void quickpanel_common_ui_set_current_popup(Evas_Object *popup, Evas_Smart_Cb func_back) +{ retif(popup == NULL, , "invalid argument"); struct appdata *ad = quickpanel_get_app_data(); @@ -53,13 +237,155 @@ HAPI void quickpanel_ui_set_current_popup(Evas_Object *popup) { ad->popup = popup; evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _current_popup_deleted_cb, NULL); + + if (func_back != NULL) { + evas_object_data_set(popup, EDATA_BACKKEY_CB, func_back); + } else { + evas_object_data_set(popup, EDATA_BACKKEY_CB, _current_popup_default_backkey_cb); + } } -HAPI void quickpanel_ui_del_current_popup(void) { +HAPI void quickpanel_common_ui_del_current_popup(void) +{ struct appdata *ad = quickpanel_get_app_data(); retif(ad == NULL, , "invalid argument"); if (ad->popup != NULL) { evas_object_del(ad->popup); + ad->popup = NULL; + } +} + +HAPI void *quickpanel_common_ui_get_buffer_from_image(const char *file_path, size_t *memfile_size, char *ext, int ext_size) +{ + FILE *fp = NULL; + void *buffer = NULL; + char *buf_ext = NULL; + + retif(file_path == NULL, NULL, "invalid data"); + + if (ext != NULL) { + buf_ext = ecore_file_strip_ext(file_path); + if (buf_ext != NULL) { + strncpy(ext, buf_ext, ext_size); + free(buf_ext); + } + } + + fp = fopen(file_path, "r"); + if (fp) { + struct stat stat_buf; + if (stat(file_path, &stat_buf) != 0) { + ERR("Getting file information Error"); + goto err; + } + + if (stat_buf.st_size > 0) { + buffer = (void *)calloc(1, (size_t)stat_buf.st_size + 1); + if (buffer == NULL) { + ERR("failed to alloc a buffer"); + goto err; + } + int result = fread(buffer, sizeof(char), stat_buf.st_size, fp); + if (result != stat_buf.st_size) { + ERR("failed to read a file"); + free(buffer); + buffer = NULL; + goto err; + } + if (memfile_size != NULL) { + *memfile_size = result; + } + } else { + if (memfile_size != NULL) { + *memfile_size = 0; + } + } + } + +err: + if (fp) { + fclose(fp); } + return buffer; +} + +HAPI char *quickpanel_common_ui_get_pkginfo_icon(const char *pkgid) +{ + int ret = 0; + char *icon_path = NULL; + char *icon_ret = NULL; + retif(pkgid == NULL, NULL, "invalid parameter"); + + pkgmgrinfo_appinfo_h appinfo_h = NULL; + + ret = pkgmgrinfo_appinfo_get_appinfo(pkgid, &appinfo_h); + if (ret < 0) { + ERR("pkgmgrinfo_appinfo_get_appinfo is failed %d", ret); + return NULL; + } + + //icon path + ret = pkgmgrinfo_appinfo_get_icon(appinfo_h, &icon_path); + if (ret < 0) { + ERR("pkgmgrinfo_appinfo_get_icon is failed %d", ret); + } + if (icon_path) { + icon_ret = (char*)strdup(icon_path); + } + if (appinfo_h) { + pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h); + } + + return icon_ret; +} + +HAPI char *quickpanel_common_ui_get_pkginfo_label(const char *pkgid) +{ + int ret = 0; + char *label = NULL; + char *value_ret = NULL; + retif(pkgid == NULL, NULL, "invalid parameter"); + + pkgmgrinfo_appinfo_h appinfo_h = NULL; + + ret = pkgmgrinfo_appinfo_get_appinfo(pkgid, &appinfo_h); + if (ret < 0) { + ERR("pkgmgrinfo_appinfo_get_appinfo is failed %d", ret); + return NULL; + } + + //icon path + ret = pkgmgrinfo_appinfo_get_label(appinfo_h, &label); + if (ret < 0) { + ERR("pkgmgrinfo_appinfo_get_icon is failed %d", ret); + } + if (label) { + value_ret = (char*)strdup(label); + } + if (appinfo_h) { + pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h); + } + + return value_ret; +} + +HAPI int quickpanel_common_ui_is_package_exist(const char *pkgid) +{ + int ret = 0; + retif(pkgid == NULL, 0, "invalid parameter"); + + pkgmgrinfo_appinfo_h appinfo_h = NULL; + + ret = pkgmgrinfo_appinfo_get_appinfo(pkgid, &appinfo_h); + if (ret < 0) { + DBG("package %s isn't exist", pkgid); + return 0; + } + + if (appinfo_h) { + pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h); + } + + return 1; } diff --git a/daemon/common.h b/daemon/common.h index 913054c..5749c17 100755 --- a/daemon/common.h +++ b/daemon/common.h @@ -1,19 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.1 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://floralicense.org/license/ + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * */ + #ifndef __QP_COMMON_H_ #define __QP_COMMON_H_ @@ -25,8 +27,11 @@ #define QP_OK (0) #define QP_FAIL (-1) +#define QP_UTIL_PHONE_NUMBER_MAX_LEN 40 +#define EDATA_BACKKEY_CB "bk_cb" #ifdef _DLOG_USED +#undef LOG_TAG #define LOG_TAG "QUICKPANEL" #include @@ -52,6 +57,21 @@ LOGE("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ } while (0) +#define SDBG(fmt , args...) \ + do { \ + SECURE_LOGD("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define SINFO(fmt , args...) \ + do { \ + SECURE_LOGI("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define SERR(fmt , args...) \ + do { \ + SECURE_LOGE("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + #elif FILE_DEBUG /*_DLOG_USED*/ #define DBG(fmt , args...) \ do { \ @@ -112,6 +132,12 @@ } \ } while (0); +#define retif_nomsg(cond, ret) do { \ + if (cond) { \ + return ret;\ + } \ +} while (0); + #define gotoif(cond, target, str, args...) do { \ if (cond) { \ WARN(str, ##args); \ @@ -120,8 +146,16 @@ } while (0); -void quickpanel_util_char_replace(char *text, char s, char t); -void quickpanel_ui_set_current_popup(Evas_Object *popup); -void quickpanel_ui_del_current_popup(void); +void quickpanel_common_util_char_trim(char *text); +void quickpanel_common_util_char_replace(char *text, char s, char t); +void quickpanel_common_util_add_char_to_each_charactor(char *dst, const char *src, char t); +int quickpanel_common_util_is_phone_number(const char *address); +void quickpanel_common_util_phone_number_tts_make(char *dst, const char *src, int size); +void quickpanel_common_ui_set_current_popup(Evas_Object *popup, Evas_Smart_Cb func_close); +void quickpanel_common_ui_del_current_popup(void); +void *quickpanel_common_ui_get_buffer_from_image(const char *file_path, size_t *memfile_size, char *ext, int ext_size); +char *quickpanel_common_ui_get_pkginfo_icon(const char *pkgid); +char *quickpanel_common_ui_get_pkginfo_label(const char *pkgid); +int quickpanel_common_ui_is_package_exist(const char *pkgid); #endif /* __QP_COMMON_H_ */ diff --git a/daemon/common_uic.c b/daemon/common_uic.c new file mode 100644 index 0000000..54596dd --- /dev/null +++ b/daemon/common_uic.c @@ -0,0 +1,375 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include +#include +#ifdef HAVE_X +#include +#include +#endif +#include +#include +#include +#include +#include +#include "common.h" +#include "quickpanel-ui.h" + + +/* binary information */ +#define QP_EMUL_STR "Emulator" +#define DEL_TIMER_VALUE 0.480 +#define SYSTEM_INFO_KEY_MODEL "http://tizen.org/system/model_name" +static Ecore_Timer *_close_timer = NULL; + + +static void _quickpanel_move_data_to_service(const char *key, const char *val, void *data) +{ + retif(data == NULL || key == NULL || val == NULL, , "Invialid parameter!"); + + app_control_h service = data; + app_control_add_extra_data(service, key, val); +} + +HAPI Evas_Object *quickpanel_uic_load_edj(Evas_Object * parent, const char *file, + const char *group, int is_just_load) +{ + Eina_Bool r; + Evas_Object *eo = NULL; + + retif(parent == NULL, NULL, "Invalid parameter!"); + + eo = elm_layout_add(parent); + retif(eo == NULL, NULL, "Failed to add layout object!"); + + r = elm_layout_file_set(eo, file, group); + retif(r != EINA_TRUE, NULL, + "Failed to set edje object file[%s-%s]!", file, group); + + evas_object_size_hint_weight_set(eo, + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(eo, + EVAS_HINT_FILL, EVAS_HINT_FILL); + + if (is_just_load == 1) { + elm_win_resize_object_add(parent, eo); + } + evas_object_show(eo); + + return eo; +} + +HAPI int quickpanel_uic_is_opened(void) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, 0, "invalid data."); + + return ad->is_opened; +} + +HAPI int quickpanel_uic_is_suspended(void) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, 0, "invalid data."); + + return ad->is_suspended; +} + +HAPI int quickpanel_uic_is_emul(void) +{ + int is_emul = 0; + char *info = NULL; + if (system_info_get_platform_string(SYSTEM_INFO_KEY_MODEL, &info) == 0) { + if (info == NULL) { + return 0; + } + if (!strncmp(QP_EMUL_STR, info, strlen(info))) { + is_emul = 1; + } + } + + if (info != NULL) free(info); + + return is_emul; +} + +HAPI void quickpanel_uic_initial_resize(Evas_Object *obj, int height) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, , "invalid data."); + + height = (height % 2 != 0) ? height + 1 : height; + + if (ad->angle == 90 || ad->angle == 270) { + evas_object_resize(obj, ad->win_height, height * ad->scale); + } else { + evas_object_resize(obj, ad->win_width, height * ad->scale); + } +} + +HAPI int quickpanel_uic_launch_app(char *app_id, void *data) +{ + int ret = APP_CONTROL_ERROR_NONE; + app_control_h service = NULL; + char *app_id_from_service = NULL; + + retif(app_id == NULL && data == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "Invialid parameter!"); + + ret = app_control_create(&service); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_create() return error : %d", ret); + return ret; + } + retif(service == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "fail to create service handle!"); + + if (app_id != NULL) { + app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT); + app_control_set_app_id(service, app_id); + + if (data != NULL) { + bundle_iterate((bundle *)data, _quickpanel_move_data_to_service, service); + } + } else { + if (data != NULL) { + ret = app_control_import_from_bundle(service, data); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("Failed to import[%d]", ret); + } + } + } + + ret = app_control_send_launch_request(service, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_send_launch_request() is failed : %d", ret); + app_control_get_app_id(service, &app_id_from_service); + if (app_id_from_service != NULL) { + quickpanel_uic_launch_app_inform_result(app_id_from_service, ret); + free(app_id_from_service); + } else { + quickpanel_uic_launch_app_inform_result(app_id, ret); + } + app_control_destroy(service); + return ret; + } + app_control_destroy(service); + return ret; +} + +HAPI int quickpanel_uic_launch_ug_by_appcontrol(const char *package, void *data) +{ + int ret = APP_CONTROL_ERROR_NONE; + app_control_h service = NULL; + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "ad null"); + retif(package == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "package null"); + + ret = app_control_create(&service); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_create() return error : %d", ret); + return ret; + } + retif(service == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "fail to create service handle!"); + + app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT); + app_control_set_app_id(service, package); + + if (data != NULL) { + bundle_iterate((bundle *)data, _quickpanel_move_data_to_service, service); + } + + ret = app_control_send_launch_request(service, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_send_launch_request() is failed : %d", ret); + app_control_destroy(service); + return ret; + } + app_control_destroy(service); + return ret; +} + +HAPI void quickpanel_uic_launch_app_inform_result(const char *pkgname, int retcode) +{ + retif(retcode == APP_CONTROL_ERROR_NONE, , "retcode = APP_CONTROL_ERROR_NONE!"); + retif(pkgname == NULL && retcode != APP_CONTROL_ERROR_APP_NOT_FOUND, , "Invialid parameter!"); + + const char *msg = NULL; + char *app_label = NULL; + + if (retcode == APP_CONTROL_ERROR_APP_NOT_FOUND) { + notification_status_message_post(_NOT_LOCALIZED("Unable to find application to perform this action.")); + } else { + Eina_Strbuf *strbuf = eina_strbuf_new(); + char *format = _("IDS_QP_TPOP_UNABLE_TO_OPEN_PS"); + + if (strbuf != NULL) { + app_label = quickpanel_common_ui_get_pkginfo_label(pkgname); + if (app_label != NULL) { + eina_strbuf_append_printf(strbuf, format, app_label); + free(app_label); + } else { + eina_strbuf_append_printf(strbuf, format, pkgname); + } + eina_strbuf_append_printf(strbuf, "(%x)", retcode); + msg = eina_strbuf_string_get(strbuf); + + if (msg != NULL) { + notification_status_message_post(msg); + } + eina_strbuf_free(strbuf); + } + } +} + +HAPI void quickpanel_uic_open_quickpanel(int reason) +{ +#ifdef HAVE_X + Ecore_X_Window xwin; + Ecore_X_Window zone; +#endif + struct appdata *ad = quickpanel_get_app_data(); + + DBG("reason:%d", reason); + + retif(ad == NULL, , "Invalid parameter!"); + retif(ad->win == NULL, , "Invalid parameter!"); +#ifdef HAVE_X + xwin = elm_win_xwindow_get(ad->win); + if (xwin != 0) { + if ((zone = ecore_x_e_illume_zone_get(xwin)) != 0) { + if (ecore_x_e_illume_quickpanel_state_get(zone) == ECORE_X_ILLUME_QUICKPANEL_STATE_OFF) { + ecore_x_e_illume_quickpanel_state_send(zone, ECORE_X_ILLUME_QUICKPANEL_STATE_ON); + quickpanel_uic_opened_reason_set(reason); + } + } else { + ERR("failed to get zone"); + } + } else { + ERR("failed to get xwin"); + } +#endif +} + +HAPI void quickpanel_uic_opened_reason_set(int reason) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, , "Invalid parameter!"); + + ad->opening_reason = reason; +} + +HAPI int quickpanel_uic_opened_reason_get(void) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, OPENED_NO_REASON, "Invalid parameter!"); + + return ad->opening_reason; +} + +static void _quickpanel_close(void) +{ +#ifdef HAVE_X + Ecore_X_Window xwin; + Ecore_X_Window zone; +#endif + struct appdata *ad = quickpanel_get_app_data(); + + DBG(""); + + retif(ad == NULL, , "Invalid parameter!"); + retif(ad->win == NULL, , "Invalid parameter!"); +#ifdef HAVE_X + xwin = elm_win_xwindow_get(ad->win); + if (xwin != 0) { + if ((zone = ecore_x_e_illume_zone_get(xwin)) != 0) { + if (ecore_x_e_illume_quickpanel_state_get(zone) == ECORE_X_ILLUME_QUICKPANEL_STATE_ON) { + ecore_x_e_illume_quickpanel_state_send(zone, ECORE_X_ILLUME_QUICKPANEL_STATE_OFF); + } + } else { + ERR("failed to get zone"); + } + } else { + ERR("failed to get xwin"); + } +#endif +} + +static Eina_Bool _quickpanel_close_timer_cb(void *data) +{ + if( _close_timer != NULL ) { + _close_timer = NULL; + } + _quickpanel_close(); + + return ECORE_CALLBACK_CANCEL; +} + +HAPI void quickpanel_uic_close_quickpanel(bool is_check_lock, int is_delay_needed) { + int ret = 0; + int is_lock_launched = VCONFKEY_IDLE_UNLOCK; + + if (is_check_lock == true) { + if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &is_lock_launched) == 0) { + if (is_lock_launched == VCONFKEY_IDLE_LOCK) { + ret = vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_UNLOCK); + if (ret == 0) { + ERR("unlock the lockscreen from quickpanel"); + } else { + ERR("failed to unlock the lockscreen from quickpanel"); + } + } + } + } + + if (is_delay_needed) { + if( _close_timer == NULL ) { + _close_timer = ecore_timer_add(DEL_TIMER_VALUE, _quickpanel_close_timer_cb, NULL); + } + } else { + _quickpanel_close(); + } +} + +HAPI void quickpanel_uic_toggle_openning_quickpanel(void) +{ +#ifdef HAVE_X + Ecore_X_Window xwin; + Ecore_X_Window zone; +#endif + struct appdata *ad = quickpanel_get_app_data(); + + DBG(""); + + retif(ad == NULL, , "Invalid parameter!"); + retif(ad->win == NULL, , "Invalid parameter!"); +#ifdef HAVE_X + xwin = elm_win_xwindow_get(ad->win); + if (xwin != 0) { + if ((zone = ecore_x_e_illume_zone_get(xwin)) != 0) { + if (ecore_x_e_illume_quickpanel_state_get(zone) == ECORE_X_ILLUME_QUICKPANEL_STATE_ON) { + ecore_x_e_illume_quickpanel_state_send(zone, ECORE_X_ILLUME_QUICKPANEL_STATE_OFF); + } else { + ecore_x_e_illume_quickpanel_state_send(zone, ECORE_X_ILLUME_QUICKPANEL_STATE_ON); + } + } else { + ERR("failed to get zone"); + } + } else { + ERR("failed to get xwin"); + } +#endif +} diff --git a/daemon/common_uic.h b/daemon/common_uic.h new file mode 100644 index 0000000..882163d --- /dev/null +++ b/daemon/common_uic.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#ifndef __QP_COMMON_UIC_H_ +#define __QP_COMMON_UIC_H_ + +typedef enum { + OPENED_NO_REASON = 0, + OPENED_BY_CMD_HIDE_LAUNCH = 1, + OPENED_BY_CMD_SHOW_SETTINGS = 2, +} qp_open_reason; + +Evas_Object *quickpanel_uic_load_edj(Evas_Object * parent, const char *file, + const char *group, int is_just_load); +int quickpanel_uic_launch_app(char *app_id, void *data); +int quickpanel_uic_launch_ug_by_appcontrol(const char *package, void *data); +int quickpanel_uic_is_emul(void); +int quickpanel_uic_is_suspended(void); +int quickpanel_uic_is_opened(void); +void quickpanel_uic_launch_app_inform_result(const char *pkgname, int retcode); +void quickpanel_uic_initial_resize(Evas_Object *obj, int height); +void quickpanel_uic_close_quickpanel(bool is_check_lock, int is_delay_needed); +void quickpanel_uic_open_quickpanel(int reason); +void quickpanel_uic_toggle_openning_quickpanel(void); +void quickpanel_uic_opened_reason_set(int reason); +int quickpanel_uic_opened_reason_get(void); + +#endif /* __QP_COMMON_UIC_H_ */ diff --git a/daemon/common_uic_x11.c b/daemon/common_uic_x11.c new file mode 100644 index 0000000..5558f29 --- /dev/null +++ b/daemon/common_uic_x11.c @@ -0,0 +1,364 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "quickpanel-ui.h" + + +/* binary information */ +#define QP_EMUL_STR "Emulator" +#define DEL_TIMER_VALUE 0.480 +#define SYSTEM_INFO_KEY_MODEL "http://tizen.org/system/model_name" +static Ecore_Timer *_close_timer = NULL; + + +static void _quickpanel_move_data_to_service(const char *key, const char *val, void *data) +{ + retif(data == NULL || key == NULL || val == NULL, , "Invialid parameter!"); + + app_control_h service = data; + app_control_add_extra_data(service, key, val); +} + +HAPI Evas_Object *quickpanel_uic_load_edj(Evas_Object * parent, const char *file, + const char *group, int is_just_load) +{ + Eina_Bool r; + Evas_Object *eo = NULL; + + retif(parent == NULL, NULL, "Invalid parameter!"); + + eo = elm_layout_add(parent); + retif(eo == NULL, NULL, "Failed to add layout object!"); + + r = elm_layout_file_set(eo, file, group); + retif(r != EINA_TRUE, NULL, + "Failed to set edje object file[%s-%s]!", file, group); + + evas_object_size_hint_weight_set(eo, + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(eo, + EVAS_HINT_FILL, EVAS_HINT_FILL); + + if (is_just_load == 1) { + elm_win_resize_object_add(parent, eo); + } + evas_object_show(eo); + + return eo; +} + +HAPI int quickpanel_uic_is_opened(void) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, 0, "invalid data."); + + return ad->is_opened; +} + +HAPI int quickpanel_uic_is_suspended(void) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, 0, "invalid data."); + + return ad->is_suspended; +} + +HAPI int quickpanel_uic_is_emul(void) +{ + int is_emul = 0; + char *info = NULL; + if (system_info_get_platform_string(SYSTEM_INFO_KEY_MODEL, &info) == 0) { + if (info == NULL) { + return 0; + } + if (!strncmp(QP_EMUL_STR, info, strlen(info))) { + is_emul = 1; + } + } + + if (info != NULL) free(info); + + return is_emul; +} + +HAPI void quickpanel_uic_initial_resize(Evas_Object *obj, int height) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, , "invalid data."); + + height = (height % 2 != 0) ? height + 1 : height; + + if (ad->angle == 90 || ad->angle == 270) { + evas_object_resize(obj, ad->win_height, height * ad->scale); + } else { + evas_object_resize(obj, ad->win_width, height * ad->scale); + } +} + +HAPI int quickpanel_uic_launch_app(char *app_id, void *data) +{ + int ret = APP_CONTROL_ERROR_NONE; + app_control_h service = NULL; + char *app_id_from_service = NULL; + + retif(app_id == NULL && data == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "Invialid parameter!"); + + ret = app_control_create(&service); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_create() return error : %d", ret); + return ret; + } + retif(service == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "fail to create service handle!"); + + if (app_id != NULL) { + app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT); + app_control_set_app_id(service, app_id); + + if (data != NULL) { + bundle_iterate((bundle *)data, _quickpanel_move_data_to_service, service); + } + } else { + if (data != NULL) { + ret = app_control_import_from_bundle(service, data); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("Failed to import[%d]", ret); + } + } + } + + ret = app_control_send_launch_request(service, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_send_launch_request() is failed : %d", ret); + app_control_get_app_id(service, &app_id_from_service); + if (app_id_from_service != NULL) { + quickpanel_uic_launch_app_inform_result(app_id_from_service, ret); + free(app_id_from_service); + } else { + quickpanel_uic_launch_app_inform_result(app_id, ret); + } + app_control_destroy(service); + return ret; + } + app_control_destroy(service); + return ret; +} + +HAPI int quickpanel_uic_launch_ug_by_appcontrol(const char *package, void *data) +{ + int ret = APP_CONTROL_ERROR_NONE; + app_control_h service = NULL; + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "ad null"); + retif(package == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "package null"); + + ret = app_control_create(&service); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_create() return error : %d", ret); + return ret; + } + retif(service == NULL, APP_CONTROL_ERROR_INVALID_PARAMETER, "fail to create service handle!"); + + app_control_set_operation(service, APP_CONTROL_OPERATION_DEFAULT); + app_control_set_app_id(service, package); + + if (data != NULL) { + bundle_iterate((bundle *)data, _quickpanel_move_data_to_service, service); + } + + ret = app_control_send_launch_request(service, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_send_launch_request() is failed : %d", ret); + app_control_destroy(service); + return ret; + } + app_control_destroy(service); + return ret; +} + +HAPI void quickpanel_uic_launch_app_inform_result(const char *pkgname, int retcode) +{ + retif(retcode == APP_CONTROL_ERROR_NONE, , "retcode = APP_CONTROL_ERROR_NONE!"); + retif(pkgname == NULL && retcode != APP_CONTROL_ERROR_APP_NOT_FOUND, , "Invialid parameter!"); + + const char *msg = NULL; + char *app_label = NULL; + + if (retcode == APP_CONTROL_ERROR_APP_NOT_FOUND) { + notification_status_message_post(_NOT_LOCALIZED("Unable to find application to perform this action.")); + } else { + Eina_Strbuf *strbuf = eina_strbuf_new(); + char *format = _("IDS_QP_TPOP_UNABLE_TO_OPEN_PS"); + + if (strbuf != NULL) { + app_label = quickpanel_common_ui_get_pkginfo_label(pkgname); + if (app_label != NULL) { + eina_strbuf_append_printf(strbuf, format, app_label); + free(app_label); + } else { + eina_strbuf_append_printf(strbuf, format, pkgname); + } + eina_strbuf_append_printf(strbuf, "(%x)", retcode); + msg = eina_strbuf_string_get(strbuf); + + if (msg != NULL) { + notification_status_message_post(msg); + } + eina_strbuf_free(strbuf); + } + } +} + +HAPI void quickpanel_uic_open_quickpanel(int reason) +{ + Ecore_X_Window xwin; + Ecore_X_Window zone; + struct appdata *ad = quickpanel_get_app_data(); + + DBG("reason:%d", reason); + + retif(ad == NULL, , "Invalid parameter!"); + retif(ad->win == NULL, , "Invalid parameter!"); + + xwin = elm_win_xwindow_get(ad->win); + if (xwin != 0) { + if ((zone = ecore_x_e_illume_zone_get(xwin)) != 0) { + if (ecore_x_e_illume_quickpanel_state_get(zone) == ECORE_X_ILLUME_QUICKPANEL_STATE_OFF) { + ecore_x_e_illume_quickpanel_state_send(zone, ECORE_X_ILLUME_QUICKPANEL_STATE_ON); + quickpanel_uic_opened_reason_set(reason); + } + } else { + ERR("failed to get zone"); + } + } else { + ERR("failed to get xwin"); + } +} + +HAPI void quickpanel_uic_opened_reason_set(int reason) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, , "Invalid parameter!"); + + ad->opening_reason = reason; +} + +HAPI int quickpanel_uic_opened_reason_get(void) +{ + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, OPENED_NO_REASON, "Invalid parameter!"); + + return ad->opening_reason; +} + +static void _quickpanel_close(void) +{ + Ecore_X_Window xwin; + Ecore_X_Window zone; + struct appdata *ad = quickpanel_get_app_data(); + + DBG(""); + + retif(ad == NULL, , "Invalid parameter!"); + retif(ad->win == NULL, , "Invalid parameter!"); + + xwin = elm_win_xwindow_get(ad->win); + if (xwin != 0) { + if ((zone = ecore_x_e_illume_zone_get(xwin)) != 0) { + if (ecore_x_e_illume_quickpanel_state_get(zone) == ECORE_X_ILLUME_QUICKPANEL_STATE_ON) { + ecore_x_e_illume_quickpanel_state_send(zone, ECORE_X_ILLUME_QUICKPANEL_STATE_OFF); + } + } else { + ERR("failed to get zone"); + } + } else { + ERR("failed to get xwin"); + } +} + +static Eina_Bool _quickpanel_close_timer_cb(void *data) +{ + if( _close_timer != NULL ) { + _close_timer = NULL; + } + _quickpanel_close(); + + return ECORE_CALLBACK_CANCEL; +} + +HAPI void quickpanel_uic_close_quickpanel(bool is_check_lock, int is_delay_needed) { + int ret = 0; + int is_lock_launched = VCONFKEY_IDLE_UNLOCK; + + if (is_check_lock == true) { + if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &is_lock_launched) == 0) { + if (is_lock_launched == VCONFKEY_IDLE_LOCK) { + ret = vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_UNLOCK); + if (ret == 0) { + ERR("unlock the lockscreen from quickpanel"); + } else { + ERR("failed to unlock the lockscreen from quickpanel"); + } + } + } + } + + if (is_delay_needed) { + if( _close_timer == NULL ) { + _close_timer = ecore_timer_add(DEL_TIMER_VALUE, _quickpanel_close_timer_cb, NULL); + } + } else { + _quickpanel_close(); + } +} + +HAPI void quickpanel_uic_toggle_openning_quickpanel(void) +{ + Ecore_X_Window xwin; + Ecore_X_Window zone; + struct appdata *ad = quickpanel_get_app_data(); + + DBG(""); + + retif(ad == NULL, , "Invalid parameter!"); + retif(ad->win == NULL, , "Invalid parameter!"); + + xwin = elm_win_xwindow_get(ad->win); + if (xwin != 0) { + if ((zone = ecore_x_e_illume_zone_get(xwin)) != 0) { + if (ecore_x_e_illume_quickpanel_state_get(zone) == ECORE_X_ILLUME_QUICKPANEL_STATE_ON) { + ecore_x_e_illume_quickpanel_state_send(zone, ECORE_X_ILLUME_QUICKPANEL_STATE_OFF); + } else { + ecore_x_e_illume_quickpanel_state_send(zone, ECORE_X_ILLUME_QUICKPANEL_STATE_ON); + } + } else { + ERR("failed to get zone"); + } + } else { + ERR("failed to get xwin"); + } +} diff --git a/daemon/datetime/datetime.c b/daemon/datetime/datetime.c new file mode 100644 index 0000000..e87197f --- /dev/null +++ b/daemon/datetime/datetime.c @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include +#include +#include +#include +#include "common.h" +#include "quickpanel-ui.h" +#include "list_util.h" +#include "quickpanel_def.h" +#ifdef QP_SCREENREADER_ENABLE +#include "accessibility.h" +#endif +#include "modules.h" +#ifdef QP_EMERGENCY_MODE_ENABLE +#include "emergency_mode.h" +#endif +#include "util-time.h" + +static int _init(void *data); +static int _fini(void *data); + +#define PKG_SETTING_EDIT "quickpanel-setting-efl" +#define QP_TIMEDATE_SETTING_UG "setting-time-efl" +#define E_DATA_EDITING_VISIBILITT "editing_visible" +#define E_DATA_TIME_N_DATE_EVENT "time_n_date_event" + +QP_Module qp_datetime_view = { + .name = "qp_datetime_view", + .init = _init, + .fini = _fini, + .suspend = NULL, + .resume = NULL, + .lang_changed = NULL, + .refresh = NULL, +}; + +static Evas_Object *_datetime_view_get(void); + +static void _flag_set(Evas_Object *container, const char *key, int value) +{ + retif(container == NULL, , "invalid parameter"); + retif(key == NULL, , "invalid parameter"); + + evas_object_data_set(container, key, (void *)value); +} + +static int _flag_get(Evas_Object *container, const char *key) +{ + retif(container == NULL, 0, "invalid parameter"); + retif(key == NULL, 0, "invalid parameter"); + + return (int)evas_object_data_get(container, key); +} + +static void _set_text_to_part(Evas_Object *obj, const char *part, const char *text) +{ + const char *old_text = NULL; + + retif(obj == NULL, , "Invalid parameter!"); + retif(part == NULL, , "Invalid parameter!"); + retif(text == NULL, , "Invalid parameter!"); + + old_text = elm_object_part_text_get(obj, part); + if (old_text != NULL) { + if (strcmp(old_text, text) == 0) { + return; + } + } + + elm_object_part_text_set(obj, part, text); +} + +static void _text_time_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Object *view = _datetime_view_get(); + int ret; + + if (view) { + if (_flag_get(view, E_DATA_TIME_N_DATE_EVENT) == 0) { + DBG("Time & date area click is event disabled"); + return; + } + } + + quickpanel_media_play_feedback(); + + ret = quickpanel_uic_launch_ug_by_appcontrol(QP_TIMEDATE_SETTING_UG, NULL); + quickpanel_uic_launch_app_inform_result(QP_TIMEDATE_SETTING_UG, ret); + + quickpanel_uic_close_quickpanel(true, 1); +} + +static void _button_setting_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + quickpanel_media_play_feedback(); + +#ifdef QP_EMERGENCY_MODE_ENABLE + if (quickpanel_emergency_mode_is_on()) { + quickpanel_uic_launch_app(PACKAGE_EMERGENCY_MODE_SETTING, NULL); + } else { + quickpanel_uic_launch_app(QP_SETTING_PKG_SETTING, NULL); + } +#else + quickpanel_uic_launch_app(QP_SETTING_PKG_SETTING, NULL); +#endif + quickpanel_uic_close_quickpanel(true, 1); +} + +static Evas_Object *_datetime_view_create(Evas_Object *parent) +{ + Evas_Object *focus = NULL; + Eina_Bool ret = EINA_TRUE; + Evas_Object *view = NULL; + + retif(parent == NULL, NULL, "Invalid parameter!"); + + view = elm_layout_add(parent); + + if (view != NULL) { + ret = elm_layout_file_set(view, DEFAULT_EDJ, + "quickpanel/datetime"); + if (ret == EINA_FALSE) { + ERR("failed to load quickpanel/datetime layout"); + } + evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(view, EVAS_HINT_FILL, EVAS_HINT_FILL); + quickpanel_uic_initial_resize(view, QP_DATE_H); + + focus = quickpanel_accessibility_ui_get_focus_object(view); + elm_object_part_content_set(view, "focus.datetime", focus); + evas_object_smart_callback_add(focus, "clicked", _text_time_clicked_cb, view); + + focus = quickpanel_accessibility_ui_get_focus_object(view); + elm_object_part_content_set(view, "focus.setting", focus); + evas_object_smart_callback_add(focus, "clicked", _button_setting_clicked_cb, view); + + _flag_set(view, E_DATA_EDITING_VISIBILITT, 0); + + if (quickpanel_emergency_mode_is_on()) { + _flag_set(view, E_DATA_TIME_N_DATE_EVENT, 0); + elm_object_signal_emit(view, "timendate.click.disable", "prog"); + } else { + _flag_set(view, E_DATA_TIME_N_DATE_EVENT, 1); + elm_object_signal_emit(view, "timendate.click.enable", "prog"); + } + + evas_object_show(view); + } + + return view; +} + +static Evas_Object *_datetime_view_get(void) { + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, NULL, "invalid argument"); + retif(ad->view_root == NULL, NULL, "invalid argument"); + + return elm_object_part_content_get(ad->view_root + , "qp.base.datetime.swallow"); +} + +static void _datetime_view_attach(void *data) +{ + Evas_Object *view = NULL; + struct appdata *ad = data; + retif(ad == NULL, ,"invalid parameter"); + retif(ad->view_root == NULL, ,"invalid parameter"); + + view = _datetime_view_create(ad->view_root); + if (view != NULL) { + elm_object_part_content_set(ad->view_root, "qp.base.datetime.swallow", view); + } +} + +static void _datetime_view_deattach(void *data) +{ + Evas_Object *view = NULL; + struct appdata *ad = data; + retif(ad == NULL, ,"invalid parameter"); + retif(ad->view_root == NULL, ,"invalid parameter"); + + view = elm_object_part_content_unset(ad->view_root, "qp.base.datetime.swallow"); + if (view != NULL) { + evas_object_del(view); + view = NULL; + } +} + +static int _init(void *data) +{ + struct appdata *ad = data; + retif(ad == NULL, QP_FAIL,"invalid parameter"); + + _datetime_view_attach(ad); + + return QP_OK; +} + +static int _fini(void *data) +{ + _datetime_view_deattach(data); + + return QP_OK; +} + +HAPI void quickpanel_datetime_datentime_event_set(int is_clickable) +{ + Evas_Object *view = _datetime_view_get(); + + DBG("date n time clickable set[%d]", is_clickable); + + if (view != NULL) { + if (is_clickable == 1) { + if (_flag_get(view, E_DATA_TIME_N_DATE_EVENT) == 0) { + _flag_set(view, E_DATA_TIME_N_DATE_EVENT, 1); + elm_object_signal_emit(view, "timendate.click.enable", "prog"); + } + } else { + if (_flag_get(view, E_DATA_TIME_N_DATE_EVENT) == 1) { + _flag_set(view, E_DATA_TIME_N_DATE_EVENT, 0); + elm_object_signal_emit(view, "timendate.click.disable", "prog"); + } + } + } +} + +HAPI void quickpanel_datetime_editing_icon_visibility_set(int is_visible) +{ + Evas_Object *view = _datetime_view_get(); + + DBG("visibility set:%d", is_visible); + + if (view != NULL) { + if (is_visible == 1) { + if (_flag_get(view, E_DATA_EDITING_VISIBILITT) == 0) { + _flag_set(view, E_DATA_EDITING_VISIBILITT, 1); + elm_object_signal_emit(view, "button,editing,show", "prog"); + } + } else { + if (_flag_get(view, E_DATA_EDITING_VISIBILITT) == 1) { + _flag_set(view, E_DATA_EDITING_VISIBILITT, 0); + elm_object_signal_emit(view, "button,editing,hide", "prog"); + } + } + } +} + +HAPI void quickpanel_datetime_view_update(char *date, char *time, char *meridiem, int meridiem_type) +{ + Evas_Object *view = NULL; + + Eina_Strbuf *strbuf_date = NULL; + Eina_Strbuf *strbuf_time = NULL; + Eina_Strbuf *strbuf_access = NULL; + + view = _datetime_view_get(); + + if (!view) { + ERR("view == NULL"); + return; + } + + strbuf_date = eina_strbuf_new(); + if(!strbuf_date) { + ERR("strbuf_date == NULL"); + return; + } + + strbuf_time = eina_strbuf_new(); + if(!strbuf_time) { + ERR("strbuf_time == NULL"); + eina_strbuf_free(strbuf_date); + return; + } + + strbuf_access = eina_strbuf_new(); + if(!strbuf_access) { + ERR("strbuf_access == NULL"); + eina_strbuf_free(strbuf_date); + eina_strbuf_free(strbuf_time); + return; + } + + + DBG("update time: %s %s %s", date, time, meridiem); + + if (date != NULL) { + eina_strbuf_append_printf(strbuf_date, "%s", date); + eina_strbuf_append_printf(strbuf_access, "%s ", date); + } + + eina_strbuf_ltrim(strbuf_date); + + // ------------------------------------------------------------------------------------- + + if (meridiem_type == UTIL_TIME_MERIDIEM_TYPE_PRE && meridiem != NULL && strlen(meridiem) != 0) { + eina_strbuf_append_printf(strbuf_time, "%s ", meridiem); + eina_strbuf_append_printf(strbuf_access, "%s ", meridiem); + } + + if (time != NULL) { + eina_strbuf_append_printf(strbuf_time, "