From: changjoo.lee Date: Fri, 29 Apr 2016 07:08:02 +0000 (+0900) Subject: Tizen 2.4 migration and fix compile warning X-Git-Tag: accepted/tizen/mobile/20160504.115320^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e89d9d650bde3772577a5cb64bb5a15b4b232bd2;p=platform%2Fcore%2Fsystem%2Fsystem-popup.git Tizen 2.4 migration and fix compile warning Change-Id: I7195e34b082bf98c8139a6f6da38f648733b0a35 Signed-off-by: changjoo.lee --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 062c067..c0ce5f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(${PKGNAME} C) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(SYSTEM_RESDIR "${PREFIX}/share/system-apps/res") +SET(SYSTEM_ICONDIR "${SYSTEM_RESDIR}/icons") SET(LICENSE_DIR "${TZ_SYS_RO_SHARE}/license") SET(DBUS_SERVICE_DIR "${TZ_SYS_RO_SHARE}/dbus-1/system-services") SET(LOCALE_DIR "${TZ_SYS_RO_SHARE}/locale") @@ -10,14 +12,26 @@ SET(LANG_DOMAIN "${PKGNAME}") ADD_DEFINITIONS("-DPKGNAME=\"${PKGNAME}\"") ADD_DEFINITIONS("-DLOCALE_DIR=\"${LOCALE_DIR}\"") ADD_DEFINITIONS("-DLANG_DOMAIN=\"${LANG_DOMAIN}\"") +ADD_DEFINITIONS("-DSYSTEM_ICONDIR=\"${SYSTEM_ICONDIR}\"") ADD_DEFINITIONS("-DPROFILE=\"${PROFILE}\"") ADD_DEFINITIONS("-DFORMFACTOR=\"${FORMFACTOR}\"") +IF(PROFILE STREQUAL mobile) + OPTION(PROFILE_MOBILE "Mobile device" ON) +ENDIF() +IF(PROFILE STREQUAL wearable) + OPTION(PROFILE_WEARABLE "Wearable device" ON) +ENDIF() +IF(PROFILE STREQUAL tv) + OPTION(PROFILE_TV "TV device" ON) +ENDIF() + SET(COMMON_DIR "${CMAKE_SOURCE_DIR}/src/common") SET(COMMON_SRCS ${COMMON_DIR}/core.c ${COMMON_DIR}/popup-common.c ${COMMON_DIR}/popup-ui.c + ${COMMON_DIR}/popup-ui-normal.c ) IF("${FORMFACTOR}" STREQUAL "circle") @@ -41,7 +55,9 @@ SET(COMMON_SRCS ${COMMON_SRCS} ${COMMON_DIR}/popup-ui-dpms-none.c) ENDIF() - +ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(src/crash) ADD_SUBDIRECTORY(src/launcher) ADD_SUBDIRECTORY(src/po) ADD_SUBDIRECTORY(src/poweroff) +ADD_SUBDIRECTORY(signal-sender) \ No newline at end of file diff --git a/data/batt_full_icon.png b/data/batt_full_icon.png new file mode 100755 index 0000000..1eed849 Binary files /dev/null and b/data/batt_full_icon.png differ diff --git a/data/batt_full_indicator.png b/data/batt_full_indicator.png new file mode 100755 index 0000000..6865802 Binary files /dev/null and b/data/batt_full_indicator.png differ diff --git a/data/datausage_warning.png b/data/datausage_warning.png new file mode 100755 index 0000000..7ac94bb Binary files /dev/null and b/data/datausage_warning.png differ diff --git a/data/led_torch.png b/data/led_torch.png new file mode 100755 index 0000000..0731c53 Binary files /dev/null and b/data/led_torch.png differ diff --git a/data/ode_encrypt.png b/data/ode_encrypt.png new file mode 100755 index 0000000..ecb54be Binary files /dev/null and b/data/ode_encrypt.png differ diff --git a/data/sdcard.png b/data/sdcard.png new file mode 100755 index 0000000..cd12ef8 Binary files /dev/null and b/data/sdcard.png differ diff --git a/data/sdcard_decryption.png b/data/sdcard_decryption.png new file mode 100755 index 0000000..1176f43 Binary files /dev/null and b/data/sdcard_decryption.png differ diff --git a/data/sdcard_decryption_error.png b/data/sdcard_decryption_error.png new file mode 100755 index 0000000..9b2a1d0 Binary files /dev/null and b/data/sdcard_decryption_error.png differ diff --git a/data/sdcard_encryption.png b/data/sdcard_encryption.png new file mode 100755 index 0000000..60a996f Binary files /dev/null and b/data/sdcard_encryption.png differ diff --git a/data/sdcard_encryption_error.png b/data/sdcard_encryption_error.png new file mode 100755 index 0000000..f9b3925 Binary files /dev/null and b/data/sdcard_encryption_error.png differ diff --git a/data/sdcard_prepare.png b/data/sdcard_prepare.png new file mode 100755 index 0000000..ed2ec52 Binary files /dev/null and b/data/sdcard_prepare.png differ diff --git a/data/sdcard_removed.png b/data/sdcard_removed.png new file mode 100755 index 0000000..cb29d4e Binary files /dev/null and b/data/sdcard_removed.png differ diff --git a/data/tima.png b/data/tima.png new file mode 100755 index 0000000..3695d72 Binary files /dev/null and b/data/tima.png differ diff --git a/data/usb.png b/data/usb.png new file mode 100755 index 0000000..65e94dc Binary files /dev/null and b/data/usb.png differ diff --git a/data/usb_icon.png b/data/usb_icon.png new file mode 100755 index 0000000..65e94dc Binary files /dev/null and b/data/usb_icon.png differ diff --git a/packaging/org.tizen.crash-syspopup.manifest b/packaging/org.tizen.crash-syspopup.manifest new file mode 100755 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/org.tizen.crash-syspopup.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/org.tizen.system-signal-sender.manifest b/packaging/org.tizen.system-signal-sender.manifest new file mode 100755 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/org.tizen.system-signal-sender.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/org.tizen.system-syspopup.manifest b/packaging/org.tizen.system-syspopup.manifest new file mode 100755 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/org.tizen.system-syspopup.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/system-servant.spec b/packaging/system-servant.spec index d82bb9a..5c51b04 100755 --- a/packaging/system-servant.spec +++ b/packaging/system-servant.spec @@ -6,12 +6,34 @@ %define FORMFACTOR none #Main applications -%define poweroff_popup on +%define poweroff_popup off +%define crash_popup off +%define system_popup off +%define notification_service off +%define signal_sender off +#sub-popups of system-popup +%define battery_popup off +%define mmc_popup off +%define usb_popup off +%define watchdog_popup off +%define overheat_popup off +%define storage_popup off %if "%{?profile}" == "mobile" %define PROFILE mobile #Main applicaitons %define poweroff_popup on +%define crash_popup on +%define system_popup on +%define notification_service on +%define signal_sender on +#sub-popups of system-popup +%define battery_popup on +%define mmc_popup on +%define usb_popup on +%define watchdog_popup on +%define overheat_popup on +%define storage_popup on %endif %if "%{?profile}" == "wearable" @@ -23,10 +45,19 @@ %endif #Main applicaitons %define poweroff_popup on +%define crash_popup on +%define system_popup on +#sub-popups of system-popup +%define storage_popup on +%define watchdog_popup on +%define battery_popup on +%define overheat_popup on %endif %if "%{?profile}" == "tv" %define PROFILE tv +#Main applications +%define crash_popup on %endif Name: system-servant @@ -38,6 +69,11 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest Source1001: org.tizen.poweroff-syspopup.manifest +Source1015: org.tizen.crash-syspopup.manifest +Source2001: org.tizen.system-syspopup.manifest +Source2003: org.tizen.system-signal-sender.manifest +BuildRequires: pkgconfig(appsvc) +BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(appcore-efl) BuildRequires: pkgconfig(syspopup) @@ -63,26 +99,78 @@ BuildRequires: gettext-devel System applications such as app-launcher and service file for dbus activation +%if %{?crash_popup} == on +%package -n org.tizen.crash-syspopup +Summary: System popup application (crash system popup) +Group: System/Utilities +Requires: %{name} = %{version}-%{release} + +%description -n org.tizen.crash-syspopup +to inform user crash information. It is activated +when crash event is happend +%endif + %if %{?poweroff_popup} == on %package -n org.tizen.poweroff-syspopup -Summary: poweroff-popup application -Group: main +Summary: Poweroff-popup application +Group: System/Utilities Requires: %{name} = %{version}-%{release} %description -n org.tizen.poweroff-syspopup -poweroff-popup application. +to inform user poweroff information. It is activated +when user power event is happened +%endif + +%if %{?signal_sender} == on +%package -n org.tizen.system-signal-sender +Summary: System FW signal sender +Group: System/Utilities +Requires: %{name} = %{version}-%{release} + +%description -n org.tizen.system-signal-sender +to inform user system FW signal sender. It is activated +when system event is happend %endif +%if %{?system_popup} == on +%package -n org.tizen.system-syspopup +Summary: System popup application +Group: System/Utilities +Requires: %{name} = %{version}-%{release} + +%description -n org.tizen.system-syspopup +to inform user system information. It is activated +when system event is happend + +%endif # system_popup + %prep %setup -q %build +chmod 0644 %{SOURCE1} cp %{SOURCE1} . %if %{poweroff_popup} == on +chmod 0644 %{SOURCE1001} cp %{SOURCE1001} . %endif +%if %{crash_popup} == on +chmod 0644 %{SOURCE1015} +cp %{SOURCE1015} . +%endif + +%if %{system_popup} == on +chmod 0644 %{SOURCE2001} +cp %{SOURCE2001} . +%endif + +%if %{signal_sender} == on +chmod 0644 %{SOURCE2003} +cp %{SOURCE2003} . +%endif + %define DPMS none %if %{with x} %define DPMS x @@ -103,7 +191,16 @@ cp %{SOURCE1001} . -DTZ_SYS_SHARE=%{TZ_SYS_SHARE} \ -DTZ_SYS_RO_SHARE=%{TZ_SYS_RO_SHARE} \ -DTZ_SYS_RO_APP=%{TZ_SYS_RO_APP} \ - -DPOWEROFF_POPUP=%{poweroff_popup} + -DPOWEROFF_POPUP=%{poweroff_popup} \ + -DCRASH_POPUP=%{crash_popup} \ + -DNOTIFICATION_SERVICE=%{notification_service} \ + -DBATTERY_POPUP=%{battery_popup} \ + -DSYSTEM_POPUP=%{system_popup} \ + -DSIGNAL_SENDER=%{signal_sender} \ + -DMMC_POPUP=%{mmc_popup} \ + -DSTORAGE_POPUP=%{storage_popup} \ + -DUSB_POPUP=%{usb_popup} \ + -DWATCHDOG_POPUP=%{watchdog_popup} \ make %{?jobs:-j%jobs} @@ -181,6 +278,29 @@ rm -rf %{buildroot} %lang(zh_HK) %{_datadir}/locale/zh_HK/LC_MESSAGES/system-servant.mo %lang(zh_TW) %{_datadir}/locale/zh_TW/LC_MESSAGES/system-servant.mo +%if %{notification_service} == on +%{_datadir}/system-apps/res/icons/batt_full_icon.png +%{_datadir}/system-apps/res/icons/batt_full_indicator.png +%{TZ_SYS_RO_SHARE}/system-apps/res/icons/datausage_warning.png +%{TZ_SYS_RO_SHARE}/system-apps/res/icons/led_torch.png +%endif + +%if %{crash_popup} == on +%files -n org.tizen.crash-syspopup +%manifest org.tizen.crash-syspopup.manifest +%license LICENSE +%defattr(-,root,root,-) +%{TZ_SYS_RO_APP}/org.tizen.crash-syspopup/bin/crash-popup +%{TZ_SYS_RO_SHARE}/packages/org.tizen.crash-syspopup.xml +%endif + +%if %{system_popup} == on +%files -n org.tizen.system-syspopup +%manifest org.tizen.system-syspopup.manifest +%defattr(-,root,root,-) +%{TZ_SYS_RO_APP}/org.tizen.system-syspopup/bin/system-syspopup +%{TZ_SYS_RO_SHARE}/packages/org.tizen.system-syspopup.xml +%endif %if %{poweroff_popup} == on %files -n org.tizen.poweroff-syspopup @@ -192,3 +312,11 @@ rm -rf %{buildroot} %{TZ_SYS_RO_APP}/org.tizen.poweroff-syspopup/res/circle_btn_check.png %{TZ_SYS_RO_APP}/org.tizen.poweroff-syspopup/res/circle_btn_delete.png %endif + +%if %{signal_sender} == on +%files -n org.tizen.system-signal-sender +%manifest org.tizen.system-signal-sender.manifest +%defattr(-,root,root,-) +%{TZ_SYS_RO_APP}/org.tizen.system-signal-sender/bin/system-signal-sender +%{TZ_SYS_RO_SHARE}/packages/org.tizen.system-signal-sender.xml +%endif diff --git a/signal-sender/CMakeLists.txt b/signal-sender/CMakeLists.txt new file mode 100755 index 0000000..370374a --- /dev/null +++ b/signal-sender/CMakeLists.txt @@ -0,0 +1,45 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +IF(SIGNAL_SENDER STREQUAL off) + RETURN() +ENDIF(SIGNAL_SENDER STREQUAL off) + +SET(SIGNAL-SENDER_SRCS ${CMAKE_SOURCE_DIR}/signal-sender/signal-sender.c) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${COMMON_DIR}) + +SET(VENDOR "tizen") +SET(PACKAGE "system-signal-sender") +SET(PKGNAME "org.${VENDOR}.${PACKAGE}") +SET(PREFIX "${CMAKE_INSTALL_PREFIX}/apps/${PKGNAME}") +SET(BINDIR "${PREFIX}/bin") +SET(MANIFESTDIR "${CMAKE_INSTALL_PREFIX}/share/packages") + +SET(PKG_MODULES + appcore-efl + edbus + bundle + dlog + elementary + aul +) + +INCLUDE(FindPkgConfig) +pkg_check_modules(signal-sender_pkgs REQUIRED ${PKG_MODULES}) + +FOREACH(flag ${signal-sender_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Wall") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") + +ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") + +ADD_EXECUTABLE(${PACKAGE} ${SIGNAL-SENDER_SRCS}) +TARGET_LINK_LIBRARIES(${PACKAGE} ${signal-sender_pkgs_LDFLAGS} "-ldl") + +INSTALL(TARGETS ${PACKAGE} DESTINATION ${BINDIR}) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/signal-sender/${PKGNAME}.xml DESTINATION ${MANIFESTDIR}) diff --git a/signal-sender/org.tizen.system-signal-sender.xml b/signal-sender/org.tizen.system-signal-sender.xml new file mode 100755 index 0000000..2e0fb33 --- /dev/null +++ b/signal-sender/org.tizen.system-signal-sender.xml @@ -0,0 +1,9 @@ + + + + Giyeol Ok + System signal sender application + + + + diff --git a/signal-sender/signal-sender.c b/signal-sender/signal-sender.c new file mode 100755 index 0000000..24e65ca --- /dev/null +++ b/signal-sender/signal-sender.c @@ -0,0 +1,373 @@ +/* + * system-popup + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * 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 "macro.h" + +#define DBUS_REPLY_TIMEOUT (120 * 1000) +#define BUF_MAX 256 + +#define MMC_ENCRYPTION_UG "setting-mmc-encryption-efl" +#define SECURITY_UG "setting-security-efl" + +enum ode_error_type { + NOT_ENOUGH_SPACE, + OPERATION_FAILED, + ODE_ERROR_MAX, +}; + +static bool (*is_storage_encryption_restricted)(void) = NULL; + +void register_storage_encryption_restricted_function(bool (*func)(void)) +{ + if (func) + is_storage_encryption_restricted = func; +} + +static Eina_Bool exit_idler_cb(void *data) +{ + elm_exit(); + return ECORE_CALLBACK_CANCEL; +} + +static void sender_terminate(void) +{ + if (ecore_idler_add(exit_idler_cb, NULL)) + return; + exit_idler_cb(NULL); +} + +static int append_variant(DBusMessageIter *iter, const char *sig, char *param[]) +{ + char *ch; + int i, int_type; + + if (!sig || !param) + return 0; + + for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) { + switch (*ch) { + case 's': + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, ¶m[i]); + break; + case 'i': + int_type = atoi(param[i]); + dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &int_type); + break; + default: + _E("ERROR: %s %c", sig, *ch); + return -EINVAL; + } + } + return 0; +} + +DBusMessage *call_dbus_method(const char *dest, const char *path, + const char *interface, const char *method, + const char *sig, char *param[]) +{ + DBusConnection *conn; + DBusMessage *msg = NULL; + DBusMessageIter iter; + DBusMessage *ret; + DBusError err; + int r; + + conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); + if (!conn) { + ret = NULL; + goto out; + } + + msg = dbus_message_new_method_call(dest, path, interface, method); + if (!msg) { + ret = NULL; + goto out; + } + + dbus_message_iter_init_append(msg, &iter); + r = append_variant(&iter, sig, param); + if (r < 0) { + ret = NULL; + goto out; + } + + /*This function is for synchronous dbus method call */ + dbus_error_init(&err); + ret = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err); + dbus_error_free(&err); + +out: + dbus_message_unref(msg); + + return ret; +} + +int request_to_launch_by_dbus(char *bus, char *path, char *iface, + char *method, char *ptype, char *param[]) +{ + DBusMessage *msg; + DBusError err; + int i, r, ret_val; + + i = 0; + do { + msg = call_dbus_method(bus, path, iface, method, ptype, param); + if (msg) + break; + i++; + } while (i < RETRY_MAX); + if (!msg) { + _E("fail to call dbus method"); + return -ECONNREFUSED; + } + + dbus_error_init(&err); + r = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID); + if (!r) { + _E("no message : [%s:%s]", err.name, err.message); + ret_val = -EBADMSG; + } + + dbus_message_unref(msg); + dbus_error_free(&err); + + return ret_val; +} + +static int send_recovery_popup_signal(void) +{ + char *param[2]; + + param[0] = "_SYSPOPUP_CONTENT_"; + param[1] = "recovery"; + + return request_to_launch_by_dbus(BUS_NAME, POPUP_PATH_SYSTEM, POPUP_IFACE_SYSTEM, + "RecoveryPopupLaunch", "ss", param); +} + +static int send_usbstorage_unmount_popup_signal(char *path) +{ + char *param[4]; + char buf[BUF_MAX]; + + if (!path) + return -EINVAL; + + snprintf(buf, sizeof(buf), "%s", path); + + param[0] = "_SYSPOPUP_CONTENT_"; + param[1] = "usbotg_unmount_storage"; + param[2] = "_DEVICE_PATH_"; + param[3] = buf; + + return request_to_launch_by_dbus(BUS_NAME, POPUP_PATH_SYSTEM, POPUP_IFACE_SYSTEM, + "PopupLaunchDouble", "ssss", param); +} + +static int get_err_and_space(bundle *b, char *type, + char *error, int error_len, char *space, int space_len) +{ + char *cErr, *spc; + int iErr; + + cErr = (char *)bundle_get_val(b, SIGNAL_SENDER_ERROR_TYPE); + if (!cErr) { + _E("Failed to get error type"); + return -ENOMEM; + } + + spc = (char *)bundle_get_val(b, SIGNAL_SENDER_MEMORY_SPACE); + if (!spc) { + _E("Failed to get memory space"); + return -ENOMEM; + } + + iErr = atoi(cErr); + switch (iErr) { + case NOT_ENOUGH_SPACE: + snprintf (error, error_len, "%s_not_enough_space", type); + break; + case OPERATION_FAILED: + snprintf (error, error_len, "%s_operation_failed", type); + break; + default: + _E("Unknown type (%d)", iErr); + return -EINVAL; + } + + snprintf(space, space_len, "%s", spc); + + return 0; +} + +static int send_ode_error_popup_signal(bundle *b, char *type) +{ + int ret; + char error[BUF_MAX]; + char space[BUF_MAX]; + char *param[6]; + + if (!b || !type) + return -EINVAL; + + ret = get_err_and_space(b, type, + error, sizeof(error), space, sizeof(space)); + if (ret < 0) + return ret; + + param[0] = "_SYSPOPUP_CONTENT_"; + param[1] = "ode_error"; + param[2] = SIGNAL_SENDER_ERROR_TYPE; + param[3] = error; + param[4] = SIGNAL_SENDER_MEMORY_SPACE; + param[5] = space; + + return request_to_launch_by_dbus(BUS_NAME, POPUP_PATH_SYSTEM, POPUP_IFACE_SYSTEM, + "PopupLaunchTriple", "ssssss", param); +} + +static int load_ode_setting_ug(void) +{ + char *setting_ug; + bundle *b; + int ret; + bool restricted = false; + + if (is_storage_encryption_restricted) + restricted = is_storage_encryption_restricted(); + + if (restricted) + setting_ug = SECURITY_UG; + else + setting_ug = MMC_ENCRYPTION_UG; + + b = bundle_create(); + if (!b) + return -ENOMEM; + + ret = aul_launch_app(setting_ug, b); + bundle_free(b); + if (ret <= 0) { + _E("Failed to launch app (%s)(%d)", setting_ug, ret); + return ret; + } + + return 0; +} + +static int app_create(void *data) +{ + return 0; +} + +static int app_terminate(void *data) +{ + return 0; +} + +static int app_pause(void *data) +{ + return 0; +} + +static int app_resume(void *data) +{ + return 0; +} + +static int app_reset(bundle *b, void *data) +{ + char *type; + char *path; + int ret; + + if (!b) { + ret = -EINVAL; + goto out; + } + + type = (char *)bundle_get_val(b, SIGNAL_SENDER_TYPE); + if (!type) { + _E("FAIL: bundle_get_val()"); + ret = -ENOMEM; + goto out; + } + + if (!strncmp(type, SIGNAL_SENDER_TYPE_RECOVERY, strlen(SIGNAL_SENDER_TYPE_RECOVERY))) { + ret = send_recovery_popup_signal(); + goto out; + } + + if (!strncmp(type, SIGNAL_SENDER_TYPE_USBSTORAGE_UNMOUNT, + strlen(SIGNAL_SENDER_TYPE_USBSTORAGE_UNMOUNT))) { + path = (char *)bundle_get_val(b, "_DEVICE_PATH_"); + if (!path) { + _E("FAIL: bundle_get_val()"); + ret = -ENOMEM; + goto out; + } + + ret = send_usbstorage_unmount_popup_signal(path); + goto out; + } + + if (!strncmp(type, SIGNAL_SENDER_TYPE_ENCRYPT, strlen(SIGNAL_SENDER_TYPE_ENCRYPT))) { + ret = send_ode_error_popup_signal(b, type); + goto out; + } + + if (!strncmp(type, SIGNAL_SENDER_TYPE_DECRYPT, strlen(SIGNAL_SENDER_TYPE_DECRYPT))) { + ret = send_ode_error_popup_signal(b, type); + goto out; + } + + if (!strncmp(type, SIGNAL_SENDER_TYPE_ODE_UG, strlen(type))) { + ret = load_ode_setting_ug(); + goto out; + } + + ret = -EINVAL; + +out: + sender_terminate(); + return ret; +} + +int main(int argc, char *argv[]) +{ + struct appcore_ops ops = { + .create = app_create, + .terminate = app_terminate, + .pause = app_pause, + .resume = app_resume, + .reset = app_reset, + }; + + return appcore_efl_main(PACKAGE, &argc, &argv, &ops); +} diff --git a/signal-sender/signal-sender.h b/signal-sender/signal-sender.h new file mode 100755 index 0000000..fe6a931 --- /dev/null +++ b/signal-sender/signal-sender.h @@ -0,0 +1,25 @@ +/* + * system-popup + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. + * + * 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 __SIGNAL_SENDER_H__ +#define __SIGNAL_SENDER_H__ + +#include "macro.h" + +void register_storage_encryption_restricted_function(bool (*func)(void)); + +#endif /* __SIGNAL_SENDER_H__ */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100755 index 0000000..01ace6c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,100 @@ +####### System-popup ############# +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +IF(SYSTEM_POPUP STREQUAL off) + RETURN() +ENDIF() + +SET(TABLE_PATH ${CMAKE_SOURCE_DIR}/edcs/table) + +#common module +SET(SRCS ${COMMON_SRCS}) + +IF(WATCHDOG_POPUP STREQUAL on) + SET(SRCS ${SRCS} watchdog/watchdog.c) +ENDIF() + +IF(BATTERY_POPUP STREQUAL on) + IF(PROFILE_WEARABLE) + SET(SRCS ${SRCS} battery/battery-wearable.c) + ENDIF() + IF (PROFILE_MOBILE) + SET(SRCS ${SRCS} battery/battery-mobile.c) + ENDIF() +ENDIF(BATTERY_POPUP STREQUAL on) + +IF(STORAGE_POPUP STREQUAL on) + IF(PROFILE_WEARABLE) + SET(SRCS ${SRCS} storage/lowstorage-wearable.c) + ENDIF() + + IF(PROFILE_MOBILE) + SET(SRCS ${SRCS} storage/lowstorage-mobile.c) + ENDIF() +ENDIF(STORAGE_POPUP STREQUAL on) + +IF(MMC_POPUP STREQUAL on) + IF(PROFILE_MOBILE) + SET(SRCS ${SRCS} mmc/mmc-mobile.c) + ENDIF() +ENDIF(MMC_POPUP STREQUAL on) + +IF(USB_POPUP STREQUAL on) + IF(PROFILE_MOBILE) + SET(SRCS ${SRCS} usb/usb-mobile.c + usb/usbotg-mobile.c + usb/usb-device.c) + ENDIF() +ENDIF(USB_POPUP STREQUAL on) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/common) + +SET(VENDOR "tizen") +SET(PACKAGE "system-syspopup") +SET(PKGNAME "org.${VENDOR}.${PACKAGE}") +SET(PREFIX "${CMAKE_INSTALL_PREFIX}/apps/${PKGNAME}") +SET(BINDIR "${PREFIX}/bin") +SET(RESDIR "${PREFIX}/res") +SET(MANIFESTDIR "${CMAKE_INSTALL_PREFIX}/share/packages") + +SET(PKG_MODULES + appcore-efl + bundle + dlog + ecore + evas + syspopup + vconf + elementary + deviced + feedback + efl-extension + appsvc + edbus + capi-appfw-application +) + +INCLUDE(FindPkgConfig) +pkg_check_modules(system_pkgs REQUIRED ${PKG_MODULES}) + +FOREACH(flag ${system_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O2 -g -Wall -fpie") + +ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") +ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +ADD_EXECUTABLE(${PACKAGE} ${SRCS}) + +TARGET_LINK_LIBRARIES(${PACKAGE} syspopup ${system_pkgs_LDFLAGS}) + +INSTALL(TARGETS ${PACKAGE} DESTINATION ${BINDIR}) + +# install manifest file +INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/${PKGNAME}.xml DESTINATION ${MANIFESTDIR}) +############## END ############## diff --git a/src/battery/battery-mobile.c b/src/battery/battery-mobile.c new file mode 100755 index 0000000..d69d219 --- /dev/null +++ b/src/battery/battery-mobile.c @@ -0,0 +1,259 @@ +/* + * system-popup + * + * Copyright (c) 2014 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 "popup-common.h" + +#define DEVICED_PATH_SYSNOTI "/Org/Tizen/System/DeviceD/SysNoti" +#define DEVICED_INTERFACE_SYSNOTI "org.tizen.system.deviced.SysNoti" +#define SIGNAL_CHARGEERR_RESPONSE "ChargeErrResponse" + +#define SYSTEMD_STOP_POWER_OFF 4 +#define POWER_BUS_NAME "org.tizen.system.deviced" +#define POWER_OBJECT_PATH "/Org/Tizen/System/DeviceD/Power" +#define POWER_INTERFACE_NAME POWER_BUS_NAME".power" +#define POWER_METHOD "reboot" +#define POWER_OPERATION_OFF "poweroff" + +static const struct popup_ops lowbattery_warning_ops; +static const struct popup_ops lowbattery_critical_ops; +static const struct popup_ops lowbattery_poweroff_ops; +static const struct popup_ops charge_error_low_ops; +static const struct popup_ops charge_error_high_ops; +static const struct popup_ops battery_disconnected_ops; + +static int lowbattery_launch(bundle *b, const struct popup_ops *ops); +static int remove_other_charge_popups(bundle *b, const struct popup_ops *ops); + + +static void remove_other_lowbattery_popups(const struct popup_ops *ops) +{ + _D("remove_other_lowbattery_popups() is finished"); + if (ops != &lowbattery_warning_ops) + unload_simple_popup(&lowbattery_warning_ops); + + if (ops != &lowbattery_critical_ops) + unload_simple_popup(&lowbattery_critical_ops); + + if (ops != &lowbattery_poweroff_ops) + unload_simple_popup(&lowbattery_poweroff_ops); +} + +static int remove_other_charge_popups(bundle *b, const struct popup_ops *ops) +{ + _D("remove_other_charge_popups() is finished"); + if (ops != &charge_error_low_ops) + unload_simple_popup(&charge_error_low_ops); + + if (ops != &charge_error_high_ops) + unload_simple_popup(&charge_error_high_ops); + + if (ops != &battery_disconnected_ops) + unload_simple_popup(&battery_disconnected_ops); + + return 0; +} + +static void charger_status_changed(keynode_t *key, void *data) +{ + int status; + const struct popup_ops *ops = data; + + _D("charger_status_changed() is finished"); + status = vconf_keynode_get_int(key); + if (status != VCONFKEY_SYSMAN_CHARGER_CONNECTED) + return; + + if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, + charger_status_changed) < 0) + _E("Failed to release vconf key handler"); + + unload_simple_popup(ops); + + terminate_if_no_popup(); +} + +static void unregister_charger_status_handler(void) +{ + _D("unregister_charger_status_handler() is finished"); + vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, + charger_status_changed); +} + +static void register_charger_status_handler(const struct popup_ops *ops) +{ + _D("register_charger_status_handler() is finished"); + if (vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, + charger_status_changed, (void *)ops) < 0) + _E("Failed to register vconf key handler"); +} + +static int lowbattery_launch(bundle *b, const struct popup_ops *ops) +{ + _D("lowbattery_launch() is finished"); + unregister_charger_status_handler(); + remove_other_lowbattery_popups(ops); + register_charger_status_handler(ops); + + return 0; +} + +static void lowbattery_terminate(const struct popup_ops *ops) +{ + _D("lowbattery_terminate() is finished"); + unregister_charger_status_handler(); +} + +static void poweroff_clicked(const struct popup_ops *ops) +{ + Evas_Object *rect, *win; + Evas_Coord w, h, size; + static int bPowerOff = 0; + char *param[2]; + char data[8]; + int ret; + + _D("poweroff_clicked() is finished"); + if (bPowerOff == 1) + return; + bPowerOff = 1; + + unload_simple_popup(ops); + + win = get_window(); + if (!win) + popup_terminate(); + + rect = evas_object_rectangle_add(evas_object_evas_get(win)); + evas_object_geometry_get(win, NULL, NULL, &w, &h); + size = max(w, h); + evas_object_resize(rect, size, size); + evas_object_color_set(rect, 0, 0, 0, 255); + evas_object_show(rect); + + if (vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, SYSTEMD_STOP_POWER_OFF) != 0) + _E("Failed to request poweroff to deviced"); + + param[0] = POWER_OPERATION_OFF; + snprintf(data, sizeof(data), "0"); + param[1] = data; + ret = popup_dbus_method_sync(POWER_BUS_NAME, + POWER_OBJECT_PATH, + POWER_INTERFACE_NAME, + POWER_METHOD, + "si", param); + if (ret < 0) + _E("Failed to request poweroff to deviced (%d)", ret); + +} + +static void charge_error_ok_clicked(const struct popup_ops *ops) +{ + _I("OK is selected"); + unload_simple_popup(ops); + + if (broadcast_dbus_signal(DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + SIGNAL_CHARGEERR_RESPONSE, + NULL, NULL) < 0) + _E("Failed to send signal"); + + terminate_if_no_popup(); +} + +static int remove_battery_popups(bundle *b, const struct popup_ops *ops) +{ + _I("Remove battery related popups"); + unload_simple_popup(&lowbattery_critical_ops); + unload_simple_popup(&lowbattery_warning_ops); + unload_simple_popup(&lowbattery_poweroff_ops); + unload_simple_popup(&charge_error_low_ops); + unload_simple_popup(&charge_error_high_ops); + unload_simple_popup(&battery_disconnected_ops); + terminate_if_no_popup(); + + return 0; +} + +static const struct popup_ops lowbattery_warning_ops = { + .name = "lowbattery_warning", + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERYLOW", + .left_text = "IDS_COM_SK_OK", + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + +static const struct popup_ops lowbattery_critical_ops = { + .name = "lowbattery_critical", + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERYLOW", + .left_text = "IDS_COM_SK_OK", + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + +static const struct popup_ops lowbattery_poweroff_ops = { + .name = "lowbattery_poweroff", + .show = load_simple_popup, + .content = "IDS_COM_POP_LOW_BATTERY_PHONE_WILL_SHUT_DOWN", + .left_text = "IDS_COM_SK_OK", + .left = poweroff_clicked, + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + +static const struct popup_ops battery_remove_ops = { + .name = "remove_battery_popups", + .show = remove_battery_popups, +}; + +static const struct popup_ops charge_error_low_ops = { + .name = "chargeerrlow",//"charge_error_low", + .show = load_simple_popup, + .content = "IDS_QP_BODY_CHARGING_PAUSED_BATTERY_TEMPERATURE_TOO_LOW", + .left_text = "IDS_COM_SK_OK", + .left = charge_error_ok_clicked, + .pre = remove_other_charge_popups, +}; + +static const struct popup_ops charge_error_high_ops = { + .name = "chargeerrhigh",//"charge_error_high", + .show = load_simple_popup, + .content = "IDS_QP_BODY_CHARGING_PAUSED_BATTERY_TEMPERATURE_TOO_HIGH", + .left_text = "IDS_COM_SK_OK", + .left = charge_error_ok_clicked, + .pre = remove_other_charge_popups, +}; + +static const struct popup_ops battery_disconnected_ops = { + .name = "battdisconnect",//"battery_disconnected", + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERY_DISCONNECTED_ABB", + .left_text = "IDS_COM_SK_OK", +}; + +/* Constructor to register lowbattery button */ +static __attribute__ ((constructor)) void battery_register_popup(void) +{ + register_popup(&lowbattery_warning_ops); + register_popup(&lowbattery_critical_ops); + register_popup(&lowbattery_poweroff_ops); + register_popup(&charge_error_low_ops); + register_popup(&charge_error_high_ops); + register_popup(&battery_disconnected_ops); +} diff --git a/src/battery/battery-werable.c b/src/battery/battery-werable.c new file mode 100755 index 0000000..86b5736 --- /dev/null +++ b/src/battery/battery-werable.c @@ -0,0 +1,208 @@ +/* + * system-popup + * + * Copyright (c) 2014 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 "popup-common.h" + +#define DEVICED_PATH_SYSNOTI "/Org/Tizen/System/DeviceD/SysNoti" +#define DEVICED_INTERFACE_SYSNOTI "org.tizen.system.deviced.SysNoti" +#define SIGNAL_CHARGEERR_RESPONSE "ChargeErrResponse" + +static const struct popup_ops lowbattery_warning_ops; +static const struct popup_ops lowbattery_critical_ops; +static const struct popup_ops lowbattery_poweroff_ops; +static const struct popup_ops charge_error_low_ops; +static const struct popup_ops charge_error_high_ops; +static const struct popup_ops battery_disconnected_ops; + +static void lowbattery_launch(bundle *b, const struct popup_ops *ops); + +static void remove_other_lowbattery_popups(const struct popup_ops *ops) +{ + if (ops != &lowbattery_warning_ops) + unload_simple_popup(&lowbattery_warning_ops); + + if (ops != &lowbattery_critical_ops) + unload_simple_popup(&lowbattery_critical_ops); + + if (ops != &lowbattery_poweroff_ops) + unload_simple_popup(&lowbattery_poweroff_ops); +} + +static void remove_other_charge_popups(bundle *b, const struct popup_ops *ops) +{ + if (ops != &charge_error_low_ops) + unload_simple_popup(&charge_error_low_ops); + + if (ops != &charge_error_high_ops) + unload_simple_popup(&charge_error_high_ops); + + if (ops != &battery_disconnected_ops) + unload_simple_popup(&battery_disconnected_ops); +} + +static void charger_status_changed(keynode_t *key, void *data) +{ + int status; + const struct popup_ops *ops = data; + + status = vconf_keynode_get_int(key); + if (status != VCONFKEY_SYSMAN_CHARGER_CONNECTED) + return; + + if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, + charger_status_changed) < 0) + _E("Failed to release vconf key handler"); + + unload_simple_popup(ops); + + terminate_if_no_popup(); +} + +static void unregister_charger_status_handler(void) +{ + vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, + charger_status_changed); +} + +static void register_charger_status_handler(const struct popup_ops *ops) +{ + if (vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, + charger_status_changed, (void *)ops) < 0) + _E("Failed to register vconf key handler"); +} + +static void lowbattery_launch(bundle *b, const struct popup_ops *ops) +{ + unregister_charger_status_handler(); + remove_other_lowbattery_popups(ops); + register_charger_status_handler(ops); +} + +static void lowbattery_terminate(const struct popup_ops *ops) +{ + unregister_charger_status_handler(); +} + +static void poweroff_clicked(const struct popup_ops *ops) +{ + _I("Power off the phone"); + unload_simple_popup(ops); + + if (vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, + VCONFKEY_SYSMAN_POWER_OFF_DIRECT) != 0) + _E("Failed to request poweroff to deviced"); + + terminate_if_no_popup(); +} + +static void charge_error_ok_clicked(const struct popup_ops *ops) +{ + _I("OK is selected"); + unload_simple_popup(ops); + + if (broadcast_dbus_signal(DEVICED_PATH_SYSNOTI, + DEVICED_INTERFACE_SYSNOTI, + SIGNAL_CHARGEERR_RESPONSE, + NULL, NULL) < 0) + _E("Failed to send signal"); + + terminate_if_no_popup(); +} + +static int remove_battery_popups(bundle *b, const struct popup_ops *ops) +{ + _I("Remove battery related popups"); + unload_simple_popup(&lowbattery_critical_ops); + unload_simple_popup(&lowbattery_warning_ops); + unload_simple_popup(&lowbattery_poweroff_ops); + unload_simple_popup(&charge_error_low_ops); + unload_simple_popup(&charge_error_high_ops); + unload_simple_popup(&battery_disconnected_ops); + terminate_if_no_popup(); + return 0; +} + +static const struct popup_ops lowbattery_warning_ops = { + .name = "lowbattery_warning", + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERYLOW", + .left_text = "IDS_COM_SK_OK", + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + +static const struct popup_ops lowbattery_critical_ops = { + .name = "lowbattery_critical", + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERYLOW", + .left_text = "IDS_COM_SK_OK", + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + +static const struct popup_ops lowbattery_poweroff_ops = { + .name = "lowbattery_poweroff", + .show = load_simple_popup, + .content = "IDS_COM_POP_LOW_BATTERY_PHONE_WILL_SHUT_DOWN", + .left_text = "IDS_COM_SK_OK", + .left = poweroff_clicked, + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + +static const struct popup_ops battery_remove_ops = { + .name = "remove_battery_popups", + .show = remove_battery_popups, +}; + +static const struct popup_ops charge_error_low_ops = { + .name = "chargeerrlow",//"charge_error_low", + .show = load_simple_popup, + .content = "IDS_QP_BODY_CHARGING_PAUSED_BATTERY_TEMPERATURE_TOO_LOW", + .left_text = "IDS_COM_SK_OK", + .left = charge_error_ok_clicked, + .pre = remove_other_charge_popups, +}; + +static const struct popup_ops charge_error_high_ops = { + .name = "chargeerrhigh",//"charge_error_high", + .show = load_simple_popup, + .content = "IDS_QP_BODY_CHARGING_PAUSED_BATTERY_TEMPERATURE_TOO_HIGH", + .left_text = "IDS_COM_SK_OK", + .left = charge_error_ok_clicked, + .pre = remove_other_charge_popups, +}; + +static const struct popup_ops battery_disconnected_ops = { + .name = "battdisconnect",//"battery_disconnected", + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERY_DISCONNECTED_ABB", + .left_text = "IDS_COM_SK_OK", +}; + +/* Constructor to register lowbattery button */ +static __attribute__ ((constructor)) void battery_register_popup(void) +{ + register_popup(&lowbattery_warning_ops); + register_popup(&lowbattery_critical_ops); + register_popup(&lowbattery_poweroff_ops); + register_popup(&charge_error_low_ops); + register_popup(&charge_error_high_ops); + register_popup(&battery_disconnected_ops); +} diff --git a/src/common/core.c b/src/common/core.c index 7009139..3e66a09 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -22,6 +22,8 @@ static syspopup_handler handler; static GList *popup_list = NULL; +extern int reset_window_priority(int priority); + GList *get_popup_list(void) { return popup_list; @@ -221,7 +223,7 @@ static int app_reset(bundle *b, void *data) } /* change window priority to normal */ - reset_window_priority(WIN_PRIORITY_HIGH); + (void)reset_window_priority(WIN_PRIORITY_HIGH); } ret = load_popup_by_type(b); diff --git a/src/common/macro.h b/src/common/macro.h index d35bb7f..3227d95 100755 --- a/src/common/macro.h +++ b/src/common/macro.h @@ -66,5 +66,21 @@ #define POPUP_PATH_APP POPUP_DBUS_PATH"/Apps" #define POPUP_IFACE_APP BUS_NAME".Apps" + +/* App to launch a popup on a notification */ +#define SYSTEM_SIGNAL_SENDER "org.tizen.system-signal-sender" +#define SIGNAL_SENDER_TYPE "_SIGNAL_TYPE_" +#define SIGNAL_SENDER_TYPE_RECOVERY "recovery-popup" +#define SIGNAL_SENDER_TYPE_USBSTORAGE_UNMOUNT "usbstorage-unmount-popup" +#define SIGNAL_SENDER_TYPE_ENCRYPT ODE_ENCRYPT +#define SIGNAL_SENDER_TYPE_DECRYPT ODE_DECRYPT +#define SIGNAL_SENDER_TYPE_ODE_UG "ode-setting-ug" +#define SIGNAL_SENDER_DEVICE_PATH "_DEVICE_PATH_" +#define SIGNAL_SENDER_ERROR_TYPE "_ERROR_TYPE_" +#define SIGNAL_SENDER_MEMORY_SPACE "_MEMORY_SPACE_" + +/* ODE */ +#define ODE_ENCRYPT "encrypt" +#define ODE_DECRYPT "decrypt" #endif /* __MACRO_H__ */ diff --git a/src/crash/CMakeLists.txt b/src/crash/CMakeLists.txt new file mode 100755 index 0000000..299a481 --- /dev/null +++ b/src/crash/CMakeLists.txt @@ -0,0 +1,65 @@ +#################### Crash ######################### +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +IF("${CRASH_POPUP}" STREQUAL "off") + RETURN() +ENDIF("${CRASH_POPUP}" STREQUAL "off") + +SET(CRASH_SRCS ${COMMON_SRCS} crash.c) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${COMMON_DIR}) + +SET(VENDOR "tizen") +SET(PACKAGE "crash-syspopup") +SET(EXECNAME "crash-popup") +SET(PKGNAME "org.${VENDOR}.${PACKAGE}") +SET(CRASH_PREFIX "${TZ_SYS_RO_APP}/${PKGNAME}") +SET(BINDIR "${CRASH_PREFIX}/bin") +SET(RESDIR "${CRASH_PREFIX}/res") +SET(MANIFESTDIR "${TZ_SYS_RO_SHARE}/packages") + +SET(PKG_MODULES + appcore-efl + elementary + dlog + deviced + evas + ecore + edbus + vconf + syspopup + syspopup-caller + feedback + efl-extension + pkgmgr-info +) + +IF("${DPMS}" STREQUAL "x") +SET(PKG_MODULES ${PKG_MODULES} + ecore-x + utilX +) +ENDIF("${DPMS}" STREQUAL "x") + +INCLUDE(FindPkgConfig) +pkg_check_modules(crash_pkgs REQUIRED ${PKG_MODULES}) + +FOREACH(flag ${crash_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O2 -g -Wall -fpie") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fpie") +SET(CMAKE_C_FLAGS_RELEASE "-O2 -fpie") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +ADD_EXECUTABLE(${EXECNAME} ${CRASH_SRCS}) +TARGET_LINK_LIBRARIES(${EXECNAME} ${crash_pkgs_LDFLAGS}) + +INSTALL(TARGETS ${EXECNAME} DESTINATION ${TZ_SYS_RO_APP}/${PKGNAME}/bin) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/crash/${PKGNAME}.xml DESTINATION ${MANIFESTDIR}) diff --git a/src/crash/crash.c b/src/crash/crash.c new file mode 100755 index 0000000..02cb563 --- /dev/null +++ b/src/crash/crash.c @@ -0,0 +1,149 @@ +/* + * system-popup + * + * Copyright (c) 2014 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 "popup-common.h" +#include + +#define BUF_MAX 256 + +static int appinfo_get_appname_func(pkgmgrinfo_appinfo_h handle, void *data) +{ + char *str = NULL; + char *label; + int ret; + + _D("appinfo_get_appname_func() is entered"); + if (!data) + return PMINFO_R_ERROR; + + ret = pkgmgrinfo_appinfo_get_label(handle, &str); + if (ret != PMINFO_R_OK) + return ret; + + if (!str) + return PMINFO_R_ERROR; + + label = strdup(str); + if (!label) + return PMINFO_R_ERROR; + + (*(char**)data) = label; + + _D("appinfo_get_appname_func() is finished"); + return PMINFO_R_OK; +} + +static int get_app_name(char *exepath, char *tname, unsigned int len) +{ + pkgmgrinfo_appinfo_filter_h handle = NULL; + int count, ret; + char *name = NULL; + + _D("get_app_name() is entered"); + ret = pkgmgrinfo_appinfo_filter_create(&handle); + if (ret != PMINFO_R_OK) + goto out; + + ret = pkgmgrinfo_appinfo_filter_add_string(handle, + PMINFO_APPINFO_PROP_APP_EXEC, exepath); + if (ret != PMINFO_R_OK) + goto out; + + ret = pkgmgrinfo_appinfo_filter_count(handle, &count); + if (ret != PMINFO_R_OK) + goto out; + + if (count < 1) + goto out; + + ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, + appinfo_get_appname_func, &name); + if (ret != PMINFO_R_OK) { + name = NULL; + goto out; + } + +out: + if (handle) + pkgmgrinfo_appinfo_filter_destroy(handle); + if (!name) + return -ENOENT; + + snprintf(tname, len, "%s", name); + free(name); + _D("get_app_name() is finished"); + return 0; +} + +static int crash_get_content(const struct popup_ops *ops, char *content, unsigned int len) +{ + int ret; + unsigned int l; + struct object_ops *obj; + char *text, *name, *path; + char tname[BUF_MAX]; + + if (!ops || !content) + return -EINVAL; + + _D("crash_get_content() is entered"); + ret = get_object_by_ops(ops, &obj); + if (ret < 0) { + _E("Failed to get object (%d)", ret); + return -ENOENT; + } + + name = (char *)bundle_get_val(obj->b, "_PROCESS_NAME_"); + if (!name) { + _E("Failed to get process name"); + return -ENOENT; + } + + path = (char *)bundle_get_val(obj->b, "_EXEPATH_"); + if (!path) { + _E("Failed to get execution path"); + return -ENOENT; + } + + l = sizeof(tname); + ret = get_app_name(path, tname, l); + if (ret < 0) + snprintf(tname, l, "%s", name); + + _I("name(%s), path(%s), tname(%s)", name, path, tname); + + text = _("IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"); + snprintf(content, len, text, tname); + + _D("crash_get_content() is finished"); + return 0; +} + +static const struct popup_ops crash_ops = { + .name = "crash", + .show = load_simple_popup, + .title = "IDS_COM_HEADER_ATTENTION", + .get_content = crash_get_content, + .left_text = "IDS_COM_SK_OK", +}; + +static __attribute__ ((constructor)) void crash_register_popup(void) +{ + register_popup(&crash_ops); +} diff --git a/src/crash/org.tizen.crash-syspopup.xml b/src/crash/org.tizen.crash-syspopup.xml new file mode 100755 index 0000000..09e6e53 --- /dev/null +++ b/src/crash/org.tizen.crash-syspopup.xml @@ -0,0 +1,10 @@ + + + + Giyeol Ok + Crash popup application (crash popup) + + + + diff --git a/src/launcher/CMakeLists.txt b/src/launcher/CMakeLists.txt index 57e0219..afeb172 100755 --- a/src/launcher/CMakeLists.txt +++ b/src/launcher/CMakeLists.txt @@ -5,8 +5,14 @@ SET(APPNAME "sysapp-launcher") SET(SRCS ${LAUNCHER_DIR}/launcher.c ${LAUNCHER_DIR}/popup.c + ${LAUNCHER_DIR}/app.c + ${LAUNCHER_DIR}/noti.c ) +IF(NOTIFICATION_SERVICE STREQUAL on) + SET(SRCS ${SRCS} ${LAUNCHER_DIR}/noti.c ) +ENDIF(NOTIFICATION_SERVICE STREQUAL on) + INCLUDE_DIRECTORIES(${COMMON_DIR}) SET(PKG_MODULES @@ -16,6 +22,8 @@ SET(PKG_MODULES elementary syspopup-caller appcore-common + appsvc + notification ) INCLUDE(FindPkgConfig) @@ -38,3 +46,10 @@ INSTALL(TARGETS ${APPNAME} DESTINATION bin) INSTALL(FILES ${LAUNCHER_DIR}/org.tizen.system.popup.service DESTINATION ${DBUS_SERVICE_DIR}) INSTALL(FILES ${LAUNCHER_DIR}/launcher.conf DESTINATION /etc/dbus-1/system.d) INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${LICENSE_DIR} RENAME ${APPNAME}) + +IF(NOTIFICATION_SERVICE STREQUAL on) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/datausage_warning.png DESTINATION ${SYSTEM_ICONDIR}) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/led_torch.png DESTINATION ${SYSTEM_ICONDIR}) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/batt_full_icon.png DESTINATION ${SYSTEM_ICONDIR}) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/batt_full_indicator.png DESTINATION ${SYSTEM_ICONDIR}) +ENDIF(NOTIFICATION_SERVICE STREQUAL on) \ No newline at end of file diff --git a/src/launcher/app.c b/src/launcher/app.c new file mode 100755 index 0000000..8ba4ec7 --- /dev/null +++ b/src/launcher/app.c @@ -0,0 +1,225 @@ +/* + * popup-launcher + * + * Copyright (c) 2013 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 "launcher.h" + +static int launch_app(char *appname, + char *key1, char *value1, + char *key2, char *value2, + char *key3, char *value3) +{ + int ret; + bundle *b; + + if (!appname) + return -EINVAL; + + b = bundle_create(); + if (!b) { + return -ENOMEM; + } + + if (key1 && value1) { + ret = bundle_add(b, key1, value1); + if (ret < 0) + goto out; + } + + if (key2 && value2) { + ret = bundle_add(b, key2, value2); + if (ret < 0) + goto out; + } + + if (key3 && value3) { + ret = bundle_add(b, key3, value3); + if (ret < 0) + goto out; + } + + ret = aul_launch_app(appname, b); + if (ret <= 0) + _E("FAIL: aul_launch_app(%s)", appname); + +out: + bundle_free(b); + return ret; +} + +static int launch_app_raw(char *path, char **argv) +{ + pid_t pid; + int ret; + + if (!path || access(path, X_OK) != 0) { + _E("Cannot execute (%s)", path); + return -EINVAL; + } + + pid = fork(); + if (pid < 0) { + _E("Failed to fork (%d)", errno); + return -errno; + } + + if (pid > 0) { /* Parent */ + return pid; + } + + /* Child */ + ret = execvp(path, argv); + + /* Failed */ + _E("Failed execvp(ret: %d, errno: %d)", ret, errno); + return -errno; +} + +DBusMessage *launch_app_no_param(E_DBus_Object *obj, + DBusMessage *msg, char *appname) +{ + DBusMessageIter iter; + DBusMessage *reply; + int ret; + + if (!appname) { + ret = -EINVAL; + goto out; + } + + _I("launch app (%s)", appname); + + ret = launch_app(appname, NULL, NULL, NULL, NULL, NULL, NULL); + if (ret < 0) + _E("FAIL: launch_app(): %d", ret); + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); + + return reply; +} + +DBusMessage *launch_app_single_param(E_DBus_Object *obj, + DBusMessage *msg, char *appname) +{ + DBusError err; + DBusMessageIter iter; + DBusMessage *reply; + char *key; + char *value; + int ret; + + if (!appname) { + ret = -EINVAL; + goto out; + } + + _I("launch app (%s)", appname); + + dbus_error_init(&err); + + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, &key, + DBUS_TYPE_STRING, &value, + DBUS_TYPE_INVALID)) { + _E("there is no message"); + ret = -EINVAL; + goto out; + } + + if (!key || !value) { + _E("message is invalid!"); + ret = -EINVAL; + goto out; + } + + ret = launch_app(appname, key, value, NULL, NULL, NULL, NULL); + if (ret < 0) + _E("FAIL: launch_app(): %d", ret); + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); + + return reply; +} + +DBusMessage *terminate_app_by_pid(E_DBus_Object *obj, DBusMessage *msg) +{ + DBusError err; + DBusMessageIter iter; + DBusMessage *reply; + pid_t pid; + int ret; + + dbus_error_init(&err); + + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INVALID)) { + _E("there is no message"); + ret = -EINVAL; + goto out; + } + + if (pid < 0) { + _E("message is invalid!"); + ret = -EINVAL; + goto out; + } + + ret = aul_terminate_pid(pid); + if (ret < 0) + _E("FAIL: aul_terminate_pid(): %d", ret); + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); + + return reply; +} + +DBusMessage *launch_system_servant_app(E_DBus_Object *obj, DBusMessage *msg, char **argv) +{ + DBusMessageIter iter; + DBusMessage *reply; + int ret; + + if (!argv) { + ret = -EINVAL; + goto out; + } + + _I("launch app raw(%s)", argv[0]); + + ret = launch_app_raw(argv[0], argv); + if (ret < 0) + _E("FAIL: launch_app_raw: %d", ret); + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); + + return reply; +} + diff --git a/src/launcher/launcher.c b/src/launcher/launcher.c index ac6e953..3fe888a 100755 --- a/src/launcher/launcher.c +++ b/src/launcher/launcher.c @@ -25,6 +25,13 @@ static E_DBus_Connection *edbus_conn; static DBusPendingCall *edbus_request_name; static Ecore_Timer *term_timer = NULL; +extern DBusMessage *activate_notification_no_param(E_DBus_Object *obj, DBusMessage *msg, int type); +extern DBusMessage *launch_system_servant_app(E_DBus_Object *obj, DBusMessage *msg, char **argv); +extern DBusMessage *activate_notification_single_param(E_DBus_Object *obj, DBusMessage *msg, int type); +extern DBusMessage *activate_notification_double_param(E_DBus_Object *obj, DBusMessage *msg, int type); +extern DBusMessage *deactivate_notification(E_DBus_Object *obj, DBusMessage *msg); +extern DBusMessage *update_notification_double_param(E_DBus_Object *obj, DBusMessage *msg, int type); + static Eina_Bool exit_idler_cb(void *data) { e_dbus_connection_close(edbus_conn); @@ -77,18 +84,114 @@ static DBusMessage *poweroff_popup(E_DBus_Object *obj, DBusMessage *msg) return launch_poweroff_popup(obj, msg, POWEROFF_SYSPOPUP); } +/* Crash popup */ +static DBusMessage *crash_popup(E_DBus_Object *obj, DBusMessage *msg) +{ + set_timer_to_terminate(); + return launch_popup(obj, msg, CRASH_SYSPOPUP); +} + +/* Battery notifications */ +static DBusMessage *battery_full_noti_on(E_DBus_Object *obj, DBusMessage *msg) +{ + set_timer_to_terminate(); + return activate_notification_no_param(obj, msg, BATTERY_FULL); +} + +static DBusMessage *battery_charge_noti_on(E_DBus_Object *obj, DBusMessage *msg) +{ + char param[2]; + char *args[3]; + + set_timer_to_terminate(); + + args[0] = SERVANT_APP_NAME; + snprintf(param, sizeof(param), "%d", CHARGER_CONNECTION); + args[1] = param; + args[2] = NULL; + return launch_system_servant_app(obj, msg, args); +} + +/* Notification Off */ +static DBusMessage *noti_off(E_DBus_Object *obj, DBusMessage *msg) +{ + set_timer_to_terminate(); + return deactivate_notification(obj, msg); +} + +/* LED */ +static DBusMessage *led_torch_noti_on(E_DBus_Object *obj, DBusMessage *msg) +{ + set_timer_to_terminate(); + return activate_notification_no_param(obj, msg, LED_TORCH); +} + +/* USB host notifications */ +static DBusMessage *usb_storage_noti_on(E_DBus_Object *obj, DBusMessage *msg) +{ + set_timer_to_terminate(); + return activate_notification_single_param(obj, msg, USB_STORAGE); +} + +static DBusMessage *usb_storage_ro_noti_on(E_DBus_Object *obj, DBusMessage *msg) +{ + set_timer_to_terminate(); + return activate_notification_single_param(obj, msg, USB_STORAGE_RO); +} + +static DBusMessage *usb_device_noti_on(E_DBus_Object *obj, DBusMessage *msg) +{ + set_timer_to_terminate(); + return activate_notification_double_param(obj, msg, USB_DEVICE); +} + +static DBusMessage *usb_device_noti_update(E_DBus_Object *obj, DBusMessage *msg) +{ + set_timer_to_terminate(); + return update_notification_double_param(obj, msg, USB_DEVICE); +} + static const struct edbus_method dbus_poweroff_methods[] = { { "PopupLaunch", NULL, "i", poweroff_popup }, /* Add methods here */ }; +static const struct edbus_method +dbus_crash_methods[] = { + { "PopupLaunch", "a{ss}", "i", crash_popup }, + /* Add methods here */ +}; + +static const struct edbus_method +dbus_noti_methods[] = { + /* LED */ + { "LedTorchNotiOn" , NULL , "i" , led_torch_noti_on }, + { "LedTorhNotiOff" , "i" , "i" , noti_off }, + /* USB storage */ + { "UsbStorageNotiOn" , "s" , "i" , usb_storage_noti_on }, + { "UsbStorageRoNotiOn" , "s" , "i" , usb_storage_ro_noti_on }, + { "UsbStorageNotiOff" , "i" , "i" , noti_off }, + { "UsbDeviceNotiOn" , "ss" , "i" , usb_device_noti_on }, + { "UsbDeviceNotiUpdate" , "isss" , "i" , usb_device_noti_update }, + { "UsbDeviceNotiOff" , "i" , "i" , noti_off }, + /* Battery */ + { "BatteryFullNotiOn" , NULL , "i" , battery_full_noti_on }, + { "BatteryFullNotiOff" , "i" , "i" , noti_off }, + { "BatteryChargeNotiOn" , NULL , "i" , battery_charge_noti_on }, + /* Add notifications here */ +}; + static struct edbus_object edbus_objects[]= { { POPUP_PATH_SYSTEM , POPUP_IFACE_SYSTEM , NULL , NULL , dbus_system_methods , ARRAY_SIZE(dbus_system_methods) }, { POPUP_PATH_POWEROFF , POPUP_IFACE_POWEROFF , NULL , NULL , dbus_poweroff_methods , ARRAY_SIZE(dbus_poweroff_methods) }, + { POPUP_PATH_NOTI , POPUP_IFACE_NOTI , NULL , NULL , + dbus_noti_methods , ARRAY_SIZE(dbus_noti_methods) }, + { POPUP_PATH_CRASH , POPUP_IFACE_CRASH , NULL , NULL , + dbus_crash_methods , ARRAY_SIZE(dbus_crash_methods) }, /* Add new object & interface here*/ }; diff --git a/src/launcher/launcher.h b/src/launcher/launcher.h index 7c69b99..81c8ff7 100755 --- a/src/launcher/launcher.h +++ b/src/launcher/launcher.h @@ -32,6 +32,61 @@ /* Popup names */ #define POWEROFF_SYSPOPUP "poweroff-syspopup" #define SYSTEM_SYSPOPUP "system-syspopup" +#define CRASH_SYSPOPUP "crash-syspopup" + +/* Setting ugs */ +#define SETTING_ENCRYPTING_APP "org.tizen.setting.encrypting" +#define SETTING_LIGHTOFF_APP "org.tizen.setting.turnofflight" +#define SETTING_DATAUSAGE_UG "setting-datausage-efl" + +/* App to show Host devices list */ +#define HOST_DEVICES "org.tizen.host-devices" +#define APPOPER_TYPE "_TYPE_" +#define APPOPER_TYPE_DEVICE_LIST "DEVICE_LIST" + +/* Notification icons */ +#define DATAUSAGE_ICON SYSTEM_ICONDIR"/datausage_warning.png" +#define LED_TORCH_ICON SYSTEM_ICONDIR"/led_torch.png" +#define ODE_ENCRYPT_ICON SYSTEM_ICONDIR"/sdcard_encryption.png" +#define ODE_DECRYPT_ICON SYSTEM_ICONDIR"/sdcard_decryption.png" +#define ODE_ENCRYPT_ERROR_ICON SYSTEM_ICONDIR"/sdcard_encryption_error.png" +#define ODE_DECRYPT_ERROR_ICON SYSTEM_ICONDIR"/sdcard_decryption_error.png" +#define TIMA_ICON SYSTEM_ICONDIR"/tima.png" +#define USB_ICON SYSTEM_ICONDIR"/usb.png" +#define BATT_INDI_ICON SYSTEM_ICONDIR"/batt_full_indicator.png" +#define BATT_NOTI_ICON SYSTEM_ICONDIR"/batt_full_icon.png" + +/* App launching */ +#define CRADLE_APP_NAME "org.tizen.desk-dock" +#define PWLOCK_APP_NAME "org.tizen.pwlock" +#define SERVANT_APP_NAME "/usr/bin/system-servant" + +enum noti_type { + NOTI_NONE = 0, + DATAUSAGE_WARNING, + DATAUSAGE_DISABLED, + LED_TORCH, + ODE_COMPLETE, + ODE_PROGRESS, + ODE_ERROR, + TIMA_LKM_PREVENTION, + TIMA_PKM_DETECTION, + TICKER, + USB_STORAGE, + USB_STORAGE_RO, + USB_DEVICE, + BATTERY_FULL, + /* Add here additional notificatoins */ + NOTI_TYPE_MAX +}; + +enum service_type { + TTS_SCREENOFF, + TTS_ENABLED, + TTS_DISABLED, + CHARGER_CONNECTION, + SERVICE_MAX, +}; struct edbus_method { const char *member; diff --git a/src/launcher/noti.c b/src/launcher/noti.c new file mode 100755 index 0000000..f007ef4 --- /dev/null +++ b/src/launcher/noti.c @@ -0,0 +1,1033 @@ +/* + * popup-launcher + * + * Copyright (c) 2013 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 "launcher.h" + +#define BUF_MAX 256 + +struct ticker_info { + const char *name; + const char *msgid; +}; + +static const struct ticker_info ticker_notifications[] = { + { "USBClient", "IDS_COM_BODY_CONNECTED_AS_A_MEDIA_DEVICE" }, + { "USBClientSSH", "SSH enabled" }, + { "DockConnected", "IDS_QP_POP_THE_DOCK_IS_CONNECTED" }, + { "HdmiConnected", "IDS_VPL_POP_HDMI_CABLE_CONNECTED" }, + { "HdmiDisconnected", "IDS_VPL_POP_HDMI_CABLE_DISCONNECTED" }, + { "USBConnectorConected", "IDS_COM_POP_USB_CONNECTOR_CONNECTED" }, + { "USBConnectorDisconnected", "IDS_COM_POP_USB_CONNECTOR_DISCONNECTED" }, + { "KeyboardConnected", "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2" }, + { "MouseConnected", "IDS_COM_POP_MOUSE_CONNECTED_ABB2" }, + { "StorageConnected", "IDS_COM_POP_USB_MASS_STORAGE_CONNECTED_ABB2" }, + { "StorageConnectedRO", "IDS_ST_BODY_READ_ONLY_USB_DEV_CONNECTED_M_NOUN_ABB" }, + { "StorageDisconnectedSafe", "IDS_USB_BODY_USB_MASS_STORAGE_SAFELY_REMOVED" }, + { "StorageDisconnectedUnsafe", "IDS_COM_POP_USB_MASS_STORAGE_UNEXPECTEDLY_REMOVED" }, + { "CameraConnected", "IDS_COM_POP_CAMERA_CONNECTED_ABB2" }, + { "PrinterConnected", "IDS_COM_POP_PRINTER_CONNECTED_ABB2" }, + { "UnknownConnected", "IDS_COM_POP_UNKNOWN_USB_DEVICE_CONNECTED" }, + { "DeviceDisconnected", "IDS_COM_BODY_USB_DEVICE_SAFELY_REMOVED" }, +}; + +static void set_language(void) +{ + char *lang; + char *r; + + lang = vconf_get_str(VCONFKEY_LANGSET); + if (!lang) + return; + + setenv("LANG", lang, 1); + setenv("LC_MESSAGES", lang, 1); + + r = setlocale(LC_ALL, ""); + if (!r) { + setlocale(LC_ALL, lang); + } + + free(lang); +} + +static int add_notification ( + int type, int layout, + char *title, char *content, + char *icon, char *icon_indi, + bundle *b, int prop, + int applist) +{ + int priv_id; + notification_h noti = NULL; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + set_language(); + + noti = notification_create(type); + if (!noti) { + _E("FAIL: notification_create()"); + return -ENOMEM; + } + + noti_err = notification_set_text_domain(noti, LANG_DOMAIN, LOCALE_DIR); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_text_domain()"); + priv_id = -ENOMEM; + goto out; + } + + + noti_err = notification_set_layout(noti, layout); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_layout()"); + priv_id = -ENOMEM; + goto out; + } + + if (layout == NOTIFICATION_LY_ONGOING_PROGRESS) { + noti_err = notification_set_progress(noti, (double)0.0); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_setprogress()"); + priv_id = -ENOMEM; + goto out; + } + } + + if (title) { + noti_err = notification_set_text (noti, + NOTIFICATION_TEXT_TYPE_TITLE, + _(title), + title, + NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_text()"); + priv_id = -ENOMEM; + goto out; + } + } + + if (content) { + noti_err = notification_set_text (noti, + NOTIFICATION_TEXT_TYPE_CONTENT, + _(content), + content, + NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_text()"); + priv_id = -ENOMEM; + goto out; + } + } + + if (icon) { + noti_err = notification_set_image (noti, + NOTIFICATION_IMAGE_TYPE_ICON, + icon); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_image()"); + priv_id = -ENOMEM; + goto out; + } + } + + if (icon_indi && (applist & NOTIFICATION_DISPLAY_APP_INDICATOR)) { + noti_err = notification_set_image (noti, + NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, + icon_indi); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_image()"); + priv_id = -ENOMEM; + goto out; + } + } + + noti_err = notification_set_property (noti, prop); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_property()"); + priv_id = -ENOMEM; + goto out; + } + + if (b) { + noti_err = notification_set_execute_option(noti, + NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_pkgname()"); + priv_id = -ENOMEM; + goto out; + } + } + + noti_err = notification_set_display_applist(noti, applist); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_display_applist()"); + priv_id = -ENOMEM; + goto out; + } + + noti_err = notification_set_pkgname(noti, APPNAME); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_pkgname()"); + priv_id = -ENOMEM; + goto out; + } + + priv_id = -1; + noti_err = notification_insert(noti, &priv_id); + if (noti_err != NOTIFICATION_ERROR_NONE) + _E("FAIL: notification_insert()"); + +out: + if (noti) + notification_free(noti); + return priv_id; +} + +static int launch_datausage_warning_notification(void) +{ + int ret; + bundle *b; + + b = bundle_create(); + if (b) + appsvc_set_pkgname(b, SETTING_DATAUSAGE_UG); + + ret = add_notification(NOTIFICATION_TYPE_NOTI, + NOTIFICATION_LY_NOTI_EVENT_SINGLE, + "IDS_COM_BODY_DATA_USAGE_WARNING", + "IDS_COM_BODY_TAP_TO_VIEW_USAGE_AND_SETTINGS", + DATAUSAGE_ICON, + DATAUSAGE_ICON, + b, + NOTIFICATION_PROP_VOLATILE_DISPLAY + | NOTIFICATION_PROP_DISABLE_AUTO_DELETE, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY + | NOTIFICATION_DISPLAY_APP_TICKER + | NOTIFICATION_DISPLAY_APP_LOCK + | NOTIFICATION_DISPLAY_APP_INDICATOR); + + if (b) + bundle_free(b); + return ret; +} + +static int launch_datausage_disabled_notification(void) +{ + int ret; + bundle *b; + + b = bundle_create(); + if (b) + appsvc_set_pkgname(b, SETTING_DATAUSAGE_UG); + + ret = add_notification(NOTIFICATION_TYPE_ONGOING, + NOTIFICATION_LY_ONGOING_EVENT, + "IDS_COM_HEADER_MOBILE_DATA_DISABLED", + "IDS_COM_BODY_TAP_TO_VIEW_USAGE_AND_SETTINGS", + DATAUSAGE_ICON, + DATAUSAGE_ICON, + b, + NOTIFICATION_PROP_VOLATILE_DISPLAY, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY + | NOTIFICATION_DISPLAY_APP_TICKER + | NOTIFICATION_DISPLAY_APP_LOCK + | NOTIFICATION_DISPLAY_APP_INDICATOR); + + if (b) + bundle_free(b); + return ret; +} + +static int launch_led_torch_notification(void) +{ + int ret; + bundle *b; + + b = bundle_create(); + if (b) + appsvc_set_pkgname(b, SETTING_LIGHTOFF_APP); + + ret = add_notification(NOTIFICATION_TYPE_ONGOING, + NOTIFICATION_LY_ONGOING_EVENT, + "IDS_QP_BODY_ASSISTIVE_LIGHT_IS_ON", + "IDS_ST_BODY_TAP_TO_TURN_OFF_ASSISTIVE_LIGHT", + LED_TORCH_ICON, + NULL, + b, + NOTIFICATION_PROP_VOLATILE_DISPLAY, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + + if (b) + bundle_free(b); + return ret; +} + +static int launch_ode_complete_notification(void *data) +{ + char *text, *content, *input; + int ret; + + if (!data) + return -EINVAL; + + input = (char *)data; + + if (!strncmp(input, ODE_ENCRYPT, strlen(ODE_ENCRYPT))) + text = "IDS_ST_BODY_SD_CARD_ENCRYPTED"; + else if (!strncmp(input, ODE_DECRYPT, strlen(ODE_DECRYPT))) + text = "IDS_ST_BODY_SD_CARD_DECRYPTED"; + else + return -EINVAL; + + set_language(); + content = dgettext(LANG_DOMAIN, text); + if (!content) + return -ENOMEM; + + ret = notification_status_message_post(content); + if (ret != NOTIFICATION_ERROR_NONE) + _E("FAIL: notification_status_message_post(text)"); + + return ret; +} + +static int launch_ode_progress_notification(void *data) +{ + char *title, *input, *icon; + int ret; + bundle *b; + + if (!data) + return -EINVAL; + + input = (char *)data; + + if (!strncmp(input, ODE_ENCRYPT, strlen(ODE_ENCRYPT))) { + title = "IDS_DN_POP_ENCRYPTING_SD_CARD_ING"; + icon = ODE_ENCRYPT_ICON; + } else if (!strncmp(input, ODE_DECRYPT, strlen(ODE_DECRYPT))) { + title = "IDS_DN_POP_DECRYPTING_SD_CARD_ING"; + icon = ODE_DECRYPT_ICON; + } else { + return -EINVAL; + } + + b = bundle_create(); + if (b) + appsvc_set_pkgname(b, SETTING_ENCRYPTING_APP); + + ret = add_notification(NOTIFICATION_TYPE_ONGOING, + NOTIFICATION_LY_ONGOING_PROGRESS, + title, + NULL, + icon, + icon, + b, + NOTIFICATION_PROP_VOLATILE_DISPLAY, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY + | NOTIFICATION_DISPLAY_APP_INDICATOR); + + if (b) + bundle_free(b); + return ret; +} + +static int launch_ode_error_notification(void *data1, void *data2, void *data3) +{ + char *enc_type = (char *)data1; + char err_type[BUF_MAX]; + char space[BUF_MAX]; + char *icon = NULL; + char *content = NULL; + int ret; + bundle *b; + + if (!enc_type) + return -EINVAL; + + b = bundle_create(); + if (b) { + snprintf(err_type, sizeof(err_type), "%d", (int)data2); + snprintf(space, sizeof(space), "%d", (int)data3); + appsvc_set_pkgname(b, SYSTEM_SIGNAL_SENDER); + appsvc_add_data(b, SIGNAL_SENDER_TYPE, enc_type); + appsvc_add_data(b, SIGNAL_SENDER_ERROR_TYPE, err_type); + appsvc_add_data(b, SIGNAL_SENDER_MEMORY_SPACE, space); + + if (!strncmp(enc_type, ODE_ENCRYPT, strlen(ODE_ENCRYPT))) { + icon = ODE_ENCRYPT_ERROR_ICON; + content = "IDS_ST_BODY_SD_CARD_ENCRYPTION_ERROR_OCCURRED"; + } else if (!strncmp(enc_type, ODE_DECRYPT, strlen(ODE_DECRYPT))) { + icon = ODE_DECRYPT_ERROR_ICON; + content = "IDS_ST_BODY_SD_CARD_DECRYPTION_ERROR_OCCURRED"; + } + } + + ret = add_notification(NOTIFICATION_TYPE_ONGOING, + NOTIFICATION_LY_ONGOING_EVENT, + content, + NULL, + icon, + icon, + b, + NOTIFICATION_PROP_VOLATILE_DISPLAY, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY + | NOTIFICATION_DISPLAY_APP_INDICATOR); + + if(b) + bundle_free(b); + return ret; +} + +static int launch_tima_lkm_prevention_notification(void) +{ + int ret; + bundle *b; + + b = bundle_create(); + if (b) { + appsvc_set_pkgname(b, SYSTEM_SIGNAL_SENDER); + appsvc_add_data(b, SIGNAL_SENDER_TYPE, SIGNAL_SENDER_TYPE_RECOVERY); + } + + ret = add_notification(NOTIFICATION_TYPE_ONGOING, + NOTIFICATION_LY_ONGOING_EVENT, + "Prevention Information", + "The device has detected an application attempting " + "unpermitted actions and has stopped loading. To " + "protect your device, it is recommended you reboot.", + TIMA_ICON, + NULL, + b, + NOTIFICATION_PROP_VOLATILE_DISPLAY, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + + if (b) + bundle_free(b); + return ret; +} + +static int launch_tima_pkm_detection_notification(void) +{ + int ret; + bundle *b; + + b = bundle_create(); + if (b) { + appsvc_set_pkgname(b, SYSTEM_SIGNAL_SENDER); + appsvc_add_data(b, SIGNAL_SENDER_TYPE, SIGNAL_SENDER_TYPE_RECOVERY); + } + + ret = add_notification(NOTIFICATION_TYPE_ONGOING, + NOTIFICATION_LY_ONGOING_EVENT, + "Detection Information", + "The device has detected an application attempting " + "unpermitted actions. To protect your device, it is " + "recommended you reboot.", + TIMA_ICON, + NULL, + b, + NOTIFICATION_PROP_VOLATILE_DISPLAY, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + + if (b) + bundle_free(b); + return ret; +} + +static int launch_usb_storage_notification(void *data, int type) +{ + int ret; + bundle *b; + char *path = data; + char *name; + char *title; + + if (!path) + return -EINVAL; + + switch(type) { + case USB_STORAGE: + title = "IDS_COM_POP_USB_MASS_STORAGE_CONNECTED_ABB2"; + break; + case USB_STORAGE_RO: + title = "IDS_ST_BODY_READ_ONLY_USB_DEV_CONNECTED_M_NOUN_ABB"; + break; + default: + _E("Unknown type(%d)", type); + return -EINVAL; + } + + name = strrchr(path, '/'); + if (name) + name = name + 1; + else + name = path; + + b = bundle_create(); + if (b) { + appsvc_set_pkgname(b, SYSTEM_SIGNAL_SENDER); + appsvc_add_data(b, SIGNAL_SENDER_TYPE, SIGNAL_SENDER_TYPE_USBSTORAGE_UNMOUNT); + appsvc_add_data(b, SIGNAL_SENDER_DEVICE_PATH, path); + } + + ret = add_notification(NOTIFICATION_TYPE_ONGOING, + NOTIFICATION_LY_ONGOING_EVENT, + title, + name, + USB_ICON, + NULL, + b, + NOTIFICATION_PROP_VOLATILE_DISPLAY, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + + if (b) + bundle_free(b); + return ret; +} + +static int launch_usb_device_notification(char *dev, char *name) +{ + int ret; + bundle *b; + char *title; + + if (!dev) + return -EINVAL; + + if (!strncmp(dev, "keyboard", strlen(dev))) { + title = "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"; + } else if (!strncmp(dev, "mouse", strlen(dev))) { + title = "IDS_COM_POP_MOUSE_CONNECTED_ABB2"; + } else if (!strncmp(dev, "camera", strlen(dev))) { + title = "IDS_COM_POP_CAMERA_CONNECTED_ABB2"; + } else if (!strncmp(dev, "printer", strlen(dev))) { + title = "IDS_COM_POP_PRINTER_CONNECTED_ABB2"; + } else if (!strncmp(dev, "unknown", strlen(dev))) { + title = "IDS_COM_POP_UNKNOWN_USB_DEVICE_CONNECTED"; + } else { + _E("Invalid device"); + return -EINVAL; + } + + b = bundle_create(); + if (b) { + appsvc_set_pkgname(b, HOST_DEVICES); + appsvc_add_data(b, APPOPER_TYPE, APPOPER_TYPE_DEVICE_LIST); + } + + ret = add_notification(NOTIFICATION_TYPE_ONGOING, + NOTIFICATION_LY_ONGOING_EVENT, + title, + name, + USB_ICON, + NULL, + b, + NOTIFICATION_PROP_VOLATILE_DISPLAY, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + + if (b) + bundle_free(b); + return ret; +} + +static int launch_ticker_notification(void *data) +{ + char *content, *input; + int ret, i; + + if (!data) + return -EINVAL; + + input = (char *)data; + + content = NULL; + for (i = 0; i < ARRAY_SIZE(ticker_notifications); i++) { + if (strncmp(input, ticker_notifications[i].name, + strlen(ticker_notifications[i].name))) + continue; + + set_language(); + content = dgettext(LANG_DOMAIN, ticker_notifications[i].msgid); + break; + } + + if (!content) + return -EINVAL; + + ret = notification_status_message_post(content); + if (ret != NOTIFICATION_ERROR_NONE) + _E("FAIL: notification_status_message_post(text)"); + + return ret; +} + +static int launch_battery_full_notification(void) +{ + int ret; + + ret = add_notification(NOTIFICATION_TYPE_ONGOING, + NOTIFICATION_LY_ONGOING_EVENT, + "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED", + "IDS_SYNCML_POP_DM_REMOVE_CHARGER", + BATT_NOTI_ICON, + BATT_INDI_ICON, + NULL, + NOTIFICATION_PROP_DISABLE_APP_LAUNCH, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY + | NOTIFICATION_DISPLAY_APP_INDICATOR); + + return ret; +} + +static int launch_notification_no_param_by_type(int type) +{ + switch (type) { + case DATAUSAGE_WARNING: + return launch_datausage_warning_notification(); + case DATAUSAGE_DISABLED: + return launch_datausage_disabled_notification(); + case LED_TORCH: + return launch_led_torch_notification(); + case TIMA_LKM_PREVENTION: + return launch_tima_lkm_prevention_notification(); + case TIMA_PKM_DETECTION: + return launch_tima_pkm_detection_notification(); + case BATTERY_FULL: + return launch_battery_full_notification(); + default: + _E("Noti type is unknown"); + return -EINVAL; + } +} + +static int launch_notification_single_param_by_type(int type, void *data) +{ + switch (type) { + case ODE_COMPLETE: + return launch_ode_complete_notification(data); + case ODE_PROGRESS: + return launch_ode_progress_notification(data); + case TICKER: + return launch_ticker_notification(data); + case USB_STORAGE: + case USB_STORAGE_RO: + return launch_usb_storage_notification(data, type); + default: + _E("Noti type is unknown"); + return -EINVAL; + } +} + +static int launch_notification_double_param_by_type(int type, char *data1, char *data2) +{ + switch (type) { + case USB_DEVICE: + return launch_usb_device_notification(data1, data2); + default: + _E("Noti type is unknown"); + return -EINVAL; + } +} + +static int launch_notification_triple_param_by_type(int type, void *data1, void *data2, void *data3) +{ + switch (type) { + case ODE_ERROR: + return launch_ode_error_notification(data1, data2, data3); + default: + _E("Noti type is unknown"); + return -EINVAL; + } +} + + +DBusMessage *activate_notification_no_param(E_DBus_Object *obj, DBusMessage *msg, int type) +{ + DBusMessageIter iter; + DBusMessage *reply; + int priv_id; + + _D("Load notification"); + + priv_id = launch_notification_no_param_by_type(type); + if (priv_id < 0) + _E("FAIL: launch_noti_by_type()"); + + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &priv_id); + + return reply; +} + +DBusMessage *activate_notification_single_param(E_DBus_Object *obj, DBusMessage *msg, int type) +{ + DBusError err; + DBusMessageIter iter; + DBusMessage *reply; + int priv_id; + char *value; + + _D("Load notification"); + + dbus_error_init(&err); + + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, &value, + DBUS_TYPE_INVALID)) { + _E("there is no message"); + priv_id = -EINVAL; + goto out; + } + + priv_id = launch_notification_single_param_by_type(type, value); + if (priv_id < 0) + _E("FAIL: launch_noti_single_param_by_type()"); + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &priv_id); + + return reply; +} + +DBusMessage *activate_notification_double_param(E_DBus_Object *obj, DBusMessage *msg, int type) +{ + DBusError err; + DBusMessageIter iter; + DBusMessage *reply; + int priv_id; + char *str1; + char *str2; + + dbus_error_init(&err); + + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, &str1, + DBUS_TYPE_STRING, &str2, + DBUS_TYPE_INVALID)) { + _E("there is no message"); + priv_id = -EINVAL; + goto out; + } + + priv_id = launch_notification_double_param_by_type(type, str1, str2); + if (priv_id < 0) + _E("FAIL: launch_noti_single_param_by_type()"); + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &priv_id); + + return reply; +} + +DBusMessage *activate_notification_triple_param(E_DBus_Object *obj, DBusMessage *msg, int type) +{ + DBusError err; + DBusMessageIter iter; + DBusMessage *reply; + int priv_id; + char *data1; + int data2, data3; + + dbus_error_init(&err); + + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, &data1, + DBUS_TYPE_INT32, &data2, + DBUS_TYPE_INT32, &data3, + DBUS_TYPE_INVALID)) { + _E("there is no message"); + priv_id = -EINVAL; + goto out; + } + + priv_id = launch_notification_triple_param_by_type(type, (void *)data1, (void *)data2, (void *)data3); + if (priv_id < 0) + _E("FAIL: launch_noti_single_param_by_type()"); + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &priv_id); + + return reply; +} + +DBusMessage *deactivate_notification(E_DBus_Object *obj, DBusMessage *msg) +{ + DBusError err; + DBusMessageIter iter; + DBusMessage *reply; + int value; + int ret; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + dbus_error_init(&err); + + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &value, + DBUS_TYPE_INVALID)) { + _E("there is no message"); + ret = -EINVAL; + goto out; + } + + noti_err = notification_delete_by_priv_id(APPNAME, + NOTIFICATION_TYPE_NOTI, value); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_delete_by_priv_id(): %d", noti_err); + ret = -EBADF; + goto out; + } + + ret = 0; + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); + + return reply; +} + +static int progress_update_notification_by_progress_rate(int priv_id, int rate) +{ + int ret; + notification_h noti; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + if (rate < 0 || rate > 100) { + _E("Improper rate: %d", rate); + return -EINVAL; + } + + noti = notification_load(APPNAME, priv_id); + if (!noti) { + _E("FAIL: notification_load()"); + return -ENOMEM; + } + + noti_err = notification_set_progress(noti, rate/100.f); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_progress()"); + ret = -ENOMEM; + goto out; + } + + noti_err = notification_update(noti); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_update()"); + ret = -ENOMEM; + goto out; + } + + ret = 0; + +out: + noti_err = notification_free(noti); + if (noti_err != NOTIFICATION_ERROR_NONE) + _E("FAIL: notification_free()"); + return ret; +} + +DBusMessage *progress_update_notification(E_DBus_Object *obj, DBusMessage *msg) +{ + DBusError err; + DBusMessageIter iter; + DBusMessage *reply; + int priv_id; + int rate; + int ret; + + dbus_error_init(&err); + + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &priv_id, + DBUS_TYPE_INT32, &rate, + DBUS_TYPE_INVALID)) { + _E("there is no message"); + ret = -EINVAL; + goto out; + } + + ret = progress_update_notification_by_progress_rate(priv_id, rate); + if (ret < 0) + _E("FAIL: progress_update_notification()"); + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); + + return reply; +} + +static int update_usb_device_notification(int id, int num, char *str1, char *str2) +{ + int ret; + notification_h noti; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + char *title, *content; + + if (num <= 0) + return -EINVAL; + + if (num == 1) { + content = str2; + if (!strncmp(str1, "keyboard", strlen(str1))) { + title = "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2"; + } else if (!strncmp(str1, "mouse", strlen(str1))) { + title = "IDS_COM_POP_MOUSE_CONNECTED_ABB2"; + } else if (!strncmp(str1, "camera", strlen(str1))) { + title = "IDS_COM_POP_CAMERA_CONNECTED_ABB2"; + } else if (!strncmp(str1, "printer", strlen(str1))) { + title = "IDS_COM_POP_PRINTER_CONNECTED_ABB2"; + } else if (!strncmp(str1, "unknown", strlen(str1))) { + title = "IDS_COM_POP_UNKNOWN_USB_DEVICE_CONNECTED"; + } else { + _E("Invalid device"); + return -EINVAL; + } + + } else { + title = "IDS_USB_MBODY_PD_USB_DEVICES_CONNECTED"; + content = "Tap to show devices"; /* TODO: Translation */ + } + + set_language(); + + noti = notification_load(APPNAME, id); + if (!noti) { + _E("FAIL: notification_load()"); + return -ENOMEM; + } + + noti_err = notification_set_text_domain(noti, LANG_DOMAIN, LOCALE_DIR); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_text_domain()"); + ret = -ENOMEM; + goto out; + } + + if (title) { + if (num > 1) + noti_err = notification_set_text (noti, + NOTIFICATION_TEXT_TYPE_TITLE, + _(title), + title, + NOTIFICATION_VARIABLE_TYPE_INT, + num, + NOTIFICATION_VARIABLE_TYPE_NONE); + else + noti_err = notification_set_text (noti, + NOTIFICATION_TEXT_TYPE_TITLE, + _(title), + title, + NOTIFICATION_VARIABLE_TYPE_NONE); + + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_text()"); + ret = -ENOMEM; + goto out; + } + } + + if (content) { + noti_err = notification_set_text (noti, + NOTIFICATION_TEXT_TYPE_CONTENT, + _(content), + content, + NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_set_text()"); + ret = -ENOMEM; + goto out; + } + } + noti_err = notification_update(noti); + if (noti_err != NOTIFICATION_ERROR_NONE) { + _E("FAIL: notification_update()"); + ret = -ENOMEM; + goto out; + } + + ret = 0; + +out: + noti_err = notification_free(noti); + if (noti_err != NOTIFICATION_ERROR_NONE) + _E("FAIL: notification_free()"); + return ret; +} + +static int text_update_notification(int type, int id, char *data, char *str1, char *str2) +{ + int num; + switch (type) { + case USB_DEVICE: + num = atoi(data); + return update_usb_device_notification(id, num, str1, str2); + default: + return -EINVAL; + } +} + +DBusMessage *update_notification_double_param(E_DBus_Object *obj, DBusMessage *msg, int type) +{ + DBusError err; + DBusMessageIter iter; + DBusMessage *reply; + int id; + char *data, *str1, *str2; + int ret; + + dbus_error_init(&err); + + if (!dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &id, + DBUS_TYPE_STRING, &data, + DBUS_TYPE_STRING, &str1, + DBUS_TYPE_STRING, &str2, + DBUS_TYPE_INVALID)) { + _E("there is no message"); + ret = -EINVAL; + goto out; + } + + ret = text_update_notification(type, id, data, str1, str2); + if (ret < 0) + _E("FAIL: progress_update_notification()"); + +out: + reply = dbus_message_new_method_return(msg); + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret); + + return reply; +} diff --git a/src/mmc/mmc-mobile.c b/src/mmc/mmc-mobile.c new file mode 100755 index 0000000..e167748 --- /dev/null +++ b/src/mmc/mmc-mobile.c @@ -0,0 +1,282 @@ +/* + * system-popup + * + * Copyright (c) 2014 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 "popup-common.h" +#include + +#define SETTING_MMC_ENCRYPTION_UG "setting-mmc-encryption-efl" + +#define DD_BUS_NAME "org.tizen.system.deviced" +#define DD_OBJECT_PATH_ODE "/Org/Tizen/System/DeviceD/Ode" +#define DD_INTERFACE_NAME_ODE DD_BUS_NAME".ode" +#define DD_SIGNAL_GENERAL_MOUNT "RequestGeneralMount" +#define DD_SIGNAL_ODE_MOUNT "RequestOdeMount" +#define DD_SIGNAL_REMOVE_MMC "RemoveMmc" + +static const struct popup_ops mount_error_ops; +static const struct popup_ops mount_read_only_ops; +static const struct popup_ops check_smack_ops; +static const struct popup_ops ode_encrypt_ops; +static const struct popup_ops ode_decrypt_ops; + +static void remove_other_mmc_popups(const struct popup_ops *ops) +{ + if (ops != &mount_error_ops) + unload_simple_popup(&mount_error_ops); + + if (ops != &mount_read_only_ops) + unload_simple_popup(&mount_read_only_ops); + + if (ops != &check_smack_ops) + unload_simple_popup(&check_smack_ops); + + if (ops != &ode_encrypt_ops) + unload_simple_popup(&ode_encrypt_ops); + + if (ops != &ode_decrypt_ops) + unload_simple_popup(&ode_decrypt_ops); +} + +static bool mmc_inserted(void) +{ + int val; + if (vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &val) == 0 + && val != VCONFKEY_SYSMAN_MMC_REMOVED) + return true; + return false; +} + +static bool mmc_mounted(void) +{ + int val; + if (vconf_get_int(VCONFKEY_SYSMAN_MMC_MOUNT, &val) == 0 + && val == VCONFKEY_SYSMAN_MMC_MOUNT_FAILED) + return false; + return true; +} + +static void send_mount_signal(char *signal) +{ + int ret; + + if (!signal) + return; + + ret = broadcast_dbus_signal( + DD_OBJECT_PATH_ODE, + DD_INTERFACE_NAME_ODE, + signal, + NULL, NULL); + if (ret < 0) + _E("FAIL: broadcast_dbus_signal(%s:%d)", signal, ret); +} + +static void launch_app(char *appname) +{ + bundle *b; + int ret; + + if (!appname) + return; + + b = bundle_create(); + if (b) { + ret = aul_launch_app(appname, b); + if (ret < 0) + _E("FAIL: aul_launch_app(%d)", ret); + if (bundle_free(b) != 0) + _E("FAIL: bundle_free(b);"); + } else { + _E("Failed to create bundle"); + } +} + +static void send_general_mount_signal(const struct popup_ops *ops) +{ + unload_simple_popup(ops); + send_mount_signal(DD_SIGNAL_GENERAL_MOUNT); + terminate_if_no_popup(); +} + +static void send_ode_mount_signal(const struct popup_ops *ops) +{ + unload_simple_popup(ops); + send_mount_signal(DD_SIGNAL_ODE_MOUNT); + terminate_if_no_popup(); +} + +static void ode_launch_settings(const struct popup_ops *ops) +{ + unload_simple_popup(ops); + launch_app(SETTING_MMC_ENCRYPTION_UG); + terminate_if_no_popup(); +} + +static bool skip_mount_error_popup(bundle *b, const struct popup_ops *ops) +{ + return mmc_mounted(); +} + +static bool skip_ode_popup(bundle *b, const struct popup_ops *ops) +{ + return !mmc_inserted(); +} + +static E_DBus_Signal_Handler *mmc_removed_handler= NULL; + +static void unregister_ode_handler(const struct popup_ops *ops) +{ + if (mmc_removed_handler) { + unregister_dbus_signal_handler(mmc_removed_handler); + mmc_removed_handler = NULL; + } +} + +static void mmc_removed(void *data, DBusMessage *msg) +{ + const struct popup_ops *ops = data; + + unregister_ode_handler(ops); + unload_simple_popup(ops); + terminate_if_no_popup(); +} + +static void register_ode_handler(const struct popup_ops *ops) +{ + int ret; + + unregister_ode_handler(ops); + + ret = register_dbus_signal_handler(&mmc_removed_handler, + DD_OBJECT_PATH_ODE, + DD_INTERFACE_NAME_ODE, + DD_SIGNAL_REMOVE_MMC, + mmc_removed, + (void*)ops); + if (ret < 0) + _E("Failed to register mmc removed signal handler(%d)", ret); +} + +static void mmc_mount_status_changed(keynode_t *in_key, void *data) +{ + const struct popup_ops *ops = data; + + if (vconf_keynode_get_int(in_key) == VCONFKEY_SYSMAN_MMC_MOUNT_FAILED) + return; + + unload_simple_popup(ops); + terminate_if_no_popup(); +} + +static void register_mmc_mount_handler(const struct popup_ops *ops) +{ + if (vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_MOUNT, + mmc_mount_status_changed, (void *)ops) != 0) + _E("Failed to register mmc mount handler"); +} + +static void unregister_mmc_mount_handler(const struct popup_ops *ops) +{ + vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_MOUNT, + mmc_mount_status_changed); +} + +static int launch_mmc_popup(bundle *b, const struct popup_ops *ops) +{ + remove_other_mmc_popups(ops); + unregister_ode_handler(ops); + + if (ops == &mount_error_ops) + register_mmc_mount_handler(ops); + + if (ops == &ode_encrypt_ops || + ops == &ode_decrypt_ops) + register_ode_handler(ops); + + return 0; +} + +static void terminate_mmc_popup(const struct popup_ops *ops) +{ + unregister_mmc_mount_handler(ops); + unregister_ode_handler(ops); +} + +static const struct popup_ops mount_error_ops = { + .name = "mounterr",//"mmc_mount_error", + .show = load_simple_popup, + .content = "IDS_DN_POP_FAILED_TO_MOUNT_SD_CARD_REINSERT_OR_FORMAT_SD_CARD", + .left_text = "IDS_COM_SK_OK", + .skip = skip_mount_error_popup, + .pre = launch_mmc_popup, +}; + +static const struct popup_ops mount_read_only_ops = { + .name = "mountrdonly",//"mmc_mount_read_only", + .show = load_simple_popup, + .content = "IDS_ST_BODY_SD_CARD_MOUNTED_READ_ONLY", + .left_text = "IDS_COM_SK_OK", + .pre = launch_mmc_popup, +}; + +static const struct popup_ops check_smack_ops = { + .name = "checksmack",//"mmc_check_smack", + .show = load_simple_popup, + .content = "IDS_MF_BODY_MMC_DATA_IS_INITIALIZING_ING", + .left_text = "IDS_COM_SK_OK", + .pre = launch_mmc_popup, +}; + +static const struct popup_ops ode_encrypt_ops = { + .name = "odeencrypt",//"mmc_ode_encrypt", + .show = load_simple_popup, + .title = "IDS_DN_BODY_ENCRYPT_SD_CARD", + .content = "IDS_ST_POP_TO_USE_YOUR_SD_CARD_IT_MUST_BE_ENCRYPTED_ENCRYPT_SD_CARD_OR_DISABLE_DEVICE_ENCRYPTION_Q", + .left_text = "IDS_ST_BUTTON_ENCRYPT_SD_CARD_ABB", + .left = ode_launch_settings, + .right_text = "IDS_ST_BUTTON_DISABLE_ENCRYPTION_ABB", + .right = send_general_mount_signal, + .skip = skip_ode_popup, + .pre = launch_mmc_popup, + .terminate = terminate_mmc_popup, +}; + +static const struct popup_ops ode_decrypt_ops = { + .name = "odedecrypt",//"mmc_ode_decrypt", + .show = load_simple_popup, + .title = "IDS_DN_BODY_DECRYPT_SD_CARD", + .content = "IDS_ST_POP_TO_USE_YOUR_SD_CARD_IT_MUST_BE_DECRYPTED_DECRYPT_SD_CARD_OR_ENABLE_DEVICE_ENCRYPTION_Q", + .left_text = "IDS_ST_BUTTON_DECRYPT_SD_CARD_ABB", + .left = ode_launch_settings, + .right_text = "IDS_ST_BUTTON_ENABLE_ENCRYPTION_ABB", + .right = send_ode_mount_signal, + .skip = skip_ode_popup, + .pre = launch_mmc_popup, + .terminate = terminate_mmc_popup, +}; + +/* Constructor to register mmc popup */ +static __attribute__ ((constructor)) void register_mmc_popup(void) +{ + register_popup(&mount_error_ops); + register_popup(&mount_read_only_ops); + register_popup(&check_smack_ops); + register_popup(&ode_encrypt_ops); + register_popup(&ode_decrypt_ops); +} diff --git a/src/org.tizen.system-syspopup.xml b/src/org.tizen.system-syspopup.xml new file mode 100755 index 0000000..e7ce761 --- /dev/null +++ b/src/org.tizen.system-syspopup.xml @@ -0,0 +1,13 @@ + + + + Giyeol Ok + System FW system popup application + + + + + http://tizen.org/privilege/power + http://tizen.org/privilege/appmanager.launch + + diff --git a/src/po/en.po b/src/po/en.po index 1e30d6b..23de7e1 100755 --- a/src/po/en.po +++ b/src/po/en.po @@ -235,3 +235,11 @@ msgstr "HDMI cable connected." msgid "IDS_VPL_POP_HDMI_CABLE_DISCONNECTED" msgstr "HDMI cable disconnected." +msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY" +msgstr "%s has closed unexpectedly." + +msgid "IDS_ST_BODY_PS_IS_NOT_RESPONDING_CLOSE_PS_Q" +msgstr "%s is not responding. Close %s?" + +msgid "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE" +msgstr "Low memory left" diff --git a/src/po/en_PH.po b/src/po/en_PH.po index a8f3fee..4c2f51d 100755 --- a/src/po/en_PH.po +++ b/src/po/en_PH.po @@ -107,7 +107,7 @@ msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED" msgstr "Battery fully charged." msgid "IDS_MF_BODY_MMC_DATA_IS_INITIALIZING_ING" -msgstr "MMC data is initializing…" +msgstr "MMC data is initializing??" msgid "IDS_QP_BODY_ASSISTIVE_LIGHT_IS_ON" msgstr "Assistive light is on." @@ -235,3 +235,11 @@ msgstr "HDMI cable connected." msgid "IDS_VPL_POP_HDMI_CABLE_DISCONNECTED" msgstr "HDMI cable disconnected." +msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY" +msgstr "%s has closed unexpectedly." + +msgid "IDS_ST_BODY_PS_IS_NOT_RESPONDING_CLOSE_PS_Q" +msgstr "%s is not responding. Close %s?" + +msgid "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE" +msgstr "Low memory left" diff --git a/src/po/en_US.po b/src/po/en_US.po index 554b34c..86dacab 100755 --- a/src/po/en_US.po +++ b/src/po/en_US.po @@ -235,3 +235,11 @@ msgstr "HDMI cable connected." msgid "IDS_VPL_POP_HDMI_CABLE_DISCONNECTED" msgstr "HDMI cable disconnected." +msgid "IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY" +msgstr "%s has closed unexpectedly." + +msgid "IDS_ST_BODY_PS_IS_NOT_RESPONDING_CLOSE_PS_Q" +msgstr "%s is not responding. Close %s?" + +msgid "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE" +msgstr "Low memory left" diff --git a/src/poweroff/poweroff.c b/src/poweroff/poweroff.c index 7f73c7e..cba5971 100755 --- a/src/poweroff/poweroff.c +++ b/src/poweroff/poweroff.c @@ -28,6 +28,16 @@ #define POWER_METHOD "reboot" #define POWER_OPERATION_OFF "poweroff" +static void remove_popup(const struct popup_ops *ops); +static void pm_state_changed(keynode_t *key, void *data); +static void event_back_key_up(void *data, Evas_Object *obj, void *event_info); +static void register_handlers(const struct popup_ops *ops); +static void unregister_handlers(const struct popup_ops *ops); +static int poweroff_launch(bundle *b, const struct popup_ops *ops); +static void poweroff_terminate(const struct popup_ops *ops); +static void poweroff_clicked(const struct popup_ops *ops); +static __attribute__ ((constructor)) void poweroff_register_popup(void); + static void remove_popup(const struct popup_ops *ops) { static bool terminating = false; diff --git a/src/storage/lowstorage-mobile.c b/src/storage/lowstorage-mobile.c new file mode 100755 index 0000000..e0d0c27 --- /dev/null +++ b/src/storage/lowstorage-mobile.c @@ -0,0 +1,59 @@ +/* + * system-popup + * + * Copyright (c) 2014 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 "popup-common.h" + +static const struct popup_ops lowstorage_warning_ops; +static const struct popup_ops lowstorage_critical_ops; + +static int remove_other_lowstorage_popups(bundle *b, const struct popup_ops *ops) +{ + _D("remove_other_lowstorage_popups() is entered"); + + if (ops != &lowstorage_warning_ops) + unload_simple_popup(&lowstorage_warning_ops); + + if (ops != &lowstorage_critical_ops) + unload_simple_popup(&lowstorage_critical_ops); + + _D("remove_other_lowstorage_popups() is finished"); + return 0; +} + +static const struct popup_ops lowstorage_warning_ops = { + .name = "lowstorage_warning", + .show = load_simple_popup, + .content = "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE", + .left_text = "IDS_COM_SK_OK", + .pre = remove_other_lowstorage_popups, +}; + +static const struct popup_ops lowstorage_critical_ops = { + .name = "lowstorage_critical", + .show = load_simple_popup, + .content = "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE", + .left_text = "IDS_COM_SK_OK", + .pre = remove_other_lowstorage_popups, +}; + +static __attribute__ ((constructor)) void lowstorage_register_popup(void) +{ + register_popup(&lowstorage_warning_ops); + register_popup(&lowstorage_critical_ops); +} diff --git a/src/storage/lowstorage-wearable.c b/src/storage/lowstorage-wearable.c new file mode 100755 index 0000000..62ef671 --- /dev/null +++ b/src/storage/lowstorage-wearable.c @@ -0,0 +1,69 @@ +/* + * system-popup + * + * Copyright (c) 2014 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 "popup-common.h" + +static const struct popup_ops lowstorage_warning_ops; +static const struct popup_ops lowstorage_critical_ops; +static const struct popup_ops lowstorage_full_ops; + +static int remove_other_lowstorage_popups(const struct popup_ops *ops) +{ + if (ops != &lowstorage_warning_ops) + unload_simple_popup(&lowstorage_warning_ops); + + if (ops != &lowstorage_critical_ops) + unload_simple_popup(&lowstorage_critical_ops); + + if (ops != &lowstorage_full_ops) + unload_simple_popup(&lowstorage_full_ops); + + return 0; +} + +static const struct popup_ops lowstorage_warning_ops = { + .name = "lowstorage_warning", + .show = load_simple_popup, + .content = "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE", + .left_text = "IDS_COM_SK_OK", + .pre = remove_other_lowstorage_popups, +}; + +static const struct popup_ops lowstorage_critical_ops = { + .name = "lowstorage_critical", + .show = load_simple_popup, + .content = "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE", + .left_text = "IDS_COM_SK_OK", + .pre = remove_other_lowstorage_popups, +}; + +static const struct popup_ops lowstorage_full_ops = { + .name = "lowstorage_full", + .show = load_simple_popup, + .content = "IDS_ST_POP_UNABLE_TO_RECORD_THERE_IS_NOT_ENOUGH_SPACE_IN_YOUR_GEAR_STORAGE", + .left_text = "IDS_COM_SK_OK", + .pre = remove_other_lowstorage_popups, +}; + +static __attribute__ ((constructor)) void lowstorage_register_popup(void) +{ + register_popup(&lowstorage_warning_ops); + register_popup(&lowstorage_critical_ops); + register_popup(&lowstorage_full_ops); +} diff --git a/src/usb/usb-device.c b/src/usb/usb-device.c new file mode 100755 index 0000000..7bd0a71 --- /dev/null +++ b/src/usb/usb-device.c @@ -0,0 +1,97 @@ +/* + * system-popup + * + * Copyright (c) 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 "popup-common.h" + +enum button_selected_e { + USB_DEVICE_CONFIRM_OK, + USB_DEVICE_CONFIRM_NOK, +}; + +#define USD_PATH "/Org/Tizen/System/USD" +#define USD_INTERFACE "org.tizen.system.usd" +#define USD_USB_DEVICE_CONFIRM_SIGNAL "USBDeviceOpenResult" + +static const struct popup_ops usb_device_confirm_ops; + +static void send_result_dbus_signal(int result) +{ + int ret; + char buf[8]; + char *param[1]; + + snprintf(buf, sizeof(buf), "%d", result); + param[0] = buf; + ret = broadcast_dbus_signal(USD_PATH, + USD_INTERFACE, + USD_USB_DEVICE_CONFIRM_SIGNAL, + "i", param); + if (ret < 0) + _E("FAIL: broadcast_dbus_signal(%d)", ret); +} + +static void usb_device_confirm_ok_clicked(const struct popup_ops *ops) +{ + _I("OK is selected"); + + unload_simple_popup(ops); + + send_result_dbus_signal(USB_DEVICE_CONFIRM_OK); + + terminate_if_no_popup(); +} + +static void usb_device_confirm_cancel_clicked(const struct popup_ops *ops) +{ + _I("CANCEL is selected"); + + unload_simple_popup(ops); + + send_result_dbus_signal(USB_DEVICE_CONFIRM_NOK); + + terminate_if_no_popup(); +} + +static void usb_device_confirm_terminate(const struct popup_ops *ops) +{ + _I("terminate usb device confirm popup"); + + unload_simple_popup(ops); + + send_result_dbus_signal(USB_DEVICE_CONFIRM_NOK); + + terminate_if_no_popup(); +} + +static const struct popup_ops usb_device_confirm_ops = { + .name = "usb_device_confirm", + .show = load_simple_popup, + .content = "Do you use this usb device?", /* TODO */ + .left_text = "IDS_COM_SK_CANCEL", + .left = usb_device_confirm_cancel_clicked, + .right_text = "IDS_COM_SK_OK", + .right = usb_device_confirm_ok_clicked, + .terminate = usb_device_confirm_terminate, +}; + +/* Constructor to register usb_device popup */ +static __attribute__ ((constructor)) void usb_device_register_popup(void) +{ + register_popup(&usb_device_confirm_ops); +} diff --git a/src/usb/usb-mobile.c b/src/usb/usb-mobile.c new file mode 100755 index 0000000..24bfdeb --- /dev/null +++ b/src/usb/usb-mobile.c @@ -0,0 +1,115 @@ +/* + * system-popup + * + * Copyright (c) 2014 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 "popup-common.h" + +static const struct popup_ops usb_error_ops; +static const struct popup_ops usb_restrict_ops; + +static int state_handler = -1; + +static void usb_state_changed(keynode_t *key, void *data) +{ + int state; + const struct popup_ops *ops = data; + + if (vconf_get_int(VCONFKEY_SYSMAN_USB_STATUS, &state) != 0) + return; + + switch (state) { + case VCONFKEY_SYSMAN_USB_DISCONNECTED: + _I("USB cabel is disconnected"); + unload_simple_popup(ops); + if (state_handler == 0) { + vconf_ignore_key_changed( + VCONFKEY_SYSMAN_USB_STATUS, + usb_state_changed); + state_handler = -1; + } + terminate_if_no_popup(); + break; + case VCONFKEY_SYSMAN_USB_CONNECTED: + case VCONFKEY_SYSMAN_USB_AVAILABLE: + default: + break; + } +} + +static int usb_launch(bundle *b, const struct popup_ops *ops) +{ + const struct popup_ops *remove; + + if (ops == &usb_error_ops) + remove = &usb_restrict_ops; + else if (ops == &usb_restrict_ops) + remove = &usb_error_ops; + else + remove = NULL; + + if (remove) + unload_simple_popup(remove); + + if (state_handler != 0) { + state_handler = vconf_notify_key_changed( + VCONFKEY_SYSMAN_USB_STATUS, + usb_state_changed, (void *)ops); + if (state_handler != 0) + _E("Failed to register usb state change event()"); + } + + return 0; +} + +static void usb_terminate(const struct popup_ops *ops) +{ + unload_simple_popup(ops); + if (state_handler == 0) { + vconf_ignore_key_changed( + VCONFKEY_SYSMAN_USB_STATUS, + usb_state_changed); + state_handler = -1; + } + terminate_if_no_popup(); +} + +static const struct popup_ops usb_error_ops = { + .name = "usb_error", + .show = load_simple_popup, + .content = "IDS_USB_POP_USB_CONNECTION_FAILED", + .left_text = "IDS_COM_SK_OK", + .pre = usb_launch, + .terminate = usb_terminate, +}; + +static const struct popup_ops usb_restrict_ops = { + .name = "usb_restrict", + .show = load_simple_popup, + .content = "IDS_ST_POP_SECURITY_POLICY_PREVENTS_USE_OF_DESKTOP_SYNC", + .left_text = "IDS_COM_SK_OK", + .pre = usb_launch, + .terminate = usb_terminate, +}; + + +/* Constructor to register mount_failed button */ +static __attribute__ ((constructor)) void usb_register_popup(void) +{ + register_popup(&usb_error_ops); + register_popup(&usb_restrict_ops); +} diff --git a/src/usb/usbotg-mobile.c b/src/usb/usbotg-mobile.c new file mode 100755 index 0000000..f3ba464 --- /dev/null +++ b/src/usb/usbotg-mobile.c @@ -0,0 +1,324 @@ +/* + * system-popup + * + * Copyright (c) 2014 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 "popup-common.h" +#include +#include + + +#define MYFILES_APPNAME "org.tizen.myfile" +#define GALLERY_APPNAME "org.tizen.gallery" + +#define USB_MOUNT_ROOT_PATH "/opt/storage" +#define USB_MOUNT_PATH "_DEVICE_PATH_" + +#define BUF_MAX 128 + +#define DEVICED_PATH "/Org/Tizen/System/DeviceD" +#define DEVICED_IFACE "org.tizen.system.deviced" +#define DEVICED_PATH_USBHOST DEVICED_PATH"/Usbhost" +#define DEVICED_IFACE_USBHOST DEVICED_IFACE".Usbhost" +#define SIGNAL_NAME_UNMOUNT "unmount_storage" + +static char added_path[BUF_MAX]; +static char removed_path[BUF_MAX]; + +enum ext_app { + EXT_MYFILES, + EXT_GALLERY, +}; + +static const struct popup_ops storage_mounted_ops; +static const struct popup_ops unmount_storage_ops; +static const struct popup_ops camera_added_ops; +static const struct popup_ops storage_mount_failed_ops; +static const struct popup_ops storage_removed_unsafe_ops; + +static void remove_otg_popup(const struct popup_ops *ops, char *path) +{ + int len; + char *popup_path; + + if (ops == &storage_mounted_ops) + popup_path = added_path; + else if (ops == &unmount_storage_ops) + popup_path = removed_path; + else + popup_path = NULL; + + if (popup_path) { + if (!path) + return; + len = strlen(popup_path); + if (len != strlen(path)) + return; + if (strncmp(popup_path, path, len)) + return; + } + + unload_simple_popup(ops); +} + +static void set_myfiles_param(bundle *b) +{ + if (!b) + return; + + if (strlen(added_path) > 0) + appsvc_add_data(b, "path", added_path); + else + appsvc_add_data(b, "path", USB_MOUNT_ROOT_PATH); + appsvc_set_pkgname(b, MYFILES_APPNAME); +} + +static void set_gallery_param(bundle *b) +{ + if (!b) + return; + appsvc_add_data(b, "album-id", "GALLERY_ALBUM_PTP_ID"); + appsvc_set_pkgname(b, GALLERY_APPNAME); +} + +static struct ext_app_type { + int type; + void (*set_param)(bundle *b); +} app_type[] = { + { EXT_MYFILES , set_myfiles_param }, + { EXT_GALLERY , set_gallery_param }, +}; + +static void launch_app(int type) +{ + app_control_h app_control; + + int ret, i, type_len; + + type_len = ARRAY_SIZE(app_type); + for (i = 0 ; i < ARRAY_SIZE(app_type) ; i++) { + if (type == app_type[i].type) + break; + } + if (i == type_len) { + _E("Invalid type (%d)", type); + return; + } + + ret = app_control_create(&app_control); + if (ret != APP_CONTROL_ERROR_NONE) + return; + + ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW); + if (ret != APP_CONTROL_ERROR_NONE) { + (void)app_control_destroy(app_control); + return; + } + + ret = app_control_send_launch_request(app_control, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) + _E("Failed to send launch request"); + + (void)app_control_destroy(app_control); +} + +static void storage_browse(const struct popup_ops *ops) +{ + unload_simple_popup(ops); + launch_app(EXT_MYFILES); + terminate_if_no_popup(); +} + +static void camera_browse(const struct popup_ops *ops) +{ + unload_simple_popup(ops); + launch_app(EXT_GALLERY); + terminate_if_no_popup(); +} + +static void storage_unmount(const struct popup_ops *ops) +{ + char *param[1]; + int ret; + + unload_simple_popup(ops); + + param[0] = removed_path; + + ret = broadcast_dbus_signal(DEVICED_PATH_USBHOST, + DEVICED_IFACE_USBHOST, + SIGNAL_NAME_UNMOUNT, "s", param); + if (ret < 0) + _E("FAIL: broadcast_dbus_signal()"); + + memset(removed_path, 0, sizeof(removed_path)); + + terminate_if_no_popup(); + +} + +static int storage_mounted_launch(bundle *b, const struct popup_ops *ops) +{ + int ret; + struct object_ops *obj; + char *path; + + if (!ops) + return -1; + + ret = get_object_by_ops(ops, &obj); + if (ret < 0) { + _E("Failed to get object (%d)", ret); + return -2; + } + + path = (char *)bundle_get_val(obj->b, USB_MOUNT_PATH); + if (!path) { + _E("Failed to get mount path"); + return -3; + } + + _I("USB storage mount path (%s)", path); + snprintf(added_path, sizeof(added_path), "%s", path); + return 0; +} + +static int unmount_storage_launch(bundle *b, const struct popup_ops *ops) +{ + int ret; + struct object_ops *obj; + char *path; + + if (!ops) + return -1; + + ret = get_object_by_ops(ops, &obj); + _D("ops = %s obj = %s",ops, obj); + if (ret < 0) { + _E("Failed to get object (%d)", ret); + return -2; + } + + path = (char *)bundle_get_val(obj->b, USB_MOUNT_PATH); + if (!path) { + _E("Failed to get mount path"); + return -3; + } + + remove_otg_popup(&storage_mounted_ops, path); + + snprintf(removed_path, sizeof(removed_path), "%s", path); + return 0; +} + +static int storage_unmounted(bundle *b, const struct popup_ops *ops) +{ + char *path; + + if (!b || !ops) + return -EINVAL; + + path = (char *)bundle_get_val(b, USB_MOUNT_PATH); + if (!path) { + _E("Failed to get mount path"); + return -ENOENT; + } + + remove_otg_popup(&storage_mounted_ops, path); + remove_otg_popup(&unmount_storage_ops, path); + + terminate_if_no_popup(); + return 0; +} + +static int camera_removed(bundle *b, const struct popup_ops *ops) +{ + remove_otg_popup(&camera_added_ops, NULL); + terminate_if_no_popup(); + return 0; +} + +static const struct popup_ops storage_mounted_ops = { + .name = "usbotg_storage_mounted", + .show = load_simple_popup, + .title = "IDS_ST_BODY_USB_STORAGE_ABB", + .content = "IDS_USB_BODY_BROWSE_STORAGE_CONNECTED_VIA_USB_Q", + .left_text = "IDS_COM_SK_CANCEL", + .right_text = "IDS_BT_SK_BROWSE", + .right = storage_browse, + .pre = storage_mounted_launch, +}; + +static const struct popup_ops storage_unmounted_ops = { + .name = "usbotg_storage_unmounted", + .show = storage_unmounted, +}; + +static const struct popup_ops unmount_storage_ops = { + .name = "usbotg_unmount_storage", + .show = load_simple_popup, + .title = "IDS_ST_BODY_USB_STORAGE_ABB", + .content = "IDS_COM_POP_UNMOUNT_USB_MASS_STORAGE_BEFORE_REMOVING_TO_AVOID_DATA_LOSS", + .left_text = "IDS_COM_SK_CANCEL", + .right_text = "IDS_USB_BUTTON_UNMOUNT", + .right = storage_unmount, + .pre = unmount_storage_launch, +}; + +static const struct popup_ops camera_added_ops = { + .name = "usbotg_camera_added", + .show = load_simple_popup, + .title = "IDS_CAM_HEADER_CAMERA_M_APPLICATION", + .content = "IDS_USB_BODY_BROWSE_CAMERA_CONNECTED_VIA_USB_Q", + .left_text = "IDS_COM_SK_CANCEL", + .right_text = "IDS_BT_SK_BROWSE", + .right = camera_browse, +}; + +static const struct popup_ops camera_removed_ops = { + .name = "usbotg_camera_removed", + .show = camera_removed, +}; + +static const struct popup_ops storage_mount_failed_ops = { + .name = "usbotg_storage_mount_failed", + .show = load_simple_popup, + .title = "IDS_COM_HEADER_ATTENTION", + .content = "IDS_COM_BODY_USB_STORAGE_BLANK_OR_HAS_UNSUPPORTED_FILE_SYSTEM", + .left_text = "IDS_COM_SK_OK", +}; + +static const struct popup_ops storage_removed_unsafe_ops = { + .name = "usbotg_storage_removed_unsafe", + .show = load_simple_popup, + .title = "IDS_COM_HEADER_ATTENTION", + .content = "IDS_COM_POP_USB_MASS_STORAGE_UNEXPECTEDLY_REMOVED", + .left_text = "IDS_COM_SK_OK", +}; + + +/* Constructor to register mount_failed button */ +static __attribute__ ((constructor)) void usbotg_register_popup(void) +{ + register_popup(&storage_mounted_ops); + register_popup(&storage_unmounted_ops); + register_popup(&unmount_storage_ops); + register_popup(&camera_added_ops); + register_popup(&camera_removed_ops); + register_popup(&storage_mount_failed_ops); + register_popup(&storage_removed_unsafe_ops); +} diff --git a/src/watchdog/watchdog.c b/src/watchdog/watchdog.c new file mode 100755 index 0000000..5352b5f --- /dev/null +++ b/src/watchdog/watchdog.c @@ -0,0 +1,114 @@ +/* + * system-popup + * + * Copyright (c) 2014 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 "popup-common.h" + +#define DBUS_RESOURCED_WATCHDOG_PATH "/Org/Tizen/ResourceD/Process" +#define DBUS_RESOURCED_WATCHDOG_IFACE "org.tizen.resourced.process" +#define DBUS_RESOURCED_WATCHDOG_SIGNAL "WatchdogResult" + +#define APP_NAME "_APP_NAME_" + +enum button_selected { + WATCHDOG_WAIT, + WATCHDOG_OK, +}; + +static int watchdog_get_content(const struct popup_ops *ops, char *content, unsigned int len) +{ + char *text, *name; + struct object_ops *obj; + int ret; + + if (!ops || !content) + return -EINVAL; + + ret = get_object_by_ops(ops, &obj); + if (ret < 0) { + _E("Failed to get object (%d)", ret); + return -ENOENT; + } + + name = (char *)bundle_get_val(obj->b, APP_NAME); + if (!name) { + _E("Failed to get app name"); + return -ENOENT; + } + + text = _("IDS_ST_BODY_PS_IS_NOT_RESPONDING_CLOSE_PS_Q"); + + snprintf(content, len, text, name, name); + + return 0; +} + +static void send_result_dbus_signal(int result) +{ + int ret; + char buf[8]; + char *param[1]; + + snprintf(buf, sizeof(buf), "%d", result); + param[0] = buf; + ret = broadcast_dbus_signal(DBUS_RESOURCED_WATCHDOG_PATH, + DBUS_RESOURCED_WATCHDOG_IFACE, + DBUS_RESOURCED_WATCHDOG_SIGNAL, + "i", param); + if (ret < 0) + _E("FAIL: broadcast_dbus_signal(%d)", ret); +} + +static void watchdog_wait(const struct popup_ops *ops) +{ + _I("Wait is selected"); + + unload_simple_popup(ops); + + send_result_dbus_signal(WATCHDOG_WAIT); + + terminate_if_no_popup(); +} + +static void watchdog_ok(const struct popup_ops *ops) +{ + _I("OK is selected"); + + unload_simple_popup(ops); + + send_result_dbus_signal(WATCHDOG_OK); + + terminate_if_no_popup(); +} + +static const struct popup_ops watchdog_ops = { + .name = "watchdog", + .show = load_simple_popup, + .title = "IDS_CLD_HEADER_NO_RESPONSE", + .get_content = watchdog_get_content, + .left_text = "IDS_CST_OPT_WAIT", + .left = watchdog_wait, + .right_text = "IDS_COM_SK_OK", + .right = watchdog_ok, +}; + +/* Constructor to register watchdog button */ +static __attribute__ ((constructor)) void watchdog_register_popup(void) +{ + register_popup(&watchdog_ops); +}