Add display feature for headless profile
[platform/core/api/device.git] / src / callback.c
index 5e2dd59..b3cf676 100644 (file)
 #include <vconf.h>
 #include <gio/gio.h>
 #include <libsyscommon/dbus-system.h>
+#include <libsyscommon/list.h>
 
 #include "callback.h"
 #include "battery.h"
 #include "display.h"
+#include "display-internal.h"
 #include "common.h"
-#include "list.h"
 
 #define SIGNAL_FLASH_STATE  "ChangeFlashState"
 
@@ -36,7 +37,7 @@ struct device_cb_info {
        void *data;
 };
 
-static dd_list *device_cb_list[DEVICE_CALLBACK_MAX];
+static GList *device_cb_list[DEVICE_CALLBACK_MAX];
 static int flash_sigid;
 
 //LCOV_EXCL_START Not called Callback
@@ -44,13 +45,13 @@ static void battery_capacity_cb(keynode_t *key, void *data)
 {
        static device_callback_e type = DEVICE_CALLBACK_BATTERY_CAPACITY;
        struct device_cb_info *cb_info;
-       dd_list *elem, *elem_next;
+       GList *elem, *elem_next;
        int val;
 
        val = vconf_keynode_get_int(key);
 
        /* invoke the each callback with value */
-       DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
+       SYS_G_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
                cb_info->cb(type, (void*)val, cb_info->data);
 }
 //LCOV_EXCL_STOP
@@ -60,13 +61,13 @@ static void battery_charging_cb(keynode_t *key, void *data)
 {
        static device_callback_e type = DEVICE_CALLBACK_BATTERY_CHARGING;
        struct device_cb_info *cb_info;
-       dd_list *elem, *elem_next;
+       GList *elem, *elem_next;
        int val;
 
        val = vconf_keynode_get_int(key);
 
        /* invoke the each callback with value */
-       DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
+       SYS_G_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
                cb_info->cb(type, (void*)val, cb_info->data);
 }
 //LCOV_EXCL_STOP
@@ -76,7 +77,7 @@ static void battery_level_cb(keynode_t *key, void *data)
 {
        static device_callback_e type = DEVICE_CALLBACK_BATTERY_LEVEL;
        struct device_cb_info *cb_info;
-       dd_list *elem, *elem_next;
+       GList *elem, *elem_next;
        int val, status;
 
        val = vconf_keynode_get_int(key);
@@ -95,7 +96,7 @@ static void battery_level_cb(keynode_t *key, void *data)
                status = -1;
 
        /* invoke the each callback with value */
-       DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
+       SYS_G_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
                cb_info->cb(type, (void*)status, cb_info->data);
 }
 //LCOV_EXCL_STOP
@@ -105,7 +106,7 @@ static void display_changed_cb(keynode_t *key, void *data)
 {
        static device_callback_e type = DEVICE_CALLBACK_DISPLAY_STATE;
        struct device_cb_info *cb_info;
-       dd_list *elem, *elem_next;
+       GList *elem, *elem_next;
        display_state_e state;
        int val;
 
@@ -123,7 +124,7 @@ static void display_changed_cb(keynode_t *key, void *data)
        }
 
        /* invoke the each callback with value */
-       DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
+       SYS_G_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
                cb_info->cb(type, (void*)state, cb_info->data);
 }
 //LCOV_EXCL_STOP
@@ -139,7 +140,7 @@ static void flash_state_cb(GDBusConnection *conn,
 {
        static int type = DEVICE_CALLBACK_FLASH_BRIGHTNESS;
        struct device_cb_info *cb_info;
-       dd_list *elem, *elem_next;
+       GList *elem, *elem_next;
        int val;
 
        if (strncmp(signal, SIGNAL_FLASH_STATE,
@@ -153,7 +154,7 @@ static void flash_state_cb(GDBusConnection *conn,
        _D("%s - %d", signal, val);
 
        /* invoke the each callback with value */
-       DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
+       SYS_G_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
                cb_info->cb(type, (void*)val, cb_info->data);
 }
 //LCOV_EXCL_STOP
@@ -289,10 +290,10 @@ static int release_request(device_callback_e type)
 int device_add_callback(device_callback_e type, device_changed_cb cb, void *data)
 {
        struct device_cb_info *cb_info;
-       dd_list *elem, *elem_next;
+       GList *elem, *elem_next;
        int ret, n;
 
-       if (!is_display_supported() && type == DEVICE_CALLBACK_DISPLAY_STATE)
+       if (!is_feature_display_supported() && type == DEVICE_CALLBACK_DISPLAY_STATE)
                return DEVICE_ERROR_NOT_SUPPORTED;
 
        if (type < 0 || type >= DEVICE_CALLBACK_MAX)
@@ -302,7 +303,7 @@ int device_add_callback(device_callback_e type, device_changed_cb cb, void *data
                return DEVICE_ERROR_INVALID_PARAMETER;
 
        /* check if it is the first request */
-       n = DD_LIST_LENGTH(device_cb_list[type]);
+       n = SYS_G_LIST_LENGTH(device_cb_list[type]);
        if (n == 0) {
                ret = register_request(type);
                if (ret < 0)
@@ -310,7 +311,7 @@ int device_add_callback(device_callback_e type, device_changed_cb cb, void *data
        }
 
        /* check for the same request */
-       DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info) {
+       SYS_G_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info) {
                if (cb_info->cb == cb)
                        return DEVICE_ERROR_ALREADY_IN_PROGRESS;
        }
@@ -323,7 +324,7 @@ int device_add_callback(device_callback_e type, device_changed_cb cb, void *data
        cb_info->cb = cb;
        cb_info->data = data;
 
-       DD_LIST_APPEND(device_cb_list[type], cb_info);
+       SYS_G_LIST_APPEND(device_cb_list[type], cb_info);
 
        return DEVICE_ERROR_NONE;
 }
@@ -331,10 +332,10 @@ int device_add_callback(device_callback_e type, device_changed_cb cb, void *data
 int device_remove_callback(device_callback_e type, device_changed_cb cb)
 {
        struct device_cb_info *cb_info;
-       dd_list *elem, *elem_next;
+       GList *elem, *elem_next;
        int ret, n;
 
-       if (!is_display_supported() && type == DEVICE_CALLBACK_DISPLAY_STATE)
+       if (!is_feature_display_supported() && type == DEVICE_CALLBACK_DISPLAY_STATE)
                return DEVICE_ERROR_NOT_SUPPORTED;
 
        if (type < 0 || type >= DEVICE_CALLBACK_MAX)
@@ -344,7 +345,7 @@ int device_remove_callback(device_callback_e type, device_changed_cb cb)
                return DEVICE_ERROR_INVALID_PARAMETER;
 
        /* search for the same element with callback */
-       DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info) {
+       SYS_G_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info) {
                if (cb_info->cb == cb)
                        break;
        }
@@ -353,11 +354,11 @@ int device_remove_callback(device_callback_e type, device_changed_cb cb)
                return DEVICE_ERROR_INVALID_PARAMETER;
 
        /* remove device callback from list (local) */
-       DD_LIST_REMOVE(device_cb_list[type], cb_info);
+       SYS_G_LIST_REMOVE(device_cb_list[type], cb_info);
        free(cb_info);
 
        /* check if this callback is last element */
-       n = DD_LIST_LENGTH(device_cb_list[type]);
+       n = SYS_G_LIST_LENGTH(device_cb_list[type]);
        if (n == 0) {
                ret = release_request(type);
                if (ret < 0)