delete redundant variable and add broadcast dbus signal API 08/14708/1
authorjy910.yun <jy910.yun@samsung.com>
Sun, 30 Jun 2013 10:23:42 +0000 (19:23 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Fri, 10 Jan 2014 08:54:48 +0000 (09:54 +0100)
Change-Id: Ic0674a7f9c8098d41d362c9eccfbbc67e9f9b758
Signed-off-by: jy910.yun <jy910.yun@samsung.com>
display/core.c
display/display-dbus.c
src/core/device-change-handler.c
src/core/edbus-handler.c
src/core/edbus-handler.h
src/core/sig-handler.c
src/deviced/dd-deviced.h
src/mmc/mmc-handler.c
src/power/power-handler.c
src/shared/deviced-priv.h
src/shared/display.c

index 9b3afeb..9d67012 100644 (file)
@@ -115,12 +115,13 @@ static int trans_table[S_END][EVENT_END] = {
 #define SHIFT_CHANGE_STATE     7
 #define CHANGE_STATE_BIT       0xF00   /* 1111 0000 0000 */
 #define LOCK_SCREEN_TIMEOUT    10
-#define SHIFT_HOLD_KEY_BLOCK   16
+#define SHIFT_LOCK_FLAG        16
+#define HOLD_KEY_BLOCK_BIT     0x1
 
 #define DEFAULT_NORMAL_TIMEOUT 30
 #define DEFAULT_DIM_TIMEOUT            5
 #define DEFAULT_OFF_TIMEOUT            5
-#define GET_HOLDKEY_BLOCK_STATE(x) ((x >> SHIFT_HOLD_KEY_BLOCK) & 0x1)
+#define GET_HOLDKEY_BLOCK_STATE(x) ((x >> SHIFT_LOCK_FLAG) & HOLD_KEY_BLOCK_BIT)
 #define LOCK_SCREEN_WATING_TIME                50000   /* 50 ms */
 #define LOCK_SCREEN_WATING_MAX_COUNT   14      /* 50 * 14 : 700 ms at worst */
 #define MASK32                         0xffffffff
index bbc4189..ec0ec45 100644 (file)
 
 #include <error.h>
 #include <Ecore.h>
+#include <device-node.h>
 
 #include "util.h"
 #include "core.h"
-#include "device-node.h"
 #include "core/common.h"
 #include "core/devices.h"
 
-#define DISP_INDEX_BIT 4
-#define COMBINE_DISP_CMD(cmd, prop, index) (cmd = (prop | (index << DISP_INDEX_BIT)))
+#define DISP_INDEX_BIT 16
+#define DISP_CMD(prop, index) (prop | (index << DISP_INDEX_BIT))
 
 static DBusMessage *e_dbus_start_cb(E_DBus_Object *obj, DBusMessage *msg)
 {
@@ -245,7 +245,7 @@ static DBusMessage *e_dbus_getbrightness_cb(E_DBus_Object *obj, DBusMessage *msg
        int cmd;
        int brightness = -1;
 
-       COMBINE_DISP_CMD(cmd, PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
+       cmd = DISP_CMD(PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
        ret = device_get_property(DEVICE_TYPE_DISPLAY, cmd, &brightness);
 
        LOGINFO("get brightness %d, %d", brightness, ret);
@@ -268,7 +268,7 @@ static DBusMessage *e_dbus_setbrightness_cb(E_DBus_Object *obj, DBusMessage *msg
        dbus_message_iter_init(msg, &iter);
        dbus_message_iter_get_basic(&iter, &brightness);
 
-       COMBINE_DISP_CMD(cmd, PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
+       cmd = DISP_CMD(PROP_DISPLAY_BRIGHTNESS, DEFAULT_DISPLAY);
        ret = device_set_property(DEVICE_TYPE_DISPLAY, cmd, brightness);
 
        LOGINFO("set brightness %d, %d", brightness, ret);
@@ -292,7 +292,7 @@ static struct edbus_method {
        { "unlockstate",     "ss",   "i", e_dbus_unlockstate_cb },
        { "changestate",      "s",   "i", e_dbus_changestate_cb },
        { "getbrightness",   NULL,   "i", e_dbus_getbrightness_cb },
-       { "setbrightness",    "i",   "i", e_dbus_setbrightness_cb }
+       { "setbrightness",    "i",   "i", e_dbus_setbrightness_cb },
        /* Add methods here */
 };
 
index 7cc0fb7..d491515 100644 (file)
@@ -721,6 +721,7 @@ static void device_change_init(void *data)
                _E("fail uevent control init");
                return;
        }
+
        /* for simple noti change cb */
        ss_noti_add("device_usb_chgdet", (void *)usb_chgdet_cb, data);
        ss_noti_add("device_ta_chgdet", (void *)ta_chgdet_cb, data);
index 895343c..8d1c140 100644 (file)
@@ -163,27 +163,27 @@ static void unregister_edbus_signal_handle(void)
        }
 }
 
-int register_edbus_signal_handler(char *signal_name, E_DBus_Signal_Cb cb)
+int register_edbus_signal_handler(const char *path, const char *interface,
+               const char *name, E_DBus_Signal_Cb cb)
 {
        Eina_List *tmp;
        struct edbus_list *entry;
        E_DBus_Signal_Handler *handler;
 
        EINA_LIST_FOREACH(edbus_handler_list, tmp, entry) {
-               if (entry != NULL && strncmp(entry->signal_name, signal_name, strlen(signal_name)) == 0)
+               if (entry != NULL && strncmp(entry->signal_name, name, strlen(name)) == 0)
                        return -1;
        }
 
-       handler = e_dbus_signal_handler_add(edbus_conn, NULL, OBJECT_PATH,
-                               INTERFACE_NAME, signal_name, cb, NULL);
+       handler = e_dbus_signal_handler_add(edbus_conn, NULL, path,
+                               interface, name, cb, NULL);
 
        if (!handler) {
                _D("fail to add edbus handler");
                return -1;
        }
 
-       _D("add edbus service: %s", signal_name);
-       PRT_TRACE_ERR("add edbus service: %s", signal_name);
+       _D("add edbus service: %s", name);
 
        entry = malloc(sizeof(struct edbus_list));
 
@@ -192,7 +192,7 @@ int register_edbus_signal_handler(char *signal_name, E_DBus_Signal_Cb cb)
                return -1;
        }
 
-       entry->signal_name = strndup(signal_name, strlen(signal_name));
+       entry->signal_name = strndup(name, strlen(name));
 
        if (!entry->signal_name) {
                _D("Malloc failed");
@@ -211,6 +211,28 @@ int register_edbus_signal_handler(char *signal_name, E_DBus_Signal_Cb cb)
        return 0;
 }
 
+int broadcast_edbus_signal(const char *path, const char *interface,
+               const char *name, int type, void *value)
+{
+       DBusMessage *signal;
+       DBusMessageIter iter;
+       DBusMessageIter val;
+       char sig[2] = {type, '\0'};
+
+       signal = dbus_message_new_signal(path, interface, name);
+       if (!signal) {
+               _D("fail to allocate new %s.%s signal", interface, name);
+               return -1;
+       }
+
+       dbus_message_append_args(signal, type, value, DBUS_TYPE_INVALID);
+
+       e_dbus_message_send(edbus_conn, signal, NULL, -1, NULL);
+
+       dbus_message_unref(signal);
+       return 0;
+}
+
 static void edbus_init(void *data)
 {
        int retry = EDBUS_INIT_RETRY_COUNT;
index 568c250..8b8f97e 100644 (file)
 #define DEVICED_PATH_DISPLAY           OBJECT_PATH"/Display"
 #define DEVICED_INTERFACE_DISPLAY      INTERFACE_NAME".display"
 
-int register_edbus_signal_handler(char *signal_name, E_DBus_Signal_Cb cb);
+int register_edbus_signal_handler(const char *path, const char *interface,
+               const char *name, E_DBus_Signal_Cb cb);
 E_DBus_Interface *get_edbus_interface(const char *path);
 pid_t get_edbus_sender_pid(DBusMessage *msg);
+int broadcast_edbus_signal(const char *path, const char *interface,
+               const char *name, int type, void *value);
 
 #endif /* __SS_EDBUS_HANDLE_H__ */
index 563cc46..c5e4bfb 100644 (file)
@@ -36,8 +36,6 @@
        write(1, buf, strlen(buf));\
 } while (0);
 
-#define SIGNAL_NAME_POWEROFF_POPUP     "poweroffpopup"
-
 static struct sigaction sig_child_old_act;
 static struct sigaction sig_pipe_old_act;
 
@@ -77,8 +75,6 @@ static void signal_init(void *data)
        sig_act.sa_flags = SA_SIGINFO;
        sigemptyset(&sig_act.sa_mask);
        sigaction(SIGPIPE, &sig_act, &sig_pipe_old_act);
-       register_edbus_signal_handler(SIGNAL_NAME_LCD_CONTROL,
-                   (void *)lcd_control_edbus_signal_handler);
 }
 
 const struct device_ops signal_device_ops = {
index 143ffc2..aeb80c1 100755 (executable)
@@ -142,7 +142,7 @@ int deviced_conf_set_permanent(void);
  * @brief This API is used to set a process which has pid as a permanent process.\n
  *              If the permanent process is dead, system server will relaunch the process automatically.
  * @return 0 on success, -1 if failed.
- * @see sysconf_set_permanent()
+ * @see deviced_set_permanent()
  * @par Example
  * @code
  *      ...
index 1017753..2be0a99 100644 (file)
@@ -120,18 +120,18 @@ static const char *vfat_arg[] = {
 };
 
 static const char *ext4_arg[] = {
-    "/sbin/mkfs.ext4",
-    NULL, NULL,
+       "/sbin/mkfs.ext4",
+       NULL, NULL,
 };
 
 static const char *vfat_check_arg[] = {
-    "/sbin/fsck.vfat",
-    "-a", NULL, NULL,
+       "/sbin/fsck.vfat",
+       "-a", NULL, NULL,
 };
 
 static const char *ext4_check_arg[] = {
-    "/sbin/fsck.ext4",
-    "-f", "-y", NULL, NULL,
+       "/sbin/fsck.ext4",
+       "-f", "-y", NULL, NULL,
 };
 
 
index 9d7364a..bd9853a 100644 (file)
@@ -61,7 +61,6 @@
 
 #define POWEROFF_NOTI_NAME             "power_off_start"
 #define POWEROFF_DURATION              2
-#define POWEROFF_ANIMATION_PATH                "/usr/bin/boot-animation"
 #define MAX_RETRY                      2
 
 static struct timeval tv_start_poweroff;
@@ -546,8 +545,12 @@ static void power_init(void *data)
                PRT_TRACE_ERR("Vconf notify key chaneged failed: KEY(%s)", VCONFKEY_SYSMAN_POWER_OFF_STATUS);
        }
 
-       register_edbus_signal_handler(SIGNAL_NAME_POWEROFF_POPUP,
+       register_edbus_signal_handler(OBJECT_PATH, INTERFACE_NAME,
+                       SIGNAL_NAME_POWEROFF_POPUP,
                    (void *)poweroff_popup_edbus_signal_handler);
+       register_edbus_signal_handler(OBJECT_PATH, INTERFACE_NAME,
+                       SIGNAL_NAME_LCD_CONTROL,
+                   (void *)lcd_control_edbus_signal_handler);
 }
 
 const struct device_ops power_device_ops = {
index 85557ec..451b073 100644 (file)
@@ -28,7 +28,7 @@ extern "C" {
 #endif
 
 #define SYSTEM_NOTI_MAXARG 16
-#define SYSTEM_NOTI_MAXSTR 100
+#define SYSTEM_NOTI_MAXSTR 255
 #define BUFF_MAX 255
 
 struct sysnoti {
index 7a02a87..35c840e 100644 (file)
 #define SHIFT_UNLOCK                   4
 #define SHIFT_UNLOCK_PARAMETER         12
 #define SHIFT_CHANGE_STATE             8
-#define SHIFT_HOLD_KEY_BLOCK           16
 #define TIMEOUT_RESET_BIT              0x80
 
-struct pwr_msg {
+struct disp_lock_msg {
        pid_t pid;
        unsigned int cond;
        unsigned int timeout;
+       unsigned int timeout2;
 };
 
 API int display_get_count(void)
@@ -227,16 +227,17 @@ API int display_set_acl_status(int val)
        return 0;
 }
 
-static int send_msg(unsigned int s_bits, unsigned int timeout)
+static int send_msg(unsigned int s_bits, unsigned int timeout, unsigned int timeout2)
 {
        int rc = 0;
        int sock;
-       struct pwr_msg p;
+       struct disp_lock_msg p;
        struct sockaddr_un remote;
 
        p.pid = getpid();
        p.cond = s_bits;
        p.timeout = timeout;
+       p.timeout2 = timeout2;
 
        sock = socket(AF_UNIX, SOCK_DGRAM, 0);
        if (sock == -1) {
@@ -280,7 +281,7 @@ API int display_change_state(unsigned int s_bits)
        default:
                return -1;
        }
-       return send_msg(s_bits << SHIFT_CHANGE_STATE, 0);
+       return send_msg(s_bits << SHIFT_CHANGE_STATE, 0, 0);
 }
 
 API int display_lock_state(unsigned int s_bits, unsigned int flag,
@@ -297,10 +298,8 @@ API int display_lock_state(unsigned int s_bits, unsigned int flag,
        if (flag & GOTO_STATE_NOW)
                /* if the flag is true, go to the locking state directly */
                s_bits = s_bits | (s_bits << SHIFT_CHANGE_STATE);
-       if (flag & HOLD_KEY_BLOCK)
-               s_bits = s_bits | (1 << SHIFT_HOLD_KEY_BLOCK);
 
-       return send_msg(s_bits, timeout);
+       return send_msg(s_bits, timeout, 0);
 }
 
 API int display_unlock_state(unsigned int s_bits, unsigned int flag)
@@ -316,5 +315,5 @@ API int display_unlock_state(unsigned int s_bits, unsigned int flag)
 
        s_bits = (s_bits << SHIFT_UNLOCK);
        s_bits = (s_bits | (flag << SHIFT_UNLOCK_PARAMETER));
-       return send_msg(s_bits, 0);
+       return send_msg(s_bits, 0, 0);
 }