tizen 2.4 release
[framework/appfw/aul-1.git] / include / aul_rsc_mgr.h
1 /*
2  * Copyright (c) 2015 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 __AUL_RESOURCE_MANAGER_H__
18 #define __AUL_RESOURCE_MANAGER_H__
19
20 #include <tizen.h>
21 #include <bundle.h>
22 #include <glib.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29  * @brief Enumeration for Resource Types
30  * @since_tizen 2.4
31  */
32 typedef enum {
33         AUL_RESOURCE_TYPE_IMAGE = 0, /**<Image*/
34         AUL_RESOURCE_TYPE_LAYOUT, /**<Edje*/
35         AUL_RESOURCE_TYPE_SOUND, /**<Sound*/
36         AUL_RESOURCE_TYPE_BIN, /**<Bin*/
37         AUL_RESOURCE_TYPE_MIN = AUL_RESOURCE_TYPE_IMAGE,
38         AUL_RESOURCE_TYPE_MAX = AUL_RESOURCE_TYPE_BIN,
39 /*add values between AUL_RESOURCE_TYPE_MIN and AUL_RESOURCE_TYPE_MAX*/
40 } aul_resource_e;
41
42 /**
43  * @brief Enumeration for Aul Resource Manager Error.
44  * @since_tizen 2.4
45  */
46 typedef enum {
47         AUL_RESOURCE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
48         AUL_RESOURCE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
49         AUL_RESOURCE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
50         AUL_RESOURCE_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
51 } aul_resource_error_e;
52
53 /**
54  * @brief Creates resource manager and get from db.
55  *
56  * @since_tizen 2.4
57  * @remarks If resource manager is already exist,
58  *                      It will just return APP_RESOURCE_ERROR_NONE
59  * @return @c 0 on success,
60  *         otherwise a negative error value
61  * @retval #AUL_RESOURCE_ERROR_NONE Successful
62  * @retval #AUL_RESOURCE_ERROR_IO_ERROR IO Internal I/O Error
63  * @retval #AUL_RESOURCE_ERROR_OUT_OF_MEMORY Out of memeory
64  * @see aul_resource_manager_release()
65  */
66 int aul_resource_manager_init(void);
67
68 /**
69  * @brief Creates resource manager and make valid filelist from given attributes.
70  *
71  * @since_tizen 2.4
72  * @remarks If resource manager is already exist,
73  *                      It will just return APP_RESOURCE_ERROR_NONE
74  *                      This function should called from resource slice tool only.
75  * @param[in] rsc_folder_path path of resource.
76  * @param[in] b bundle which contain attributes about target device.
77  * @return @c 0 on success,
78  *         otherwise a negative error value
79  * @retval #AUL_RESOURCE_ERROR_NONE Successful
80  * @retval #AUL_RESOURCE_ERROR_IO_ERROR IO Internal I/O Error
81  * @retval #AUL_RESOURCE_ERROR_OUT_OF_MEMORY Out of memeory
82  * @see aul_resource_manager_release()
83  */
84 int aul_resource_manager_init_slice(const char *rsc_folder_path, bundle *b);
85
86 /**
87  * @brief Convert resource ID to path name
88  *
89  * @since_tizen 2.4
90  * @remarks If resource manager is not created yet,
91  *                      aul_resource_manager_init() will be invoked automatically.
92  *                      Caller should free the returned pointer.
93  * @param[in] type Resource type @see aul_resource_e
94  * @param[in] id Resource ID
95  * @param[out] path The name of requested resource on success, otherwise NULL
96  * @return @c 0 on success,
97  *         otherwise a negative error value
98  * @retval #AUL_RESOURCE_ERROR_NONE Successful
99  * @retval #AUL_RESOURCE_ERROR_INVALID_PARAMETER Invalid Parameter
100  * @retval #AUL_RESOURCE_ERROR_IO_ERROR Internal I/O Error
101  * @see aul_resource_manager_init()
102  */
103 int aul_resource_manager_get(aul_resource_e type, const char *id, char **path);
104
105 /**
106  * @brief Destroys resource manager.
107  *
108  * @since_tizen 2.4
109  * @remarks Please make sure that the instance of resource manager should be released when the application is closing only.
110  *                      It is highly recommended way to improve run-time performance.
111  * @return @c 0 on success,
112  *         otherwise a negative error value
113  * @retval #AUL_RESOURCE_ERROR_NONE Successful
114  * @see aul_resource_manager_init()
115  */
116 int aul_resource_manager_release(void);
117
118 /**
119  * @brief Get valid file path list.
120  *
121  * @since_tizen 2.4
122  * @remarks Please make sure that the instance of resource manager should be released when the application is closing only.
123  *                      It is highly recommended way to improve run-time performance.
124  * @return @c 0 on success,
125  *         otherwise a negative error value
126  * @retval #AUL_RESOURCE_ERROR_NONE Successful
127  * @see aul_resource_manager_init()
128  */
129 int aul_resource_manager_get_path_list(GHashTable **list);
130
131 /**
132  * @}
133  */
134
135 #ifdef __cplusplus
136 }
137 #endif
138
139 #endif /* __AUL_RESOURCE_MANAGER_H__ */