SET(SRCS
src/core/main.c
src/shared/common.c
- src/shared/config-parser.c
src/shared/device-idler.c
src/shared/log.c
src/driver/haptic.c
dlog
capi-system-info
glib-2.0
+ libsyscommon
)
INCLUDE(FindPkgConfig)
*/
#include <strings.h>
+#include <libsyscommon/list.h>
#include "test.h"
-static dd_list *dd_head;
+static list *dd_head;
void add_test(const struct test_ops *d)
{
if (d->priority == TEST_PRIORITY_HIGH)
- DD_LIST_PREPEND(dd_head, d);
+ LIST_PREPEND(dd_head, d);
else
- DD_LIST_APPEND(dd_head, d);
+ LIST_APPEND(dd_head, d);
}
void remove_test(const struct test_ops *d)
{
- DD_LIST_REMOVE(dd_head, d);
+ LIST_REMOVE(dd_head, d);
}
const struct test_ops *find_test(const char *name)
{
- dd_list *elem;
+ list *elem;
const struct test_ops *d;
- DD_LIST_FOREACH(dd_head, elem, d) {
+ LIST_FOREACH(dd_head, elem, d) {
if (!strcasecmp(d->name, name))
return d;
}
void test_init(void *data)
{
- dd_list *elem;
+ list *elem;
const struct test_ops *d;
- _D("Test module count(%d)", DD_LIST_LENGTH(dd_head));
- DD_LIST_FOREACH(dd_head, elem, d) {
+ _D("Test module count(%d)", LIST_LENGTH(dd_head));
+ LIST_FOREACH(dd_head, elem, d) {
_D("'%s' initialize", d->name);
if (d->init)
d->init(data);
void test_exit(void *data)
{
- dd_list *elem;
+ list *elem;
const struct test_ops *d;
- DD_LIST_FOREACH(dd_head, elem, d) {
+ LIST_FOREACH(dd_head, elem, d) {
_D("'%s' deinitialize", d->name);
if (d->exit)
d->exit(data);
#include <errno.h>
#include <libsyscommon/dbus-system.h>
-#include "shared/list.h"
#include "shared/log.h"
#include "shared/common.h"
#include <stdio.h>
#include <errno.h>
+#include <libsyscommon/list.h>
#include "shared/common.h"
#include "shared/log.h"
-#include "shared/list.h"
#include "haptic-dev.h"
-static dd_list *handle_list;
+static list *handle_list;
static int unique_number = 0;
/* START: Haptic Module APIs */
static int open_device(int device_index, int *device_handle)
{
- dd_list *elem;
+ list *elem;
int handle;
bool found = false;
while (found != true) {
++unique_number;
- elem = DD_LIST_FIND(handle_list, (gpointer)(long)unique_number);
+ elem = LIST_FIND(handle_list, (gpointer)(long)unique_number);
if (!elem)
found = true;
}
handle = unique_number;
- DD_LIST_APPEND(handle_list, (gpointer)(long)handle);
+ LIST_APPEND(handle_list, (gpointer)(long)handle);
if (device_handle)
*device_handle = handle;
static int close_device(int device_handle)
{
- DD_LIST_REMOVE(handle_list, (gpointer)(long)device_handle);
+ 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)
{
- dd_list *elem;
+ list *elem;
- elem = DD_LIST_FIND(handle_list, (gpointer)(long)device_handle);
+ elem = LIST_FIND(handle_list, (gpointer)(long)device_handle);
if (!elem)
return -EINVAL;
static int stop_device(int device_handle)
{
- dd_list *elem;
+ list *elem;
- elem = DD_LIST_FIND(handle_list, (gpointer)(long)device_handle);
+ elem = LIST_FIND(handle_list, (gpointer)(long)device_handle);
if (!elem)
return -EINVAL;
#include <stdlib.h>
#include <glib.h>
+#include <libsyscommon/list.h>
#include "shared/common.h"
#include "shared/log.h"
-#include "shared/list.h"
#include "haptic-interface.h"
#include "peripheral_io.h"
static peripheral_i2c_h device_handle = NULL;
-static dd_list *handle_list;
+static list *handle_list;
static int unique_number;
static bool state = false;
static bool find_from_list(int handle)
{
- dd_list *elem;
+ list *elem;
- elem = DD_LIST_FIND(handle_list, (gpointer)(long)handle);
+ elem = LIST_FIND(handle_list, (gpointer)(long)handle);
if (elem)
return true;
{
int n;
bool found = false;
- dd_list *elem;
+ list *elem;
if (!handle)
return -EINVAL;
/* if it is the first element */
- n = DD_LIST_LENGTH(handle_list);
+ n = LIST_LENGTH(handle_list);
if (n == 0) {
_I("Peripheral Device Open.");
if (device_handle == NULL) {
while (found != true) {
++unique_number;
- elem = DD_LIST_FIND(handle_list, (gpointer)(long)unique_number);
+ elem = LIST_FIND(handle_list, (gpointer)(long)unique_number);
if (!elem)
found = true;
}
/* add info to local list */
- DD_LIST_APPEND(handle_list, (gpointer)(long)unique_number);
+ 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);
- DD_LIST_REMOVE(handle_list, (gpointer)(long)handle);
+ LIST_REMOVE(handle_list, (gpointer)(long)handle);
/* if it is the last element */
- n = DD_LIST_LENGTH(handle_list);
+ n = LIST_LENGTH(handle_list);
if (n == 0) {
_I("Peripheral Device Close.");
if (device_handle != NULL) {
#define __FEEDBACKD_HAPTIC_DEV_H__
#include <stdbool.h>
-#include "shared/list.h"
#include "haptic-interface.h"
int haptic_load_device(void);
#include <time.h>
#include <string.h>
#include <libsyscommon/dbus-system.h>
+#include <libsyscommon/list.h>
+#include <libsyscommon/ini-parser.h>
#include "shared/log.h"
-#include "shared/list.h"
#include "shared/common.h"
#include "shared/device-idler.h"
-#include "shared/config-parser.h"
#include "haptic.h"
#include "haptic-dev.h"
struct vibration_config {
char *pattern; /* pattern name */
char *standard; /* assigned standard pattern name */
- dd_list *data; /* duration_data list */
+ list *data; /* duration_data list */
unsigned int pattern_duration;
int unlimit;
};
struct haptic_info {
char *sender;
- dd_list *handle_list;
+ list *handle_list;
guint id_watch;
};
static int g_handle;
/* pattern configuration list */
-static dd_list *vib_conf_list;
+static list *vib_conf_list;
static guint duration_timer;
/* haptic operation variable */
-static dd_list *haptic_handle_list;
+static list *haptic_handle_list;
static bool haptic_disabled;
struct haptic_data cur_h_data;
-static int insert_conf_data(dd_list **conf_data, struct duration_data *update)
+static int insert_conf_data(list **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);
- DD_LIST_APPEND(*conf_data, data);
+ LIST_APPEND(*conf_data, data);
return 0;
}
}
/* [A]xxxDxxxIxxxFxxxOxxxW format */
-static int insert_raw_data_format(dd_list **conf_data, char *value)
+static int insert_raw_data_format(list **conf_data, char *value)
{
struct duration_data update = {0, };
char *iter;
}
}
close(fd);
- DD_LIST_APPEND(vib_conf_list, conf);
+ 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;
- DD_LIST_APPEND(vib_conf_list, conf);
+ LIST_APPEND(vib_conf_list, conf);
return 0;
}
_E("Failed to copy standard name.");
goto error_out;
}
- DD_LIST_APPEND(vib_conf_list, conf);
+ LIST_APPEND(vib_conf_list, conf);
return 0;
}
goto error_out;
} else
conf->pattern_duration = duration;
- DD_LIST_APPEND(vib_conf_list, conf);
+ LIST_APPEND(vib_conf_list, conf);
return 0;
const gchar *name,
gpointer user_data)
{
- dd_list *n;
+ list *n;
struct haptic_info *info = user_data;
int handle;
return NULL;
}
- DD_LIST_APPEND(haptic_handle_list, info);
+ 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);
- DD_LIST_REMOVE(haptic_handle_list, info);
- DD_LIST_FREE_LIST(info->handle_list);
+ LIST_REMOVE(haptic_handle_list, info);
+ LIST_FREE_LIST(info->handle_list);
if (info->sender) {
free(info->sender);
}
static struct haptic_info *get_matched_haptic_info(const char *sender)
{
- dd_list *n;
+ list *n;
struct haptic_info *info;
int len;
assert(sender);
len = strlen(sender) + 1;
- DD_LIST_FOREACH(haptic_handle_list, n, info) {
+ LIST_FOREACH(haptic_handle_list, n, info) {
if (!strncmp(info->sender, sender, len))
return info;
}
}
}
- DD_LIST_APPEND(info->handle_list, (gpointer)(long)handle);
+ LIST_APPEND(info->handle_list, (gpointer)(long)handle);
ret = handle;
goto exit;
}
- DD_LIST_REMOVE(info->handle_list, (gpointer)(long)handle);
- cnt = DD_LIST_LENGTH(info->handle_list);
+ LIST_REMOVE(info->handle_list, (gpointer)(long)handle);
+ cnt = LIST_LENGTH(info->handle_list);
if (cnt == 0)
remove_haptic_info(info);
static gboolean haptic_duration_play(void *data)
{
- dd_list *head, *n, *next;
+ list *head, *n, *next;
struct duration_data *node;
int ret = 0;
goto out;
}
} else
- head = (dd_list *)data;
+ head = (list *)data;
if (cur_h_data.stop) {
_I("Stop currunt vibration.");
goto out;
}
- DD_LIST_FOREACH_SAFE(head, n, next, node) {
+ 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;
- dd_list *elem;
+ list *elem;
struct vibration_config *conf;
char pattern[PATH_MAX];
int ret;
}
snprintf(pattern, sizeof(pattern), "%s", vibrate_info->pattern);
- DD_LIST_FOREACH(vib_conf_list, elem, conf) {
+ 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)
{
- dd_list *n;
- dd_list *elem;
+ list *n;
+ list *elem;
struct haptic_info *info;
_D("Sender Handle");
- DD_LIST_FOREACH(haptic_handle_list, n, info) {
+ 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)
{
- dd_list *elem;
+ list *elem;
struct vibration_config *conf;
int ret;
return -EINVAL;
ret = 0;
- DD_LIST_FOREACH(vib_conf_list, elem, conf) {
+ LIST_FOREACH(vib_conf_list, elem, conf) {
if (!conf->pattern)
continue;
if (!strcmp(conf->pattern, pattern)) {
#ifndef __FEEDBACKD_HAPTIC_H__
#define __FEEDBACKD_HAPTIC_H__
-#include <device/power.h>
#include <stdbool.h>
+#include <device/power.h>
+#include <libsyscommon/list.h>
#include "shared/common.h"
-#include "shared/list.h"
enum priority_level {
PRIORITY_MIN = 0,
};
struct haptic_data {
- dd_list *vibration_data;
+ list *vibration_data;
unsigned int handle;
int level;
int priority;
#include <fcntl.h>
#include <dirent.h>
#include <linux/input.h>
+#include <libsyscommon/list.h>
#include "shared/common.h"
#include "shared/log.h"
-#include "shared/list.h"
#include "haptic-interface.h"
#define MAX_MAGNITUDE 0xFFFF
};
static int ff_fd;
-static dd_list *ff_list;
-static dd_list *handle_list;
+static list *ff_list;
+static list *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;
- dd_list *elem;
+ list *elem;
- DD_LIST_FOREACH(ff_list, elem, temp) {
+ 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;
- dd_list *elem;
+ list *elem;
- DD_LIST_FOREACH(ff_list, elem, temp) {
+ LIST_FOREACH(ff_list, elem, temp) {
if (temp == info)
break;
}
struct ff_info *info;
int n;
bool found = false;
- dd_list *elem;
+ list *elem;
if (!device_handle)
return -EINVAL;
/* if it is the first element */
- n = DD_LIST_LENGTH(ff_list);
+ n = LIST_LENGTH(ff_list);
if (n == 0 && !ff_fd) {
_I("First element: open ff driver");
/* open ff driver */
while (found != true) {
++unique_number;
- elem = DD_LIST_FIND(handle_list, (gpointer)(long)unique_number);
+ elem = LIST_FIND(handle_list, (gpointer)(long)unique_number);
if (!elem)
found = true;
}
info->handle = unique_number;
/* add info to local list */
- DD_LIST_APPEND(ff_list, info);
- DD_LIST_APPEND(handle_list, (gpointer)(long)info->handle);
+ LIST_APPEND(ff_list, info);
+ LIST_APPEND(handle_list, (gpointer)(long)info->handle);
*device_handle = info->handle;
return 0;
/* stop vibration */
stop_device(device_handle);
- DD_LIST_REMOVE(handle_list, (gpointer)(long)info->handle);
+ LIST_REMOVE(handle_list, (gpointer)(long)info->handle);
safe_free(info->ffinfobuffer);
/* remove info from local list */
- DD_LIST_REMOVE(ff_list, info);
+ LIST_REMOVE(ff_list, info);
safe_free(info);
/* if it is the last element */
- n = DD_LIST_LENGTH(ff_list);
+ n = LIST_LENGTH(ff_list);
if (n == 0 && ff_fd) {
_I("Last element: close ff driver");
/* close ff driver */
+++ /dev/null
-/*
- * feedbackd
- *
- * Copyright (c) 2013 - 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include "log.h"
-#include "config-parser.h"
-
-#define MAX_LINE 512
-#define MAX_SECTION 64
-#define WHITESPACE " \t"
-#define NEWLINE "\n\r"
-#define COMMENT '#'
-
-static inline char *trim_str(char *s)
-{
- char *t;
- /* left trim */
- s += strspn(s, WHITESPACE);
-
- /* right trim */
- for (t = strchr(s, 0); t > s; t--)
- if (!strchr(WHITESPACE, t[-1]))
- break;
- *t = 0;
- return s;
-}
-
-int config_parse(const char *file_name, int cb(struct parse_result *result,
- void *user_data), void *user_data)
-{
- FILE *f = NULL;
- struct parse_result result;
- /* use stack for parsing */
- char line[MAX_LINE];
- char section[MAX_SECTION];
- char *start, *end, *name, *value;
- int lineno = 0, ret = 0;
-
- if (!file_name || !cb) {
- ret = -EINVAL;
- goto error;
- }
-
- /* open conf file */
- f = fopen(file_name, "r");
- if (!f) {
- _E("Failed to open file '%s'.", file_name);
- ret = -EIO;
- goto error;
- }
-
- /* parsing line by line */
- while (fgets(line, MAX_LINE, f) != NULL) {
- lineno++;
-
- start = line;
- start[strcspn(start, NEWLINE)] = '\0';
- start = trim_str(start);
-
- if (*start == COMMENT) {
- continue;
- } else if (*start == '[') {
- /* parse section */
- end = strchr(start, ']');
- if (!end || *end != ']') {
- ret = -EBADMSG;
- goto error;
- }
-
- *end = '\0';
- strncpy(section, start + 1, sizeof(section)-1);
- section[MAX_SECTION-1] = '\0';
- } else if (*start) {
- /* parse name & value */
- end = strchr(start, '=');
- if (!end || *end != '=') {
- ret = -EBADMSG;
- goto error;
- }
- *end = '\0';
- name = trim_str(start);
- value = trim_str(end + 1);
- end = strchr(value, COMMENT);
- if (end && *end == COMMENT) {
- *end = '\0';
- value = trim_str(value);
- }
-
- result.section = section;
- result.name = name;
- result.value = value;
- /* callback with parse result */
- ret = cb(&result, user_data);
- if (ret < 0) {
- ret = -EBADMSG;
- goto error;
- }
- }
- }
- _D("Success to load '%s'.", file_name);
- fclose(f);
- return 0;
-
-error:
- if (f)
- fclose(f);
- _E("Failed to read '%s': %d", file_name, lineno);
- return ret;
-}
-
+++ /dev/null
-/*
- * feedbackd
- *
- * Copyright (c) 2013 - 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef __FEEDBACKD_CONFIG_PARSER_H__
-#define __FEEDBACKD_CONFIG_PARSER_H__
-
-#define MATCH(a, b) (!strncmp(a, b, strlen(a)))
-#define SET_CONF(a, b) (a = (b > 0.0 ? b : a))
-
-struct parse_result {
- char *section;
- char *name;
- char *value;
-};
-
-/**
- * @brief Parse config file and call callback\n
- * @param[in] file_name conf file.
- * @param[in] cb cb is called when conf file is parsed line by line.
- * @param[in] user_data user data is passed to cb.
- * @return 0 on success, negative if failed
- */
-int config_parse(const char *file_name, int cb(struct parse_result *result,
- void *user_data), void *user_data);
-
-#endif
-
+++ /dev/null
-/*
- * feedbackd
- *
- * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __FEEDBACKD_LIST_H__
-#define __FEEDBACKD_LIST_H__
-
-#include <glib.h>
-typedef GList dd_list;
-
-#define DD_LIST_PREPEND(a, b) \
- a = g_list_prepend(a, (gpointer)b)
-#define DD_LIST_APPEND(a, b) \
- a = g_list_append(a, (gpointer)b)
-#define DD_LIST_REMOVE(a, b) \
- a = g_list_remove(a, (gpointer)b)
-#define DD_LIST_REMOVE_LIST(a, b) \
- a = g_list_delete_link(a, b)
-#define DD_LIST_LENGTH(a) \
- g_list_length(a)
-#define DD_LIST_NTH(a, b) \
- g_list_nth_data(a, b)
-#define DD_LIST_FIND(a, b) \
- g_list_find(a, (gpointer)b)
-#define DD_LIST_FREE_LIST(a) \
- g_list_free(a)
-#define DD_LIST_FOREACH(head, elem, node) \
- for (elem = head, node = NULL; \
- elem && ((node = elem->data) != NULL); \
- elem = elem->next, node = NULL)
-#define DD_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
- for (elem = head, elem_next = g_list_next(elem), node = NULL; \
- elem && ((node = elem->data) != NULL); \
- elem = elem_next, elem_next = g_list_next(elem), node = NULL)
-#define DD_LIST_REVERSE_FOREACH(head, elem, node) \
- for (elem = g_list_last(head), node = NULL; \
- elem && ((node = elem->data) != NULL); \
- elem = g_list_previous(elem), node = NULL)
-#define DD_LIST_REVERSE_FOREACH_SAFE(head, elem, elem_next, node) \
- for (elem = g_list_last(head), elem_next = g_list_previous(elem), node = NULL; \
- elem && ((node = elem->data) != NULL); \
- elem = elem_next, elem_next = g_list_previous(elem), node = NULL)
-#define DD_LIST_NEXT(a) \
- g_list_next(a)
-
-#endif