Update wrt-installer_0.0.51
[framework/web/wrt-installer.git] / src / wrt-installer / wrt_type.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  * @file        wrt_type.h
18  * @author      jihoon Chung (jihoon.Chung@samsung.com)
19  * @version     1.0
20  * @brief       This file contains declarations of wrt api
21  */
22
23 /*
24  * @defgroup wrt_engine_group WebRunTime engine Library
25  * @ingroup internet_FW
26  * Functions to APIs to access wrt-engine
27  */
28
29 #ifndef WRT_TYPE_H_
30 #define WRT_TYPE_H_
31
32 #include <stdbool.h>
33 #include <stddef.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #define WRT_DEPRECATED __attribute__((deprecated))
40
41 typedef enum
42 {
43     /* Generic success */
44     WRT_SUCCESS = 0,                /*< Success*/
45     WRT_ALREADY_INIT,               /*< Wrt already initialized*/
46     WRT_UPDATE_NEED,                /*< Widget data has been updated*/
47     WRT_SHUTDOWN,                   /*<WRT daemon has been closed*/
48
49     /* Version result */
50     WRT_VERSION_OLD = 128,          /*< widget's version is older*/
51     WRT_VERSION_NEW,                /*< widget's version is latest*/
52     WRT_VERSION_EXACT,              /*< widget's version the same as in arg*/
53     WRT_VERSION_NOT_COMPARABLE,     /*< widget's version are not comparable */
54
55     /* Error result */
56     WRT_ERROR_INTERNAL = -128,      /*< Internal library error.
57                                        Should never occur */
58     WRT_ERROR_INVALID_PARAMETER,    /*< Invalid parameter value was given
59                                        (eg. NULL) */
60     WRT_ERROR_HANDLE_NOT_FOUND,     /*< Widget handle was not found */
61     WRT_ERROR_ID_NOT_FOUND,         /*< Widget id was not found */
62     WRT_ERROR_PKGNAME_NOT_FOUND,    /*< package name was not found */
63     WRT_ERROR_ALREADY_RUNNING,      /*< Widget is already running */
64     WRT_ERROR_ALREADY_STOPPED,      /*< Widget is already stopped */
65     WRT_ERROR_STILL_AUTHORIZING,    /*< Widget is still autorizing and has not
66                                        yet finished it */
67     WRT_ERROR_EARLY_KILLED,         /*< Widget was early killed during launch */
68     WRT_ERROR_ACCESS_DENIED,        /*< Access denied from ACE */
69     WRT_ERROR_NOT_INITIALIZED,      /*<Occur if wrt initialization fails*/
70     WRT_ERROR_INIT,                 /*<Occur if wrt initialization fails*/
71     WRT_ERROR_CONNECTION,           /*<Connectiond error occured*/
72     WRT_ERROR_NO_PATH,              /*<One of specific directory does not
73                                        exist*/
74
75     /* Installer Errors*/
76     WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE, /*<  */
77     WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST,  /*<  */
78     WRT_INSTALLER_ERROR_FACTORY_WIDGET,         /*< Widget is factory installed,
79                                                    and cannot be uninstalled */
80     WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING,   /*< Widget is already being
81                                                    uninstalled */
82     WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE,     /*<  */
83     WRT_INSTALLER_ERROR_INVALID_CERTIFICATE,    /*<  */
84     WRT_INSTALLER_ERROR_ALREADY_INSTALLED,      /*< Widget is already installed
85                                                  */
86     WRT_INSTALLER_ERROR_INTERNAL,               /*<  */
87     WRT_INSTALLER_ERROR_NOT_ALLOWED,            /*< Widget installation or
88                                                    update not allowed */
89                                                 /*< because violation of policy
90                                                    ocurred */
91     WRT_INSTALLER_ERROR_DEFERRED,               /*< Widget installation deferred
92                                                  */
93     WRT_INSTALLER_ERROR_DATABASE_FAILURE,       /*< Failure in database */
94     WRT_INSTALLER_ERROR_UNKNOWN,                /*< Temporary error. Try to not
95                                                    use this. */
96     WRT_INSTALLER_ERROR_OSPSVC,                 /*< */
97     WRT_ERROR_INVALID_LANGUAGE,                 /*< Widget is not valid in
98                                                     current locales*/
99
100     /* Plugin Installer Errors */
101     WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH,       /*< Wrong Path to plugin Dir */
102     WRT_PLUGIN_INSTALLER_ERROR_METAFILE,         /*< Plugin metafile error */
103     WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED, /*< Plugin already installed*/
104     WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR,    /*< Shared library error*/
105     WRT_PLUGIN_INSTALLER_ERROR_WAITING,          /*< Missing dependencies*/
106     WRT_PLUGIN_INSTALLER_ERROR_LOCK,             /*< Another installation
107                                                      in progress or lock file
108                                                      error*/
109     WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN           /*< Unknown error*/
110 } WrtErrStatus;
111
112 typedef struct
113 {
114     char* id;           /**< the widget's id
115                            (read from its config.xml during installation)*/
116     char* name;         /**< the widget's name
117                            (read from its config.xml during installation)*/
118     char* version;      /**< the widget's varsion
119                            (read from its config.xml during installation)*/
120     char* icon_path;    /**< the widget's icon_path
121                            (read from its config.xml during installation)*/
122     char* pkg_name;     /**< the widget's pkg name */
123
124     /**< the widget's application storage size */
125     size_t application_size;
126     /**< the widget's data storage size */
127     size_t data_size;
128 } wrt_widget_info;
129
130 typedef struct
131 {
132     char *src; /**< valid path to widget's icon*/
133     int width;  /**< the width of the icon in pixels*/
134     int height;  /**< the height of the icon in pixels*/
135 } wrt_widget_icon;
136
137 typedef struct
138 {
139     int width;      /**< the width of the widget in pixels*/
140     int height;     /**< the height of the widget in pixels*/
141 } wrt_widget_size;
142
143 typedef struct
144 {
145     char *widget_name;              /**< the widget's name*/
146     wrt_widget_icon *widget_icon;   /**< the widget's icon data*/
147     wrt_widget_size widget_size;    /**< the widget's size data*/
148     wrt_widget_info *widget_info;   /**< the widget's info data*/
149 } wrt_widget_info_data;
150
151
152 /**
153  * @fn inline bool wrt_has_succeded(WrtErrStatus err)
154  * @brief Checks whether call succeded
155  *
156  * This function checks whether call succeded.
157  * If call succeded it returns TRUE.
158  *
159  * @param [in] err WrtErrStatus to check
160  *
161  * @return Result of the test
162  * @retval TRUE     - the call was successful
163  * @retval FALSE    - the call failed
164  *
165  * Sample code:
166  * @code
167  *      static void InitCallback(WrtErrStatus status, void *data)
168  *      {
169  *          MyApplication *This = (MyApplication *)(data);
170  *
171  *          printf("[LAUNCH-WIDGET] init callback");
172  *
173  *          if (wrt_has_succeded(status) && status!=WRT_UPDATE_NEED)
174  *          {
175  *             This->InstallAllPlugins();
176  *
177  *             if (This->m_argc == 2)
178  *                 wrt_install_widget(This->m_argv[1], This, InstallCallback);
179  *          }
180  *          else if(wrt_has_failed(status))
181  *              printf("[LAUNCH-WIDGET] INITIALIZATION HAS FAILED");
182  *      }
183  * @endcode
184  *
185  * @see wrt_has_failed
186  */
187 inline bool wrt_has_succeded(WrtErrStatus err)
188 {
189     return (err >= 0);
190 }
191
192 /**
193  * @fn inline bool wrt_has_failed(WrtErrStatus err)
194  * @brief Checks whether call failed
195  *
196  * This function checks whether call failed.
197  * If call failed it returns TRUE.
198  *
199  * @param [in] err WrtErrStatus to check
200  *
201  * @return Result of the test
202  * @retval TRUE     - the call failed
203  * @retval FALSE    - the call was successful
204  *
205  * Sample code:
206  * @code
207  *      static void InitCallback(WrtErrStatus status, void *data)
208  *      {
209  *          MyApplication *This = (MyApplication *)(data);
210  *
211  *          printf("[LAUNCH-WIDGET] init callback");
212  *
213  *          if (wrt_has_succeded(status) && status!=WRT_UPDATE_NEED)
214  *          {
215  *             This->InstallAllPlugins();
216  *
217  *             if (This->m_argc == 2)
218  *                 wrt_install_widget(This->m_argv[1], This, InstallCallback);
219  *          }
220  *          else if(wrt_has_failed(status))
221  *              printf("[LAUNCH-WIDGET] INITIALIZATION HAS FAILED");
222  *      }
223  * @endcode
224  *
225  * @see wrt_has_succeded
226  */
227 inline bool wrt_has_failed(WrtErrStatus err)
228 {
229     return (err < 0);
230 }
231
232 namespace CommonError {
233 enum Type
234 {
235     WrtSuccess,                ///< Success
236
237     HandleNotFound,         ///< Widget handle was not found
238     AlreadyRunning,         ///< Widget is already running
239     AlreadyStopped,         ///< Widget is already stopped
240     InvalidLanguage,        ///< Widget is invalid in current locales
241     StillAuthorizing,       ///< Widget is still autorizing and has not yet finished it
242     EarlyKilled,            ///< Widget was early killed during launch
243     AccessDenied,           ///< Access denied from ACE
244     CertificateRevoked,     ///< Some certificate was revoked.
245                             ///  Widget is not allowed to run.
246
247     Unknown                 ///< Temporary error. Try to not use this.
248 };
249 }
250
251 #ifdef __cplusplus
252 }
253 #endif
254
255 #endif /* WRT_TYPE_H_ */