This patch remove dependency to libxml.
Instead of xml, libfeedback will use configuration file for initial configuration.
And this patch diminishes static variable sizes by using dynamic allocation.
.
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
Change-Id: I173ab419ab29dca34fb84fabef1c96cdca91b8a1
src/sound.c
src/vibrator.c
src/devices.c
- src/xmlparser.c
+ src/parser.c
src/feedback.c
src/dbus.c
${FEEDBACK_PROFILE_PATH}/src/check.c)
INCLUDE_DIRECTORIES(${FEEDBACK_PROFILE_PATH}/include)
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED vconf mm-keysound dlog libxml-2.0 glib-2.0 dbus-1)
+pkg_check_modules(pkgs REQUIRED vconf mm-keysound dlog glib-2.0 dbus-1)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
--- /dev/null
+[Sound]
+FEEDBACK_PATTERN_TAP=/usr/share/feedback/sound/touch/touch.wav
+FEEDBACK_PATTERN_SIP=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_KEY0=/usr/share/feedback/sound/touch/key0.wav
+FEEDBACK_PATTERN_KEY1=/usr/share/feedback/sound/touch/key1.wav
+FEEDBACK_PATTERN_KEY2=/usr/share/feedback/sound/touch/key2.wav
+FEEDBACK_PATTERN_KEY3=/usr/share/feedback/sound/touch/key3.wav
+FEEDBACK_PATTERN_KEY4=/usr/share/feedback/sound/touch/key4.wav
+FEEDBACK_PATTERN_KEY5=/usr/share/feedback/sound/touch/key5.wav
+FEEDBACK_PATTERN_KEY6=/usr/share/feedback/sound/touch/key6.wav
+FEEDBACK_PATTERN_KEY7=/usr/share/feedback/sound/touch/key7.wav
+FEEDBACK_PATTERN_KEY8=/usr/share/feedback/sound/touch/key8.wav
+FEEDBACK_PATTERN_KEY9=/usr/share/feedback/sound/touch/key9.wav
+FEEDBACK_PATTERN_KEY_STAR=/usr/share/feedback/sound/touch/keyasterisk.wav
+FEEDBACK_PATTERN_KEY_SHARP=/usr/share/feedback/sound/touch/keysharp.wav
+FEEDBACK_PATTERN_KEY_BACK=/usr/share/feedback/sound/touch/touch.wav
+FEEDBACK_PATTERN_HW_TAP=/usr/share/feedback/sound/touch/touch.wav
+FEEDBACK_PATTERN_POWERON=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_CHARGERCONN=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LOWBATT=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LOCK=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_UNLOCK=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_SILENT_OFF=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LIST_REORDER=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LIST_SLIDER=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_VOLUME_KEY=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_MOBILE_SIP_FUNCTION=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_MOBILE_SIP_FJKEY=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_MOBILE_MAX_CHARACTER=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_LOCK_SWIPE=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_UNLOCK_SWIPE=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_GEOMETRIC_LOCK=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_CALLCONNECT=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_DISCALLCONNECT=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_MINUTEMINDER=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_SCREEN_CAPTURE=/usr/share/feedback/sound/operation/shutter.wav
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<config>
- <label>svi-data</label>
- <description>Sound Resource</description>
- <sound>
- <label>FEEDBACK_PATTERN_TAP</label>
- <data>/usr/share/feedback/sound/touch/touch.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_SIP</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY0</label>
- <data>/usr/share/feedback/sound/touch/key0.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY1</label>
- <data>/usr/share/feedback/sound/touch/key1.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY2</label>
- <data>/usr/share/feedback/sound/touch/key2.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY3</label>
- <data>/usr/share/feedback/sound/touch/key3.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY4</label>
- <data>/usr/share/feedback/sound/touch/key4.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY5</label>
- <data>/usr/share/feedback/sound/touch/key5.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY6</label>
- <data>/usr/share/feedback/sound/touch/key6.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY7</label>
- <data>/usr/share/feedback/sound/touch/key7.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY8</label>
- <data>/usr/share/feedback/sound/touch/key8.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY9</label>
- <data>/usr/share/feedback/sound/touch/key9.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY_STAR</label>
- <data>/usr/share/feedback/sound/touch/keyasterisk.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY_SHARP</label>
- <data>/usr/share/feedback/sound/touch/keysharp.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY_BACK</label>
- <data>/usr/share/feedback/sound/touch/touch.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_HW_TAP</label>
- <data>/usr/share/feedback/sound/touch/touch.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_POWERON</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_CHARGERCONN</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_LOWBATT</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_LOCK</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_UNLOCK</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_SILENT_OFF</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_LIST_REORDER</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_LIST_SLIDER</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_VOLUME_KEY</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_SIP_FUNCTION</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_SIP_FJKEY</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_MAX_CHARACTER</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_LOCK_SWIPE</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_UNLOCK_SWIPE</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_GEOMETRIC_LOCK</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_CALLCONNECT</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_DISCALLCONNECT</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_MINUTEMINDER</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_SCREEN_CAPTURE</label>
- <data>/usr/share/feedback/sound/operation/shutter.wav</data>
- </sound>
-</config>
--- /dev/null
+[Vibration]
+FEEDBACK_PATTERN_SIP=mono
+FEEDBACK_PATTERN_KEY0=mono
+FEEDBACK_PATTERN_KEY1=mono
+FEEDBACK_PATTERN_KEY2=mono
+FEEDBACK_PATTERN_KEY3=mono
+FEEDBACK_PATTERN_KEY4=mono
+FEEDBACK_PATTERN_KEY5=mono
+FEEDBACK_PATTERN_KEY6=mono
+FEEDBACK_PATTERN_KEY7=mono
+FEEDBACK_PATTERN_KEY8=mono
+FEEDBACK_PATTERN_KEY9=mono
+FEEDBACK_PATTERN_KEY_STAR=mono
+FEEDBACK_PATTERN_KEY_SHARP=mono
+FEEDBACK_PATTERN_KEY_BACK=mono
+FEEDBACK_PATTERN_HOLD=mono
+FEEDBACK_PATTERN_HW_TAP=mono
+FEEDBACK_PATTERN_HW_HOLD=mono
+FEEDBACK_PATTERN_MESSAGE=mono
+FEEDBACK_PATTERN_EMAIL=mono
+FEEDBACK_PATTERN_WAKEUP=mono
+FEEDBACK_PATTERN_SCHEDULE=mono
+FEEDBACK_PATTERN_TIMER=mono
+FEEDBACK_PATTERN_GENERAL=mono
+FEEDBACK_PATTERN_POWERON=mono
+FEEDBACK_PATTERN_POWEROFF=mono
+FEEDBACK_PATTERN_CHARGERCONN=mono
+FEEDBACK_PATTERN_LOWBATT=mono
+FEEDBACK_PATTERN_VIBRATION_ON=mono
--- /dev/null
+[Sound]
+FEEDBACK_PATTERN_TAP=/usr/share/feedback/sound/touch/touch.wav
+FEEDBACK_PATTERN_SIP=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_KEY0=/usr/share/feedback/sound/touch/key0.wav
+FEEDBACK_PATTERN_KEY1=/usr/share/feedback/sound/touch/key1.wav
+FEEDBACK_PATTERN_KEY2=/usr/share/feedback/sound/touch/key2.wav
+FEEDBACK_PATTERN_KEY3=/usr/share/feedback/sound/touch/key3.wav
+FEEDBACK_PATTERN_KEY4=/usr/share/feedback/sound/touch/key4.wav
+FEEDBACK_PATTERN_KEY5=/usr/share/feedback/sound/touch/key5.wav
+FEEDBACK_PATTERN_KEY6=/usr/share/feedback/sound/touch/key6.wav
+FEEDBACK_PATTERN_KEY7=/usr/share/feedback/sound/touch/key7.wav
+FEEDBACK_PATTERN_KEY8=/usr/share/feedback/sound/touch/key8.wav
+FEEDBACK_PATTERN_KEY9=/usr/share/feedback/sound/touch/key9.wav
+FEEDBACK_PATTERN_KEY_STAR=/usr/share/feedback/sound/touch/keyasterisk.wav
+FEEDBACK_PATTERN_KEY_SHARP=/usr/share/feedback/sound/touch/keysharp.wav
+FEEDBACK_PATTERN_KEY_BACK=/usr/share/feedback/sound/touch/touch.wav
+FEEDBACK_PATTERN_HW_TAP=/usr/share/feedback/sound/touch/touch.wav
+FEEDBACK_PATTERN_POWERON=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_CHARGERCONN=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LOWBATT=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LOCK=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_UNLOCK=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_SILENT_OFF=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LIST_REORDER=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_LIST_SLIDER=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_VOLUME_KEY=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_MOBILE_SIP_FUNCTION=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_MOBILE_SIP_FJKEY=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_MOBILE_MAX_CHARACTER=/usr/share/feedback/sound/touch/sip.wav
+FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_LOCK_SWIPE=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_UNLOCK_SWIPE=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_GEOMETRIC_LOCK=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_CALLCONNECT=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_DISCALLCONNECT=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_MINUTEMINDER=/usr/share/feedback/sound/operation/operation.wav
+FEEDBACK_PATTERN_MOBILE_SCREEN_CAPTURE=/usr/share/feedback/sound/operation/shutter.wav
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<config>
- <label>svi-data</label>
- <description>Sound Resource</description>
- <sound>
- <label>FEEDBACK_PATTERN_TAP</label>
- <data>/usr/share/feedback/sound/touch/touch.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_SIP</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY0</label>
- <data>/usr/share/feedback/sound/touch/key0.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY1</label>
- <data>/usr/share/feedback/sound/touch/key1.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY2</label>
- <data>/usr/share/feedback/sound/touch/key2.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY3</label>
- <data>/usr/share/feedback/sound/touch/key3.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY4</label>
- <data>/usr/share/feedback/sound/touch/key4.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY5</label>
- <data>/usr/share/feedback/sound/touch/key5.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY6</label>
- <data>/usr/share/feedback/sound/touch/key6.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY7</label>
- <data>/usr/share/feedback/sound/touch/key7.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY8</label>
- <data>/usr/share/feedback/sound/touch/key8.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY9</label>
- <data>/usr/share/feedback/sound/touch/key9.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY_STAR</label>
- <data>/usr/share/feedback/sound/touch/keyasterisk.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY_SHARP</label>
- <data>/usr/share/feedback/sound/touch/keysharp.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY_BACK</label>
- <data>/usr/share/feedback/sound/touch/touch.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_HW_TAP</label>
- <data>/usr/share/feedback/sound/touch/touch.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_POWERON</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_CHARGERCONN</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_LOWBATT</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_LOCK</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_UNLOCK</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_SILENT_OFF</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_LIST_REORDER</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_LIST_SLIDER</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_VOLUME_KEY</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_SIP_FUNCTION</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_SIP_FJKEY</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_MAX_CHARACTER</label>
- <data>/usr/share/feedback/sound/touch/sip.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_LOCK_SWIPE</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_UNLOCK_SWIPE</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_GEOMETRIC_LOCK</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_CALLCONNECT</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_DISCALLCONNECT</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_MINUTEMINDER</label>
- <data>/usr/share/feedback/sound/operation/operation.wav</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_MOBILE_SCREEN_CAPTURE</label>
- <data>/usr/share/feedback/sound/operation/shutter.wav</data>
- </sound>
-</config>
--- /dev/null
+[Vibration]
+FEEDBACK_PATTERN_SIP=mono
+FEEDBACK_PATTERN_KEY0=mono
+FEEDBACK_PATTERN_KEY1=mono
+FEEDBACK_PATTERN_KEY2=mono
+FEEDBACK_PATTERN_KEY3=mono
+FEEDBACK_PATTERN_KEY4=mono
+FEEDBACK_PATTERN_KEY5=mono
+FEEDBACK_PATTERN_KEY6=mono
+FEEDBACK_PATTERN_KEY7=mono
+FEEDBACK_PATTERN_KEY8=mono
+FEEDBACK_PATTERN_KEY9=mono
+FEEDBACK_PATTERN_KEY_STAR=mono
+FEEDBACK_PATTERN_KEY_SHARP=mono
+FEEDBACK_PATTERN_KEY_BACK=mono
+FEEDBACK_PATTERN_HOLD=mono
+FEEDBACK_PATTERN_HW_TAP=mono
+FEEDBACK_PATTERN_HW_HOLD=mono
+FEEDBACK_PATTERN_MESSAGE=mono
+FEEDBACK_PATTERN_EMAIL=mono
+FEEDBACK_PATTERN_WAKEUP=mono
+FEEDBACK_PATTERN_SCHEDULE=mono
+FEEDBACK_PATTERN_TIMER=mono
+FEEDBACK_PATTERN_GENERAL=mono
+FEEDBACK_PATTERN_POWERON=mono
+FEEDBACK_PATTERN_POWEROFF=mono
+FEEDBACK_PATTERN_CHARGERCONN=mono
+FEEDBACK_PATTERN_LOWBATT=mono
+FEEDBACK_PATTERN_VIBRATION_ON=mono
+FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE=mono
+FEEDBACK_PATTERN_MOBILE_SIP_FUNCTION=mono
+FEEDBACK_PATTERN_MOBILE_SIP_FJKEY=mono
+FEEDBACK_PATTERN_MOBILE_MAX_CHARACTER=mono
+FEEDBACK_PATTERN_MOBILE_MULTI_TAP=mono
+FEEDBACK_PATTERN_MOBILE_MESSAGE_ON_CALL=mono
+FEEDBACK_PATTERN_MOBILE_EMAIL_ON_CALL=mono
+FEEDBACK_PATTERN_MOBILE_WAKEUP_ON_CALL=mono
+FEEDBACK_PATTERN_MOBILE_SCHEDULE_ON_CALL=mono
+FEEDBACK_PATTERN_MOBILE_TIMER_ON_CALL=mono
+FEEDBACK_PATTERN_MOBILE_GENERAL_ON_CALL=mono
+FEEDBACK_PATTERN_MOBILE_SMART_ALERT=mono
+FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL=mono
+FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL=mono
+FEEDBACK_PATTERN_MOBILE_OUTGOING_CALL=mono
+FEEDBACK_PATTERN_MOBILE_MINUTEMINDER=mono
+FEEDBACK_PATTERN_MOBILE_MMS=mono
+FEEDBACK_PATTERN_MOBILE_HOURLY_ALERT=mono
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(mm-keysound)
-BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(dbus-1)
--- /dev/null
+/*
+ * libfeedback
+ * Copyright (c) 2015 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 <stdlib.h>
+#include <errno.h>
+
+#include "parser.h"
+#include "profiles.h"
+#include "log.h"
+
+#define MAX_DATA 256
+#define MAX_LINE 256
+#define MAX_SECTION 64
+#define WHITESPACE " \t"
+#define NEWLINE "\n\r"
+#define COMMENT '#'
+
+#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;
+};
+
+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;
+}
+
+static 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));
+ 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;
+}
+
+static int load_config(struct parse_result *result, void *user_data)
+{
+ struct feedback_config_info *info = (struct feedback_config_info *)user_data;
+ char *name;
+ char *value;
+ int i;
+
+ if (!info)
+ return -EINVAL;
+
+ if (!MATCH(result->section, info->name))
+ return -ENOENT;
+
+ if (!result->name || !result->value)
+ return -ENOENT;
+
+ name = result->name;
+ value = result->value;
+
+ for (i = 0; i < profile->max_pattern; i++) {
+ if (!MATCH(name, (char *)profile->str_pattern[i]))
+ continue;
+
+ info->data[i].origin = strdup(value);
+ if (!info->data[i].origin)
+ _E("fail to copy %s sound data",
+ profile->str_pattern[i]);
+ break;
+ }
+
+ return 0;
+}
+
+int feedback_load_config(const char *path,
+ struct feedback_config_info *info)
+{
+ int ret;
+
+ if (!path || !info)
+ return -EINVAL;
+
+ info->data = calloc(1,
+ sizeof(struct feedback_data) * profile->max_pattern);
+ if (!info->data) {
+ _E("fail to allocate %s data", path);
+ return -ENOMEM;
+ }
+
+ ret = config_parse(path, load_config, info);
+ if (ret < 0)
+ _E("Failed to load %s, %d Use default value!",
+ path, ret);
+
+ return ret;
+}
+
+void feedback_free_config(struct feedback_config_info *info)
+{
+ int i;
+
+ for (i = 0; i < profile->max_pattern; i++) {
+ if (info->data[i].origin) {
+ free(info->data[i].origin);
+ info->data[i].origin = NULL;
+ }
+ if (info->data[i].changed) {
+ free(info->data[i].changed);
+ info->data[i].changed = NULL;
+ }
+ }
+
+ free(info->data);
+}
--- /dev/null
+/*
+ * libfeedback
+ * Copyright (c) 2015 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 __PARSER_H__
+#define __PARSER_H__
+
+struct feedback_data {
+ char *origin;
+ char *changed;
+};
+
+struct feedback_config_info {
+ char *name;
+ struct feedback_data *data;
+};
+
+int feedback_load_config(const char *path,
+ struct feedback_config_info *info);
+void feedback_free_config(struct feedback_config_info *info);
+
+#endif
#include <stdio.h>
+#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include "profiles.h"
#include "devices.h"
#include "log.h"
-#include "xmlparser.h"
+#include "parser.h"
-#define SOUND_XML "/usr/share/feedback/sound.xml"
+#define SOUND_CONF_FILE "/usr/share/feedback/sound.conf"
/* Temporary keys */
#ifndef VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL
static int sndstatus;
static int touch_sndstatus;
static int keytone_sndstatus;
+static struct feedback_config_info sound_info = {
+ .name = "Sound",
+};
+
+static char *get_data(feedback_pattern_e pattern)
+{
+ char *data;
-static xmlDocPtr v_doc;
+ if (pattern <= FEEDBACK_PATTERN_NONE ||
+ pattern >= profile->max_pattern)
+ return NULL;
-static char sound_file[FEEDBACK_PATTERN_END][PATH_MAX];
+ if (sound_info.data[pattern].changed)
+ data = sound_info.data[pattern].changed;
+ else
+ data = sound_info.data[pattern].origin;
+
+ return data;
+}
inline int is_sound_mode(void)
{
keytone_sndstatus = vconf_keynode_get_bool(key);
}
-static int get_xml_data(xmlDocPtr doc, feedback_pattern_e pattern, struct xmlData **data)
-{
- xmlNodePtr cur;
- struct xmlData *retData;
-
- cur = xml_find(doc, SOUND_STR,
- (const xmlChar*)profile->str_pattern[pattern]);
- /* This pattern does not have sound file to play */
- if (cur == NULL)
- return -ENOENT;
-
- retData = xml_parse(doc, cur);
- if (retData == NULL) {
- _E("xml_parse fail");
- return -EPERM;
- }
-
- *data = retData;
- return 0;
-}
-
-static void release_xml_data(struct xmlData *data)
-{
- if (data == NULL)
- return;
-
- xml_free(data);
-}
-
static void sound_init(void)
{
- /* xml Init */
- v_doc = xml_open(SOUND_XML);
- if (v_doc == NULL) {
- _E("xml_open(%s) fail", SOUND_XML);
- return;
- }
+ /* get sound data */
+ feedback_load_config(SOUND_CONF_FILE, &sound_info);
/* check sound status */
if (vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &touch_sndstatus) < 0)
vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, feedback_touch_sndstatus_cb);
vconf_ignore_key_changed(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL, feedback_keytone_sndstatus_cb);
- if (v_doc) {
- xml_close(v_doc);
- v_doc = NULL;
- }
+ /* free sound data */
+ feedback_free_config(&sound_info);
}
static int sound_play(feedback_pattern_e pattern)
struct stat buf;
int retry = FEEDBACK_RETRY_CNT, ret;
char *path;
- struct xmlData *data = NULL;
int level;
- if (!v_doc) {
- _E("Not initialize");
- return -EPERM;
- }
-
if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sndstatus) < 0) {
_D("fail to get sound status, will work as turning off");
sndstatus = 0;
return 0;
}
- /* check whether there is a user defined file */
- path = sound_file[pattern];
-
- /* if not */
- if (!(*path)) {
- ret = get_xml_data(v_doc, pattern, &data);
- if (ret == -ENOENT) {
- _E("No sound case(%s)", profile->str_pattern[pattern]);
- return -ENOTSUP;
- }
-
- if (ret < 0) {
- _E("get_xml_data fail");
- return -EPERM;
- }
-
- if (!data->data) {
- _E("No sound case(%s)", profile->str_pattern[pattern]);
- release_xml_data(data);
- return -ENOTSUP;
- }
-
- path = data->data;
- }
-
- if (stat(path, &buf)) {
- _E("%s is not presents", path);
+ /* get sound file path */
+ path = get_data(pattern);
+ if (!path || stat(path, &buf)) {
+ _E("Not supported sound pattern");
return -ENOTSUP;
}
ret = mm_sound_play_keysound(path, level);
if (ret == MM_ERROR_NONE) {
_D("Play success! SND filename is %s", path);
- release_xml_data(data);
return 0;
}
_E("mm_sound_play_keysound() returned error(%d)", ret);
} while(retry--);
- release_xml_data(data);
return -EPERM;
}
{
struct stat buf;
char *path;
- struct xmlData *data = NULL;
- int ret;
+ bool ret = true;
if (!supported) {
_E("Invalid parameter : supported(NULL)");
return -EINVAL;
}
- if (!v_doc) {
- _E("Not initialize");
- return -EPERM;
- }
-
- /* check whether there is a user defined file */
- path = sound_file[pattern];
-
- /* if not */
- if (!(*path)) {
- ret = get_xml_data(v_doc, pattern, &data);
- if (ret == -ENOENT) {
- _D("No sound case(%s)", profile->str_pattern[pattern]);
- goto out;
- }
-
- if (ret < 0) {
- _E("get_xml_data fail");
- return -EPERM;
- }
-
- if (!data->data) {
- _D("No sound case(%s)", profile->str_pattern[pattern]);
- goto out;
- }
-
- path = data->data;
- }
-
- if (stat(path, &buf)) {
+ /* get sound file path */
+ path = get_data(pattern);
+ if (!path || stat(path, &buf)) {
_E("%s is not presents", path);
- release_xml_data(data);
- return -ENOENT;
+ ret = false;
}
- release_xml_data(data);
-
- *supported = true;
- return 0;
-
-out:
- if (data)
- release_xml_data(data);
-
- *supported = false;
+ *supported = ret;
return 0;
}
{
char *cur_path;
int ret = 0;
- struct xmlData *data = NULL;
if (!buf || buflen <= 0)
return -EINVAL;
- cur_path = sound_file[pattern];
- if (!cur_path) {
- ret = get_xml_data(v_doc, pattern, &data);
- if (ret >= 0 && data && data->data)
- cur_path = (char*)data->data;
- }
-
+ /* get sound file path */
+ cur_path = get_data(pattern);
if (!cur_path) {
_E("This pattern(%s) in sound type is not supported to play",
profile->str_pattern[pattern]);
}
snprintf(buf, buflen, "%s", cur_path);
- release_xml_data(data);
- return 0;
+ return ret;
}
static int sound_set_path(feedback_pattern_e pattern, char *path)
{
struct stat buf;
- char *ppath;
/*
* check the path is valid
return -errno;
}
- ppath = sound_file[pattern];
+ if (sound_info.data[pattern].changed) {
+ free(sound_info.data[pattern].changed);
+ sound_info.data[pattern].changed = NULL;
+ }
/* if path is NULL, this pattern set to default file */
if (path)
- snprintf(ppath, NAME_MAX, "%s", path);
- else
- memset(ppath, 0, NAME_MAX);
+ sound_info.data[pattern].changed = strdup(path);
_D("The file of pattern(%s) is changed to [%s]",
profile->str_pattern[pattern], path);
#include <stdio.h>
+#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include "feedback-ids.h"
#include "profiles.h"
+#include "parser.h"
#include "devices.h"
#include "log.h"
#include "dbus.h"
HAPTIC_ITERATION_INFINITE = 256,
};
-#define VIBRATION_XML "/usr/share/feedback/vibration.xml"
+#define VIBRATION_CONF_FILE "/usr/share/feedback/vibration.conf"
#define METHOD_OPEN "OpenDevice"
#define METHOD_CLOSE "CloseDevice"
#define METHOD_VIBRATE_MONOTONE "VibrateMonotone"
+#define METHOD_VIBRATE_BUFFER "VibrateBuffer"
#define METHOD_STOP "StopDevice"
#define DEFAULT_DURATION 100
static int vibstatus;
-
static unsigned int v_handle;
+static struct feedback_config_info vib_info = {
+ .name = "Vibration",
+};
+
+static char *get_data(feedback_pattern_e pattern)
+{
+ char *data;
-static char haptic_file[FEEDBACK_PATTERN_END][NAME_MAX];
+ if (pattern <= FEEDBACK_PATTERN_NONE ||
+ pattern >= profile->max_pattern)
+ return NULL;
+
+ if (vib_info.data[pattern].changed)
+ data = vib_info.data[pattern].changed;
+ else
+ data = vib_info.data[pattern].origin;
+
+ return data;
+}
inline int is_vibration_mode(void)
{
"u", arr);
}
+static int haptic_vibrate_buffer(unsigned int handle,
+ const unsigned char *buffer,
+ int size,
+ int iteration,
+ int feedback,
+ int priority)
+{
+ char *arr[6];
+ char buf_handle[32];
+ char buf_iteration[32];
+ char buf_feedback[32];
+ char buf_priority[32];
+ struct dbus_byte bytes;
+
+ snprintf(buf_handle, sizeof(buf_handle), "%u", handle);
+ arr[0] = buf_handle;
+ bytes.size = size;
+ bytes.data = buffer;
+ arr[2] = (char *)&bytes;
+ snprintf(buf_iteration, sizeof(buf_iteration), "%d", iteration);
+ arr[3] = buf_iteration;
+ snprintf(buf_feedback, sizeof(buf_feedback), "%d", feedback);
+ arr[4] = buf_feedback;
+ snprintf(buf_priority, sizeof(buf_priority), "%d", priority);
+ arr[5] = buf_priority;
+
+ return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_HAPTIC,
+ DEVICED_INTERFACE_HAPTIC, METHOD_VIBRATE_BUFFER,
+ "uayiii", arr);
+}
+
static int haptic_vibrate_monotone(unsigned int handle,
int duration,
int feedback,
"u", arr);
}
+static unsigned char *convert_file_to_buffer(const char *file_name, int *size)
+{
+ FILE *pf;
+ long file_size;
+ unsigned char *pdata = NULL;
+
+ if (!file_name)
+ return NULL;
+
+ /* Get File Stream Pointer */
+ pf = fopen(file_name, "rb");
+ if (!pf) {
+ _E("fopen failed : %s", strerror(errno));
+ return NULL;
+ }
+
+ if (fseek(pf, 0, SEEK_END))
+ goto error;
+
+ file_size = ftell(pf);
+ if (fseek(pf, 0, SEEK_SET))
+ goto error;
+
+ if (file_size < 0)
+ goto error;
+
+ pdata = (unsigned char *)malloc(file_size);
+ if (!pdata)
+ goto error;
+
+ if (fread(pdata, 1, file_size, pf) != file_size)
+ goto err_free;
+
+ fclose(pf);
+ *size = file_size;
+ return pdata;
+
+err_free:
+ free(pdata);
+
+error:
+ fclose(pf);
+
+ _E("failed to convert file to buffer (%s)", strerror(errno));
+ return NULL;
+}
+
static int get_priority(feedback_pattern_e pattern)
{
if (pattern >= FEEDBACK_PATTERN_TAP && pattern <= FEEDBACK_PATTERN_HW_HOLD)
/* Set vibration handle */
v_handle = (unsigned int)ret;
+
+ /* get vibration data */
+ feedback_load_config(VIBRATION_CONF_FILE, &vib_info);
}
static void vibrator_exit(void)
_E("haptic_close is failed : %d", ret);
v_handle = 0;
}
+
+ /* free vibration data */
+ feedback_free_config(&vib_info);
}
static int vibrator_play(feedback_pattern_e pattern)
{
+ struct stat buf;
+ char *data;
+ unsigned char *pbuf;
+ int size;
int ret;
int level;
else
level = DEFAULT_VIB_LEVEL * HAPTIC_FEEDBACK_STEP;
- ret = haptic_vibrate_monotone(v_handle, DEFAULT_DURATION,
- level, get_priority(pattern));
+ /* get vibration data */
+ data = get_data(pattern);
+ if (!data) {
+ _E("Not supported vibration pattern");
+ return -ENOTSUP;
+ }
+
+ /* if it has a file path */
+ if (!stat(data, &buf)) {
+ pbuf = convert_file_to_buffer(data, &size);
+ if (!pbuf) {
+ _E("fail to convert file to buffer");
+ return -EPERM;
+ }
+
+ ret = haptic_vibrate_buffer(v_handle, pbuf, size,
+ HAPTIC_ITERATION_ONCE,
+ level, get_priority(pattern));
+ } else
+ ret = haptic_vibrate_monotone(v_handle, DEFAULT_DURATION,
+ level, get_priority(pattern));
+
if (ret < 0) {
- _E("haptic_vibrate_monotone is failed");
+ _E("fail to play vibration");
if (ret == -ECOMM)
return ret;
return -EPERM;
}
+ _D("Play success! Data is %s", data);
return 0;
}
static int vibrator_is_supported(int pattern, bool *supported)
{
+ char *data;
+ bool ret = true;
+
if (!supported) {
_E("Invalid parameter : supported(NULL)");
return -EINVAL;
return 0;
}
- *supported = true;
+ /* get vibration data */
+ data = get_data(pattern);
+ if (!data) {
+ _E("Not supported vibration pattern");
+ ret = false;
+ }
+
+ *supported = ret;
return 0;
}
static int vibrator_get_path(feedback_pattern_e pattern, char *buf, unsigned int buflen)
{
- const char *cur_path;
+ char *data;
+ int ret = 0;
- assert(buf != NULL && buflen > 0);
+ if (!buf || buflen <= 0)
+ return -EINVAL;
- cur_path = haptic_file[pattern];
- if (*cur_path) {
+ /* get vibration data */
+ data = get_data(pattern);
+ if (!data) {
_E("This pattern(%s) in vibrator type is not supported to play",
profile->str_pattern[pattern]);
- snprintf(buf, buflen, "NULL");
- return -ENOENT;
+ data = "NULL";
+ ret = -ENOENT;
}
- snprintf(buf, buflen, "%s", cur_path);
- return 0;
+ snprintf(buf, buflen, "%s", data);
+ return ret;
}
static int vibrator_set_path(feedback_pattern_e pattern, char *path)
{
struct stat buf;
- char *ppath;
/*
* check the path is valid
return -errno;
}
- ppath = haptic_file[pattern];
+ if (vib_info.data[pattern].changed) {
+ free(vib_info.data[pattern].changed);
+ vib_info.data[pattern].changed = NULL;
+ }
/* if path is NULL, this pattern set to default file */
if (path)
- snprintf(ppath, NAME_MAX, "%s", path);
- else
- memset(ppath, 0, NAME_MAX);
+ vib_info.data[pattern].changed = strdup(path);
_D("The file of pattern(%s) is changed to [%s]",
profile->str_pattern[pattern], path);
+++ /dev/null
-/*
- * libfeedback
- * Copyright (c) 2012 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 <assert.h>
-#include <errno.h>
-#include <glib.h>
-
-#include "xmlparser.h"
-#include "log.h"
-
-static const char* data_str[] = {
- [XML_LABEL] = "label",
- [XML_DATA] = "data",
-};
-
-xmlDocPtr xml_open(const char *xml)
-{
- xmlDocPtr doc;
-
- doc = xmlReadFile(xml, NULL, 0);
- if (doc == NULL) {
- _E("xmlReadFile fail");
- return NULL;
- }
-
- return doc;
-}
-
-void xml_close(xmlDocPtr doc)
-{
- xmlFreeDoc(doc);
-}
-
-static int xml_compare(xmlDocPtr doc, xmlNodePtr cur, const xmlChar* expr)
-{
- xmlNodePtr node;
- xmlChar *key;
- int r;
-
- assert(doc);
- assert(cur);
- assert(expr);
-
- for (node = cur->children; node != NULL; node = node->next) {
- if (xmlStrcmp(node->name, (const xmlChar*)data_str[XML_LABEL]))
- continue;
-
- key = xmlNodeListGetString(doc, node->children, 1);
- r = xmlStrcmp(key, expr);
- xmlFree(key);
-
- if (r == 0)
- return 1;
-
- break;
- }
-
- return 0;
-}
-
-xmlNodePtr xml_find(xmlDocPtr doc, const char *label, const xmlChar* expr)
-{
- xmlNodePtr root;
- xmlNodePtr cur;
-
- assert(doc);
- assert(expr);
-
- root = xmlDocGetRootElement(doc);
- if (root == NULL) {
- _E("xmlDocGetRootElement fail");
- return NULL;
- }
-
- for (cur = root->children; cur != NULL; cur = cur->next) {
- if (xmlStrcmp(cur->name, (const xmlChar*)label))
- continue;
-
- if (!xml_compare(doc, cur, expr))
- continue;
-
- return cur;
- }
-
- return NULL;
-}
-
-struct xmlData *xml_parse(xmlDocPtr doc, xmlNodePtr cur)
-{
- xmlNodePtr node;
- struct xmlData *data;
-
- assert(doc);
- assert(cur);
-
- data = (struct xmlData*)malloc(sizeof(struct xmlData));
- if (data == NULL) {
- _E("out of memory");
- return NULL;
- }
-
- memset(data, 0, sizeof(struct xmlData));
- for (node = cur->children; node != NULL; node = node->next) {
- if (!xmlStrcmp(node->name, (const xmlChar*)data_str[XML_LABEL])) {
- data->label = (char*)xmlNodeListGetString(doc, node->children, 1);
- _D("label : %s", data->label);
- } else if (!xmlStrcmp(node->name, (const xmlChar*)data_str[XML_DATA])) {
- data->data = (char*)xmlNodeListGetString(doc, node->children, 1);
- data->size = strlen(data->data);
- }
- }
-
- return data;
-}
-
-int xml_decode_data(struct xmlData *data)
-{
- char *decode;
- gsize len;
-
- if (!data || !data->data)
- return -EINVAL;
-
- _D("b64_data : %s", data->data);
- decode = (char*)g_base64_decode(data->data, &len);
- free(data->data);
-
- data->data = decode;
- data->size = (unsigned int)len;
- return 0;
-}
-
-int xml_save(xmlDocPtr doc, const char *path)
-{
- int r;
-
- assert(doc);
- assert(path);
-
- r = xmlSaveFile(path, doc);
- if (r < 0) {
- _E("xmlSaveFile fail");
- return -1;
- }
-
- return 0;
-}
-
-void xml_free(struct xmlData* data)
-{
- assert(data);
-
- free(data->label);
- free(data->data);
- free(data);
-}
+++ /dev/null
-/*
- * libfeedback
- * Copyright (c) 2012 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 __XMLPARSER_H__
-#define __XMLPARSER_H__
-
-#include <libxml/parser.h>
-
-struct xmlData {
- char *label;
- char *data;
- int size;
-};
-
-enum xmlType {
- XML_LABEL = 0,
- XML_DATA,
-};
-
-#define VIBRATION_STR "vibration"
-#define SOUND_STR "sound"
-
-xmlDocPtr xml_open(const char *xml);
-void xml_close(xmlDocPtr doc);
-
-xmlNodePtr xml_find(xmlDocPtr doc, const char *label, const xmlChar* expr);
-struct xmlData *xml_parse(xmlDocPtr doc, xmlNodePtr cur);
-int xml_decode_data(struct xmlData *data);
-int xml_save(xmlDocPtr doc, const char *path);
-void xml_free(struct xmlData* data);
-
-#endif //__XMLPARSER_H__
--- /dev/null
+[Sound]
+FEEDBACK_PATTERN_TAP=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_SIP=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY0=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY1=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY2=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY3=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY4=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY5=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY6=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY7=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY8=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY9=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY_STAR=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY_SHARP=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_KEY_BACK=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_POWERON=/usr/share/feedback/sound/operation/power_on.ogg
+FEEDBACK_PATTERN_CHARGERCONN=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_CHARGING_ERROR=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_LOWBATT=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_SILENT_OFF=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_BT_CONNECTED=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_BT_DISCONNECTED=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_VOLUME_KEY=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_SIP_BACKSPACE=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_WEARABLE_SIP_FUNCTION=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_WEARABLE_SIP_FJKEY=/usr/share/feedback/sound/touch/touch.ogg
+FEEDBACK_PATTERN_WEARABLE_WAKEUP_ON_CALL=/usr/share/feedback/sound/operation/notification.ogg
+FEEDBACK_PATTERN_WEARABLE_SCHEDULE_ON_CALL=/usr/share/feedback/sound/operation/notification.ogg
+FEEDBACK_PATTERN_WEARABLE_TIMER_ON_CALL=/usr/share/feedback/sound/operation/notification.ogg
+FEEDBACK_PATTERN_WEARABLE_SAFETY_ALERT=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_CALLCONNECT=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_DISCALLCONNECT=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_BT_PAIRING=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_BT_WAITING=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_SCREEN_CAPTURE=/usr/share/feedback/sound/operation/shutter.ogg
+FEEDBACK_PATTERN_WEARABLE_SAFETY_LOW_POWER=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_CMAS=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_GOAL_ACHIEVED=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_MEASURING_SUCCESS=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_MEASURING_FAILURE=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_UV_PROCESSING=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_SHEALTH_START=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_SHEALTH_PAUSE=/usr/share/feedback/sound/operation/system.ogg
+FEEDBACK_PATTERN_WEARABLE_SHEALTH_STOP=/usr/share/feedback/sound/operation/system.ogg
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<config>
- <label>svi-data</label>
- <description>Sound Resource</description>
- <sound>
- <label>FEEDBACK_PATTERN_TAP</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_SIP</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY0</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY1</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY2</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY3</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY4</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY5</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY6</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY7</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY8</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY9</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY_STAR</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY_SHARP</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_KEY_BACK</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_POWERON</label>
- <data>/usr/share/feedback/sound/operation/power_on.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_CHARGERCONN</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_CHARGING_ERROR</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_LOWBATT</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_SILENT_OFF</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_BT_CONNECTED</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_BT_DISCONNECTED</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_VOLUME_KEY</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SIP_BACKSPACE</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SIP_FUNCTION</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SIP_FJKEY</label>
- <data>/usr/share/feedback/sound/touch/touch.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_WAKEUP_ON_CALL</label>
- <data>/usr/share/feedback/sound/operation/notification.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SCHEDULE_ON_CALL</label>
- <data>/usr/share/feedback/sound/operation/notification.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_TIMER_ON_CALL</label>
- <data>/usr/share/feedback/sound/operation/notification.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SAFETY_ALERT</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_CALLCONNECT</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_DISCALLCONNECT</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_BT_PAIRING</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_BT_WAITING</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SCREEN_CAPTURE</label>
- <data>/usr/share/feedback/sound/operation/shutter.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SAFETY_LOW_POWER</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_CMAS</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_GOAL_ACHIEVED</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_MEASURING_SUCCESS</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_MEASURING_FAILURE</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_UV_PROCESSING</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SHEALTH_START</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SHEALTH_PAUSE</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
- <sound>
- <label>FEEDBACK_PATTERN_WEARABLE_SHEALTH_STOP</label>
- <data>/usr/share/feedback/sound/operation/system.ogg</data>
- </sound>
-</config>
--- /dev/null
+[Vibration]
+FEEDBACK_PATTERN_TAP=mono
+FEEDBACK_PATTERN_SIP=mono
+FEEDBACK_PATTERN_HOLD=mono
+FEEDBACK_PATTERN_MESSAGE=mono
+FEEDBACK_PATTERN_EMAIL=mono
+FEEDBACK_PATTERN_WAKEUP=mono
+FEEDBACK_PATTERN_SCHEDULE=mono
+FEEDBACK_PATTERN_TIMER=mono
+FEEDBACK_PATTERN_GENERAL=mono
+FEEDBACK_PATTERN_CHARGERCONN=mono
+FEEDBACK_PATTERN_LOWBATT=mono
+FEEDBACK_PATTERN_VIBRATION_ON=mono
+FEEDBACK_PATTERN_BT_CONNECTED=mono
+FEEDBACK_PATTERN_BT_DISCONNECTED=mono
+FEEDBACK_PATTERN_WEARABLE_SIP_BACKSPACE=mono
+FEEDBACK_PATTERN_WEARABLE_SIP_FUNCTION=mono
+FEEDBACK_PATTERN_WEARABLE_SIP_FJKEY=mono
+FEEDBACK_PATTERN_WEARABLE_CHARGERCONN_ON_CALL=mono
+FEEDBACK_PATTERN_WEARABLE_LOWBATT_ON_CALL=mono
+FEEDBACK_PATTERN_WEARABLE_CALLCONNECT=mono
+FEEDBACK_PATTERN_WEARABLE_DISCALLCONNECT=mono
+FEEDBACK_PATTERN_WEARABLE_BT_PAIRING=mono
+FEEDBACK_PATTERN_WEARABLE_BT_WAITING=mono
+FEEDBACK_PATTERN_WEARABLE_SAFETY_ALERT=mono
+FEEDBACK_PATTERN_WEARABLE_SEND_SOS_MESSAGE=mono
+FEEDBACK_PATTERN_WEARABLE_END_SOS_MESSAGE=mono
+FEEDBACK_PATTERN_WEARABLE_CMAS=mono
+FEEDBACK_PATTERN_WEARABLE_SPEED_UP=mono
+FEEDBACK_PATTERN_WEARABLE_SLOW_DOWN=mono
+FEEDBACK_PATTERN_WEARABLE_KEEP_THIS_PACE=mono
+FEEDBACK_PATTERN_WEARABLE_GOAL_ACHIEVED=mono
+FEEDBACK_PATTERN_WEARABLE_START_CUE=mono
+FEEDBACK_PATTERN_WEARABLE_HEALTH_PACE=mono
+FEEDBACK_PATTERN_WEARABLE_INACTIVE_TIME=mono
+FEEDBACK_PATTERN_WEARABLE_MEASURING_SUCCESS=mono
+FEEDBACK_PATTERN_WEARABLE_MEASURING_FAILURE=mono
+FEEDBACK_PATTERN_WEARABLE_3RD_APPLICATION=mono