Skip to main content

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