sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FSysVibrator.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FSysVibrator.h
20  * @brief       This is the header file for the %Vibrator class.
21  *
22  * This header file contains the declarations of the %Vibrator class.
23  */
24
25 #ifndef _FSYS_VIBRATOR_H_
26 #define _FSYS_VIBRATOR_H_
27
28 #include <FBaseObject.h>
29
30 namespace Tizen { namespace System
31 {
32
33 /**
34  * @class   Vibrator
35  * @brief   This class handles the vibration functionality of the device.
36  *
37  * @since   2.0
38  *
39  * The %Vibrator class handles the vibration functionality of a device. It allows you to manage the device's vibrator parameters, such as vibration count and level.
40  *
41  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/system/vibrator_mgmt.htm">Vibrator Management</a>.
42  *
43  * The following example demonstrates how to use the %Vibrator class.
44  *
45  * @code
46  *
47  * #include <FBase.h>
48  * #include <FSystem.h>
49  *
50  * using namespace Tizen::Base;
51  * using namespace Tizen::System;
52  *
53  * class MyVibratorClass
54  * {
55  * public:
56  *  result VibratorExample(void);
57  * private:
58  *  Vibrator vibrator;
59  * };
60  *
61  * result
62  * MyVibratorClass::VibratorExample(void)
63  * {
64  *      result r = vibrator.Construct();
65  *      if (IsFailed(r))
66  *      {
67  *              goto CATCH;
68  *      }
69  *
70  *      // Vibrate with a given pattern and level
71  *      vibrator.Start(2000, 1000, 1, 50);
72  *
73  *      return E_SUCCESS;
74  *
75  * CATCH:
76  *      // Do some exception handling
77  *      return r;
78  * }
79  * @endcode
80  */
81
82 class _OSP_EXPORT_ Vibrator
83         : public Tizen::Base::Object
84 {
85
86 public:
87         /**
88          * This is the default constructor for this class.
89          *
90          * @since   2.0
91          *
92          * @remarks The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
93          */
94         Vibrator(void);
95
96         /**
97          * This is the destructor for this class. @n
98          * This destructor overrides Tizen::Base::Object::~Object().
99          *
100          * @since   2.0
101          *
102          * @remarks If the instance is destroyed before the vibration stops, the vibration is stopped forcefully.
103          */
104         virtual ~Vibrator(void);
105
106         /**
107          * Initializes this instance of %Vibrator.
108          *
109          * @since       2.0
110          *
111          * @return      An error code
112          * @exception   E_SUCCESS           The method is successful.
113          * @exception   E_SYSTEM            An unknown operating system error has occurred.
114          *
115          */
116         result Construct(void);
117
118         /**
119          * Vibrates the device with the specified pattern and level. @n
120          * This method returns the result immediately so that the vibration occurs simultaneously as the device runs.
121          * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately.
122          *
123          * @since 2.0
124          *
125          * @privilege   %http://tizen.org/privilege/vibrator
126          *
127          * @return      An error code
128          * @param[in]   onPeriod    The period in milliseconds when the vibrator is on @n
129          *                          It should be greater than @c 0.
130          * @param[in]   offPeriod   The period in milliseconds when the vibrator is off @n
131          *                          It should be equal to or greater than @c 0.
132          * @param[in]   count       The number of times to execute the given pattern @n
133          *                          It should be greater than @c 0.
134          * @param[in]   level       The vibration level @n
135          *                          Ranges from [@c 0~ @c 100], where ' @c 0' is a special case indicating the system default level.
136          * @exception   E_SUCCESS           The method is successful.
137          * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
138          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
139          * @exception   E_DEVICE_BUSY       The device cannot be approached because of other operations.
140          * @exception   E_DEVICE_FAILED     The device operation has failed.
141          * @remarks     Various devices may have different vibration capabilities.
142          *              If the device supports only one level of vibration, then a level value between [@c 0~ @c 100] results in the default vibration.
143          *              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
144          *              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.
145          *
146          */
147         result Start(long onPeriod, long offPeriod, int count, int level = 0);
148
149         /**
150          * Vibrates the device for the specified duration at the specified @c level. @n
151          * This method returns the result immediately so that the vibration occurs simultaneously as the device runs.
152          * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately.
153          *
154          * @since       2.0
155          *
156          * @privilege   %http://tizen.org/privilege/vibrator
157          *
158          * @return      An error code
159          * @param[in]   milliseconds    The duration for the vibration in milliseconds @n
160          *                              It should be greater than @c 0.
161          * @param[in]   level           The vibration level @n
162          *                              Ranges from [@c 0~ @c 100], where ' @c 0' is a special case indicating the system default level.
163          * @exception   E_SUCCESS       The method is successful.
164          * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
165          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
166          * @exception   E_DEVICE_BUSY       The device cannot be approached because of other operations.
167          * @exception   E_DEVICE_FAILED     The device operation has failed.
168          * @remarks     Various devices have different vibration capabilities. @n
169          *              If the device supports only one level of vibration, then a level value between [@c 0~ @c 100] results in the default vibration.
170          *              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
171          *              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.
172          *
173          */
174         result Start(long milliseconds, int level = 0);
175
176         /**
177          * Turns the vibrator off.
178          *
179          * @since   2.0
180          *
181          * @privilege   %http://tizen.org/privilege/vibrator
182          *
183          * @return      An error code
184          * @exception   E_SUCCESS           The method is successful.
185          * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
186          * @exception   E_DEVICE_FAILED     The device operation has failed.
187          *
188          */
189         result Stop(void);
190
191 private:
192         /**
193          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
194          */
195         Vibrator(const Vibrator& value);
196
197         /**
198          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
199          */
200         Vibrator& operator =(const Vibrator& value);
201
202 private:
203         friend class _VibratorImpl;
204         class _VibratorImpl* __pVibratorImpl;
205
206 }; // Vibrator
207
208 } } // Tizen::System
209
210 #endif