From: jin0.kim Date: Tue, 26 Apr 2016 00:53:28 +0000 (+0830) Subject: apps/core/preloaded/quickpanel base X-Git-Tag: submit/tizen/20160426.005901^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd286d1eb25e9fa083ac57e7808fad99c2174a96;p=profile%2Fmobile%2Fapps%2Fnative%2Fquickpanel.git apps/core/preloaded/quickpanel base Change-Id: Ib84dba03ee41a17e31691d84fc1f43feeb034cf4 --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..24aebc0 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +youngsub ko +seung taek jung diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..6f40394 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,190 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(quickpanel C) + +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/test TEST_SRCS) + +SET(SRCS + daemon/modules.c + daemon/accessibility.c + daemon/voice_control.c + daemon/media.c + daemon/datetime/util-time.c + daemon/datetime/datetime.c + daemon/sim_controller.c + daemon/minictrl/minictrl.c + daemon/preference.c + daemon/notifications/noti_list_item.c + daemon/notifications/animated_image.c + daemon/notifications/activenoti.c + daemon/notifications/noti_view_listype.c + daemon/notifications/noti_view_ongoing.c + daemon/notifications/noti_node.c + daemon/notifications/noti_section.c + daemon/notifications/noti_win.c + daemon/notifications/noti_listbox.c + daemon/notifications/noti_util.c + daemon/notifications/noti_view.c + daemon/notifications/noti.c + daemon/device/brightness.c + daemon/settings/modules/rotate-lock.c + daemon/settings/modules/bluetooth.c + daemon/settings/modules/gps.c + daemon/settings/modules/wifi.c + daemon/settings/modules/sound-profile.c + daemon/settings/settings_view_all.c + daemon/settings/settings_icon_common.c + daemon/settings/settings_gridbox.c + daemon/settings/settings_view_featured.c + daemon/settings/settings_ipc.c + daemon/settings/setting_module_api.c + daemon/settings/settings.c + daemon/settings/setting_utils.c + daemon/vi/vi_manager.c + daemon/common_uic.c + daemon/handler_controller.c + daemon/service/animated_icon.c + daemon/service/emergency_mode.c + daemon/service/uninstall.c + daemon/service/reminder.c + daemon/service/keyboard.c + daemon/service/noti_led.c + daemon/page/pager.c + daemon/page/page_base.c + daemon/page/pager_common.c + daemon/page/page_setting_all.c + daemon/quickpanel-ui.c + daemon/common.c + daemon/list_util.c + ${EXTRA_SRCS} + ${TEST_SRCS} +) + +SET(PACKAGE ${PROJECT_NAME}) +SET(PREFIX "${CMAKE_INSTALL_PREFIX}/apps/${PKGNAME}") +SET(BINDIR "${PREFIX}/bin") +SET(RESDIR "${PREFIX}/res") +SET(LOCALEDIR "${RESDIR}/locale") +SET(ICONDIR "${RESDIR}/icons") +SET(EDJDIR "${RESDIR}/edje") +SET(DATADIR "${PREFIX}/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") +ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") +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 + capi-appfw-application + capi-system-runtime-info + capi-system-info + capi-system-device + capi-location-manager + 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 + notification + badge + vconf + edbus + evas + ecore + edje + ecore-input + icu-i18n + elementary + dlog + syspopup-caller + minicontrol-viewer + minicontrol-monitor + capi-appfw-package-manager + iniparser + alarm-service + voice-control-setting + tzsh-quickpanel-service +) + +FOREACH(flag ${pkgs_CFLAGS} ${x11_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -g -O2 -fpie -Werror") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_C_FLAGS_RELEASE "-O2") + +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DQP_SETTING_ENABLE") +ADD_DEFINITIONS("-DQP_BRIGHTNESS_ENABLE") +ADD_DEFINITIONS("-DQP_MINICTRL_ENABLE") +ADD_DEFINITIONS("-DQP_SCREENREADER_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") +ADD_DEFINITIONS("-DQP_VOICE_CONTROL_ENABLE") + +ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") +ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"") +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") +ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") +ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"") +ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"") +ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"") +ADD_DEFINITIONS("-DSHARED_DIR=\"${SHARED_DIR}\"") + +#ADD_DEFINITIONS("-DFILE_DEBUG") +ADD_DEFINITIONS("-D_DLOG_USED") +#ADD_DEFINITIONS("-DHAVE_X") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${x11_pkgs_LDFLAGS} "-pie") + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) +INSTALL(DIRECTORY DESTINATION ${DATADIR}) +#INSTALL(FILES ${CMAKE_SOURCE_DIR}/icons/quickpanel_icon_default.png DESTINATION ${RESDIR}) + +# icons for notification +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/data/images_noti_icons/ DESTINATION ${SHARED_DIR}/noti_icons FILES_MATCHING PATTERN "*.png") +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/images/quickpanel_icon_default.png DESTINATION ${RESDIR}) + +# License +INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME ${PKGNAME}) + +# i18n +ADD_SUBDIRECTORY(data) +ADD_SUBDIRECTORY(po) 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/NOTICE b/NOTICE new file mode 100644 index 0000000..177464e --- /dev/null +++ b/NOTICE @@ -0,0 +1 @@ +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 100755 index 0000000..3434832 --- /dev/null +++ b/daemon/accessibility.c @@ -0,0 +1,123 @@ +/* + * 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 "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"); + + /** + * @note + * 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 100755 index 0000000..b2f1272 --- /dev/null +++ b/daemon/accessibility.h @@ -0,0 +1,34 @@ +/* + * 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; + +extern Evas_Object *quickpanel_accessibility_screen_reader_object_get(void *obj, screen_reader_object_type_e type, const char *part, Evas_Object *parent); +extern Evas_Object *quickpanel_accessibility_ui_get_focus_object(Evas_Object *parent); +extern char *quickpanel_accessibility_info_cb(void *data, Evas_Object *obj); +extern char *quickpanel_accessibility_info_cb_s(void *data, Evas_Object *obj); +extern 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 new file mode 100755 index 0000000..e32535f --- /dev/null +++ b/daemon/common.c @@ -0,0 +1,398 @@ +/* + * 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" + +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; + + text_len = strlen(text); + + for (i = 0; i < text_len; i++) { + if (*(text + i) == s) { + *(text + i) = 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"); + + struct appdata *ad = quickpanel_get_app_data(); + retif(ad == NULL, , "invalid argument"); + + if (ad->popup == obj) { + ad->popup = NULL; + } else { + ERR("popup is created over the 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(); + retif(ad == NULL, , "invalid argument"); + + 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_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; + package_info_h package_info = NULL; + + ret = package_manager_get_package_info(pkgid, &package_info); + if (ret != PACKAGE_MANAGER_ERROR_NONE) { + ERR("package_manager_get_package_info is failed id : %s %d", pkgid, ret); + return NULL; + } + + ret = package_info_get_icon(package_info, &icon_path); + if (ret != PACKAGE_MANAGER_ERROR_NONE) { + ERR("package_info_get_icon is failed %d", ret); + return NULL; + } + + if (icon_path) { + icon_ret = (char*)strdup(icon_path); + } + + package_info_destroy(package_info); + + return icon_ret; +} + +HAPI char *quickpanel_common_ui_get_pkginfo_label(const char *pkgid) +{ + int ret = 0; + char *label = NULL; + char *label_ret = NULL; + package_info_h package_info = NULL; + + ret = package_manager_get_package_info(pkgid, &package_info); + if (ret != PACKAGE_MANAGER_ERROR_NONE) { + ERR("package_manager_get_package_info is failed %d", ret); + return NULL; + } + + ret = package_info_get_label(package_info, &label); + if (ret != PACKAGE_MANAGER_ERROR_NONE) { + ERR("package_info_get_label is failed %d", ret); + return NULL; + } + + if (label) { + label_ret = (char*)strdup(label); + } + + package_info_destroy(package_info); + + return label_ret; + +} + +HAPI int quickpanel_common_ui_is_package_exist(const char *pkgid) +{ + int ret = 0; + retif(pkgid == NULL, 0, "invalid parameter"); + + package_info_h package_info = NULL; + + ret = package_manager_get_package_info(pkgid, &package_info); + if (ret == PACKAGE_MANAGER_ERROR_NO_SUCH_PACKAGE) { + DBG("package %s isn't exist", pkgid); + return 0; + } + + if (package_info) { + package_info_destroy(package_info); + } + + return 1; +} diff --git a/daemon/common.h b/daemon/common.h new file mode 100755 index 0000000..3b9a541 --- /dev/null +++ b/daemon/common.h @@ -0,0 +1,155 @@ +/* + * 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_H_ +#define __QP_COMMON_H_ + + +#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 + +#define HAPI __attribute__((visibility("hidden"))) + +#define DBG(fmt , args...) \ + do { \ + LOGD("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define INFO(fmt , args...) \ + do { \ + LOGI("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define WARN(fmt , args...) \ + do { \ + LOGI("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define ERR(fmt , args...) \ + do { \ + 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 { \ + debug_printf("[D]%s : %d] "fmt"\n", \ + __func__, __LINE__, ##args); \ + } while (0) + +#define INFO(fmt , args...) \ + do { \ + debug_printf("[I][%s : %d] "fmt"\n",\ + __func__, __LINE__, ##args); \ + } while (0) + +#define WARN(fmt , args...) \ + do { \ + debug_printf("[W][%s : %d] "fmt"\n", \ + __func__, __LINE__, ##args); \ + } while (0) + +#define ERR(fmt , args...) \ + do { \ + debug_printf("[E][%s : %d] "fmt"\n", \ + __func__, __LINE__, ##args); \ + } while (0) + +#else /*_DLOG_USED*/ +#define DBG(fmt , args...) \ + do { \ + fprintf("[D][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define INFO(fmt , args...) \ + do { \ + fprintf("[I][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define WARN(fmt , args...) \ + do { \ + fprintf("[W][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define ERR(fmt , args...) \ + do { \ + fprintf("[E][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) +#endif /*_DLOG_USED*/ + +#define msgif(cond, str, args...) do { \ + if (cond) { \ + ERR(str, ##args);\ + } \ +} while (0); + +#define retif(cond, ret, str, args...) do { \ + if (cond) { \ + ERR(str, ##args);\ + return ret;\ + } \ +} 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); \ + goto target; \ + } \ +} while (0); + +extern void quickpanel_common_util_char_trim(char *text); +extern void quickpanel_common_util_char_replace(char *text, char s, char t); +extern void quickpanel_common_util_add_char_to_each_charactor(char *dst, const char *src, char t); +extern int quickpanel_common_util_is_phone_number(const char *address); +extern void quickpanel_common_util_phone_number_tts_make(char *dst, const char *src, int size); +extern void quickpanel_common_ui_set_current_popup(Evas_Object *popup, Evas_Smart_Cb func_close); +extern void quickpanel_common_ui_del_current_popup(void); +extern void *quickpanel_common_ui_get_buffer_from_image(const char *file_path, size_t *memfile_size, char *ext, int ext_size); +extern char *quickpanel_common_ui_get_pkginfo_icon(const char *pkgid); +extern char *quickpanel_common_ui_get_pkginfo_label(const char *pkgid); +extern 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 100755 index 0000000..7359a7d --- /dev/null +++ b/daemon/common_uic.c @@ -0,0 +1,327 @@ +/* + * 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 + +#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; + } + } + + 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) +{ + struct appdata *ad = quickpanel_get_app_data(); + + DBG("reason:%d", reason); + + retif(ad == NULL, , "Invalid parameter!"); + retif(ad->win == NULL, , "Invalid parameter!"); + + ERR("Not yet implemented"); + +} + +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) +{ + struct appdata *ad = quickpanel_get_app_data(); + + DBG(""); + + if (!ad || !ad->win) { + ERR("Invalid parameter"); + return; + } + + int ret = 0; + ret = tzsh_quickpanel_service_hide(ad->quickpanel_service); + if(ret != 0) { + ERR("failed tzsh_quickpanel_service_hide"); + } + +} + +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) +{ + /* TO DO */ +} diff --git a/daemon/common_uic.h b/daemon/common_uic.h new file mode 100755 index 0000000..2191b25 --- /dev/null +++ b/daemon/common_uic.h @@ -0,0 +1,42 @@ +/* + * 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; + +extern Evas_Object *quickpanel_uic_load_edj(Evas_Object * parent, const char *file, const char *group, int is_just_load); +extern int quickpanel_uic_launch_app(char *app_id, void *data); +extern int quickpanel_uic_launch_ug_by_appcontrol(const char *package, void *data); +extern int quickpanel_uic_is_emul(void); +extern int quickpanel_uic_is_suspended(void); +extern int quickpanel_uic_is_opened(void); +extern void quickpanel_uic_launch_app_inform_result(const char *pkgname, int retcode); +extern void quickpanel_uic_initial_resize(Evas_Object *obj, int height); +extern void quickpanel_uic_close_quickpanel(bool is_check_lock, int is_delay_needed); +extern void quickpanel_uic_open_quickpanel(int reason); +extern void quickpanel_uic_toggle_openning_quickpanel(void); +extern void quickpanel_uic_opened_reason_set(int reason); +extern int quickpanel_uic_opened_reason_get(void); + +#endif /* __QP_COMMON_UIC_H_ */ diff --git a/daemon/datetime/datetime.c b/daemon/datetime/datetime.c new file mode 100755 index 0000000..a1674ec --- /dev/null +++ b/daemon/datetime/datetime.c @@ -0,0 +1,361 @@ +/* + * 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 + +#include "common.h" +#include "common_uic.h" +#include "quickpanel-ui.h" +#include "list_util.h" +#include "quickpanel_def.h" +#include "modules.h" +#include "util-time.h" +#include "media.h" + +#ifdef QP_SCREENREADER_ENABLE +#include "accessibility.h" +#endif + +#ifdef QP_EMERGENCY_MODE_ENABLE +#include "emergency_mode.h" +#endif + +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 *)(long)(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)(long)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); + +#ifdef QP_EMERGENCY_MODE_ENABLE + 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 { +#endif + _flag_set(view, E_DATA_TIME_N_DATE_EVENT, 1); + elm_object_signal_emit(view, "timendate.click.enable", "prog"); +#ifdef QP_EMERGENCY_MODE_ENABLE + } +#endif + + 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, "