#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 "common.h"
-#include "list.h"
#define SIGNAL_FLASH_STATE "ChangeFlashState"
void *data;
};
-static dd_list *device_cb_list[DEVICE_CALLBACK_MAX];
+static list *device_cb_list[DEVICE_CALLBACK_MAX];
static int flash_sigid;
//LCOV_EXCL_START Not called Callback
{
static device_callback_e type = DEVICE_CALLBACK_BATTERY_CAPACITY;
struct device_cb_info *cb_info;
- dd_list *elem, *elem_next;
+ list *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)
+ 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 device_callback_e type = DEVICE_CALLBACK_BATTERY_CHARGING;
struct device_cb_info *cb_info;
- dd_list *elem, *elem_next;
+ list *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)
+ 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 device_callback_e type = DEVICE_CALLBACK_BATTERY_LEVEL;
struct device_cb_info *cb_info;
- dd_list *elem, *elem_next;
+ list *elem, *elem_next;
int val, status;
val = vconf_keynode_get_int(key);
status = -1;
/* invoke the each callback with value */
- DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
+ LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
cb_info->cb(type, (void*)status, cb_info->data);
}
//LCOV_EXCL_STOP
{
static device_callback_e type = DEVICE_CALLBACK_DISPLAY_STATE;
struct device_cb_info *cb_info;
- dd_list *elem, *elem_next;
+ list *elem, *elem_next;
display_state_e state;
int val;
}
/* invoke the each callback with value */
- DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
+ LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
cb_info->cb(type, (void*)state, cb_info->data);
}
//LCOV_EXCL_STOP
{
static int type = DEVICE_CALLBACK_FLASH_BRIGHTNESS;
struct device_cb_info *cb_info;
- dd_list *elem, *elem_next;
+ list *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_SAFE(device_cb_list[type], elem, elem_next, cb_info)
+ LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info)
cb_info->cb(type, (void*)val, cb_info->data);
}
//LCOV_EXCL_STOP
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;
+ list *elem, *elem_next;
int ret, n;
if (!is_display_supported() && type == DEVICE_CALLBACK_DISPLAY_STATE)
return DEVICE_ERROR_INVALID_PARAMETER;
/* check if it is the first request */
- n = DD_LIST_LENGTH(device_cb_list[type]);
+ n = LIST_LENGTH(device_cb_list[type]);
if (n == 0) {
ret = register_request(type);
if (ret < 0)
}
/* check for the same request */
- DD_LIST_FOREACH_SAFE(device_cb_list[type], elem, elem_next, cb_info) {
+ 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);
+ 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, *elem_next;
+ list *elem, *elem_next;
int ret, n;
if (!is_display_supported() && type == DEVICE_CALLBACK_DISPLAY_STATE)
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) {
+ 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);
+ 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 = LIST_LENGTH(device_cb_list[type]);
if (n == 0) {
ret = release_request(type);
if (ret < 0)
#include "common.h"
#include <sys/time.h>
-#define MAX_LINE 128
-#define MAX_SECTION 64
-#define WHITESPACE " \t"
-#define NEWLINE "\n\r"
-#define COMMENT '#'
-
#define MODEL_NAME "http://tizen.org/system/model_name"
#define MODEL_EMULATOR "Emulator"
#define DISPLAY_FEATURE "http://tizen.org/feature/display"
#define DISPLAY_STATE_FEATURE "http://tizen.org/feature/display.state"
-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) {
-//LCOV_EXCL_START System Error
- ret = -EINVAL;
- goto error;
-//LCOV_EXCL_STOP
- }
-
- /* open conf file */
- f = fopen(file_name, "r");
- if (!f) {
-//LCOV_EXCL_START System Error
- if (errno == ENOENT) {
- _I("There is no power config file");
- return 0;
-//LCOV_EXCL_STOP
- }
-
-//LCOV_EXCL_START System Error
- _E("Failed to open file %s", file_name);
- ret = -EIO;
- goto error;
-//LCOV_EXCL_STOP
- }
-
- /* 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 != ']') {
-//LCOV_EXCL_START System Error
- ret = -EBADMSG;
- goto error;
-//LCOV_EXCL_STOP
- }
-
- *end = '\0';
- strncpy(section, start + 1, sizeof(section));
- section[MAX_SECTION-1] = '\0';
- } else if (*start) {
- /* parse name & value */
- end = strchr(start, '=');
- if (!end || *end != '=') {
-//LCOV_EXCL_START System Error
- ret = -EBADMSG;
- goto error;
-//LCOV_EXCL_STOP
- }
- *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) {
-//LCOV_EXCL_START System Error
- ret = -EBADMSG;
- goto error;
-//LCOV_EXCL_STOP
- }
- }
- }
- _D("Success to load %s", file_name);
- fclose(f);
- return 0;
-
-//LCOV_EXCL_START System Error
-error:
- if (f)
- fclose(f);
- _E("Failed to read %s:%d!", file_name, lineno);
-//LCOV_EXCL_STOP
- return ret;
-}
-
tizen_profile_t _get_tizen_profile()
{
static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
}
}
-struct parse_result {
- char *section;
- char *name;
- char *value;
-};
-
-int config_parse(const char *file_name,
- int cb(struct parse_result *result, void *data),
- void *user_data);
-
typedef enum {
TIZEN_PROFILE_UNKNOWN = 0,
TIZEN_PROFILE_MOBILE = 0x1,
#include <stdlib.h>
#include <system_info.h>
#include <libsyscommon/dbus-system.h>
+#include <libsyscommon/list.h>
#include "haptic.h"
#include "common.h"
-#include "list.h"
#define SIGNAL_VIBRATOR_INITIATED "InitiateVibrator"
};
static guint haptic_id = 0;
-static dd_list *handle_list;
+static list *handle_list;
static int is_haptic_supported(void)
{
//LCOV_EXCL_START Not called Callback
static void restart_callback(void)
{
- dd_list *elem, *elem_next;
+ list *elem, *elem_next;
struct haptic_handle *temp;
int ret;
- DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
+ LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME,
VIBRATOR_PATH_HAPTIC, VIBRATOR_INTERFACE_HAPTIC,
METHOD_OPEN_DEVICE, g_variant_new("(i)", temp->index));
int device_haptic_open(int device_index, haptic_device_h *device_handle)
{
- dd_list *elem, *elem_next;
+ list *elem, *elem_next;
struct haptic_handle *handle;
struct haptic_handle *temp;
int ret, max;
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
- DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
+ LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
if (temp->handle == ret) {
found = true;
temp->index = device_index;
handle->handle = ret;
handle->index = device_index;
- DD_LIST_APPEND(handle_list, handle);
+ LIST_APPEND(handle_list, handle);
*device_handle = (haptic_device_h)handle;
}
- if (DD_LIST_LENGTH(handle_list) == 1) {
+ if (LIST_LENGTH(handle_list) == 1) {
haptic_id = subscribe_dbus_signal(NULL,
VIBRATOR_PATH_HAPTIC,
VIBRATOR_INTERFACE_HAPTIC,
int device_haptic_close(haptic_device_h device_handle)
{
- dd_list *elem, *elem_next;
+ list *elem, *elem_next;
struct haptic_handle *handle = (struct haptic_handle *)device_handle;
struct haptic_handle *temp;
int ret;
if (!ret)
return DEVICE_ERROR_NOT_SUPPORTED;
- DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
+ LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
if (temp->handle != handle->handle)
continue;
found = true;
if (!found)
return DEVICE_ERROR_OPERATION_FAILED;
- DD_LIST_REMOVE(handle_list, handle);
+ LIST_REMOVE(handle_list, handle);
/* request to deviced to open haptic device */
ret = dbus_handle_method_sync_var(VIBRATOR_BUS_NAME,
if (ret < 0)
return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
- if (DD_LIST_LENGTH(handle_list) == 0)
+ if (LIST_LENGTH(handle_list) == 0)
unsubscribe_dbus_signal(NULL, haptic_id);
return DEVICE_ERROR_NONE;
int device_haptic_vibrate(haptic_device_h device_handle, int duration, int feedback, haptic_effect_h *effect_handle)
{
- dd_list *elem, *elem_next;
+ list *elem, *elem_next;
struct haptic_handle *handle = (struct haptic_handle *)device_handle;
struct haptic_handle *temp;
int ret, priority;
priority = HAPTIC_PRIORITY_MIN;
- DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
+ LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
if (temp != handle)
continue;
found = true;
int device_haptic_stop(haptic_device_h device_handle, haptic_effect_h effect_handle)
{
- dd_list *elem, *elem_next;
+ list *elem, *elem_next;
struct haptic_handle *handle = (struct haptic_handle *)device_handle;
struct haptic_handle *temp;
int ret;
if (!ret)
return DEVICE_ERROR_NOT_SUPPORTED;
- DD_LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
+ LIST_FOREACH_SAFE(handle_list, elem, elem_next, temp) {
if (temp != handle)
continue;
found = true;
+++ /dev/null
-/*
- * deviced
- *
- * Copyright (c) 2012 - 2013 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 __LIST_H__
-#define __LIST_H__
-
-#include <stdio.h>
-
-#define EINA_LIST_APPEND(a, b) \
- a = eina_list_append(a, b)
-
-#define EINA_LIST_REMOVE(a, b) \
- a = eina_list_remove(a, b)
-
-#define EINA_LIST_REMOVE_LIST(a, b) \
- a = eina_list_remove_list(a, b)
-
-#define EINA_LIST_FREE_LIST(a) \
- a = eina_list_free(a)
-
-#define EINA_LIST_PROMOTE_LIST(a, b) \
- a = eina_list_promote_list(a, b)
-
-#ifdef EINA_LIST
-#include <Ecore.h>
-typedef Eina_List dd_list;
-#define DD_LIST_PREPEND(a, b) \
- a = eina_list_prepend(a, b)
-#define DD_LIST_APPEND(a, b) \
- a = eina_list_append(a, b)
-#define DD_LIST_REMOVE(a, b) \
- a = eina_list_remove(a, b)
-#define DD_LIST_LENGTH(a) \
- eina_list_count(a)
-#define DD_LIST_NTH(a, b) \
- eina_list_nth(a, b)
-#define DD_LIST_FREE_LIST(a) \
- a = eina_list_free(a)
-#define DD_LIST_FOREACH(head, elem, node) \
- EINA_LIST_FOREACH(head, elem, node)
-#define DD_LIST_FOREACH_SAFE(head, elem, elem_next, node) \
- EINA_LIST_FOREACH_SAFE(head, elem, elem_next, node)
-
-#else
-#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_LENGTH(a) \
- g_list_length(a)
-#define DD_LIST_NTH(a, b) \
- g_list_nth_data(a, 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)
-
-#endif
-
-#endif
#include <tracker.h>
#include <sys/time.h>
#include <libsyscommon/dbus-system.h>
+#include <libsyscommon/ini-parser.h>
#include "power.h"
#include "power-internal.h"