2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __TIZEN_APPFW_APP_COMMON_H__
19 #define __TIZEN_APPFW_APP_COMMON_H__
30 * @addtogroup CAPI_APP_COMMON_MODULE
36 * @brief Enumeration for system events
41 APP_EVENT_LOW_MEMORY, /**< The low memory event */
42 APP_EVENT_LOW_BATTERY, /**< The low battery event */
43 APP_EVENT_LANGUAGE_CHANGED, /**< The system language changed event */
44 APP_EVENT_DEVICE_ORIENTATION_CHANGED, /**< The device orientation changed event */
45 APP_EVENT_REGION_FORMAT_CHANGED, /**< The region format changed event */
50 * @brief Enumeration for device orientation.
55 APP_DEVICE_ORIENTATION_0 = 0, /**< The device is oriented in a natural position */
56 APP_DEVICE_ORIENTATION_90 = 90, /**< The device's left side is at the top */
57 APP_DEVICE_ORIENTATION_180 = 180, /**< The device is upside down */
58 APP_DEVICE_ORIENTATION_270 = 270, /**< The device's right side is at the top */
59 } app_device_orientation_e;
63 * @brief Enumeration for low memory status.
68 APP_EVENT_LOW_MEMORY_NORMAL = 0x01, /**< Normal status */
69 APP_EVENT_LOW_MEMORY_SOFT_WARNING = 0x02, /**< Soft warning status */
70 APP_EVENT_LOW_MEMORY_HARD_WARNING = 0x04, /**< Hard warning status */
71 } app_event_low_memory_status_e;
75 * @brief Enumeration for battery status.
80 APP_EVENT_LOW_BATTERY_POWER_OFF = 1, /**< The battery status is under 1% */
81 APP_EVENT_LOW_BATTERY_CRITICAL_LOW, /**< The battery status is under 5% */
82 } app_event_low_battery_status_e;
86 * @brief The event handler that returned from add event handler function
89 * @see app_event_type_e
90 * @see app_add_event_handler
91 * @see app_remove_event_handler
92 * @see app_event_info_h
94 typedef struct app_event_handler* app_event_handler_h;
98 * @brief The system event information
101 * @see app_event_get_low_memory_status
102 * @see app_event_get_low_battery_status
103 * @see app_event_get_language
104 * @see app_event_get_region_format
105 * @see app_event_get_device_orientation
107 typedef struct app_event_info* app_event_info_h;
111 * @brief The system event callback function
114 * @param[in] event_info The system event information
115 * @param[in] user_data The user data passed from the add event handler function
117 * @see app_add_event_handler
118 * @see app_event_info_h
120 typedef void (*app_event_cb)(app_event_info_h event_info, void *user_data);
124 * @brief Gets the low memory status from given event info
127 * @param[in] event_info The system event info
128 * @param[out] status The low memory status
130 * @return 0 on success, otherwise a negative error value
131 * @retval #APP_ERROR_NONE Successful
132 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
133 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
135 * @see app_event_info_h
136 * @see app_event_low_memory_status_e
138 int app_event_get_low_memory_status(app_event_info_h event_info, app_event_low_memory_status_e *status);
142 * @brief Gets the low battery status from given event info
145 * @param[in] event_info The system event info
146 * @param[out] status The low battery status
148 * @return 0 on success, otherwise a negative error value
149 * @retval #APP_ERROR_NONE Successful
150 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
151 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
153 * @see app_event_info_h
154 * @see app_event_low_battery_status_e
156 int app_event_get_low_battery_status(app_event_info_h event_info, app_event_low_battery_status_e *status);
160 * @brief Gets the language from given event info
163 * @remarks @a lang must be released using free()
164 * @param[in] event_info The system event info
165 * @param[out] lang The language changed
167 * @return 0 on success, otherwise a negative error value
168 * @retval #APP_ERROR_NONE Successful
169 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
170 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
172 * @see app_event_info_h
174 int app_event_get_language(app_event_info_h event_info, char **lang);
178 * @brief Gets the region format from given event info
181 * @remarks @a region must be released using free()
182 * @param[in] event_info The system event info
183 * @param[out] region The region format changed
185 * @return 0 on success, otherwise a negative error value
186 * @retval #APP_ERROR_NONE Successful
187 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
188 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
190 * @see app_event_info_h
192 int app_event_get_region_format(app_event_info_h event_info, char **region);
196 * @brief Gets the device orientation from given event info
199 * @param[in] event_info The system event info
200 * @param[out] orientation The device orientation changed
202 * @return 0 on success, otherwise a negative error value
203 * @retval #APP_ERROR_NONE Successful
204 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
205 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
207 * @see app_event_info_h
208 * @see app_device_orientation_e
210 int app_event_get_device_orientation(app_event_info_h event_info, app_device_orientation_e *orientation);
214 * @brief Gets the ID of the application.
217 * @remarks @a id must be released using free().
219 * @param[out] id The ID of the application
221 * @return @c 0 on success,
222 * otherwise a negative error value
224 * @retval #APP_ERROR_NONE Successful
225 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
226 * @retval #APP_ERROR_INVALID_CONTEXT The application is illegally launched, not launched by the launch system
227 * @retval #APP_ERROR_OUT_OF_MEMORY Out of memory
229 int app_get_id(char **id);
233 * @brief Gets the localized name of the application.
236 * @remarks @a name must be released using free().
238 * @param[out] name The name of the application
240 * @return @c 0 on success,
241 * otherwise a negative error value
243 * @retval #APP_ERROR_NONE Successful
244 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
245 * @retval #APP_ERROR_INVALID_CONTEXT The application is illegally launched, not launched by the launch system
246 * @retval #APP_ERROR_OUT_OF_MEMORY Out of memory
248 int app_get_name(char **name);
252 * @brief Gets the version of the application package.
255 * @remarks @a version must be released using free().
257 * @param[out] version The version of the application
259 * @return @c 0 on success,
260 * otherwise a negative error value
262 * @retval #APP_ERROR_NONE Successful
263 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
264 * @retval #APP_ERROR_INVALID_CONTEXT The application is illegally launched, not launched by the launch system
265 * @retval #APP_ERROR_OUT_OF_MEMORY Out of memory
267 int app_get_version(char **version);
271 * @brief Gets the absolute path to the application's data directory which is used to store private
272 * data of the application.
273 * @details An application can read and write its own files in the application's data directory.
275 * @remarks The returned path should be released.
277 * @return The absolute path to the application's data directory, @n
278 * otherwise a null pointer if the memory is insufficient
280 char *app_get_data_path(void);
284 * @brief Gets the absolute path to the application's cache directory which is used to store
285 * temporary data of the application.
286 * @details An application can read and write its own files in the application's cache directory.
288 * @remarks The returned path should be released. @n
289 * The files stored in the application's cache directory can be removed by Setting
290 * application or platform while the application is running.
292 * @return The absolute path to the application's cache directory, @n
293 * otherwise a null pointer if the memory is insufficient
295 char *app_get_cache_path(void);
299 * @brief Gets the absolute path to the application resource directory. The resource files
300 * are delivered with the application package.
301 * @details An application can only read its own files in the application's resource directory.
303 * @remarks The returned path should be released.
305 * @return The absolute path to the application's resource directory, @n
306 * otherwise a null pointer if the memory is insufficient
308 char *app_get_resource_path(void);
312 * @brief Gets the absolute path to the application's shared data directory which is used to share
313 * data with other applications.
314 * @details An application can read and write its own files in the application's shared data
315 * directory and others can only read the files.
317 * @remarks The returned path should be released.
319 * @return The absolute path to the application's shared data directory, @n
320 * otherwise a null pointer if the memory is insufficient
322 char *app_get_shared_data_path(void);
326 * @brief Gets the absolute path to the application's shared resource directory which is used to
327 * share resources with other applications.
328 * @details An application can read its own files in the application's shared resource directory
329 * and others can only read the files.
331 * @remarks The returned path should be released.
333 * @return The absolute path to the application's shared resource directory, @n
334 * otherwise a null pointer if the memory is insufficient
336 char *app_get_shared_resource_path(void);
340 * @brief Gets the absolute path to the application's shared trusted directory which is used to share data
341 * with a family of trusted applications.
342 * @details An application can read and write its own files in the application's shared trusted directory
343 * and the family applications signed with the same certificate can read and write the files in the
344 * shared trusted directory.
346 * @remarks The returned path should be released.
348 * @return The absolute path to the application's shared trusted directory, @n
349 * otherwise a null pointer if the memory is insufficient
351 char *app_get_shared_trusted_path(void);
355 * @brief Gets the absolute path to the application's external data directory which is used to
356 * store data of the application.
357 * @details An application can read and write its own files in the application's external data
360 * @remarks The returned path should be released. @n
361 * The important files stored in the application's external data directory should be
362 * encrypted because they can be exported via the external sdcard.
364 * @return The absolute path to the application's external data directory, @n
365 * otherwise a null pointer if the memory is insufficient
367 char *app_get_external_data_path(void);
371 * @brief Gets the absolute path to the application's external cache directory which is used to
372 * store temporary data of the application.
373 * @details An application can read and write its own files in the application's external cache
376 * @remarks The returned path should be released. @n
377 * The files stored in the application's external cache directory can be removed by
378 * Setting application while the application is running. @n
379 * The important files stored in the application's external cache directory should be
380 * encrypted because they can be exported via the external sdcard.
382 * @return The absolute path to the application's external cache directory, @n
383 * otherwise a null pointer if the memory is insufficient
385 char *app_get_external_cache_path(void);
389 * @brief Gets the absolute path to the application's external shared data directory which is
390 * used to share data with other applications.
391 * @details An application can read and write its own files in the application's external shared
392 * data directory and others can only read the files.
394 * @remarks The specified @a path should be released.
396 * @return The absolute path to the application's external shared data directory, @n
397 * otherwise a null pointer if the memory is insufficient
399 char *app_get_external_shared_data_path(void);
409 #endif /* __TIZEN_APPFW_APP_H__ */