#include <libsyscommon/list.h>
#include "test.h"
-static list *dd_head;
+static GList *dd_head;
void add_test(const struct test_ops *d)
{
if (d->priority == TEST_PRIORITY_HIGH)
- LIST_PREPEND(dd_head, d);
+ SYS_G_LIST_PREPEND(dd_head, d);
else
- LIST_APPEND(dd_head, d);
+ SYS_G_LIST_APPEND(dd_head, d);
}
void remove_test(const struct test_ops *d)
{
- LIST_REMOVE(dd_head, d);
+ SYS_G_LIST_REMOVE(dd_head, d);
}
const struct test_ops *find_test(const char *name)
{
- list *elem;
+ GList *elem;
const struct test_ops *d;
- LIST_FOREACH(dd_head, elem, d) {
+ SYS_G_LIST_FOREACH(dd_head, elem, d) {
if (!strcasecmp(d->name, name))
return d;
}
void test_init(void *data)
{
- list *elem;
+ GList *elem;
const struct test_ops *d;
- _D("Test module count(%d)", LIST_LENGTH(dd_head));
- LIST_FOREACH(dd_head, elem, d) {
+ _D("Test module count(%d)", SYS_G_LIST_LENGTH(dd_head));
+ SYS_G_LIST_FOREACH(dd_head, elem, d) {
_D("'%s' initialize", d->name);
if (d->init)
d->init(data);
void test_exit(void *data)
{
- list *elem;
+ GList *elem;
const struct test_ops *d;
- LIST_FOREACH(dd_head, elem, d) {
+ SYS_G_LIST_FOREACH(dd_head, elem, d) {
_D("'%s' deinitialize", d->name);
if (d->exit)
d->exit(data);
#include "shared/log.h"
#include "haptic-dev.h"
-static list *handle_list;
+static GList *handle_list;
static int unique_number = 0;
/* START: Haptic Module APIs */
static int open_device(int device_index, int *device_handle)
{
- list *elem;
+ GList *elem;
int handle;
bool found = false;
while (found != true) {
++unique_number;
- elem = LIST_FIND(handle_list, (gpointer)(long)unique_number);
+ elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)unique_number);
if (!elem)
found = true;
}
handle = unique_number;
- LIST_APPEND(handle_list, (gpointer)(long)handle);
+ SYS_G_LIST_APPEND(handle_list, (gpointer)(long)handle);
if (device_handle)
*device_handle = handle;
static int close_device(int device_handle)
{
- LIST_REMOVE(handle_list, (gpointer)(long)device_handle);
+ SYS_G_LIST_REMOVE(handle_list, (gpointer)(long)device_handle);
return 0;
}
static int vibrate_monotone(int device_handle, int duration, int frequency, int overdrive, int level, int intensity, int priority)
{
- list *elem;
+ GList *elem;
- elem = LIST_FIND(handle_list, (gpointer)(long)device_handle);
+ elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)device_handle);
if (!elem)
return -EINVAL;
static int stop_device(int device_handle)
{
- list *elem;
+ GList *elem;
- elem = LIST_FIND(handle_list, (gpointer)(long)device_handle);
+ elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)device_handle);
if (!elem)
return -EINVAL;
static peripheral_i2c_h device_handle = NULL;
-static list *handle_list;
+static GList *handle_list;
static int unique_number;
static bool state = false;
static bool find_from_list(int handle)
{
- list *elem;
+ GList *elem;
- elem = LIST_FIND(handle_list, (gpointer)(long)handle);
+ elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)handle);
if (elem)
return true;
{
int n;
bool found = false;
- list *elem;
+ GList *elem;
if (!handle)
return -EINVAL;
/* if it is the first element */
- n = LIST_LENGTH(handle_list);
+ n = SYS_G_LIST_LENGTH(handle_list);
if (n == 0) {
_I("Peripheral Device Open.");
if (device_handle == NULL) {
while (found != true) {
++unique_number;
- elem = LIST_FIND(handle_list, (gpointer)(long)unique_number);
+ elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)unique_number);
if (!elem)
found = true;
}
/* add info to local list */
- LIST_APPEND(handle_list, (gpointer)(long)unique_number);
+ SYS_G_LIST_APPEND(handle_list, (gpointer)(long)unique_number);
*handle = unique_number;
return 0;
_I("Already stopped or failed to stop effect: %d", r);
_D("Handle(%d) is closed and timer deleted.", handle);
- LIST_REMOVE(handle_list, (gpointer)(long)handle);
+ SYS_G_LIST_REMOVE(handle_list, (gpointer)(long)handle);
/* if it is the last element */
- n = LIST_LENGTH(handle_list);
+ n = SYS_G_LIST_LENGTH(handle_list);
if (n == 0) {
_I("Peripheral Device Close.");
if (device_handle != NULL) {
struct vibration_config {
char *pattern; /* pattern name */
char *standard; /* assigned standard pattern name */
- list *data; /* duration_data list */
+ GList *data; /* duration_data list */
unsigned int pattern_duration;
int unlimit;
};
struct haptic_info {
char *sender;
- list *handle_list;
+ GList *handle_list;
guint id_watch;
};
static int g_handle;
/* pattern configuration list */
-static list *vib_conf_list;
+static GList *vib_conf_list;
static guint duration_timer;
/* haptic operation variable */
-static list *haptic_handle_list;
+static GList *haptic_handle_list;
static bool haptic_disabled;
struct haptic_data cur_h_data;
-static int insert_conf_data(list **conf_data, struct duration_data *update)
+static int insert_conf_data(GList **conf_data, struct duration_data *update)
{
struct duration_data *data;
/* insert vibration pattern data */
// to debug :
// _D("%dD%dI%dF%dO%dW", data->duration, data->intensity, data->frequency, data->overdrive, data->wait);
- LIST_APPEND(*conf_data, data);
+ SYS_G_LIST_APPEND(*conf_data, data);
return 0;
}
}
/* [A]xxxDxxxIxxxFxxxOxxxW format */
-static int insert_raw_data_format(list **conf_data, char *value)
+static int insert_raw_data_format(GList **conf_data, char *value)
{
struct duration_data update = {0, };
char *iter;
}
}
close(fd);
- LIST_APPEND(vib_conf_list, conf);
+ SYS_G_LIST_APPEND(vib_conf_list, conf);
return ret;
error_out:
if (len == 0) {
if (insert_raw_data_format(&conf->data, NULL) < 0)
goto error_out;
- LIST_APPEND(vib_conf_list, conf);
+ SYS_G_LIST_APPEND(vib_conf_list, conf);
return 0;
}
_E("Failed to copy standard name.");
goto error_out;
}
- LIST_APPEND(vib_conf_list, conf);
+ SYS_G_LIST_APPEND(vib_conf_list, conf);
return 0;
}
goto error_out;
} else
conf->pattern_duration = duration;
- LIST_APPEND(vib_conf_list, conf);
+ SYS_G_LIST_APPEND(vib_conf_list, conf);
return 0;
const gchar *name,
gpointer user_data)
{
- list *n;
+ GList *n;
struct haptic_info *info = user_data;
int handle;
return NULL;
}
- LIST_APPEND(haptic_handle_list, info);
+ SYS_G_LIST_APPEND(haptic_handle_list, info);
info->id_watch = dbus_handle_watch_name(sender, NULL, haptic_name_owner_changed, info, NULL);
dbus_handle_unwatch_name(info->id_watch);
- LIST_REMOVE(haptic_handle_list, info);
- LIST_FREE_LIST(info->handle_list);
+ SYS_G_LIST_REMOVE(haptic_handle_list, info);
+ SYS_G_LIST_FREE_LIST(info->handle_list);
if (info->sender) {
free(info->sender);
}
static struct haptic_info *get_matched_haptic_info(const char *sender)
{
- list *n;
+ GList *n;
struct haptic_info *info;
int len;
assert(sender);
len = strlen(sender) + 1;
- LIST_FOREACH(haptic_handle_list, n, info) {
+ SYS_G_LIST_FOREACH(haptic_handle_list, n, info) {
if (!strncmp(info->sender, sender, len))
return info;
}
}
}
- LIST_APPEND(info->handle_list, (gpointer)(long)handle);
+ SYS_G_LIST_APPEND(info->handle_list, (gpointer)(long)handle);
ret = handle;
goto exit;
}
- LIST_REMOVE(info->handle_list, (gpointer)(long)handle);
- cnt = LIST_LENGTH(info->handle_list);
+ SYS_G_LIST_REMOVE(info->handle_list, (gpointer)(long)handle);
+ cnt = SYS_G_LIST_LENGTH(info->handle_list);
if (cnt == 0)
remove_haptic_info(info);
static gboolean haptic_duration_play(void *data)
{
- list *head, *n, *next;
+ GList *head, *n, *next;
struct duration_data *node;
int ret = 0;
goto out;
}
} else
- head = (list *)data;
+ head = (GList *)data;
if (cur_h_data.stop) {
_I("Stop currunt vibration.");
goto out;
}
- LIST_FOREACH_SAFE(head, n, next, node) {
+ SYS_G_LIST_FOREACH_SAFE(head, n, next, node) {
_I("Handle(%d) play=%dms and Wait=%dms %s type. (level=%d, intensity=%d, frequency=%d)",
cur_h_data.handle, node->duration, node->wait,
cur_h_data.unlimit ? "Unlimit" : "Once", cur_h_data.level, node->intensity, node->frequency);
static void vibrate_pattern_idler_cb(void *data)
{
struct vibrate_pattern_info *vibrate_info;
- list *elem;
+ GList *elem;
struct vibration_config *conf;
char pattern[PATH_MAX];
int ret;
}
snprintf(pattern, sizeof(pattern), "%s", vibrate_info->pattern);
- LIST_FOREACH(vib_conf_list, elem, conf) {
+ SYS_G_LIST_FOREACH(vib_conf_list, elem, conf) {
if (!conf->pattern)
continue;
if (strcmp(conf->pattern, pattern))
const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
{
- list *n;
- list *elem;
+ GList *n;
+ GList *elem;
struct haptic_info *info;
_D("Sender Handle");
- LIST_FOREACH(haptic_handle_list, n, info) {
+ SYS_G_LIST_FOREACH(haptic_handle_list, n, info) {
for (elem = info->handle_list; elem; elem = elem->next)
_D("%s %d", info->sender, (int)(long)elem->data);
}
int pattern_is_supported(const char *pattern)
{
- list *elem;
+ GList *elem;
struct vibration_config *conf;
int ret;
return -EINVAL;
ret = 0;
- LIST_FOREACH(vib_conf_list, elem, conf) {
+ SYS_G_LIST_FOREACH(vib_conf_list, elem, conf) {
if (!conf->pattern)
continue;
if (!strcmp(conf->pattern, pattern)) {
#define __FEEDBACKD_HAPTIC_H__
#include <stdbool.h>
+#include <glib.h>
#include <device/power.h>
-#include <libsyscommon/list.h>
#include "shared/common.h"
enum priority_level {
};
struct haptic_data {
- list *vibration_data;
+ GList *vibration_data;
unsigned int handle;
int level;
int priority;
};
static int ff_fd;
-static list *ff_list;
-static list *handle_list;
+static GList *ff_list;
+static GList *handle_list;
static char ff_path[PATH_MAX];
static int unique_number;
static int current_effect_id = -1;
struct ff_info *read_from_list(int handle)
{
struct ff_info *temp;
- list *elem;
+ GList *elem;
- LIST_FOREACH(ff_list, elem, temp) {
+ SYS_G_LIST_FOREACH(ff_list, elem, temp) {
if (temp->handle == handle)
return temp;
}
static bool check_valid_handle(struct ff_info *info)
{
struct ff_info *temp;
- list *elem;
+ GList *elem;
- LIST_FOREACH(ff_list, elem, temp) {
+ SYS_G_LIST_FOREACH(ff_list, elem, temp) {
if (temp == info)
break;
}
struct ff_info *info;
int n;
bool found = false;
- list *elem;
+ GList *elem;
if (!device_handle)
return -EINVAL;
/* if it is the first element */
- n = LIST_LENGTH(ff_list);
+ n = SYS_G_LIST_LENGTH(ff_list);
if (n == 0 && !ff_fd) {
_I("First element: open ff driver");
/* open ff driver */
while (found != true) {
++unique_number;
- elem = LIST_FIND(handle_list, (gpointer)(long)unique_number);
+ elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)unique_number);
if (!elem)
found = true;
}
info->handle = unique_number;
/* add info to local list */
- LIST_APPEND(ff_list, info);
- LIST_APPEND(handle_list, (gpointer)(long)info->handle);
+ SYS_G_LIST_APPEND(ff_list, info);
+ SYS_G_LIST_APPEND(handle_list, (gpointer)(long)info->handle);
*device_handle = info->handle;
return 0;
/* stop vibration */
stop_device(device_handle);
- LIST_REMOVE(handle_list, (gpointer)(long)info->handle);
+ SYS_G_LIST_REMOVE(handle_list, (gpointer)(long)info->handle);
safe_free(info->ffinfobuffer);
/* remove info from local list */
- LIST_REMOVE(ff_list, info);
+ SYS_G_LIST_REMOVE(ff_list, info);
safe_free(info);
/* if it is the last element */
- n = LIST_LENGTH(ff_list);
+ n = SYS_G_LIST_LENGTH(ff_list);
if (n == 0 && ff_fd) {
_I("Last element: close ff driver");
/* close ff driver */