710d4711ecd7e6b2d9b142d4bc991cc33dc24402
[platform/core/appfw/librua.git] / include / rua.h
1 /*
2  *  RUA
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 /**
23  * @file        rua.h
24  * @brief       RUA API declaration header file.
25  * @author      Jinwoo Nam (jwoo.nam@samsung.com)
26  * @version     0.1
27  * @history     0.1: RUA API Declarations, structure declaration
28  */
29
30 #ifndef __RUA_H__
31 #define __RUA_H__
32
33 #include <sqlite3.h>
34 #include <bundle.h>
35 #include <time.h>
36
37 #ifndef API
38 #define API __attribute__ ((visibility("default")))
39 #endif
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 /**
46  * @defgroup RUA rua
47  * @{
48  */
49
50 /**
51  * @}
52  */
53
54 /**
55  * @addtogroup RUA
56  * @{
57  */
58
59 /**
60  * @struct rua_rec
61  * @brief RUA record info structure
62  */
63 struct rua_rec {
64         int id;         /**<  primary key */
65         char *pkg_name;         /**< package name */
66         char *app_path;         /**< application path */
67         char *arg;              /**< application launching argument */
68         time_t launch_time;             /**< application launching time */
69 };
70
71
72
73 /**
74  * @brief       Delete history from DB
75  * @return      0 on success, otherwise a nagative error value
76  * @retval      0 on successful
77  * @retval      -1 on failed
78  */
79 API int rua_delete_history_from_db(bundle *b);
80
81 /**
82  * @brief       Clear history
83  * @return      0 on success, otherwise a nagative error value
84  * @retval      0 on successful
85  * @retval      -1 on failed
86  */
87 API int rua_clear_history(void);
88
89 /**
90  * @brief       Delete history with pkg_name
91  * @param[in]   pkg_name package name to delete history
92  * @return      0 on success, otherwise a nagative error value
93  * @retval      0 on successful
94  * @retval      -1 on failed
95  */
96 API int rua_delete_history_with_pkgname(char *pkg_name);
97
98 /**
99  * @brief       Delete history with app_path
100  * @param[in]   app_path package name to delete history
101  * @return      0 on success, otherwise a nagative error value
102  * @retval      0 on successful
103  * @retval      -1 on failed
104  */
105 API int rua_delete_history_with_apppath(char *app_path);
106
107 /**
108  * @brief       Add application to recently used application list
109  * @param[in]   rec  record to add history
110  * @return      0 on success, otherwise a nagative error value
111  * @retval      0 on successful
112  * @retval      -1 on failed
113  */
114 API int rua_add_history(struct rua_rec *rec);
115
116 /**
117  * @brief       Load recently used application history db.
118  * @param[out]  table db table pointer
119  * @param[out]  nrows the number of record
120  * @param[out]  ncols the number of field
121  * @return      0 on success, otherwise a nagative error value
122  * @retval      0 on successful
123  * @retval      -1 on failed
124  */
125 API int rua_history_load_db(char ***table, int *nrows, int *ncols);
126
127 /**
128  * @brief       Unload recently used application history db.
129  * @param[in]   table db table pointer to unload
130  * @return      0 on success, otherwise a nagative error value
131  * @retval      0 on successful
132  * @retval      -1 on failed
133  */
134 API int rua_history_unload_db(char ***table);
135
136 /**
137  * @brief       Load recently used application record.
138  * @param[out]  rec record to load
139  * @param[in]   table db table pointer
140  * @param[in]   nrows the number of record
141  * @param[in]   ncols the number of field
142  * @param[in]   row record index to load
143  * @return      0 on success, otherwise a nagative error value
144  * @retval      0 on successful
145  * @retval      -1 on failed
146  */
147 API int rua_history_get_rec(struct rua_rec *rec, char **table,
148                                 int nrows, int ncols, int row);
149
150 /**
151  * @brief       Check some package is latest or not with package name
152  * @param[in]   pkg_name package name
153  * @return      0 on success, otherwise a nagative error value
154  * @retval      0 if given pkg_name is lastest application
155  * @retval      -1 if not lastest applicaton or on failed
156  */
157 API int rua_is_latest_app(const char *pkg_name);
158
159 /**
160  * @brief       Initialize rua
161  * @return      0 on success, otherwise a nagative error value
162  * @retval      0 on successful
163  * @retval      -1 on failed
164  */
165 API int rua_init(void);
166
167 /**
168  * @brief       Finalize rua
169  * @return      0 on success, otherwise a nagative error value
170  * @retval      0 on successful
171  * @retval      -1 on failed
172  */
173 API int rua_fini(void);
174
175 #ifdef __cplusplus
176 }
177 #endif
178 #endif                          /*__RUA_H__*/