Apply consistent log messages.
[platform/core/system/system-popup.git] / src / power / power.c
old mode 100755 (executable)
new mode 100644 (file)
index 8d4f9bb..20e3231
 #define APP_COMM      "_APP_COMM_"
 #define REQ_ID        "_REQUEST_ID_"
 
-#define DBUS_POWER_PATH "/Org/Tizen/System/DeviceD/Power"
-#define DBUS_POWER_IFACE "org.tizen.system.deviced.power"
-#define METHOD_POWER_LOCK_EXPIRED "PowerLockExpired"
+#define DBUS_POWER_BUS   "org.tizen.system.deviced"
+#define DBUS_POWER_PATH  "/Org/Tizen/System/DeviceD/Display"
+#define DBUS_POWER_IFACE "org.tizen.system.deviced.display"
+#define METHOD_LOCK_TIMEOUT_INPUT "LockTimeoutInput"
 
 static const struct popup_ops power_lock_expired_ops;
-static bool signal_broadcasted;
+static bool result_sended;
 static char *request_id;
 
 enum button_selected {
        ALLOW_APP,
+       RESTRICT_APP,
        CLOSE_APP,
 };
 
-static void send_result_dbus_signal(int result)
+static void send_result(int result)
 {
        int ret;
        char buf[8];
        char *param[2];
 
-       if (signal_broadcasted)
+       if (result_sended)
                return;
 
-       signal_broadcasted = true;
+       result_sended = true;
 
        param[0] = request_id;
        snprintf(buf, sizeof(buf), "%d", result);
        param[1] = buf;
-       ret = broadcast_dbus_signal(DBUS_POWER_PATH,
+       ret = popup_dbus_method_sync(
+                       DBUS_POWER_BUS,
+                       DBUS_POWER_PATH,
                        DBUS_POWER_IFACE,
-                       METHOD_POWER_LOCK_EXPIRED,
+                       METHOD_LOCK_TIMEOUT_INPUT,
                        "si", param);
        if (ret < 0)
-               _E("FAIL: broadcast_dbus_signal(%d)", ret);
+               _E("Failed to deliver the result: %d", ret);
 }
 
 static int power_lock_expired_get_content(const struct popup_ops *ops, char *content, unsigned int len)
@@ -71,19 +75,19 @@ static int power_lock_expired_get_content(const struct popup_ops *ops, char *con
 
        ret = get_object_by_ops(ops, &obj);
        if (ret < 0) {
-               _E("Failed to get object (%d)", ret);
+               _E("Failed to get object: %d", ret);
                return -ENOENT;
        }
 
        pid_str = (char *)bundle_get_val(obj->b, APP_PID);
        if (!pid_str) {
-               _E("Failed to get app pid");
+               _E("Failed to get app pid.");
                return -ENOENT;
        }
 
        request_id = (char *)bundle_get_val(obj->b, REQ_ID);
        if (!request_id) {
-               _E("Failed to get request id");
+               _E("Failed to get request id.");
                return -ENOENT;
        }
 
@@ -92,9 +96,9 @@ static int power_lock_expired_get_content(const struct popup_ops *ops, char *con
        if (ret != APP_MANAGER_ERROR_NONE) {
                name = (char *)bundle_get_val(obj->b, APP_COMM);
                if (!name) {
-                       _E("Failed to get app command");
-                       return -ENOENT;
-               }
+                       _E("Failed to get app command.");
+               return -ENOENT;
+       }
        }
 
        text = _("\"%s\" is using too much battery power. Close \"%s\" ?");
@@ -107,34 +111,35 @@ static int power_lock_expired_get_content(const struct popup_ops *ops, char *con
 
 static void power_lock_expired_allow_app(const struct popup_ops *ops)
 {
-       _I("Allow is selected");
+       _I("Allow is selected.");
 
        unload_simple_popup(ops);
 
-       send_result_dbus_signal(ALLOW_APP);
+       send_result(ALLOW_APP);
 
        terminate_if_no_popup();
 }
 
 static void power_lock_expired_close_app(const struct popup_ops *ops)
 {
-       _I("Close is selected");
+       _I("Close is selected.");
 
        unload_simple_popup(ops);
 
-       send_result_dbus_signal(CLOSE_APP);
+       send_result(CLOSE_APP);
 
        terminate_if_no_popup();
 }
 
 static void power_lock_expired_terminate(const struct popup_ops *ops)
 {
-       send_result_dbus_signal(CLOSE_APP);
-       signal_broadcasted = false;
+       send_result(CLOSE_APP);
+       result_sended = false;
 }
 
 static const struct popup_ops power_lock_expired_ops = {
        .name                   = "power_lock_expired",
+       .pattern                = FEEDBACK_PATTERN_LOWBATT,
        .show                   = load_simple_popup,
        .get_content    = power_lock_expired_get_content,
        .left_text              = "IDS_COM_SK_CANCEL",