1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @addtogroup UDMF
18 * @{
19 *
20 * @brief The Unified Data Management Framework(UDMF) aims to define various standards
21 * for data across applications, devices, and platforms, providing a unified OpenHarmony
22 * data language and standardized data access and reading paths.
23 *
24 * @since 12
25 */
26
27/**
28 * @file udmf.h
29 *
30 * @brief Provides unified data management framework related functions and enumerations.
31 *
32 * @kit ArkData
33 * @library libudmf.so
34 * @syscap SystemCapability.DistributedDataManager.UDMF.Core
35 *
36 * @since 12
37 */
38
39#ifndef UDMF_H
40#define UDMF_H
41
42#include <inttypes.h>
43#include <stdbool.h>
44#include "uds.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/**
51 * @brief The key minimum memory space size of Unified Data.
52 *
53 * @since 12
54 */
55#define UDMF_KEY_BUFFER_LEN (512)
56
57/**
58 * @brief Describe the intention type of the udmf.
59 *
60 * @since 12
61 */
62typedef enum Udmf_Intention {
63    /**
64     * @brief The intention is drag.
65     */
66    UDMF_INTENTION_DRAG,
67    /**
68     * @brief The intention is pasteboard.
69     */
70    UDMF_INTENTION_PASTEBOARD,
71} Udmf_Intention;
72
73/**
74 * @brief Describe intra-device usage range type enumeration.
75 *
76 * @since 12
77 */
78typedef enum Udmf_ShareOption {
79    /**
80     * @brief Invalid share option.
81     */
82    SHARE_OPTIONS_INVALID,
83    /**
84     * @brief Allowed to be used in the same application on this device.
85     */
86    SHARE_OPTIONS_IN_APP,
87    /**
88     * @brief Allowed to be used in the cross application on this device.
89     */
90    SHARE_OPTIONS_CROSS_APP
91} Udmf_ShareOption;
92
93/**
94 * @brief Describes the unified data type.
95 *
96 * @since 12
97 */
98typedef struct OH_UdmfData OH_UdmfData;
99
100/**
101 * @brief Describes the record type in the unified data.
102 *
103 * @since 12
104 */
105typedef struct OH_UdmfRecord OH_UdmfRecord;
106
107/**
108 * @brief Defines the data provider.
109 *
110 * @since 13
111 */
112typedef struct OH_UdmfRecordProvider OH_UdmfRecordProvider;
113
114/**
115 * @brief Describes some property parameters of unified data.
116 *
117 * @since 12
118 */
119typedef struct OH_UdmfProperty OH_UdmfProperty;
120
121/**
122 * @brief Creation a pointer to the instance of the {@link OH_UdmfData}.
123 *
124 * @return If the operation is successful, a pointer to the instance of the {@link OH_UdmfData}
125 * structure is returned. If the operation is failed, nullptr is returned.
126 * @see OH_UdmfData.
127 * @since 12
128 */
129OH_UdmfData* OH_UdmfData_Create();
130
131/**
132 * @brief Destroy a pointer that points to the {@link OH_UdmfData} instance.
133 *
134 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}.
135 * @see OH_UdmfData.
136 * @since 12
137 */
138void OH_UdmfData_Destroy(OH_UdmfData* pThis);
139
140/**
141 * @brief Add one {OH_UdmfRecord} record to the {@link OH_UdmfData} data.
142 *
143 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}.
144 * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}.
145 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
146 *         {@link UDMF_E_OK} success.
147 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
148 * @see OH_UdmfData Udmf_ErrCode.
149 * @since 12
150 */
151int OH_UdmfData_AddRecord(OH_UdmfData* pThis, OH_UdmfRecord* record);
152
153/**
154 * @brief Check whether the type exists in the {@link OH_UdmfData} data.
155 *
156 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}.
157 * @param type Represents a string pointer of the type.
158 * @return Returns the status of finding type.
159 *         {@code false} is not existed.
160 *         {@code true} is existed.
161 * @see OH_UdmfData.
162 * @since 12
163 */
164bool OH_UdmfData_HasType(OH_UdmfData* pThis, const char* type);
165
166/**
167 * @brief Get all types in the {@link OH_UdmfData} data.
168 *
169 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}.
170 * @param count Represents the types count that is a output param.
171 * @return Returns string array that in {@link OH_UdmfData} when input parameters valid,
172 * otherwise return nullptr.
173 * @see OH_UdmfData.
174 * @since 12
175 */
176char** OH_UdmfData_GetTypes(OH_UdmfData* pThis, unsigned int* count);
177
178/**
179 * @brief Get all records in the {@link OH_UdmfData} data.
180 *
181 * @param pThis Represents a pointer to an instance of {@link OH_UdmfData}.
182 * @param count Represents the records count that is a output param.
183 * @return Returns {@link OH_UdmfRecord} pointer array when input parameters valid, otherwise return nullptr.
184 * @see OH_UdmfData OH_UdmfRecord.
185 * @since 12
186 */
187OH_UdmfRecord** OH_UdmfData_GetRecords(OH_UdmfData* pThis, unsigned int* count);
188
189/**
190 * @brief Defines the callback function used free the context.
191 * @param context Pointer to the context which is to be free.
192 * @since 13
193 */
194typedef void (*UdmfData_Finalize)(void* context);
195
196/**
197 * @brief Creates an {@link OH_UdmfRecordProvider} instance.
198 *
199 * @return Returns the pointer to the {@link OH_UdmfRecordProvider} instance created if the operation is successful.
200 * Returns nullptr if the memory is not enough.
201 * @see OH_UdmfRecordProvider.
202 * @since 13
203 */
204OH_UdmfRecordProvider* OH_UdmfRecordProvider_Create();
205
206/**
207 * @brief Destroy an {@link OH_UdmfRecordProvider} instance.
208 *
209 * @param subscriber Pointer to the {@link OH_UdmfRecordProvider} instance to destroy.
210 * @return Returns the status code of the execution. For details, see {@link Udmf_ErrCode}.
211 *         Returns {@link UDMF_E_OK} if the operation is successful.
212 *         Returns {@link UDMF_E_INVALID_PARAM} if invalid args are detected.
213 * @see OH_UdmfRecordProvider Udmf_ErrCode.
214 * @since 13
215 */
216int OH_UdmfRecordProvider_Destroy(OH_UdmfRecordProvider* provider);
217
218/**
219 * @brief Defines a callback function used to obtain data by type.
220 *
221 * @param context Pointer to the context set by {@link OH_UdmfRecordProvider_SetData}.
222 * @param type Pointer to the type of data to obtain. For details, see {@link udmf_meta.h}.
223 * @return Returns the data content.
224 * @since 13
225 */
226typedef void* (*OH_UdmfRecordProvider_GetData)(void* context, const char* type);
227
228/**
229 * @brief Sets a callback function to obtain data.
230 *
231 * @param provider Pointer to the {@link OH_UdmfRecordProvider} instance.
232 * @param context Pointer to the context set, which is the first parameter in OH_UdmfRecordProvider_GetData.
233 * @param callback Callback to set. For details, see {@link OH_UdmfRecordProvider_GetData}.
234 * @param finalize Optional callback that can free context when destroy provider.
235 *         For details, see {@link UdmfData_Finalize}.
236 * @return Returns the status code of the execution. For details, see {@link Udmf_ErrCode}.
237 *         Returns {@link UDMF_E_OK} if the operation is successful.
238 *         Returns {@link UDMF_E_INVALID_PARAM} if invalid args are detected.
239 * @see OH_UdmfRecordProvider OH_UdmfRecordProvider_GetData UdmfData_Finalize Udmf_ErrCode.
240 * @since 13
241 */
242int OH_UdmfRecordProvider_SetData(OH_UdmfRecordProvider* provider, void* context,
243    const OH_UdmfRecordProvider_GetData callback, const UdmfData_Finalize finalize);
244
245/**
246 * @brief Creation a pointer to the instance of the {@link OH_UdmfRecord}, it's relate with UDS data.
247 *
248 * @return If the operation is successful, a pointer to the instance of the {@link OH_UdmfRecord}
249 * structure is returned. If the operation is failed, nullptr is returned.
250 * @see OH_UdmfRecord.
251 * @since 12
252 */
253OH_UdmfRecord* OH_UdmfRecord_Create();
254
255/**
256 * @brief Destroy a pointer that points to an instance of {@link OH_UdmfRecord}.
257 *
258 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
259 * @see OH_UdmfRecord.
260 * @since 12
261 */
262void OH_UdmfRecord_Destroy(OH_UdmfRecord* pThis);
263
264/**
265 * @brief Add one custom data to the {@link OH_UdmfRecord} record.
266 *
267 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
268 * @param typeId Represents record type, reference udmf_meta.h.
269 * @param entry Represents custom data.
270 * @param count Represents the size of data param.
271 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
272 *         {@link UDMF_E_OK} success.
273 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
274 * @see OH_UdmfRecord Udmf_ErrCode.
275 * @since 12
276 */
277int OH_UdmfRecord_AddGeneralEntry(OH_UdmfRecord* pThis, const char* typeId, unsigned char* entry, unsigned int count);
278
279/**
280 * @brief Add one {OH_UdsPlainText} data to the {@link OH_UdmfRecord} record.
281 *
282 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
283 * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}.
284 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
285 *         {@link UDMF_E_OK} success.
286 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
287 * @see OH_UdmfRecord OH_UdsPlainText Udmf_ErrCode.
288 * @since 12
289 */
290int OH_UdmfRecord_AddPlainText(OH_UdmfRecord* pThis, OH_UdsPlainText* plainText);
291
292/**
293 * @brief Add one {OH_UdsHyperlink} data to the {@link OH_UdmfRecord} record.
294 *
295 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
296 * @param hyperlink Represents a pointer to an instance of {@link OH_UdsHyperlink}.
297 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
298 *         {@link UDMF_E_OK} success.
299 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
300 * @see OH_UdmfRecord OH_UdsHyperlink Udmf_ErrCode.
301 * @since 12
302 */
303int OH_UdmfRecord_AddHyperlink(OH_UdmfRecord* pThis, OH_UdsHyperlink* hyperlink);
304
305/**
306 * @brief Add one {OH_UdsHtml} data to the {@link OH_UdmfRecord} record.
307 *
308 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
309 * @param html Represents a pointer to an instance of {@link OH_UdsHtml}.
310 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
311 *         {@link UDMF_E_OK} success.
312 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
313 * @see OH_UdmfRecord OH_UdsHtml Udmf_ErrCode.
314 * @since 12
315 */
316int OH_UdmfRecord_AddHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html);
317
318/**
319 * @brief Add one {OH_UdsAppItem} data to the {@link OH_UdmfRecord} record.
320 *
321 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
322 * @param appItem Represents a pointer to an instance of {@link OH_UdsAppItem}.
323 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
324 *         {@link UDMF_E_OK} success.
325 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
326 * @see OH_UdmfRecord OH_UdsAppItem Udmf_ErrCode.
327 * @since 12
328 */
329int OH_UdmfRecord_AddAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem);
330
331/**
332 * @brief Add one {OH_UdsFileUri} data to the {@link OH_UdmfRecord} record.
333 *
334 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
335 * @param fileUri Represents a pointer to an instance of {@link OH_UdsFileUri}.
336 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
337 *         {@link UDMF_E_OK} success.
338 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
339 * @see OH_UdmfRecord OH_UdsFileUri Udmf_ErrCode.
340 * @since 13
341 */
342int OH_UdmfRecord_AddFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri);
343
344/**
345 * @brief Add one {OH_UdsPixelMap} data to the {@link OH_UdmfRecord} record.
346 *
347 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
348 * @param pixelMap Represents a pointer to an instance of {@link OH_UdsPixelMap}.
349 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
350 *         {@link UDMF_E_OK} success.
351 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
352 * @see OH_UdmfRecord OH_UdsPixelMap Udmf_ErrCode.
353 * @since 13
354 */
355int OH_UdmfRecord_AddPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap);
356
357/**
358 * @brief Add one {@link OH_UdsArrayBuffer} data to the {@link OH_UdmfRecord} record.
359 *
360 * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}.
361 * @param type Represents record type, reference udmf_meta.h.
362 * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}.
363 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
364 *         {@link UDMF_E_OK} success.
365 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
366 * @see OH_UdmfRecord OH_UdsArrayBuffer Udmf_ErrCode.
367 * @since 13
368 */
369int OH_UdmfRecord_AddArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer);
370
371/**
372 * @brief Get all types in the {@link OH_UdmfRecord} record.
373 *
374 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
375 * @param count Represents the types count that is a output param.
376 * @return Returns string array that in {@link OH_UdmfRecord} when input parameters valid,
377 * otherwise return nullptr.
378 * @see OH_UdmfRecord.
379 * @since 12
380 */
381char** OH_UdmfRecord_GetTypes(OH_UdmfRecord* pThis, unsigned int* count);
382
383/**
384 * @brief Get one entry data from the {@link OH_UdmfRecord} record.
385 *
386 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
387 * @param typeId Represents record type, reference udmf_meta.h.
388 * @param entry Represents a pointer to entry data that is a output param.
389 * @param count Represents the entry data length that is a output param.
390 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
391 *         {@link UDMF_E_OK} success.
392 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
393 *         {@link UDMF_ERR} Internal data error.
394 * @see OH_UdmfRecord Udmf_ErrCode.
395 * @since 12
396 */
397int OH_UdmfRecord_GetGeneralEntry(OH_UdmfRecord* pThis, const char* typeId,
398    unsigned char** entry, unsigned int* count);
399
400/**
401 * @brief Get one {OH_UdsPlainText} data from the {@link OH_UdmfRecord} record.
402 *
403 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
404 * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}.
405 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
406 *         {@link UDMF_E_OK} success.
407 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
408 *         {@link UDMF_ERR} Internal data error.
409 * @see OH_UdmfRecord OH_UdsPlainText Udmf_ErrCode.
410 * @since 12
411 */
412int OH_UdmfRecord_GetPlainText(OH_UdmfRecord* pThis, OH_UdsPlainText* plainText);
413
414/**
415 * @brief Get one {OH_UdsHyperlink} data from the {@link OH_UdmfRecord} record.
416 *
417 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
418 * @param hyperlink Represents a pointer to an instance of {@link OH_UdsHyperlink}.
419 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
420 *         {@link UDMF_E_OK} success.
421 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
422 *         {@link UDMF_ERR} Internal data error.
423 * @see OH_UdmfRecord OH_UdsHyperlink Udmf_ErrCode.
424 * @since 12
425 */
426int OH_UdmfRecord_GetHyperlink(OH_UdmfRecord* pThis, OH_UdsHyperlink* hyperlink);
427
428/**
429 * @brief Get one {OH_UdsHtml} data from the {@link OH_UdmfRecord} record.
430 *
431 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
432 * @param html Represents a pointer to an instance of {@link OH_UdsHtml}.
433 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
434 *         {@link UDMF_E_OK} success.
435 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
436 *         {@link UDMF_ERR} Internal data error.
437 * @see OH_UdmfRecord OH_UdsHtml Udmf_ErrCode.
438 * @since 12
439 */
440int OH_UdmfRecord_GetHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html);
441
442/**
443 * @brief Get one {OH_UdsAppItem} data from the {@link OH_UdmfRecord} record.
444 *
445 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
446 * @param appItem Represents a pointer to an instance of {@link OH_UdsAppItem}.
447 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
448 *         {@link UDMF_E_OK} success.
449 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
450 *         {@link UDMF_ERR} Internal data error.
451 * @see OH_UdmfRecord OH_UdsAppItem Udmf_ErrCode.
452 * @since 12
453 */
454int OH_UdmfRecord_GetAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem);
455
456/**
457 * @brief Set the data provider of the types.
458 *
459 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
460 * @param types Represents a pointer to a group of data types;
461 * @param count Represents the number of data types;
462 * @param provider Represents a pointer an instance of {@link OH_UdmfRecordProvider}.
463 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
464 *         {@link UDMF_E_OK} success.
465 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
466 * @see OH_UdmfRecord OH_UdmfRecordProvider Udmf_ErrCode.
467 * @since 13
468 */
469int OH_UdmfRecord_SetProvider(OH_UdmfRecord* pThis, const char* const* types, unsigned int count,
470    OH_UdmfRecordProvider* provider);
471
472/**
473 * @brief Get one {OH_UdsFileUri} data from the {@link OH_UdmfRecord} record.
474 *
475 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
476 * @param fileUri Represents a pointer to an instance of {@link OH_UdsFileUri}.
477 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
478 *         {@link UDMF_E_OK} success.
479 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
480 * @see OH_UdmfRecord OH_UdsFileUri Udmf_ErrCode.
481 * @since 13
482 */
483int OH_UdmfRecord_GetFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri);
484
485/**
486 * @brief Get one {OH_UdsPixelMap} data from the {@link OH_UdmfRecord} record.
487 *
488 * @param pThis Represents a pointer to an instance of {@link OH_UdmfRecord}.
489 * @param pixelMap Represents a pointer to an instance of {@link OH_UdsPixelMap}.
490 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
491 *         {@link UDMF_E_OK} success.
492 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
493 * @see OH_UdmfRecord OH_UdsPixelMap Udmf_ErrCode.
494 * @since 13
495 */
496int OH_UdmfRecord_GetPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap);
497
498/**
499 * @brief Get one {@link OH_UdsArrayBuffer} data from the {@link OH_UdmfRecord} record.
500 *
501 * @param record Represents a pointer to an instance of {@link OH_UdmfRecord}.
502 * @param type Represents record type, reference udmf_meta.h.
503 * @param buffer Represents a pointer to an instance of {@link OH_UdsArrayBuffer}.
504 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
505 *         {@link UDMF_E_OK} success.
506 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
507 * @see OH_UdmfRecord OH_UdsArrayBuffer Udmf_ErrCode.
508 * @since 13
509 */
510int OH_UdmfRecord_GetArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer);
511
512/**
513 * @brief Get primary {@link OH_UdsPlainText} data from the {@link OH_UdmfData}.
514 *
515 * @param data Represents a pointer to an instance of {@link OH_UdmfData}.
516 * @param plainText Represents a pointer to an instance of {@link OH_UdsPlainText}.
517 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
518 *         {@link UDMF_E_OK} success.
519 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
520 * @see OH_UdmfData OH_UdsPlainText Udmf_ErrCode.
521 * @since 13
522 */
523int OH_UdmfData_GetPrimaryPlainText(OH_UdmfData* data, OH_UdsPlainText* plainText);
524
525/**
526 * @brief Get one {@link OH_UdsHtml} data from the {@link OH_UdmfData}.
527 *
528 * @param data Represents a pointer to an instance of {@link OH_UdmfData}.
529 * @param html Represents a pointer to an instance of {@link OH_UdsHtml}.
530 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
531 *         {@link UDMF_E_OK} success.
532 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
533 * @see OH_UdmfData OH_UdsHtml Udmf_ErrCode.
534 * @since 13
535 */
536int OH_UdmfData_GetPrimaryHtml(OH_UdmfData* data, OH_UdsHtml* html);
537
538/**
539 * @brief Get the count of {@link OH_UdmfRecord} in the {@link OH_UdmfData}.
540 *
541 * @param data Represents a pointer to an instance of {@link OH_UdmfData}.
542 * @return Returns the count of {@link OH_UdmfRecord}
543 * @see OH_UdmfData.
544 * @since 13
545 */
546int OH_UdmfData_GetRecordCount(OH_UdmfData* data);
547
548/**
549 * @brief Get the record of the specified index from the {@link OH_UdmfData}.
550 *
551 * @param data Represents a pointer to an instance of {@link OH_UdmfData}.
552 * @param index Represents the index of {@link OH_UdmfRecord} in the {@link OH_UdmfData}.
553 * @return Returns {@link OH_UdmfRecord} pointer when input parameters valid, otherwise return nullptr.
554 * @see OH_UdmfData.
555 * @since 13
556 */
557OH_UdmfRecord* OH_UdmfData_GetRecord(OH_UdmfData* data, unsigned int index);
558
559/**
560 * @brief Checks whether the UDMF data is from a local device.
561 *
562 * @param data Represents a pointer to an instance of {@link OH_UdmfData}.
563 * @return Returns a boolean value, which indicates whether the UDMF data is from a local device.
564 *         The value {@code true} means the data is from a local device.
565 *         The value {@code false} means the opposite.
566 * @see OH_UdmfData.
567 * @since 13
568 */
569bool OH_UdmfData_IsLocal(OH_UdmfData* data);
570
571/**
572 * @brief Creation a pointer to the instance of the {@link OH_UdmfProperty}
573 * from a {@link OH_UdmfData} data.
574 *
575 * @param unifiedData Represents a pointer to an instance of {@link OH_UdmfData}.
576 * @return If the operation is successful, a pointer to the instance of the {@link OH_UdmfProperty}
577 * structure is returned. If the operation is failed, nullptr is returned.
578 * @see OH_UdmfData OH_UdmfProperty.
579 * @since 12
580 */
581OH_UdmfProperty* OH_UdmfProperty_Create(OH_UdmfData* unifiedData);
582
583/**
584 * @brief Destroy a pointer that points to the {@link OH_UdmfProperty} instance.
585 *
586 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
587 * @see OH_UdmfProperty.
588 * @since 12
589 */
590void OH_UdmfProperty_Destroy(OH_UdmfProperty* pThis);
591
592/**
593 * @brief Get tag value from the {@link OH_UdmfProperty}.
594 *
595 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
596 * @return Returns a pointer of the tag value string when input parameters valid, otherwise return nullptr.
597 * @see OH_UdmfProperty.
598 * @since 12
599 */
600const char* OH_UdmfProperty_GetTag(OH_UdmfProperty* pThis);
601
602/**
603 * @brief Get timestamp value from the {@link OH_UdmfProperty}.
604 *
605 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
606 * @return Returns timestamp value.
607 * @see OH_UdmfProperty
608 * @since 12
609 */
610int64_t OH_UdmfProperty_GetTimestamp(OH_UdmfProperty* pThis);
611
612/**
613 * @brief Get share option value from the {@link OH_UdmfProperty}.
614 *
615 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
616 * @return Returns {@link Udmf_ShareOption} value.
617 * @see OH_UdmfProperty Udmf_ShareOption
618 * @since 12
619 */
620Udmf_ShareOption OH_UdmfProperty_GetShareOption(OH_UdmfProperty* pThis);
621
622/**
623 * @brief Get integer value by key from the {@link OH_UdmfProperty}.
624 *
625 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
626 * @param key Represents key-value pair's key
627 * @param defaultValue Represents when get value failure.
628 * @return Returns value associated with the key in successfully, otherwise return defaultValue.
629 * @see OH_UdmfProperty.
630 * @since 12
631 */
632int OH_UdmfProperty_GetExtrasIntParam(OH_UdmfProperty* pThis,
633    const char* key, int defaultValue);
634
635/**
636 * @brief Get tag value from the {@link OH_UdmfProperty}.
637 *
638 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
639 * @param key Represents key-value pair's key.
640 * @return Returns a pointer of the key value string when input parameters valid, otherwise return nullptr.
641 * @see OH_UdmfProperty
642 * @since 12
643 */
644const char* OH_UdmfProperty_GetExtrasStringParam(OH_UdmfProperty* pThis, const char* key);
645
646/**
647 * @brief Set tag value to {@link OH_UdmfProperty} .
648 *
649 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
650 * @param tag Represents new tag param.
651 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
652 *         {@link UDMF_E_OK} success.
653 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
654 * @see OH_UdmfProperty Udmf_ErrCode.
655 * @since 12
656 */
657int OH_UdmfProperty_SetTag(OH_UdmfProperty* pThis, const char* tag);
658
659/**
660 * @brief Set Udmf_ShareOption value to {@link OH_UdmfProperty}.
661 *
662 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
663 * @param option Represents new {@link Udmf_ShareOption} param.
664 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
665 *         {@link UDMF_E_OK} success.
666 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
667 * @see OH_UdmfProperty Udmf_ShareOption Udmf_ErrCode.
668 * @since 12
669 */
670int OH_UdmfProperty_SetShareOption(OH_UdmfProperty* pThis, Udmf_ShareOption option);
671
672/**
673 * @brief Set extras param to {@link OH_UdmfProperty}.
674 *
675 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
676 * @param key Represents extras param's key value.
677 * @param param Represents value of k-v pairs.
678 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
679 *         {@link UDMF_E_OK} success.
680 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
681 * @see OH_UdmfProperty Udmf_ErrCode.
682 * @since 12
683 */
684int OH_UdmfProperty_SetExtrasIntParam(OH_UdmfProperty* pThis, const char* key, int param);
685
686/**
687 * @brief Set extras param to {@link OH_UdmfProperty}.
688 *
689 * @param pThis Represents a pointer to an instance of {@link OH_UdmfProperty}.
690 * @param key Represents extras param's key value.
691 * @param param Represents value of k-v pairs.
692 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
693 *         {@link UDMF_E_OK} success.
694 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
695 * @see OH_UdmfProperty Udmf_ErrCode.
696 * @since 12
697 */
698int OH_UdmfProperty_SetExtrasStringParam(OH_UdmfProperty* pThis,
699    const char* key, const char* param);
700
701/**
702 * @brief Get {@link OH_UdmfData} data from udmf database.
703 *
704 * @param key Represents database store's key value.
705 * @param intention Represents data type {@link Udmf_Intention}
706 * @param unifiedData Represents output params of {@link OH_UdmfData};
707 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
708 *         {@link UDMF_E_OK} success.
709 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
710 *         {@link UDMF_ERR} Internal data error.
711 * @see OH_UdmfProperty Udmf_Intention Udmf_ErrCode.
712 * @since 12
713 */
714int OH_Udmf_GetUnifiedData(const char* key, Udmf_Intention intention, OH_UdmfData* unifiedData);
715
716/**
717 * @brief Set {@link OH_UdmfData} data to database.
718 *
719 * @param intention Represents data type {@link Udmf_Intention}.
720 * @param unifiedData Represents a pointer to an instance of {@link OH_UdmfData}.
721 * @param key Represents return value after set data to database successfully,
722 * it's memory size not less than {@link UDMF_KEY_BUFFER_LEN}.
723 * @param keyLen Represents size of key param.
724 * @return Returns the status code of the execution. See {@link Udmf_ErrCode}.
725 *         {@link UDMF_E_OK} success.
726 *         {@link UDMF_E_INVALID_PARAM} The error code for common invalid args.
727 *         {@link UDMF_ERR} Internal data error.
728 * @see OH_UdmfProperty Udmf_Intention Udmf_ErrCode.
729 * @since 12
730 */
731int OH_Udmf_SetUnifiedData(Udmf_Intention intention, OH_UdmfData* unifiedData,
732    char* key, unsigned int keyLen);
733
734#ifdef __cplusplus
735};
736#endif
737
738/** @} */
739#endif