arkweb-sys 0.1.0

Raw Bindings to the Web module of OpenHarmony
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
// automatically generated by rust-bindgen 0.71.1

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#[cfg(feature = "api-20")]
use crate::arkweb_error_code::ArkWeb_BlanklessErrorCode;
#[cfg(feature = "api-15")]
use crate::arkweb_error_code::ArkWeb_ErrorCode;
#[cfg(feature = "api-20")]
use crate::arkweb_type::ArkWeb_ProxyObjectWithResult;

/// Defines the javascript callback of the web component.
///
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub type NativeArkWeb_OnJavaScriptCallback =
    ::core::option::Option<unsafe extern "C" fn(arg1: *const ::core::ffi::c_char)>;
/// Defines the javascript proxy callback of the web component.
///
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub type NativeArkWeb_OnJavaScriptProxyCallback = ::core::option::Option<
    unsafe extern "C" fn(
        argv: *mut *const ::core::ffi::c_char,
        argc: i32,
    ) -> *mut ::core::ffi::c_char,
>;
/// Defines the valid callback of the web component.
///
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub type NativeArkWeb_OnValidCallback =
    ::core::option::Option<unsafe extern "C" fn(arg1: *const ::core::ffi::c_char)>;
/// Defines the destroy callback of the web component.
///
///
/// Available since API-level: 11
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub type NativeArkWeb_OnDestroyCallback =
    ::core::option::Option<unsafe extern "C" fn(arg1: *const ::core::ffi::c_char)>;
/// Defines the callback of save cookie.
/// # Arguments
///
/// * `errorCode` - [`ARKWEB_SUCCESS`] Save cookie success.
/// [`ARKWEB_COOKIE_MANAGER_INITIALIZE_FAILED`] Cookie manager initialize failed.
/// [`ARKWEB_COOKIE_SAVE_FAILED`] Save cookie failed.
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
pub type OH_ArkWeb_OnCookieSaveCallback =
    ::core::option::Option<unsafe extern "C" fn(errorCode: ArkWeb_ErrorCode)>;
/// Defines the blankless information.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[repr(C)]
pub struct ArkWeb_BlanklessInfo {
    /// The errCode of the blankless.
    pub errCode: ArkWeb_BlanklessErrorCode,
    /// The estimated similarity of the history snapshots.
    pub similarity: f64,
    /// The loadingTime of the history loading.
    pub loadingTime: i32,
}
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
impl ArkWebEngineVersion {
    /// the system default ArkWeb engine.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub const SYSTEM_DEFAULT: ArkWebEngineVersion = ArkWebEngineVersion(0);
    /// ArkWeb M114 version.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub const ARKWEB_M114: ArkWebEngineVersion = ArkWebEngineVersion(1);
    /// ArkWeb M132 version.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub const ARKWEB_M132: ArkWebEngineVersion = ArkWebEngineVersion(2);
}
#[repr(transparent)]
/// ArkWeb Engine Version.
///
/// <strong>ArkWeb Dual Web Engine Versioning Convention</strong>:
/// <p>See [ArkWeb Dual Web Engine Versioning Convention] for switching between Legacy and Evergreen Web Engine.
///
///
/// Available since API-level: 20
#[cfg(feature = "api-20")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ArkWebEngineVersion(pub ::core::ffi::c_uint);
extern "C" {
    /// Loads a piece of code and execute JS code in the context of the currently displayed page.
    ///
    /// # Arguments
    ///
    /// * `webTag` - The name of the web component.
    ///
    /// * `jsCode` - a piece of javascript code.
    ///
    /// * `callback` - Callbacks execute JavaScript script results.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Web.Webview.Core
    ///
    /// Available since API-level: 11
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_NativeArkWeb_RunJavaScript(
        webTag: *const ::core::ffi::c_char,
        jsCode: *const ::core::ffi::c_char,
        callback: NativeArkWeb_OnJavaScriptCallback,
    );
    /// Registers the JavaScript object and method list.
    ///
    /// # Arguments
    ///
    /// * `webTag` - The name of the web component.
    ///
    /// * `objName` - The name of the registered object.
    ///
    /// * `methodList` - The method of the application side JavaScript object participating in the registration.
    ///
    /// * `callback` - The callback function registered by developer is called back when HTML side uses.
    ///
    /// * `size` - The size of the callback.
    ///
    /// * `needRefresh` - if web need refresh.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Web.Webview.Core
    ///
    /// Available since API-level: 11
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_NativeArkWeb_RegisterJavaScriptProxy(
        webTag: *const ::core::ffi::c_char,
        objName: *const ::core::ffi::c_char,
        methodList: *mut *const ::core::ffi::c_char,
        callback: *mut NativeArkWeb_OnJavaScriptProxyCallback,
        size: i32,
        needRefresh: bool,
    );
    /// Deletes the registered object which th given name.
    ///
    /// # Arguments
    ///
    /// * `webTag` - The name of the web component.
    ///
    /// * `objName` - The name of the registered object.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Web.Webview.Core
    ///
    /// Available since API-level: 11
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_NativeArkWeb_UnregisterJavaScriptProxy(
        webTag: *const ::core::ffi::c_char,
        objName: *const ::core::ffi::c_char,
    );
    /// Registers the valid callback.
    ///
    /// # Arguments
    ///
    /// * `webTag` - The name of the web component.
    ///
    /// * `callback` - The callback in which we can register object.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Web.Webview.Core
    ///
    /// Available since API-level: 11
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_NativeArkWeb_SetJavaScriptProxyValidCallback(
        webTag: *const ::core::ffi::c_char,
        callback: NativeArkWeb_OnValidCallback,
    );
    /// Get the valid callback.
    ///
    /// # Arguments
    ///
    /// * `webTag` - The name of the web component.
    ///
    /// # Returns
    ///
    /// * Return the valid callback function registered. If the valid callback function
    /// specified by the parameter webTag is not set, a null pointer is returned.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Web.Webview.Core
    ///
    /// Available since API-level: 11
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_NativeArkWeb_GetJavaScriptProxyValidCallback(
        webTag: *const ::core::ffi::c_char,
    ) -> NativeArkWeb_OnValidCallback;
    /// Registers the destroy callback.
    ///
    /// # Arguments
    ///
    /// * `webTag` - The name of the web component.
    ///
    /// * `callback` - the destroy callback.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Web.Webview.Core
    ///
    /// Available since API-level: 11
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_NativeArkWeb_SetDestroyCallback(
        webTag: *const ::core::ffi::c_char,
        callback: NativeArkWeb_OnDestroyCallback,
    );
    /// Get the destroy callback.
    ///
    /// # Arguments
    ///
    /// * `webTag` - The name of the web component.
    ///
    /// # Returns
    ///
    /// * Return the destroy callback function registered. If the destroy callback
    /// function specified by the parameter webTag is not set,
    /// a null pointer is returned.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Web.Webview.Core
    ///
    /// Available since API-level: 11
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_NativeArkWeb_GetDestroyCallback(
        webTag: *const ::core::ffi::c_char,
    ) -> NativeArkWeb_OnDestroyCallback;
    /// Loads the data or URL.
    /// This function should be called on main thread.
    ///
    /// # Arguments
    ///
    /// * `webTag` - The name of the web component.
    ///
    /// * `data` - A string encoded according to "Base64" or "URL", should not be NULL.
    ///
    /// * `mimeType` - Media type. For example: "text/html", should not be NULL.
    ///
    /// * `encoding` - Encoding type. For example: "UTF-8", should not be NULL.
    ///
    /// * `baseUrl` - A specified URL path ("http"/"https"/"data" protocol),
    /// which is assigned to window.origin by the Web component.
    ///
    /// * `historyUrl` - History URL. When it is not empty, it can be managed by
    /// history records to realize the back and forth function.
    ///
    /// # Returns
    ///
    /// * LoadData result code.
    /// [`ARKWEB_SUCCESS`] load data success.
    /// [`ARKWEB_INVALID_PARAM`] Mandatory parameters are left unspecified or
    /// Incorrect parameter types or Parameter verification failed.
    /// [`ARKWEB_INIT_ERROR`] Initialization error, can't get a valid Web for the webTag.
    /// [`ARKWEB_LIBRARY_OPEN_FAILURE`] Failed to open the library.
    /// [`ARKWEB_LIBRARY_SYMBOL_NOT_FOUND`] The required symbol was not found in the library.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Web.Webview.Core
    ///
    /// Available since API-level: 15
    #[cfg(feature = "api-15")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-15")))]
    pub fn OH_NativeArkWeb_LoadData(
        webTag: *const ::core::ffi::c_char,
        data: *const ::core::ffi::c_char,
        mimeType: *const ::core::ffi::c_char,
        encoding: *const ::core::ffi::c_char,
        baseUrl: *const ::core::ffi::c_char,
        historyUrl: *const ::core::ffi::c_char,
    ) -> ArkWeb_ErrorCode;
    /// Registers a JavaScript object with callback methods, which may return values. This object will be injected
    /// into all frames of the current page, including all iframes, and will be accessible using the specified
    /// name in ArkWeb_ProxyObjectWithResult. The object will only be available in JavaScript after the next
    /// load or reload.
    /// These methods will be executed in the ArkWeb worker thread.
    ///
    /// # Arguments
    ///
    /// * `webTag` - Name of the web component.
    ///
    /// * `proxyObject` - JavaScript object to register, the object has callback functions with return value.
    ///
    /// * `permission` - Optional JSON string(default is null) for JSBridge permission control,
    /// allowing URL whitelist configuration at object-level and method-level.
    ///
    /// Required System Capabilities: SystemCapability.Web.Webview.Core
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_NativeArkWeb_RegisterAsyncThreadJavaScriptProxy(
        webTag: *const ::core::ffi::c_char,
        proxyObject: *const ArkWeb_ProxyObjectWithResult,
        permission: *const ::core::ffi::c_char,
    );
    /// Sets whether to enable blankless page loading. This API must be used in pair with the
    /// OH_NativeArkWeb_GetBlanklessInfoWithKey API.
    ///
    /// # Arguments
    ///
    /// * `webTag` - webTag used when the webviewController is created.
    ///
    /// * `key` - Key value that uniquely identifies the current page. It must be the same as the key value of the
    /// OH_NativeArkWeb_GetBlanklessInfoWithKey API.
    ///
    /// * `isStarted` - Whether to enable frame interpolation. The value true indicates to enable frame
    /// interpolation, and the value false indicates the opposite.
    /// The default value is false.
    /// The value can be true or false.
    /// Action for setting an invalid value: N/A.
    ///
    /// # Returns
    ///
    /// * Whether the API is successfully called. For details, see ArkWeb_BlanklessErrorCode.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_NativeArkWeb_SetBlanklessLoadingWithKey(
        webTag: *const ::core::ffi::c_char,
        key: *const ::core::ffi::c_char,
        isStarted: bool,
    ) -> ArkWeb_BlanklessErrorCode;
    /// Clears the blankless loading cache of the page with a specified key value.
    ///
    /// # Arguments
    ///
    /// * `key` - The list of key values of pages cached in the blankless loading solution. These key values are
    /// specified in OH_NativeArkWeb_GetBlanklessInfoWithKey.
    /// The default value is the list of key values of all pages cached in the blankless loading solution.
    /// The key length cannot exceed 2048 characters, and the number of keys must be less than or equal to 100. The
    /// URL is the same as that input to the Web component during page loading.
    /// When the key length exceeds 2048 characters, the key does not take effect. When the number of keys exceeds
    /// 100, the first 100 keys are used. If this parameter is set to NULL, the default value is used.
    ///
    /// * `size` - Size of the key list.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_NativeArkWeb_ClearBlanklessLoadingCache(
        key: *mut *const ::core::ffi::c_char,
        size: u32,
    );
    /// Obtains the prediction information about the blankless loading solution and enables the generation
    /// of the transition frame for the current loading. The application determines whether to enable the blankless
    /// loading solution based on the information.
    /// This API applies to pages in an applet or web application whose URLs are not fixed or cannot be uniquely
    /// identified.
    ///
    /// # Arguments
    ///
    /// * `webTag` - webTag used when the webviewController is created.
    /// Default value: N/A.
    /// The value cannot be empty.
    /// When an invalid value is set, the error code is returned, and the API does not take effect.
    ///
    /// * `key` - Key value that uniquely identifies the current page.
    ///
    /// # Returns
    ///
    /// * Return value of the ArkWeb_BlanklessInfo type.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_NativeArkWeb_GetBlanklessInfoWithKey(
        webTag: *const ::core::ffi::c_char,
        key: *const ::core::ffi::c_char,
    ) -> ArkWeb_BlanklessInfo;
    /// Sets the cache capacity of the blankless loading solution and returns the value that takes effect.
    ///
    /// # Arguments
    ///
    /// * `capacity` - Cache capacity, in MB. The maximum value is 100 MB.
    /// The default value is 30 MB.
    /// The value ranges from 0 to 100. If this parameter is set to 0, no cache capacity is available and the
    /// functionality is disabled globally.
    /// When the value is set to a number smaller than 0, the value 0 takes effect. When the value is set to a
    /// number greater than 100, the value 100 takes effect.
    ///
    /// # Returns
    ///
    /// * The effective value that ranges from 0 MB to 100 MB.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_NativeArkWeb_SetBlanklessLoadingCacheCapacity(capacity: u32) -> u32;
    /// Ensure that all cookies currently accessible via the CookieManager API have been persisted to disk.
    /// If you want to use this interface in a non-UI thread, you need to initialize the CookieManager interface
    /// using OH_ArkWeb_GetNativeAPI first.
    ///
    /// # Returns
    ///
    /// * Save cookie result code.
    /// [`ARKWEB_SUCCESS`] Save cookie success.
    /// [`ARKWEB_COOKIE_SAVE_FAILED`] Save cookie failed.
    /// [`ARKWEB_COOKIE_MANAGER_INITIALIZE_FAILED`] The CookieManager initialize failed.
    /// [`ARKWEB_COOKIE_MANAGER_NOT_INITIALIZED`] It is not allowed to call on a non-UI thread without
    /// initializing the CookieManager interface. please
    /// initialize the CookieManager interface using
    /// OH_ArkWeb_GetNativeAPI first.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_ArkWebCookieManager_SaveCookieSync() -> ArkWeb_ErrorCode;
    /// Ensure that all cookies currently accessible via the CookieManager API have been persisted to disk.
    /// Without initializing the CookieManager interface, this call will automatically be executed on the UI thread.
    /// # Arguments
    ///
    /// * `callback` - Callback execute when save cookie done.
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_ArkWebCookieManager_SaveCookieAsync(callback: OH_ArkWeb_OnCookieSaveCallback);
    /// Set active ArkWeb engine version.
    /// If the system does not support the specified version, it will not take effect.
    ///
    /// This is a global static API that must be called before initializeWebEngine, and it will have no effect if any
    /// Web components are loaded.
    ///
    /// <strong>Legacy Web Engine Compatibility Note</strong>:
    /// <p>When using legacy ArkWeb Engine, some ArkWeb newly created API will not take effect,<br>
    /// see [Compatible with Legacy Web Engine in release note] for compatibility guidelines.
    /// </p>
    ///
    /// # Arguments
    ///
    /// { ArkWebEngineVersion } webEngineVersion - the ArkWebEngineVersion
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_NativeArkWeb_SetActiveWebEngineVersion(webEngineVersion: ArkWebEngineVersion);
    /// Get currently active ArkWeb engine version.
    ///
    /// # Returns
    ///
    /// * { ArkWebEngineVersion } Active ArkWeb Engine version as defined by ArkWebEngineVersion
    ///
    /// Available since API-level: 20
    #[cfg(feature = "api-20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-20")))]
    pub fn OH_NativeArkWeb_GetActiveWebEngineVersion() -> ArkWebEngineVersion;
}