diff options
author | Jean-Benoit MARTIN <jean-benoit.martin@open.eurogiciel.org> | 2014-03-03 15:26:09 +0100 |
---|---|---|
committer | Jean-Benoit MARTIN <jean-benoit.martin@open.eurogiciel.org> | 2014-03-03 15:26:09 +0100 |
commit | 537a8118070f72b7976b6d8467aede81aadf8570 (patch) | |
tree | e96a57ded182e1824dbf1258b5a7db249a2902d1 /src | |
parent | 3b911306adbda98eb7693249dc9a434808602fb1 (diff) | |
download | libsvi-537a8118070f72b7976b6d8467aede81aadf8570.tar.gz libsvi-537a8118070f72b7976b6d8467aede81aadf8570.tar.bz2 libsvi-537a8118070f72b7976b6d8467aede81aadf8570.zip |
Remove hardcoded path for multiuser support
Bug-Tizen: PTREL-269
Change-Id: Idc1bf888a089daf1001bd98b1dafd57fc4a91245
Signed-off-by: Jean-Benoit MARTIN <jean-benoit.martin@open.eurogiciel.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/sound.c | 137 | ||||
-rw-r--r-- | src/vibrator.c | 142 |
2 files changed, 268 insertions, 11 deletions
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) |