Remove rua db write logic from rua_init, rua_fini.
[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 <time.h>
35
36 #ifndef API
37 #define API __attribute__ ((visibility("default")))
38 #endif
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /**
45  * @defgroup RUA rua
46  * @{
47  */
48
49 /**
50  * @}
51  */
52
53 /**
54  * @addtogroup RUA
55  * @{
56  */
57
58 /**
59  * @struct rua_rec
60  * @brief RUA record info structure
61  */
62 struct rua_rec {
63         int id;         /**<  primary key */
64         char *pkg_name;         /**< package name */
65         char *app_path;         /**< application path */
66         char *arg;              /**< application launching argument */
67         time_t launch_time;             /**< application launching time */
68 };
69
70 /**
71  * @brief       Clear history
72  * @return      0 on success, otherwise a nagative error value
73  * @retval      0 on successful
74  * @retval      -1 on failed
75  */
76 API int rua_clear_history(void);
77
78 /**
79  * @brief       Delete history with pkg_name
80  * @param[in]   pkg_name package name to delete history
81  * @return      0 on success, otherwise a nagative error value
82  * @retval      0 on successful
83  * @retval      -1 on failed
84  */
85 API int rua_delete_history_with_pkgname(char *pkg_name);
86
87 /**
88  * @brief       Delete history with app_path
89  * @param[in]   app_path package name to delete history
90  * @return      0 on success, otherwise a nagative error value
91  * @retval      0 on successful
92  * @retval      -1 on failed
93  */
94 API int rua_delete_history_with_apppath(char *app_path);
95
96 /**
97  * @brief       Add application to recently used application list
98  * @param[in]   rec  record to add history
99  * @return      0 on success, otherwise a nagative error value
100  * @retval      0 on successful
101  * @retval      -1 on failed
102  */
103 API int rua_add_history(struct rua_rec *rec);
104
105 /**
106  * @brief       Load recently used application history db.
107  * @param[out]  table db table pointer
108  * @param[out]  nrows the number of record
109  * @param[out]  ncols the number of field
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_history_load_db(char ***table, int *nrows, int *ncols);
115
116 /**
117  * @brief       Unload recently used application history db.
118  * @param[in]   table db table pointer to unload
119  * @return      0 on success, otherwise a nagative error value
120  * @retval      0 on successful
121  * @retval      -1 on failed
122  */
123 API int rua_history_unload_db(char ***table);
124
125 /**
126  * @brief       Load recently used application record.
127  * @param[out]  rec record to load
128  * @param[in]   table db table pointer
129  * @param[in]   nrows the number of record
130  * @param[in]   ncols the number of field
131  * @param[in]   row record index to load
132  * @return      0 on success, otherwise a nagative error value
133  * @retval      0 on successful
134  * @retval      -1 on failed
135  */
136 API int rua_history_get_rec(struct rua_rec *rec, char **table,
137                                 int nrows, int ncols, int row);
138
139 /**
140  * @brief       Check some package is latest or not with package name
141  * @param[in]   pkg_name package name
142  * @return      0 on success, otherwise a nagative error value
143  * @retval      0 if given pkg_name is lastest application
144  * @retval      -1 if not lastest applicaton or on failed
145  */
146 API int rua_is_latest_app(const char *pkg_name);
147
148 /**
149  * @brief       Initialize rua
150  * @return      0 on success, otherwise a nagative error value
151  * @retval      0 on successful
152  * @retval      -1 on failed
153  */
154 API int rua_init(void);
155
156 /**
157  * @brief       Finalize rua
158  * @return      0 on success, otherwise a nagative error value
159  * @retval      0 on successful
160  * @retval      -1 on failed
161  */
162 API int rua_fini(void);
163
164 #ifdef __cplusplus
165 }
166 #endif
167 #endif                          /*__RUA_H__*/