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__
21 #include <app_types.h>
32 * @addtogroup CAPI_APP_COMMON_MODULE
38 * @brief Enumeration for system events
39 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
43 APP_EVENT_LOW_MEMORY, /**< The low memory event */
44 APP_EVENT_LOW_BATTERY, /**< The low battery event */
45 APP_EVENT_LANGUAGE_CHANGED, /**< The system language changed event */
46 APP_EVENT_DEVICE_ORIENTATION_CHANGED, /**< The device orientation changed event */
47 APP_EVENT_REGION_FORMAT_CHANGED, /**< The region format changed event */
52 * @brief Enumeration for device orientation.
53 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
57 APP_DEVICE_ORIENTATION_0 = 0, /**< The device is oriented in a natural position */
58 APP_DEVICE_ORIENTATION_90 = 90, /**< The device's left side is at the top */
59 APP_DEVICE_ORIENTATION_180 = 180, /**< The device is upside down */
60 APP_DEVICE_ORIENTATION_270 = 270, /**< The device's right side is at the top */
61 } app_device_orientation_e;
65 * @brief Enumeration for low memory status.
66 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
70 APP_EVENT_LOW_MEMORY_NORMAL = 0x01, /**< Normal status */
71 APP_EVENT_LOW_MEMORY_SOFT_WARNING = 0x02, /**< Soft warning status */
72 APP_EVENT_LOW_MEMORY_HARD_WARNING = 0x04, /**< Hard warning status */
73 } app_event_low_memory_status_e;
77 * @brief Enumeration for battery status.
78 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
82 APP_EVENT_LOW_BATTERY_POWER_OFF = 1, /**< The battery status is under 1% */
83 APP_EVENT_LOW_BATTERY_CRITICAL_LOW, /**< The battery status is under 5% */
84 } app_event_low_battery_status_e;
88 * @brief The event handler that returned from add event handler function
90 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
91 * @see app_event_type_e
92 * @see app_add_event_handler
93 * @see app_remove_event_handler
94 * @see app_event_info_h
96 typedef struct app_event_handler* app_event_handler_h;
100 * @brief The system event information
102 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
103 * @see app_event_get_low_memory_status
104 * @see app_event_get_low_battery_status
105 * @see app_event_get_language
106 * @see app_event_get_region_format
107 * @see app_event_get_device_orientation
109 typedef struct app_event_info* app_event_info_h;
113 * @brief The system event callback function
115 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
116 * @param[in] event_info The system event information
117 * @param[in] user_data The user data passed from the add event handler function
119 * @see app_add_event_handler
120 * @see app_event_info_h
122 typedef void (*app_event_cb)(app_event_info_h event_info, void *user_data);
126 * @brief Gets the low memory status from given event info
128 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
129 * @param[in] event_info The system event info
130 * @param[out] status The low memory status
132 * @return 0 on success, otherwise a negative error value
133 * @retval #APP_ERROR_NONE Successful
134 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
135 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
137 * @see app_event_info_h
138 * @see app_event_low_memory_status_e
140 int app_event_get_low_memory_status(app_event_info_h event_info, app_event_low_memory_status_e *status);
144 * @brief Gets the low battery status from given event info
146 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
147 * @param[in] event_info The system event info
148 * @param[out] status The low battery status
150 * @return 0 on success, otherwise a negative error value
151 * @retval #APP_ERROR_NONE Successful
152 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
153 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
155 * @see app_event_info_h
156 * @see app_event_low_battery_status_e
158 int app_event_get_low_battery_status(app_event_info_h event_info, app_event_low_battery_status_e *status);
162 * @brief Gets the language from given event info
164 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
165 * @remarks @a lang must be released using free()
166 * @param[in] event_info The system event info
167 * @param[out] lang The language changed
169 * @return 0 on success, otherwise a negative error value
170 * @retval #APP_ERROR_NONE Successful
171 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
172 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
174 * @see app_event_info_h
176 int app_event_get_language(app_event_info_h event_info, char **lang);
180 * @brief Gets the region format from given event info
182 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
183 * @remarks @a region must be released using free()
184 * @param[in] event_info The system event info
185 * @param[out] region The region format changed
187 * @return 0 on success, otherwise a negative error value
188 * @retval #APP_ERROR_NONE Successful
189 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
190 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
192 * @see app_event_info_h
194 int app_event_get_region_format(app_event_info_h event_info, char **region);
198 * @brief Gets the device orientation from given event info
200 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
201 * @param[in] event_info The system event info
202 * @param[out] orientation The device orientation changed
204 * @return 0 on success, otherwise a negative error value
205 * @retval #APP_ERROR_NONE Successful
206 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
207 * @retval #APP_ERROR_INVALID_CONTEXT Invalid event context
209 * @see app_event_info_h
210 * @see app_device_orientation_e
212 int app_event_get_device_orientation(app_event_info_h event_info, app_device_orientation_e *orientation);
216 * @brief Gets the ID of the application.
218 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
219 * @remarks @a id must be released using free().
221 * @param[out] id The ID of the application
223 * @return @c 0 on success,
224 * otherwise a negative error value
226 * @retval #APP_ERROR_NONE Successful
227 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
228 * @retval #APP_ERROR_INVALID_CONTEXT The application is illegally launched, not launched by the launch system
229 * @retval #APP_ERROR_OUT_OF_MEMORY Out of memory
231 int app_get_id(char **id);
235 * @brief Gets the localized name of the application.
237 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
238 * @remarks @a name must be released using free().
240 * @param[out] name The name of the application
242 * @return @c 0 on success,
243 * otherwise a negative error value
245 * @retval #APP_ERROR_NONE Successful
246 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
247 * @retval #APP_ERROR_INVALID_CONTEXT The application is illegally launched, not launched by the launch system
248 * @retval #APP_ERROR_OUT_OF_MEMORY Out of memory
250 int app_get_name(char **name);
254 * @brief Gets the version of the application package.
256 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
257 * @remarks @a version must be released using free().
259 * @param[out] version The version of the application
261 * @return @c 0 on success,
262 * otherwise a negative error value
264 * @retval #APP_ERROR_NONE Successful
265 * @retval #APP_ERROR_INVALID_PARAMETER Invalid parameter
266 * @retval #APP_ERROR_INVALID_CONTEXT The application is illegally launched, not launched by the launch system
267 * @retval #APP_ERROR_OUT_OF_MEMORY Out of memory
269 int app_get_version(char **version);
273 * @brief Gets the absolute path to the application's data directory which is used to store private
274 * data of the application.
275 * @details An application can read and write its own files in the application's data directory.
276 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
277 * @remarks The returned path should be released.
279 * @return The absolute path to the application's data directory, @n
280 * otherwise a null pointer if the memory is insufficient
282 char *app_get_data_path(void);
286 * @brief Gets the absolute path to the application's cache directory which is used to store
287 * temporary data of the application.
288 * @details An application can read and write its own files in the application's cache directory.
289 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
290 * @remarks The returned path should be released. @n
291 * The files stored in the application's cache directory can be removed by Setting
292 * application or platform while the application is running.
294 * @return The absolute path to the application's cache directory, @n
295 * otherwise a null pointer if the memory is insufficient
297 char *app_get_cache_path(void);
301 * @brief Gets the absolute path to the application resource directory. The resource files
302 * are delivered with the application package.
303 * @details An application can only read its own files in the application's resource directory.
304 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
305 * @remarks The returned path should be released.
307 * @return The absolute path to the application's resource directory, @n
308 * otherwise a null pointer if the memory is insufficient
310 char *app_get_resource_path(void);
314 * @brief Gets the absolute path to the application's shared data directory which is used to share
315 * data with other applications.
316 * @details An application can read and write its own files in the application's shared data
317 * directory and others can only read the files.
318 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
319 * @remarks The returned path should be released.
321 * @return The absolute path to the application's shared data directory, @n
322 * otherwise a null pointer if the memory is insufficient
324 char *app_get_shared_data_path(void);
328 * @brief Gets the absolute path to the application's shared resource directory which is used to
329 * share resources with other applications.
330 * @details An application can read its own files in the application's shared resource directory
331 * and others can only read the files.
332 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
333 * @remarks The returned path should be released.
335 * @return The absolute path to the application's shared resource directory, @n
336 * otherwise a null pointer if the memory is insufficient
338 char *app_get_shared_resource_path(void);
342 * @brief Gets the absolute path to the application's shared trusted directory which is used to share data
343 * with a family of trusted applications.
344 * @details An application can read and write its own files in the application's shared trusted directory
345 * and the family applications signed with the same certificate can read and write the files in the
346 * shared trusted directory.
347 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
348 * @remarks The returned path should be released.
350 * @return The absolute path to the application's shared trusted directory, @n
351 * otherwise a null pointer if the memory is insufficient
353 char *app_get_shared_trusted_path(void);
357 * @brief Gets the absolute path to the application's external data directory which is used to
358 * store data of the application.
359 * @details An application can read and write its own files in the application's external data
361 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
362 * @remarks The returned path should be released. @n
363 * The important files stored in the application's external data directory should be
364 * encrypted because they can be exported via the external sdcard.
366 * @return The absolute path to the application's external data directory, @n
367 * otherwise a null pointer if the memory is insufficient
369 char *app_get_external_data_path(void);
373 * @brief Gets the absolute path to the application's external cache directory which is used to
374 * store temporary data of the application.
375 * @details An application can read and write its own files in the application's external cache
377 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
378 * @remarks The returned path should be released. @n
379 * The files stored in the application's external cache directory can be removed by
380 * Setting application while the application is running. @n
381 * The important files stored in the application's external cache directory should be
382 * encrypted because they can be exported via the external sdcard.
384 * @return The absolute path to the application's external cache directory, @n
385 * otherwise a null pointer if the memory is insufficient
387 char *app_get_external_cache_path(void);
391 * @brief Gets the absolute path to the application's external shared data directory which is
392 * used to share data with other applications.
393 * @details An application can read and write its own files in the application's external shared
394 * data directory and others can only read the files.
395 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
396 * @remarks The specified @a path should be released.
398 * @return The absolute path to the application's external shared data directory, @n
399 * otherwise a null pointer if the memory is insufficient
401 char *app_get_external_shared_data_path(void);
404 * @brief Gets the absolute path to the application's TEP(Tizen Expansion Package) directory.
405 * The resource files are delivered with the expansion package.
406 * @details An application can only read its own files in the application's TEP(Tizen Expansion Package) directory.
408 * @remarks The returned path should be released.
410 * @return The absolute path to the application's TEP(Tizen Expansion Package) directory, @n
411 * otherwise a null pointer if the memory is insufficient
413 char *app_get_tep_resource_path(void);
423 #endif /* __TIZEN_APPFW_APP_H__ */