2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file wrt_installer_api.h
18 * @author Chung Jihoon (jihoon.chung@samsung.com)
20 * @brief This file contains declarations of wrt_installer_api
24 * @defgroup wrt_engine_group WebRunTime engine Library
25 * @ingroup internet_FW
26 * Functions to APIs to access wrt-engine
29 #ifndef WRT_INSTALLER_API_H_
30 #define WRT_INSTALLER_API_H_
42 * Callback function type invoked after async init function
44 typedef void (*WrtInstallerInitCallback)(WrtErrStatus status,
48 * Callback function type invoked after async functions
50 typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status,
54 * Callback function type invoked after async functions
56 typedef void (*WrtInstallerStatusCallback)(std::string tizenId,
61 * Callback function type invoked after async functions
63 typedef void (*WrtProgressCallback)(float percent,
64 const char *description,
68 * Callback function type invoked when all plugin installations are finished
70 typedef void (*WrtAllPluginInstalledCallback)(void *userdata);
74 WrtAllPluginInstalledCallback plugin_installed_cb;
80 * @fn int wrt_installer_init(void *userdata, WrtInstallerInitCallback callback)
81 * @brief Initializes WRT
83 * This method is used to initialize wrt-engine.
84 * It connects to database, initializes webkit, widget and plugin logic.
86 * @param [in] userdata - User parameters to be passed to the callback
87 * @param [in] callback - The callback function that is launched, after
89 * The callback is called in the context of the
90 * application's main loop.
92 * @return 0 on success, -1 on failure
96 * int main (int argc, char *argv[])
98 * init_loop(argc, argv);
99 * printf("Initializing WRT");
100 * wrt_init(NULL, &init_cb);
102 * wait_for_wrt_init();
103 * printf("Starting tests");
105 * int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
108 * wrt_installer_shutdown();
114 * @see wrt_installer_shutdown
116 typedef enum wrt_widget_install_mode_e
119 * Raw install bit flags
121 WRT_WIM_NOT_INSTALLED = (1 << 0),
122 WRT_WIM_INCOMING_VERSION_NOT_STD = (1 << 1),
123 WRT_WIM_EXISTING_VERSION_NOT_STD = (1 << 2),
124 WRT_WIM_BOTH_VERSIONS_NOT_STD = (1 << 3),
125 WRT_WIM_EXISTING_VERSION_OLDER = (1 << 4),
126 WRT_WIM_EXISTING_VERSION_EQUAL = (1 << 5),
127 WRT_WIM_EXISTING_VERSION_NEWER = (1 << 6),
130 * Update default policies
133 /* Never update policy
135 WRT_WIM_POLICY_NEVER_UPDATE = WRT_WIM_NOT_INSTALLED,
139 WRT_WIM_POLICY_WAC = WRT_WIM_NOT_INSTALLED |
140 WRT_WIM_EXISTING_VERSION_OLDER,
142 /* Always update policy
144 WRT_WIM_POLICY_ALWAYS_INSTALL = WRT_WIM_NOT_INSTALLED |
145 WRT_WIM_INCOMING_VERSION_NOT_STD |
146 WRT_WIM_EXISTING_VERSION_NOT_STD |
147 WRT_WIM_BOTH_VERSIONS_NOT_STD |
148 WRT_WIM_EXISTING_VERSION_OLDER |
149 WRT_WIM_EXISTING_VERSION_EQUAL |
150 WRT_WIM_EXISTING_VERSION_NEWER,
152 /* Force install policy
154 WRT_WIM_POLICY_FORCE_INSTALL = WRT_WIM_POLICY_ALWAYS_INSTALL,
155 /* Installation from directory - forced update
157 WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL
158 } wrt_widget_update_mode_t;
160 int wrt_installer_init(void *userdata,
161 WrtInstallerInitCallback callback);
164 * @fn void wrt_installer_shutdown(void)
165 * @brief Deinitializes WRT
167 * This method is used to deinitialize wrt-engine.
168 * It deinitializes widget logic, plugin logic, shuts down connection to
169 * database, switchs back to single thread and does deinit checks.
175 * int main (int argc, char *argv[])
177 * init_loop(argc, argv);
178 * printf("Initializing WRT");
179 * wrt_init(NULL, &init_cb);
181 * wait_for_wrt_init();
182 * printf("Starting tests");
184 * int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
187 * wrt_installer_shutdown();
195 void wrt_installer_shutdown(void);
198 * @fn void wrt_install_widget(const char *widget_package_path,
199 * void *user_parameter,
200 * WrtInstallerStatusCallback status_callback,
201 * WrtProgressCallback progress_callback,
202 * wrt_widget_update_mode_t update_mode,
206 * @brief Installs widget from given path
208 * This method is used to install widget from a given path.
210 * @param [in] widget_package_path Path of the widget package.
211 * @param [in] user_parameter User parameters to be passed to the callback
212 * @param [in] status_cb Call to this one will be done at the end of
214 * The callback is called in the context of the
216 * @param [in] progress_cb Callback function to get data of install
218 * If you don't want to get progress data, this
220 * @param [in] install_mode Installation mode
221 * @param [in] quiet quiet mode
222 * @param [in] preload preload widget install
223 * @return Nothing (status returned in callback).
227 * wrt_install_widget(path.c_str(),
231 * WRT_WIM_POLICY_WAC,
236 * @see wrt_installer_uninstall_widget
238 void wrt_install_widget(const char *path,
239 void *user_parameter,
240 WrtInstallerStatusCallback status_callback,
241 WrtProgressCallback progress_callback,
242 wrt_widget_update_mode_t update_mode,
247 * @fn void wrt_installer_uninstall_widget (const char * const pkg_name,
249 * WrtInstallerStatusCallback cb)
250 * @brief Uninstalls widget using its name
252 * This method is used to uninstall the widget specified by its pkgname.
253 * The callback function is called when the uninstall operation is done.
255 * @param [in] pkg_name - package name
256 * @param [in] userdata - user parameters to be passed to the callback
257 * @param [in] status_cb - Call to this one will be done at the end of
259 * The callback is called in the context of the
261 * @param [in] progress_cb - Callback function to get data of install progress
262 * If you don't want to get progress data, this
265 * @return nothing (status returned in callback).
268 * @code //TODO SAMPLE
269 * wrt_installer_uninstall_widget( appId, NULL, uninstall_cb, progress_cb);
272 * @see wrt_installer_install_widget
274 void wrt_uninstall_widget (const char * const pkg_name,
276 WrtInstallerStatusCallback status_cb,
277 WrtProgressCallback progress_cb);
280 * @fn void wrt_install_plugin(const char *pluginDirectory,
282 * WrtInstallerStatusCallback statusCallback,
283 * WrtProgressCallback progressCallback)
285 * @brief Installs plugin from given path
287 * This method installs new plugin from specified location and calls a callback
288 * function when the operation is done.
290 * @param [in] pluginDirectory - plugin directory
291 * @param [in] userData - user parameters to be passed to the callback
292 * @param [in] statusCallback - user callback to call after installation
293 * @param [in] progressCallback - user callback to call when plugin
294 * installation progress has changed
296 * @return nothing (status returned in callback).
300 * wrt_install_plugin("/usr/lib/wrt-plugins/",NULL,NULL,NULL);
303 * @see wrt_install_plugin
305 void wrt_install_plugin(const char *pluginDirectory,
307 WrtPluginInstallerStatusCallback statusCallback,
308 WrtProgressCallback progressCallback);
311 * @brief To install plugins for first excution
313 * This method install plugins
317 void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb,
321 * @brief To initialize for tests
323 * This method is wrt init for tests
327 int wrt_installer_init_for_tests(void *userdata,
328 WrtInstallerInitCallback callback);
331 * @brief To shutdown for tests
333 * This method is wrt shutdown for tests
337 void wrt_installer_shutdown_for_tests();
340 * @brief wrt_get_widget_by_guid Returns pkgname by pkg guid (widgetId)
341 * @param pkgname pkgname argument ot be set
342 * @param guid guid that we look for
345 WrtErrStatus wrt_get_widget_by_guid(std::string &pkgname, const std::string guid);
350 #endif /* WRT_INSTALLER_API_H_ */