arkweb_sys/native_interface_arkweb/native_interface_arkweb_ffi.rs
1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6#[cfg(feature = "api-20")]
7use crate::arkweb_error_code::ArkWeb_BlanklessErrorCode;
8#[cfg(feature = "api-15")]
9use crate::arkweb_error_code::ArkWeb_ErrorCode;
10#[cfg(feature = "api-20")]
11use crate::arkweb_type::ArkWeb_ProxyObjectWithResult;
12
13/// Defines the javascript callback of the web component.
14///
15///
16/// Available since API-level: 11
17#[cfg(feature = "api-11")]
18#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
19pub type NativeArkWeb_OnJavaScriptCallback =
20 ::core::option::Option<unsafe extern "C" fn(arg1: *const ::core::ffi::c_char)>;
21/// Defines the javascript proxy callback of the web component.
22///
23///
24/// Available since API-level: 11
25#[cfg(feature = "api-11")]
26#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
27pub type NativeArkWeb_OnJavaScriptProxyCallback = ::core::option::Option<
28 unsafe extern "C" fn(
29 argv: *mut *const ::core::ffi::c_char,
30 argc: i32,
31 ) -> *mut ::core::ffi::c_char,
32>;
33/// Defines the valid callback of the web component.
34///
35///
36/// Available since API-level: 11
37#[cfg(feature = "api-11")]
38#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
39pub type NativeArkWeb_OnValidCallback =
40 ::core::option::Option<unsafe extern "C" fn(arg1: *const ::core::ffi::c_char)>;
41/// Defines the destroy callback of the web component.
42///
43///
44/// Available since API-level: 11
45#[cfg(feature = "api-11")]
46#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
47pub type NativeArkWeb_OnDestroyCallback =
48 ::core::option::Option<unsafe extern "C" fn(arg1: *const ::core::ffi::c_char)>;
49/// Defines the callback of save cookie.
50/// # Arguments
51///
52/// * `errorCode` - [`ARKWEB_SUCCESS`] Save cookie success.
53/// [`ARKWEB_COOKIE_MANAGER_INITIALIZE_FAILED`] Cookie manager initialize failed.
54/// [`ARKWEB_COOKIE_SAVE_FAILED`] Save cookie failed.
55///
56/// Available since API-level: 20
57#[cfg(feature = "api-20")]
58#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
59pub type OH_ArkWeb_OnCookieSaveCallback =
60 ::core::option::Option<unsafe extern "C" fn(errorCode: ArkWeb_ErrorCode)>;
61/// Defines the blankless information.
62///
63///
64/// Available since API-level: 20
65#[cfg(feature = "api-20")]
66#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
67#[repr(C)]
68pub struct ArkWeb_BlanklessInfo {
69 /// The errCode of the blankless.
70 pub errCode: ArkWeb_BlanklessErrorCode,
71 /// The estimated similarity of the history snapshots.
72 pub similarity: f64,
73 /// The loadingTime of the history loading.
74 pub loadingTime: i32,
75}
76#[cfg(feature = "api-20")]
77#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
78impl ArkWebEngineVersion {
79 /// the system default ArkWeb engine.
80 ///
81 /// Available since API-level: 20
82 #[cfg(feature = "api-20")]
83 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
84 pub const SYSTEM_DEFAULT: ArkWebEngineVersion = ArkWebEngineVersion(0);
85 /// ArkWeb M114 version.
86 ///
87 /// Available since API-level: 20
88 #[cfg(feature = "api-20")]
89 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
90 pub const ARKWEB_M114: ArkWebEngineVersion = ArkWebEngineVersion(1);
91 /// ArkWeb M132 version.
92 ///
93 /// Available since API-level: 20
94 #[cfg(feature = "api-20")]
95 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
96 pub const ARKWEB_M132: ArkWebEngineVersion = ArkWebEngineVersion(2);
97}
98#[repr(transparent)]
99/// ArkWeb Engine Version.
100///
101/// <strong>ArkWeb Dual Web Engine Versioning Convention</strong>:
102/// <p>See [ArkWeb Dual Web Engine Versioning Convention] for switching between Legacy and Evergreen Web Engine.
103///
104///
105/// Available since API-level: 20
106#[cfg(feature = "api-20")]
107#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
108#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
109pub struct ArkWebEngineVersion(pub ::core::ffi::c_uint);
110extern "C" {
111 /// Loads a piece of code and execute JS code in the context of the currently displayed page.
112 ///
113 /// # Arguments
114 ///
115 /// * `webTag` - The name of the web component.
116 ///
117 /// * `jsCode` - a piece of javascript code.
118 ///
119 /// * `callback` - Callbacks execute JavaScript script results.
120 ///
121 ///
122 /// Required System Capabilities: SystemCapability.Web.Webview.Core
123 ///
124 /// Available since API-level: 11
125 #[cfg(feature = "api-11")]
126 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
127 pub fn OH_NativeArkWeb_RunJavaScript(
128 webTag: *const ::core::ffi::c_char,
129 jsCode: *const ::core::ffi::c_char,
130 callback: NativeArkWeb_OnJavaScriptCallback,
131 );
132 /// Registers the JavaScript object and method list.
133 ///
134 /// # Arguments
135 ///
136 /// * `webTag` - The name of the web component.
137 ///
138 /// * `objName` - The name of the registered object.
139 ///
140 /// * `methodList` - The method of the application side JavaScript object participating in the registration.
141 ///
142 /// * `callback` - The callback function registered by developer is called back when HTML side uses.
143 ///
144 /// * `size` - The size of the callback.
145 ///
146 /// * `needRefresh` - if web need refresh.
147 ///
148 ///
149 /// Required System Capabilities: SystemCapability.Web.Webview.Core
150 ///
151 /// Available since API-level: 11
152 #[cfg(feature = "api-11")]
153 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
154 pub fn OH_NativeArkWeb_RegisterJavaScriptProxy(
155 webTag: *const ::core::ffi::c_char,
156 objName: *const ::core::ffi::c_char,
157 methodList: *mut *const ::core::ffi::c_char,
158 callback: *mut NativeArkWeb_OnJavaScriptProxyCallback,
159 size: i32,
160 needRefresh: bool,
161 );
162 /// Deletes the registered object which th given name.
163 ///
164 /// # Arguments
165 ///
166 /// * `webTag` - The name of the web component.
167 ///
168 /// * `objName` - The name of the registered object.
169 ///
170 ///
171 /// Required System Capabilities: SystemCapability.Web.Webview.Core
172 ///
173 /// Available since API-level: 11
174 #[cfg(feature = "api-11")]
175 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
176 pub fn OH_NativeArkWeb_UnregisterJavaScriptProxy(
177 webTag: *const ::core::ffi::c_char,
178 objName: *const ::core::ffi::c_char,
179 );
180 /// Registers the valid callback.
181 ///
182 /// # Arguments
183 ///
184 /// * `webTag` - The name of the web component.
185 ///
186 /// * `callback` - The callback in which we can register object.
187 ///
188 ///
189 /// Required System Capabilities: SystemCapability.Web.Webview.Core
190 ///
191 /// Available since API-level: 11
192 #[cfg(feature = "api-11")]
193 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
194 pub fn OH_NativeArkWeb_SetJavaScriptProxyValidCallback(
195 webTag: *const ::core::ffi::c_char,
196 callback: NativeArkWeb_OnValidCallback,
197 );
198 /// Get the valid callback.
199 ///
200 /// # Arguments
201 ///
202 /// * `webTag` - The name of the web component.
203 ///
204 /// # Returns
205 ///
206 /// * Return the valid callback function registered. If the valid callback function
207 /// specified by the parameter webTag is not set, a null pointer is returned.
208 ///
209 ///
210 /// Required System Capabilities: SystemCapability.Web.Webview.Core
211 ///
212 /// Available since API-level: 11
213 #[cfg(feature = "api-11")]
214 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
215 pub fn OH_NativeArkWeb_GetJavaScriptProxyValidCallback(
216 webTag: *const ::core::ffi::c_char,
217 ) -> NativeArkWeb_OnValidCallback;
218 /// Registers the destroy callback.
219 ///
220 /// # Arguments
221 ///
222 /// * `webTag` - The name of the web component.
223 ///
224 /// * `callback` - the destroy callback.
225 ///
226 ///
227 /// Required System Capabilities: SystemCapability.Web.Webview.Core
228 ///
229 /// Available since API-level: 11
230 #[cfg(feature = "api-11")]
231 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
232 pub fn OH_NativeArkWeb_SetDestroyCallback(
233 webTag: *const ::core::ffi::c_char,
234 callback: NativeArkWeb_OnDestroyCallback,
235 );
236 /// Get the destroy callback.
237 ///
238 /// # Arguments
239 ///
240 /// * `webTag` - The name of the web component.
241 ///
242 /// # Returns
243 ///
244 /// * Return the destroy callback function registered. If the destroy callback
245 /// function specified by the parameter webTag is not set,
246 /// a null pointer is returned.
247 ///
248 ///
249 /// Required System Capabilities: SystemCapability.Web.Webview.Core
250 ///
251 /// Available since API-level: 11
252 #[cfg(feature = "api-11")]
253 #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
254 pub fn OH_NativeArkWeb_GetDestroyCallback(
255 webTag: *const ::core::ffi::c_char,
256 ) -> NativeArkWeb_OnDestroyCallback;
257 /// Loads the data or URL.
258 /// This function should be called on main thread.
259 ///
260 /// # Arguments
261 ///
262 /// * `webTag` - The name of the web component.
263 ///
264 /// * `data` - A string encoded according to "Base64" or "URL", should not be NULL.
265 ///
266 /// * `mimeType` - Media type. For example: "text/html", should not be NULL.
267 ///
268 /// * `encoding` - Encoding type. For example: "UTF-8", should not be NULL.
269 ///
270 /// * `baseUrl` - A specified URL path ("http"/"https"/"data" protocol),
271 /// which is assigned to window.origin by the Web component.
272 ///
273 /// * `historyUrl` - History URL. When it is not empty, it can be managed by
274 /// history records to realize the back and forth function.
275 ///
276 /// # Returns
277 ///
278 /// * LoadData result code.
279 /// [`ARKWEB_SUCCESS`] load data success.
280 /// [`ARKWEB_INVALID_PARAM`] Mandatory parameters are left unspecified or
281 /// Incorrect parameter types or Parameter verification failed.
282 /// [`ARKWEB_INIT_ERROR`] Initialization error, can't get a valid Web for the webTag.
283 /// [`ARKWEB_LIBRARY_OPEN_FAILURE`] Failed to open the library.
284 /// [`ARKWEB_LIBRARY_SYMBOL_NOT_FOUND`] The required symbol was not found in the library.
285 ///
286 ///
287 /// Required System Capabilities: SystemCapability.Web.Webview.Core
288 ///
289 /// Available since API-level: 15
290 #[cfg(feature = "api-15")]
291 #[cfg_attr(docsrs, doc(cfg(feature = "api-15")))]
292 pub fn OH_NativeArkWeb_LoadData(
293 webTag: *const ::core::ffi::c_char,
294 data: *const ::core::ffi::c_char,
295 mimeType: *const ::core::ffi::c_char,
296 encoding: *const ::core::ffi::c_char,
297 baseUrl: *const ::core::ffi::c_char,
298 historyUrl: *const ::core::ffi::c_char,
299 ) -> ArkWeb_ErrorCode;
300 /// Registers a JavaScript object with callback methods, which may return values. This object will be injected
301 /// into all frames of the current page, including all iframes, and will be accessible using the specified
302 /// name in ArkWeb_ProxyObjectWithResult. The object will only be available in JavaScript after the next
303 /// load or reload.
304 /// These methods will be executed in the ArkWeb worker thread.
305 ///
306 /// # Arguments
307 ///
308 /// * `webTag` - Name of the web component.
309 ///
310 /// * `proxyObject` - JavaScript object to register, the object has callback functions with return value.
311 ///
312 /// * `permission` - Optional JSON string(default is null) for JSBridge permission control,
313 /// allowing URL whitelist configuration at object-level and method-level.
314 ///
315 /// Required System Capabilities: SystemCapability.Web.Webview.Core
316 ///
317 /// Available since API-level: 20
318 #[cfg(feature = "api-20")]
319 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
320 pub fn OH_NativeArkWeb_RegisterAsyncThreadJavaScriptProxy(
321 webTag: *const ::core::ffi::c_char,
322 proxyObject: *const ArkWeb_ProxyObjectWithResult,
323 permission: *const ::core::ffi::c_char,
324 );
325 /// Sets whether to enable blankless page loading. This API must be used in pair with the
326 /// OH_NativeArkWeb_GetBlanklessInfoWithKey API.
327 ///
328 /// # Arguments
329 ///
330 /// * `webTag` - webTag used when the webviewController is created.
331 ///
332 /// * `key` - Key value that uniquely identifies the current page. It must be the same as the key value of the
333 /// OH_NativeArkWeb_GetBlanklessInfoWithKey API.
334 ///
335 /// * `isStarted` - Whether to enable frame interpolation. The value true indicates to enable frame
336 /// interpolation, and the value false indicates the opposite.
337 /// The default value is false.
338 /// The value can be true or false.
339 /// Action for setting an invalid value: N/A.
340 ///
341 /// # Returns
342 ///
343 /// * Whether the API is successfully called. For details, see ArkWeb_BlanklessErrorCode.
344 ///
345 /// Available since API-level: 20
346 #[cfg(feature = "api-20")]
347 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
348 pub fn OH_NativeArkWeb_SetBlanklessLoadingWithKey(
349 webTag: *const ::core::ffi::c_char,
350 key: *const ::core::ffi::c_char,
351 isStarted: bool,
352 ) -> ArkWeb_BlanklessErrorCode;
353 /// Clears the blankless loading cache of the page with a specified key value.
354 ///
355 /// # Arguments
356 ///
357 /// * `key` - The list of key values of pages cached in the blankless loading solution. These key values are
358 /// specified in OH_NativeArkWeb_GetBlanklessInfoWithKey.
359 /// The default value is the list of key values of all pages cached in the blankless loading solution.
360 /// The key length cannot exceed 2048 characters, and the number of keys must be less than or equal to 100. The
361 /// URL is the same as that input to the Web component during page loading.
362 /// When the key length exceeds 2048 characters, the key does not take effect. When the number of keys exceeds
363 /// 100, the first 100 keys are used. If this parameter is set to NULL, the default value is used.
364 ///
365 /// * `size` - Size of the key list.
366 ///
367 /// Available since API-level: 20
368 #[cfg(feature = "api-20")]
369 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
370 pub fn OH_NativeArkWeb_ClearBlanklessLoadingCache(
371 key: *mut *const ::core::ffi::c_char,
372 size: u32,
373 );
374 /// Obtains the prediction information about the blankless loading solution and enables the generation
375 /// of the transition frame for the current loading. The application determines whether to enable the blankless
376 /// loading solution based on the information.
377 /// This API applies to pages in an applet or web application whose URLs are not fixed or cannot be uniquely
378 /// identified.
379 ///
380 /// # Arguments
381 ///
382 /// * `webTag` - webTag used when the webviewController is created.
383 /// Default value: N/A.
384 /// The value cannot be empty.
385 /// When an invalid value is set, the error code is returned, and the API does not take effect.
386 ///
387 /// * `key` - Key value that uniquely identifies the current page.
388 ///
389 /// # Returns
390 ///
391 /// * Return value of the ArkWeb_BlanklessInfo type.
392 ///
393 /// Available since API-level: 20
394 #[cfg(feature = "api-20")]
395 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
396 pub fn OH_NativeArkWeb_GetBlanklessInfoWithKey(
397 webTag: *const ::core::ffi::c_char,
398 key: *const ::core::ffi::c_char,
399 ) -> ArkWeb_BlanklessInfo;
400 /// Sets the cache capacity of the blankless loading solution and returns the value that takes effect.
401 ///
402 /// # Arguments
403 ///
404 /// * `capacity` - Cache capacity, in MB. The maximum value is 100 MB.
405 /// The default value is 30 MB.
406 /// The value ranges from 0 to 100. If this parameter is set to 0, no cache capacity is available and the
407 /// functionality is disabled globally.
408 /// When the value is set to a number smaller than 0, the value 0 takes effect. When the value is set to a
409 /// number greater than 100, the value 100 takes effect.
410 ///
411 /// # Returns
412 ///
413 /// * The effective value that ranges from 0 MB to 100 MB.
414 ///
415 /// Available since API-level: 20
416 #[cfg(feature = "api-20")]
417 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
418 pub fn OH_NativeArkWeb_SetBlanklessLoadingCacheCapacity(capacity: u32) -> u32;
419 /// Ensure that all cookies currently accessible via the CookieManager API have been persisted to disk.
420 /// If you want to use this interface in a non-UI thread, you need to initialize the CookieManager interface
421 /// using OH_ArkWeb_GetNativeAPI first.
422 ///
423 /// # Returns
424 ///
425 /// * Save cookie result code.
426 /// [`ARKWEB_SUCCESS`] Save cookie success.
427 /// [`ARKWEB_COOKIE_SAVE_FAILED`] Save cookie failed.
428 /// [`ARKWEB_COOKIE_MANAGER_INITIALIZE_FAILED`] The CookieManager initialize failed.
429 /// [`ARKWEB_COOKIE_MANAGER_NOT_INITIALIZED`] It is not allowed to call on a non-UI thread without
430 /// initializing the CookieManager interface. please
431 /// initialize the CookieManager interface using
432 /// OH_ArkWeb_GetNativeAPI first.
433 ///
434 /// Available since API-level: 20
435 #[cfg(feature = "api-20")]
436 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
437 pub fn OH_ArkWebCookieManager_SaveCookieSync() -> ArkWeb_ErrorCode;
438 /// Ensure that all cookies currently accessible via the CookieManager API have been persisted to disk.
439 /// Without initializing the CookieManager interface, this call will automatically be executed on the UI thread.
440 /// # Arguments
441 ///
442 /// * `callback` - Callback execute when save cookie done.
443 ///
444 /// Available since API-level: 20
445 #[cfg(feature = "api-20")]
446 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
447 pub fn OH_ArkWebCookieManager_SaveCookieAsync(callback: OH_ArkWeb_OnCookieSaveCallback);
448 /// Set active ArkWeb engine version.
449 /// If the system does not support the specified version, it will not take effect.
450 ///
451 /// This is a global static API that must be called before initializeWebEngine, and it will have no effect if any
452 /// Web components are loaded.
453 ///
454 /// <strong>Legacy Web Engine Compatibility Note</strong>:
455 /// <p>When using legacy ArkWeb Engine, some ArkWeb newly created API will not take effect,<br>
456 /// see [Compatible with Legacy Web Engine in release note] for compatibility guidelines.
457 /// </p>
458 ///
459 /// # Arguments
460 ///
461 /// { ArkWebEngineVersion } webEngineVersion - the ArkWebEngineVersion
462 ///
463 /// Available since API-level: 20
464 #[cfg(feature = "api-20")]
465 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
466 pub fn OH_NativeArkWeb_SetActiveWebEngineVersion(webEngineVersion: ArkWebEngineVersion);
467 /// Get currently active ArkWeb engine version.
468 ///
469 /// # Returns
470 ///
471 /// * { ArkWebEngineVersion } Active ArkWeb Engine version as defined by ArkWebEngineVersion
472 ///
473 /// Available since API-level: 20
474 #[cfg(feature = "api-20")]
475 #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
476 pub fn OH_NativeArkWeb_GetActiveWebEngineVersion() -> ArkWebEngineVersion;
477}