merge tizen 2.4 & add test bin
[platform/core/appfw/app2sd.git] / plugin / app2sd / inc / app2sd_interface.h
1 /*
2  * app2ext
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Garima Shrivastava<garima.s@samsung.com>
7  *      Jyotsna Dhumale <jyotsna.a@samsung.com>
8  *      Venkatesha Sarpangala <sarpangala.v@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24 #ifndef __APPTOSD_INTERFACE_H__
25 #define __APPTOSD_INTERFACE_H__
26
27 /**
28  * @file app2sd_interface.h
29  * @version 0.2
30  * @brief    This file declares API of app2sd library
31  */
32 /**
33  * @addtogroup APPLICATION_FRAMEWORK
34  * @{
35  *
36  * @defgroup app2sd
37  * @version    0.2
38  *
39  * @section    Header to use them:
40  * @code
41  * #include <app2sd_interface.h>
42  * @endcode
43  *
44  * @addtogroup app2sd
45  * @{
46  */
47
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
53 #include <app2ext_interface.h>
54
55
56         /**
57          * @brief : This API prepares the setup for installation in SD card.
58          *              It should be called before actual installation is done.
59          * @pre                 vfat type sd card must be present.
60          * @post                Installation is done by package installer.
61                         Encryption password is saved in db TZ_SYS_DB/.app2sd.db
62          * @param[in] appname           application package name
63          *                              [Ex: com.samsung.calculator]
64          *This entry is parsed from application package control/manifest file.
65          * @param[in] dir_list          directory structure of the application
66          * @param[in] size      size of memory required by application(in MB).
67          *This entry is parsed from application package control/manifest file.
68          * @return      0 if success,  error code(>0) if fail
69          * @remark      None.
70          *
71          *
72          @code
73          #include <app2sd_interface.h>
74          int ret = -1;
75          GList* dir_list = NULL;
76          // Package manager populates dir_list with directory structure information
77          ret= app2sd_pre_app_install
78                 ("com.samsung.calculotor", dir_list, 10);
79          if(!ret)
80          {
81          printf("\n SUCCESS");
82                 // Package installer performs installation
83                 // app2sd_post_app_install() API should be called
84          return;
85          }
86          else
87          printf("\n FAILURE");
88          @endcode
89          */
90         API int app2sd_pre_app_install(const char *appname,
91                         GList* dir_list, int size);
92
93         /**
94          * @brief : This API does post installation operations after
95          *              the installation in SD card
96          * @param[in] appname           application package name
97          *                              [Ex: com.samsung.calculator]
98          * @param[in] install_status    Status of installation of package
99          *[ enum app2ext_status].If package installation failed then
100          * install_status= APP2EXT_STATUS_FAILURE else if installation
101          * was successful then install_status = APP2EXT_ISTATUS_SUCCESS.
102          * @pre         Installation should be done by package installer.
103          * @return      0 if success,  error code(>0) if fail
104          * @remark      @see enum app2sd_install_status
105          *
106          *
107          @code
108          #include <app2sd_interface.h>
109          int ret = -1;
110          ret= app2sd_pre_app_install
111                 ("com.samsung.calculotor", APP2EXT_NATIVE_APP, 10);
112          if(!ret)
113          {
114                  printf("\n SUCCESS");
115                 // Package installer performs installation
116         //Package was installed successfully.
117         if(package_installation _success)
118          {
119          ret = app2sd_post_app_install
120          ("com.samsung.calculator",APP2EXT_STATUS_SUCCESS);
121          if(!ret)
122          printf("\n SUCCESS");
123          else
124          printf("\n FAILURE");
125          return;
126          }
127          else
128          {
129          //Package installation failed
130          ret = app2sd_post_app_install
131          ("com.samsung.calculator",APP2EXT_STATUS_FAILURE);
132          if(!ret)
133          printf("\n SUCCESS");
134          else
135          printf("\n FAILURE");
136          return;
137          }
138          }
139          else
140          printf("\n FAILURE");
141          @endcode
142          */
143         API int app2sd_post_app_install(const char *appname,
144                         app2ext_status install_status);
145
146         /**
147          * @brief : This API prepares the setup for upgradation of
148          *               application package
149          * @pre                 vfat type sd card must be present.
150          * @post                Upgradation is done by package installer.
151          * @param[in] appname           application package name
152          *                              [Ex: com.samsung.calculator]
153          * @param[in] dir_list          directory structure of the application
154          * @param[in] size      size of memory required by application(in MB).
155          *This entry is parsed from application package control/manifest file.
156          * @return      0 if success,  error code(>0) if fail
157          * @remark      None.
158          *
159          *
160          @code
161          #include <app2sd_interface.h>
162          int ret = -1;
163          GList* dir_list = NULL;
164          // Package manager populates dir_list with directory structure information
165          ret= app2sd_pre_app_upgrade
166                 ("com.samsung.calculator", dir_list, 10);
167          if(!ret)
168          {
169          printf("\n SUCCESS");
170                 // Package installer performs upgradation
171                 // app2sd_post_app_upgrade() API should be called
172          return;
173          }
174          else
175          printf("\n FAILURE");
176          @endcode
177          */
178         API int app2sd_pre_app_upgrade(const char *appname,
179                         GList* dir_list, int size);
180
181         /**
182          * @brief : This API does post upgradation operations after
183          *              the installation in SD card
184          * @param[in] appname           application package name
185          *                              [Ex: com.samsung.calculator]
186          * @param[in] install_status    Status of installation of package
187          *[ enum app2extl_status].If package upgradation failed then
188          * upgrade_status= APP2EXT_STATUS_FAILURE else if upgradation
189          * was successful then upgrade_status = APP2EXT_STATUS_SUCCESS.
190          * @pre         Upgradation should be done by package installer.
191          * @return      0 if success,  error code(>0) if fail
192          * @remark      @see enum app2ext_status
193          *
194          *
195          @code
196          #include <app2sd_interface.h>
197          int ret = -1;
198          ret= app2sd_pre_app_upgrade
199                 ("com.samsung.calculator", APP2EXT_NATIVE_APP, 10);
200          if(!ret)
201          {
202          printf("\n SUCCESS");
203                 // Package installer performs upgradation
204         //Package was upgraded successfully.
205         if(package_upgradation _success)
206          {
207          ret = app2sd_post_app_upgrade
208          ("com.samsung.calculator",APP2EXT_STATUS_SUCCESS);
209          if(!ret)
210          printf("\n SUCCESS");
211          else
212          printf("\n FAILURE");
213          return;
214          }
215          else
216          {
217          //Package upgradation failed
218          ret = app2sd_post_app_upgrade
219          ("com.samsung.calculator",APP2EXT_STATUS_FAILURE);
220          if(!ret)
221          printf("\n SUCCESS");
222          else
223          printf("\n FAILURE");
224          return;
225          }
226          }
227          else
228          printf("\n FAILURE");
229          @endcode
230          */
231         API int app2sd_post_app_upgrade(const char *appname,
232                                         app2ext_status upgrade_status);
233
234         /**
235          * @brief: This API prepares the setup for uninstallation
236          * @pre                 Package must be installed in sdcard.
237          * @post        Package is uninstalled by the package installer.
238          * @param[in] appname           application package name
239          *                              [Ex: com.samsung.calculator]
240          * @return      0 if success,  error code(>0) if fail
241          * @remark      None.
242          *
243          *
244          @code
245          #include <app2sd_interface.h>
246          int ret = -1;
247          ret= app2sd_pre_app_uninstall
248                 ("com.samsung.calculator");
249          if(!ret)
250          {
251          printf("\n SUCCESS");
252                 // Package installer performs uninstallation
253                 // app2sd_post_app_uninstall() API should be called
254          return;
255          }
256          else
257          printf("\n FAILURE");
258          @endcode
259          */
260         API int app2sd_pre_app_uninstall(const char *appname);
261
262         /**
263          * @brief This API removes the resources created during
264          app2sd setup.It is called after uninstallation.
265          * @pre                 Package must be uninstalled .
266          * @post                Encryption password is removed from sqlite db.
267          * @param[in] appname           application package name
268          *                              [Ex: com.samsung.calculator]
269          * @return      0 if success,  error code(>0) if fail
270          * @remark      None.
271          *
272          *
273          @code
274          #include <app2sd_interface.h>
275          int ret = -1;
276          ret= app2sd_pre_app_uninstall
277                 ("com.samsung.calculator");
278          if(!ret)
279          {
280          printf("\n SUCCESS");
281                 // Package installer performs uninstallation
282          ret = app2sd_post_app_uninstall("com.samsung.calculator");
283          if(!ret)
284          printf("\n SUCCESS");
285          else
286          printf("\n FAILURE");
287          return;
288          }
289          else
290          printf("\n FAILURE");
291          @endcode
292          */
293         API int app2sd_post_app_uninstall(const char *appname);
294
295         /**
296          * @brief : This API moves the package from sd card
297          to internal memory and vice versa.
298          * @param[in] pkgid             application package id
299          *                              [Ex: com.samsung.calculator]
300          * @param[in] move_type         Move type[enum app2ext_move_type]
301          *                      [sd card to internal/internal to sd card]
302          * @param[in] dir_list          directory structure of the application
303          * @pre                 Package must be installed and its installation
304          * location should be known.Use app2sd_get_app_install_location()
305          * to get installation location.
306          * @see app2sd_get_app_install_location().
307          * @post        Package is moved to new location.
308          * @return      0 if success,  error code(>0) if fail
309          * @remark      None.
310          *
311          *
312          @code
313          #include <app2sd_interface.h>
314          int ret = -1;
315          GList* dir_list = NULL;
316          // Package manager populates dir_list with directory structure information
317          ret = app2sd_get_app_install_location("com.samsung.calculator");
318          if(ret == APP2SD_INTERNAL_MEM)
319          {
320          ret= app2sd_move_installed_app("com.samsung.calculator",
321          dir_list, APP2EXT_MOVE_TO_EXT);
322          if(!ret)
323          printf("\n SUCCESS");
324          else
325          printf("\n FAILURE");
326          }
327          else if(ret == APP2SD_EXTERNAL_MEM)
328          {
329          ret= app2sd_move_installed_app("com.samsung.calculator",
330          dir_list, APP2SD_MOVE_TO PHONE);
331          if(!ret)
332          printf("\n SUCCESS");
333          else
334          printf("\n FAILURE");
335          }
336          @endcode
337          */
338         API int app2sd_move_installed_app(const char *pkgid,
339                                         GList* dir_list, app2ext_move_type move_type);
340
341         /**
342          * @brief : This API Enables the application in sd card
343          for use. This API should be called by AUL.
344          * @param[in] pkgid             application package id
345         *                               [Ex: com.samsung.calculator]
346          * @pre                 Package must be installed
347          * @post        application is enabled in SD card.
348          * @return      0 if success,  error code(>0) if fail
349          * @remark      None.
350          *
351          *
352          @code
353          #include <app2sd_interface.h>
354          int ret = -1;
355          ret= app2sd_on_demand_setup_init("com.samsung.calculator");
356          if(!ret)
357          printf("\n SUCCESS");
358          else
359          printf("\n FAILURE");
360          }
361          @endcode
362          */
363         API int app2sd_on_demand_setup_init(const char *pkgid);
364
365
366         /**
367          * @brief : This API Disables the application in sd card
368          . This API should be called by Launchpad callback which will be registered
369           during app launch for exit action of the application
370          * @param[in] pkgid             application package id
371         *                               [Ex: com.samsung.calculator]
372          * @pre                 Package must be installed and enabled
373          *                      and application must be running in SD card
374          * @post        application is disabked in SD card.
375          * @return      0 if success,  error code(>0) if fail
376          * @remark      None.
377          *
378          *
379          @code
380          #include <app2sd_interface.h>
381          int ret = -1;
382          ret= app2sd_on_demand_setup_exit("com.samsung.calculator");
383          if(!ret)
384          printf("\n SUCCESS");
385          else
386          printf("\n FAILURE");
387          }
388          @endcode
389          */
390         API int app2sd_on_demand_setup_exit(const char *pkgid);
391
392         /**
393          * @brief : This is the plug-in load function.
394                   The plugin has to bind its functions to function pointers of storage handle
395          * @param[in/out] st_interface          Specifies the storage interface.
396          * @return      None
397         */
398         API void app2ext_on_load(app2ext_interface *st_interface);
399
400
401 #ifdef __cplusplus
402 }
403 #endif
404 #endif