#include <errno.h>
#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 "dbus.h"
-#include "list.h"
#define SIGNAL_FLASH_STATE "ChangeFlashState"
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
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;
+ GList *elem, *elem_next;
int val;
val = vconf_keynode_get_int(key);
/* invoke the each callback with value */
- DD_LIST_FOREACH(device_cb_list[type], elem, 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
+//LCOV_EXCL_START Not called Callback
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;
+ GList *elem, *elem_next;
int val;
val = vconf_keynode_get_int(key);
/* invoke the each callback with value */
- DD_LIST_FOREACH(device_cb_list[type], elem, 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
+//LCOV_EXCL_START Not called Callback
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;
+ GList *elem, *elem_next;
int val, status;
val = vconf_keynode_get_int(key);
status = -1;
/* invoke the each callback with value */
- DD_LIST_FOREACH(device_cb_list[type], elem, 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
+//LCOV_EXCL_START Not called Callback
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;
+ GList *elem, *elem_next;
display_state_e state;
int val;
}
/* invoke the each callback with value */
- DD_LIST_FOREACH(device_cb_list[type], elem, 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
+//LCOV_EXCL_START Not called Callback
static void flash_state_cb(GDBusConnection *conn,
const gchar *sender,
const gchar *object,
{
static int type = DEVICE_CALLBACK_FLASH_BRIGHTNESS;
struct device_cb_info *cb_info;
- dd_list *elem;
+ GList *elem, *elem_next;
int val;
if (strncmp(signal, SIGNAL_FLASH_STATE,
_D("%s - %d", signal, val);
/* invoke the each callback with value */
- DD_LIST_FOREACH(device_cb_list[type], elem, 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
static int register_signal(const char *bus_name,
const char *object_path,
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn) {
+//LCOV_EXCL_START System Error
_E("fail to get dbus connection : %s", err->message);
g_clear_error(&err);
return -EPERM;
+//LCOV_EXCL_STOP
}
/* subscribe signal */
NULL,
NULL);
if (id == 0) {
+//LCOV_EXCL_START System Error
_E("fail to connect %s signal", signal);
return -EPERM;
+//LCOV_EXCL_STOP
}
if (sig_id)
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn) {
+//LCOV_EXCL_START System Error
_E("fail to get dbus connection : %s", err->message);
g_clear_error(&err);
return -EPERM;
+//LCOV_EXCL_STOP
}
/* unsubscribe signal */
int device_add_callback(device_callback_e type, device_changed_cb cb, void *data)
{
struct device_cb_info *cb_info;
- dd_list *elem;
+ GList *elem, *elem_next;
int ret, n;
+ if (!is_feature_display_supported() && type == DEVICE_CALLBACK_DISPLAY_STATE)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
if (type < 0 || type >= DEVICE_CALLBACK_MAX)
return DEVICE_ERROR_INVALID_PARAMETER;
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)
}
/* check for the same request */
- DD_LIST_FOREACH(device_cb_list[type], elem, 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;
}
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;
}
int device_remove_callback(device_callback_e type, device_changed_cb cb)
{
struct device_cb_info *cb_info;
- dd_list *elem;
+ GList *elem, *elem_next;
int ret, n;
+ if (!is_feature_display_supported() && type == DEVICE_CALLBACK_DISPLAY_STATE)
+ return DEVICE_ERROR_NOT_SUPPORTED;
+
if (type < 0 || type >= DEVICE_CALLBACK_MAX)
return DEVICE_ERROR_INVALID_PARAMETER;
return DEVICE_ERROR_INVALID_PARAMETER;
/* search for the same element with callback */
- DD_LIST_FOREACH(device_cb_list[type], elem, cb_info) {
+ SYS_G_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info) {
if (cb_info->cb == cb)
break;
}
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)
- return DEVICE_ERROR_OPERATION_FAILED;
+ return DEVICE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE System Error
}
return DEVICE_ERROR_NONE;