Tizen 2.1 base
[platform/core/api/runtime-info.git] / include / runtime_info.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef __TIZEN_SYSTEM_RUNTIME_INFO_H__
18 #define __TIZEN_SYSTEM_RUNTIME_INFO_H__
19
20 #include <tizen.h>
21
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif
26
27  /**
28  * @addtogroup CAPI_SYSTEM_RUNTIME_INFO_MODULE
29  * @{
30  */
31
32 /**
33  * @brief Enumeration of error code for runtime information
34  */
35 typedef enum {
36         RUNTIME_INFO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
37         RUNTIME_INFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
38         RUNTIME_INFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
39         RUNTIME_INFO_ERROR_IO_ERROR =  TIZEN_ERROR_IO_ERROR, /**< An input/output error occurred when read value from system */
40 } runtime_info_error_e;
41
42 /**
43  * @brief Enumeration of key for runtime information
44  */
45 typedef enum {
46         RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, /**<Indicates whether the device is in flight mode. */
47         RUNTIME_INFO_KEY_WIFI_STATUS, /**<Indicates the current status of Wi-Fi. */
48         RUNTIME_INFO_KEY_BLUETOOTH_ENABLED, /**<Indicates whether Bluetooth is enabled. */
49         RUNTIME_INFO_KEY_WIFI_HOTSPOT_ENABLED, /**<Indicates whether Wi-Fi hotspot is enabled. */
50         RUNTIME_INFO_KEY_BLUETOOTH_TETHERING_ENABLED, /**<Indicates whether Bluetooth tethering is enabled. */
51         RUNTIME_INFO_KEY_USB_TETHERING_ENABLED, /**<Indicates whether USB tethering is enabled. */
52         RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED, /**<Indicates whether the location service is allowed to use location data from GPS satellites. */
53         RUNTIME_INFO_KEY_LOCATION_ADVANCED_GPS_ENABLED, /**<Indicates whether the location service is allowed to download location data for GPS operation. */
54         RUNTIME_INFO_KEY_LOCATION_NETWORK_POSITION_ENABLED, /**<Indicates whether the location service is allowed to use location data from cellular and Wi-Fi. */
55         RUNTIME_INFO_KEY_LOCATION_SENSOR_AIDING_ENABLED, /**<Indicates whether the location service is allowed to use pedestrian sensors for positioning performance. */
56         RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, /**<Indicates Whether the packet data through 3G network is enabled. */
57         RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, /**<Indicates whether data roaming is enabled. */
58         RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, /**<Indicates whether the device is in silent mode. */
59         RUNTIME_INFO_KEY_VIBRATION_ENABLED, /**<Indicates whether vibration is enabled. */
60         RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED,
61         RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED, /**<Indicates whether 24-hour clock is enabled. */
62         RUNTIME_INFO_KEY_FIRST_DAY_OF_WEEK, /**<Indicates the first day of week. */
63         RUNTIME_INFO_KEY_LANGUAGE, /**<Indicates the current language setting. */
64         RUNTIME_INFO_KEY_REGION, /**<Indicates the current region setting. */
65         RUNTIME_INFO_KEY_AUDIO_JACK_CONNECTED, /**<Indicates whether audio jack is connected. */
66         RUNTIME_INFO_KEY_GPS_STATUS, /**<Indicates the current status of GPS. */
67         RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, /**<Indicates the battery is currently charging. */
68         RUNTIME_INFO_KEY_TV_OUT_CONNECTED, /**<Indicates whether TV out is connected. */
69         RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, /**<Indicates the current status of audio jack. */
70         RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, /**<Indicates whether sliding keyboard is opened. */
71         RUNTIME_INFO_KEY_USB_CONNECTED, /**<Indicates whether USB is connected. */
72         RUNTIME_INFO_KEY_CHARGER_CONNECTED, /**<Indicates whether charger is connected. */
73         RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK, /**<Indicates the current vibration level of haptic feedback. */
74         RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, /**<Indicates whether auto rotation is enabled. */
75 } runtime_info_key_e;
76
77
78 /**
79  * @brief Enumeration of Wi-Fi status
80  */
81 typedef enum {
82         RUNTIME_INFO_WIFI_STATUS_DISABLED, /**< GPS is disabled. */
83         RUNTIME_INFO_WIFI_STATUS_UNCONNECTED, /**< Wi-Fi is enabled and network connection is not established. */
84         RUNTIME_INFO_WIFI_STATUS_CONNECTED, /**< Network connection is established in Wi-Fi network. */
85 } runtime_info_wifi_status_e;
86
87 /**
88  * @brief Enumeration of GPS status
89  */
90 typedef enum {
91         RUNTIME_INFO_GPS_STATUS_DISABLED, /**< GPS is disabled. */
92         RUNTIME_INFO_GPS_STATUS_SEARCHING, /**< GPS is searching for satellites. */
93         RUNTIME_INFO_GPS_STATUS_CONNECTED, /**< GPS connection is established. */
94 } runtime_info_gps_status_e;
95
96 /**
97  * @brief Enumeration of first day of week
98  */
99 typedef enum {
100         RUNTIME_INFO_FIRST_DAY_OF_WEEK_SUNDAY, /**< Sunday */
101         RUNTIME_INFO_FIRST_DAY_OF_WEEK_MONDAY, /**< Monday */
102         RUNTIME_INFO_FIRST_DAY_OF_WEEK_TUESDAY, /**< Tuesday */
103         RUNTIME_INFO_FIRST_DAY_OF_WEEK_WEDNESDAY, /**< Wednesday */
104         RUNTIME_INFO_FIRST_DAY_OF_WEEK_THURSDAY, /**< Thursday */
105         RUNTIME_INFO_FIRST_DAY_OF_WEEK_FRIDAY, /**< Friday */
106         RUNTIME_INFO_FIRST_DAY_OF_WEEK_SATURDAY, /**< Saturday */
107 } runtime_info_first_day_of_week_e;
108
109 /**
110  * @brief Enumeration of audio jack status
111  */
112 typedef enum {
113         RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED, /**< audio jack is not connected */
114         RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE, /**< 3-conductor wire is connected. */
115         RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE, /**< 4-conductor wire is connected. */
116 } runtime_info_audio_jack_status_e;
117
118
119 /**
120  * @brief   Called when the runtime information changes
121  * @param[in] key Type of notification
122  * @param[in] user_data The user data passed from the callback registration function
123  * @pre runtime_info_set_changed_cb() will invoke this callback function.
124  * @see runtime_info_set_changed_cb()
125  * @see runtime_info_unset_changed_cb()
126  */
127 typedef void (*runtime_info_changed_cb)(runtime_info_key_e key, void *user_data);
128
129 /**
130  * @brief   Gets the integer value of the runtime information
131  * @details This function gets current state of the given key which represents specific runtime information.
132  * @param[in] key The runtime information status key from which data should be read
133  * @param[out] value The current value of the given key
134  * @return  0 on success, otherwise a negative error value.
135  * @retval  #RUNTIME_INFO_ERROR_NONE Successful
136  * @retval  #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
137  * @retval  #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
138  */
139 int runtime_info_get_value_int(runtime_info_key_e key, int *value);
140
141 /**
142  * @brief   Gets the boolean value from the runtime information
143  * @details This function gets current state of the given key which represents specific runtime information.
144  * @param[in] key The runtime information  key from which data should be read
145  * @param[out] value The current value of the given key
146  * @return  0 on success, otherwise a negative error value.
147  * @retval  #RUNTIME_INFO_ERROR_NONE Successful
148  * @retval  #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
149  * @retval  #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
150  */
151 int runtime_info_get_value_bool(runtime_info_key_e key, bool *value);
152
153 /**
154  * @brief   Gets the double value from the runtime information
155  * @details This function gets current state of the given key which represents specific runtime information.
156  * @param[in] key The runtime information  key from which data should be read
157  * @param[out] value The current value of the given key
158  * @return  0 on success, otherwise a negative error value.
159  * @retval  #RUNTIME_INFO_ERROR_NONE Successful
160  * @retval  #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
161  * @retval  #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
162  */
163 int runtime_info_get_value_double(runtime_info_key_e key, double *value);
164
165 /**
166  * @brief   Gets the string value for specified runtime information
167  * @details This function gets current state of the given key which represents specific runtime information.
168  * @remarks @a value must be released with @c free() by you.
169  * @param[in] key The runtime information  key from which data should be read
170  * @param[out] value The current value of the given key
171  * @return  0 on success, otherwise a negative error value.
172  * @retval  #RUNTIME_INFO_ERROR_NONE Successful
173  * @retval  #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
174  * @retval  #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
175  * @retval  #RUNTIME_INFO_ERROR_OUT_OF_MEMORY Out of memory
176  */
177 int runtime_info_get_value_string(runtime_info_key_e key, char **value);
178
179
180 /**
181  * @brief   Registers a change event callback for given runtime information key.
182  *
183  * @param[in] key The runtime information type
184  * @param[in] callback The callback function to invoke
185  * @param[in] user_data The user data to be passed to the callback function
186  *
187  * @return  0 on success, otherwise a negative error value.
188  * @retval  #RUNTIME_INFO_ERROR_NONE Successful
189  * @retval  #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
190  * @post runtime_info_changed_cb() will be invoked.
191  *
192  * @see runtime_info_unset_changed_cb()
193  * @see runtime_info_changed_cb()
194 */
195 int runtime_info_set_changed_cb(runtime_info_key_e key, runtime_info_changed_cb callback, void *user_data);
196
197
198 /**
199  * @brief   Unregisters the callback function.
200  *
201  * @param[in] key The runtime information type
202  * @return  0 on success, otherwise a negative error value.
203  * @retval  #RUNTIME_INFO_ERROR_NONE Successful
204  * @retval  #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
205  *
206  * @see runtime_info_set_changed_cb()
207  */
208 int runtime_info_unset_changed_cb(runtime_info_key_e key);
209
210 /**
211  * @}
212  */
213
214 #ifdef __cplusplus
215 }
216 #endif
217
218 #endif /* __TIZEN_SYSTEM_RUNTIME_INFO_H__ */