po: move translation files
[apps/core/preloaded/indicator-win.git] / inc / util.h
1 /*
2  *  Indicator
3  *
4  * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20
21
22 #ifndef __INDICATOR_UTIL_H__
23 #define __INDICATOR_UTIL_H__
24 #include <Ecore.h>
25 #include <wifi.h>
26 #include <system_settings.h>
27 #include <runtime_info.h>
28
29 typedef enum {
30         INDICATOR_ERROR_NONE = 0,
31         INDICATOR_ERROR_FAIL = -1,
32         INDICATOR_ERROR_DB_FAILED = -2,
33         INDICATOR_ERROR_OUT_OF_MEMORY = -3,
34         INDICATOR_ERROR_INVALID_PARAMETER = -4,
35         INDICATOR_ERROR_NO_DATA = -5,
36 } indicator_error_e;
37
38 typedef struct _Indicator_Data_Animation Indicator_Data_Animation;
39
40 struct _Indicator_Data_Animation
41 {
42    Ecore_X_Window xwin;
43    double         duration;
44 };
45
46 extern char *util_set_label_text_color(const char *txt);
47 extern const char *util_get_icon_dir(void);
48 extern void util_signal_emit(void* data, const char *emission, const char *source);
49 extern void util_part_text_emit(void* data, const char *part, const char *text);
50 extern void util_signal_emit_by_win(void* data, const char *emission, const char *source);
51 extern void util_part_text_emit_by_win(void* data, const char *part, const char *text);
52 extern void util_battery_percentage_part_content_set(void* data, const char *part, const char *img_path);
53 extern void util_launch_search(void* data);
54 extern int util_check_system_status(void);
55 extern char* util_get_timezone_str(void);
56 extern Eina_Bool util_win_prop_angle_get(Ecore_X_Window win, int *curr);
57 extern int util_is_orf(void);
58 extern int util_check_noti_ani(const char* path);
59 extern void util_start_noti_ani(void* data);
60 extern void util_stop_noti_ani(void* data);
61 extern void util_send_status_message_start(void* data,double duration);
62 extern void util_char_replace(char *text, char s, char t);
63 extern int util_dynamic_state_get(void);
64
65 extern Ecore_File_Monitor* util_file_monitor_add(const char* file_path, Ecore_File_Monitor_Cb callback_func, void *ad);
66 extern void util_file_monitor_remove(Ecore_File_Monitor* pFileMonitor);
67 extern char *util_safe_str(const char *str, const char *strSearch);
68
69 #ifdef _SUPPORT_SCREEN_READER
70 extern Evas_Object *util_access_object_register(Evas_Object *object, Evas_Object *layout);
71 extern void util_access_object_unregister(Evas_Object *object);
72 extern void util_access_object_info_set(Evas_Object *object, int info_type, char *info_text);
73 extern void util_icon_access_register(icon_s *icon);
74 extern void util_icon_access_unregister(icon_s *icon);
75 #endif /* _SUPPORT_SCREEN_READER */
76
77 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
78
79 /*
80  * @brief Application sub-directories type.
81  */
82 enum app_subdir {
83         APP_DIR_DATA,
84         APP_DIR_CACHE,
85         APP_DIR_RESOURCE,
86         APP_DIR_SHARED_DATA,
87         APP_DIR_SHARED_RESOURCE,
88         APP_DIR_SHARED_TRUSTED,
89         APP_DIR_EXTERNAL_DATA,
90         APP_DIR_EXTERNAL_CACHE,
91         APP_DIR_EXTERNAL_SHARED_DATA,
92 };
93
94 /**
95  * @brief Returns absolute path to resource file located in applications directory.
96  *
97  * @param subdir type of subdirectory
98  * @param relative path of resource in application's subdir.
99  *        eg. for DATA_DIR subdir and relative "database.db" => "/home/owner/apps/org.tizen.homescreen-efl/data/database.db"
100  * @return absolute path string.
101  */
102 const char *util_get_file_path(enum app_subdir dir, const char *relative);
103
104 /**
105  * @brief Convinience macros
106  */
107 #define util_get_data_file_path(x) util_get_file_path(APP_DIR_DATA, (x))
108 #define util_get_cache_file_path(x) util_get_file_path(APP_DIR_CACHE, (x))
109 #define util_get_res_file_path(x) util_get_file_path(APP_DIR_RESOURCE, (x))
110 #define util_get_shared_data_file_path(x) util_get_file_path(APP_DIR_SHARED_DATA, (x))
111 #define util_get_shared_res_file_path(x) util_get_file_path(APP_DIR_SHARED_RESOURCE, (x))
112 #define util_get_trusted_file_path(x) util_get_file_path(APP_DIR_SHARED_TRUSTED, (x))
113 #define util_get_external_data_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_DATA, (x))
114 #define util_get_external_cache_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_CACHE, (x))
115 #define util_get_external_shared_data_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_SHARED_DATA, (x))
116
117 /**
118  * @brief Allows to set multiple callbacks using wifi_set_connection_state_changed_cb API
119  *
120  * @param cb callback
121  * @param data user_data passed to callback function.
122  * @return 0 on success, other value on failure
123  */
124 int util_wifi_set_connection_state_changed_cb(wifi_connection_state_changed_cb, void *data);
125
126 /**
127  * @brief Unregisters callback set with util_wifi_set_connection_state_changed_cb.
128  *
129  * @param cb callback
130  */
131 void util_wifi_unset_connection_state_changed_cb(wifi_connection_state_changed_cb);
132
133 /**
134  * @brief Allows to register multiple callbacks using system_settings_changed_cb API.
135  *
136  * @param key key to monitor.
137  * @param cb callback.
138  * @param data user_data passed to callback function.
139  *
140  * @return 0 on success, other value on failure.
141  */
142 int util_system_settings_set_changed_cb(system_settings_key_e key, system_settings_changed_cb cb, void *data);
143
144 /**
145  * @brief Unregisters callback set with util_system_settings_set_changed_cb.
146  *
147  * @param key key to stop monitor.
148  * @param cb callback
149  */
150 void util_system_settings_unset_changed_cb(system_settings_key_e key, system_settings_changed_cb cb);
151
152 /**
153  * @brief Allows to register multiple callbacks using runtime_info_set_changed_cb API.
154  *
155  * @param key key to monitor.
156  * @param cb callback.
157  * @param data user data passed to callback function.
158  *
159  * @return 0 on success, other value on failure.
160  */
161 int util_runtime_info_set_changed_cb(runtime_info_key_e key, runtime_info_changed_cb cb, void *data);
162
163 /**
164  * @brief Unregisters callback set with util_runtime_info_set_changed_cb.
165  *
166  * @param key key to stop monitor.
167  * @param cb callback.
168  */
169 void util_runtime_info_unset_changed_cb(runtime_info_key_e key, runtime_info_changed_cb cb);
170
171 #endif /* __INDICATOR_UTIL_H__ */