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_
36 #include <pkgmgr_signal_interface.h>
44 * Callback function type invoked after async init function
46 typedef void (*WrtInstallerInitCallback)(WrtErrStatus status,
50 * Callback function type invoked after async functions
52 typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status,
56 * Callback function type invoked after async functions
58 typedef void (*WrtInstallerStatusCallback)(std::string tizenId,
63 * Callback function type invoked after async functions
65 typedef void (*WrtProgressCallback)(float percent,
66 const char *description,
70 * Callback function type invoked when all plugin installations are finished
72 typedef void (*WrtAllPluginInstalledCallback)(void *userdata);
76 WrtAllPluginInstalledCallback plugin_installed_cb;
82 * @fn int wrt_installer_init(void *userdata, WrtInstallerInitCallback callback)
83 * @brief Initializes WRT
85 * This method is used to initialize wrt-engine.
86 * It connects to database, initializes webkit, widget and plugin logic.
88 * @param [in] userdata - User parameters to be passed to the callback
89 * @param [in] callback - The callback function that is launched, after
91 * The callback is called in the context of the
92 * application's main loop.
94 * @return 0 on success, -1 on failure
98 * int main (int argc, char *argv[])
100 * init_loop(argc, argv);
101 * printf("Initializing WRT");
102 * wrt_init(NULL, &init_cb);
104 * wait_for_wrt_init();
105 * printf("Starting tests");
107 * int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
110 * wrt_installer_shutdown();
116 * @see wrt_installer_shutdown
118 typedef enum wrt_widget_install_mode_e
121 * Raw install bit flags
123 WRT_WIM_NOT_INSTALLED = (1 << 0),
124 WRT_WIM_INCOMING_VERSION_NOT_STD = (1 << 1),
125 WRT_WIM_EXISTING_VERSION_NOT_STD = (1 << 2),
126 WRT_WIM_BOTH_VERSIONS_NOT_STD = (1 << 3),
127 WRT_WIM_EXISTING_VERSION_OLDER = (1 << 4),
128 WRT_WIM_EXISTING_VERSION_EQUAL = (1 << 5),
129 WRT_WIM_EXISTING_VERSION_NEWER = (1 << 6),
132 * Update default policies
135 /* Never update policy
137 WRT_WIM_POLICY_NEVER_UPDATE = WRT_WIM_NOT_INSTALLED,
141 WRT_WIM_POLICY_WAC = WRT_WIM_NOT_INSTALLED |
142 WRT_WIM_EXISTING_VERSION_OLDER,
144 /* Always update policy
146 WRT_WIM_POLICY_ALWAYS_INSTALL = WRT_WIM_NOT_INSTALLED |
147 WRT_WIM_INCOMING_VERSION_NOT_STD |
148 WRT_WIM_EXISTING_VERSION_NOT_STD |
149 WRT_WIM_BOTH_VERSIONS_NOT_STD |
150 WRT_WIM_EXISTING_VERSION_OLDER |
151 WRT_WIM_EXISTING_VERSION_EQUAL |
152 WRT_WIM_EXISTING_VERSION_NEWER,
154 /* Force install policy
156 WRT_WIM_POLICY_FORCE_INSTALL = WRT_WIM_POLICY_ALWAYS_INSTALL,
157 /* Installation from directory - forced update
159 WRT_WIM_POLICY_DIRECTORY_FORCE_INSTALL
160 } wrt_widget_update_mode_t;
162 int wrt_installer_init(void *userdata,
163 WrtInstallerInitCallback callback);
166 * @fn void wrt_installer_shutdown(void)
167 * @brief Deinitializes WRT
169 * This method is used to deinitialize wrt-engine.
170 * It deinitializes widget logic, plugin logic, shuts down connection to
171 * database, switchs back to single thread and does deinit checks.
177 * int main (int argc, char *argv[])
179 * init_loop(argc, argv);
180 * printf("Initializing WRT");
181 * wrt_init(NULL, &init_cb);
183 * wait_for_wrt_init();
184 * printf("Starting tests");
186 * int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
189 * wrt_installer_shutdown();
197 void wrt_installer_shutdown(void);
200 * @fn void wrt_install_widget(const char *widget_package_path,
201 * void *user_parameter,
202 * WrtInstallerStatusCallback status_callback,
203 * WrtProgressCallback progress_callback,
204 * wrt_widget_update_mode_t update_mode,
208 * @brief Installs widget from given path
210 * This method is used to install widget from a given path.
212 * @param [in] widget_package_path Path of the widget package.
213 * @param [in] user_parameter User parameters to be passed to the callback
214 * @param [in] status_cb Call to this one will be done at the end of
216 * The callback is called in the context of the
218 * @param [in] progress_cb Callback function to get data of install
220 * If you don't want to get progress data, this
222 * @param [in] install_mode Installation mode
223 * @param [in] quiet quiet mode
224 * @param [in] preload preload widget install
225 * @return Nothing (status returned in callback).
229 * wrt_install_widget(path.c_str(),
233 * WRT_WIM_POLICY_WAC,
238 * @see wrt_installer_uninstall_widget
240 void wrt_install_widget(const char *path,
241 void *user_parameter,
242 WrtInstallerStatusCallback status_callback,
243 WrtProgressCallback progress_callback,
244 wrt_widget_update_mode_t update_mode,
247 std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrInterface
251 * @fn void wrt_installer_uninstall_widget (const char * const tizenAppid,
253 * WrtInstallerStatusCallback cb)
254 * @brief Uninstalls widget using its name
256 * This method is used to uninstall the widget specified by its appid.
257 * The callback function is called when the uninstall operation is done.
259 * @param [in] tzAppid - tizen appid
260 * @param [in] userdata - user parameters to be passed to the callback
261 * @param [in] status_cb - Call to this one will be done at the end of
263 * The callback is called in the context of the
265 * @param [in] progress_cb - Callback function to get data of install progress
266 * If you don't want to get progress data, this
269 * @return nothing (status returned in callback).
272 * @code //TODO SAMPLE
273 * wrt_installer_uninstall_widget( appId, NULL, uninstall_cb, progress_cb);
276 * @see wrt_installer_install_widget
278 void wrt_uninstall_widget (const char * const tzAppid,
280 WrtInstallerStatusCallback status_cb,
281 WrtProgressCallback progress_cb,
282 std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface);
285 * @fn void wrt_install_plugin(const char *pluginDirectory,
287 * WrtInstallerStatusCallback statusCallback,
288 * WrtProgressCallback progressCallback)
290 * @brief Installs plugin from given path
292 * This method installs new plugin from specified location and calls a callback
293 * function when the operation is done.
295 * @param [in] pluginDirectory - plugin directory
296 * @param [in] userData - user parameters to be passed to the callback
297 * @param [in] statusCallback - user callback to call after installation
298 * @param [in] progressCallback - user callback to call when plugin
299 * installation progress has changed
301 * @return nothing (status returned in callback).
305 * wrt_install_plugin("/usr/lib/wrt-plugins/",NULL,NULL,NULL);
308 * @see wrt_install_plugin
310 void wrt_install_plugin(const char *pluginDirectory,
312 WrtPluginInstallerStatusCallback statusCallback,
313 WrtProgressCallback progressCallback);
316 * @brief To install plugins for first excution
318 * This method install plugins
322 void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb,
326 * @brief To initialize for tests
328 * This method is wrt init for tests
332 int wrt_installer_init_for_tests(void *userdata,
333 WrtInstallerInitCallback callback);
336 * @brief To shutdown for tests
338 * This method is wrt shutdown for tests
342 void wrt_installer_shutdown_for_tests();
345 * @brief wrt_get_widget_by_guid Returns tizenAppid by pkg guid (widgetId)
346 * @param tzAppid tizen appid argument ot be set
347 * @param guid guid that we look for
350 WrtErrStatus wrt_get_widget_by_guid(std::string &tzAppid, const std::string guid);
355 #endif /* WRT_INSTALLER_API_H_ */