diff options
author | jy910.yun <jy910.yun@samsung.com> | 2012-08-21 19:00:15 +0900 |
---|---|---|
committer | jy910.yun <jy910.yun@samsung.com> | 2012-08-21 19:00:15 +0900 |
commit | 6ec67742893ac1bcfe058348d7d149a52ead42b8 (patch) | |
tree | 545d4009ab3ec71c8c7782d1a54f812c4492b97b | |
parent | 6887ab18767b01b79bb358390ce6b99c712343a1 (diff) | |
download | libsvi-6ec67742893ac1bcfe058348d7d149a52ead42b8.tar.gz libsvi-6ec67742893ac1bcfe058348d7d149a52ead42b8.tar.bz2 libsvi-6ec67742893ac1bcfe058348d7d149a52ead42b8.zip |
patch tizen_2.0_build
-rwxr-xr-x | CMakeLists.txt | 21 | ||||
-rwxr-xr-x | SLP_SVI_PG.h | 4 | ||||
-rwxr-xr-x | debian/changelog | 256 | ||||
-rwxr-xr-x | include/svi-file.h | 180 | ||||
-rwxr-xr-x | include/svi-ids.h | 156 | ||||
-rwxr-xr-x | include/svi.h | 151 | ||||
-rw-r--r-- | libsvi.manifest | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | packaging/libsvi.spec | 36 | ||||
-rwxr-xr-x | svi.c | 517 | ||||
-rwxr-xr-x | test/svi_test.c | 65 |
10 files changed, 1018 insertions, 377 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e6345a..adcf457 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,16 @@ SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") SET(VERSION 0.1.4) SET(TESTSVI svi_test) -SET(SRCS svi.c) -SET(TEST_SRCS test/svi_test.c) +SET(SRCS + svi.c) + +SET(TEST_SRCS + test/svi_test.c) + +SET(HEADERS + SLP_SVI_PG.h + include/svi.h + include/svi-ids.h) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) @@ -28,6 +36,8 @@ ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"") ADD_DEFINITIONS("-DDATAFS=\"$ENV{DATADIR}\"") +#ADD_DEFINITIONS("-DENABLE_LED_NOTIFICATION") + ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION 0) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) @@ -40,9 +50,10 @@ TARGET_LINK_LIBRARIES(${TESTSVI} ${PROJECT_NAME}) CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) #CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY) +FOREACH(hfile ${HEADERS}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME}) +ENDFOREACH(hfile) + INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/svi.h DESTINATION include/${PROJECT_NAME}) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/svi-ids.h DESTINATION include/${PROJECT_NAME}) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/SLP_SVI_PG.h DESTINATION include/${PROJECT_NAME}) INSTALL(TARGETS ${TESTSVI} DESTINATION bin) diff --git a/SLP_SVI_PG.h b/SLP_SVI_PG.h index 77b7f97..5ab2fbd 100755 --- a/SLP_SVI_PG.h +++ b/SLP_SVI_PG.h @@ -159,8 +159,8 @@ if (r != SVI_SUCCESS){ SVI_VIB_OPERATION_POWER_ON SVI_VIB_OPERATION_POWER_OFF SVI_VIB_OPERATION_CHARGERCONN - SVI_VIB_OPERATION_FULLYCHARGED - SVI_VIB_OPERATION_LOTBATT + SVI_VIB_OPERATION_FULLCHARGED + SVI_VIB_OPERATION_LOWBATT SVI_VIB_OPERATION_LOCK SVI_VIB_OPERATION_UNLOCK SVI_VIB_OPERATION_CALLCONNECT diff --git a/debian/changelog b/debian/changelog index 8b62992..8a32fa1 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,257 @@ +libsvi (0.1.2-2) unstable; urgency=low + + * change SVI_VIB_OPERATION_LOTBATT to SVI_VIB_OPERATION_LOWBATT value + * Git: slp/pkgs/l/libsvi + * Tag: libsvi_0.1.2-2 + + -- Jiyoung Yun <jy910.yun@samsung.com> Fri, 03 Aug 2012 16:00:47 +0900 + +libsvi (0.1.1) unstable; urgency=low + + * add new enum value (incoming call04,05,06 / sip_backspace) + * add svi_set_path function for supporting changable svi resource feature + * Git: slp/pkgs/l/libsvi + * Tag: libsvi_0.1.1 + + -- Hyungdeuk Kim <hd3.kim@samsung.com> Thu, 28 Jun 2012 10:45:25 +0900 + libsvi (0.1.0-30) unstable; urgency=low - * Initial Release. - * Git: pkgs/l/libsvi + * upload changed spec file + * include sys/stat,sys/types header + * Git: slp/pkgs/l/libsvi * Tag: libsvi_0.1.0-30 - -- Sangil Yoon <si83.yoon@samsung.com> Wed, 07 Dec 2011 09:08:58 +0900 + -- Hyungdeuk Kim <hd3.kim@samsung.com> Fri, 16 Mar 2012 00:45:25 +0900 + +libsvi (0.1.0-29) unstable; urgency=low + + * fix svi.c(strncpy). change to buf size from strlen in strncpy. + * Git: slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-29 + + -- Sangil Yoon <si83.yoon@samsung.com> Fri, 16 Dec 2011 17:45:25 +0900 + +libsvi (0.1.0-28) unstable; urgency=low + + * Change API description in header file. + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-28 + + -- Sangil Yoon <si83.yoon@samsung.com> Tue, 06 Dec 2011 14:06:09 +0900 + +libsvi (0.1.0-27) unstable; urgency=low + + * Changed boilerplate + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-27 + + -- Sangil Yoon <si83.yoon@samsung.com> Fri, 02 Dec 2011 17:18:04 +0900 + +libsvi (0.1.0-26) unstable; urgency=low + + * change boilerplate. add check routine for file existence. + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-26 + + -- Sangil Yoon <seokkyu.jang@samsung.com> Thu, 20 Oct 2011 08:52:34 +0900 + +libsvi (0.1.0-25) unstable; urgency=low + + * Remove dead code for prevent fix Run 84, CID 57783. + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-25 + + -- Seokkyu Jang <seokkyu.jang@samsung.com> Mon, 05 Sep 2011 14:06:58 +0900 + +libsvi (0.1.0-24) unstable; urgency=low + + * Create svi_get_path() API. + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-24 + + -- Sangil Yoon <si83.yoon@samsung.com> Wed, 24 Aug 2011 15:34:20 +0900 + +libsvi (0.1.0-23) unstable; urgency=low + + * remove deprecated enum & changed directory path + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-23 + + -- Sangil Yoon <si83.yoon@samsung.com> Tue, 16 Aug 2011 19:32:23 +0900 + +libsvi (0.1.0-22) unstable; urgency=low + + * modify TETware TC Makefile. + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-22 + + -- Sangil Yoon <si83.yoon@samsung.com> Tue, 16 Aug 2011 11:15:37 +0900 + +libsvi (0.1.0-21) unstable; urgency=low + + * Rebuild libsvi for tagging + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-21 + + -- Sangil Yoon <si83.yoon@samsung.com> Thu, 11 Aug 2011 13:47:36 +0900 + +libsvi (0.1.0-20) unstable; urgency=low + + * Add deprecated enum for prevent build-break. fixed some bugs. + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-20 + + -- Sangil Yoon <si83.yoon@samsung.com> Wed, 03 Aug 2011 18:21:51 +0900 + +libsvi (0.1.0-19) unstable; urgency=low + + * Re-defined sound & vibration enum type. + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-19 + + -- Sangil Yoon <si83.yoon@samsung.com> Mon, 01 Aug 2011 13:24:46 +0900 + +libsvi (0.1.0-18) unstable; urgency=low + + * change AUTHORS, boilerplate + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-18 + + -- Sangil Yoon <si83.yoon@samsung.com> Wed, 13 Jul 2011 15:57:00 +0900 + +libsvi (0.1.0-17) unstable; urgency=low + + * Add boilerplate by code cleanup. change COPYING, AUTHORS + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-17 + + -- Sangil Yoon <si83.yoon@samsung.com> Wed, 13 Jul 2011 15:04:51 +0900 + +libsvi (0.1.0-16) unstable; urgency=low + + * Modify TC + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-16 + + -- Noha Park <noha.park@samsung.com> Wed, 16 Feb 2011 16:41:38 +0900 + +libsvi (0.1.0-15) unstable; urgency=low + + * Modify sound file path + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-15 + + -- Noha Park <noha.park@samsung.com> Wed, 12 Jan 2011 16:10:35 +0900 + +libsvi (0.1.0-14) unstable; urgency=low + + * Update sound resource enumeration + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-14 + + -- Noha Park <noha.park@samsung.com> Wed, 29 Dec 2010 11:31:49 +0900 + +libsvi (0.1.0-13) unstable; urgency=low + + * Remove svi-data dependency + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-13 + + -- Noha Park <noha.park@samsung.com> Wed, 15 Dec 2010 18:01:30 +0900 + +libsvi (0.1.0-12) unstable; urgency=low + + * Remove svi-data dependency + * Git: slp-source.sec.samsung.net:slp/pkgs/l/libsvi + * Tag: libsvi_0.1.0-12 + + -- Noha Park <noha.park@samsung.com> Wed, 15 Dec 2010 17:55:44 +0900 + +libsvi (0.1.0-11) unstable; urgency=low + + * Remove svi-data dependency + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-11 + + -- Noha Park <noha.park@samsung.com> Wed, 15 Dec 2010 17:49:37 +0900 + +libsvi (0.1.0-10) unstable; urgency=low + + * Modify volume type for sound play + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-10 + + -- Noha Park <noha.park@samsung.com> Fri, 03 Dec 2010 17:46:18 +0900 + +libsvi (0.1.0-9) unstable; urgency=low + + * Modify build dependency + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-9 + + -- Noha Park <noha.park@samsung.com> Thu, 18 Nov 2010 11:42:54 +0900 + +libsvi (0.1.0-8) unstable; urgency=low + + * Modify build dependency + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-8 + + -- Noha Park <noha.park@samsung.com> Thu, 18 Nov 2010 11:25:42 +0900 + +libsvi (0.1.0-7) unstable; urgency=low + + * Modify doxyzen + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-7 + + -- Noha Park <noha.park@samsung.com> Thu, 18 Nov 2010 08:42:03 +0900 + +libsvi (0.1.0-6) unstable; urgency=low + + * Modify doxyzen + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-6 + + -- Noha Park <noha.park@samsung.com> Wed, 17 Nov 2010 15:24:13 +0900 + +libsvi (0.1.0-5) unstable; urgency=low + + * Modify control file + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-5 + + -- Noha Park <noha.park@samsung.com> Mon, 15 Nov 2010 15:50:49 +0900 + +libsvi (0.1.0-4) unstable; urgency=low + + * remove data file + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-4 + + -- Noha Park <noha.park@samsung.com> Fri, 12 Nov 2010 11:18:01 +0900 + +libsvi (0.1.0-3) unstable; urgency=low + + * Modify git repo + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-3 + + -- Noha Park <noha.park@samsung.com> Wed, 10 Nov 2010 08:59:31 +0900 + +libsvi (0.1.0-2) unstable; urgency=low + + * Update vibration key + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-2 + + -- Noha Park <noha.park@samsung.com> Wed, 03 Nov 2010 19:58:11 +0900 + +libsvi (0.1.0-1) unstable; urgency=low + + * Initial Release. + * Git: 165.213.180.234:/git/slp/pkgs/libsvi + * Tag: libsvi_0.1.0-1 + + -- Noha Park <noha.park@samsung.com> Wed, 20 Oct 2010 11:32:44 +0900 diff --git a/include/svi-file.h b/include/svi-file.h new file mode 100755 index 0000000..990fc26 --- /dev/null +++ b/include/svi-file.h @@ -0,0 +1,180 @@ +/* + * libsvi + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jiyoung Yun <jy910.yun@samsung.com> + * + * 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 __SVI_FILE_H__ +#define __SVI_FILE_H__ + +#define SVI_DATA_DIR "/opt/share/svi/" +#define SVI_ORIGIN_DATA_DIR "/usr/share/svi/" + +#define SVI_SOUND_DIR SVI_DATA_DIR"sound/" +#define SVI_SOUND_TOUCH_DIR SVI_SOUND_DIR"touch/" +#define SVI_SOUND_OPER_DIR SVI_SOUND_DIR"operation/" + +#define SVI_HAPTIC_DIR SVI_DATA_DIR"haptic/" +#define SVI_HAPTIC_TOUCH_DIR SVI_HAPTIC_DIR"touch/" +#define SVI_HAPTIC_OPER_DIR SVI_HAPTIC_DIR"operation/" +#define SVI_HAPTIC_NOTI_DIR SVI_HAPTIC_DIR"notification/" + +const char* snd_file[] = { + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : GENERAL */ + SVI_SOUND_TOUCH_DIR"touch1.wav", + SVI_SOUND_TOUCH_DIR"touch2.wav", + SVI_SOUND_TOUCH_DIR"touch3.wav", + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : TEXT_NUMERIC_INPUT */ + SVI_SOUND_TOUCH_DIR"sip.wav", + SVI_SOUND_TOUCH_DIR"sip_backspace.wav", + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : DAILER */ + SVI_SOUND_TOUCH_DIR"key0.wav", + SVI_SOUND_TOUCH_DIR"key1.wav", + SVI_SOUND_TOUCH_DIR"key2.wav", + SVI_SOUND_TOUCH_DIR"key3.wav", + SVI_SOUND_TOUCH_DIR"key4.wav", + SVI_SOUND_TOUCH_DIR"key5.wav", + SVI_SOUND_TOUCH_DIR"key6.wav", + SVI_SOUND_TOUCH_DIR"key7.wav", + SVI_SOUND_TOUCH_DIR"key8.wav", + SVI_SOUND_TOUCH_DIR"key9.wav", + SVI_SOUND_TOUCH_DIR"keyasterisk.wav", + SVI_SOUND_TOUCH_DIR"keysharp.wav", + /* TOUCH : H/W OR SOFT TOUCH : HOLD(TAP & HOLD) */ + SVI_SOUND_TOUCH_DIR"hold.wav", + /* TOUCH : H/W OR SOFT TOUCH : MULTI TAP */ + SVI_SOUND_TOUCH_DIR"multi_tap.wav", + /* TOUCH : H/W OR SOFT TOUCH : TAP */ + SVI_SOUND_TOUCH_DIR"hw_tap.wav", + /* TOUCH : H/W OR SOFT TOUCH : TAP & HOLD */ + SVI_SOUND_TOUCH_DIR"hw_hold.wav", + + /* OPERATION : POWER ON/OFF */ + SVI_SOUND_OPER_DIR"power_on.wav", + SVI_SOUND_OPER_DIR"power_off.wav", + /* OPERATION : CHARGECONN */ + SVI_SOUND_OPER_DIR"charger_connection.wav", + /* OPERATION : FULLCHAREGED */ + SVI_SOUND_OPER_DIR"fully_charged.wav", + /* OPERATION : LOW BATTERY */ + SVI_SOUND_OPER_DIR"low_battery.wav", + /* OPERATION : LOCK/UNLOCK */ + SVI_SOUND_OPER_DIR"lock.wav", + SVI_SOUND_OPER_DIR"unlock.wav", + /* OPERATION : CALL CONNECT/ DISCONNECT */ + SVI_SOUND_OPER_DIR"call_connect.wav", + SVI_SOUND_OPER_DIR"call_disconnect.wav", + /* OPERATION : MINUTE MINDER */ + SVI_SOUND_OPER_DIR"minute_minder.wav", + /* OPERATION : VIBRATION */ + SVI_SOUND_OPER_DIR"vibration.wav", + /* OPERATION : BALLOON MESSAGE SEND/RECV */ + SVI_SOUND_OPER_DIR"new_chat.wav", + SVI_SOUND_OPER_DIR"sent_chat.wav", + /* OPERATION : ON/OFF SLIDER */ + SVI_SOUND_OPER_DIR"on_off_slider.wav", + /* OPERATION : CAMERA SHUTTER / SCREEN CAPTURE */ + SVI_SOUND_OPER_DIR"shutter.wav", + /* OPERATION : LIST RE-ORDER */ + SVI_SOUND_OPER_DIR"list_reorder.wav", + /* OPERATION : LIST SLIDER */ + SVI_SOUND_OPER_DIR"slider_sweep.wav" +}; + +/* led_file and haptic_file should be managed in the same order */ +const char* haptic_file[] = { + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : GENERAL */ + SVI_HAPTIC_TOUCH_DIR"touch.ivt", + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : TEXT_NUMERIC_INPUT */ + SVI_HAPTIC_TOUCH_DIR"sip.ivt", + SVI_HAPTIC_TOUCH_DIR"sip_backspace.ivt", + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : DAILER */ + SVI_HAPTIC_TOUCH_DIR"key0.ivt", + SVI_HAPTIC_TOUCH_DIR"key1.ivt", + SVI_HAPTIC_TOUCH_DIR"key2.ivt", + SVI_HAPTIC_TOUCH_DIR"key3.ivt", + SVI_HAPTIC_TOUCH_DIR"key4.ivt", + SVI_HAPTIC_TOUCH_DIR"key5.ivt", + SVI_HAPTIC_TOUCH_DIR"key6.ivt", + SVI_HAPTIC_TOUCH_DIR"key7.ivt", + SVI_HAPTIC_TOUCH_DIR"key8.ivt", + SVI_HAPTIC_TOUCH_DIR"key9.ivt", + SVI_HAPTIC_TOUCH_DIR"keyasterisk.ivt", + SVI_HAPTIC_TOUCH_DIR"keysharp.ivt", + /* TOUCH : H/W OR SOFT TOUCH : HOLD(TAP & HOLD) */ + SVI_HAPTIC_TOUCH_DIR"hold.ivt", + /* TOUCH : H/W OR SOFT TOUCH : MULTI TAP */ + SVI_HAPTIC_TOUCH_DIR"multi_tap.ivt", + /* TOUCH : H/W OR SOFT TOUCH : TAP */ + SVI_HAPTIC_TOUCH_DIR"hw_tap.ivt", + /* TOUCH : H/W OR SOFT TOUCH : TAP & HOLD */ + SVI_HAPTIC_TOUCH_DIR"hw_hold.ivt", + + /* NOTIFICATION : INCOMING : CALL */ + SVI_HAPTIC_NOTI_DIR"incoming_call1.ivt", + SVI_HAPTIC_NOTI_DIR"incoming_call2.ivt", + SVI_HAPTIC_NOTI_DIR"incoming_call3.ivt", + SVI_HAPTIC_NOTI_DIR"incoming_call4.ivt", + SVI_HAPTIC_NOTI_DIR"incoming_call5.ivt", + SVI_HAPTIC_NOTI_DIR"incoming_call6.ivt", + /* NOTIFICATION : INCOMING : MESSAGE */ + SVI_HAPTIC_NOTI_DIR"message.ivt", + /* NOTIFICATION : INCOMING : EMAIL */ + SVI_HAPTIC_NOTI_DIR"email.ivt", + /* NOTIFICATION : ALARM : WAKEUP */ + SVI_HAPTIC_NOTI_DIR"wakeup.ivt", + /* NOTIFICATION : ALARM : SCHEDULE */ + SVI_HAPTIC_NOTI_DIR"schedule.ivt", + /* NOTIFICATION : ALARM : TIMER */ + SVI_HAPTIC_NOTI_DIR"timer.ivt", + /* NOTIFICATION : GENERAL(TICKER/IM/SMS ETC) */ + SVI_HAPTIC_NOTI_DIR"general.ivt", + + /* OPERATION : POWER ON/OFF */ + SVI_HAPTIC_OPER_DIR"power_on.ivt", + SVI_HAPTIC_OPER_DIR"power_off.ivt", + /* OPERATION : CHARGECONN */ + SVI_HAPTIC_OPER_DIR"charger_connection.ivt", + /* OPERATION : FULLCHAREGED */ + SVI_HAPTIC_OPER_DIR"fully_charged.ivt", + /* OPERATION : LOW BATTERY */ + SVI_HAPTIC_OPER_DIR"low_battery.ivt", + /* OPERATION : LOCK/UNLOCK */ + SVI_HAPTIC_OPER_DIR"lock.ivt", + SVI_HAPTIC_OPER_DIR"unlock.ivt", + /* OPERATION : CALL CONNECT/ DISCONNECT */ + SVI_HAPTIC_OPER_DIR"call_connect.ivt", + SVI_HAPTIC_OPER_DIR"call_disconnect.ivt", + /* OPERATION : MINUTE MINDER */ + SVI_HAPTIC_OPER_DIR"minute_minder.ivt", + /* OPERATION : VIBRATION */ + SVI_HAPTIC_OPER_DIR"vibration.ivt", + /* OPERATION : BALLOON MESSAGE SEND/RECV */ + SVI_HAPTIC_OPER_DIR"new_chat.ivt", + SVI_HAPTIC_OPER_DIR"sent_chat.ivt", + /* OPERATION : ON/OFF SLIDER */ + SVI_HAPTIC_OPER_DIR"on_off_slider.ivt", + /* OPERATION : CAMERA SHUTTER / SCREEN CAPTURE */ + SVI_HAPTIC_OPER_DIR"shutter.ivt", + /* OPERATION : LIST RE-ORDER */ + SVI_SOUND_OPER_DIR"list_reorder.wav", + /* OPERATION : LIST SLIDER */ + SVI_SOUND_OPER_DIR"slider_sweep.wav" +}; + +#endif //__SVI_FILE_H__ diff --git a/include/svi-ids.h b/include/svi-ids.h index 0a004d2..f3dc2b0 100755 --- a/include/svi-ids.h +++ b/include/svi-ids.h @@ -23,62 +23,87 @@ #ifndef __SVI_IDS_H__ #define __SVI_IDS_H__ +typedef enum svi_type_t { + SVI_TYPE_NONE, + SVI_TYPE_SND, + SVI_TYPE_VIB, + SVI_TYPE_END +} svi_type; typedef enum sound_type_t { - SVI_SND_NONE = -1, + SVI_SND_NONE = -1, - SVI_SND_TOUCH_TOUCH1 = 0, - SVI_SND_TOUCH_TOUCH2, - SVI_SND_TOUCH_TOUCH3, - SVI_SND_TOUCH_SIP, - SVI_SND_TOUCH_HOLD, - SVI_SND_TOUCH_MULTI_TAP, - SVI_SND_TOUCH_HW_TAP, - SVI_SND_TOUCH_HW_HOLD, - - SVI_SND_TOUCH_KEY00, - SVI_SND_TOUCH_KEY01, - SVI_SND_TOUCH_KEY02, - SVI_SND_TOUCH_KEY03, - SVI_SND_TOUCH_KEY04, - SVI_SND_TOUCH_KEY05, - SVI_SND_TOUCH_KEY06, - SVI_SND_TOUCH_KEY07, - SVI_SND_TOUCH_KEY08, - SVI_SND_TOUCH_KEY09, - SVI_SND_TOUCH_KEY_STAR, - SVI_SND_TOUCH_KEY_SHARP, - - SVI_SND_OPERATION_POWERON, - SVI_SND_OPERATION_POWEROFF, - SVI_SND_OPERATION_CHARGERCONN, - SVI_SND_OPERATION_FULLCHARGED, - SVI_SND_OPERATION_LOWBATT, - SVI_SND_OPERATION_LOCK, - SVI_SND_OPERATION_UNLOCK, - SVI_SND_OPERATION_CALLCONN, - SVI_SND_OPERATION_CALLDISCONN, - SVI_SND_OPERATION_MINUTE_MINDER, - SVI_SND_OPERATION_VIBRATION, - SVI_SND_OPERATION_NEWCHAT, - SVI_SND_OPERATION_SENTCHAT, - SVI_SND_OPERATION_ONOFFSLIDER, - SVI_SND_OPERATION_SCRCAPTURE, - - SVI_SND_ENUM_END = 100 + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : GENERAL */ + SVI_SND_TOUCH_TOUCH1 = 0, + SVI_SND_TOUCH_TOUCH2, + SVI_SND_TOUCH_TOUCH3, + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : TEXT_NUMERIC_INPUT */ + SVI_SND_TOUCH_SIP, + SVI_SND_TOUCH_SIP_BACKSPACE, + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : DAILER */ + SVI_SND_TOUCH_KEY00, + SVI_SND_TOUCH_KEY01, + SVI_SND_TOUCH_KEY02, + SVI_SND_TOUCH_KEY03, + SVI_SND_TOUCH_KEY04, + SVI_SND_TOUCH_KEY05, + SVI_SND_TOUCH_KEY06, + SVI_SND_TOUCH_KEY07, + SVI_SND_TOUCH_KEY08, + SVI_SND_TOUCH_KEY09, + SVI_SND_TOUCH_KEY_STAR, + SVI_SND_TOUCH_KEY_SHARP, + /* TOUCH : H/W OR SOFT TOUCH : HOLD(TAP & HOLD) */ + SVI_SND_TOUCH_HOLD, + /* TOUCH : H/W OR SOFT TOUCH : MULTI TAP */ + SVI_SND_TOUCH_MULTI_TAP, + /* TOUCH : H/W OR SOFT TOUCH : TAP */ + SVI_SND_TOUCH_HW_TAP, + /* TOUCH : H/W OR SOFT TOUCH : TAP & HOLD */ + SVI_SND_TOUCH_HW_HOLD, + /* OPERATION : POWER ON/OFF */ + SVI_SND_OPERATION_POWERON, + SVI_SND_OPERATION_POWEROFF, + /* OPERATION : CHARGECONN */ + SVI_SND_OPERATION_CHARGERCONN, + /* OPERATION : FULLCHAREGED */ + SVI_SND_OPERATION_FULLCHARGED, + /* OPERATION : LOW BATTERY */ + SVI_SND_OPERATION_LOWBATT, + /* OPERATION : LOCK/UNLOCK */ + SVI_SND_OPERATION_LOCK, + SVI_SND_OPERATION_UNLOCK, + /* OPERATION : CALL CONNECT/ DISCONNECT */ + SVI_SND_OPERATION_CALLCONN, + SVI_SND_OPERATION_CALLDISCONN, + /* OPERATION : MINUTE MINDER */ + SVI_SND_OPERATION_MINUTE_MINDER, + /* OPERATION : VIBRATION */ + SVI_SND_OPERATION_VIBRATION, + /* OPERATION : BALLOON MESSAGE SEND/RECV */ + SVI_SND_OPERATION_NEWCHAT, + SVI_SND_OPERATION_SENTCHAT, + /* OPERATION : ON/OFF SLIDER */ + SVI_SND_OPERATION_ONOFFSLIDER, + /* OPERATION : CAMERA SHUTTER / SCREEN CAPTURE */ + SVI_SND_OPERATION_SCRCAPTURE, + /* OPERATION : LIST RE-ORDER */ + SVI_SND_OPERATION_LIST_REORDER, + /* OPERATION : LIST SLIDER */ + SVI_SND_OPERATION_SLIDER_SWEEP, + SVI_SND_ENUM_END } sound_type; typedef enum vibration_type_t { SVI_VIB_NONE = -1, + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : GENERAL */ SVI_VIB_TOUCH_TOUCH = 0, + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : TEXT_NUMERIC_INPUT */ SVI_VIB_TOUCH_SIP, - SVI_VIB_TOUCH_HOLD, - SVI_VIB_TOUCH_MULTI_TAP, - SVI_VIB_TOUCH_HW_TAP, - SVI_VIB_TOUCH_HW_HOLD, - + SVI_VIB_TOUCH_SIP_BACKSPACE, + /* TOUCH : SCREEN TOUCH : TAP(TOUCH & RELEASE) : DAILER */ SVI_VIB_TOUCH_KEY00, SVI_VIB_TOUCH_KEY01, SVI_VIB_TOUCH_KEY02, @@ -91,34 +116,67 @@ typedef enum vibration_type_t { SVI_VIB_TOUCH_KEY09, SVI_VIB_TOUCH_KEY_STAR, SVI_VIB_TOUCH_KEY_SHARP, + /* TOUCH : H/W OR SOFT TOUCH : HOLD(TAP & HOLD) */ + SVI_VIB_TOUCH_HOLD, + /* TOUCH : H/W OR SOFT TOUCH : MULTI TAP */ + SVI_VIB_TOUCH_MULTI_TAP, + /* TOUCH : H/W OR SOFT TOUCH : TAP */ + SVI_VIB_TOUCH_HW_TAP, + /* TOUCH : H/W OR SOFT TOUCH : TAP & HOLD */ + SVI_VIB_TOUCH_HW_HOLD, + /* NOTIFICATION : INCOMING : CALL */ SVI_VIB_NOTIFICATION_INCOMING_CALL01, SVI_VIB_NOTIFICATION_INCOMING_CALL02, SVI_VIB_NOTIFICATION_INCOMING_CALL03, + SVI_VIB_NOTIFICATION_INCOMING_CALL04, + SVI_VIB_NOTIFICATION_INCOMING_CALL05, + SVI_VIB_NOTIFICATION_INCOMING_CALL06, + /* NOTIFICATION : INCOMING : MESSAGE */ SVI_VIB_NOTIFICATION_MESSAGE, + /* NOTIFICATION : INCOMING : EMAIL */ SVI_VIB_NOTIFICATION_EMAIL, + /* NOTIFICATION : ALARM : WAKEUP */ SVI_VIB_NOTIFICATION_WAKEUP, + /* NOTIFICATION : ALARM : SCHEDULE */ SVI_VIB_NOTIFICATION_SCHEDULE, + /* NOTIFICATION : ALARM : TIMER */ SVI_VIB_NOTIFICATION_TIMER, + /* NOTIFICATION : GENERAL(TICKER/IM/SMS ETC) */ SVI_VIB_NOTIFICATION_GENERAL, - + + /* OPERATION : POWER ON/OFF */ SVI_VIB_OPERATION_POWER_ON, SVI_VIB_OPERATION_POWER_OFF, + /* OPERATION : CHARGECONN */ SVI_VIB_OPERATION_CHARGERCONN, - SVI_VIB_OPERATION_FULLYCHARGED, - SVI_VIB_OPERATION_LOTBATT, + /* OPERATION : FULLCHAREGED */ + SVI_VIB_OPERATION_FULLCHARGED, + /* OPERATION : LOW BATTERY */ + SVI_VIB_OPERATION_LOWBATT, + /* OPERATION : LOCK/UNLOCK */ SVI_VIB_OPERATION_LOCK, SVI_VIB_OPERATION_UNLOCK, + /* OPERATION : CALL CONNECT/ DISCONNECT */ SVI_VIB_OPERATION_CALLCONNECT, SVI_VIB_OPERATION_DISCALLCONNECT, + /* OPERATION : MINUTE MINDER */ SVI_VIB_OPERATION_MINUTEMINDER, + /* OPERATION : VIBRATION */ SVI_VIB_OPERATION_VIBRATION, + /* OPERATION : BALLOON MESSAGE SEND/RECV */ SVI_VIB_OPERATION_NEWCHAT, SVI_VIB_OPERATION_SENDCHAT, + /* OPERATION : ON/OFF SLIDER */ SVI_VIB_OPERATION_ONOFFSLIDER, + /* OPERATION : CAMERA SHUTTER / SCREEN CAPTURE */ SVI_VIB_OPERATION_SHUTTER, + /* OPERATION : LIST RE-ORDER */ + SVI_VIB_OPERATION_LIST_REORDER, + /* OPERATION : LIST SLIDER */ + SVI_VIB_OPERATION_SLIDER_SWEEP, - SVI_VIB_ENUM_END = 100 + SVI_VIB_ENUM_END } vibration_type; diff --git a/include/svi.h b/include/svi.h index 34c97c8..bdea270 100755 --- a/include/svi.h +++ b/include/svi.h @@ -27,7 +27,7 @@ * @addtogroup APPLICATION_FRAMEWORK * @{ * - * @defgroup SVI SVI + * @defgroup SVI SVI * @brief A library for playing sound and vibration. * * @section Header To use Them: @@ -39,6 +39,7 @@ * @code SVI_VIB_TOUCH_TOUCH SVI_VIB_TOUCH_SIP + SVI_VIB_TOUCH_SIP_BACKSPACE SVI_VIB_TOUCH_HOLD SVI_VIB_TOUCH_MULTI_TAP SVI_VIB_TOUCH_HW_TAP @@ -66,12 +67,12 @@ SVI_VIB_NOTIFICATION_SCHEDULE SVI_VIB_NOTIFICATION_TIMER SVI_VIB_NOTIFICATION_GENERAL - + SVI_VIB_OPERATION_POWER_ON SVI_VIB_OPERATION_POWER_OFF SVI_VIB_OPERATION_CHARGERCONN - SVI_VIB_OPERATION_FULLYCHARGED - SVI_VIB_OPERATION_LOTBATT + SVI_VIB_OPERATION_FULLCHARGED + SVI_VIB_OPERATION_LOWBATT SVI_VIB_OPERATION_LOCK SVI_VIB_OPERATION_UNLOCK SVI_VIB_OPERATION_CALLCONNECT @@ -82,6 +83,8 @@ SVI_VIB_OPERATION_SENDCHAT SVI_VIB_OPERATION_ONOFFSLIDER SVI_VIB_OPERATION_SHUTTER + SVI_VIB_OPERATION_LIST_REORDER + SVI_VIB_OPERATION_SLIDER_SWEEP * @endcode * * @section Snd_IDs Sound IDs @@ -90,6 +93,7 @@ SVI_SND_TOUCH_TOUCH2 SVI_SND_TOUCH_TOUCH3 SVI_SND_TOUCH_SIP + SVI_SND_TOUCH_SIP_BACKSPACE SVI_SND_TOUCH_HOLD SVI_SND_TOUCH_MULTI_TAP SVI_SND_TOUCH_HW_TAP @@ -123,6 +127,8 @@ SVI_SND_OPERATION_SENTCHAT SVI_SND_OPERATION_ONOFFSLIDER SVI_SND_OPERATION_SCRCAPTURE + SVI_SND_OPERATION_LIST_REORDER + SVI_SND_OPERATION_SLIDER_SWEEP * @endcode */ @@ -141,9 +147,6 @@ extern "C" #define SVI_SUCCESS 0 #define SVI_ERROR -1 -#define SVI_TYPE_SND 0 -#define SVI_TYPE_VIB 1 - /** * \par Description: * Initialize audio ui library.\n @@ -171,7 +174,7 @@ extern "C" * External Apps. * * \par Related functions: - * svi_fini() + * svi_fini() * * \par Known issues/bugs: * None @@ -197,23 +200,23 @@ extern "C" * int handle = 0; * * r = svi_init(&handle); //Initialize SVI - * + * * if ( r != SVI_SUCCESS ) { - * printf("Cannot initialize SVI.\n"); + * printf("Cannot initialize SVI.\n"); * svi_fini(handle); //If initialization is failed, finalize SVI directly * } else { * - * r = svi_play (handle, SVI_VIB_TOUCH_TOUCH, SVI_SND_TOUCH_TOUCH1); //Play sound and vibration + * r = svi_play (handle, SVI_VIB_TOUCH_TOUCH, SVI_SND_TOUCH_TOUCH1); //Play sound and vibration * if (r != SVI_SUCCESS) { * printf("Cannot play sound or vibration.\n"); * } * * r = svi_fini(handle); //Finalize SVI * if (r != SVI_SUCCESS) { - * printf("Cannot close SVI.\n"); + * printf("Cannot close SVI.\n"); * } * } - * + * * ... * \endcode */ @@ -247,7 +250,7 @@ int svi_init(int *handle); * External Apps. * * \par Related functions: - * svi_init() + * svi_init() * * \par Known issues/bugs: * None @@ -273,9 +276,9 @@ int svi_init(int *handle); * int handle = 0; * * r = svi_init(&handle); //Initialize SVI - * + * * if ( r != SVI_SUCCESS ) { - * printf("Cannot initialize SVI.\n"); + * printf("Cannot initialize SVI.\n"); * svi_fini(handle); //If initialization is failed, finalize SVI directly * } else { * @@ -286,10 +289,10 @@ int svi_init(int *handle); * * r = svi_fini(handle); //Finalize SVI * if (r != SVI_SUCCESS) { - * printf("Cannot close SVI.\n"); + * printf("Cannot close SVI.\n"); * } * } - * + * * ... * \endcode */ @@ -348,25 +351,25 @@ int svi_fini(int handle); * ... * int r = 0; * int handle = 0; - * + * * r = svi_init(&handle); //Initialize SVI - * + * * if ( r != SVI_SUCCESS ) { - * printf("Cannot initialize SVI.\n"); + * printf("Cannot initialize SVI.\n"); * svi_fini(handle); //If initialization is failed, finalize SVI directly * } else { * - * r = svi_play_sound (handle, SVI_SND_TOUCH_TOUCH1); //Play sound + * r = svi_play_sound (handle, SVI_SND_TOUCH_TOUCH1); //Play sound * if (r != SVI_SUCCESS) { * printf("Cannot play sound or vibration.\n"); * } * * r = svi_fini(handle); //Finalize SVI * if (r != SVI_SUCCESS) { - * printf("Cannot close SVI.\n"); + * printf("Cannot close SVI.\n"); * } * } - * + * * ... * \endcode */ @@ -424,11 +427,11 @@ int svi_play_sound(int handle, sound_type sound_key); * ... * int r = 0; * int handle = 0; - * + * * r = svi_init(&handle); //Initialize SVI - * + * * if ( r != SVI_SUCCESS ) { - * printf("Cannot initialize SVI.\n"); + * printf("Cannot initialize SVI.\n"); * svi_fini(handle); //If initialization is failed, finalize SVI directly * } else { * @@ -439,10 +442,10 @@ int svi_play_sound(int handle, sound_type sound_key); * * r = svi_fini(handle); //Finalize SVI * if (r != SVI_SUCCESS) { - * printf("Cannot close SVI.\n"); + * printf("Cannot close SVI.\n"); * } * } - * + * * ... * \endcode */ @@ -501,11 +504,11 @@ int svi_play_vib(int handle, vibration_type vibration_key); * ... * int r = 0; * int handle = 0; - * + * * r = svi_init(&handle); //Initialize SVI - * + * * if ( r != SVI_SUCCESS ) { - * printf("Cannot initialize SVI.\n"); + * printf("Cannot initialize SVI.\n"); * svi_fini(handle); //If initialization is failed, finalize SVI directly. * } else { * @@ -516,10 +519,10 @@ int svi_play_vib(int handle, vibration_type vibration_key); * * r = svi_fini(handle); //Finalize SVI * if (r != SVI_SUCCESS) { - * printf("Cannot close SVI.\n"); + * printf("Cannot close SVI.\n"); * } * } - * + * * ... * \endcode */ @@ -528,13 +531,77 @@ int svi_play(int handle, vibration_type vibration_key, sound_type sound_key); /** * \par Description: - * Get filepath from predefined sound & vibration.\n + * Set filepath for sound & vibration pattern.\n * * \par Purpose: - * This API is used for getting filepath of predefined sound or vibration. + * This API is used for setting filepath of sound & vibration pattern. * * \par Typical use case: - * If user want to get filepath of sound or vibration for predefined simple pattern, he(or she) can use this API. + * In case that user want to set filepath of sound or vibration pattern. + * + * \par Method of function operation: + * SVI uses multimedia sound library and device manager library. + * + * \par Important notes: + * None + * + * \param svi_type [in] svi_type(sound, vibration). + * \param svi_enum [in] predefined enum_type. + * \param path [in] file path. + * + * \return Return Type (int) \n + * - SVI_SUCCESS - \n + * - SVI_ERROR - \n + * + * \par Prospective clients: + * External Apps. + * + * \par Related functions: + * None + * + * \par Known issues/bugs: + * None + * + * \pre + * None + * + * \post + * None + * + * \see + * None + * + * \remarks + * None + * + * \par Sample code: + * \code + * ... + * #include <svi.h> + * ... + * int r = 0; + * char *path[512] = "/mnt/ums/sound/sound.wav"; + * + * r = svi_set_path(SVI_SND_TYPE, SVI_SND_TOUCH_TOUCH1, path); + * + * if ( r != SVI_SUCCESS ) { + * printf("Fail.\n"); + * } + * ... + * \endcode + */ +/*================================================================================================*/ +int svi_set_path(int svi_type, int svi_enum, char* path); + +/** + * \par Description: + * Get filepath for sound & vibration pattern.\n + * + * \par Purpose: + * This API is used for getting filepath of sound & vibration pattern. + * + * \par Typical use case: + * In case that user want to get filepath of sound or vibration pattern. * * \par Method of function operation: * SVI uses multimedia sound library and device manager library. @@ -578,13 +645,13 @@ int svi_play(int handle, vibration_type vibration_key, sound_type sound_key); * #include <svi.h> * ... * int r = 0; - * char buf[256] = {0,}; - * + * char buf[512] = {0,}; + * * r = svi_get_path(SVI_SND_TYPE, SVI_SND_TOUCH_TOUCH1, buf, sizeof(buf)); - * + * * if ( r != SVI_SUCCESS ) { - * printf("Fail.\n"); - * } + * printf("Fail.\n"); + * } * ... * \endcode */ diff --git a/libsvi.manifest b/libsvi.manifest new file mode 100644 index 0000000..f13bba5 --- /dev/null +++ b/libsvi.manifest @@ -0,0 +1,9 @@ +<manifest> + <request> + <domain name="_"/> + </request> + <assign> + <filesystem path="/usr/bin/svi_test" exec_label="_"/> + </assign> +</manifest> + diff --git a/packaging/libsvi.spec b/packaging/libsvi.spec index c899c89..800d25a 100644..100755 --- a/packaging/libsvi.spec +++ b/packaging/libsvi.spec @@ -1,7 +1,7 @@ Name: libsvi Summary: SVI -Version: 0.1.0 -Release: 30 +Version: 0.1.2 +Release: 7 Group: System/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz @@ -49,3 +49,35 @@ rm -rf %{buildroot} %{_libdir}/libsvi.so %{_libdir}/pkgconfig/svi.pc +%changelog +* Mon Aug 20 2012 - Jiyoung Yun <jy910.yun@samsung.com> +- Re-uploaded because prev commit is not supply on tizen_build project +- Tag : libsvi_0.1.2-7 + +* Fri Aug 17 2012 - Jiyoung Yun <jy910.yun@samsung.com> +- separate 2.0_beta branch from master +- Remove code regarding led notification that is product feature +- Tag : libsvi_0.1.2-6 + +* Tue Aug 14 2012 - Jiyoung Yun <jy910.yun@samsung.com> +- led bug fix +- svi_play_led function is called twice +- Tag : libsvi_0.1.2-5 + +* Tue Aug 14 2012 - Jiyoung Yun <jy910.yun@samsung.com> +- Code merge from old git +- Tag : libsvi_0.1.2-4 + +* Mon Aug 06 2012 - Jiyoung Yun <jy910.yun@samsung.com> +- Add new code for support LED notification +- Add svi-led.c file to convert ivt to led file +- Change SVI_VIB_OPERATION_FULLYCHARGED to SVI_VIB_OPERATION_FULLCHARGED enum value +- Tag : libsvi_0.1.2-3 + +* Fri Aug 03 2012 - Jiyoung Yun <jy910.yun@samsung.com> +- Change SVI_VIB_OPERATION_LOTBATT to SVI_VIB_OPERATION_LOWBATT value +- Tag : libsvi_0.1.2-2 + +* Fri Jul 13 2012 - Hyungdeuk Kim <hd3.kim@samsung.com> +- Add 2 new enum type defined by ux 0627 document +- remove temp code for error handling @@ -3,8 +3,7 @@ * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Seokkyu Jang <seokkyu.jang@samsung.com> - * Contact: Sangil Yoon <si83.yoon@samsung.com> + * Contact: Hyungdeuk Kim <hd3.kim@samsung.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +21,10 @@ #define _GNU_SOURCE +#include <stdlib.h> #include <stdio.h> +#include <unistd.h> +#include <string.h> #include <sys/stat.h> #include <sys/types.h> @@ -30,28 +32,20 @@ #include <vconf.h> #include <devman_haptic.h> -#include <svi.h> -#include "svi-log.h" - -#define SVI_DATA_DIR "/usr/share/svi" -#define SVI_SOUND_DIR SVI_DATA_DIR"/sound" -#define SVI_HAPTIC_DIR SVI_DATA_DIR"/haptic" - -#define SOUND_TOUCH_DIR SVI_SOUND_DIR"/touch" -#define HAPTIC_TOUCH_DIR SVI_HAPTIC_DIR"/touch" +#include <fcntl.h> +#include <errno.h> -#define HAPTIC_NOTI_DIR SVI_HAPTIC_DIR"/notification" - -#define SOUND_OPER_DIR SVI_SOUND_DIR"/operation" -#define HAPTIC_OPER_DIR SVI_HAPTIC_DIR"/operation" +#include "svi.h" +#include "svi-log.h" +#include "svi-file.h" +#define SVI_RETRY_CNT 1 +#define MAX_FILE_PATH 512 #ifndef API #define API __attribute__ ((visibility("default"))) #endif -//#define PERFORM_CHECK - #ifdef PERFORM_CHECK static long long ms = 0; @@ -63,10 +57,10 @@ static long long ms = 0; if (ms == 0) { \ gettimeofday(&tv, NULL); \ ms = MICROSECONDS(tv); \ - fprintf(stderr, "%s start time : %lld\n", __func__, ms); \ + fprintf(stderr, "%s start time : %lld", __func__, ms); \ } else { \ gettimeofday(&tv, NULL); \ - fprintf(stderr, "%s elapsed time : %lld\n", __func__, MICROSECONDS(tv) - ms); \ + fprintf(stderr, "%s elapsed time : %lld", __func__, MICROSECONDS(tv) - ms); \ ms = 0; \ } \ } while(0) @@ -74,135 +68,46 @@ static long long ms = 0; #define ESTIMATE_PERFORMANCE() #endif -const char* snd_file[] = { - SOUND_TOUCH_DIR"/touch1.wav", - SOUND_TOUCH_DIR"/touch2.wav", - SOUND_TOUCH_DIR"/touch3.wav", - SOUND_TOUCH_DIR"/sip.wav", - SOUND_TOUCH_DIR"/hold.wav", - SOUND_TOUCH_DIR"/multi_tap.wav", - SOUND_TOUCH_DIR"/hw_tap.wav", - SOUND_TOUCH_DIR"/hw_hold.wav", - - SOUND_TOUCH_DIR"/key0.wav", - SOUND_TOUCH_DIR"/key1.wav", - SOUND_TOUCH_DIR"/key2.wav", - SOUND_TOUCH_DIR"/key3.wav", - SOUND_TOUCH_DIR"/key4.wav", - SOUND_TOUCH_DIR"/key5.wav", - SOUND_TOUCH_DIR"/key6.wav", - SOUND_TOUCH_DIR"/key7.wav", - SOUND_TOUCH_DIR"/key8.wav", - SOUND_TOUCH_DIR"/key9.wav", - SOUND_TOUCH_DIR"/keyasterisk.wav", - SOUND_TOUCH_DIR"/keysharp.wav", - - SOUND_OPER_DIR"/power_on.wav", - SOUND_OPER_DIR"/power_off.wav", - SOUND_OPER_DIR"/charger_connection.wav", - SOUND_OPER_DIR"/fully_charged.wav", - SOUND_OPER_DIR"/low_battery.wav", - SOUND_OPER_DIR"/lock.wav", - SOUND_OPER_DIR"/unlock.wav", - SOUND_OPER_DIR"/call_connect.wav", - SOUND_OPER_DIR"/call_disconnect.wav", - SOUND_OPER_DIR"/minute_minder.wav", - SOUND_OPER_DIR"/vibration.wav", - SOUND_OPER_DIR"/new_chat.wav", - SOUND_OPER_DIR"/sent_chat.wav", - SOUND_OPER_DIR"/on_off_slider.wav", - SOUND_OPER_DIR"/shutter.wav", -}; - -const char* haptic_file[] = { - HAPTIC_TOUCH_DIR"/touch.ivt", - HAPTIC_TOUCH_DIR"/sip.ivt", - HAPTIC_TOUCH_DIR"/hold.ivt", - HAPTIC_TOUCH_DIR"/multi_tap.ivt", - HAPTIC_TOUCH_DIR"/hw_tap.ivt", - HAPTIC_TOUCH_DIR"/hw_hold.ivt", - - HAPTIC_TOUCH_DIR"/key0.ivt", - HAPTIC_TOUCH_DIR"/key1.ivt", - HAPTIC_TOUCH_DIR"/key2.ivt", - HAPTIC_TOUCH_DIR"/key3.ivt", - HAPTIC_TOUCH_DIR"/key4.ivt", - HAPTIC_TOUCH_DIR"/key5.ivt", - HAPTIC_TOUCH_DIR"/key6.ivt", - HAPTIC_TOUCH_DIR"/key7.ivt", - HAPTIC_TOUCH_DIR"/key8.ivt", - HAPTIC_TOUCH_DIR"/key9.ivt", - HAPTIC_TOUCH_DIR"/keyasterisk.ivt", - HAPTIC_TOUCH_DIR"/keysharp.ivt", - - HAPTIC_NOTI_DIR"/incoming_call1.ivt", - HAPTIC_NOTI_DIR"/incoming_call2.ivt", - HAPTIC_NOTI_DIR"/incoming_call3.ivt", - HAPTIC_NOTI_DIR"/message.ivt", - HAPTIC_NOTI_DIR"/email.ivt", - HAPTIC_NOTI_DIR"/wakeup.ivt", - HAPTIC_NOTI_DIR"/schedule.ivt", - HAPTIC_NOTI_DIR"/timer.ivt", - HAPTIC_NOTI_DIR"/general.ivt", - - HAPTIC_OPER_DIR"/power_on.ivt", - HAPTIC_OPER_DIR"/power_off.ivt", - HAPTIC_OPER_DIR"/charger_connection.ivt", - HAPTIC_OPER_DIR"/fully_charged.ivt", - HAPTIC_OPER_DIR"/low_battery.ivt", - HAPTIC_OPER_DIR"/lock.ivt", - HAPTIC_OPER_DIR"/unlock.ivt", - HAPTIC_OPER_DIR"/call_connect.ivt", - HAPTIC_OPER_DIR"/call_disconnect.ivt", - HAPTIC_OPER_DIR"/minute_minder.ivt", - HAPTIC_OPER_DIR"/vibration.ivt", - HAPTIC_OPER_DIR"/new_chat.ivt", - HAPTIC_OPER_DIR"/sent_chat.ivt", - HAPTIC_OPER_DIR"/on_off_slider.ivt", - HAPTIC_OPER_DIR"/shutter.ivt", -}; - static int soundon = -1; static int vib_level = -1; static int sndstatus = -1; static int vibstatus = -1; -void soundon_cb(keynode_t *key, void* data) +static void __svi_soundon_cb(keynode_t *key, void* data) { soundon = vconf_keynode_get_bool(key); - SVILOG("[[[[[[[[[[[[[[soundon changed!! new soundon => %d\n", soundon); + SVILOG("[[[[[[[[[[[[[[soundon changed!! new soundon => %d", soundon); return; } -void vib_cb(keynode_t *key, void* data) +static void __svi_vib_cb(keynode_t *key, void* data) { vib_level = vconf_keynode_get_int(key); - SVILOG("[[[[[[[[[[[[[[vib_level changed!! new vib_level => %d\n", vib_level); + SVILOG("[[[[[[[[[[[[[[vib_level changed!! new vib_level => %d", vib_level); return; } -void sndstatus_cb(keynode_t *key, void* data) +static void __svi_sndstatus_cb(keynode_t *key, void* data) { sndstatus = vconf_keynode_get_int(key); - SVILOG("[[[[[[[[[[[[[[sndstatus changed!! new sndstatus => %d\n", sndstatus); + SVILOG("[[[[[[[[[[[[[[sndstatus changed!! new sndstatus => %d", sndstatus); return; } -void vibstatus_cb(keynode_t *key, void* data) +static void __svi_vibstatus_cb(keynode_t *key, void* data) { vibstatus = vconf_keynode_get_bool(key); - SVILOG("[[[[[[[[[[[[[[vibstatus changed!! new vibstatus => %d\n", vibstatus); + SVILOG("[[[[[[[[[[[[[[vibstatus changed!! new vibstatus => %d", vibstatus); return; } - -volume_type_t get_volume_type(sound_type sound_key) +static volume_type_t __svi_get_volume_type(sound_type sound_key) { volume_type_t type = VOLUME_TYPE_SYSTEM; @@ -214,110 +119,176 @@ volume_type_t get_volume_type(sound_type sound_key) return type; } -API int svi_init(int *handle) +static int __svi_restore_default_file(int svi_type, int svi_enum) { - int ret_vib = SVI_SUCCESS; - int v_handle = 0; + vibration_type vib_enum_type = SVI_VIB_NONE; + sound_type snd_enum_type = SVI_SND_NONE; + const char* cur_path = NULL; + char default_path[MAX_FILE_PATH] = {0,}; + char *temp = NULL; + struct stat buf; - /* Sound Init */ - if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) < 0) - SVILOG("vconf_get_int(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) ==> FAIL!!\n"); - SVILOG("vconf_get_int(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) ==> %d\n", soundon); + if(svi_type <=SVI_TYPE_NONE || svi_type >= SVI_TYPE_END) { + SVILOG("ERROR!! invalid svi_type(%d).", svi_type); + return SVI_ERROR; + } - if (vconf_get_int("memory/Sound/SoundStatus", &sndstatus) < 0) - SVILOG("vconf_get_int(memory/Sound/SoundStatus, &sndstatus) ==> FAIL!!\n"); - SVILOG("vconf_get_int(memory/Sound/SoundStatus, &sndstatus) ==> %d\n", sndstatus); + if (svi_type == SVI_TYPE_SND) { + snd_enum_type = (sound_type)svi_enum; - vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, soundon_cb, NULL); - vconf_notify_key_changed("memory/Sound/SoundStatus", sndstatus_cb, NULL); + if (snd_enum_type <= SVI_SND_NONE || snd_enum_type >= SVI_SND_ENUM_END) { + SVILOG("ERROR! invalid svi_enum(%d)", snd_enum_type); + return SVI_ERROR; + } - /* Vibration Init */ - v_handle = device_haptic_open( DEV_IDX_0 , 0x01); // new haptic lib. + cur_path = snd_file[snd_enum_type]; + } else { + vib_enum_type = (vibration_type)svi_enum; - if (v_handle < 0) - { - SVILOG("device_haptic_open(DEV_IDX_0) ==> FAIL!!\n"); - ret_vib = SVI_ERROR; + if (vib_enum_type <= SVI_VIB_NONE || vib_enum_type >= SVI_VIB_ENUM_END) { + SVILOG("ERROR! invalid svi_enum(%d)", vib_enum_type); + return SVI_ERROR; + } + + cur_path = haptic_file[vib_enum_type]; } - else - { - if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vibstatus) < 0) //check vibration status - SVILOG("vconf_get_int(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vibstatus) ==> FAIL!!\n"); - SVILOG("vconf_get_int(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vibstatus) ==> %d\n", vibstatus); - - if (vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vib_level) < 0) //check vib_level - SVILOG("vconf_get_int(VCONFKEY_SETAPPL_VIB_FEEDBACK_INT, &vib_level) ==> FAIL!!\n"); - SVILOG("vconf_get_int(VCONFKEY_SETAPPL_VIB_FEEDBACK_INT, &vib_level) ==> %d\n", vib_level); - - vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vibstatus_cb, NULL); - vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, vib_cb, NULL); - ret_vib = SVI_SUCCESS; + + if( (cur_path == NULL) || (strlen(cur_path) == 0) ) { + SVILOG("ERROR! current path is invalid"); + return SVI_ERROR; } - if (ret_vib == SVI_ERROR) { - vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, soundon_cb); - vconf_ignore_key_changed("memory/Sound/SoundStatus", sndstatus_cb); + temp = strcat(default_path, SVI_ORIGIN_DATA_DIR); + + strcat(temp, cur_path+strlen(SVI_DATA_DIR)); + + SVILOG("default_path : %s", default_path); + + if(stat(default_path, &buf)) { /*check file existence*/ + SVILOG("ERROR!! default file for type(%d),enum(%d) is not presents", svi_type, svi_enum); + return SVI_ERROR; + } + + if(unlink(cur_path) < 0) { + SVILOG("WARNING!! unlink(%s) error(%d)", cur_path, errno); + } + + if(symlink(default_path, cur_path) < 0) { + SVILOG("ERROR!! symlink(%s) error(%d)", default_path, errno); + return SVI_ERROR; + } + + return SVI_SUCCESS; +} + +API int svi_init(int *handle) +{ + int v_handle = 0; + + /* Sound Init */ + if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) < 0) { + SVILOG("vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) ==> FAIL!!"); + return SVI_ERROR; + } else { + SVILOG("vconf_get_int(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) ==> %d", soundon); + } + + if (vconf_get_int(VCONFKEY_SOUND_STATUS, &sndstatus) < 0) { + SVILOG("vconf_get_int(VCONFKEY_SOUND_STATUS, &sndstatus) ==> FAIL!!"); + return SVI_ERROR; + } else { + SVILOG("vconf_get_int(VCONFKEY_SOUND_STATUS, &sndstatus) ==> %d", sndstatus); + } + + /* Vibration Init */ + v_handle = device_haptic_open( DEV_IDX_0 , 0x01); // new haptic lib. + if (v_handle < 0) { + SVILOG("device_haptic_open(DEV_IDX_0) ==> FAIL!!"); return SVI_ERROR; } else { + /* check vibration status */ + if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vibstatus) < 0) { + SVILOG("vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vibstatus) ==> FAIL!!"); + return SVI_ERROR; + } else { + SVILOG("vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vibstatus) ==> %d", vibstatus); + } + + /* check vib_level */ + if (vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vib_level) < 0) { + SVILOG("vconf_get_int(VCONFKEY_SETAPPL_VIB_FEEDBACK_INT, &vib_level) ==> FAIL!!"); + return SVI_ERROR; + } else { + SVILOG("vconf_get_int(VCONFKEY_SETAPPL_VIB_FEEDBACK_INT, &vib_level) ==> %d", vib_level); + } + *handle = v_handle; - return SVI_SUCCESS; } + + /* add watch for status value */ + vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, __svi_soundon_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SOUND_STATUS, __svi_sndstatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, __svi_vibstatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, __svi_vib_cb, NULL); + + return SVI_SUCCESS; } API int svi_fini(int handle) { - int ret_vib = SVI_SUCCESS; - - vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, soundon_cb); - vconf_ignore_key_changed("memory/Sound/SoundStatus", sndstatus_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, __svi_soundon_cb); + vconf_ignore_key_changed(VCONFKEY_SOUND_STATUS, __svi_sndstatus_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, __svi_vibstatus_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, __svi_vib_cb); if (handle > 0) { - vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vibstatus_cb); - vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, vib_cb); if (device_haptic_close(handle) < 0) { - ret_vib = SVI_ERROR; + return SVI_ERROR; } else { - ret_vib = SVI_SUCCESS; + return SVI_SUCCESS; } } - if ( ret_vib == SVI_ERROR) { - return SVI_ERROR; - } else { - return SVI_SUCCESS; - } + return SVI_ERROR; } API int svi_play_sound(int handle, sound_type sound_key) { int ret_snd = SVI_SUCCESS; - struct stat buf; - SVILOG("sound_key = %d\n", sound_key); + int ret = 0; + int retry = 1; if (handle < 0) { - SVILOG("ERROR!! Please call svi_init() for sound init \n"); + SVILOG("ERROR!! Please call svi_init() for sound init "); ret_snd = SVI_ERROR; - } - else - { - if (sound_key > SVI_SND_NONE && sound_key <= SVI_SND_OPERATION_SCRCAPTURE) - { - SVILOG("soundon = %d, sndstatus = %d \n", soundon, sndstatus); - if (soundon != 0 && sndstatus == 0) - { - if(stat(snd_file[sound_key], &buf)) { /*check file existence*/ - SVILOG("ERROR!! %s is not presents\n", snd_file[sound_key]); - return SVI_ERROR; - } - if (mm_sound_play_keysound(snd_file[sound_key], get_volume_type(sound_key)) < 0) - { - SVILOG("ERROR!! mm_sound_play_keysound() returned error.\n"); - ret_snd = SVI_ERROR; - } - SVILOG("SND filename is %s\n", snd_file[sound_key]); + } else { + if (sound_key > SVI_SND_NONE && sound_key <= SVI_SND_OPERATION_SCRCAPTURE) { + SVILOG("sound_key = %d, soundon = %d, sndstatus = %d ", sound_key, soundon, sndstatus); + if (soundon != 0 && sndstatus == 0) { + do { + ret = mm_sound_play_keysound(snd_file[sound_key], __svi_get_volume_type(sound_key)); + if(ret == MM_ERROR_NONE) { + SVILOG("Play success! SND filename is %s", snd_file[sound_key]); + break; + } else { + if(ret == MM_ERROR_SOUND_FILE_NOT_FOUND) { + SVILOG("mm_sound_play_keysound MM_ERROR_SOUND_FILE_NOT_FOUND error"); + if(__svi_restore_default_file(SVI_TYPE_SND, sound_key) == SVI_ERROR) { + SVILOG("ERROR!! __svi_restore_origin_file(%d/%d) error", SVI_TYPE_SND, sound_key); + ret_snd = SVI_ERROR; + break; + } else { + SVILOG("sound file link is restored. sound play will be retried. "); + } + } else { + SVILOG("ERROR!! mm_sound_play_keysound() returned error(%d)", ret); + ret_snd = SVI_ERROR; + break; + } + } + } while(retry--); } - } - else if (sound_key != SVI_SND_NONE) { + } else if (sound_key != SVI_SND_NONE) { ret_snd = SVI_ERROR; } } @@ -328,38 +299,43 @@ API int svi_play_sound(int handle, sound_type sound_key) API int svi_play_vib(int handle, vibration_type vibration_key) { int ret_vib = SVI_SUCCESS; - struct stat buf; - - SVILOG("vibration key - %d\n", vibration_key); + int vib_lev = 0; if (handle < 0) { - SVILOG("ERROR!! Please call svi_init() for vibration init \n"); + SVILOG("ERROR!! Please call svi_init() for vibration init "); ret_vib = SVI_ERROR; } else { - if (vibration_key > SVI_VIB_NONE && vibration_key <= SVI_VIB_OPERATION_SHUTTER) { - if (vibration_key == SVI_VIB_OPERATION_FULLYCHARGED || vibration_key == SVI_VIB_OPERATION_LOTBATT) { - SVILOG("vibration type is SVI_VIB_OPERATION_FULLYCHARGED or SVI_VIB_OPERATION_LOTBATT\n"); - if (device_haptic_play_file(handle, haptic_file[vibration_key], 1, 5) < 0) { - SVILOG("ERROR!! device_haptic_play_file() returned error.\n"); - ret_vib = SVI_ERROR; - } - SVILOG("device_haptic_play_file(handle, vibration_key, 1, 5)\n"); + if (vibration_key > SVI_VIB_NONE && vibration_key < SVI_VIB_ENUM_END) { + + if (vibration_key == SVI_VIB_OPERATION_FULLCHARGED || vibration_key == SVI_VIB_OPERATION_LOWBATT) { + vib_lev = 5; } else { - SVILOG("vibstatus = %d, vib_level = %d\n", vibstatus, vib_level); - if (vibstatus != 0) { - if(stat(haptic_file[vibration_key], &buf)) { /*check file existence*/ - SVILOG("ERROR!! %s is not presents\n", haptic_file[vibration_key]); + vib_lev = vib_level; + } + + SVILOG("key = %d, vibstatus = %d, vib_level = %d", vibration_key, vibstatus, vib_lev); + + if (vibstatus != 0) { + + struct stat buf; + if(stat(haptic_file[vibration_key], &buf)) { /*check file existence*/ + SVILOG("ERROR!! %s is not presents", haptic_file[vibration_key]); + if(__svi_restore_default_file(SVI_TYPE_VIB, vibration_key) == SVI_ERROR) { + SVILOG("ERROR!! __svi_restore_default_file(%d/%d) error", SVI_TYPE_VIB, vibration_key); return SVI_ERROR; + } else { + SVILOG("%s is restored", haptic_file[vibration_key]); } - if (device_haptic_play_file(handle, haptic_file[vibration_key], 1, vib_level) < 0) { - SVILOG("ERROR!! device_haptic_play_file() returned error.\n"); - ret_vib = SVI_ERROR; - } - SVILOG("device_haptic_play_file(handle, vibration_key, 1, %d)\n", vib_level); + } + + int ret = 0; + ret = device_haptic_play_file(handle, haptic_file[vibration_key], 1, vib_lev); + if(ret < 0) { + SVILOG("ERROR!! device_haptic_play_file(%s) returned error(%d).", haptic_file[vibration_key], ret); + return SVI_ERROR; } } - } - else if (vibration_key != SVI_VIB_NONE) { + } else { ret_vib = SVI_ERROR; } } @@ -380,63 +356,118 @@ API int svi_play(int handle, vibration_type vibration_key, sound_type sound_key) } } -API int svi_get_path(int svi_type, int svi_enum, char* buf, unsigned int bufLen) +API int svi_set_path(int svi_type, int svi_enum, char* path) { vibration_type vib_enum_type = SVI_VIB_NONE; sound_type snd_enum_type = SVI_SND_NONE; - unsigned int pathLen = 0; + const char* cur_path = NULL; - SVILOG("starts\n"); - - if (buf == NULL || bufLen <= 0) { - SVILOG("ERROR!! invalid input parameters.\n"); + if(svi_type <=SVI_TYPE_NONE || svi_type >= SVI_TYPE_END) { + SVILOG("ERROR!! invalid svi_type(%d).", svi_type); return SVI_ERROR; } - if (!(svi_type == SVI_TYPE_SND || svi_type == SVI_TYPE_VIB)) { - SVILOG("ERROR!! invalid svi_type(%d).\n", svi_type); + if (path == NULL) { + SVILOG("ERROR!! invalid path param."); return SVI_ERROR; + } else { + if(access(path, F_OK) != 0) { + SVILOG("ERROR!! path does not exist."); + return SVI_ERROR; + } } - if (svi_type == SVI_TYPE_SND) { snd_enum_type = (sound_type)svi_enum; - if (snd_enum_type < SVI_SND_TOUCH_TOUCH1 || snd_enum_type> SVI_SND_OPERATION_SCRCAPTURE) { - SVILOG("ERROR! invalid svi_enum(%d)\n", snd_enum_type); + if (snd_enum_type <= SVI_SND_NONE || snd_enum_type >= SVI_SND_ENUM_END) { + SVILOG("ERROR! invalid svi_enum(%d)", snd_enum_type); return SVI_ERROR; } - pathLen = strlen(snd_file[snd_enum_type]); - if (pathLen <= 0) { - SVILOG("ERROR!! NULL path.\n"); + + cur_path = snd_file[snd_enum_type]; + } else { + vib_enum_type = (vibration_type)svi_enum; + + if (vib_enum_type <= SVI_VIB_NONE || vib_enum_type >= SVI_VIB_ENUM_END) { + SVILOG("ERROR! invalid svi_enum(%d)", vib_enum_type); return SVI_ERROR; } - if (pathLen < bufLen) { - strncpy(buf, snd_file[snd_enum_type], bufLen); - } else { - SVILOG("ERROR!! Overflow.\n"); + + cur_path = haptic_file[vib_enum_type]; + } + + if( (cur_path == NULL) || (strlen(cur_path) == 0) ) { + SVILOG("ERROR! current path is invalid"); + return SVI_ERROR; + } + + if(unlink(cur_path) < 0) { + SVILOG("ERROR!! unlink(%s) error(%d)", cur_path, errno); + return SVI_ERROR; + } + + if(symlink(path,cur_path) < 0) { + SVILOG("ERROR!! symlink(%s) error(%d)", path, errno); + return SVI_ERROR; + } + + return SVI_SUCCESS; +} + +API int svi_get_path(int svi_type, int svi_enum, char* buf, unsigned int bufLen) +{ + vibration_type vib_enum_type = SVI_VIB_NONE; + sound_type snd_enum_type = SVI_SND_NONE; + const char* cur_path = NULL; + int retry = SVI_RETRY_CNT; + + if (buf == NULL || bufLen <= 0) { + SVILOG("ERROR!! invalid input parameters."); + return SVI_ERROR; + } + + if (!(svi_type == SVI_TYPE_SND || svi_type == SVI_TYPE_VIB)) { + SVILOG("ERROR!! invalid svi_type(%d).", svi_type); + return SVI_ERROR; + } + + if (svi_type == SVI_TYPE_SND) { + snd_enum_type = (sound_type)svi_enum; + + if (snd_enum_type <= SVI_SND_NONE || snd_enum_type >= SVI_SND_ENUM_END) { + SVILOG("ERROR! invalid svi_enum(%d)", snd_enum_type); return SVI_ERROR; } + + cur_path = snd_file[snd_enum_type]; + } else if (svi_type == SVI_TYPE_VIB) { vib_enum_type = (vibration_type) svi_enum; - if (vib_enum_type < SVI_VIB_TOUCH_TOUCH || vib_enum_type > SVI_VIB_OPERATION_SHUTTER) { - SVILOG("ERROR! invalid svi_enum(%d)\n", vib_enum_type); - return SVI_ERROR; - } - pathLen = strlen(haptic_file[vib_enum_type]); - if (pathLen <= 0) { - SVILOG("ERROR!! NULL path.\n"); - return SVI_ERROR; - } - if (pathLen < bufLen) { - strncpy(buf, haptic_file[vib_enum_type], bufLen); - } else { - SVILOG("ERROR!! Overflow.\n"); + + if (vib_enum_type <= SVI_VIB_NONE || vib_enum_type >= SVI_VIB_ENUM_END) { + SVILOG("ERROR! invalid svi_enum(%d)", vib_enum_type); return SVI_ERROR; } + + cur_path = haptic_file[vib_enum_type]; } - SVILOG("ends\n"); + do { + if(readlink(cur_path, buf, bufLen) < 0) { + if(errno == ENOENT) { + /* restore svi origin path because of invalid link */ + if(__svi_restore_default_file(svi_type, svi_enum) == SVI_ERROR) { + SVILOG("ERROR!! __svi_restore_default_file(%d/%d) error", svi_type, svi_enum); + return SVI_ERROR; + } + } else { + SVILOG("ERROR!! readlink(%s) error(%d)", cur_path, errno); + return SVI_ERROR; + } + } + } while(retry--); + return SVI_SUCCESS; } diff --git a/test/svi_test.c b/test/svi_test.c index 6ced888..cac7f0e 100755 --- a/test/svi_test.c +++ b/test/svi_test.c @@ -29,6 +29,7 @@ char* show_sound_type[] = { "SVI_SND_TOUCH_TOUCH2", "SVI_SND_TOUCH_TOUCH3", "SVI_SND_TOUCH_SIP", + "SVI_SND_TOUCH_SIP_BACKSPACE", "SVI_SND_TOUCH_HOLD", "SVI_SND_TOUCH_MULTI_TAP", "SVI_SND_TOUCH_HW_TAP", @@ -59,18 +60,18 @@ char* show_sound_type[] = { "SVI_SND_OPERATION_NEWCHAT", "SVI_SND_OPERATION_SENTCHAT", "SVI_SND_OPERATION_ONOFFSLIDER", - "SVI_SND_OPERATION_SCRCAPTURE", - + "SVI_SND_OPERATION_SCRCAPTURE" }; char* show_vibration_type[] = { - "SVI_VIB_TOUCH_TOUCH", - "SVI_VIB_TOUCH_SIP", + "SVI_VIB_TOUCH_TOUCH", + "SVI_VIB_TOUCH_SIP", + "SVI_VIB_TOUCH_SIP_BACKSPACE", "SVI_VIB_TOUCH_HOLD", "SVI_VIB_TOUCH_MULTI_TAP", "SVI_VIB_TOUCH_HW_TAP", "SVI_VIB_TOUCH_HW_HOLD", - "SVI_VIB_TOUCH_KEY00", + "SVI_VIB_TOUCH_KEY00", "SVI_VIB_TOUCH_KEY01", "SVI_VIB_TOUCH_KEY02", "SVI_VIB_TOUCH_KEY03", @@ -82,31 +83,33 @@ char* show_vibration_type[] = { "SVI_VIB_TOUCH_KEY09", "SVI_VIB_TOUCH_KEY_STAR", "SVI_VIB_TOUCH_KEY_SHARP", - "SVI_VIB_NOTIFICATION_INCOMING_CALL01", - "SVI_VIB_NOTIFICATION_INCOMING_CALL02", - "SVI_VIB_NOTIFICATION_INCOMING_CALL03", - "SVI_VIB_NOTIFICATION_MESSAGE", - "SVI_VIB_NOTIFICATION_EMAIL", - "SVI_VIB_NOTIFICATION_WAKEUP", - "SVI_VIB_NOTIFICATION_SCHEDULE", - "SVI_VIB_NOTIFICATION_TIMER", - "SVI_VIB_NOTIFICATION_GENERAL", - "SVI_VIB_OPERATION_POWER_ON", - "SVI_VIB_OPERATION_POWER_OFF", - "SVI_VIB_OPERATION_CHARGERCONN", - "SVI_VIB_OPERATION_FULLYCHARGED", - "SVI_VIB_OPERATION_LOTBATT", - "SVI_VIB_OPERATION_LOCK", - "SVI_VIB_OPERATION_UNLOCK", - "SVI_VIB_OPERATION_CALLCONNECT", - "SVI_VIB_OPERATION_DISCALLCONNECT", - "SVI_VIB_OPERATION_MINUTEMINDER", - "SVI_VIB_OPERATION_VIBRATION", - "SVI_VIB_OPERATION_NEWCHAT", - "SVI_VIB_OPERATION_SENDCHAT", - "SVI_VIB_OPERATION_ONOFFSLIDER", - "SVI_VIB_OPERATION_SHUTTER", - + "SVI_VIB_NOTIFICATION_INCOMING_CALL01", + "SVI_VIB_NOTIFICATION_INCOMING_CALL02", + "SVI_VIB_NOTIFICATION_INCOMING_CALL03", + "SVI_VIB_NOTIFICATION_INCOMING_CALL04", + "SVI_VIB_NOTIFICATION_INCOMING_CALL05", + "SVI_VIB_NOTIFICATION_INCOMING_CALL06", + "SVI_VIB_NOTIFICATION_MESSAGE", + "SVI_VIB_NOTIFICATION_EMAIL", + "SVI_VIB_NOTIFICATION_WAKEUP", + "SVI_VIB_NOTIFICATION_SCHEDULE", + "SVI_VIB_NOTIFICATION_TIMER", + "SVI_VIB_NOTIFICATION_GENERAL", + "SVI_VIB_OPERATION_POWER_ON", + "SVI_VIB_OPERATION_POWER_OFF", + "SVI_VIB_OPERATION_CHARGERCONN", + "SVI_VIB_OPERATION_FULLCHARGED", + "SVI_VIB_OPERATION_LOWBATT", + "SVI_VIB_OPERATION_LOCK", + "SVI_VIB_OPERATION_UNLOCK", + "SVI_VIB_OPERATION_CALLCONNECT", + "SVI_VIB_OPERATION_DISCALLCONNECT", + "SVI_VIB_OPERATION_MINUTEMINDER", + "SVI_VIB_OPERATION_VIBRATION", + "SVI_VIB_OPERATION_NEWCHAT", + "SVI_VIB_OPERATION_SENDCHAT", + "SVI_VIB_OPERATION_ONOFFSLIDER", + "SVI_VIB_OPERATION_SHUTTER" }; int main(int argc, char* argv[]) { @@ -114,7 +117,7 @@ int main(int argc, char* argv[]) { int i = 0; int handle = 0; int input_type = 0, input = 0; - char buf[256] = {0,}; + char buf[512] = {0,}; r = svi_init(&handle); |