Add code versioning for "SettingInfo TC"
[platform/framework/native/appfw.git] / src / system / inc / FSys_VibratorImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FSys_VibratorImpl.h
19  * @brief               This is the header file for _VibratorImpl class.
20  */
21
22 #ifndef _FSYSTEM_INTERNAL_VIBRATOR_IMPL_H_
23 #define _FSYSTEM_INTERNAL_VIBRATOR_IMPL_H_
24 #include <haptic/haptic.h>
25
26 #include <FOspConfig.h>
27 #include <FBaseDataType.h>
28 #include <FBaseObject.h>
29 #include <FBaseRtTimer.h>
30 #include <FBaseRtITimerEventListener.h>
31
32 namespace Tizen { namespace System
33 {
34 class Vibrator;
35
36 class _OSP_EXPORT_ _VibratorImpl
37         : public Tizen::Base::Object
38 {
39 public:
40         /*
41          * This is the default constructor for this class.
42          *
43          * @since 2.1
44          */
45         _VibratorImpl(void);
46
47         /*
48          * This is the destructor for this class.
49          *
50          * @since 2.1
51          */
52         virtual ~_VibratorImpl(void);
53
54         /*
55          * Initializes this instance of %Vibrator.
56          *
57          * @since 2.1
58          *
59          * @return      An error code
60          * @exception   E_SUCCESS           The method is successful.
61          * @exception   E_SYSTEM            An unknown operating system error has occurred.
62          * @exception   E_OUT_OF_MEMORY     The memory is insufficient.
63          *
64          */
65         result Construct(void);
66
67
68         /**
69          * Vibrates the device with the specified array pattern which has vibration intensity and duration. @n
70          * This method returns the result immediately so that the vibration occurs simultaneously as the device runs. @n
71          * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately. @n
72          * If multiple applications trigger the vibration, the vibrator merges one vibration pattern with another in the overlapped time. @n
73          * If the system alert occurs such as ring vibration and a system event notification, the vibration can be interrupted. @n
74          * If the application is terminated, the vibration is canceled.
75          *
76          * @since 2.1
77          *
78          * @privilege     http://tizen.org/privilege/vibrator
79          *
80          * @return      An error code
81          *
82          * @param[in]   patterns                        An array of @c IntensityDurationVibrationPattern.
83          * @param[in]   length                          The length of @c patterns.
84          * @param[in]   repeatCount                           The number of repeat for pattern. This value has to be between 1 to 100.
85          * @exception   E_SUCCESS           The method is successful.
86          * @exception    E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
87          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
88          * @exception E_OPERATION_FAILED The device operation has failed.
89          * @remarks The vibration intensity does not apply the change, even if the system default vibration intensity is changed after starting vibration.
90          * @see  IntensityDurationVibrationPattern
91          */
92         result Start(IntensityDurationVibrationPattern* patterns, int length, int repeatCount);
93
94
95         /*
96          * Vibrates the device with the specified pattern and level. @n
97          * This method returns the result immediately so that the vibration occurs simultaneously as the device runs.
98          * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately.
99          *
100          * @since 2.1
101          *
102          * @return      An error code
103          * @param[in]   onPeriod    The period in milliseconds when the vibrator is on @n
104          *                          It should be greater than @c 0.
105          * @param[in]   offPeriod   The period in milliseconds when the vibrator is off @n
106          *                          It should be equal to or greater than @c 0.
107          * @param[in]   count       The number of times to execute the given pattern @n
108          *                          It should be greater than @c 0.
109          * @param[in]   level       The vibration level @n
110          *                          Ranges from @c [0~100], where ' @c 0' is a special case indicating the system default level.
111          * @exception   E_SUCCESS           The method is successful.
112          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
113          * @exception   E_DEVICE_BUSY       The device cannot be approached because of other operations.
114          * @exception   E_DEVICE_FAILED     The device operation has failed.
115          * @remarks     Various devices may have different vibration capabilities.
116          *              If the device supports only one level of vibration, then a level value between @c [0~100] results in the default vibration.
117          *              If the device supports many levels of vibration, then a level value @c 0 results in the system default vibration, value @c 1 results in the lowest frequency vibration, value @c 100 results in the highest frequency vibration, and intermediate values result in intermediate vibration levels. @n
118          *              Devices have implementation-specific limits for the total duration of the vibration, and vibration cuts off at that limit even if the duration parameter is greater than the limit.
119          *
120          */
121         result Start(long onPeriod, long offPeriod, int count, int level = 0);
122
123         /*
124          * Turns the vibrator off.
125          *
126          * @since 2.1
127          *
128          * @return      An error code
129          * @exception   E_SUCCESS           The method is successful.
130          * @exception   E_DEVICE_FAILED     The device operation has failed.
131          */
132         result Stop(void);
133
134         /*
135          * Convert the error code of hapic library to the result
136          */
137         result ConvertErrorCode(int errorCode);
138
139         static _VibratorImpl* GetInstance(Vibrator& vibrator);
140
141         static const _VibratorImpl* GetInstance(const Vibrator& vibrator);
142
143 private:
144         _VibratorImpl(const _VibratorImpl& value);
145
146         _VibratorImpl& operator =(const _VibratorImpl& value);
147
148 private:
149         haptic_device_h __handle;
150         haptic_effect_h __effectHandle;
151 };
152 } } // Tizen::System
153 #endif