merge from tizen24 to tizen30
[platform/core/api/system-settings.git] / include / system_settings_private.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
18 #ifndef __TIZEN_SYSTEM_SETTING_PRIVATE_H__
19 #define __TIZEN_SYSTEM_SETTING_PRIVATE_H__
20
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif
25
26 #include <dlog.h>
27
28 #ifdef LOG_TAG
29 #undef LOG_TAG
30 #endif
31
32 #define LOG_TAG "SYSTEM-SETTINGS"
33
34 #define SYSTEM_SETTINGS_ENABLE_TRACE
35
36 #ifdef SYSTEM_SETTINGS_ENABLE_TRACE
37
38         #define SETTING_TRACE_DEBUG(fmt, arg...) \
39                 do {\
40                         LOGD("\n\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \
41         ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
42                 }while(0);
43
44         #define SETTING_TRACE(fmt, arg...) \
45                 do {\
46                         LOGI("\n\033[0;36m" fmt "\033[0m\t%s:%d\n", \
47         ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
48                 }while(0);
49
50         #define SETTING_TRACE_BEGIN do {\
51                 {\
52                         printf("\n[SETTING]\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \
53                                         __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
54                 }\
55         }while(0);
56
57         #define SETTING_TRACE_END  do {\
58                 {\
59                         printf("\n[SETTING]\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \
60                                         __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\
61                 }\
62         }while(0);
63
64 #else
65         #define SETTING_TRACE_DEBUG(fmt, arg...)
66         #define SETTING_TRACE(fmt, arg...)
67     #define SETTING_TRACE_BEGIN
68     #define SETTING_TRACE_END
69 #endif
70
71
72 #define VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME  "db/setting/accessibility/font_name"
73
74 /**
75  * @internal
76  * @since_tizen 2.3
77  * Enumeration for data type of internal getter/setter.
78  */
79 typedef enum {
80         SYSTEM_SETTING_DATA_TYPE_STRING,        /**< string */
81         SYSTEM_SETTING_DATA_TYPE_INT,           /**< integer */
82         SYSTEM_SETTING_DATA_TYPE_BOOL,          /**< boolean */
83         #if 0
84         //SYSTEM_SETTING_DATA_TYPE_FLOAT,
85         //SYSTEM_SETTING_DATA_TYPE_DOULBE,
86         #endif
87 } system_setting_data_type_e;
88
89
90 /**
91  * @internal
92  * @since_tizen 2.3
93  * @return  0 on success, otherwise a negative error value
94  * @retval  #SYSTEM_SETTINGS_ERROR_NONE Successful
95  * @retval  #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter
96  * @retval  #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error
97  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
98  */
99 typedef int (*system_setting_get_value_cb) (system_settings_key_e key, system_setting_data_type_e data_type, void** value);
100
101 /**
102  * @internal
103  * @since_tizen 2.3
104  * @return  0 on success, otherwise a negative error value
105  * @retval  #SYSTEM_SETTINGS_ERROR_NONE Successful
106  * @retval  #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter
107  * @retval  #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error
108  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
109  */
110 typedef int (*system_setting_set_value_cb) (system_settings_key_e key, system_setting_data_type_e data_type, void* value);
111
112 /**
113  * @internal
114  * @since_tizen 2.3
115  * @return  0 on success, otherwise a negative error value
116  * @retval  #SYSTEM_SETTINGS_ERROR_NONE Successful
117  * @retval  #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter
118  * @retval  #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error
119  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
120  */
121 typedef int (*system_setting_set_changed_callback_cb)(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
122
123 /**
124  * @internal
125  * @since_tizen 2.3
126  * @return  0 on success, otherwise a negative error value
127  * @retval  #SYSTEM_SETTINGS_ERROR_NONE Successful
128  * @retval  #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter
129  * @retval  #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error
130  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
131  */
132 typedef int (*system_setting_unset_changed_callback_cb)(system_settings_key_e key);
133
134
135 /**
136  * @internal
137  * @since_tizen 2.3
138  * @return  0 on success, otherwise a negative error value
139  * @retval  #SYSTEM_SETTINGS_ERROR_NONE Successful
140  * @retval  #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter
141  * @retval  #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error
142  */
143 typedef struct {
144         system_settings_key_e key;                                                                              /**< key */
145         system_setting_data_type_e data_type;                                                   /**< data type */
146         system_setting_get_value_cb get_value_cb;                                               /**< function pointer for getter */
147         system_setting_set_value_cb set_value_cb;                                               /**< function pointer for setter */
148
149         system_setting_set_changed_callback_cb set_changed_cb;                  /**< function pointer to register for notification callback */
150         system_setting_unset_changed_callback_cb unset_changed_cb ;             /**< function pointer to un-register for notification callback */
151
152         system_settings_changed_cb changed_cb;                                                  /* registered by user application */
153         void* user_data;                                                                                                /* user_data */
154
155 } system_setting_s;
156
157 typedef system_setting_s* system_setting_h;
158
159
160 /**
161  * @internal
162  * @since_tizen 2.3
163  * @return  0 on success, otherwise a negative error value
164  * @retval  #SYSTEM_SETTINGS_ERROR_NONE Successful
165  * @retval  #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter
166  * @retval  #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error
167  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
168  */
169 int system_settings_get_item(system_settings_key_e key, system_setting_h *item);
170
171
172 // get
173
174 /**
175  * @internal
176  * @brief get vconf of in type value
177  * @since_tizen 2.3
178  *
179  * @param[in] vconf_key string
180  * @param[out] value get the integer type value
181  *
182  * @return 0 on success, -1 on error
183  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
184  */
185 int system_setting_vconf_get_value_int(const char *vconf_key, int *value);
186
187 /**
188  * @internal
189  * @brief get vconf of in bool value
190  * @since_tizen 2.3
191  *
192  * @param[in] vconf_key string
193  * @param[out] value get the bool type value
194  *
195  * @return 0 on success, -1 on error
196  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
197  */
198 int system_setting_vconf_get_value_bool(const char *vconf_key, bool *value);
199
200 /**
201  * @internal
202  * @brief get vconf of string type value
203  * @since_tizen 2.3
204  *
205  * @param[in] vconf_key string
206  * @param[out] value get the string(char*) type value
207  *
208  * @return 0 on success, -1 on error
209  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
210  */
211 int system_setting_vconf_get_value_string(const char *vconf_key, char **value);
212
213 /**
214  * @internal
215  * @brief set the int type vconf value
216  * @since_tizen 2.3
217  *
218  * @param[in] vconf_key key name
219  * @param[in] value int type value
220  *
221  * @return 0 on success, -1 on error
222  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
223  */
224 int system_setting_vconf_set_value_int(const char *vconf_key, int value);
225
226 /**
227  * @internal
228  * @brief set the bool type vconf value
229  * @since_tizen 2.3
230  *
231  * @param[in] vconf_key key name
232  * @param[in] value bool type value
233  *
234  * @return 0 on success, -1 on error
235  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
236  */
237 int system_setting_vconf_set_value_bool(const char *vconf_key, bool value);
238
239 /**
240  * @internal
241  * @brief set the string type vconf value
242  * @since_tizen 2.3
243  *
244  * @param[in] vconf_key key name
245  * @param[in] value string type value
246  *
247  * @return 0 on success, -1 on error
248  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
249  */
250 int system_setting_vconf_set_value_string(const char *vconf_key, char *value);
251
252 /**
253  * @internal
254  * @brief Set the system settings notification callback
255  * @since_tizen 2.3
256  * @param[in] vconf_key
257  * @param[in] key
258  * @param[in] slot internal slot to set the key (0~4)
259  * @param[in] user_data user data
260  * @return  0 on success, otherwise a negative error value
261  * @retval  #SYSTEM_SETTINGS_ERROR_NONE Successful
262  * @retval  #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error
263  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
264  */
265 int system_setting_vconf_set_changed_cb(const char *vconf_key, system_settings_key_e key, int slot, void* user_data);
266
267 /**
268  * @internal
269  * @brief Unset the system settings notification callback
270  * @since_tizen 2.3
271  * @param[in] vconf_key vconf key name used in the code
272  * @param[in] slot internal slot to set the key (0~4)
273  * @return  0 on success, otherwise a negative error value
274  * @retval  #SYSTEM_SETTINGS_ERROR_NONE Successful
275  * @retval  #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error
276  * @retval  #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error
277  */
278 int system_setting_vconf_unset_changed_cb(const char *vconf_key, int slot);
279
280 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void** value);
281 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void** value);
282 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void** value);
283 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void** value);
284 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void** value);
285 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void** value);
286 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void** value);
287 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void** value);
288 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void** value);
289
290 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void* value);
291 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void* value);
292 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void* value);
293 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void* value);
294 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void* value);
295 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void* value);
296 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void* value);
297 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void* value);
298 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void* value);
299
300 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
301 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key);
302
303 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
304 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key);
305
306 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
307 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key);
308
309 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
310 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key);
311
312 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
313 int system_setting_unset_changed_callback_font_size(system_settings_key_e key);
314
315 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
316 int system_setting_unset_changed_callback_font_type(system_settings_key_e key);
317
318 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
319 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key);
320
321 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
322 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key);
323
324 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data);
325 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key);
326
327 #ifdef __cplusplus
328 }
329 #endif
330
331 #endif /* __TIZEN_SYSTEM_SETTING_PRIVATE_H__ */
332
333
334