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)(int widget_handle,
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 } wrt_widget_update_mode_t;
157 int wrt_installer_init(void *userdata,
158 WrtInstallerInitCallback callback);
161 * @fn void wrt_installer_shutdown(void)
162 * @brief Deinitializes WRT
164 * This method is used to deinitialize wrt-engine.
165 * It deinitializes widget logic, plugin logic, shuts down connection to
166 * database, switchs back to single thread and does deinit checks.
172 * int main (int argc, char *argv[])
174 * init_loop(argc, argv);
175 * printf("Initializing WRT");
176 * wrt_init(NULL, &init_cb);
178 * wait_for_wrt_init();
179 * printf("Starting tests");
181 * int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
184 * wrt_installer_shutdown();
192 void wrt_installer_shutdown(void);
195 * @fn void wrt_install_widget(const char *widget_package_path,
196 * void *user_parameter,
197 * WrtInstallerStatusCallback status_callback,
198 * WrtProgressCallback progress_callback,
199 * wrt_widget_update_mode_t update_mode);
201 * @brief Installs widget from given path
203 * This method is used to install widget from a given path.
205 * @param [in] widget_package_path Path of the widget package.
206 * @param [in] user_parameter User parameters to be passed to the callback
207 * @param [in] status_cb Call to this one will be done at the end of
209 * The callback is called in the context of the
211 * @param [in] progress_cb Callback function to get data of install
213 * If you don't want to get progress data, this
215 * @param [in] install_mode Installation mode
216 * @return Nothing (status returned in callback).
220 * wrt_install_widget(path.c_str(),
224 * WRT_WIM_POLICY_WAC);
227 * @see wrt_installer_uninstall_widget
229 void wrt_install_widget(const char *path,
230 void *user_parameter,
231 WrtInstallerStatusCallback status_callback,
232 WrtProgressCallback progress_callback,
233 wrt_widget_update_mode_t update_mode,
237 * @fn void wrt_installer_uninstall_widget (int widget_handle,
239 * WrtInstallerStatusCallback cb)
240 * @brief Uninstalls widget using its id
242 * This method is used to uninstall the widget specified by its handle.
243 * The callback function is called when the uninstall operation is done.
245 * @param [in] widget_handle - widget id
246 * @param [in] userdata - user parameters to be passed to the callback
247 * @param [in] status_cb - Call to this one will be done at the end of
249 * The callback is called in the context of the
251 * @param [in] progress_cb - Callback function to get data of install progress
252 * If you don't want to get progress data, this
255 * @return nothing (status returned in callback).
258 * @code //TODO SAMPLE
259 * wrt_installer_uninstall_widget( appId, NULL, uninstall_cb, progress_cb);
262 * @see wrt_installer_install_widget
264 void wrt_uninstall_widget (int widget_handle,
266 WrtInstallerStatusCallback status_cb,
267 WrtProgressCallback progress_cb);
270 * @fn void wrt_install_plugin(const char *pluginDirectory,
272 * WrtInstallerStatusCallback statusCallback,
273 * WrtProgressCallback progressCallback)
275 * @brief Installs plugin from given path
277 * This method installs new plugin from specified location and calls a callback
278 * function when the operation is done.
280 * @param [in] pluginDirectory - plugin directory
281 * @param [in] userData - user parameters to be passed to the callback
282 * @param [in] statusCallback - user callback to call after installation
283 * @param [in] progressCallback - user callback to call when plugin
284 * installation progress has changed
286 * @return nothing (status returned in callback).
290 * wrt_install_plugin("/usr/lib/wrt-plugins/",NULL,NULL,NULL);
293 * @see wrt_install_plugin
295 void wrt_install_plugin(const char *pluginDirectory,
297 WrtPluginInstallerStatusCallback statusCallback,
298 WrtProgressCallback progressCallback);
301 * @brief To install plugins for first excution
303 * This method install plugins
307 void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb,
311 * @brief To initialize for tests
313 * This method is wrt init for tests
317 int wrt_installer_init_for_tests(void *userdata,
318 WrtInstallerInitCallback callback);
321 * @brief To shutdown for tests
323 * This method is wrt shutdown for tests
327 void wrt_installer_shutdown_for_tests();
329 WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
332 WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
338 #endif /* WRT_INSTALLER_API_H_ */