diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2015-03-16 15:07:26 +0900 |
---|---|---|
committer | taeyoung <ty317.kim@samsung.com> | 2015-06-11 14:25:27 +0900 |
commit | c4868d52f1a2bc254128f1b1f55553fdb152ad81 (patch) | |
tree | 38dc2dd48bfe04e5952d57fddaba3451184a4ed8 | |
parent | ddafb7d6eaedb0fcc669d6c40fe663b7e58fc370 (diff) | |
download | libsvi-c4868d52f1a2bc254128f1b1f55553fdb152ad81.tar.gz libsvi-c4868d52f1a2bc254128f1b1f55553fdb152ad81.tar.bz2 libsvi-c4868d52f1a2bc254128f1b1f55553fdb152ad81.zip |
feedback: Seperate codes between common and mobile profile
feedback-ids.h and feedback.h will be public api on Tizen v2.4.
If you need a specific enum for your profile,
you can make new file like feedback-ids-[PROFILE].h.
Change-Id: Iedcd7092866351a6c0b07fed3060b096e073973a
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
Signed-off-by: taeyoung <ty317.kim@samsung.com>
-rw-r--r-- | CMakeLists.txt | 45 | ||||
-rw-r--r-- | SLP_FEEDBACK_PG.h | 225 | ||||
-rw-r--r--[-rwxr-xr-x] | common/data/sound.xml (renamed from data/mobile/sound.xml) | 100 | ||||
-rwxr-xr-x | common/data/sound/operation/operation.wav (renamed from data/mobile/sound/operation/call_connect.wav) | bin | 27644 -> 27644 bytes | |||
-rwxr-xr-x | common/data/sound/operation/shutter.wav (renamed from data/mobile/sound/operation/shutter.wav) | bin | 149108 -> 149108 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key0.wav (renamed from data/mobile/sound/touch/key0.wav) | bin | 9064 -> 9064 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key1.wav (renamed from data/mobile/sound/touch/key1.wav) | bin | 9000 -> 9000 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key2.wav (renamed from data/mobile/sound/touch/key2.wav) | bin | 8968 -> 8968 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key3.wav (renamed from data/mobile/sound/touch/key3.wav) | bin | 9000 -> 9000 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key4.wav (renamed from data/mobile/sound/touch/key4.wav) | bin | 8976 -> 8976 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key5.wav (renamed from data/mobile/sound/touch/key5.wav) | bin | 8936 -> 8936 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key6.wav (renamed from data/mobile/sound/touch/key6.wav) | bin | 8976 -> 8976 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key7.wav (renamed from data/mobile/sound/touch/key7.wav) | bin | 8964 -> 8964 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key8.wav (renamed from data/mobile/sound/touch/key8.wav) | bin | 9000 -> 9000 bytes | |||
-rwxr-xr-x | common/data/sound/touch/key9.wav (renamed from data/mobile/sound/touch/key9.wav) | bin | 8968 -> 8968 bytes | |||
-rwxr-xr-x | common/data/sound/touch/keyasterisk.wav (renamed from data/mobile/sound/touch/keyasterisk.wav) | bin | 9000 -> 9000 bytes | |||
-rwxr-xr-x | common/data/sound/touch/keysharp.wav (renamed from data/mobile/sound/touch/keysharp.wav) | bin | 9000 -> 9000 bytes | |||
-rwxr-xr-x | common/data/sound/touch/sip.wav (renamed from data/mobile/sound/touch/sip.wav) | bin | 8832 -> 8832 bytes | |||
-rwxr-xr-x | common/data/sound/touch/touch.wav (renamed from data/mobile/sound/touch/touch.wav) | bin | 7974 -> 7974 bytes | |||
-rw-r--r-- | common/src/check.c | 141 | ||||
-rw-r--r-- | data/emulator/sound.xml | 133 | ||||
-rw-r--r-- | data/emulator/vibration.xml | 157 | ||||
-rwxr-xr-x | data/micro/sound/operation/notification.ogg | bin | 16051 -> 0 bytes | |||
-rwxr-xr-x | data/micro/sound/operation/power_on.ogg | bin | 36190 -> 0 bytes | |||
-rwxr-xr-x | data/micro/sound/operation/ringtone.ogg | bin | 38673 -> 0 bytes | |||
-rwxr-xr-x | data/micro/sound/operation/shutter.ogg | bin | 16468 -> 0 bytes | |||
-rwxr-xr-x | data/micro/sound/operation/system.ogg | bin | 7657 -> 0 bytes | |||
-rwxr-xr-x | data/micro/sound/touch/touch.ogg | bin | 4303 -> 0 bytes | |||
-rw-r--r-- | data/micro/vibration.xml | 161 | ||||
-rwxr-xr-x | data/mobile/sound/operation/charger_connection.wav | bin | 27644 -> 0 bytes | |||
-rwxr-xr-x | data/mobile/sound/operation/fully_charged.wav | bin | 27644 -> 0 bytes | |||
-rwxr-xr-x | data/mobile/sound/operation/list_reorder.wav | bin | 27644 -> 0 bytes | |||
-rwxr-xr-x | data/mobile/sound/operation/lock.wav | bin | 27644 -> 0 bytes | |||
-rwxr-xr-x | data/mobile/sound/operation/low_battery.wav | bin | 27644 -> 0 bytes | |||
-rwxr-xr-x | data/mobile/sound/operation/minute_minder.wav | bin | 27644 -> 0 bytes | |||
-rwxr-xr-x | data/mobile/sound/operation/power_on.wav | bin | 27644 -> 0 bytes | |||
-rwxr-xr-x | data/mobile/sound/operation/slider_sweep.wav | bin | 27644 -> 0 bytes | |||
-rwxr-xr-x | data/mobile/sound/operation/unlock.wav | bin | 27644 -> 0 bytes | |||
-rw-r--r-- | data/mobile/vibration.xml | 196 | ||||
-rwxr-xr-x | doc/feedback_doc.h | 14 | ||||
-rw-r--r-- | include/feedback-ids.h | 213 | ||||
-rw-r--r-- | include/feedback-internal.h | 115 | ||||
-rw-r--r-- | include/feedback.h | 151 | ||||
-rwxr-xr-x | include/feedback_doc.h | 35 | ||||
-rw-r--r-- | mobile/data/sound.xml | 157 | ||||
-rwxr-xr-x | mobile/data/sound/operation/notification.wav | bin | 0 -> 149168 bytes | |||
-rwxr-xr-x | mobile/data/sound/operation/operation.wav (renamed from data/mobile/sound/operation/call_disconnect.wav) | bin | 27644 -> 27644 bytes | |||
-rwxr-xr-x | mobile/data/sound/operation/ringtone.wav | bin | 0 -> 213228 bytes | |||
-rwxr-xr-x | mobile/data/sound/operation/shutter.wav | bin | 0 -> 149108 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key0.wav | bin | 0 -> 9064 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key1.wav | bin | 0 -> 9000 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key2.wav | bin | 0 -> 8968 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key3.wav | bin | 0 -> 9000 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key4.wav | bin | 0 -> 8976 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key5.wav | bin | 0 -> 8936 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key6.wav | bin | 0 -> 8976 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key7.wav | bin | 0 -> 8964 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key8.wav | bin | 0 -> 9000 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/key9.wav | bin | 0 -> 8968 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/keyasterisk.wav | bin | 0 -> 9000 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/keysharp.wav | bin | 0 -> 9000 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/sip.wav (renamed from data/mobile/sound/touch/sip_backspace.wav) | bin | 8832 -> 8832 bytes | |||
-rwxr-xr-x | mobile/data/sound/touch/touch.wav (renamed from data/mobile/sound/operation/volume_control.wav) | bin | 7974 -> 7974 bytes | |||
-rw-r--r-- | mobile/include/feedback-ids-mobile.h | 109 | ||||
-rw-r--r-- | mobile/src/check.c | 412 | ||||
-rw-r--r-- | packaging/libfeedback.spec | 8 | ||||
-rw-r--r-- | src/common.h (renamed from include/common.h) | 36 | ||||
-rw-r--r-- | src/dbus.h (renamed from include/dbus.h) | 0 | ||||
-rw-r--r-- | src/devices.c | 41 | ||||
-rw-r--r-- | src/devices.h (renamed from include/devices.h) | 17 | ||||
-rw-r--r-- | src/feedback.c | 280 | ||||
-rw-r--r-- | src/log.h (renamed from include/log.h) | 0 | ||||
-rw-r--r-- | src/profiles.c | 36 | ||||
-rw-r--r-- | src/profiles.h | 48 | ||||
-rw-r--r-- | src/sound.c | 217 | ||||
-rw-r--r-- | src/str.c | 124 | ||||
-rw-r--r-- | src/vibrator.c | 307 | ||||
-rw-r--r-- | src/xmlparser.h (renamed from include/xmlparser.h) | 0 | ||||
-rw-r--r-- | wearable/data/sound.xml (renamed from data/micro/sound.xml) | 88 | ||||
-rwxr-xr-x | wearable/data/sound/operation/notification.ogg (renamed from data/emulator/sound/operation/notification.ogg) | bin | 16051 -> 16051 bytes | |||
-rwxr-xr-x | wearable/data/sound/operation/power_on.ogg (renamed from data/emulator/sound/operation/power_on.ogg) | bin | 36190 -> 36190 bytes | |||
-rwxr-xr-x | wearable/data/sound/operation/ringtone.ogg (renamed from data/emulator/sound/operation/ringtone.ogg) | bin | 38673 -> 38673 bytes | |||
-rwxr-xr-x | wearable/data/sound/operation/shutter.ogg (renamed from data/emulator/sound/operation/shutter.ogg) | bin | 16468 -> 16468 bytes | |||
-rwxr-xr-x | wearable/data/sound/operation/system.ogg (renamed from data/emulator/sound/operation/system.ogg) | bin | 7657 -> 7657 bytes | |||
-rwxr-xr-x | wearable/data/sound/touch/touch.ogg (renamed from data/emulator/sound/touch/touch.ogg) | bin | 4303 -> 4303 bytes | |||
-rw-r--r-- | wearable/include/feedback-ids-wearable.h | 109 | ||||
-rw-r--r-- | wearable/src/check.c | 408 |
87 files changed, 2212 insertions, 1871 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a6ffd2f..c0a2084 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,37 +6,29 @@ SET(EXEC_PREFIX "\${prefix}") SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") SET(VERSION 0.1.4) -IF("${ARCH}" STREQUAL "emulator") - OPTION(USE_EMULATOR "Use Emulator" ON) -ELSEIF("${ARCH}" STREQUAL "arm") - OPTION(USE_ARM "Use Arm" ON) +IF("${PROFILE}" STREQUAL "") + SET(PROFILE "common") ENDIF() - -SET(FEEDBACK_DATA_PATH ${CMAKE_CURRENT_SOURCE_DIR}/data) -IF(USE_EMULATOR) -SET(FEEDBACK_DATA_DIRS ${FEEDBACK_DATA_PATH}/emulator) -ELSE(USE_EMULATOR) -IF(MICRO_DD) -SET(FEEDBACK_DATA_DIRS ${FEEDBACK_DATA_PATH}/micro) -ELSE(MICRO_DD) -SET(FEEDBACK_DATA_DIRS ${FEEDBACK_DATA_PATH}/mobile) -ENDIF(MICRO_DD) -ENDIF(USE_EMULATOR) +SET(FEEDBACK_PROFILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${PROFILE}) SET(SRCS - src/devices.c src/sound.c src/vibrator.c + src/devices.c src/xmlparser.c src/feedback.c - src/str.c - src/dbus.c) + src/dbus.c + ${FEEDBACK_PROFILE_PATH}/src/check.c) SET(HEADERS - SLP_FEEDBACK_PG.h include/feedback.h include/feedback-ids.h) +IF(NOT "${PROFILE}" STREQUAL "common") + SET(HEADERS ${HEADERS} + ${FEEDBACK_PROFILE_PATH}/include/feedback-ids-${PROFILE}.h) +ENDIF() + SET(DEPENDENTS "vconf mm-keysound dlog libxml-2.0 glib-2.0 dbus-1") SET(PC_DEPENDENTS "capi-base-common") @@ -45,6 +37,8 @@ SET(PC_REQUIRED ${PC_DEPENDENTS}) SET(PC_LDFLAGS -l${PROJECT_NAME}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) +INCLUDE_DIRECTORIES(${FEEDBACK_PROFILE_PATH}/include) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED ${DEPENDENTS}) @@ -67,14 +61,5 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT Runtime CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -FOREACH(hfile ${HEADERS}) - INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME}) -ENDFOREACH(hfile) - -IF(MICRO_DD OR USE_EMULATOR) - INSTALL(DIRECTORY ${FEEDBACK_DATA_DIRS}/ DESTINATION share/${PROJECT_NAME}) -ELSE(MICRO_DD OR USE_EMULATOR) - INSTALL(DIRECTORY ${FEEDBACK_DATA_DIRS}/sound DESTINATION share/${PROJECT_NAME}) - INSTALL(FILES ${FEEDBACK_DATA_DIRS}/sound.xml DESTINATION share/${PROJECT_NAME}) - INSTALL(FILES ${FEEDBACK_DATA_DIRS}/vibration.xml DESTINATION share/${PROJECT_NAME}) -ENDIF(MICRO_DD OR USE_EMULATOR) +INSTALL(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME}) +INSTALL(DIRECTORY ${FEEDBACK_PROFILE_PATH}/data/ DESTINATION share/${PROJECT_NAME}) diff --git a/SLP_FEEDBACK_PG.h b/SLP_FEEDBACK_PG.h deleted file mode 100644 index b7006a2..0000000 --- a/SLP_FEEDBACK_PG.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - * libsvi - * - * 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> - * - * 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. - * - */ - -/** - * - * @ingroup SLP_PG - * @defgroup SVI_PG SVI -@{ - -@par SVI Programming Guide - -<h1 class="pg">Brief Information</h1> -- Sound & Vibration UI -- Convenient API -- Header File : svi.h - -<h1 class="pg"> Introduction</h1> -<h2 class="pg"> Purpose of this document</h2> -The purpose of this document is to describe how applications can use Sound and Vibration Interface Library APIs.\n -This document gives only programming guidelines to application engineers. - -<h2 class="pg"> Scope</h2> -The scope of this document is limited to Samsung platform Sound and Vibration Interface Library API usage. - -<h1 class="pg"> Architecture</h1> -<h2 class="pg"> Architecture overview</h2> -Sound and Vibration Interface Library (SVI) is responsible for playing simple sound and vibration.\n -SVI play sound using mm-sound library and play vibration with device framework. - -@image html svi.png "SVI diagram" - -<h2 class="pg"> SLP Features</h2> -Sound and Vibration Interface Library has the following features:\n - - - Play Sound - - It can play simple sound with predefined key. - - - Play Vibration - - It can play simple vibration with predefined key. - -<h2 class="pg">API list and description</h2> - - int svi_init(int *handle) - - Unload sound profile and status, and close haptic device. - - - int svi_fini(int handle) - - Finalize audio ui library. - - Unload sound profile and status, and close haptic device. - - - int svi_play_sound(int handle, sound_type sound_key) - - Play simple sound. - - - int svi_play_vib(int handle, vibration_type vibration_key) - - Play simple vibration. - - - int svi_play(int handle, vibration_type vibration_key, sound_type sound_key) - - Play simple sound and vibration. - -<h1 class="pg">Programming with Sound & Vibration UI</h1> - -<h2 class="pg">Defines</h2> -@code -#define SVI_SUCCESS 0 -#define SVI_ERROR -1 -@endcode - -<h2 class="pg">Functions</h2> -@code -int svi_init(int *handle) -int svi_fini(int handle) -int svi_play_sound(int handle, sound_type sound_key) -int svi_play_vib(int handle, vibration_type vibration_key) -int svi_play(int handle, vibration_type vibration_key, sound_type sound_key) -@endcode - -<h2 class="pg">Example code</h2> -@code -#include <svi.h> - -int r = 0; -int handle = 0; - -r = svi_init(&handle); -if (r != SVI_SUCCESS){ - - printf("Cannot initialize svi.\n"); - -} else { - - r = svi_play (handle, SVI_VIB_TOUCH, SVI_SND_TOUCH1); - if (r != SVI_SUCCESS) { - printf("Cannot play sound or vibration.\n"); - } - - r = svi_play_sound (handle, SVI_SND_TOUCH1); - if (r != SVI_SUCCESS) { - printf("Cannot play sound.\n"); - } - - r = svi_play_vib (handle, SVI_VIB_TOUCH); - if (r != SVI_SUCCESS) { - printf("Cannot play vibration.\n"); - } - - r = svi_fini(handle); - if (r != SVI_SUCCESS) { - printf("Cannot close svi.\n"); - } -} -@endcode - -<h2 class="pg">Vibration IDs</h2> -@code - SVI_VIB_TOUCH_TOUCH - 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_KEY00 - SVI_VIB_TOUCH_KEY01 - SVI_VIB_TOUCH_KEY02 - SVI_VIB_TOUCH_KEY03 - SVI_VIB_TOUCH_KEY04 - SVI_VIB_TOUCH_KEY05 - SVI_VIB_TOUCH_KEY06 - SVI_VIB_TOUCH_KEY07 - SVI_VIB_TOUCH_KEY08 - 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_FULLCHARGED - SVI_VIB_OPERATION_LOWBATT - SVI_VIB_OPERATION_LOCK - SVI_VIB_OPERATION_UNLOCK - SVI_VIB_OPERATION_LOCK_SWIPE - SVI_VIB_OPERATION_UNLOCK_SWIPE - 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_OPERATION_HOURLY_ALERT -@endcode - -<h2 class="pg">Sound IDs</h2> -@code - SVI_SND_TOUCH_TOUCH1 - 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_POWEROF - SVI_SND_OPERATION_CHARGERCONN - SVI_SND_OPERATION_FULLCHARGED - SVI_SND_OPERATION_LOWBATT - SVI_SND_OPERATION_LOCK - SVI_SND_OPERATION_UNLOCK - SVI_SND_OPERATION_LOCK_SWIPE - SVI_SND_OPERATION_UNLOCK_SWIPE - 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_OPERATION_HOURLY_ALERT -@endcode - -*/ - -/** -@} -*/ diff --git a/data/mobile/sound.xml b/common/data/sound.xml index d5738b8..72f4f77 100755..100644 --- a/data/mobile/sound.xml +++ b/common/data/sound.xml @@ -11,22 +11,6 @@ <data>/usr/share/feedback/sound/touch/sip.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SIP_BACKSPACE</label> - <data>/usr/share/feedback/sound/touch/sip_backspace.wav</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_SIP_FUNCTION</label> - <data>/usr/share/feedback/sound/touch/sip.wav</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_SIP_FJKEY</label> - <data>/usr/share/feedback/sound/touch/sip.wav</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_MAX_CHARACTER</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> @@ -84,74 +68,90 @@ </sound> <sound> <label>FEEDBACK_PATTERN_POWERON</label> - <data>/usr/share/feedback/sound/operation/power_on.wav</data> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> <label>FEEDBACK_PATTERN_CHARGERCONN</label> - <data>/usr/share/feedback/sound/operation/charger_connection.wav</data> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_CHARGERCONN_ON_CALL</label> - <data>/usr/share/feedback/sound/operation/charger_connection.wav</data> + <label>FEEDBACK_PATTERN_LOWBATT</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_LOWBATT</label> - <data>/usr/share/feedback/sound/operation/low_battery.wav</data> + <label>FEEDBACK_PATTERN_LOCK</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_LOWBATT_ON_CALL</label> - <data>/usr/share/feedback/sound/operation/low_battery.wav</data> + <label>FEEDBACK_PATTERN_UNLOCK</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_LOCK</label> - <data>/usr/share/feedback/sound/operation/lock.wav</data> + <label>FEEDBACK_PATTERN_SILENT_OFF</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_UNLOCK</label> - <data>/usr/share/feedback/sound/operation/unlock.wav</data> + <label>FEEDBACK_PATTERN_LIST_REORDER</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_LOCK_SWIPE</label> - <data>/usr/share/feedback/sound/operation/lock.wav</data> + <label>FEEDBACK_PATTERN_LIST_SLIDER</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_UNLOCK_SWIPE</label> - <data>/usr/share/feedback/sound/operation/unlock.wav</data> + <label>FEEDBACK_PATTERN_VOLUME_KEY</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_GEOMETRIC_LOCK</label> - <data>/usr/share/feedback/sound/operation/lock.wav</data> + <label>FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE</label> + <data>/usr/share/feedback/sound/touch/sip.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_CALLCONNECT</label> - <data>/usr/share/feedback/sound/operation/call_connect.wav</data> + <label>FEEDBACK_PATTERN_MOBILE_SIP_FUNCTION</label> + <data>/usr/share/feedback/sound/touch/sip.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_DISCALLCONNECT</label> - <data>/usr/share/feedback/sound/operation/call_disconnect.wav</data> + <label>FEEDBACK_PATTERN_MOBILE_SIP_FJKEY</label> + <data>/usr/share/feedback/sound/touch/sip.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_MINUTEMINDER</label> - <data>/usr/share/feedback/sound/operation/minute_minder.wav</data> + <label>FEEDBACK_PATTERN_MOBILE_MAX_CHARACTER</label> + <data>/usr/share/feedback/sound/touch/sip.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SILENT_OFF</label> - <data>/usr/share/feedback/sound/operation/volume_control.wav</data> + <label>FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SCREEN_CAPTURE</label> - <data>/usr/share/feedback/sound/operation/shutter.wav</data> + <label>FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_LIST_REORDER</label> - <data>/usr/share/feedback/sound/operation/list_reorder.wav</data> + <label>FEEDBACK_PATTERN_MOBILE_LOCK_SWIPE</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_LIST_SLIDER</label> - <data>/usr/share/feedback/sound/operation/slider_sweep.wav</data> + <label>FEEDBACK_PATTERN_MOBILE_UNLOCK_SWIPE</label> + <data>/usr/share/feedback/sound/operation/operation.wav</data> </sound> <sound> - <label>FEEDBACK_PATTERN_VOLUME_KEY</label> - <data>/usr/share/feedback/sound/operation/volume_control.wav</data> + <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> diff --git a/data/mobile/sound/operation/call_connect.wav b/common/data/sound/operation/operation.wav Binary files differindex 5383bdf..5383bdf 100755 --- a/data/mobile/sound/operation/call_connect.wav +++ b/common/data/sound/operation/operation.wav diff --git a/data/mobile/sound/operation/shutter.wav b/common/data/sound/operation/shutter.wav Binary files differindex 9dea92b..9dea92b 100755 --- a/data/mobile/sound/operation/shutter.wav +++ b/common/data/sound/operation/shutter.wav diff --git a/data/mobile/sound/touch/key0.wav b/common/data/sound/touch/key0.wav Binary files differindex e2cd877..e2cd877 100755 --- a/data/mobile/sound/touch/key0.wav +++ b/common/data/sound/touch/key0.wav diff --git a/data/mobile/sound/touch/key1.wav b/common/data/sound/touch/key1.wav Binary files differindex fa77cf4..fa77cf4 100755 --- a/data/mobile/sound/touch/key1.wav +++ b/common/data/sound/touch/key1.wav diff --git a/data/mobile/sound/touch/key2.wav b/common/data/sound/touch/key2.wav Binary files differindex 53da84c..53da84c 100755 --- a/data/mobile/sound/touch/key2.wav +++ b/common/data/sound/touch/key2.wav diff --git a/data/mobile/sound/touch/key3.wav b/common/data/sound/touch/key3.wav Binary files differindex ede9a2b..ede9a2b 100755 --- a/data/mobile/sound/touch/key3.wav +++ b/common/data/sound/touch/key3.wav diff --git a/data/mobile/sound/touch/key4.wav b/common/data/sound/touch/key4.wav Binary files differindex 105bddc..105bddc 100755 --- a/data/mobile/sound/touch/key4.wav +++ b/common/data/sound/touch/key4.wav diff --git a/data/mobile/sound/touch/key5.wav b/common/data/sound/touch/key5.wav Binary files differindex a34b4d0..a34b4d0 100755 --- a/data/mobile/sound/touch/key5.wav +++ b/common/data/sound/touch/key5.wav diff --git a/data/mobile/sound/touch/key6.wav b/common/data/sound/touch/key6.wav Binary files differindex 34a8bec..34a8bec 100755 --- a/data/mobile/sound/touch/key6.wav +++ b/common/data/sound/touch/key6.wav diff --git a/data/mobile/sound/touch/key7.wav b/common/data/sound/touch/key7.wav Binary files differindex 3b845a4..3b845a4 100755 --- a/data/mobile/sound/touch/key7.wav +++ b/common/data/sound/touch/key7.wav diff --git a/data/mobile/sound/touch/key8.wav b/common/data/sound/touch/key8.wav Binary files differindex 2a05528..2a05528 100755 --- a/data/mobile/sound/touch/key8.wav +++ b/common/data/sound/touch/key8.wav diff --git a/data/mobile/sound/touch/key9.wav b/common/data/sound/touch/key9.wav Binary files differindex 80699c8..80699c8 100755 --- a/data/mobile/sound/touch/key9.wav +++ b/common/data/sound/touch/key9.wav diff --git a/data/mobile/sound/touch/keyasterisk.wav b/common/data/sound/touch/keyasterisk.wav Binary files differindex 9ec2e71..9ec2e71 100755 --- a/data/mobile/sound/touch/keyasterisk.wav +++ b/common/data/sound/touch/keyasterisk.wav diff --git a/data/mobile/sound/touch/keysharp.wav b/common/data/sound/touch/keysharp.wav Binary files differindex ce7cd88..ce7cd88 100755 --- a/data/mobile/sound/touch/keysharp.wav +++ b/common/data/sound/touch/keysharp.wav diff --git a/data/mobile/sound/touch/sip.wav b/common/data/sound/touch/sip.wav Binary files differindex 5b44d12..5b44d12 100755 --- a/data/mobile/sound/touch/sip.wav +++ b/common/data/sound/touch/sip.wav diff --git a/data/mobile/sound/touch/touch.wav b/common/data/sound/touch/touch.wav Binary files differindex 1ec9de4..1ec9de4 100755 --- a/data/mobile/sound/touch/touch.wav +++ b/common/data/sound/touch/touch.wav diff --git a/common/src/check.c b/common/src/check.c new file mode 100644 index 0000000..b6a70e2 --- /dev/null +++ b/common/src/check.c @@ -0,0 +1,141 @@ +/* + * 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 "feedback.h" +#include "profiles.h" +#include "log.h" + + +static const char *common_str_type[] = +{ + "FEEDBACK_TYPE_NONE", + "FEEDBACK_TYPE_SOUND", + "FEEDBACK_TYPE_VIBRATION", +}; + +static const char *common_str_pattern[] = +{ + "FEEDBACK_PATTERN_TAP", + "FEEDBACK_PATTERN_SIP", + "FEEDBACK_PATTERN_KEY0", + "FEEDBACK_PATTERN_KEY1", + "FEEDBACK_PATTERN_KEY2", + "FEEDBACK_PATTERN_KEY3", + "FEEDBACK_PATTERN_KEY4", + "FEEDBACK_PATTERN_KEY5", + "FEEDBACK_PATTERN_KEY6", + "FEEDBACK_PATTERN_KEY7", + "FEEDBACK_PATTERN_KEY8", + "FEEDBACK_PATTERN_KEY9", + "FEEDBACK_PATTERN_KEY_STAR", + "FEEDBACK_PATTERN_KEY_SHARP", + "FEEDBACK_PATTERN_KEY_BACK", + "FEEDBACK_PATTERN_HOLD", + "FEEDBACK_PATTERN_HW_TAP", + "FEEDBACK_PATTERN_HW_HOLD", + + "FEEDBACK_PATTERN_MESSAGE", + "FEEDBACK_PATTERN_EMAIL", + "FEEDBACK_PATTERN_WAKEUP", + "FEEDBACK_PATTERN_SCHEDULE", + "FEEDBACK_PATTERN_TIMER", + "FEEDBACK_PATTERN_GENERAL", + + "FEEDBACK_PATTERN_POWERON", + "FEEDBACK_PATTERN_POWEROFF", + "FEEDBACK_PATTERN_CHARGERCONN", + "FEEDBACK_PATTERN_CHARGING_ERROR", + "FEEDBACK_PATTERN_FULLCHARGED", + "FEEDBACK_PATTERN_LOWBATT", + "FEEDBACK_PATTERN_LOCK", + "FEEDBACK_PATTERN_UNLOCK", + "FEEDBACK_PATTERN_VIBRATION_ON", + "FEEDBACK_PATTERN_SILENT_OFF", + "FEEDBACK_PATTERN_BT_CONNECTED", + "FEEDBACK_PATTERN_BT_DISCONNECTED", + "FEEDBACK_PATTERN_LIST_REORDER", + "FEEDBACK_PATTERN_LIST_SLIDER", + "FEEDBACK_PATTERN_VOLUME_KEY", +}; + +static bool common_get_always_alert_case(int type, int pattern) +{ + switch (pattern) { + case FEEDBACK_PATTERN_SIP: + case FEEDBACK_PATTERN_TIMER: + if (CHECK_VIBRATION(type)) + return true; + break; + case FEEDBACK_PATTERN_WAKEUP: + return true; + default: + break; + } + return false; +} + +static bool common_get_always_off_case(int type, int pattern) +{ + switch (pattern) { + case FEEDBACK_PATTERN_TAP ... FEEDBACK_PATTERN_SIP: + case FEEDBACK_PATTERN_HOLD ... FEEDBACK_PATTERN_HW_HOLD: + if (CHECK_SOUND(type) && !is_touch_sndstatus()) + return true; + break; + case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: + if (CHECK_SOUND(type) && !is_keytone_sndstatus()) + return true; + break; + default: + break; + } + return false; +} + +static int common_get_strength_type(int type, int pattern) +{ + if (CHECK_SOUND(type)) { + if (pattern == FEEDBACK_PATTERN_TAP) + return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_TOUCH; + else if (pattern >= FEEDBACK_PATTERN_KEY0 && pattern <= FEEDBACK_PATTERN_KEY_BACK) + return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_DIALER; + else if (pattern == FEEDBACK_PATTERN_VOLUME_KEY) + return VOLUME_TYPE_RINGTONE; + else + return VOLUME_TYPE_SYSTEM; + } else if (CHECK_VIBRATION(type)) { + return DEFAULT_VIB_LEVEL * HAPTIC_FEEDBACK_STEP; + } + + return -EINVAL; +} + +static const struct profile_ops common_profile_ops = { + .profile = "common", + .get_always_alert_case = common_get_always_alert_case, + .get_always_off_case = common_get_always_off_case, + .get_strength_type = common_get_strength_type, + .max_type = FEEDBACK_TYPE_END, + .max_pattern = FEEDBACK_PATTERN_END, + .str_type = common_str_type, + .str_pattern = common_str_pattern, +}; + +PROFILE_OPS_REGISTER(&common_profile_ops); diff --git a/data/emulator/sound.xml b/data/emulator/sound.xml deleted file mode 100644 index fa8c279..0000000 --- a/data/emulator/sound.xml +++ /dev/null @@ -1,133 +0,0 @@ -<?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_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_CHARGERCONN_ON_CALL</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_CHARGING_ERROR_ON_CALL</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_LOWBATT_ON_CALL</label> - <data>/usr/share/feedback/sound/operation/system.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_LOCK</label> - <data>/usr/share/feedback/sound/operation/system.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_UNLOCK</label> - <data>/usr/share/feedback/sound/operation/system.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_CALLCONNECT</label> - <data>/usr/share/feedback/sound/operation/system.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_DISCALLCONNECT</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_VOLUME_KEY</label> - <data>/usr/share/feedback/sound/operation/system.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_SCREEN_CAPTURE</label> - <data>/usr/share/feedback/sound/operation/shutter.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_HOURLY_ALERT</label> - <data>/usr/share/feedback/sound/operation/system.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_SAFETY_ALERT</label> - <data>/usr/share/feedback/sound/operation/ringtone.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_SAFETY_LOW_POWER</label> - <data>/usr/share/feedback/sound/operation/ringtone.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_CMAS</label> - <data>/usr/share/feedback/sound/operation/notification.ogg</data> - </sound> -</config> diff --git a/data/emulator/vibration.xml b/data/emulator/vibration.xml deleted file mode 100644 index 09887c2..0000000 --- a/data/emulator/vibration.xml +++ /dev/null @@ -1,157 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<config> - <label>svi-data</label> - <description>Vibration Resource</description> - <vibration> - <label>FEEDBACK_PATTERN_TAP</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_HOLD</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MESSAGE</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MESSAGE_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_EMAIL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_EMAIL_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_WAKEUP</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_WAKEUP_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SCHEDULE</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SCHEDULE_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_TIMER</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_TIMER_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_GENERAL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_GENERAL_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGERCONN</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGERCONN_ON_CALL</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGING_ERROR</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_LOWBATT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_LOWBATT_ON_CALL</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CALLCONNECT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_DISCALLCONNECT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_VIBRATION_ON</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CONNECTED</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_DISCONNECTED</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_BT_PAIRING</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SAFETY_ALERT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SEND_SOS_MESSAGE</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_END_SOS_MESSAGE</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CMAS</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SPEED_UP</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SLOW_DOWN</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEEP_THIS_PACE</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_GOAL_ACHIEVED</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_EXERCISE_COUNT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_START_CUE</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SUCCESS</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_FAILURE</label> - <data>SYSTEM</data> - </vibration> -</config> diff --git a/data/micro/sound/operation/notification.ogg b/data/micro/sound/operation/notification.ogg Binary files differdeleted file mode 100755 index 457f7e8..0000000 --- a/data/micro/sound/operation/notification.ogg +++ /dev/null diff --git a/data/micro/sound/operation/power_on.ogg b/data/micro/sound/operation/power_on.ogg Binary files differdeleted file mode 100755 index 7756406..0000000 --- a/data/micro/sound/operation/power_on.ogg +++ /dev/null diff --git a/data/micro/sound/operation/ringtone.ogg b/data/micro/sound/operation/ringtone.ogg Binary files differdeleted file mode 100755 index 2653dd6..0000000 --- a/data/micro/sound/operation/ringtone.ogg +++ /dev/null diff --git a/data/micro/sound/operation/shutter.ogg b/data/micro/sound/operation/shutter.ogg Binary files differdeleted file mode 100755 index c22c810..0000000 --- a/data/micro/sound/operation/shutter.ogg +++ /dev/null diff --git a/data/micro/sound/operation/system.ogg b/data/micro/sound/operation/system.ogg Binary files differdeleted file mode 100755 index 69c8425..0000000 --- a/data/micro/sound/operation/system.ogg +++ /dev/null diff --git a/data/micro/sound/touch/touch.ogg b/data/micro/sound/touch/touch.ogg Binary files differdeleted file mode 100755 index 8be60ce..0000000 --- a/data/micro/sound/touch/touch.ogg +++ /dev/null diff --git a/data/micro/vibration.xml b/data/micro/vibration.xml deleted file mode 100644 index 80a5849..0000000 --- a/data/micro/vibration.xml +++ /dev/null @@ -1,161 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<config> - <label>svi-data</label> - <description>Vibration Resource</description> - <vibration> - <label>FEEDBACK_PATTERN_SIP</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SIP_BACKSPACE</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SIP_FUNCTION</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SIP_FJKEY</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_HOLD</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY_STAR</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY_SHARP</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY_BACK</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_WAKEUP</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SCHEDULE</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_TIMER</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_GENERAL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_3RD_APPLICATION</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGERCONN</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGERCONN_ON_CALL</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGING_ERROR</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_LOWBATT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_LOWBATT_ON_CALL</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CALLCONNECT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_DISCALLCONNECT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_VIBRATION_ON</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_BT_CONNECTED</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_BT_DISCONNECTED</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_BT_PAIRING</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_BT_WAITING</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SAFETY_ALERT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SEND_SOS_MESSAGE</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_END_SOS_MESSAGE</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CMAS</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SPEED_UP</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SLOW_DOWN</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEEP_THIS_PACE</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_GOAL_ACHIEVED</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_START_CUE</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_HEALTH_PACE</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_INACTIVE_TIME</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MEASURING_SUCCESS</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MEASURING_FAILURE</label> - <data>SYSTEM</data> - </vibration> -</config> diff --git a/data/mobile/sound/operation/charger_connection.wav b/data/mobile/sound/operation/charger_connection.wav Binary files differdeleted file mode 100755 index 5383bdf..0000000 --- a/data/mobile/sound/operation/charger_connection.wav +++ /dev/null diff --git a/data/mobile/sound/operation/fully_charged.wav b/data/mobile/sound/operation/fully_charged.wav Binary files differdeleted file mode 100755 index 5383bdf..0000000 --- a/data/mobile/sound/operation/fully_charged.wav +++ /dev/null diff --git a/data/mobile/sound/operation/list_reorder.wav b/data/mobile/sound/operation/list_reorder.wav Binary files differdeleted file mode 100755 index 5383bdf..0000000 --- a/data/mobile/sound/operation/list_reorder.wav +++ /dev/null diff --git a/data/mobile/sound/operation/lock.wav b/data/mobile/sound/operation/lock.wav Binary files differdeleted file mode 100755 index 5383bdf..0000000 --- a/data/mobile/sound/operation/lock.wav +++ /dev/null diff --git a/data/mobile/sound/operation/low_battery.wav b/data/mobile/sound/operation/low_battery.wav Binary files differdeleted file mode 100755 index 5383bdf..0000000 --- a/data/mobile/sound/operation/low_battery.wav +++ /dev/null diff --git a/data/mobile/sound/operation/minute_minder.wav b/data/mobile/sound/operation/minute_minder.wav Binary files differdeleted file mode 100755 index 5383bdf..0000000 --- a/data/mobile/sound/operation/minute_minder.wav +++ /dev/null diff --git a/data/mobile/sound/operation/power_on.wav b/data/mobile/sound/operation/power_on.wav Binary files differdeleted file mode 100755 index 5383bdf..0000000 --- a/data/mobile/sound/operation/power_on.wav +++ /dev/null diff --git a/data/mobile/sound/operation/slider_sweep.wav b/data/mobile/sound/operation/slider_sweep.wav Binary files differdeleted file mode 100755 index 5383bdf..0000000 --- a/data/mobile/sound/operation/slider_sweep.wav +++ /dev/null diff --git a/data/mobile/sound/operation/unlock.wav b/data/mobile/sound/operation/unlock.wav Binary files differdeleted file mode 100755 index 5383bdf..0000000 --- a/data/mobile/sound/operation/unlock.wav +++ /dev/null diff --git a/data/mobile/vibration.xml b/data/mobile/vibration.xml deleted file mode 100644 index 8221ffa..0000000 --- a/data/mobile/vibration.xml +++ /dev/null @@ -1,196 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<config> - <label>svi-data</label> - <description>Vibration Resource</description> - <vibration> - <label>FEEDBACK_PATTERN_SIP</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SIP_BACKSPACE</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SIP_FUNCTION</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SIP_FJKEY</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MAX_CHARACTER</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY0</label> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY1</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY2</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY3</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY4</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY5</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY6</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY7</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY8</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY9</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY_STAR</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY_SHARP</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_KEY_BACK</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_HOLD</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MULTI_TAP</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_HW_TAP</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_HW_HOLD</label> - <data>TOUCH</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MESSAGE</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MESSAGE_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_EMAIL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_EMAIL_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_WAKEUP</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_WAKEUP_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SCHEDULE</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SCHEDULE_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_TIMER</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_TIMER_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_GENERAL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_GENERAL_ON_CALL</label> - <data>NOTIFICATION</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SMART_ALERT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_POWERON</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_POWEROFF</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGERCONN</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_CHARGERCONN_ON_CALL</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_LOWBATT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_LOWBATT_ON_CALL</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_OUTGOING_CALL</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MINUTEMINDER</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_VIBRATION_ON</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_MMS</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_HOURLY_ALERT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SAFETY_ALERT</label> - <data>SYSTEM</data> - </vibration> - <vibration> - <label>FEEDBACK_PATTERN_SEND_SOS_MESSAGE</label> - <data>SYSTEM</data> - </vibration> -</config> diff --git a/doc/feedback_doc.h b/doc/feedback_doc.h index 0b0131e..ef3b17f 100755 --- a/doc/feedback_doc.h +++ b/doc/feedback_doc.h @@ -27,18 +27,8 @@ * \#include <feedback.h> * * @section CAPI_SYSTEM_FEEDBACK_MODULE_OVERVIEW Overview - * The FEEDBACK API provides functions to play sound or vibration associated with properties. - * @section CAPI_SYSTEM_FEEDBACK_MODULE_FEATURE Related Features - * This API is related with the following features:\n - * - http://developer.samsung.com/tizen/feature/haptic\n - * - * It is recommended to design feature related codes in your application for reliability.\n - * - * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n - * - * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n - * - * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * The FEEDBACK API is responsible for playing simple sound and vibration. + * It plays sound using mm-sound library and vibration with system framework. * */ diff --git a/include/feedback-ids.h b/include/feedback-ids.h index 84e9430..eac2d2e 100644 --- a/include/feedback-ids.h +++ b/include/feedback-ids.h @@ -24,27 +24,20 @@ extern "C" { #endif /** - * @file feedback-ids.h - * @brief This file contains the feedback API - */ - -/** - * @addtogroup CAPI_FEEDBACK_MODULE + * @addtogroup CAPI_SYSTEM_FEEDBACK_MODULE * @{ */ /** * @brief Enumerations of the type for feedback interface - * @details - * + * @since_tizen 2.4 */ typedef enum { FEEDBACK_TYPE_NONE, FEEDBACK_TYPE_SOUND, FEEDBACK_TYPE_VIBRATION, - FEEDBACK_TYPE_LED, - FEEDBACK_TYPE_END + FEEDBACK_TYPE_END, } feedback_type_e; /** @@ -53,122 +46,122 @@ typedef enum * Each feedback pattern can have separate media files of each types. * But Depending on vendor design, pattern may not have any type of file. * + * @since_tizen 2.4 */ typedef enum { FEEDBACK_PATTERN_NONE = -1, - FEEDBACK_PATTERN_TAP = 0, /**< feedback pattern when general touch */ - FEEDBACK_PATTERN_SIP, /**< feedback pattern when touch text key */ - FEEDBACK_PATTERN_SIP_BACKSPACE, /**< feedback pattern when touch backspace key */ - FEEDBACK_PATTERN_SIP_FUNCTION, /**< feedback pattern when touch function key */ - FEEDBACK_PATTERN_SIP_FJKEY, /**< feedback pattern when touch F,J key */ - FEEDBACK_PATTERN_MAX_CHARACTER, /**< feedback pattern when max character */ - FEEDBACK_PATTERN_KEY0, /**< feedback pattern when touch numeric 0 key */ - FEEDBACK_PATTERN_KEY1, /**< feedback pattern when touch numeric 1 key */ - FEEDBACK_PATTERN_KEY2, /**< feedback pattern when touch numeric 2 key */ - FEEDBACK_PATTERN_KEY3, /**< feedback pattern when touch numeric 3 key */ - FEEDBACK_PATTERN_KEY4, /**< feedback pattern when touch numeric 4 key */ - FEEDBACK_PATTERN_KEY5, /**< feedback pattern when touch numeric 5 key */ - FEEDBACK_PATTERN_KEY6, /**< feedback pattern when touch numeric 6 key */ - FEEDBACK_PATTERN_KEY7, /**< feedback pattern when touch numeric 7 key */ - FEEDBACK_PATTERN_KEY8, /**< feedback pattern when touch numeric 8 key */ - FEEDBACK_PATTERN_KEY9, /**< feedback pattern when touch numeric 9 key */ - FEEDBACK_PATTERN_KEY_STAR, /**< feedback pattern when touch star key */ - FEEDBACK_PATTERN_KEY_SHARP, /**< feedback pattern when touch sharp key */ - FEEDBACK_PATTERN_KEY_BACK, /**< feedback pattern when touch backspace key */ - FEEDBACK_PATTERN_HOLD, /**< feedback pattern when touch hold */ - FEEDBACK_PATTERN_MULTI_TAP, /**< feedback pattern when multi touch */ - FEEDBACK_PATTERN_HW_TAP, /**< feedback pattern when press hardware key */ - FEEDBACK_PATTERN_HW_HOLD, /**< feedback pattern when holding press hardware key */ - - FEEDBACK_PATTERN_MESSAGE, /**< feedback pattern when incoming a message */ - FEEDBACK_PATTERN_MESSAGE_ON_CALL, /**< feedback pattern when incoming a message on call */ - FEEDBACK_PATTERN_EMAIL, /**< feedback pattern when incoming an email */ - FEEDBACK_PATTERN_EMAIL_ON_CALL, /**< feedback pattern when incoming an email on call */ - FEEDBACK_PATTERN_WAKEUP, /**< feedback pattern when alert wake up call */ - FEEDBACK_PATTERN_WAKEUP_ON_CALL, /**< feedback pattern when alert wake up call on call */ - FEEDBACK_PATTERN_SCHEDULE, /**< feedback pattern when alert schedule alarm */ - FEEDBACK_PATTERN_SCHEDULE_ON_CALL, /**< feedback pattern when alert schedule alarm on call */ - FEEDBACK_PATTERN_TIMER, /**< feedback pattern when alert timer */ - FEEDBACK_PATTERN_TIMER_ON_CALL, /**< feedback pattern when alert timer on call */ - FEEDBACK_PATTERN_GENERAL, /**< feedback pattern when alert general event */ - FEEDBACK_PATTERN_GENERAL_ON_CALL, /**< feedback pattern when alert general event on call */ - FEEDBACK_PATTERN_SMART_ALERT, /**< feedback pattern when alert noti on motion */ - - FEEDBACK_PATTERN_POWERON, /**< feedback pattern when power on */ - FEEDBACK_PATTERN_POWEROFF, /**< feedback pattern when power off */ - FEEDBACK_PATTERN_CHARGERCONN, /**< feedback pattern when connecting charger */ - FEEDBACK_PATTERN_CHARGERCONN_ON_CALL, /**< feedback pattern when connecting charger on call */ - FEEDBACK_PATTERN_CHARGING_ERROR, /**< feedback pattern when occuring charging error */ - FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL,/**< feedback pattern when occuring charging error on call */ - FEEDBACK_PATTERN_FULLCHARGED, /**< feedback pattern when full charged */ - FEEDBACK_PATTERN_FULLCHARGED_ON_CALL, /**< feedback pattern when full charged on call */ - FEEDBACK_PATTERN_LOWBATT, /**< feedback pattern when low battery */ - FEEDBACK_PATTERN_LOWBATT_ON_CALL, /**< feedback pattern when low battery on call */ - FEEDBACK_PATTERN_LOCK, /**< feedback pattern when lock */ - FEEDBACK_PATTERN_UNLOCK, /**< feedback pattern when unlock */ - FEEDBACK_PATTERN_LOCK_SWIPE, /**< feedback pattern when lock swipe */ - FEEDBACK_PATTERN_UNLOCK_SWIPE, /**< feedback pattern when unlock swipe*/ - FEEDBACK_PATTERN_GEOMETRIC_LOCK, /**< feedback pattern when lock by geometric effect */ - FEEDBACK_PATTERN_CALLCONNECT, /**< feedback pattern when connecting call */ - FEEDBACK_PATTERN_DISCALLCONNECT, /**< feedback pattern when disconnecting call */ - FEEDBACK_PATTERN_OUTGOING_CALL, /**< feedback pattern when connected outgoing call */ - FEEDBACK_PATTERN_MINUTEMINDER, /**< feedback pattern when minute minder */ - FEEDBACK_PATTERN_VIBRATION_ON, /**< feedback pattern when turn on vibration mode */ - FEEDBACK_PATTERN_SILENT_OFF, /**< feedback pattern when turn off silent mode */ - FEEDBACK_PATTERN_BT_CONNECTED, /**< feedback pattern when connecting with bluetooth */ - FEEDBACK_PATTERN_BT_DISCONNECTED, /**< feedback pattern when disconnecting with bluetooth */ - FEEDBACK_PATTERN_BT_PAIRING, /**< feedback pattern when starting pare with bluetooth */ - FEEDBACK_PATTERN_BT_WAITING, /**< feedback pattern when pairing bluetooth */ - FEEDBACK_PATTERN_SCREEN_CAPTURE, /**< feedback pattern when screen capture */ - FEEDBACK_PATTERN_LIST_REORDER, /**< feedback pattern when list reorder */ - FEEDBACK_PATTERN_LIST_SLIDER, /**< feedback pattern when list slider sweep */ - FEEDBACK_PATTERN_VOLUME_KEY, /**< feedback pattern when pressed volume key */ - FEEDBACK_PATTERN_MMS, /**< feedback pattern when message state changed to MMS */ - FEEDBACK_PATTERN_HOURLY_ALERT, /**< feedback pattern when alert every hour on the hour */ - - FEEDBACK_PATTERN_SAFETY_ALERT, /**< feedback pattern when safety alert from phone */ - FEEDBACK_PATTERN_ACCIDENT_DETECT, /**< feedback pattern when accident detect */ - FEEDBACK_PATTERN_SEND_SOS_MESSAGE, /**< feedback pattern when sending SOS message */ - FEEDBACK_PATTERN_END_SOS_MESSAGE, /**< feedback pattern when finishing SOS message */ - FEEDBACK_PATTERN_EMERGENCY_BUZZER, /**< feedback pattern when occurs emergency buzzer */ - FEEDBACK_PATTERN_SAFETY_LOW_POWER, /**< this pattern is a low power ringtone */ - FEEDBACK_PATTERN_CMAS, /**< feedback pattern when alerting commercial mobile */ - FEEDBACK_PATTERN_SPEED_UP, /**< feedback pattern when advising user to speed up */ - FEEDBACK_PATTERN_SLOW_DOWN, /**< feedback pattern when advising user to slow down */ - FEEDBACK_PATTERN_KEEP_THIS_PACE, /**< feedback pattern when advising user to keep this pace */ - FEEDBACK_PATTERN_GOAL_ACHIEVED, /**< feedback pattern when alerting goal achieved */ - FEEDBACK_PATTERN_EXERCISE_COUNT, /**< feedback pattern when changing count number */ - FEEDBACK_PATTERN_START_CUE, /**< feedback pattern when starting cue */ - FEEDBACK_PATTERN_HEALTH_PACE, /**< feedback pattern when alerting health pace */ - FEEDBACK_PATTERN_INACTIVE_TIME, /**< feedback pattern when alerting inactive time */ - FEEDBACK_PATTERN_MEASURING_SUCCESS, /**< feedback pattern when measuring is succeeded */ - FEEDBACK_PATTERN_MEASURING_FAILURE, /**< feedback pattern when measuring is failed */ - FEEDBACK_PATTERN_UV_PROCESSING, /**< feedback pattern when UV is processing */ - FEEDBACK_PATTERN_SHEALTH_START, /**< feedback pattern when starting s-health */ - FEEDBACK_PATTERN_SHEALTH_PAUSE, /**< feedback pattern when pausing s-health */ - FEEDBACK_PATTERN_SHEALTH_STOP, /**< feedback pattern when stoping s-health */ - FEEDBACK_PATTERN_3RD_APPLICATION, /**< feedback pattern when alert 3rd event */ + FEEDBACK_PATTERN_TAP = 0, /**< Feedback pattern when general touch */ + FEEDBACK_PATTERN_SIP, /**< Feedback pattern when touch text key */ + FEEDBACK_PATTERN_KEY0, /**< Feedback pattern when touch numeric 0 key */ + FEEDBACK_PATTERN_KEY1, /**< Feedback pattern when touch numeric 1 key */ + FEEDBACK_PATTERN_KEY2, /**< Feedback pattern when touch numeric 2 key */ + FEEDBACK_PATTERN_KEY3, /**< Feedback pattern when touch numeric 3 key */ + FEEDBACK_PATTERN_KEY4, /**< Feedback pattern when touch numeric 4 key */ + FEEDBACK_PATTERN_KEY5, /**< Feedback pattern when touch numeric 5 key */ + FEEDBACK_PATTERN_KEY6, /**< Feedback pattern when touch numeric 6 key */ + FEEDBACK_PATTERN_KEY7, /**< Feedback pattern when touch numeric 7 key */ + FEEDBACK_PATTERN_KEY8, /**< Feedback pattern when touch numeric 8 key */ + FEEDBACK_PATTERN_KEY9, /**< Feedback pattern when touch numeric 9 key */ + FEEDBACK_PATTERN_KEY_STAR, /**< Feedback pattern when touch star key */ + FEEDBACK_PATTERN_KEY_SHARP, /**< Feedback pattern when touch sharp key */ + FEEDBACK_PATTERN_KEY_BACK, /**< Feedback pattern when touch backspace key */ + FEEDBACK_PATTERN_HOLD, /**< Feedback pattern when touch hold */ + FEEDBACK_PATTERN_HW_TAP, /**< Feedback pattern when press hardware key */ + FEEDBACK_PATTERN_HW_HOLD, /**< Feedback pattern when holding press hardware key */ + + FEEDBACK_PATTERN_MESSAGE, /**< Feedback pattern when incoming a message */ + FEEDBACK_PATTERN_EMAIL, /**< Feedback pattern when incoming an email */ + FEEDBACK_PATTERN_WAKEUP, /**< Feedback pattern when alert wake up call */ + FEEDBACK_PATTERN_SCHEDULE, /**< Feedback pattern when alert schedule alarm */ + FEEDBACK_PATTERN_TIMER, /**< Feedback pattern when alert timer */ + FEEDBACK_PATTERN_GENERAL, /**< Feedback pattern when alert general event */ + + FEEDBACK_PATTERN_POWERON, /**< Feedback pattern when power on */ + FEEDBACK_PATTERN_POWEROFF, /**< Feedback pattern when power off */ + FEEDBACK_PATTERN_CHARGERCONN, /**< Feedback pattern when connecting charger */ + FEEDBACK_PATTERN_CHARGING_ERROR, /**< Feedback pattern when occuring charging error */ + FEEDBACK_PATTERN_FULLCHARGED, /**< Feedback pattern when full charged */ + FEEDBACK_PATTERN_LOWBATT, /**< Feedback pattern when low battery */ + FEEDBACK_PATTERN_LOCK, /**< Feedback pattern when lock */ + FEEDBACK_PATTERN_UNLOCK, /**< Feedback pattern when unlock */ + FEEDBACK_PATTERN_VIBRATION_ON, /**< Feedback pattern when turn on vibration mode */ + FEEDBACK_PATTERN_SILENT_OFF, /**< Feedback pattern when turn off silent mode */ + FEEDBACK_PATTERN_BT_CONNECTED, /**< Feedback pattern when connecting with bluetooth */ + FEEDBACK_PATTERN_BT_DISCONNECTED, /**< Feedback pattern when disconnecting with bluetooth */ + FEEDBACK_PATTERN_LIST_REORDER, /**< Feedback pattern when list reorder */ + FEEDBACK_PATTERN_LIST_SLIDER, /**< Feedback pattern when list slider sweep */ + FEEDBACK_PATTERN_VOLUME_KEY, /**< Feedback pattern when pressed volume key */ FEEDBACK_PATTERN_END, - /* START : Will be removed */ + /* TODO Will be removed */ FEEDBACK_PATTERN_TOUCH_TAP = FEEDBACK_PATTERN_TAP, - FEEDBACK_PATTERN_TOUCH_MULTI_TAP = FEEDBACK_PATTERN_MULTI_TAP, + FEEDBACK_PATTERN_TOUCH_MULTI_TAP = FEEDBACK_PATTERN_TAP, FEEDBACK_PATTERN_TOUCH_KEY = FEEDBACK_PATTERN_KEY0, FEEDBACK_PATTERN_TOUCH_HOLD = FEEDBACK_PATTERN_HOLD, - FEEDBACK_PATTERN_REACTIVE_ALERT = FEEDBACK_PATTERN_SMART_ALERT, + FEEDBACK_PATTERN_REACTIVE_ALERT = FEEDBACK_PATTERN_NONE, FEEDBACK_PATTERN_VIBRATION = FEEDBACK_PATTERN_VIBRATION_ON, FEEDBACK_PATTERN_SOUND_ON = FEEDBACK_PATTERN_SILENT_OFF, - FEEDBACK_PATTERN_SHUTTER = FEEDBACK_PATTERN_SCREEN_CAPTURE, + FEEDBACK_PATTERN_SHUTTER = FEEDBACK_PATTERN_NONE, FEEDBACK_PATTERN_SLIDER_SWEEP = FEEDBACK_PATTERN_LIST_SLIDER, - FEEDBACK_PATTERN_SAFETY_ASSISTANCE = FEEDBACK_PATTERN_SEND_SOS_MESSAGE, - FEEDBACK_PATTERN_BT_PARING = FEEDBACK_PATTERN_BT_PAIRING, + FEEDBACK_PATTERN_SAFETY_ASSISTANCE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_BT_PARING = FEEDBACK_PATTERN_BT_CONNECTED, FEEDBACK_PATTERN_CONNECTED = FEEDBACK_PATTERN_BT_CONNECTED, FEEDBACK_PATTERN_DISCONNECTED = FEEDBACK_PATTERN_BT_DISCONNECTED, - FEEDBACK_PATTERN_SUCCESS = FEEDBACK_PATTERN_MEASURING_SUCCESS, - FEEDBACK_PATTERN_FAILURE = FEEDBACK_PATTERN_MEASURING_FAILURE, + FEEDBACK_PATTERN_SUCCESS = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_FAILURE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SIP_BACKSPACE = FEEDBACK_PATTERN_SIP, + FEEDBACK_PATTERN_SIP_FUNCTION = FEEDBACK_PATTERN_SIP, + FEEDBACK_PATTERN_SIP_FJKEY = FEEDBACK_PATTERN_SIP, + FEEDBACK_PATTERN_MAX_CHARACTER = FEEDBACK_PATTERN_SIP, + FEEDBACK_PATTERN_MULTI_TAP = FEEDBACK_PATTERN_TAP, + FEEDBACK_PATTERN_MESSAGE_ON_CALL = FEEDBACK_PATTERN_MESSAGE, + FEEDBACK_PATTERN_EMAIL_ON_CALL = FEEDBACK_PATTERN_EMAIL, + FEEDBACK_PATTERN_WAKEUP_ON_CALL = FEEDBACK_PATTERN_WAKEUP, + FEEDBACK_PATTERN_SCHEDULE_ON_CALL = FEEDBACK_PATTERN_SCHEDULE, + FEEDBACK_PATTERN_TIMER_ON_CALL = FEEDBACK_PATTERN_TIMER, + FEEDBACK_PATTERN_GENERAL_ON_CALL = FEEDBACK_PATTERN_GENERAL, + FEEDBACK_PATTERN_SMART_ALERT = FEEDBACK_PATTERN_GENERAL, + FEEDBACK_PATTERN_CHARGERCONN_ON_CALL = FEEDBACK_PATTERN_CHARGERCONN, + FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL = FEEDBACK_PATTERN_CHARGING_ERROR, + FEEDBACK_PATTERN_FULLCHARGED_ON_CALL = FEEDBACK_PATTERN_FULLCHARGED, + FEEDBACK_PATTERN_LOWBATT_ON_CALL = FEEDBACK_PATTERN_LOWBATT, + FEEDBACK_PATTERN_LOCK_SWIPE = FEEDBACK_PATTERN_LOCK, + FEEDBACK_PATTERN_UNLOCK_SWIPE = FEEDBACK_PATTERN_UNLOCK, + FEEDBACK_PATTERN_GEOMETRIC_LOCK = FEEDBACK_PATTERN_LOCK, + FEEDBACK_PATTERN_CALLCONNECT = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_DISCALLCONNECT = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_OUTGOING_CALL = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_MINUTEMINDER = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_BT_PAIRING = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_BT_WAITING = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SCREEN_CAPTURE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_MMS = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_HOURLY_ALERT = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SAFETY_ALERT = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_ACCIDENT_DETECT = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SEND_SOS_MESSAGE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_END_SOS_MESSAGE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_EMERGENCY_BUZZER = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SAFETY_LOW_POWER = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_CMAS = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SPEED_UP = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SLOW_DOWN = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_KEEP_THIS_PACE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_GOAL_ACHIEVED = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_EXERCISE_COUNT = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_START_CUE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_HEALTH_PACE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_INACTIVE_TIME = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_MEASURING_SUCCESS = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_MEASURING_FAILURE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_UV_PROCESSING = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SHEALTH_START = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SHEALTH_PAUSE = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_SHEALTH_STOP = FEEDBACK_PATTERN_NONE, + FEEDBACK_PATTERN_3RD_APPLICATION = FEEDBACK_PATTERN_NONE, /* END : Will be removed */ } feedback_pattern_e; diff --git a/include/feedback-internal.h b/include/feedback-internal.h new file mode 100644 index 0000000..08c5e0a --- /dev/null +++ b/include/feedback-internal.h @@ -0,0 +1,115 @@ +/* + * 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 __FEEDBACK_INTERNAL_H__ +#define __FEEDBACK_INTERNAL_H__ + +#include <tizen_error.h> +#include "feedback-ids.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file feedback-internal.h + * @brief This file contains the feedback internal API + */ + +#define FEEDBACK_SUCCEEDED(n) ((n) == FEEDBACK_ERROR_NONE) +#define FEEDBACK_FAILED(n) ((n) != FEEDBACK_ERROR_NONE) + +/** + * + * @brief Plays specific type of reactions that are pre-defined. + * @details + * This function can be used to react to pre-defined actions. \n + * It play specific type of system pre-defined pattern. + * + * @since_tizen 2.3 + * + * @remarks + * Currently, there are two types of reactions: sound and vibration. + * + * @param[in] type string The pattern type + * @param[in] pattern string The pre-defined pattern + * + * @return 0 on success, otherwise a negative error value. + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + */ +int feedback_play_type_by_name(char *type, char *pattern); + +/** + * @brief Gets the file path of resource for the given feedback type and pattern. + * @details + * Depending on the type of each pattern resouorce has a different format. \n + * Currently, System supports two pattern types. \n + * #FEEDBACK_TYPE_SOUND type uses .wav format. \n + * #FEEDBACK_TYPE_VIBRATION type uses .ivt format. \n + * If the given pattern doesn't have a file for the type, @a path will return NULL. + * + * @since_tizen 2.3 + * + * @remarks @a path must be released with free() by you. + * + * @param[in] type The pattern type + * @param[in] pattern The pre-defined pattern + * @param[out] path The file path of resource for feedback type and pattern + * + * @return 0 on success, otherwise a negative error value. + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed + * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + */ +int feedback_get_resource_path(feedback_type_e type, feedback_pattern_e pattern, char **path); + +/** + * @brief Sets the new file path of resource for the given feedback type and pattern. + * @details + * Depending on the type of each pattern resouorce has a different format. \n + * Currently, System supports two pattern types. \n + * #FEEDBACK_TYPE_SOUND type uses .wav format. \n + * #FEEDBACK_TYPE_VIBRATION type uses .ivt format. \n + * If the given pattern doesn't have a file for the type, @a path will return NULL. + * + * @since_tizen 2.3 + * + * @param[in] type The pattern type + * @param[in] pattern The pre-defined pattern + * @param[in] path The new file path of resource for feedback type and pattern + * + * @return 0 on success, otherwise a negative error value. + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed + * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + */ +int feedback_set_resource_path(feedback_type_e type, feedback_pattern_e pattern, char *path); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif //__FEEDBACK_INTERNAL_H__ diff --git a/include/feedback.h b/include/feedback.h index 532e24e..a63713e 100644 --- a/include/feedback.h +++ b/include/feedback.h @@ -19,8 +19,11 @@ #ifndef __FEEDBACK_H__ #define __FEEDBACK_H__ +#include <tizen.h> #include <tizen_error.h> #include "feedback-ids.h" +/* TODO Will be removed */ +#include "feedback-internal.h" #ifdef __cplusplus extern "C" { @@ -38,7 +41,7 @@ extern "C" { /** * @brief Enumerations of error codes for the Feedback API. - * @since_tizen 2.3 + * @since_tizen 2.4 */ typedef enum { @@ -46,24 +49,22 @@ typedef enum FEEDBACK_ERROR_OPERATION_FAILED = TIZEN_ERROR_NOT_PERMITTED, /**< Operation not permitted */ FEEDBACK_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ FEEDBACK_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported in this device */ - FEEDBACK_ERROR_NOT_INITIALIZED = TIZEN_ERROR_SYSTEM_CLASS | 0x52, /**< Has not yet been Initialized */ + FEEDBACK_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + FEEDBACK_ERROR_NOT_INITIALIZED = TIZEN_ERROR_FEEDBACK | 0x01, /**< Not initialized */ } feedback_error_e; -#define FEEDBACK_SUCCEEDED(n) ((n) == FEEDBACK_ERROR_NONE) -#define FEEDBACK_FAILED(n) ((n) != FEEDBACK_ERROR_NONE) - /** * @brief Initializes feedback API. * - * @since_tizen 2.3 + * @since_tizen 2.4 * * @remarks * If this function is not called in advance, other function will return #FEEDBACK_ERROR_NOT_INITIALIZED. * * @return 0 on success, otherwise a negative error value. * @retval #FEEDBACK_ERROR_NONE Successful - * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed - * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * + * @post feedback_deinitialize() * * @see feedback_deinitialize() */ @@ -73,12 +74,13 @@ int feedback_initialize(void); * @brief Deinitializes feedback API. * @details This function must be called when feedback functions are no longer needed. * - * @since_tizen 2.3 + * @since_tizen 2.4 * * @return 0 on success, otherwise a negative error value. * @retval #FEEDBACK_ERROR_NONE Successful - * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed - * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * @retval #FEEDBACK_ERROR_NOT_INITIALIZED Not initialized + * + * @pre feedback_initialize() * * @see feedback_initialize() */ @@ -90,19 +92,27 @@ int feedback_deinitialize(void); * This functon can be used to react to pre-defined actions. \n * It play various types of system pre-defined media or vibration patterns. * - * @since_tizen 2.3 + * @since_tizen 2.4 * * @remarks * Currently, there are two types of reactions: sound and vibration. \n * Depending on the settings, some types cannot operate. * For example, when set to silent mode, the device doesn't produce any sound. + * If to play one of devices is successful, this function regards as success. + * And for controlling haptic device, the privilege should be set to, %http://tizen.org/privilege/haptic. + * If you don't have the haptic privilege, it only works sound operation. + * It does not return any error in this case. * * @param[in] pattern The pre-defined pattern * * @return 0 on success, otherwise a negative error value. - * @retval #FEEDBACK_ERROR_NONE Successful - * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation not permitted + * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * @retval #FEEDBACK_ERROR_NOT_INITIALIZED Not initialized + * + * @pre feedback_initialize() */ int feedback_play(feedback_pattern_e pattern); @@ -113,104 +123,77 @@ int feedback_play(feedback_pattern_e pattern); * This function can be used to react to pre-defined actions. \n * It play specific type of system pre-defined pattern. * - * @since_tizen 2.3 + * @since_tizen 2.4 * * @remarks - * Currently, there are two types of reactions: sound and vibration. + * Currently, there are two types of reactions: sound and vibration. \n + * Depending on the settings, some types cannot operate. + * For example, when set to silent mode, the device doesn't produce any sound. + * And for controlling haptic device, the privilege should be set to, %http://tizen.org/privilege/haptic. + * If you don't have the haptic privilege, it returns FEEDBACK_ERROR_PERMISSION_DENIED error. * * @param[in] type The pattern type * @param[in] pattern The pre-defined pattern * * @return 0 on success, otherwise a negative error value. - * @retval #FEEDBACK_ERROR_NONE Successful - * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation not permitted + * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * @retval #FEEDBACK_ERROR_PERMISSION_DENIED Permission denied + * @retval #FEEDBACK_ERROR_NOT_INITIALIZED Not initialized + * + * @pre feedback_initialize() */ int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern); /** - * - * @brief Plays specific type of reactions that are pre-defined. + * @brief Stop various types of reactions * @details - * This function can be used to react to pre-defined actions. \n - * It play specific type of system pre-defined pattern. + * This functon can be used to stop react to pre-defined actions. \n + * It stops system pre-defined vibration patterns. * - * @since_tizen 2.3 + * @since_tizen 2.4 * * @remarks - * Currently, there are two types of reactions: sound and vibration. - * - * @param[in] type string The pattern type - * @param[in] pattern string The pre-defined pattern + * This function does not support to stop media sound actions. \n + * In this case, it will return FEEDBACK_ERROR_NOT_SUPPORTED error. + * And for controlling haptic device, the privilege should be set to, %http://tizen.org/privilege/haptic. + * If you don't have the haptic privilege, it only works sound operation. + * It does not return any error in this case. * * @return 0 on success, otherwise a negative error value. - * @retval #FEEDBACK_ERROR_NONE Successful - * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device - */ -int feedback_play_type_by_name(char *type, char *pattern); - -/** - * @brief Stop various types of reactions - * @details - * This functon can be used to stop react to pre-defined actions. \n - * It stops various types of system pre-defined media or vibration patterns. - * - * @since_tizen 2.3 + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation not permitted + * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * @retval #FEEDBACK_ERROR_PERMISSION_DENIED Permission denied + * @retval #FEEDBACK_ERROR_NOT_INITIALIZED Not initialized * - * @return 0 on success, otherwise a negative error value. - * @retval #FEEDBACK_ERROR_NONE Successful - * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * @pre feedback_initialize() */ int feedback_stop(void); /** - * @brief Gets the file path of resource for the given feedback type and pattern. + * @brief Checks if the pattern is supported * @details - * Depending on the type of each pattern resouorce has a different format. \n - * Currently, System supports two pattern types. \n - * #FEEDBACK_TYPE_SOUND type uses .wav format. \n - * #FEEDBACK_TYPE_VIBRATION type uses .ivt format. \n - * If the given pattern doesn't have a file for the type, @a path will return NULL. - * - * @since_tizen 2.3 + * This functon can be used to check if a specific pattern is supported. * - * @remarks @a path must be released with free() by you. + * @since_tizen 2.4 * - * @param[in] type The pattern type - * @param[in] pattern The pre-defined pattern - * @param[out] path The file path of resource for feedback type and pattern + * @param[in] type The pattern type + * @param[in] pattern The pre-defined pattern + * @param[out] status True means the pattern is supported, otherwise not supported. * * @return 0 on success, otherwise a negative error value. - * @retval #FEEDBACK_ERROR_NONE Successful - * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed - * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device - */ -int feedback_get_resource_path(feedback_type_e type, feedback_pattern_e pattern, char **path); - -/** - * @brief Sets the new file path of resource for the given feedback type and pattern. - * @details - * Depending on the type of each pattern resouorce has a different format. \n - * Currently, System supports two pattern types. \n - * #FEEDBACK_TYPE_SOUND type uses .wav format. \n - * #FEEDBACK_TYPE_VIBRATION type uses .ivt format. \n - * If the given pattern doesn't have a file for the type, @a path will return NULL. - * - * @since_tizen 2.3 - * - * @param[in] type The pattern type - * @param[in] pattern The pre-defined pattern - * @param[in] path The new file path of resource for feedback type and pattern + * @retval #FEEDBACK_ERROR_NONE Successful + * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation not permitted + * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * @retval #FEEDBACK_ERROR_NOT_INITIALIZED Not initialized * - * @return 0 on success, otherwise a negative error value. - * @retval #FEEDBACK_ERROR_NONE Successful - * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed - * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device + * @pre feedback_initialize() */ -int feedback_set_resource_path(feedback_type_e type, feedback_pattern_e pattern, char *path); +int feedback_is_supported_pattern(feedback_type_e type, feedback_pattern_e pattern, bool *status); /** * @} diff --git a/include/feedback_doc.h b/include/feedback_doc.h deleted file mode 100755 index c11960d..0000000 --- a/include/feedback_doc.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __FEEDBACK_DOC_H__ -#define __FEEDBACK_DOC_H__ - -/** - * @defgroup CAPI_FEEDBACK_MODULE Feedback - * @brief The FEEDBACK API provides functions to play simple sound and vibration. - * @ingroup CAPI_UIX_FRAMEWORK - * - * @section CAPI_FEEDBACK_MODULE_HEADER Required Header - * \#include <feedback.h> - * - * @section CAPI_FEEDBACK_MODULE_OVERVIEW Overview - * The feedback library is responsible for playing simple sound and vibration. - * Feedback play sound using mm-sound library and play vibration with system framework. - * - */ - -#endif /* __FEEDBACK_DOC_H__ */ diff --git a/mobile/data/sound.xml b/mobile/data/sound.xml new file mode 100644 index 0000000..72f4f77 --- /dev/null +++ b/mobile/data/sound.xml @@ -0,0 +1,157 @@ +<?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> diff --git a/mobile/data/sound/operation/notification.wav b/mobile/data/sound/operation/notification.wav Binary files differnew file mode 100755 index 0000000..6487389 --- /dev/null +++ b/mobile/data/sound/operation/notification.wav diff --git a/data/mobile/sound/operation/call_disconnect.wav b/mobile/data/sound/operation/operation.wav Binary files differindex 5383bdf..5383bdf 100755 --- a/data/mobile/sound/operation/call_disconnect.wav +++ b/mobile/data/sound/operation/operation.wav diff --git a/mobile/data/sound/operation/ringtone.wav b/mobile/data/sound/operation/ringtone.wav Binary files differnew file mode 100755 index 0000000..f159e35 --- /dev/null +++ b/mobile/data/sound/operation/ringtone.wav diff --git a/mobile/data/sound/operation/shutter.wav b/mobile/data/sound/operation/shutter.wav Binary files differnew file mode 100755 index 0000000..9dea92b --- /dev/null +++ b/mobile/data/sound/operation/shutter.wav diff --git a/mobile/data/sound/touch/key0.wav b/mobile/data/sound/touch/key0.wav Binary files differnew file mode 100755 index 0000000..e2cd877 --- /dev/null +++ b/mobile/data/sound/touch/key0.wav diff --git a/mobile/data/sound/touch/key1.wav b/mobile/data/sound/touch/key1.wav Binary files differnew file mode 100755 index 0000000..fa77cf4 --- /dev/null +++ b/mobile/data/sound/touch/key1.wav diff --git a/mobile/data/sound/touch/key2.wav b/mobile/data/sound/touch/key2.wav Binary files differnew file mode 100755 index 0000000..53da84c --- /dev/null +++ b/mobile/data/sound/touch/key2.wav diff --git a/mobile/data/sound/touch/key3.wav b/mobile/data/sound/touch/key3.wav Binary files differnew file mode 100755 index 0000000..ede9a2b --- /dev/null +++ b/mobile/data/sound/touch/key3.wav diff --git a/mobile/data/sound/touch/key4.wav b/mobile/data/sound/touch/key4.wav Binary files differnew file mode 100755 index 0000000..105bddc --- /dev/null +++ b/mobile/data/sound/touch/key4.wav diff --git a/mobile/data/sound/touch/key5.wav b/mobile/data/sound/touch/key5.wav Binary files differnew file mode 100755 index 0000000..a34b4d0 --- /dev/null +++ b/mobile/data/sound/touch/key5.wav diff --git a/mobile/data/sound/touch/key6.wav b/mobile/data/sound/touch/key6.wav Binary files differnew file mode 100755 index 0000000..34a8bec --- /dev/null +++ b/mobile/data/sound/touch/key6.wav diff --git a/mobile/data/sound/touch/key7.wav b/mobile/data/sound/touch/key7.wav Binary files differnew file mode 100755 index 0000000..3b845a4 --- /dev/null +++ b/mobile/data/sound/touch/key7.wav diff --git a/mobile/data/sound/touch/key8.wav b/mobile/data/sound/touch/key8.wav Binary files differnew file mode 100755 index 0000000..2a05528 --- /dev/null +++ b/mobile/data/sound/touch/key8.wav diff --git a/mobile/data/sound/touch/key9.wav b/mobile/data/sound/touch/key9.wav Binary files differnew file mode 100755 index 0000000..80699c8 --- /dev/null +++ b/mobile/data/sound/touch/key9.wav diff --git a/mobile/data/sound/touch/keyasterisk.wav b/mobile/data/sound/touch/keyasterisk.wav Binary files differnew file mode 100755 index 0000000..9ec2e71 --- /dev/null +++ b/mobile/data/sound/touch/keyasterisk.wav diff --git a/mobile/data/sound/touch/keysharp.wav b/mobile/data/sound/touch/keysharp.wav Binary files differnew file mode 100755 index 0000000..ce7cd88 --- /dev/null +++ b/mobile/data/sound/touch/keysharp.wav diff --git a/data/mobile/sound/touch/sip_backspace.wav b/mobile/data/sound/touch/sip.wav Binary files differindex 5b44d12..5b44d12 100755 --- a/data/mobile/sound/touch/sip_backspace.wav +++ b/mobile/data/sound/touch/sip.wav diff --git a/data/mobile/sound/operation/volume_control.wav b/mobile/data/sound/touch/touch.wav Binary files differindex 1ec9de4..1ec9de4 100755 --- a/data/mobile/sound/operation/volume_control.wav +++ b/mobile/data/sound/touch/touch.wav diff --git a/mobile/include/feedback-ids-mobile.h b/mobile/include/feedback-ids-mobile.h new file mode 100644 index 0000000..c1932f0 --- /dev/null +++ b/mobile/include/feedback-ids-mobile.h @@ -0,0 +1,109 @@ +/* + * 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 __FEEDBACK_IDS_MOBILE_H__ +#define __FEEDBACK_IDS_MOBILE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file feedback-ids-mobile.h + * @brief This file contains the feedback API + */ + +/** + * @addtogroup CAPI_FEEDBACK_MODULE + * @{ + */ + +/** + * @brief Enumerations of the type for feedback interface + * @details + * + */ +typedef enum +{ + FEEDBACK_TYPE_MOBILE_LED = FEEDBACK_TYPE_END, + FEEDBACK_TYPE_MOBILE_END, +} feedback_mobile_type_e; + +/** + * @brief Enumerations of the system pre-defined patterns for feedback interface + * @details + * Each feedback pattern can have separate media files of each types. + * But Depending on vendor design, pattern may not have any type of file. + * + */ +typedef enum +{ + FEEDBACK_PATTERN_MOBILE_NONE = -1, + + FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE = FEEDBACK_PATTERN_END, /**< feedback pattern when touch backspace key */ + FEEDBACK_PATTERN_MOBILE_SIP_FUNCTION, /**< feedback pattern when touch function key */ + FEEDBACK_PATTERN_MOBILE_SIP_FJKEY, /**< feedback pattern when touch F,J key */ + FEEDBACK_PATTERN_MOBILE_MAX_CHARACTER, /**< feedback pattern when max character */ + FEEDBACK_PATTERN_MOBILE_MULTI_TAP, /**< feedback pattern when multi touch */ + + FEEDBACK_PATTERN_MOBILE_MESSAGE_ON_CALL, /**< feedback pattern when incoming a message on call */ + FEEDBACK_PATTERN_MOBILE_EMAIL_ON_CALL, /**< feedback pattern when incoming an email on call */ + FEEDBACK_PATTERN_MOBILE_WAKEUP_ON_CALL, /**< feedback pattern when alert wake up call on call */ + FEEDBACK_PATTERN_MOBILE_SCHEDULE_ON_CALL, /**< feedback pattern when alert schedule alarm on call */ + FEEDBACK_PATTERN_MOBILE_TIMER_ON_CALL, /**< feedback pattern when alert timer on call */ + FEEDBACK_PATTERN_MOBILE_GENERAL_ON_CALL, /**< feedback pattern when alert general event on call */ + FEEDBACK_PATTERN_MOBILE_SMART_ALERT, /**< feedback pattern when alert noti on motion */ + + FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL, /**< feedback pattern when connecting charger on call */ + FEEDBACK_PATTERN_MOBILE_CHARGING_ERROR_ON_CALL,/**< feedback pattern when occuring charging error on call */ + FEEDBACK_PATTERN_MOBILE_FULLCHARGED_ON_CALL, /**< feedback pattern when full charged on call */ + FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL, /**< feedback pattern when low battery on call */ + FEEDBACK_PATTERN_MOBILE_LOCK_SWIPE, /**< feedback pattern when lock swipe */ + FEEDBACK_PATTERN_MOBILE_UNLOCK_SWIPE, /**< feedback pattern when unlock swipe*/ + FEEDBACK_PATTERN_MOBILE_GEOMETRIC_LOCK, /**< feedback pattern when lock by geometric effect */ + FEEDBACK_PATTERN_MOBILE_CALLCONNECT, /**< feedback pattern when connecting call */ + FEEDBACK_PATTERN_MOBILE_DISCALLCONNECT, /**< feedback pattern when disconnecting call */ + FEEDBACK_PATTERN_MOBILE_OUTGOING_CALL, /**< feedback pattern when connected outgoing call */ + FEEDBACK_PATTERN_MOBILE_MINUTEMINDER, /**< feedback pattern when minute minder */ + FEEDBACK_PATTERN_MOBILE_BT_PAIRING, /**< feedback pattern when starting pare with bluetooth */ + FEEDBACK_PATTERN_MOBILE_BT_WAITING, /**< feedback pattern when pairing bluetooth */ + FEEDBACK_PATTERN_MOBILE_SCREEN_CAPTURE, /**< feedback pattern when screen capture */ + FEEDBACK_PATTERN_MOBILE_MMS, /**< feedback pattern when message state changed to MMS */ + FEEDBACK_PATTERN_MOBILE_HOURLY_ALERT, /**< feedback pattern when alert every hour on the hour */ + + FEEDBACK_PATTERN_MOBILE_SAFETY_ALERT, /**< feedback pattern when safety alert from phone */ + FEEDBACK_PATTERN_MOBILE_ACCIDENT_DETECT, /**< feedback pattern when accident detect */ + FEEDBACK_PATTERN_MOBILE_SEND_SOS_MESSAGE, /**< feedback pattern when sending SOS message */ + FEEDBACK_PATTERN_MOBILE_END_SOS_MESSAGE, /**< feedback pattern when finishing SOS message */ + FEEDBACK_PATTERN_MOBILE_EMERGENCY_BUZZER, /**< feedback pattern when occurs emergency buzzer */ + FEEDBACK_PATTERN_MOBILE_SAFETY_LOW_POWER, /**< this pattern is a low power ringtone */ + FEEDBACK_PATTERN_MOBILE_CMAS, /**< feedback pattern when alerting commercial mobile */ + + FEEDBACK_PATTERN_MOBILE_END, + +} feedback_pattern_mobile_e; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif //__FEEDBACK_IDS_MOBILE_H__ diff --git a/mobile/src/check.c b/mobile/src/check.c new file mode 100644 index 0000000..7783487 --- /dev/null +++ b/mobile/src/check.c @@ -0,0 +1,412 @@ +/* + * 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 <vconf.h> + +#include "feedback.h" +#include "feedback-ids-mobile.h" +#include "profiles.h" +#include "log.h" + +/* Temporary keys */ +#ifndef VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL +#define VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL "db/setting/sound/vibrate_when_notification" +#endif +#ifndef VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL +#define VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL "db/setting/sound/haptic_feedback_on" +#endif + + +static const char *mobile_str_type[] = +{ + "FEEDBACK_TYPE_NONE", + "FEEDBACK_TYPE_SOUND", + "FEEDBACK_TYPE_VIBRATION", + "FEEDBACK_TYPE_MOBILE_LED", +}; + +static const char *mobile_str_pattern[] = +{ + "FEEDBACK_PATTERN_TAP", + "FEEDBACK_PATTERN_SIP", + "FEEDBACK_PATTERN_KEY0", + "FEEDBACK_PATTERN_KEY1", + "FEEDBACK_PATTERN_KEY2", + "FEEDBACK_PATTERN_KEY3", + "FEEDBACK_PATTERN_KEY4", + "FEEDBACK_PATTERN_KEY5", + "FEEDBACK_PATTERN_KEY6", + "FEEDBACK_PATTERN_KEY7", + "FEEDBACK_PATTERN_KEY8", + "FEEDBACK_PATTERN_KEY9", + "FEEDBACK_PATTERN_KEY_STAR", + "FEEDBACK_PATTERN_KEY_SHARP", + "FEEDBACK_PATTERN_KEY_BACK", + "FEEDBACK_PATTERN_HOLD", + "FEEDBACK_PATTERN_HW_TAP", + "FEEDBACK_PATTERN_HW_HOLD", + + "FEEDBACK_PATTERN_MESSAGE", + "FEEDBACK_PATTERN_EMAIL", + "FEEDBACK_PATTERN_WAKEUP", + "FEEDBACK_PATTERN_SCHEDULE", + "FEEDBACK_PATTERN_TIMER", + "FEEDBACK_PATTERN_GENERAL", + + "FEEDBACK_PATTERN_POWERON", + "FEEDBACK_PATTERN_POWEROFF", + "FEEDBACK_PATTERN_CHARGERCONN", + "FEEDBACK_PATTERN_CHARGING_ERROR", + "FEEDBACK_PATTERN_FULLCHARGED", + "FEEDBACK_PATTERN_LOWBATT", + "FEEDBACK_PATTERN_LOCK", + "FEEDBACK_PATTERN_UNLOCK", + "FEEDBACK_PATTERN_VIBRATION_ON", + "FEEDBACK_PATTERN_SILENT_OFF", + "FEEDBACK_PATTERN_BT_CONNECTED", + "FEEDBACK_PATTERN_BT_DISCONNECTED", + "FEEDBACK_PATTERN_LIST_REORDER", + "FEEDBACK_PATTERN_LIST_SLIDER", + "FEEDBACK_PATTERN_VOLUME_KEY", + + "FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE", + "FEEDBACK_PATTERN_MOBILE_SIP_FUNCTION", + "FEEDBACK_PATTERN_MOBILE_SIP_FJKEY", + "FEEDBACK_PATTERN_MOBILE_MAX_CHARACTER", + "FEEDBACK_PATTERN_MOBILE_MULTI_TAP", + + "FEEDBACK_PATTERN_MOBILE_MESSAGE_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_EMAIL_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_WAKEUP_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_SCHEDULE_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_TIMER_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_GENERAL_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_SMART_ALERT", + + "FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_CHARGING_ERROR_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_FULLCHARGED_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL", + "FEEDBACK_PATTERN_MOBILE_LOCK_SWIPE", + "FEEDBACK_PATTERN_MOBILE_UNLOCK_SWIPE", + "FEEDBACK_PATTERN_MOBILE_GEOMETRIC_LOCK", + "FEEDBACK_PATTERN_MOBILE_CALLCONNECT", + "FEEDBACK_PATTERN_MOBILE_DISCALLCONNECT", + "FEEDBACK_PATTERN_MOBILE_OUTGOING_CALL", + "FEEDBACK_PATTERN_MOBILE_MINUTEMINDER", + "FEEDBACK_PATTERN_MOBILE_BT_PAIRING", + "FEEDBACK_PATTERN_MOBILE_BT_WAITING", + "FEEDBACK_PATTERN_MOBILE_SCREEN_CAPTURE", + "FEEDBACK_PATTERN_MOBILE_MMS", + "FEEDBACK_PATTERN_MOBILE_HOURLY_ALERT", + + "FEEDBACK_PATTERN_MOBILE_SAFETY_ALERT", + "FEEDBACK_PATTERN_MOBILE_ACCIDENT_DETECT", + "FEEDBACK_PATTERN_MOBILE_SEND_SOS_MESSAGE", + "FEEDBACK_PATTERN_MOBILE_END_SOS_MESSAGE", + "FEEDBACK_PATTERN_MOBILE_EMERGENCY_BUZZER", + "FEEDBACK_PATTERN_MOBILE_SAFETY_LOW_POWER", + "FEEDBACK_PATTERN_MOBILE_CMAS", +}; + +static int callstatus; +static int alert_callstatus; +static int lock_sndstatus; +static int camerastatus; +static int shutter_sndstatus; +static int noti_vibstatus; +static int vib_level; +static int noti_level; +static int feedbackstatus; + +static void feedback_callstatus_cb(keynode_t *key, void* data) +{ + callstatus = vconf_keynode_get_int(key); +} + +static void feedback_alertstatus_cb(keynode_t *key, void* data) +{ + alert_callstatus = vconf_keynode_get_int(key); +} + +static void feedback_lock_sndstatus_cb(keynode_t *key, void* data) +{ + lock_sndstatus = vconf_keynode_get_bool(key); +} + +static void feedback_camerastatus_cb(keynode_t *key, void* data) +{ + camerastatus = vconf_keynode_get_int(key); +} + +static void feedback_noti_vibstatus_cb(keynode_t *key, void* data) +{ + noti_vibstatus = vconf_keynode_get_bool(key); +} + +static void feedback_vib_cb(keynode_t *key, void* data) +{ + vib_level = vconf_keynode_get_int(key); +} + +static void feedback_noti_cb(keynode_t *key, void* data) +{ + noti_level = vconf_keynode_get_int(key); +} + +static void feedback_feedbackstatus_cb(keynode_t *key, void* data) +{ + feedbackstatus = vconf_keynode_get_bool(key); +} + +static void mobile_init(void) +{ + /* check call status */ + if (vconf_get_int(VCONFKEY_CALL_STATE, &callstatus) < 0) + _W("VCONFKEY_CALL_STATE ==> FAIL!!"); + + /* alert option on call */ + if (vconf_get_int(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, &alert_callstatus) < 0) + _W("VCONFKEY_CISSAPPL_ON_CALL_INT ==> FAIL!!"); + + if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &lock_sndstatus) < 0) + _W("VCONFKEY_SETAPPL_SOUND_LOCK_BOOL ==> FAIL!!"); + + /* check camera status */ + if (vconf_get_int(VCONFKEY_CAMERA_STATE, &camerastatus) < 0) + _W("VCONFKEY_CAMERA_STATE ==> FAIL!!"); + + /* shutter sound policy */ + // This vconf is read just once, because this value is not changed in running time. + if (vconf_get_int(VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY, &shutter_sndstatus) < 0) + _W("VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY ==> FAIL!!"); + + /* check vibration status */ + if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, ¬i_vibstatus) < 0) + _W("VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL ==> FAIL!!"); + + /* check vib_level */ + if (vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vib_level) < 0) + _W("VCONFKEY_FEEDBACK_VIBRATION_LEVEL_INT ==> FAIL!!"); + + /* check noti_level */ + if (vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, ¬i_level) < 0) + _W("VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT ==> FAIL!!"); + + /* feedback Init */ + if(vconf_get_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, &feedbackstatus) < 0) + _W("VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL ==> FAIL!!"); + + /* add watch for status value */ + vconf_notify_key_changed(VCONFKEY_CALL_STATE, feedback_callstatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, feedback_alertstatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, feedback_lock_sndstatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_CAMERA_STATE, feedback_camerastatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, feedback_noti_vibstatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, feedback_vib_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, feedback_noti_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, feedback_feedbackstatus_cb, NULL); +} + +static void mobile_exit(void) +{ + /* remove watch */ + vconf_ignore_key_changed(VCONFKEY_CALL_STATE, feedback_callstatus_cb); + vconf_ignore_key_changed(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, feedback_alertstatus_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, feedback_lock_sndstatus_cb); + vconf_ignore_key_changed(VCONFKEY_CAMERA_STATE, feedback_camerastatus_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, feedback_noti_vibstatus_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, feedback_vib_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, feedback_noti_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, feedback_feedbackstatus_cb); +} + +static bool mobile_get_switched_pattern(int pattern, int *switched) +{ + if (!switched) + return false; + + if (callstatus == VCONFKEY_CALL_OFF) + return false; + + /* in case of call connected or connecting */ + _D("Call status is connected or connecting."); + if (pattern == FEEDBACK_PATTERN_MESSAGE) + *switched = FEEDBACK_PATTERN_MOBILE_MESSAGE_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_EMAIL) + *switched = FEEDBACK_PATTERN_MOBILE_EMAIL_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_WAKEUP) + *switched = FEEDBACK_PATTERN_MOBILE_WAKEUP_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_SCHEDULE) + *switched = FEEDBACK_PATTERN_MOBILE_SCHEDULE_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_TIMER) + *switched = FEEDBACK_PATTERN_MOBILE_TIMER_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_GENERAL) + *switched = FEEDBACK_PATTERN_MOBILE_GENERAL_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_CHARGERCONN) + *switched = FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_CHARGING_ERROR) + *switched = FEEDBACK_PATTERN_MOBILE_CHARGING_ERROR_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_FULLCHARGED) + *switched = FEEDBACK_PATTERN_MOBILE_FULLCHARGED_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_LOWBATT) + *switched = FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL; + + return true; +} + +static bool mobile_get_always_alert_case(int type, int pattern) +{ + switch (pattern) { + case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: + case FEEDBACK_PATTERN_HOLD: + if (CHECK_VIBRATION(type) && feedbackstatus) + return true; + break; + case FEEDBACK_PATTERN_SIP: + case FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE: + case FEEDBACK_PATTERN_MOBILE_SIP_FUNCTION: + case FEEDBACK_PATTERN_MOBILE_SIP_FJKEY: + if (CHECK_VIBRATION(type)) + return true; + break; + case FEEDBACK_PATTERN_MESSAGE: + case FEEDBACK_PATTERN_EMAIL: + if (CHECK_VIBRATION(type) && noti_vibstatus) + return true; + break; + case FEEDBACK_PATTERN_TIMER: + case FEEDBACK_PATTERN_MOBILE_TIMER_ON_CALL: + if (CHECK_VIBRATION(type)) + return true; + break; + case FEEDBACK_PATTERN_WAKEUP: + case FEEDBACK_PATTERN_MOBILE_WAKEUP_ON_CALL: + return true; + case FEEDBACK_PATTERN_MOBILE_MESSAGE_ON_CALL: + case FEEDBACK_PATTERN_MOBILE_EMAIL_ON_CALL: + case FEEDBACK_PATTERN_MOBILE_GENERAL_ON_CALL: + if (alert_callstatus) + return true; + break; + case FEEDBACK_PATTERN_MOBILE_CHARGERCONN_ON_CALL: + case FEEDBACK_PATTERN_MOBILE_CHARGING_ERROR_ON_CALL: + case FEEDBACK_PATTERN_MOBILE_LOWBATT_ON_CALL: + case FEEDBACK_PATTERN_MOBILE_MMS: + case FEEDBACK_PATTERN_MOBILE_HOURLY_ALERT: + /* no matter sound profile */ + if (CHECK_VIBRATION(type)) + return true; + break; + case FEEDBACK_PATTERN_MOBILE_SMART_ALERT: + case FEEDBACK_PATTERN_MOBILE_SEND_SOS_MESSAGE: + case FEEDBACK_PATTERN_MOBILE_END_SOS_MESSAGE: + case FEEDBACK_PATTERN_MOBILE_CMAS: + case FEEDBACK_PATTERN_MOBILE_OUTGOING_CALL: + return true; + case FEEDBACK_PATTERN_MOBILE_SCREEN_CAPTURE: + if (CHECK_SOUND(type) && camerastatus && shutter_sndstatus) + return true; + break; + default: + break; + } + return false; +} + +static bool mobile_get_always_off_case(int type, int pattern) +{ + int ret; + + /* check if the state of voice recorder is recording */ + if (vconf_get_int(VCONFKEY_SOUND_STATUS, &ret) < 0) { + _D("fail to get media sound status, status will be zero"); + ret = 0; + } + + if (CHECK_SOUND(type) && ret & VCONFKEY_SOUND_STATUS_AVRECORDING) { + _D("voice recording status is RECORDING"); + return true; + } + + switch (pattern) { + case FEEDBACK_PATTERN_TAP ... FEEDBACK_PATTERN_SIP: + case FEEDBACK_PATTERN_HOLD ... FEEDBACK_PATTERN_HW_HOLD: + case FEEDBACK_PATTERN_MOBILE_SIP_BACKSPACE ... FEEDBACK_PATTERN_MOBILE_MAX_CHARACTER: + if (CHECK_SOUND(type) && !is_touch_sndstatus()) + return true; + break; + case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: + if (CHECK_SOUND(type) && !is_keytone_sndstatus()) + return true; + else if (CHECK_VIBRATION(type) && !feedbackstatus) + return true; + break; + case FEEDBACK_PATTERN_LOCK: + case FEEDBACK_PATTERN_UNLOCK: + case FEEDBACK_PATTERN_MOBILE_LOCK_SWIPE: + case FEEDBACK_PATTERN_MOBILE_UNLOCK_SWIPE: + if (CHECK_SOUND(type) && !lock_sndstatus) + return true; + break; + default: + break; + } + return false; +} + +static int mobile_get_strength_type(int type, int pattern) +{ + if (CHECK_SOUND(type)) { + if (pattern == FEEDBACK_PATTERN_TAP) + return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_TOUCH; + else if (pattern >= FEEDBACK_PATTERN_KEY0 && pattern <= FEEDBACK_PATTERN_KEY_BACK) + return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_DIALER; + else if (pattern == FEEDBACK_PATTERN_VOLUME_KEY) + return VOLUME_TYPE_RINGTONE; + else if (camerastatus && shutter_sndstatus && pattern == FEEDBACK_PATTERN_MOBILE_SCREEN_CAPTURE) + return VOLUME_TYPE_FIXED; + else + return VOLUME_TYPE_SYSTEM; + } else if (CHECK_VIBRATION(type)) { + if (pattern >= FEEDBACK_PATTERN_MESSAGE && + pattern <= FEEDBACK_PATTERN_GENERAL) + return noti_level * HAPTIC_FEEDBACK_STEP; + else + return vib_level * HAPTIC_FEEDBACK_STEP; + } + + return -EINVAL; +} + +static const struct profile_ops mobile_profile_ops = { + .profile = "mobile", + .init = mobile_init, + .exit = mobile_exit, + .get_switched_pattern = mobile_get_switched_pattern, + .get_always_alert_case = mobile_get_always_alert_case, + .get_always_off_case = mobile_get_always_off_case, + .get_strength_type = mobile_get_strength_type, + .max_type = FEEDBACK_TYPE_MOBILE_END, + .max_pattern = FEEDBACK_PATTERN_MOBILE_END, + .str_type = mobile_str_type, + .str_pattern = mobile_str_pattern, +}; + +PROFILE_OPS_REGISTER(&mobile_profile_ops); diff --git a/packaging/libfeedback.spec b/packaging/libfeedback.spec index fee4ff9..5e5682f 100644 --- a/packaging/libfeedback.spec +++ b/packaging/libfeedback.spec @@ -53,11 +53,13 @@ cp %{SOURCE2} . %define ARCH emulator %endif -%cmake \ %if "%{?tizen_profile_name}" == "wearable" - -DMICRO_DD=YES \ +%define PROFILE wearable +%else if "%{?tizen_profile_name}" == "mobile" +%define PROFILE mobile %endif - . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCH=%{ARCH} + +%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DARCH=%{ARCH} -DPROFILE=%{PROFILE} make %install diff --git a/include/common.h b/src/common.h index 71fa321..ddfae02 100644 --- a/include/common.h +++ b/src/common.h @@ -19,6 +19,10 @@ #ifndef __COMMON_H__ #define __COMMON_H__ +#include <stdbool.h> +#include <errno.h> +#include <mm_sound_private.h> + #ifdef __cplusplus extern "C" { #endif @@ -28,18 +32,40 @@ extern "C" { * @brief This file contains the common information */ +#ifndef __CONSTRUCTOR__ +#define __CONSTRUCTOR__ __attribute__ ((constructor)) +#endif + +#ifndef __DESTRUCTOR__ +#define __DESTRUCTOR__ __attribute__ ((destructor)) +#endif + +#ifndef __DD_LIST__ +#define __DD_LIST__ +#include <glib.h> +typedef GList dd_list; +#define DD_LIST_PREPEND(a, b) \ + a = g_list_prepend(a, b) +#define DD_LIST_APPEND(a, b) \ + a = g_list_append(a, b) +#define DD_LIST_REMOVE(a, b) \ + a = g_list_remove(a, b) +#define DD_LIST_FOREACH(head, elem, node) \ + for (elem = head; elem && ((node = elem->data) != NULL); elem = elem->next, node = NULL) +#endif + #define FEEDBACK_DATA_DIR "/opt/usr/share/feedback" #define FEEDBACK_ORIGIN_DATA_DIR "/usr/share/feedback" #define FEEDBACK_RETRY_CNT 1 -extern int callstatus; -extern int alert_callstatus; - -extern const char *str_type[]; -extern const char *str_pattern[]; +#define DEFAULT_VIB_LEVEL 3 +#define HAPTIC_FEEDBACK_STEP 20 /**< feedback max / slider step */ int is_sound_mode(void); +int is_touch_sndstatus(void); +int is_keytone_sndstatus(void); +int is_vibration_mode(void); #ifdef __cplusplus } diff --git a/include/dbus.h b/src/dbus.h index 9710b59..9710b59 100644 --- a/include/dbus.h +++ b/src/dbus.h diff --git a/src/devices.c b/src/devices.c index e135e07..8d351e4 100644 --- a/src/devices.c +++ b/src/devices.c @@ -18,22 +18,10 @@ #include <stdio.h> -#include <glib.h> #include "devices.h" -#include "common.h" #include "log.h" -#define DD_LIST_PREPEND(a, b) \ - a = g_list_prepend(a, b) -#define DD_LIST_APPEND(a, b) \ - a = g_list_append(a, b) -#define DD_LIST_REMOVE(a, b) \ - a = g_list_remove(a, b) -#define DD_LIST_FOREACH(head, elem, node) \ - for (elem = head; elem && ((node = elem->data) != NULL); elem = elem->next, node = NULL) - -typedef GList dd_list; static dd_list *dev_head; void add_device(const struct device_ops *dev) @@ -64,7 +52,7 @@ void devices_init(void) const struct device_ops *dev; DD_LIST_FOREACH(dev_head, elem, dev) { - _D("[%s] initialize", str_type[dev->type]); + _D("[%s] initialize", dev->name); if (dev->init) dev->init(); } @@ -76,30 +64,45 @@ void devices_exit(void) const struct device_ops *dev; DD_LIST_FOREACH(dev_head, elem, dev) { - _D("[%s] deinitialize", str_type[dev->type]); + _D("[%s] deinitialize", dev->name); if (dev->exit) dev->exit(); } } -void devices_play(int pattern) +int devices_play(int pattern) { dd_list *elem; const struct device_ops *dev; + int ret, prev = -EPERM; DD_LIST_FOREACH(dev_head, elem, dev) { - if (dev->play) - dev->play(pattern); + if (dev->play) { + ret = dev->play(pattern); + if ((prev < 0 && ret == 0) || + (prev == 0 && ret < 0)) + prev = 0; + else if ((prev < 0 && ret == -ENOTSUP) || + (prev == -ENOTSUP && ret < 0)) + prev = -ENOTSUP; + else + prev = ret; + } } + + return prev; } -void devices_stop(void) +int devices_stop(void) { dd_list *elem; const struct device_ops *dev; + int ret = -ENOTSUP; DD_LIST_FOREACH(dev_head, elem, dev) { if (dev->stop) - dev->stop(); + ret = dev->stop(); } + + return ret; } diff --git a/include/devices.h b/src/devices.h index 2fdd215..2774967 100644 --- a/include/devices.h +++ b/src/devices.h @@ -20,28 +20,25 @@ #ifndef __DEVICES_H__ #define __DEVICES_H__ +#include <stdbool.h> +#include "common.h" + struct device_ops { int type; + const char *name; void (*init) (void); void (*exit) (void); int (*play) (int); int (*stop) (void); + int (*is_supported) (int, bool *); int (*get_path) (int, char *, unsigned int); int (*set_path) (int, char *); }; void devices_init(void); void devices_exit(void); -void devices_play(int pattern); -void devices_stop(void); - -#ifndef __CONSTRUCTOR__ -#define __CONSTRUCTOR__ __attribute__ ((constructor)) -#endif - -#ifndef __DESTRUCTOR__ -#define __DESTRUCTOR__ __attribute__ ((destructor)) -#endif +int devices_play(int pattern); +int devices_stop(void); #define DEVICE_OPS_REGISTER(dev) \ static void __CONSTRUCTOR__ module_init(void) \ diff --git a/src/feedback.c b/src/feedback.c index f14ffef..273318d 100644 --- a/src/feedback.c +++ b/src/feedback.c @@ -20,130 +20,153 @@ #include <stdbool.h> #include <string.h> #include <limits.h> -#include <vconf.h> #include "feedback.h" -#include "common.h" -#include "log.h" +#include "profiles.h" #include "devices.h" +#include "log.h" #ifndef API #define API __attribute__ ((visibility("default"))) #endif -int callstatus; -int alert_callstatus; - static bool binit; -static void feedback_callstatus_cb(keynode_t *key, void* data) +API int feedback_initialize(void) { - callstatus = vconf_keynode_get_int(key); -} - -static void feedback_alertstatus_cb(keynode_t *key, void* data) -{ - alert_callstatus = vconf_keynode_get_int(key); -} + if (binit) + return FEEDBACK_ERROR_NONE; -static feedback_pattern_e get_alert_on_call_key(feedback_pattern_e pattern) -{ - switch(pattern) { - case FEEDBACK_PATTERN_MESSAGE: - case FEEDBACK_PATTERN_EMAIL: - case FEEDBACK_PATTERN_WAKEUP: - case FEEDBACK_PATTERN_SCHEDULE: - case FEEDBACK_PATTERN_TIMER: - case FEEDBACK_PATTERN_GENERAL: - case FEEDBACK_PATTERN_CHARGERCONN: - case FEEDBACK_PATTERN_CHARGING_ERROR: - case FEEDBACK_PATTERN_FULLCHARGED: - case FEEDBACK_PATTERN_LOWBATT: - return (feedback_pattern_e)(pattern+1); - default: - break; + if (!profile) { + _E("there is no valid profile module."); + return FEEDBACK_ERROR_NOT_SUPPORTED; } - return pattern; + /* initialize device */ + devices_init(); + + /* initialize profile feature */ + if (profile->init) + profile->init(); + + binit = true; + return FEEDBACK_ERROR_NONE; } -static void __DESTRUCTOR__ module_exit(void) +API int feedback_deinitialize(void) { if (!binit) - return; - - vconf_ignore_key_changed(VCONFKEY_CALL_STATE, feedback_callstatus_cb); - vconf_ignore_key_changed(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, feedback_alertstatus_cb); + return FEEDBACK_ERROR_NOT_INITIALIZED; /* deinitialize device */ devices_exit(); + /* deinitialize profile feature */ + if (profile->exit) + profile->exit(); + binit = false; + return FEEDBACK_ERROR_NONE; } -API int feedback_initialize() +API int feedback_play(feedback_pattern_e pattern) { - if (binit) - return FEEDBACK_ERROR_NONE; - - /* check call status */ - if (vconf_get_int(VCONFKEY_CALL_STATE, &callstatus) < 0) - _W("VCONFKEY_CALL_STATE ==> FAIL!!"); + int err; + bool result; + int switched; + /* check initialize */ + if (!binit) { + _E("Not initialized"); + return FEEDBACK_ERROR_NOT_INITIALIZED; + } - /* alert option on call */ - if (vconf_get_int(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, &alert_callstatus) < 0) - _W("VCONFKEY_CISSAPPL_ON_CALL_INT ==> FAIL!!"); + if (pattern <= FEEDBACK_PATTERN_NONE || + pattern >= profile->max_pattern) { + _E("Invalid parameter : pattern(%d)", pattern); + return FEEDBACK_ERROR_INVALID_PARAMETER; + } - /* add watch for status value */ - vconf_notify_key_changed(VCONFKEY_CALL_STATE, feedback_callstatus_cb, NULL); - vconf_notify_key_changed(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, feedback_alertstatus_cb, NULL); + /* if you need to switch pattern */ + if (profile->get_switched_pattern) { + result = profile->get_switched_pattern(pattern, &switched); + if (result) { + _W("pattern is changed : (%s) -> (%s)", + profile->str_pattern[pattern], profile->str_pattern[switched]); + pattern = switched; + } + } - /* initialize device */ - devices_init(); + /* play all device */ + err = devices_play(pattern); + /** + * devices_play() returns error even if all devices are failed. + * It means if to play anything is successful, + * this function regards as success. + */ + if (err == -ENOTSUP) + return FEEDBACK_ERROR_NOT_SUPPORTED; + else if (err < 0) + return FEEDBACK_ERROR_OPERATION_FAILED; - binit = true; return FEEDBACK_ERROR_NONE; } -API int feedback_deinitialize() +API int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern) { - return FEEDBACK_ERROR_NONE; -} + const struct device_ops *dev; + int err; + bool result; + int switched; -API int feedback_play(feedback_pattern_e pattern) -{ /* check initialize */ if (!binit) { _E("Not initialized"); return FEEDBACK_ERROR_NOT_INITIALIZED; } - if (pattern < FEEDBACK_PATTERN_NONE || pattern >= FEEDBACK_PATTERN_END) { + if (type <= FEEDBACK_TYPE_NONE || + type >= profile->max_type) { + _E("Invalid parameter : type(%d)", type); + return FEEDBACK_ERROR_INVALID_PARAMETER; + } + + if (pattern <= FEEDBACK_PATTERN_NONE || + pattern >= profile->max_pattern) { _E("Invalid parameter : pattern(%d)", pattern); return FEEDBACK_ERROR_INVALID_PARAMETER; } - if (pattern == FEEDBACK_PATTERN_NONE) { - _D("pattern is NONE"); - return FEEDBACK_ERROR_NONE; + /* if you need to switch pattern */ + if (profile->get_switched_pattern) { + result = profile->get_switched_pattern(pattern, &switched); + if (result) { + _W("pattern is changed : (%s) -> (%s)", + profile->str_pattern[pattern], profile->str_pattern[switched]); + pattern = switched; + } } - /* in case of call connected or connecting */ - if (callstatus != VCONFKEY_CALL_OFF) { - pattern = get_alert_on_call_key(pattern); - _D("Call status is connected or connecting. pattern changed : %s", str_pattern[pattern]); + /* play proper device */ + dev = find_device(type); + if (!dev) { + _E("Not supported device : type(%s)", profile->str_type[type]); + return FEEDBACK_ERROR_NOT_SUPPORTED; } - /* play all device */ - devices_play(pattern); + err = dev->play(pattern); + if (err == -ENOTSUP) + return FEEDBACK_ERROR_NOT_SUPPORTED; + else if (err == -ECOMM) + return FEEDBACK_ERROR_PERMISSION_DENIED; + else + return FEEDBACK_ERROR_OPERATION_FAILED; return FEEDBACK_ERROR_NONE; } -API int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern) +API int feedback_stop(void) { - const struct device_ops *dev; int err; /* check initialize */ @@ -152,75 +175,106 @@ API int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern) return FEEDBACK_ERROR_NOT_INITIALIZED; } - if (type <= FEEDBACK_TYPE_NONE || type >= FEEDBACK_TYPE_END) { - _E("Invalid parameter : type(%d)", type); - return FEEDBACK_ERROR_INVALID_PARAMETER; + /* stop all device */ + err = devices_stop(); + if (err == -ENOTSUP) + return FEEDBACK_ERROR_NOT_SUPPORTED; + else if (err == -ECOMM) + return FEEDBACK_ERROR_PERMISSION_DENIED; + else + return FEEDBACK_ERROR_OPERATION_FAILED; + + return FEEDBACK_ERROR_NONE; +} + +API int feedback_is_supported_pattern(feedback_type_e type, feedback_pattern_e pattern, bool *status) +{ + const struct device_ops *dev; + bool supported; + int err; + bool result; + int switched; + + /* check initialize */ + if (!binit) { + _E("Not initialized"); + return FEEDBACK_ERROR_NOT_INITIALIZED; } - if (pattern < FEEDBACK_PATTERN_NONE || pattern >= FEEDBACK_PATTERN_END) { - _E("Invalid parameter : pattern(%d)", pattern); + if (!status) { + _E("Invalid parameter : status(NULL)"); return FEEDBACK_ERROR_INVALID_PARAMETER; } - if (pattern == FEEDBACK_PATTERN_NONE) { - _D("pattern is NONE"); - return FEEDBACK_ERROR_NONE; + if (type <= FEEDBACK_TYPE_NONE || + type >= profile->max_type) { + _E("Invalid parameter : type(%d)", type); + return FEEDBACK_ERROR_INVALID_PARAMETER; } - /* in case of call connected or connecting */ - if (callstatus != VCONFKEY_CALL_OFF) { - pattern = get_alert_on_call_key(pattern); - _D("Call status is connected or connecting. pattern changed : %s", str_pattern[pattern]); + if (pattern <= FEEDBACK_PATTERN_NONE || + pattern >= profile->max_pattern) { + _E("Invalid parameter : pattern(%d)", pattern); + return FEEDBACK_ERROR_INVALID_PARAMETER; } - /* should play led regardless of sound or vibration */ - dev = find_device(FEEDBACK_TYPE_LED); - if (dev) { - err = dev->play(pattern); - if (err < 0) - _E("feedback_play_led is failed"); + /* if you need to switch pattern */ + if (profile->get_switched_pattern) { + result = profile->get_switched_pattern(pattern, &switched); + if (result) { + _W("pattern is changed : (%s) -> (%s)", + profile->str_pattern[pattern], profile->str_pattern[switched]); + pattern = switched; + } } - if (type == FEEDBACK_TYPE_LED) - return FEEDBACK_ERROR_NONE; - /* play proper device */ dev = find_device(type); - if (dev) { - err = dev->play(pattern); - if (err < 0) - _E("fail to play sound"); + if (!dev) { + _E("Not supported device : type(%s)", profile->str_type[type]); + return FEEDBACK_ERROR_NOT_SUPPORTED; + } + + err = dev->is_supported(pattern, &supported); + if (err < 0) { + _E("fail to invoke is_supported() : pattern(%s)", profile->str_pattern[pattern]); + return FEEDBACK_ERROR_OPERATION_FAILED; } return FEEDBACK_ERROR_NONE; } +/* Internal APIs */ API int feedback_play_type_by_name(char *type, char *pattern) { feedback_type_e etype; feedback_pattern_e epattern; + int type_max; + int pattern_max; if (!type || !pattern) { _E("Invalid parameter : type(%x), pattern(%x)", type, pattern); return FEEDBACK_ERROR_INVALID_PARAMETER; } - for (etype = FEEDBACK_TYPE_NONE; etype < FEEDBACK_TYPE_END; ++etype) { - if (!strncmp(type, str_type[etype], strlen(type))) + type_max = profile->max_type; + for (etype = 0; etype < type_max; ++etype) { + if (!strncmp(type, profile->str_type[etype], strlen(type))) break; } - if (etype == FEEDBACK_TYPE_END) { + if (etype == type_max) { _E("Invalid parameter : type(%s)", type); return FEEDBACK_ERROR_INVALID_PARAMETER; } - for (epattern = 0; epattern < FEEDBACK_PATTERN_END; ++epattern) { - if (!strncmp(pattern, str_pattern[epattern], strlen(pattern))) + pattern_max = profile->max_pattern; + for (epattern = 0; epattern < pattern_max; ++epattern) { + if (!strncmp(pattern, profile->str_pattern[epattern], strlen(pattern))) break; } - if (epattern == FEEDBACK_PATTERN_END) { + if (epattern == pattern_max) { _E("Invalid parameter : pattern(%d)", pattern); return FEEDBACK_ERROR_INVALID_PARAMETER; } @@ -228,20 +282,6 @@ API int feedback_play_type_by_name(char *type, char *pattern) return feedback_play_type(etype, epattern); } -API int feedback_stop(void) -{ - /* check initialize */ - if (!binit) { - _E("Not initialized"); - return FEEDBACK_ERROR_NOT_INITIALIZED; - } - - /* stop all device */ - devices_stop(); - - return FEEDBACK_ERROR_NONE; -} - API int feedback_get_resource_path(feedback_type_e type, feedback_pattern_e pattern, char** path) { const struct device_ops *dev; @@ -253,12 +293,14 @@ API int feedback_get_resource_path(feedback_type_e type, feedback_pattern_e patt return FEEDBACK_ERROR_INVALID_PARAMETER; } - if (type <= FEEDBACK_TYPE_NONE || type >= FEEDBACK_TYPE_END) { + if (type <= FEEDBACK_TYPE_NONE || + type >= profile->max_type) { _E("Invalid parameter : type(%d)", type); return FEEDBACK_ERROR_INVALID_PARAMETER; } - if (pattern <= FEEDBACK_PATTERN_NONE || pattern >= FEEDBACK_PATTERN_END) { + if (pattern <= FEEDBACK_PATTERN_NONE || + pattern >= profile->max_pattern) { _E("Invalid parameter : pattern(%d)", pattern); return FEEDBACK_ERROR_INVALID_PARAMETER; } @@ -280,12 +322,14 @@ API int feedback_set_resource_path(feedback_type_e type, feedback_pattern_e patt const struct device_ops *dev; int err; - if (type <= FEEDBACK_TYPE_NONE || type >= FEEDBACK_TYPE_END) { + if (type <= FEEDBACK_TYPE_NONE || + type >= profile->max_type) { _E("Invalid parameter : type(%d)", type); return FEEDBACK_ERROR_INVALID_PARAMETER; } - if (pattern <= FEEDBACK_PATTERN_NONE || pattern >= FEEDBACK_PATTERN_END) { + if (pattern <= FEEDBACK_PATTERN_NONE || + pattern >= profile->max_pattern) { _E("Invalid parameter : pattern(%d)", pattern); return FEEDBACK_ERROR_INVALID_PARAMETER; } diff --git a/include/log.h b/src/log.h index d07bb81..d07bb81 100644 --- a/include/log.h +++ b/src/log.h diff --git a/src/profiles.c b/src/profiles.c new file mode 100644 index 0000000..1f7f2f9 --- /dev/null +++ b/src/profiles.c @@ -0,0 +1,36 @@ +/* + * deviced + * + * 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 <limits.h> + +#include "profiles.h" +#include "log.h" + +static dd_list *profile_head; + +void add_profile(const struct profile_ops *ops) +{ + DD_LIST_APPEND(profile_head, (struct profile_ops*)ops); +} + +void remove_profile(const struct profile_ops *ops) +{ + DD_LIST_REMOVE(profile_head, (struct profile_ops*)ops); +} diff --git a/src/profiles.h b/src/profiles.h new file mode 100644 index 0000000..786b4c7 --- /dev/null +++ b/src/profiles.h @@ -0,0 +1,48 @@ +/* + * 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 __PROFILES_H__ +#define __PROFILES_H__ + +#include <stdbool.h> +#include "common.h" + +struct profile_ops { + const char *profile; + void (*init) (void); + void (*exit) (void); + bool (*get_switched_pattern)(int pattern, int *switched); + bool (*get_always_alert_case)(int type, int pattern); + bool (*get_always_off_case)(int type, int pattern); + int (*get_strength_type)(int type, int pattern); + const int max_type; + const int max_pattern; + const char **str_type; + const char **str_pattern; +}; + +#define PROFILE_OPS_REGISTER(ops) \ + const struct profile_ops *profile = ops + +extern const struct profile_ops *profile; + +#define CHECK_VIBRATION(type) (type == FEEDBACK_TYPE_VIBRATION) +#define CHECK_SOUND(type) (type == FEEDBACK_TYPE_SOUND) + +#endif diff --git a/src/sound.c b/src/sound.c index 0d14b22..49fba53 100644 --- a/src/sound.c +++ b/src/sound.c @@ -28,107 +28,49 @@ #include <mm_sound_private.h> #include "feedback-ids.h" -#include "common.h" -#include "log.h" +#include "profiles.h" #include "devices.h" +#include "log.h" #include "xmlparser.h" #define SOUND_XML "/usr/share/feedback/sound.xml" +/* Temporary keys */ +#ifndef VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL +#define VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL "db/setting/sound/button_sounds" +#endif + static int sndstatus; static int touch_sndstatus; -static int lock_sndstatus; -static int camerastatus; -static int shutter_sndstatus; +static int keytone_sndstatus; static xmlDocPtr v_doc; -static char sound_file[FEEDBACK_PATTERN_END][NAME_MAX]; +static char sound_file[FEEDBACK_PATTERN_END][PATH_MAX]; inline int is_sound_mode(void) { return sndstatus; } -static void feedback_touch_sndstatus_cb(keynode_t *key, void* data) -{ - touch_sndstatus = vconf_keynode_get_bool(key); -} - -static void feedback_lock_sndstatus_cb(keynode_t *key, void* data) -{ - lock_sndstatus = vconf_keynode_get_bool(key); -} - -static void feedback_camerastatus_cb(keynode_t *key, void* data) +inline int is_touch_sndstatus(void) { - camerastatus = vconf_keynode_get_int(key); + return touch_sndstatus; } -static volume_type_t get_volume_type(feedback_pattern_e pattern) +inline int is_keytone_sndstatus(void) { - if (pattern == FEEDBACK_PATTERN_TAP) - return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_TOUCH; - else if (pattern >= FEEDBACK_PATTERN_KEY0 && pattern <= FEEDBACK_PATTERN_KEY_BACK) - return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_DIALER; - else if (pattern == FEEDBACK_PATTERN_VOLUME_KEY) - return VOLUME_TYPE_RINGTONE; - else if (camerastatus && shutter_sndstatus && pattern == FEEDBACK_PATTERN_SCREEN_CAPTURE) - return VOLUME_TYPE_FIXED; - - return VOLUME_TYPE_SYSTEM; + return keytone_sndstatus; } -static bool get_always_alert_case(feedback_pattern_e pattern) +static void feedback_touch_sndstatus_cb(keynode_t *key, void* data) { - switch (pattern) { - case FEEDBACK_PATTERN_WAKEUP: - case FEEDBACK_PATTERN_WAKEUP_ON_CALL: - return true; - case FEEDBACK_PATTERN_MESSAGE_ON_CALL: - case FEEDBACK_PATTERN_EMAIL_ON_CALL: - case FEEDBACK_PATTERN_GENERAL_ON_CALL: - if (alert_callstatus) - return true; - break; - case FEEDBACK_PATTERN_SMART_ALERT: - case FEEDBACK_PATTERN_SEND_SOS_MESSAGE: - case FEEDBACK_PATTERN_END_SOS_MESSAGE: - case FEEDBACK_PATTERN_CMAS: - return true; - case FEEDBACK_PATTERN_SCREEN_CAPTURE: - if (camerastatus && shutter_sndstatus) - return true; - break; - case FEEDBACK_PATTERN_OUTGOING_CALL: - return true; - default: - break; - } - return false; + touch_sndstatus = vconf_keynode_get_bool(key); } -static bool get_always_off_case(feedback_pattern_e pattern) +static void feedback_keytone_sndstatus_cb(keynode_t *key, void* data) { - switch (pattern) { - case FEEDBACK_PATTERN_TAP ... FEEDBACK_PATTERN_MAX_CHARACTER: - case FEEDBACK_PATTERN_HOLD ... FEEDBACK_PATTERN_HW_HOLD: - if (!touch_sndstatus) - return true; - break; - case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: - break; - case FEEDBACK_PATTERN_LOCK: - case FEEDBACK_PATTERN_UNLOCK: - case FEEDBACK_PATTERN_LOCK_SWIPE: - case FEEDBACK_PATTERN_UNLOCK_SWIPE: - if (!lock_sndstatus) - return true; - break; - default: - break; - } - return false; + keytone_sndstatus = vconf_keynode_get_bool(key); } static int get_xml_data(xmlDocPtr doc, feedback_pattern_e pattern, struct xmlData **data) @@ -136,7 +78,8 @@ static int get_xml_data(xmlDocPtr doc, feedback_pattern_e pattern, struct xmlDat xmlNodePtr cur; struct xmlData *retData; - cur = xml_find(doc, SOUND_STR, (const xmlChar*)str_pattern[pattern]); + 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; @@ -172,30 +115,19 @@ static void sound_init(void) if (vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &touch_sndstatus) < 0) _W("VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL ==> FAIL!!"); - if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &lock_sndstatus) < 0) - _W("VCONFKEY_SETAPPL_SOUND_LOCK_BOOL ==> FAIL!!"); - - /* check camera status */ - if (vconf_get_int(VCONFKEY_CAMERA_STATE, &camerastatus) < 0) - _W("VCONFKEY_CAMERA_STATE ==> FAIL!!"); - - /* shutter sound policy */ - // This vconf is read just once, because this value is not changed in running time. - if (vconf_get_int(VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY, &shutter_sndstatus) < 0) - _W("VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY ==> FAIL!!"); + if (vconf_get_bool(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL, &keytone_sndstatus) < 0) + _W("VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL ==> FAIL!!"); /* add watch for status value */ vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, feedback_touch_sndstatus_cb, NULL); - vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, feedback_lock_sndstatus_cb, NULL); - vconf_notify_key_changed(VCONFKEY_CAMERA_STATE, feedback_camerastatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL, feedback_keytone_sndstatus_cb, NULL); } static void sound_exit(void) { /* remove watch */ vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, feedback_touch_sndstatus_cb); - vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, feedback_lock_sndstatus_cb); - vconf_ignore_key_changed(VCONFKEY_CAMERA_STATE, feedback_camerastatus_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL, feedback_keytone_sndstatus_cb); if (v_doc) { xml_close(v_doc); @@ -209,6 +141,7 @@ static int sound_play(feedback_pattern_e pattern) int retry = FEEDBACK_RETRY_CNT, ret; char *path; struct xmlData *data = NULL; + int level; if (!v_doc) { _E("Not initialize"); @@ -220,27 +153,18 @@ static int sound_play(feedback_pattern_e pattern) sndstatus = 0; } - if (sndstatus == 0 && !get_always_alert_case(pattern)) { + if (sndstatus == 0 && profile->get_always_alert_case && + !profile->get_always_alert_case(FEEDBACK_TYPE_SOUND, pattern)) { _D("Sound condition is OFF (sndstatus : %d)", sndstatus); return 0; } - if (sndstatus && get_always_off_case(pattern)) { + if (sndstatus && profile->get_always_off_case && + profile->get_always_off_case(FEEDBACK_TYPE_SOUND, pattern)) { _D("Sound always off condition"); return 0; } - /* check if the state of voice recorder is recording */ - if (vconf_get_int(VCONFKEY_SOUND_STATUS, &ret) < 0) { - _D("fail to get media sound status, status will be zero"); - ret = 0; - } - - if (ret & VCONFKEY_SOUND_STATUS_AVRECORDING) { - _D("voice recording status is RECORDING"); - return 0; - } - /* check whether there is a user defined file */ path = sound_file[pattern]; @@ -248,8 +172,8 @@ static int sound_play(feedback_pattern_e pattern) if (!(*path)) { ret = get_xml_data(v_doc, pattern, &data); if (ret == -ENOENT) { - _D("No sound case(%s)", str_pattern[pattern]); - return 0; + _E("No sound case(%s)", profile->str_pattern[pattern]); + return -ENOTSUP; } if (ret < 0) { @@ -258,9 +182,9 @@ static int sound_play(feedback_pattern_e pattern) } if (!data->data) { - _D("No sound case(%s)", str_pattern[pattern]); + _E("No sound case(%s)", profile->str_pattern[pattern]); release_xml_data(data); - return 0; + return -ENOTSUP; } path = data->data; @@ -268,12 +192,17 @@ static int sound_play(feedback_pattern_e pattern) if (stat(path, &buf)) { _E("%s is not presents", path); - return -ENOENT; + return -ENOTSUP; } /* play sound file */ do { - ret = mm_sound_play_keysound(path, get_volume_type(pattern)); + if (profile->get_strength_type) + level = profile->get_strength_type(FEEDBACK_TYPE_SOUND, pattern); + else + level = VOLUME_TYPE_SYSTEM; + + ret = mm_sound_play_keysound(path, level); if (ret == MM_ERROR_NONE) { _D("Play success! SND filename is %s", path); release_xml_data(data); @@ -286,6 +215,66 @@ static int sound_play(feedback_pattern_e pattern) return -EPERM; } +static int sound_is_supported(feedback_pattern_e pattern, bool *supported) +{ + struct stat buf; + char *path; + struct xmlData *data = NULL; + int ret; + + 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)) { + _E("%s is not presents", path); + release_xml_data(data); + return -ENOENT; + } + + release_xml_data(data); + + *supported = true; + return 0; + +out: + if (data) + release_xml_data(data); + + *supported = false; + return 0; +} + static int sound_get_path(feedback_pattern_e pattern, char *buf, unsigned int buflen) { char *cur_path; @@ -303,7 +292,8 @@ static int sound_get_path(feedback_pattern_e pattern, char *buf, unsigned int bu } if (!cur_path) { - _E("This pattern(%s) in sound type is not supported to play", str_pattern[pattern]); + _E("This pattern(%s) in sound type is not supported to play", + profile->str_pattern[pattern]); cur_path = "NULL"; ret = -ENOENT; } @@ -335,15 +325,18 @@ static int sound_set_path(feedback_pattern_e pattern, char *path) else memset(ppath, 0, NAME_MAX); - _D("The file of pattern(%s) is changed to [%s]", str_pattern[pattern], path); + _D("The file of pattern(%s) is changed to [%s]", + profile->str_pattern[pattern], path); return 0; } static const struct device_ops sound_device_ops = { .type = FEEDBACK_TYPE_SOUND, + .name = "Sound", .init = sound_init, .exit = sound_exit, .play = sound_play, + .is_supported = sound_is_supported, .get_path = sound_get_path, .set_path = sound_set_path, }; diff --git a/src/str.c b/src/str.c deleted file mode 100644 index 13c2b53..0000000 --- a/src/str.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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> - -const char *str_type[] = -{ - "FEEDBACK_TYPE_NONE", - "FEEDBACK_TYPE_SOUND", - "FEEDBACK_TYPE_VIBRATION", - "FEEDBACK_TYPE_LED", - "FEEDBACK_TYPE_END", -}; - -const char *str_pattern[] = -{ - "FEEDBACK_PATTERN_TAP", - "FEEDBACK_PATTERN_SIP", - "FEEDBACK_PATTERN_SIP_BACKSPACE", - "FEEDBACK_PATTERN_SIP_FUNCTION", - "FEEDBACK_PATTERN_SIP_FJKEY", - "FEEDBACK_PATTERN_MAX_CHARACTER", - "FEEDBACK_PATTERN_KEY0", - "FEEDBACK_PATTERN_KEY1", - "FEEDBACK_PATTERN_KEY2", - "FEEDBACK_PATTERN_KEY3", - "FEEDBACK_PATTERN_KEY4", - "FEEDBACK_PATTERN_KEY5", - "FEEDBACK_PATTERN_KEY6", - "FEEDBACK_PATTERN_KEY7", - "FEEDBACK_PATTERN_KEY8", - "FEEDBACK_PATTERN_KEY9", - "FEEDBACK_PATTERN_KEY_STAR", - "FEEDBACK_PATTERN_KEY_SHARP", - "FEEDBACK_PATTERN_KEY_BACK", - "FEEDBACK_PATTERN_HOLD", - "FEEDBACK_PATTERN_MULTI_TAP", - "FEEDBACK_PATTERN_HW_TAP", - "FEEDBACK_PATTERN_HW_HOLD", - - "FEEDBACK_PATTERN_MESSAGE", - "FEEDBACK_PATTERN_MESSAGE_ON_CALL", - "FEEDBACK_PATTERN_EMAIL", - "FEEDBACK_PATTERN_EMAIL_ON_CALL", - "FEEDBACK_PATTERN_WAKEUP", - "FEEDBACK_PATTERN_WAKEUP_ON_CALL", - "FEEDBACK_PATTERN_SCHEDULE", - "FEEDBACK_PATTERN_SCHEDULE_ON_CALL", - "FEEDBACK_PATTERN_TIMER", - "FEEDBACK_PATTERN_TIMER_ON_CALL", - "FEEDBACK_PATTERN_GENERAL", - "FEEDBACK_PATTERN_GENERAL_ON_CALL", - "FEEDBACK_PATTERN_SMART_ALERT", - - "FEEDBACK_PATTERN_POWERON", - "FEEDBACK_PATTERN_POWEROFF", - "FEEDBACK_PATTERN_CHARGERCONN", - "FEEDBACK_PATTERN_CHARGERCONN_ON_CALL", - "FEEDBACK_PATTERN_CHARGING_ERROR", - "FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL", - "FEEDBACK_PATTERN_FULLCHARGED", - "FEEDBACK_PATTERN_FULLCHARGED_ON_CALL", - "FEEDBACK_PATTERN_LOWBATT", - "FEEDBACK_PATTERN_LOWBATT_ON_CALL", - "FEEDBACK_PATTERN_LOCK", - "FEEDBACK_PATTERN_UNLOCK", - "FEEDBACK_PATTERN_LOCK_SWIPE", - "FEEDBACK_PATTERN_UNLOCK_SWIPE", - "FEEDBACK_PATTERN_GEOMETRIC_LOCK", - "FEEDBACK_PATTERN_CALLCONNECT", - "FEEDBACK_PATTERN_DISCALLCONNECT", - "FEEDBACK_PATTERN_OUTGOING_CALL", - "FEEDBACK_PATTERN_MINUTEMINDER", - "FEEDBACK_PATTERN_VIBRATION_ON", - "FEEDBACK_PATTERN_SILENT_OFF", - "FEEDBACK_PATTERN_BT_CONNECTED", - "FEEDBACK_PATTERN_BT_DISCONNECTED", - "FEEDBACK_PATTERN_BT_PAIRING", - "FEEDBACK_PATTERN_BT_WAITING", - "FEEDBACK_PATTERN_SCREEN_CAPTURE", - "FEEDBACK_PATTERN_LIST_REORDER", - "FEEDBACK_PATTERN_LIST_SLIDER", - "FEEDBACK_PATTERN_VOLUME_KEY", - "FEEDBACK_PATTERN_MMS", - "FEEDBACK_PATTERN_HOURLY_ALERT", - - "FEEDBACK_PATTERN_SAFETY_ALERT", - "FEEDBACK_PATTERN_ACCIDENT_DETECT", - "FEEDBACK_PATTERN_SEND_SOS_MESSAGE", - "FEEDBACK_PATTERN_END_SOS_MESSAGE", - "FEEDBACK_PATTERN_EMERGENCY_BUZZER", - "FEEDBACK_PATTERN_SAFETY_LOW_POWER", - "FEEDBACK_PATTERN_CMAS", - "FEEDBACK_PATTERN_SPEED_UP", - "FEEDBACK_PATTERN_SLOW_DOWN", - "FEEDBACK_PATTERN_KEEP_THIS_PACE", - "FEEDBACK_PATTERN_GOAL_ACHIEVED", - "FEEDBACK_PATTERN_EXERCISE_COUNT", - "FEEDBACK_PATTERN_START_CUE", - "FEEDBACK_PATTERN_HEALTH_PACE", - "FEEDBACK_PATTERN_INACTIVE_TIME", - "FEEDBACK_PATTERN_MEASURING_SUCCESS", - "FEEDBACK_PATTERN_MEASURING_FAILURE", - "FEEDBACK_PATTERN_UV_PROCESSING", - "FEEDBACK_PATTERN_SHEALTH_START", - "FEEDBACK_PATTERN_SHEALTH_PAUSE", - "FEEDBACK_PATTERN_SHEALTH_STOP", - "FEEDBACK_PATTERN_3RD_APPLICATION", -}; diff --git a/src/vibrator.c b/src/vibrator.c index b212597..8aae412 100644 --- a/src/vibrator.c +++ b/src/vibrator.c @@ -26,15 +26,11 @@ #include <sys/stat.h> #include "feedback-ids.h" -#include "common.h" -#include "log.h" +#include "profiles.h" #include "devices.h" -#include "xmlparser.h" +#include "log.h" #include "dbus.h" -#define DEFAULT_VIB_LEVEL 3 -#define HAPTIC_FEEDBACK_STEP 20 /**< feedback max / slider step */ - #define HAPTIC_DEVICE 0 enum haptic_priority @@ -54,21 +50,22 @@ enum haptic_iteration #define METHOD_OPEN "OpenDevice" #define METHOD_CLOSE "CloseDevice" -#define METHOD_VIBRATE_BUFFER "VibrateBuffer" #define METHOD_VIBRATE_MONOTONE "VibrateMonotone" #define METHOD_STOP "StopDevice" #define DEFAULT_DURATION 100 static int vibstatus; -static int vib_level; -static int noti_level; static unsigned int v_handle; -static xmlDocPtr v_doc; static char haptic_file[FEEDBACK_PATTERN_END][NAME_MAX]; +inline int is_vibration_mode(void) +{ + return vibstatus; +} + static int haptic_open(void) { char *arr[1]; @@ -120,37 +117,6 @@ static int haptic_vibrate_monotone(unsigned int handle, "uiii", 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_stop(unsigned int handle) { char *arr[1]; @@ -164,63 +130,6 @@ static int haptic_vibrate_stop(unsigned int handle) "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 void feedback_vib_cb(keynode_t *key, void* data) -{ - vib_level = vconf_keynode_get_int(key); -} - -static void feedback_noti_cb(keynode_t *key, void* data) -{ - noti_level = vconf_keynode_get_int(key); -} - static int get_priority(feedback_pattern_e pattern) { if (pattern >= FEEDBACK_PATTERN_TAP && pattern <= FEEDBACK_PATTERN_HW_HOLD) @@ -229,198 +138,77 @@ static int get_priority(feedback_pattern_e pattern) return HAPTIC_PRIORITY_MIDDLE; } -static int get_haptic_level(feedback_pattern_e pattern) -{ - int level; - - if (pattern >= FEEDBACK_PATTERN_MESSAGE && pattern <= FEEDBACK_PATTERN_SMART_ALERT) - level = noti_level * HAPTIC_FEEDBACK_STEP; - else - level = vib_level * HAPTIC_FEEDBACK_STEP; - - _D("Call status : %d, pattern : %s, level : %d", callstatus, str_pattern[pattern], level); - if (callstatus == VCONFKEY_CALL_VOICE_ACTIVE - || callstatus == VCONFKEY_CALL_VIDEO_ACTIVE) { - // if call status is ON, vibration magnitude is 20% - level = 20; - _D("level changed : %d", level); - } - - return level; -} - -static bool get_always_alert_case(feedback_pattern_e pattern) -{ - switch (pattern) { - case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: - case FEEDBACK_PATTERN_HOLD: - break; - case FEEDBACK_PATTERN_SIP: - case FEEDBACK_PATTERN_SIP_BACKSPACE: - case FEEDBACK_PATTERN_SIP_FUNCTION: - case FEEDBACK_PATTERN_SIP_FJKEY: - return true; - case FEEDBACK_PATTERN_TIMER: - case FEEDBACK_PATTERN_TIMER_ON_CALL: - case FEEDBACK_PATTERN_WAKEUP: - case FEEDBACK_PATTERN_WAKEUP_ON_CALL: - return true; - case FEEDBACK_PATTERN_MESSAGE_ON_CALL: - case FEEDBACK_PATTERN_EMAIL_ON_CALL: - case FEEDBACK_PATTERN_GENERAL_ON_CALL: - if (alert_callstatus) - return true; - break; - case FEEDBACK_PATTERN_MESSAGE: - case FEEDBACK_PATTERN_EMAIL: - case FEEDBACK_PATTERN_3RD_APPLICATION: - case FEEDBACK_PATTERN_SMART_ALERT: - case FEEDBACK_PATTERN_SEND_SOS_MESSAGE: - case FEEDBACK_PATTERN_END_SOS_MESSAGE: - case FEEDBACK_PATTERN_CMAS: - case FEEDBACK_PATTERN_OUTGOING_CALL: - case FEEDBACK_PATTERN_MMS: - case FEEDBACK_PATTERN_HOURLY_ALERT: - return true; - case FEEDBACK_PATTERN_SPEED_UP: - case FEEDBACK_PATTERN_SLOW_DOWN: - case FEEDBACK_PATTERN_KEEP_THIS_PACE: - case FEEDBACK_PATTERN_GOAL_ACHIEVED: - case FEEDBACK_PATTERN_EXERCISE_COUNT: - case FEEDBACK_PATTERN_START_CUE: - /* except mute case */ - if (is_sound_mode() || vibstatus) - return true; - break; - case FEEDBACK_PATTERN_CHARGERCONN_ON_CALL: - case FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL: - case FEEDBACK_PATTERN_LOWBATT_ON_CALL: - /* no matter sound profile */ - return true; - default: - break; - } - return false; -} - -static bool get_always_off_case(feedback_pattern_e pattern) -{ - return false; -} - -static int get_xml_data(xmlDocPtr doc, feedback_pattern_e pattern, struct xmlData **data) -{ - xmlNodePtr cur; - struct xmlData *retData; - - cur = xml_find(doc, VIBRATION_STR, (const xmlChar*)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 vibrator_init(void) { int ret; - /* xml Init */ - v_doc = xml_open(VIBRATION_XML); - if (v_doc == NULL) { - _E("xml_open(%s) fail", VIBRATION_XML); - return; - } - /* Vibration Init */ ret = haptic_open(); if (ret < 0) { _E("haptic_open ==> FAIL!! : %d", ret); - xml_close(v_doc); - v_doc = NULL; + v_handle = -ENOTSUP; return; } /* Set vibration handle */ v_handle = (unsigned int)ret; - - /* check vib_level */ - if (vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vib_level) < 0) - _W("VCONFKEY_FEEDBACK_VIBRATION_LEVEL_INT ==> FAIL!!"); - - /* check noti_level */ - if (vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, ¬i_level) < 0) - _W("VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT ==> FAIL!!"); - - /* add watch for status value */ - vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, feedback_vib_cb, NULL); - vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, feedback_noti_cb, NULL); } static void vibrator_exit(void) { int ret; - /* remove watch */ - vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, feedback_vib_cb); - vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, feedback_noti_cb); - - if (v_handle) { + if (v_handle > 0) { ret = haptic_close(v_handle); if (ret < 0) _E("haptic_close is failed : %d", ret); v_handle = 0; } - - if (v_doc) { - xml_close(v_doc); - v_doc = NULL; - } } static int vibrator_play(feedback_pattern_e pattern) { int ret; + int level; - if (!v_handle || !v_doc) { + if (!v_handle) { _E("Not initialize"); return -EPERM; } + if (v_handle == -ENOTSUP) { + _E("Not supported vibration"); + return -ENOTSUP; + } + if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vibstatus) < 0) { _D("fail to get vibration status, will work as turning off"); vibstatus = 0; } - if (vibstatus == 0 && !get_always_alert_case(pattern)) { + if (vibstatus == 0 && profile->get_always_alert_case && + !profile->get_always_alert_case(FEEDBACK_TYPE_VIBRATION, pattern)) { _D("Vibration condition is OFF (vibstatus : %d)", vibstatus); return 0; } - if (vibstatus && get_always_off_case(pattern)) { + if (vibstatus && profile->get_always_off_case && + profile->get_always_off_case(FEEDBACK_TYPE_VIBRATION, pattern)) { _D("Vibration always off condition"); return 0; } + if (profile->get_strength_type) + level = profile->get_strength_type(FEEDBACK_TYPE_VIBRATION, pattern); + else + level = DEFAULT_VIB_LEVEL * HAPTIC_FEEDBACK_STEP; + ret = haptic_vibrate_monotone(v_handle, DEFAULT_DURATION, - get_haptic_level(pattern), get_priority(pattern)); + level, get_priority(pattern)); if (ret < 0) { _E("haptic_vibrate_monotone is failed"); + if (ret == -ECOMM) + return ret; return -EPERM; } @@ -431,18 +219,47 @@ static int vibrator_stop(void) { int ret; - if (!v_handle || !v_doc) { + if (!v_handle) { _E("Not initialize"); return -EPERM; } + if (v_handle == -ENOTSUP) { + _E("Not supported vibration"); + return -ENOTSUP; + } + /* stop haptic device */ ret = haptic_vibrate_stop(v_handle); if (ret < 0) { _E("haptic_vibrate_stop is failed"); + if (ret == -ECOMM) + return ret; + return -EPERM; + } + + return 0; +} + +static int vibrator_is_supported(int pattern, bool *supported) +{ + if (!supported) { + _E("Invalid parameter : supported(NULL)"); + return -EINVAL; + } + + if (!v_handle) { + _E("Not initialize"); return -EPERM; } + if (v_handle == -ENOTSUP) { + _E("Not supported vibration"); + *supported = false; + return 0; + } + + *supported = true; return 0; } @@ -454,7 +271,8 @@ static int vibrator_get_path(feedback_pattern_e pattern, char *buf, unsigned int cur_path = haptic_file[pattern]; if (*cur_path) { - _E("This pattern(%s) in vibrator type is not supported to play", str_pattern[pattern]); + _E("This pattern(%s) in vibrator type is not supported to play", + profile->str_pattern[pattern]); snprintf(buf, buflen, "NULL"); return -ENOENT; } @@ -485,16 +303,19 @@ static int vibrator_set_path(feedback_pattern_e pattern, char *path) else memset(ppath, 0, NAME_MAX); - _D("The file of pattern(%s) is changed to [%s]", str_pattern[pattern], path); + _D("The file of pattern(%s) is changed to [%s]", + profile->str_pattern[pattern], path); return 0; } static const struct device_ops vibrator_device_ops = { .type = FEEDBACK_TYPE_VIBRATION, + .name = "Vibrator", .init = vibrator_init, .exit = vibrator_exit, .play = vibrator_play, .stop = vibrator_stop, + .is_supported = vibrator_is_supported, .get_path = vibrator_get_path, .set_path = vibrator_set_path, }; diff --git a/include/xmlparser.h b/src/xmlparser.h index 0c38672..0c38672 100644 --- a/include/xmlparser.h +++ b/src/xmlparser.h diff --git a/data/micro/sound.xml b/wearable/data/sound.xml index 2ff9be9..d4e2a86 100644 --- a/data/micro/sound.xml +++ b/wearable/data/sound.xml @@ -11,18 +11,6 @@ <data>/usr/share/feedback/sound/touch/touch.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SIP_BACKSPACE</label> - <data>/usr/share/feedback/sound/touch/touch.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_SIP_FUNCTION</label> - <data>/usr/share/feedback/sound/touch/touch.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_SIP_FJKEY</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> @@ -75,18 +63,6 @@ <data>/usr/share/feedback/sound/touch/touch.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_WAKEUP_ON_CALL</label> - <data>/usr/share/feedback/sound/operation/notification.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_SCHEDULE_ON_CALL</label> - <data>/usr/share/feedback/sound/operation/notification.ogg</data> - </sound> - <sound> - <label>FEEDBACK_PATTERN_TIMER_ON_CALL</label> - <data>/usr/share/feedback/sound/operation/notification.ogg</data> - </sound> - <sound> <label>FEEDBACK_PATTERN_POWERON</label> <data>/usr/share/feedback/sound/operation/power_on.ogg</data> </sound> @@ -103,15 +79,15 @@ <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_CALLCONNECT</label> + <label>FEEDBACK_PATTERN_SILENT_OFF</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_DISCALLCONNECT</label> + <label>FEEDBACK_PATTERN_BT_CONNECTED</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SILENT_OFF</label> + <label>FEEDBACK_PATTERN_BT_DISCONNECTED</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> @@ -119,63 +95,87 @@ <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> + <label>FEEDBACK_PATTERN_WEARABLE_SIP_BACKSPACE</label> + <data>/usr/share/feedback/sound/touch/touch.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_BT_DISCONNECTED</label> + <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_BT_PAIRING</label> + <label>FEEDBACK_PATTERN_WEARABLE_CALLCONNECT</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_BT_WAITING</label> + <label>FEEDBACK_PATTERN_WEARABLE_DISCALLCONNECT</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SCREEN_CAPTURE</label> - <data>/usr/share/feedback/sound/operation/shutter.ogg</data> + <label>FEEDBACK_PATTERN_WEARABLE_BT_PAIRING</label> + <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SAFETY_ALERT</label> + <label>FEEDBACK_PATTERN_WEARABLE_BT_WAITING</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SAFETY_LOW_POWER</label> + <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_CMAS</label> + <label>FEEDBACK_PATTERN_WEARABLE_CMAS</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_GOAL_ACHIEVED</label> + <label>FEEDBACK_PATTERN_WEARABLE_GOAL_ACHIEVED</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_MEASURING_SUCCESS</label> + <label>FEEDBACK_PATTERN_WEARABLE_MEASURING_SUCCESS</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_MEASURING_FAILURE</label> + <label>FEEDBACK_PATTERN_WEARABLE_MEASURING_FAILURE</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_UV_PROCESSING</label> + <label>FEEDBACK_PATTERN_WEARABLE_UV_PROCESSING</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SHEALTH_START</label> + <label>FEEDBACK_PATTERN_WEARABLE_SHEALTH_START</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SHEALTH_PAUSE</label> + <label>FEEDBACK_PATTERN_WEARABLE_SHEALTH_PAUSE</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> <sound> - <label>FEEDBACK_PATTERN_SHEALTH_STOP</label> + <label>FEEDBACK_PATTERN_WEARABLE_SHEALTH_STOP</label> <data>/usr/share/feedback/sound/operation/system.ogg</data> </sound> </config> diff --git a/data/emulator/sound/operation/notification.ogg b/wearable/data/sound/operation/notification.ogg Binary files differindex 457f7e8..457f7e8 100755 --- a/data/emulator/sound/operation/notification.ogg +++ b/wearable/data/sound/operation/notification.ogg diff --git a/data/emulator/sound/operation/power_on.ogg b/wearable/data/sound/operation/power_on.ogg Binary files differindex 7756406..7756406 100755 --- a/data/emulator/sound/operation/power_on.ogg +++ b/wearable/data/sound/operation/power_on.ogg diff --git a/data/emulator/sound/operation/ringtone.ogg b/wearable/data/sound/operation/ringtone.ogg Binary files differindex 2653dd6..2653dd6 100755 --- a/data/emulator/sound/operation/ringtone.ogg +++ b/wearable/data/sound/operation/ringtone.ogg diff --git a/data/emulator/sound/operation/shutter.ogg b/wearable/data/sound/operation/shutter.ogg Binary files differindex c22c810..c22c810 100755 --- a/data/emulator/sound/operation/shutter.ogg +++ b/wearable/data/sound/operation/shutter.ogg diff --git a/data/emulator/sound/operation/system.ogg b/wearable/data/sound/operation/system.ogg Binary files differindex 69c8425..69c8425 100755 --- a/data/emulator/sound/operation/system.ogg +++ b/wearable/data/sound/operation/system.ogg diff --git a/data/emulator/sound/touch/touch.ogg b/wearable/data/sound/touch/touch.ogg Binary files differindex 8be60ce..8be60ce 100755 --- a/data/emulator/sound/touch/touch.ogg +++ b/wearable/data/sound/touch/touch.ogg diff --git a/wearable/include/feedback-ids-wearable.h b/wearable/include/feedback-ids-wearable.h new file mode 100644 index 0000000..fb7188c --- /dev/null +++ b/wearable/include/feedback-ids-wearable.h @@ -0,0 +1,109 @@ +/* + * 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 __FEEDBACK_IDS_WEARABLE_H__ +#define __FEEDBACK_IDS_WEARABLE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file feedback-ids-mobile.h + * @brief This file contains the feedback API + */ + +/** + * @addtogroup CAPI_FEEDBACK_MODULE + * @{ + */ + +/** + * @brief Enumerations of the system pre-defined patterns for feedback interface + * @details + * Each feedback pattern can have separate media files of each types. + * But Depending on vendor design, pattern may not have any type of file. + * + */ +typedef enum +{ + FEEDBACK_PATTERN_WEARABLE_NONE = -1, + + FEEDBACK_PATTERN_WEARABLE_SIP_BACKSPACE = FEEDBACK_PATTERN_END, /**< feedback pattern when touch backspace key */ + FEEDBACK_PATTERN_WEARABLE_SIP_FUNCTION, /**< feedback pattern when touch function key */ + FEEDBACK_PATTERN_WEARABLE_SIP_FJKEY, /**< feedback pattern when touch F,J key */ + FEEDBACK_PATTERN_WEARABLE_MAX_CHARACTER, /**< feedback pattern when max character */ + + FEEDBACK_PATTERN_WEARABLE_MESSAGE_ON_CALL, /**< feedback pattern when incoming a message on call */ + FEEDBACK_PATTERN_WEARABLE_EMAIL_ON_CALL, /**< feedback pattern when incoming an email on call */ + FEEDBACK_PATTERN_WEARABLE_WAKEUP_ON_CALL, /**< feedback pattern when alert wake up call on call */ + FEEDBACK_PATTERN_WEARABLE_SCHEDULE_ON_CALL, /**< feedback pattern when alert schedule alarm on call */ + FEEDBACK_PATTERN_WEARABLE_TIMER_ON_CALL, /**< feedback pattern when alert timer on call */ + FEEDBACK_PATTERN_WEARABLE_GENERAL_ON_CALL, /**< feedback pattern when alert general event on call */ + FEEDBACK_PATTERN_WEARABLE_SMART_ALERT, /**< feedback pattern when alert noti on motion */ + + FEEDBACK_PATTERN_WEARABLE_CHARGERCONN_ON_CALL, /**< feedback pattern when connecting charger on call */ + FEEDBACK_PATTERN_WEARABLE_CHARGING_ERROR_ON_CALL,/**< feedback pattern when occuring charging error on call */ + FEEDBACK_PATTERN_WEARABLE_FULLCHARGED_ON_CALL, /**< feedback pattern when full charged on call */ + FEEDBACK_PATTERN_WEARABLE_LOWBATT_ON_CALL, /**< feedback pattern when low battery on call */ + FEEDBACK_PATTERN_WEARABLE_CALLCONNECT, /**< feedback pattern when connecting call */ + FEEDBACK_PATTERN_WEARABLE_DISCALLCONNECT, /**< feedback pattern when disconnecting call */ + FEEDBACK_PATTERN_WEARABLE_OUTGOING_CALL, /**< feedback pattern when connected outgoing call */ + FEEDBACK_PATTERN_WEARABLE_MINUTEMINDER, /**< feedback pattern when minute minder */ + FEEDBACK_PATTERN_WEARABLE_BT_PAIRING, /**< feedback pattern when starting pare with bluetooth */ + FEEDBACK_PATTERN_WEARABLE_BT_WAITING, /**< feedback pattern when pairing bluetooth */ + FEEDBACK_PATTERN_WEARABLE_SCREEN_CAPTURE, /**< feedback pattern when screen capture */ + FEEDBACK_PATTERN_WEARABLE_MMS, /**< feedback pattern when message state changed to MMS */ + FEEDBACK_PATTERN_WEARABLE_HOURLY_ALERT, /**< feedback pattern when alert every hour on the hour */ + + FEEDBACK_PATTERN_WEARABLE_SAFETY_ALERT, /**< feedback pattern when safety alert from phone */ + FEEDBACK_PATTERN_WEARABLE_ACCIDENT_DETECT, /**< feedback pattern when accident detect */ + FEEDBACK_PATTERN_WEARABLE_SEND_SOS_MESSAGE, /**< feedback pattern when sending SOS message */ + FEEDBACK_PATTERN_WEARABLE_END_SOS_MESSAGE, /**< feedback pattern when finishing SOS message */ + FEEDBACK_PATTERN_WEARABLE_EMERGENCY_BUZZER, /**< feedback pattern when occurs emergency buzzer */ + FEEDBACK_PATTERN_WEARABLE_SAFETY_LOW_POWER, /**< this pattern is a low power ringtone */ + FEEDBACK_PATTERN_WEARABLE_CMAS, /**< feedback pattern when alerting commercial mobile */ + FEEDBACK_PATTERN_WEARABLE_SPEED_UP, /**< feedback pattern when advising user to speed up */ + FEEDBACK_PATTERN_WEARABLE_SLOW_DOWN, /**< feedback pattern when advising user to slow down */ + FEEDBACK_PATTERN_WEARABLE_KEEP_THIS_PACE, /**< feedback pattern when advising user to keep this pace */ + FEEDBACK_PATTERN_WEARABLE_GOAL_ACHIEVED, /**< feedback pattern when alerting goal achieved */ + FEEDBACK_PATTERN_WEARABLE_EXERCISE_COUNT, /**< feedback pattern when changing count number */ + FEEDBACK_PATTERN_WEARABLE_START_CUE, /**< feedback pattern when starting cue */ + FEEDBACK_PATTERN_WEARABLE_HEALTH_PACE, /**< feedback pattern when alerting health pace */ + FEEDBACK_PATTERN_WEARABLE_INACTIVE_TIME, /**< feedback pattern when alerting inactive time */ + FEEDBACK_PATTERN_WEARABLE_MEASURING_SUCCESS, /**< feedback pattern when measuring is succeeded */ + FEEDBACK_PATTERN_WEARABLE_MEASURING_FAILURE, /**< feedback pattern when measuring is failed */ + FEEDBACK_PATTERN_WEARABLE_UV_PROCESSING, /**< feedback pattern when UV is processing */ + FEEDBACK_PATTERN_WEARABLE_SHEALTH_START, /**< feedback pattern when starting s-health */ + FEEDBACK_PATTERN_WEARABLE_SHEALTH_PAUSE, /**< feedback pattern when pausing s-health */ + FEEDBACK_PATTERN_WEARABLE_SHEALTH_STOP, /**< feedback pattern when stoping s-health */ + FEEDBACK_PATTERN_WEARABLE_3RD_APPLICATION, /**< feedback pattern when alert 3rd event */ + + FEEDBACK_PATTERN_WEARABLE_END, + +} feedback_pattern_wearable_e; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif //__FEEDBACK_IDS_WEARABLE_H__ diff --git a/wearable/src/check.c b/wearable/src/check.c new file mode 100644 index 0000000..345b102 --- /dev/null +++ b/wearable/src/check.c @@ -0,0 +1,408 @@ +/* + * 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 <vconf.h> + +#include "feedback.h" +#include "feedback-ids-wearable.h" +#include "profiles.h" +#include "log.h" + + +static const char *wearable_str_type[] = +{ + "FEEDBACK_TYPE_NONE", + "FEEDBACK_TYPE_SOUND", + "FEEDBACK_TYPE_VIBRATION", +}; + +static const char *wearable_str_pattern[] = +{ + "FEEDBACK_PATTERN_TAP", + "FEEDBACK_PATTERN_SIP", + "FEEDBACK_PATTERN_KEY0", + "FEEDBACK_PATTERN_KEY1", + "FEEDBACK_PATTERN_KEY2", + "FEEDBACK_PATTERN_KEY3", + "FEEDBACK_PATTERN_KEY4", + "FEEDBACK_PATTERN_KEY5", + "FEEDBACK_PATTERN_KEY6", + "FEEDBACK_PATTERN_KEY7", + "FEEDBACK_PATTERN_KEY8", + "FEEDBACK_PATTERN_KEY9", + "FEEDBACK_PATTERN_KEY_STAR", + "FEEDBACK_PATTERN_KEY_SHARP", + "FEEDBACK_PATTERN_KEY_BACK", + "FEEDBACK_PATTERN_HOLD", + "FEEDBACK_PATTERN_HW_TAP", + "FEEDBACK_PATTERN_HW_HOLD", + + "FEEDBACK_PATTERN_MESSAGE", + "FEEDBACK_PATTERN_EMAIL", + "FEEDBACK_PATTERN_WAKEUP", + "FEEDBACK_PATTERN_SCHEDULE", + "FEEDBACK_PATTERN_TIMER", + "FEEDBACK_PATTERN_GENERAL", + + "FEEDBACK_PATTERN_POWERON", + "FEEDBACK_PATTERN_POWEROFF", + "FEEDBACK_PATTERN_CHARGERCONN", + "FEEDBACK_PATTERN_CHARGING_ERROR", + "FEEDBACK_PATTERN_FULLCHARGED", + "FEEDBACK_PATTERN_LOWBATT", + "FEEDBACK_PATTERN_LOCK", + "FEEDBACK_PATTERN_UNLOCK", + "FEEDBACK_PATTERN_VIBRATION_ON", + "FEEDBACK_PATTERN_SILENT_OFF", + "FEEDBACK_PATTERN_BT_CONNECTED", + "FEEDBACK_PATTERN_BT_DISCONNECTED", + "FEEDBACK_PATTERN_LIST_REORDER", + "FEEDBACK_PATTERN_LIST_SLIDER", + "FEEDBACK_PATTERN_VOLUME_KEY", + + "FEEDBACK_PATTERN_WEARABLE_SIP_BACKSPACE", + "FEEDBACK_PATTERN_WEARABLE_SIP_FUNCTION", + "FEEDBACK_PATTERN_WEARABLE_SIP_FJKEY", + "FEEDBACK_PATTERN_WEARABLE_MAX_CHARACTER", + + "FEEDBACK_PATTERN_WEARABLE_MESSAGE_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_EMAIL_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_WAKEUP_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_SCHEDULE_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_TIMER_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_GENERAL_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_SMART_ALERT", + + "FEEDBACK_PATTERN_WEARABLE_CHARGERCONN_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_CHARGING_ERROR_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_FULLCHARGED_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_LOWBATT_ON_CALL", + "FEEDBACK_PATTERN_WEARABLE_CALLCONNECT", + "FEEDBACK_PATTERN_WEARABLE_DISCALLCONNECT", + "FEEDBACK_PATTERN_WEARABLE_OUTGOING_CALL", + "FEEDBACK_PATTERN_WEARABLE_MINUTEMINDER", + "FEEDBACK_PATTERN_WEARABLE_BT_PAIRING", + "FEEDBACK_PATTERN_WEARABLE_BT_WAITING", + "FEEDBACK_PATTERN_WEARABLE_SCREEN_CAPTURE", + "FEEDBACK_PATTERN_WEARABLE_MMS", + "FEEDBACK_PATTERN_WEARABLE_HOURLY_ALERT", + + "FEEDBACK_PATTERN_WEARABLE_SAFETY_ALERT", + "FEEDBACK_PATTERN_WEARABLE_ACCIDENT_DETECT", + "FEEDBACK_PATTERN_WEARABLE_SEND_SOS_MESSAGE", + "FEEDBACK_PATTERN_WEARABLE_END_SOS_MESSAGE", + "FEEDBACK_PATTERN_WEARABLE_EMERGENCY_BUZZER", + "FEEDBACK_PATTERN_WEARABLE_SAFETY_LOW_POWER", + "FEEDBACK_PATTERN_WEARABLE_CMAS", + "FEEDBACK_PATTERN_WEARABLE_SPEED_UP", + "FEEDBACK_PATTERN_WEARABLE_SLOW_DOWN", + "FEEDBACK_PATTERN_WEARABLE_KEEP_THIS_PACE", + "FEEDBACK_PATTERN_WEARABLE_GOAL_ACHIEVED", + "FEEDBACK_PATTERN_WEARABLE_EXERCISE_COUNT", + "FEEDBACK_PATTERN_WEARABLE_START_CUE", + "FEEDBACK_PATTERN_WEARABLE_HEALTH_PACE", + "FEEDBACK_PATTERN_WEARABLE_INACTIVE_TIME", + "FEEDBACK_PATTERN_WEARABLE_MEASURING_SUCCESS", + "FEEDBACK_PATTERN_WEARABLE_MEASURING_FAILURE", + "FEEDBACK_PATTERN_WEARABLE_UV_PROCESSING", + "FEEDBACK_PATTERN_WEARABLE_SHEALTH_START", + "FEEDBACK_PATTERN_WEARABLE_SHEALTH_PAUSE", + "FEEDBACK_PATTERN_WEARABLE_SHEALTH_STOP", + "FEEDBACK_PATTERN_WEARABLE_3RD_APPLICATION", +}; + +static int callstatus; +static int alert_callstatus; +static int camerastatus; +static int shutter_sndstatus; +static int noti_vibstatus; +static int vib_level; +static int noti_level; +static int feedbackstatus; + +static void feedback_callstatus_cb(keynode_t *key, void* data) +{ + callstatus = vconf_keynode_get_int(key); +} + +static void feedback_alertstatus_cb(keynode_t *key, void* data) +{ + alert_callstatus = vconf_keynode_get_int(key); +} + +static void feedback_camerastatus_cb(keynode_t *key, void* data) +{ + camerastatus = vconf_keynode_get_int(key); +} + +static void feedback_noti_vibstatus_cb(keynode_t *key, void* data) +{ + noti_vibstatus = vconf_keynode_get_bool(key); +} + +static void feedback_vib_cb(keynode_t *key, void* data) +{ + vib_level = vconf_keynode_get_int(key); +} + +static void feedback_noti_cb(keynode_t *key, void* data) +{ + noti_level = vconf_keynode_get_int(key); +} + +static void feedback_feedbackstatus_cb(keynode_t *key, void* data) +{ + feedbackstatus = vconf_keynode_get_bool(key); +} + +static void wearable_init(void) +{ + /* check call status */ + if (vconf_get_int(VCONFKEY_CALL_STATE, &callstatus) < 0) + _W("VCONFKEY_CALL_STATE ==> FAIL!!"); + + /* alert option on call */ + if (vconf_get_int(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, &alert_callstatus) < 0) + _W("VCONFKEY_CISSAPPL_ON_CALL_INT ==> FAIL!!"); + + /* check camera status */ + if (vconf_get_int(VCONFKEY_CAMERA_STATE, &camerastatus) < 0) + _W("VCONFKEY_CAMERA_STATE ==> FAIL!!"); + + /* shutter sound policy */ + // This vconf is read just once, because this value is not changed in running time. + if (vconf_get_int(VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY, &shutter_sndstatus) < 0) + _W("VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY ==> FAIL!!"); + + /* check vibration status */ + if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, ¬i_vibstatus) < 0) + _W("VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL ==> FAIL!!"); + + /* check vib_level */ + if (vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vib_level) < 0) + _W("VCONFKEY_FEEDBACK_VIBRATION_LEVEL_INT ==> FAIL!!"); + + /* check noti_level */ + if (vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, ¬i_level) < 0) + _W("VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT ==> FAIL!!"); + + /* feedback Init */ + if(vconf_get_bool(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, &feedbackstatus) < 0) + _W("VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL ==> FAIL!!"); + + /* add watch for status value */ + vconf_notify_key_changed(VCONFKEY_CALL_STATE, feedback_callstatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, feedback_alertstatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_CAMERA_STATE, feedback_camerastatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, feedback_noti_vibstatus_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, feedback_vib_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, feedback_noti_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, feedback_feedbackstatus_cb, NULL); +} + +static void wearable_exit(void) +{ + /* remove watch */ + vconf_ignore_key_changed(VCONFKEY_CALL_STATE, feedback_callstatus_cb); + vconf_ignore_key_changed(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT, feedback_alertstatus_cb); + vconf_ignore_key_changed(VCONFKEY_CAMERA_STATE, feedback_camerastatus_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, feedback_noti_vibstatus_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, feedback_vib_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, feedback_noti_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_HAPTIC_FEEDBACK_STATUS_BOOL, feedback_feedbackstatus_cb); +} + +static bool wearable_get_switched_pattern(int pattern, int *switched) +{ + if (!switched) + return false; + + if (callstatus == VCONFKEY_CALL_OFF) + return false; + + /* in case of call connected or connecting */ + _D("Call status is connected or connecting."); + if (pattern == FEEDBACK_PATTERN_MESSAGE) + *switched = FEEDBACK_PATTERN_WEARABLE_MESSAGE_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_EMAIL) + *switched = FEEDBACK_PATTERN_WEARABLE_EMAIL_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_WAKEUP) + *switched = FEEDBACK_PATTERN_WEARABLE_WAKEUP_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_SCHEDULE) + *switched = FEEDBACK_PATTERN_WEARABLE_SCHEDULE_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_TIMER) + *switched = FEEDBACK_PATTERN_WEARABLE_TIMER_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_GENERAL) + *switched = FEEDBACK_PATTERN_WEARABLE_GENERAL_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_CHARGERCONN) + *switched = FEEDBACK_PATTERN_WEARABLE_CHARGERCONN_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_CHARGING_ERROR) + *switched = FEEDBACK_PATTERN_WEARABLE_CHARGING_ERROR_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_FULLCHARGED) + *switched = FEEDBACK_PATTERN_WEARABLE_FULLCHARGED_ON_CALL; + else if (pattern == FEEDBACK_PATTERN_LOWBATT) + *switched = FEEDBACK_PATTERN_WEARABLE_LOWBATT_ON_CALL; + + return true; +} + +static bool wearable_get_always_alert_case(int type, int pattern) +{ + switch (pattern) { + case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: + case FEEDBACK_PATTERN_HOLD: + if (CHECK_VIBRATION(type) && feedbackstatus) + return true; + break; + case FEEDBACK_PATTERN_SIP: + case FEEDBACK_PATTERN_WEARABLE_SIP_BACKSPACE: + case FEEDBACK_PATTERN_WEARABLE_SIP_FUNCTION: + case FEEDBACK_PATTERN_WEARABLE_SIP_FJKEY: + if (CHECK_VIBRATION(type)) + return true; + break; + case FEEDBACK_PATTERN_MESSAGE: + case FEEDBACK_PATTERN_EMAIL: + if (CHECK_VIBRATION(type) && noti_vibstatus) + return true; + break; + case FEEDBACK_PATTERN_TIMER: + case FEEDBACK_PATTERN_WEARABLE_TIMER_ON_CALL: + if (CHECK_VIBRATION(type)) + return true; + break; + case FEEDBACK_PATTERN_WAKEUP: + case FEEDBACK_PATTERN_WEARABLE_WAKEUP_ON_CALL: + return true; + case FEEDBACK_PATTERN_WEARABLE_MESSAGE_ON_CALL: + case FEEDBACK_PATTERN_WEARABLE_EMAIL_ON_CALL: + case FEEDBACK_PATTERN_WEARABLE_GENERAL_ON_CALL: + if (alert_callstatus) + return true; + break; + case FEEDBACK_PATTERN_WEARABLE_CHARGERCONN_ON_CALL: + case FEEDBACK_PATTERN_WEARABLE_CHARGING_ERROR_ON_CALL: + case FEEDBACK_PATTERN_WEARABLE_LOWBATT_ON_CALL: + case FEEDBACK_PATTERN_WEARABLE_3RD_APPLICATION: + case FEEDBACK_PATTERN_WEARABLE_MMS: + case FEEDBACK_PATTERN_WEARABLE_HOURLY_ALERT: + /* no matter sound profile */ + if (CHECK_VIBRATION(type)) + return true; + break; + case FEEDBACK_PATTERN_WEARABLE_SMART_ALERT: + case FEEDBACK_PATTERN_WEARABLE_SEND_SOS_MESSAGE: + case FEEDBACK_PATTERN_WEARABLE_END_SOS_MESSAGE: + case FEEDBACK_PATTERN_WEARABLE_CMAS: + case FEEDBACK_PATTERN_WEARABLE_OUTGOING_CALL: + return true; + case FEEDBACK_PATTERN_WEARABLE_SCREEN_CAPTURE: + if (CHECK_SOUND(type) && camerastatus && shutter_sndstatus) + return true; + break; + case FEEDBACK_PATTERN_WEARABLE_SPEED_UP: + case FEEDBACK_PATTERN_WEARABLE_SLOW_DOWN: + case FEEDBACK_PATTERN_WEARABLE_KEEP_THIS_PACE: + case FEEDBACK_PATTERN_WEARABLE_GOAL_ACHIEVED: + case FEEDBACK_PATTERN_WEARABLE_EXERCISE_COUNT: + case FEEDBACK_PATTERN_WEARABLE_START_CUE: + /* except mute case */ + if (CHECK_VIBRATION(type) && + (is_sound_mode() || is_vibration_mode())) + return true; + break; + default: + break; + } + return false; +} + +static bool wearable_get_always_off_case(int type, int pattern) +{ + int ret; + + /* check if the state of voice recorder is recording */ + if (vconf_get_int(VCONFKEY_SOUND_STATUS, &ret) < 0) { + _D("fail to get media sound status, status will be zero"); + ret = 0; + } + + if (CHECK_SOUND(type) && ret & VCONFKEY_SOUND_STATUS_AVRECORDING) { + _D("voice recording status is RECORDING"); + return true; + } + + switch (pattern) { + case FEEDBACK_PATTERN_TAP ... FEEDBACK_PATTERN_SIP: + case FEEDBACK_PATTERN_HOLD ... FEEDBACK_PATTERN_HW_HOLD: + case FEEDBACK_PATTERN_WEARABLE_SIP_BACKSPACE ... FEEDBACK_PATTERN_WEARABLE_MAX_CHARACTER: + if (CHECK_SOUND(type) && !is_touch_sndstatus()) + return true; + break; + case FEEDBACK_PATTERN_KEY0 ... FEEDBACK_PATTERN_KEY_BACK: + if (CHECK_SOUND(type) && !is_keytone_sndstatus()) + return true; + else if (CHECK_VIBRATION(type) && !feedbackstatus) + return true; + break; + default: + break; + } + return false; +} + +static int wearable_get_strength_type(int type, int pattern) +{ + if (CHECK_SOUND(type)) { + if (pattern == FEEDBACK_PATTERN_TAP) + return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_TOUCH; + else if (pattern >= FEEDBACK_PATTERN_KEY0 && pattern <= FEEDBACK_PATTERN_KEY_BACK) + return VOLUME_TYPE_SYSTEM|VOLUME_GAIN_DIALER; + else if (pattern == FEEDBACK_PATTERN_VOLUME_KEY) + return VOLUME_TYPE_RINGTONE; + else if (camerastatus && shutter_sndstatus && pattern == FEEDBACK_PATTERN_WEARABLE_SCREEN_CAPTURE) + return VOLUME_TYPE_FIXED; + else + return VOLUME_TYPE_SYSTEM; + } else if (CHECK_VIBRATION(type)) { + if (pattern >= FEEDBACK_PATTERN_MESSAGE && + pattern <= FEEDBACK_PATTERN_GENERAL) + return noti_level * HAPTIC_FEEDBACK_STEP; + else + return vib_level * HAPTIC_FEEDBACK_STEP; + } + + return -EINVAL; +} + +static const struct profile_ops wearable_profile_ops = { + .profile = "wearable", + .init = wearable_init, + .exit = wearable_exit, + .get_switched_pattern = wearable_get_switched_pattern, + .get_always_alert_case = wearable_get_always_alert_case, + .get_always_off_case = wearable_get_always_off_case, + .get_strength_type = wearable_get_strength_type, + .max_type = FEEDBACK_TYPE_END, + .max_pattern = FEEDBACK_PATTERN_WEARABLE_END, + .str_type = wearable_str_type, + .str_pattern = wearable_str_pattern, +}; + +PROFILE_OPS_REGISTER(&wearable_profile_ops); |