diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | include/common.h | 3 | ||||
-rw-r--r-- | packaging/libfeedback.spec | 43 | ||||
-rw-r--r-- | src/sound.c | 137 | ||||
-rw-r--r-- | src/vibrator.c | 142 |
5 files changed, 272 insertions, 55 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 69fe1c2..c3b673f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ SET(SVI_HEADERS SET(SVI_SRCS src/svi.c) -SET(DEPENDENTS "vconf haptic mm-keysound dlog libxml-2.0 glib-2.0") +SET(DEPENDENTS "vconf haptic mm-keysound dlog libxml-2.0 glib-2.0 libtzplatform-config") SET(PC_DEPENDENTS "capi-base-common") SET(PC_NAME ${PROJECT_NAME}) diff --git a/include/common.h b/include/common.h index 0113c02..ccbb1bf 100644 --- a/include/common.h +++ b/include/common.h @@ -27,8 +27,9 @@ extern "C" { * @file common.h * @brief This file contains the common information */ +#include <tzplatform_config.h> -#define FEEDBACK_DATA_DIR "/opt/usr/share/feedback" +#define FEEDBACK_DATA_DIR tzplatform_mkpath(TZ_USER_SHARE,"feedback") #define FEEDBACK_ORIGIN_DATA_DIR "/usr/share/feedback" #define FEEDBACK_RETRY_CNT 1 diff --git a/packaging/libfeedback.spec b/packaging/libfeedback.spec index 49e8adc..6a6b155 100644 --- a/packaging/libfeedback.spec +++ b/packaging/libfeedback.spec @@ -18,6 +18,7 @@ BuildRequires: pkgconfig(haptic) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(libtzplatform-config) %description Feedback library for playing sound, vibration and led @@ -69,11 +70,6 @@ make rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}/opt/usr/share/feedback/sound/touch -mkdir -p %{buildroot}/opt/usr/share/feedback/sound/operation -mkdir -p %{buildroot}/opt/usr/share/feedback/haptic/default -mkdir -p %{buildroot}/opt/usr/share/feedback/haptic/touch - mkdir -p %{buildroot}%{_datadir}/license cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/%{name} @@ -83,38 +79,6 @@ cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/%{name} %postun -n libsvi -p /sbin/ldconfig -%post -n svi-data -ln -s %{_datadir}/feedback/sound/touch/key0.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/key1.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/key2.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/key3.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/key4.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/key5.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/key6.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/key7.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/key8.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/key9.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/keyasterisk.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/keysharp.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/sip.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/sip_backspace.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/touch/touch.wav /opt/usr/share/feedback/sound/touch -ln -s %{_datadir}/feedback/sound/operation/call_connect.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/call_disconnect.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/charger_connection.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/fully_charged.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/list_reorder.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/lock.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/low_battery.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/minute_minder.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/power_on.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/shutter.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/slider_sweep.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/unlock.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/sound/operation/volume_control.wav /opt/usr/share/feedback/sound/operation -ln -s %{_datadir}/feedback/haptic/default/Basic_call.tht /opt/usr/share/feedback/haptic/default -ln -s %{_datadir}/feedback/haptic/touch/touch.tht /opt/usr/share/feedback/haptic/touch - %postun -p /sbin/ldconfig %postun -n svi-data @@ -150,8 +114,3 @@ rm -rf /opt/usr/share/feedback/ %manifest %{name}.manifest %defattr(644,root,root,-) %{_datadir}/feedback/* -%defattr(666,app,app,-) -%dir /opt/usr/share/feedback/sound/touch -%dir /opt/usr/share/feedback/sound/operation -%dir /opt/usr/share/feedback/haptic/default -%dir /opt/usr/share/feedback/haptic/touch diff --git a/src/sound.c b/src/sound.c index 3cefac7..86a1241 100644 --- a/src/sound.c +++ b/src/sound.c @@ -17,6 +17,7 @@ #include <stdio.h> +#include <stdlib.h> #include <stdbool.h> #include <string.h> #include <unistd.h> @@ -32,11 +33,13 @@ #include "log.h" #include "devices.h" -#define FEEDBACK_SOUND_DIR FEEDBACK_DATA_DIR"/sound" -#define FEEDBACK_SOUND_TOUCH_DIR FEEDBACK_SOUND_DIR"/touch" -#define FEEDBACK_SOUND_OPER_DIR FEEDBACK_SOUND_DIR"/operation" +#define FEEDBACK_SOUND_DIR FEEDBACK_DATA_DIR"/sound" +#define FEEDBACK_SOUND_TOUCH_DIR "touch" +#define FEEDBACK_SOUND_OPER_DIR "operation" +#define SCRIPT_INIT_LINK_WAV FEEDBACK_ORIGIN_DATA_DIR"/init_wav_link.sh" +#define MAX_SOUND_FILE 50 -static const char* sound_file[] = { +static const char* sound_file_default[] = { /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : GENERAL */ FEEDBACK_SOUND_TOUCH_DIR"/touch.wav", /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : TEXT_NUMERIC_INPUT */ @@ -85,6 +88,7 @@ static const char* sound_file[] = { NULL, /* NOTIFICATION : ALARM : TIMER ALERT ON CALL */ NULL, + /* NOTIFICATION : GENERAL(TICKER/IM/SMS ETC) */ FEEDBACK_SOUND_OPER_DIR"/call_connect.wav", /* NOTIFICATION : GENERAL(TICKER/IM/SMS ETC) ALERT ON CALL */ @@ -124,6 +128,95 @@ static const char* sound_file[] = { /* OPERATION : VOLUME KEY */ FEEDBACK_SOUND_OPER_DIR"/volume_control.wav", }; +static char* sound_file[] = { + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : GENERAL */ + NULL, + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : TEXT_NUMERIC_INPUT */ + NULL, + NULL, + NULL, + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : DAILER */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + /* TOUCH : H/W OR SOFT TOUCH : HOLD(TAP & HOLD) */ + NULL, + /* TOUCH : H/W OR SOFT TOUCH : MULTI TAP */ + NULL, + /* TOUCH : H/W OR SOFT TOUCH : TAP */ + NULL, + /* TOUCH : H/W OR SOFT TOUCH : TAP & HOLD */ + NULL, + + /* NOTIFICATION : INCOMING : MESSAGE */ + NULL, + /* NOTIFICATION : INCOMING : MESSAGE ALERT ON CALL */ + NULL, + /* NOTIFICATION : INCOMING : EMAIL */ + NULL, + /* NOTIFICATION : INCOMING : EMAIL ALERT ON CALL */ + NULL, + /* NOTIFICATION : ALARM : WAKEUP */ + NULL, + /* NOTIFICATION : ALARM : WAKEUP ALERT ON CALL */ + NULL, + /* NOTIFICATION : ALARM : SCHEDULE */ + NULL, + /* NOTIFICATION : ALARM : SCHEDULE ALERT ON CALL */ + NULL, + /* NOTIFICATION : ALARM : TIMER */ + NULL, + /* NOTIFICATION : ALARM : TIMER ALERT ON CALL */ + NULL, + + /* NOTIFICATION : GENERAL(TICKER/IM/SMS ETC) */ + NULL, + /* NOTIFICATION : GENERAL(TICKER/IM/SMS ETC) ALERT ON CALL */ + NULL, + + /* OPERATION : POWER ON/OFF */ + NULL, + NULL, + /* OPERATION : CHARGECONN */ + NULL, + /* OPERATION : CHARGECONN ALERT ON CALL */ + NULL, + /* OPERATION : FULLCHAREGED */ + NULL, + /* OPERATION : FULLCHAREGED ALERT ON CALL */ + NULL, + /* OPERATION : LOW BATTERY */ + NULL, + /* OPERATION : LOW BATTERY ALERT ON CALL */ + NULL, + /* OPERATION : LOCK/UNLOCK */ + NULL, + NULL, + /* OPERATION : CALL CONNECT/ DISCONNECT */ + NULL, + NULL, + /* OPERATION : MINUTE MINDER */ + NULL, + /* OPERATION : VIBRATION */ + NULL, + /* OPERATION : CAMERA SHUTTER / SCREEN CAPTURE */ + NULL, + /* OPERATION : LIST RE-ORDER */ + NULL, + /* OPERATION : LIST SLIDER */ + NULL, + /* OPERATION : VOLUME KEY */ + NULL, +}; static int sndstatus; static int touch_sndstatus; @@ -219,8 +312,37 @@ static int restore_default_file(feedback_pattern_e pattern) return 0; } +static void link_init(void) +{ + struct stat sts; + int i,ret; + int directory = 0; + char default_path[PATH_MAX] = {0,}; + + /* Check if the directory exists; if not, create it and initialize it */ + ret = stat(FEEDBACK_DATA_DIR, &sts); + if (ret == -1 && errno == ENOENT){ + directory = 1; + } + + /* init of sound array and link*/ + strcat(default_path, FEEDBACK_ORIGIN_DATA_DIR); + for( i = 0 ; i< MAX_SOUND_FILE ; i++){ + if ( sound_file_default[i] != NULL ){ + sound_file[i] = strdup(tzplatform_mkpath3(TZ_USER_SHARE,"feedback/sound",sound_file_default[i])); + if (directory == 1){ + if (symlink(default_path,sound_file[i]) < 0){ + _W("change_symlink is failed"); + } + } + } + } +} + static void sound_init(void) { + link_init(); + /* Sound Init */ if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sndstatus) < 0) _W("VCONFKEY_SETAPPL_SOUND_STATUS_BOOL ==> FAIL!!"); @@ -239,10 +361,17 @@ static void sound_init(void) static void sound_exit(void) { + + int i; + /* remove watch */ vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, feedback_sndstatus_cb); vconf_ignore_key_changed(VCONFKEY_SOUND_STATUS, feedback_soundon_cb); vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, feedback_touch_sndstatus_cb); + + for(i = 0 ; i< MAX_SOUND_FILE ; i++){ + free(sound_file[i]); + } } static int sound_play(feedback_pattern_e pattern) diff --git a/src/vibrator.c b/src/vibrator.c index bdbd7ec..21897c8 100644 --- a/src/vibrator.c +++ b/src/vibrator.c @@ -34,12 +34,14 @@ #include "xmlparser.h" #define FEEDBACK_HAPTIC_DIR FEEDBACK_DATA_DIR"/haptic" -#define FEEDBACK_HAPTIC_TOUCH_DIR FEEDBACK_HAPTIC_DIR"/touch" -#define FEEDBACK_HAPTIC_OPER_DIR FEEDBACK_HAPTIC_DIR"/operation" -#define FEEDBACK_HAPTIC_NOTI_DIR FEEDBACK_HAPTIC_DIR"/notification" -#define FEEDBACK_HAPTIC_DEFAULT_DIR FEEDBACK_HAPTIC_DIR"/default" - -static const char* haptic_file[] = { +#define FEEDBACK_HAPTIC_TOUCH_DIR "touch" +#define FEEDBACK_HAPTIC_OPER_DIR "operation" +#define FEEDBACK_HAPTIC_NOTI_DIR "notification" +#define FEEDBACK_HAPTIC_DEFAULT_DIR "default" +#define SCRIPT_INIT_LINK_HAPTIC FEEDBACK_ORIGIN_DATA_DIR"/init_wav_link.sh" +#define MAX_HAPTIC_FILE 50 + +static const char* haptic_file_default[] = { /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : GENERAL */ NULL, /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : TEXT_NUMERIC_INPUT */ @@ -128,6 +130,95 @@ static const char* haptic_file[] = { NULL, }; +static char* haptic_file[] = { + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : GENERAL */ + NULL, + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : TEXT_NUMERIC_INPUT */ + NULL, + NULL, + NULL, + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : DAILER */ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + /* TOUCH : H/W OR SOFT TOUCH : HOLD(TAP & HOLD) */ + NULL, + /* TOUCH : H/W OR SOFT TOUCH : MULTI TAP */ + NULL, + /* TOUCH : H/W OR SOFT TOUCH : TAP */ + NULL, + /* TOUCH : H/W OR SOFT TOUCH : TAP & HOLD */ + NULL, + + /* NOTIFICATION : INCOMING : MESSAGE */ + NULL, + /* NOTIFICATION : INCOMING : MESSAGE ALERT ON CALL */ + NULL, + /* NOTIFICATION : INCOMING : EMAIL */ + NULL, + /* NOTIFICATION : INCOMING : EMAIL ALERT ON CALL */ + NULL, + /* NOTIFICATION : ALARM : WAKEUP */ + NULL, + /* NOTIFICATION : ALARM : WAKEUP ALERT ON CALL */ + NULL, + /* NOTIFICATION : ALARM : SCHEDULE */ + NULL, + /* NOTIFICATION : ALARM : SCHEDULE ALERT ON CALL */ + NULL, + /* NOTIFICATION : ALARM : TIMER */ + NULL, + /* NOTIFICATION : ALARM : TIMER ALERT ON CALL */ + NULL, + /* NOTIFICATION : GENERAL(TICKER/IM/SMS ETC) */ + NULL, + /* NOTIFICATION : GENERAL(TICKER/IM/SMS ETC) ALERT ON CALL */ + NULL, + + /* OPERATION : POWER ON/OFF */ + NULL, + NULL, + /* OPERATION : CHARGECONN */ + NULL, + /* OPERATION : CHARGECONN ALERT ON CALL */ + NULL, + /* OPERATION : FULLCHAREGED */ + NULL, + /* OPERATION : FULLCHAREGED ALERT ON CALL */ + NULL, + /* OPERATION : LOW BATTERY */ + NULL, + /* OPERATION : LOW BATTERY ALERT ON CALL */ + NULL, + /* OPERATION : LOCK/UNLOCK */ + NULL, + NULL, + /* OPERATION : CALL CONNECT/ DISCONNECT */ + NULL, + NULL, + /* OPERATION : MINUTE MINDER */ + NULL, + /* OPERATION : VIBRATION */ + NULL, + /* OPERATION : CAMERA SHUTTER / SCREEN CAPTURE */ + NULL, + /* OPERATION : LIST RE-ORDER */ + NULL, + /* OPERATION : LIST SLIDER */ + NULL, + /* OPERATION : VOLUME KEY */ + NULL, +}; + #define VIBRATION_XML "/usr/share/feedback/vibration.xml" static int vibstatus; @@ -273,10 +364,40 @@ static int restore_default_file(feedback_pattern_e pattern) return 0; } + +static void link_init(void) +{ + struct stat sts; + int i,ret; + int directory = 0; + char default_path[PATH_MAX] = {0,}; + + /* Check if the directory exists; if not, create it and initialize it */ + ret = stat(FEEDBACK_DATA_DIR, &sts); + if (ret == -1 && errno == ENOENT){ + directory = 1; + } + + /* init of haptic array and link*/ + strcat(default_path, FEEDBACK_ORIGIN_DATA_DIR); + for( i = 0 ; i< MAX_HAPTIC_FILE ; i++){ + if ( haptic_file_default[i] != NULL ){ + haptic_file[i] = strdup(tzplatform_mkpath3(TZ_USER_SHARE,"feedback/haptic",haptic_file_default[i])); + if (directory == 1){ + if (symlink(default_path,haptic_file[i]) < 0){ + _W("change_symlink is failed"); + } + } + } + } +} + static void vibrator_init(void) { int ret; + link_init(); + /* xml Init */ v_doc = xml_open(VIBRATION_XML); if (v_doc == NULL) { @@ -313,7 +434,7 @@ static void vibrator_init(void) static void vibrator_exit(void) { - int ret; + int ret,i; /* remove watch */ vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, feedback_vibstatus_cb); @@ -331,6 +452,13 @@ static void vibrator_exit(void) xml_close(v_doc); v_doc = NULL; } + + for( i = 0 ; i< MAX_HAPTIC_FILE ; i++) + { + if ( haptic_file[i] != NULL ) { + free (haptic_file[i]); + } + } } static int vibrator_play(feedback_pattern_e pattern) |