merge tizen 2.4
[platform/core/api/application.git] / include / app_resource_manager.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_APPFW_RESOURCE_MANAGER_H__
18 #define __TIZEN_APPFW_RESOURCE_MANAGER_H__
19
20 #include <tizen.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 /**
27  * @file app_resource_manager.h
28  */
29
30 /**
31  * @addtogroup CAPI_RESOURCE_MANAGER_MODULE
32  * @{
33  */
34
35 /**
36  * @brief Enumeration for Resource Types
37  * @since_tizen 2.4
38  */
39 typedef enum {
40         APP_RESOURCE_TYPE_IMAGE = 0, /**<Image*/
41         APP_RESOURCE_TYPE_LAYOUT, /**<Edje*/
42         APP_RESOURCE_TYPE_SOUND, /**<Sound*/
43         APP_RESOURCE_TYPE_BIN, /**<Bin*/
44         APP_RESOURCE_TYPE_MIN = APP_RESOURCE_TYPE_IMAGE,
45         APP_RESOURCE_TYPE_MAX = APP_RESOURCE_TYPE_BIN,
46 /*add values between APP_RESOURCE_TYPE_MIN and APP_RESOURCE_TYPE_MAX*/
47 } app_resource_e;
48
49 /**
50  * @brief Enumeration for App Resource Manager Error.
51  * @since_tizen 2.4
52  */
53 typedef enum {
54         APP_RESOURCE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
55         APP_RESOURCE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
56         APP_RESOURCE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
57         APP_RESOURCE_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
58 } app_resource_error_e;
59
60 /**
61  * @brief Creates resource manager and get from db.
62  *
63  * @since_tizen 2.4
64  * @remarks If resource manager is already exist,
65  *                      It will just return APP_RESOURCE_ERROR_NONE
66  * @return @c 0 on success,
67  *         otherwise a negative error value
68  * @retval #APP_RESOURCE_ERROR_NONE Successful
69  * @retval #APP_RESOURCE_ERROR_IO_ERROR IO Internal I/O Error
70  * @retval #APP_RESOURCE_ERROR_OUT_OF_MEMORY Out of memeory
71  * @see app_resource_manager_release()
72  */
73 int app_resource_manager_init(void);
74
75 /**
76  * @brief Convert resource ID to path name
77  *
78  * @since_tizen 2.4
79  * @remarks If resource manager is not created yet,
80  *                      app_resource_manager_init() will be invoked automatically.
81  *                      Caller should free the returned pointer.
82  * @param[in] type Resource type @see app_resource_e
83  * @param[in] id Resource ID
84  * @param[out] path The name of requested resource on success, otherwise NULL
85  * @return @c 0 on success,
86  *         otherwise a negative error value
87  * @retval #APP_RESOURCE_ERROR_NONE Successful
88  * @retval #APP_RESOURCE_ERROR_INVALID_PARAMETER Invalid Parameter
89  * @retval #APP_RESOURCE_ERROR_IO_ERROR Internal I/O Error
90  * @see app_resource_manager_init()
91  */
92 int app_resource_manager_get(app_resource_e type, const char *id, char **path);
93
94 /**
95  * @brief Destroys resource manager.
96  *
97  * @since_tizen 2.4
98  * @remarks Please make sure that the instance of resource manager should be released when the application is closing only.
99  *                      It is highly recommended way to improve run-time performance.
100  * @return @c 0 on success,
101  *         otherwise a negative error value
102  * @retval #APP_RESOURCE_ERROR_NONE Successful
103  * @see app_resource_manager_init()
104  */
105 int app_resource_manager_release(void);
106
107 /**
108  * @}
109  */
110
111 #ifdef __cplusplus
112 }
113 #endif
114
115 #endif /* __TIZEN_APPFW_RESOURCE_MANAGER_H__ */
116