- all popups are launched by deviced or resourced. However the deviced and resourced are
system daemons and they should not have dependency with AUL. Thus the popups are launched
by dbus activation. popup-launcher is activated by dbus automatically and the popup-launcher
launches all popups for each situation
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
Change-Id: I6763de603284516f77a9c8041916e6df9614ae8f
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(SYSTEM_RESDIR "${PREFIX}/share/system-apps/res")
SET(SYSTEM_ICONDIR "${SYSTEM_RESDIR}/icons")
-
SET(LANG_DOMAIN "system-apps")
SET(LOCALE_DIR "/usr/share/locale")
+ADD_DEFINITIONS("-DSYSTEM_RESDIR=\"${SYSTEM_RESDIR}\"")
+ADD_DEFINITIONS("-DSYSTEM_ICONDIR=\"${SYSTEM_ICONDIR}\"")
ADD_DEFINITIONS("-DLANG_DOMAIN=\"${LANG_DOMAIN}\"")
ADD_DEFINITIONS("-DLOCALE_DIR=\"${LOCALE_DIR}\"")
# SUbmodules
+ADD_SUBDIRECTORY(popup-launcher)
ADD_SUBDIRECTORY(po)
ADD_SUBDIRECTORY(poweroff-popup)
ADD_SUBDIRECTORY(lowbatt-popup)
--- /dev/null
+<manifest>
+ <define>
+ <domain name="system-apps"/>
+ </define>
+ <assign>
+ <filesystem path="/usr/bin/popup-launcher" label="_" exec_label="none" />
+ <filesystem path="/usr/bin/sys_device_noti" label="_" exec_label="none" />
+ <filesystem path="/usr/bin/systemfw-app-test" label="_" exec_label="none" />
+ </assign>
+ <request>
+ <domain name="system-apps"/>
+ </request>
+</manifest>
License: Apache-2.0
Source0: %{name}-%{version}.tar.bz2
Source1001: %{name}.manifest
+Source1: system-apps.manifest
Source1002: org.tizen.lowmem-syspopup.manifest
Source1003: org.tizen.lowbat-syspopup.manifest
Source1004: org.tizen.mmc-syspopup.manifest
%manifest %{name}.manifest
%defattr(-,root,root,-)
%{_datadir}/locale/*/LC_MESSAGES/*.mo
+/usr/share/system-apps/res/icons/datausage_warning.png
+/usr/share/system-apps/res/icons/led_torch.png
+/usr/share/system-apps/res/icons/sdcard_encryption.png
+/usr/share/system-apps/res/icons/sdcard_decryption.png
+/usr/share/system-apps/res/icons/sdcard_encryption_error.png
+/usr/share/system-apps/res/icons/sdcard_decryption_error.png
+/usr/share/system-apps/res/icons/usb.png
+/usr/share/system-apps/res/icons/battery_full_noti.png
+/usr/share/system-apps/res/icons/battery_full_indi.png
+%{_bindir}/popup-launcher
+/usr/share/dbus-1/services/org.tizen.system.popup.service
+/etc/smack/accesses2.d/system-apps.rule
%files -n org.tizen.poweroff-syspopup
%manifest %{name}.manifest
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+ADD_SUBDIRECTORY(src)
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(SRCS ${CMAKE_SOURCE_DIR}/popup-launcher/src/launcher.c
+ ${CMAKE_SOURCE_DIR}/popup-launcher/src/popup.c
+ ${CMAKE_SOURCE_DIR}/popup-launcher/src/noti.c
+ ${CMAKE_SOURCE_DIR}/popup-launcher/src/app.c
+ ${CMAKE_SOURCE_DIR}/share/src/common.c
+)
+
+SET(APPNAME "popup-launcher")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/share/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/popup-launcher/src)
+
+SET(PKG_MODULES ${PKG_MODULES}
+ edbus
+ dlog
+ ecore
+ syspopup-caller
+ syspopup
+ appsvc
+ notification
+ appcore-efl
+ elementary
+ devman
+ sysman
+ pmapi
+ deviced
+ utilX
+ bundle
+ evas
+ vconf
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Wall")
+
+ADD_DEFINITIONS("-DAPPNAME=\"${APPNAME}\"")
+
+ADD_EXECUTABLE(${APPNAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${APPNAME} ${pkgs_LDFLAGS} "-ldl")
+
+INSTALL(TARGETS ${APPNAME} DESTINATION bin)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${APPNAME}/src/org.tizen.system.popup.service DESTINATION /usr/share/dbus-1/services)
+
+# instatll rule file
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${APPNAME}/src/system-apps.rule DESTINATION /etc/smack/accesses2.d)
+
+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/sdcard_encryption.png DESTINATION ${SYSTEM_ICONDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/sdcard_decryption.png DESTINATION ${SYSTEM_ICONDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/sdcard_encryption_error.png DESTINATION ${SYSTEM_ICONDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/sdcard_decryption_error.png DESTINATION ${SYSTEM_ICONDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/usb.png DESTINATION ${SYSTEM_ICONDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/battery_full_indi.png DESTINATION ${SYSTEM_ICONDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/battery_full_noti.png DESTINATION ${SYSTEM_ICONDIR})
--- /dev/null
+/*
+ * 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;
+}
+
+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;
+}
--- /dev/null
+/*
+ * 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"
+
+#define TERMINATE_TIMEOUT 5
+
+static E_DBus_Connection *edbus_conn;
+static DBusPendingCall *edbus_request_name;
+static Ecore_Timer *term_timer = NULL;
+
+static Eina_Bool exit_idler_cb(void *data)
+{
+ e_dbus_connection_close(edbus_conn);
+ e_dbus_shutdown();
+
+ ecore_main_loop_quit();
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool terminate_launcher(void *data)
+{
+ if (term_timer)
+ ecore_timer_del(term_timer);
+
+ if (ecore_idler_add(exit_idler_cb, NULL))
+ return ECORE_CALLBACK_CANCEL;
+
+ exit_idler_cb(NULL);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void set_timer_to_terminate(void)
+{
+ if (term_timer)
+ ecore_timer_reset(term_timer);
+ else {
+ term_timer = ecore_timer_add(TERMINATE_TIMEOUT, terminate_launcher, NULL);
+ if (!term_timer)
+ terminate_launcher(NULL);
+ }
+}
+
+static DBusMessage *edbus_noti_off(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return deactivate_notification(obj, msg);
+}
+
+/* Poweroff popup */
+static DBusMessage *edbus_poweroff_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_no_param(obj, msg, POWEROFF_SYSPOPUP);
+}
+
+static const struct edbus_method
+edbus_poweroff_methods[] = {
+ { "PopupLaunch" , NULL, "i", edbus_poweroff_popup },
+ /* Add methods here */
+};
+
+/* Lowbat popup */
+static DBusMessage *edbus_lowbat_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_single_param(obj, msg, LOWBAT_SYSPOPUP);
+}
+
+static const struct edbus_method
+edbus_lowbat_methods[] = {
+ { "PopupLaunch" , "ss", "i", edbus_lowbat_popup },
+ /* Add methods here */
+};
+
+/* Lowmem popup */
+static DBusMessage *edbus_lowmem_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_single_param(obj, msg, LOWMEM_SYSPOPUP);
+}
+
+static const struct edbus_method
+edbus_lowmem_methods[] = {
+ { "PopupLaunch" , "ss", "i", edbus_lowmem_popup },
+ /* Add methods here */
+};
+
+/* Mmc popup */
+static DBusMessage *edbus_mmc_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_single_param(obj, msg, MMC_SYSPOPUP);
+}
+
+static const struct edbus_method
+edbus_mmc_methods[] = {
+ { "PopupLaunch" , "ss", "i", edbus_mmc_popup },
+ /* Add methods here */
+};
+
+/* Usb popup */
+static DBusMessage *edbus_usb_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_single_param(obj, msg, USB_SYSPOPUP);
+}
+
+static const struct edbus_method
+edbus_usb_methods[] = {
+ { "PopupLaunch" , "ss", "i", edbus_usb_popup },
+ /* Add methods here */
+};
+
+/* Usbotg popup */
+static DBusMessage *edbus_usbstorage_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_double_param(obj, msg, USBOTG_SYSPOPUP);
+}
+
+static DBusMessage *edbus_usbcamera_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_single_param(obj, msg, USBOTG_SYSPOPUP);
+}
+
+static DBusMessage *edbus_usbstorage_unmount_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_double_param(obj, msg, USBOTG_SYSPOPUP);
+}
+
+static const struct edbus_method
+edbus_usbotg_methods[] = {
+ { "StoragePopupLaunch" , "ssss", "i", edbus_usbstorage_popup },
+ { "CameraPopupLaunch" , "ss", "i", edbus_usbcamera_popup },
+ { "StorageUnmountPopupLaunch" , "ssss", "i", edbus_usbstorage_unmount_popup },
+ /* Add methods here */
+};
+
+/* DataUsage popups/notifications */
+static DBusMessage *edbus_datausage_blocked_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_double_param(obj, msg, DATAUSAGE_SYSPOPUP);
+}
+
+static DBusMessage *edbus_datausage_warning_noti_on(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return activate_notification_no_param(obj, msg, DATAUSAGE_WARNING);
+}
+
+static DBusMessage *edbus_datausage_disabled_noti_on(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return activate_notification_no_param(obj, msg, DATAUSAGE_DISABLED);
+}
+
+static const struct edbus_method
+edbus_datausage_methods[] = {
+ { "BlockedPopupLaunch" , "ssss", "i", edbus_datausage_blocked_popup },
+ { "WarningNotiOn" , NULL, "i", edbus_datausage_warning_noti_on },
+ { "WarningNotiOff" , "i", "i", edbus_noti_off },
+ { "DisabledNotiOn" , NULL, "i", edbus_datausage_disabled_noti_on },
+ { "DisabledNotiOff" , "i", "i", edbus_noti_off },
+ /* Add methods here */
+};
+
+/* LED torch notifications */
+static DBusMessage *edbus_led_torch_noti_on(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return activate_notification_no_param(obj, msg, LED_TORCH);
+}
+
+static const struct edbus_method
+edbus_led_methods[] = {
+ { "TorchNotiOn" , NULL, "i", edbus_led_torch_noti_on },
+ { "TorchNotiOff" , "i", "i", edbus_noti_off },
+ /* Add methods here */
+};
+
+/* Ode complete/progress notifications */
+static DBusMessage *edbus_ode_complete_noti_on(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return activate_notification_single_param(obj, msg, ODE_COMPLETE);
+}
+
+static DBusMessage *edbus_ode_progress_noti_on(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return activate_notification_single_param(obj, msg, ODE_PROGRESS);
+}
+
+static DBusMessage *edbus_ode_progress_noti_update(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return progress_update_notification(obj, msg);
+}
+
+static DBusMessage *edbus_ode_error_noti_on(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return activate_notification_triple_param(obj, msg, ODE_ERROR);
+}
+
+static const struct edbus_method
+edbus_ode_methods[] = {
+ { "CompNotiOn" , "s", "i", edbus_ode_complete_noti_on },
+ { "CompNotiOff" , "i", "i", edbus_noti_off },
+ { "ProgNotiOn" , "s", "i", edbus_ode_progress_noti_on },
+ { "ProgNotiUpdate" , "ii", "i", edbus_ode_progress_noti_update },
+ { "ProgNotiOff" , "i", "i", edbus_noti_off },
+ { "ErrorNotiOn" , "sii", "i", edbus_ode_error_noti_on },
+ { "ErrorNotiOff" , "i", "i", edbus_noti_off },
+ /* Add methods here */
+};
+
+/* System popup */
+static DBusMessage *edbus_recovery_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_single_param(obj, msg, SYSTEM_SYSPOPUP);
+}
+
+static DBusMessage *edbus_watchdog_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_double_param(obj, msg, SYSTEM_SYSPOPUP);
+}
+
+static DBusMessage *edbus_usbotg_warning_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_single_param(obj, msg, SYSTEM_SYSPOPUP);
+}
+
+static DBusMessage *edbus_brightness_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_double_param(obj, msg, SYSTEM_SYSPOPUP);
+}
+
+static DBusMessage *edbus_ode_error_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_triple_param(obj, msg, SYSTEM_SYSPOPUP);
+}
+
+static const struct edbus_method
+edbus_system_methods[] = {
+ { "RecoveryPopupLaunch" , "ss", "i", edbus_recovery_popup },
+ { "WatchdogPopupLaunch" , "ssss", "i", edbus_watchdog_popup },
+ { "UsbotgWarningPopupLaunch" , "ss", "i", edbus_usbotg_warning_popup },
+ { "BrightnessPopupLaunch" , "ssss", "i", edbus_brightness_popup },
+ { "OdeErrorPopupLaunch" , "ssssss", "i", edbus_ode_error_popup },
+ /* Add methods here */
+};
+
+/* Crash popup */
+static DBusMessage *edbus_crash_popup(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_popup_double_param(obj, msg, CRASH_SYSPOPUP);
+}
+
+static const struct edbus_method
+edbus_crash_methods[] = {
+ { "PopupLaunch" , "ssss", "i", edbus_crash_popup },
+ /* Add methods here */
+};
+
+/* Ticker noti */
+static DBusMessage *edbus_ticker_noti_on(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return activate_notification_single_param(obj, msg, TICKER);
+}
+
+static const struct edbus_method
+edbus_ticker_methods[] = {
+ { "TickerNotiOn" , "s", "i", edbus_ticker_noti_on },
+ /* Add methods here */
+};
+
+/* App noti */
+static DBusMessage *edbus_cradle_app_launch(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_app_no_param(obj, msg, CRADLE_APP_NAME);
+}
+
+static DBusMessage *edbus_pwlock_app_launch(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return launch_app_single_param(obj, msg, PWLOCK_APP_NAME);
+}
+
+static DBusMessage *edbus_app_terminate_by_pid(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return terminate_app_by_pid(obj, msg);
+}
+
+static const struct edbus_method
+edbus_app_methods[] = {
+ { "CradleAppLaunch" , NULL, "i", edbus_cradle_app_launch },
+ { "PWLockAppLaunch" , "ss", "i", edbus_pwlock_app_launch },
+ { "AppTerminateByPid", "i", "i", edbus_app_terminate_by_pid },
+ /* Add methods here */
+};
+
+/* USB host notifications */
+static DBusMessage *edbus_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 *edbus_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 *edbus_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 *edbus_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
+edbus_usbhost_methods[] = {
+ { "UsbStorageNotiOn" , "s", "i", edbus_usb_storage_noti_on },
+ { "UsbStorageRoNotiOn" , "s", "i", edbus_usb_storage_ro_noti_on },
+ { "UsbStorageNotiOff" , "i", "i", edbus_noti_off },
+ { "UsbDeviceNotiOn" , "ss", "i", edbus_usb_device_noti_on },
+ { "UsbDeviceNotiUpdate", "isss", "i", edbus_usb_device_noti_update },
+ { "UsbDeviceNotiOff" , "i", "i", edbus_noti_off },
+
+ /* Add methods here */
+};
+
+/* Battery notifications */
+static DBusMessage *edbus_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 *edbus_battery_charge_noti_on(E_DBus_Object *obj, DBusMessage *msg)
+{
+ set_timer_to_terminate();
+ return activate_notification_no_param(obj, msg, BATTERY_CHARGE);
+}
+
+static const struct edbus_method
+edbus_battery_methods[] = {
+ { "BatteryFullNotiOn" , NULL, "i", edbus_battery_full_noti_on },
+ { "BatteryFullNotiOff" , "i", "i", edbus_noti_off },
+ { "BatteryChargeNotiOn" , NULL, "i", edbus_battery_charge_noti_on },
+ /* Add methods here */
+};
+
+static struct edbus_object
+edbus_objects[]= {
+ { POPUP_PATH_POWEROFF , POPUP_IFACE_POWEROFF , NULL, NULL,
+ edbus_poweroff_methods , ARRAY_SIZE(edbus_poweroff_methods) },
+ { POPUP_PATH_LOWBAT , POPUP_IFACE_LOWBAT , NULL, NULL,
+ edbus_lowbat_methods , ARRAY_SIZE(edbus_lowbat_methods) },
+ { POPUP_PATH_LOWMEM , POPUP_IFACE_LOWMEM , NULL, NULL,
+ edbus_lowmem_methods , ARRAY_SIZE(edbus_lowmem_methods) },
+ { POPUP_PATH_MMC , POPUP_IFACE_MMC , NULL, NULL,
+ edbus_mmc_methods , ARRAY_SIZE(edbus_mmc_methods) },
+ { POPUP_PATH_USB , POPUP_IFACE_USB , NULL, NULL,
+ edbus_usb_methods , ARRAY_SIZE(edbus_usb_methods) },
+ { POPUP_PATH_USBOTG , POPUP_IFACE_USBOTG , NULL, NULL,
+ edbus_usbotg_methods , ARRAY_SIZE(edbus_usbotg_methods) },
+ { POPUP_PATH_DATAUSAGE , POPUP_IFACE_DATAUSAGE , NULL, NULL,
+ edbus_datausage_methods , ARRAY_SIZE(edbus_datausage_methods) },
+ { POPUP_PATH_LED , POPUP_IFACE_LED , NULL, NULL,
+ edbus_led_methods , ARRAY_SIZE(edbus_led_methods) },
+ { POPUP_PATH_ODE , POPUP_IFACE_ODE , NULL, NULL,
+ edbus_ode_methods , ARRAY_SIZE(edbus_ode_methods) },
+ { POPUP_PATH_SYSTEM , POPUP_IFACE_SYSTEM , NULL, NULL,
+ edbus_system_methods , ARRAY_SIZE(edbus_system_methods) },
+ { POPUP_PATH_CRASH , POPUP_IFACE_CRASH , NULL, NULL,
+ edbus_crash_methods , ARRAY_SIZE(edbus_crash_methods) },
+ { POPUP_PATH_TICKER , POPUP_IFACE_TICKER , NULL, NULL,
+ edbus_ticker_methods , ARRAY_SIZE(edbus_ticker_methods) },
+ { POPUP_PATH_APP , POPUP_IFACE_APP , NULL, NULL,
+ edbus_app_methods , ARRAY_SIZE(edbus_app_methods) },
+ { POPUP_PATH_USBHOST , POPUP_IFACE_USBHOST , NULL, NULL,
+ edbus_usbhost_methods , ARRAY_SIZE(edbus_usbhost_methods) },
+ { POPUP_PATH_BATTERY , POPUP_IFACE_BATTERY , NULL, NULL,
+ edbus_battery_methods , ARRAY_SIZE(edbus_battery_methods) },
+ /* Add new object & interface here*/
+};
+
+static int init_methods(void)
+{
+ int ret;
+ int i, j;
+
+ for (i = 0; i < ARRAY_SIZE(edbus_objects); i++) {
+ for (j = 0; j < edbus_objects[i].methods_len; j++) {
+ ret = e_dbus_interface_method_add(edbus_objects[i].iface,
+ edbus_objects[i].methods[j].member,
+ edbus_objects[i].methods[j].signature,
+ edbus_objects[i].methods[j].reply_signature,
+ edbus_objects[i].methods[j].func);
+ if (!ret) {
+ _E("fail to add method %s!", edbus_objects[i].methods[j].member);
+ return -ECONNREFUSED;
+ }
+ }
+ }
+ return 0;
+}
+
+static int register_dbus(void)
+{
+ DBusError error;
+ int retry, ret, i;
+
+ dbus_error_init(&error);
+
+ retry = 0;
+ do {
+ if (e_dbus_init())
+ break;
+ if (++retry == RETRY_MAX) {
+ _E("fail to init edbus");
+ return -ECONNREFUSED;
+ }
+ } while (retry <= RETRY_MAX);
+
+ retry = 0;
+ do {
+ edbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (edbus_conn)
+ break;
+ if (++retry == RETRY_MAX) {
+ _E("fail to get edbus");
+ ret = -ECONNREFUSED;
+ goto out1;
+ }
+ } while (retry <= RETRY_MAX);
+
+ retry = 0;
+ do {
+ edbus_request_name = e_dbus_request_name(edbus_conn, BUS_NAME, 0, NULL, NULL);
+ if (edbus_request_name)
+ break;
+ if (++retry == RETRY_MAX) {
+ _E("fail to request edbus name");
+ ret = -ECONNREFUSED;
+ goto out2;
+ }
+ } while (retry <= RETRY_MAX);
+
+ for (i = 0; i < ARRAY_SIZE(edbus_objects); i++) {
+ edbus_objects[i].obj = e_dbus_object_add(edbus_conn, edbus_objects[i].path, NULL);
+ if (!(edbus_objects[i].obj)) {
+ _E("fail to add edbus obj");
+ ret = -ECONNREFUSED;
+ goto out2;
+ }
+
+ edbus_objects[i].iface = e_dbus_interface_new(edbus_objects[i].interface);
+ if (!(edbus_objects[i].iface)) {
+ _E("fail to add edbus interface");
+ ret = -ECONNREFUSED;
+ goto out2;
+ }
+
+ e_dbus_object_interface_attach(edbus_objects[i].obj, edbus_objects[i].iface);
+ }
+
+ return 0;
+
+out2:
+ e_dbus_connection_close(edbus_conn);
+out1:
+ e_dbus_shutdown();
+
+ return ret;
+}
+
+int main (int argc, char *argv[])
+{
+ int ret;
+
+ ecore_init();
+
+ ret = register_dbus();
+ if (ret < 0)
+ return ret;
+
+ ret= init_methods();
+ if (ret < 0)
+ return ret;
+
+ ecore_main_loop_begin();
+ ecore_shutdown();
+ return 0;
+}
--- /dev/null
+/*
+ * 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.
+ *
+*/
+
+#ifndef __LAUNCHER_H__
+#define __LAUNCHER_H__
+
+#include <stdio.h>
+#include <bundle.h>
+#include <E_DBus.h>
+#include <aul.h>
+#include "common.h"
+
+#define RETRY_MAX 10
+#define SLEEP_USEC 200000
+
+/* DBus paths, interfaces */
+#define BUS_NAME "org.tizen.system.popup"
+#define POPUP_DBUS_PATH "/Org/Tizen/System/Popup"
+#define POPUP_DBUS_IFACE BUS_NAME
+
+#define POPUP_PATH_POWEROFF POPUP_DBUS_PATH"/Poweroff"
+#define POPUP_IFACE_POWEROFF BUS_NAME".Poweroff"
+
+#define POPUP_PATH_LOWBAT POPUP_DBUS_PATH"/Lowbat"
+#define POPUP_IFACE_LOWBAT BUS_NAME".Lowbat"
+
+#define POPUP_PATH_LOWMEM POPUP_DBUS_PATH"/Lowmem"
+#define POPUP_IFACE_LOWMEM BUS_NAME".Lowmem"
+
+#define POPUP_PATH_MMC POPUP_DBUS_PATH"/Mmc"
+#define POPUP_IFACE_MMC BUS_NAME".Mmc"
+
+#define POPUP_PATH_USB POPUP_DBUS_PATH"/Usb"
+#define POPUP_IFACE_USB BUS_NAME".Usb"
+
+#define POPUP_PATH_USBOTG POPUP_DBUS_PATH"/Usbotg"
+#define POPUP_IFACE_USBOTG BUS_NAME".Usbotg"
+
+#define POPUP_PATH_DATAUSAGE POPUP_DBUS_PATH"/DataUsage"
+#define POPUP_IFACE_DATAUSAGE BUS_NAME".DataUsage"
+
+#define POPUP_PATH_LED POPUP_DBUS_PATH"/Led"
+#define POPUP_IFACE_LED BUS_NAME".Led"
+
+#define POPUP_PATH_ODE POPUP_DBUS_PATH"/Ode"
+#define POPUP_IFACE_ODE BUS_NAME".Ode"
+
+#define POPUP_PATH_SYSTEM POPUP_DBUS_PATH"/System"
+#define POPUP_IFACE_SYSTEM BUS_NAME".System"
+
+#define POPUP_PATH_CRASH POPUP_DBUS_PATH"/Crash"
+#define POPUP_IFACE_CRASH BUS_NAME".Crash"
+
+#define POPUP_PATH_TICKER POPUP_DBUS_PATH"/Ticker"
+#define POPUP_IFACE_TICKER BUS_NAME".Ticker"
+
+#define POPUP_PATH_APP POPUP_DBUS_PATH"/Apps"
+#define POPUP_IFACE_APP BUS_NAME".Apps"
+
+#define POPUP_PATH_USBHOST POPUP_DBUS_PATH"/Usbhost"
+#define POPUP_IFACE_USBHOST BUS_NAME".Usbhost"
+
+#define POPUP_PATH_BATTERY POPUP_DBUS_PATH"/Battery"
+#define POPUP_IFACE_BATTERY BUS_NAME".Battery"
+
+/* Popup names */
+#define POWEROFF_SYSPOPUP "poweroff-syspopup"
+#define LOWBAT_SYSPOPUP "lowbat-syspopup"
+#define LOWMEM_SYSPOPUP "lowmem-syspopup"
+#define MMC_SYSPOPUP "mmc-syspopup"
+#define USB_SYSPOPUP "usb-syspopup"
+#define USBOTG_SYSPOPUP "usbotg-syspopup"
+#define DATAUSAGE_SYSPOPUP "datausage-syspopup"
+#define SYSTEM_SYSPOPUP "system-syspopup"
+#define CRASH_SYSPOPUP "crash-popup"
+
+/* Setting ugs */
+#define SETTING_DATAUSAGE_UG "setting-datausage-efl"
+#define SETTING_ACCESSIBILITY_UG "setting-accessibility-efl"
+#define SETTING_MMC_ENCRYPTION_UG "setting-mmc-encryption-efl"
+#define SETTING_ENCRYPTING_APP "com.samsung.setting.encrypting"
+#define SETTING_LIGHTOFF_APP "com.samsung.setting.turnofflight"
+
+/* ODE */
+#define ODE_ENCRYPT "encrypt"
+#define ODE_DECRYPT "decrypt"
+
+/* App to launch a popup on a notification */
+#define SYSTEM_SIGNAL_SENDER "com.samsung.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_DEVICE_PATH "_DEVICE_PATH_"
+#define SIGNAL_SENDER_ERROR_TYPE "_ERROR_TYPE_"
+#define SIGNAL_SENDER_MEMORY_SPACE "_MEMORY_SPACE_"
+
+/* App to show Host devices list */
+#define HOST_DEVICES "com.samsung.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 USB_ICON SYSTEM_ICONDIR"/usb.png"
+#define BATT_INDI_ICON SYSTEM_ICONDIR"/battery_full_indi.png"
+#define BATT_NOTI_ICON SYSTEM_ICONDIR"/battery_full_noti.png"
+
+/* Notification parameters */
+#define VALUE_DATA_WARNING "data_warning"
+
+/* App launching */
+#define CRADLE_APP_NAME "com.samsung.desk-dock"
+#define PWLOCK_APP_NAME "com.samsung.pwlock"
+
+enum noti_type {
+ DATAUSAGE_WARNING = 0,
+ DATAUSAGE_DISABLED,
+ LED_TORCH,
+ ODE_COMPLETE,
+ ODE_PROGRESS,
+ ODE_ERROR,
+ TICKER,
+ USB_STORAGE,
+ USB_STORAGE_RO,
+ USB_DEVICE,
+ BATTERY_FULL,
+ BATTERY_CHARGE,
+ /* Add here additional notificatoins */
+ NOTI_TYPE_MAX
+};
+
+enum ode_error_type {
+ NOT_ENOUGH_SPACE,
+ OPERATION_FAILED,
+ ODE_ERROR_MAX,
+};
+
+struct edbus_method {
+ const char *member;
+ const char *signature;
+ const char *reply_signature;
+ E_DBus_Method_Cb func;
+};
+
+struct edbus_object {
+ const char *path;
+ const char *interface;
+ E_DBus_Object *obj;
+ E_DBus_Interface *iface;
+ const struct edbus_method *methods;
+ const int methods_len;
+};
+
+/* launch popup */
+DBusMessage *launch_popup_no_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *popup_name);
+DBusMessage *launch_popup_single_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *popup_name);
+DBusMessage *launch_popup_double_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *popup_name);
+DBusMessage *launch_popup_triple_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *popup_name);
+
+/* Activate notification */
+DBusMessage *activate_notification_no_param(E_DBus_Object *obj,
+ DBusMessage *msg, int type);
+DBusMessage *activate_notification_single_param(E_DBus_Object *obj,
+ DBusMessage *msg, int type);
+DBusMessage *activate_notification_double_param(E_DBus_Object *obj,
+ DBusMessage *msg, int type);
+DBusMessage *activate_notification_triple_param(E_DBus_Object *obj,
+ DBusMessage *msg, int type);
+
+/* Deactivate notification */
+DBusMessage *deactivate_notification(E_DBus_Object *obj, DBusMessage *msg);
+
+/* Update progress bar on the notification */
+DBusMessage *progress_update_notification(E_DBus_Object *obj, DBusMessage *msg);
+
+/* Update text of notification */
+DBusMessage *update_notification_double_param(E_DBus_Object *obj,
+ DBusMessage *msg, int type);
+
+/* launch app */
+DBusMessage *launch_app_no_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *appname);
+DBusMessage *launch_app_single_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *appname);
+DBusMessage *terminate_app_by_pid(E_DBus_Object *obj, DBusMessage *msg);
+
+#endif /* __LAUNCHER_H__ */
+
--- /dev/null
+/*
+ * 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 <vconf.h>
+#include <appsvc.h>
+#include <notification.h>
+#include "launcher.h"
+
+#define BUF_MAX 256
+
+struct ticker_info {
+ const char *name;
+ const char *msgid;
+};
+
+static const struct ticker_info ticker_notifications[] = {
+ { "usb-client-default" , "IDS_COM_BODY_CONNECTED_AS_A_MEDIA_DEVICE" },
+ { "usb-client-ssh" , "SSH enabled" },
+ { "dock-connected" , "IDS_QP_POP_THE_DOCK_IS_CONNECTED" },
+ { "hdmi-connected" , "IDS_VPL_POP_HDMI_CABLE_CONNECTED" },
+ { "hdmi-disconnected" , "IDS_VPL_POP_HDMI_CABLE_DISCONNECTED" },
+ { "connector-connected" , "IDS_COM_POP_USB_CONNECTOR_CONNECTED" },
+ { "connector-disconnected" , "IDS_COM_POP_USB_CONNECTOR_DISCONNECTED" },
+ { "keyboard-connected" , "IDS_COM_POP_KEYBOARD_CONNECTED_ABB2" },
+ { "mouse-connected" , "IDS_COM_POP_MOUSE_CONNECTED_ABB2" },
+ { "storage-connected" , "IDS_COM_POP_USB_MASS_STORAGE_CONNECTED_ABB2" },
+ { "storage-ro-connected" , "IDS_ST_BODY_READ_ONLY_USB_DEV_CONNECTED_M_NOUN_ABB" },
+ { "storage-disconnected-safe" , "IDS_USB_BODY_USB_MASS_STORAGE_SAFELY_REMOVED" },
+ { "storage-disconnected-unsafe" , "IDS_COM_POP_USB_MASS_STORAGE_UNEXPECTEDLY_REMOVED" },
+ { "camera-connected" , "IDS_COM_POP_CAMERA_CONNECTED_ABB2" },
+ { "printer-connected" , "IDS_COM_POP_PRINTER_CONNECTED_ABB2" },
+ { "unknown-connected" , "IDS_COM_POP_UNKNOWN_USB_DEVICE_CONNECTED" },
+ { "device-disconnected" , "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 *title, *content, *input, *icon;
+ int ret;
+ bundle *b;
+
+
+ if (!data)
+ return -EINVAL;
+
+ input = (char *)data;
+
+ if (!strncmp(input, ODE_ENCRYPT, strlen(ODE_ENCRYPT))) {
+ title = "IDS_ST_BODY_SD_CARD_ENCRYPTION";
+ content = "IDS_ST_BODY_SD_CARD_ENCRYPTION_HAS_BEEN_ENABLED";
+ icon = ODE_ENCRYPT_ICON;
+ } else if (!strncmp(input, ODE_DECRYPT, strlen(ODE_DECRYPT))) {
+ title = "IDS_DN_HEADER_DATA_DECRYPTION_ABB";
+ content = "IDS_DN_POP_DATA_DECRYPTED";
+ icon = ODE_DECRYPT_ICON;
+ } else {
+ return -EINVAL;
+ }
+
+ b = bundle_create();
+ if (b)
+ appsvc_set_pkgname(b, SETTING_MMC_ENCRYPTION_UG);
+
+ ret = add_notification(NOTIFICATION_TYPE_NOTI,
+ NOTIFICATION_LY_NOTI_EVENT_SINGLE,
+ title,
+ content,
+ 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_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_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_QP_BODY_UNPLUG_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_battery_charge_notification(void)
+{
+ return 0;
+}
+
+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 BATTERY_FULL:
+ return launch_battery_full_notification();
+ case BATTERY_CHARGE:
+ return launch_battery_charge_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;
+ }
+
+ _D("Remove notification (noti id: %d)", value);
+
+ 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;
+ }
+
+ _D("Progress update notification (noti id: %d, rate: %d\%)", priv_id, rate);
+
+ 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;
+}
--- /dev/null
+[D-BUS Service]
+Name=org.tizen.system.popup
+Exec=/usr/bin/popup-launcher
--- /dev/null
+/*
+ * 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 <syspopup_caller.h>
+#include "launcher.h"
+
+static int launch_popup(char *popup_name,
+ char *key1, char *value1,
+ char *key2, char *value2,
+ char *key3, char *value3)
+{
+ int ret;
+ bundle *b;
+
+ if (!popup_name)
+ 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 = syspopup_launch(popup_name, b);
+ if (ret < 0)
+ _E("FAIL: syspopup_launch(): %d", ret);
+
+out:
+ bundle_free(b);
+ return ret;
+}
+
+DBusMessage *launch_popup_no_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *popup_name)
+{
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ int ret;
+
+ if (!popup_name) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ _I("launch popup (%s)", popup_name);
+
+ ret = launch_popup(popup_name, NULL, NULL, NULL, NULL, NULL, NULL);
+ if (ret < 0)
+ _E("FAIL: launch_popup(): %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_popup_single_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *popup_name)
+{
+ DBusError err;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ char *key;
+ char *value;
+ int ret;
+
+ if (!popup_name) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ _I("launch popup (%s)", popup_name);
+
+ 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_popup(popup_name, key, value, NULL, NULL, NULL, NULL);
+ if (ret < 0)
+ _E("FAIL: launch_popup(): %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_popup_double_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *popup_name)
+{
+ DBusError err;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ char *key1, *key2;
+ char *value1, *value2;
+ int ret;
+
+ if (!popup_name) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ _I("launch popup (%s)", popup_name);
+
+ dbus_error_init(&err);
+
+ if (!dbus_message_get_args(msg, &err,
+ DBUS_TYPE_STRING, &key1,
+ DBUS_TYPE_STRING, &value1,
+ DBUS_TYPE_STRING, &key2,
+ DBUS_TYPE_STRING, &value2,
+ DBUS_TYPE_INVALID)) {
+ _E("there is no message");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (!key1 || !key2 || !value1 || !value2) {
+ _E("message is invalid!");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = launch_popup(popup_name, key1, value1, key2, value2, NULL, NULL);
+ if (ret < 0)
+ _E("FAIL: launch_popup(): %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_popup_triple_param(E_DBus_Object *obj,
+ DBusMessage *msg, char *popup_name)
+{
+ DBusError err;
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ char *key1, *key2, *key3;
+ char *value1, *value2, *value3;
+ int ret;
+
+ if (!popup_name) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ _I("launch popup (%s)", popup_name);
+
+ dbus_error_init(&err);
+
+ if (!dbus_message_get_args(msg, &err,
+ DBUS_TYPE_STRING, &key1,
+ DBUS_TYPE_STRING, &value1,
+ DBUS_TYPE_STRING, &key2,
+ DBUS_TYPE_STRING, &value2,
+ DBUS_TYPE_STRING, &key3,
+ DBUS_TYPE_STRING, &value3,
+ DBUS_TYPE_INVALID)) {
+ _E("there is no message");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (!key1 || !key2 || !key3 || !value1 || !value2 || !value3) {
+ _E("message is invalid!");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = launch_popup(popup_name, key1, value1, key2, value2, key3, value3);
+ if (ret < 0)
+ _E("FAIL: launch_popup(): %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;
+}
+
--- /dev/null
+system-apps aul::db rx
+system-apps system::homedir rwxat
+system-apps isf rx
+system-apps ail::db rw
+system-apps dbus rwx
+system-apps xorg w
+system-apps device::app_logging w
+system-apps system::vconf rwxat
+system-apps tts-server rwx
+org.tizen.indicator system-apps rwx
+org.tizen.quickpanel system-apps rwx
+dbus system-apps rw
+# default include
+system-apps app.default include