• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# oh_pasteboard.h
2<!--Kit: Basic Services Kit-->
3<!--Subsystem: MiscServices-->
4<!--Owner: @yangxiaodong41-->
5<!--Designer: @guo867-->
6<!--Tester: @maxiaorong2-->
7<!--Adviser: @HelloCrease-->
8
9## Overview
10
11Provides data structure, enum types, and APIs for accessing the system pasteboard.<br>
12
13**File to include**: <database/pasteboard/oh_pasteboard.h>
14
15**Library**: libpasteboard.so
16
17**System capability**: SystemCapability.MiscServices.Pasteboard
18
19**Since**: 13
20
21**Related module**: [Pasteboard](capi-pasteboard.md)
22
23## Summary
24
25### Structs
26
27| Name| typedef Keyword| Description|
28| -- | -- | -- |
29| [Pasteboard_ProgressInfo](capi-pasteboard-progressinfo.md) | Pasteboard_ProgressInfo | Defines a struct for the progress information.|
30| [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) | Pasteboard_GetDataParams | Defines a struct for the parameters required for obtaining the pasteboard data and paste progress.|
31| [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) | OH_PasteboardObserver | Defines a struct for the pasteboard observer.|
32| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) | OH_Pasteboard | Defines a struct for the pasteboard object to operate the system pasteboard.|
33
34### Enums
35
36| Name| typedef Keyword| Description|
37| -- | -- | -- |
38| [Pasteboard_NotifyType](#pasteboard_notifytype) | Pasteboard_NotifyType | Enumerates the data change types of the pasteboard.|
39| [Pasteboard_FileConflictOptions](#pasteboard_fileconflictoptions) | Pasteboard_FileConflictOptions | Enumerates the options used to resolve file copy conflicts.|
40| [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) | Pasteboard_ProgressIndicator | Enumerates the progress indicator options. You can use the default progress indicator as required.|
41
42### Functions
43
44| Name| typedef Keyword| Description|
45| -- | -- | -- |
46| [typedef void (\*OH_Pasteboard_ProgressListener)(Pasteboard_ProgressInfo* progressInfo)](#oh_pasteboard_progresslistener) | OH_Pasteboard_ProgressListener | Defines a callback to be invoked to obtain the progress information when the default progress indicator is not used.|
47| [typedef void (\*Pasteboard_Notify)(void* context, Pasteboard_NotifyType type)](#pasteboard_notify) | Pasteboard_Notify | Defines a callback to be invoked when the pasteboard content changes.|
48| [typedef void (\*Pasteboard_Finalize)(void* context)](#pasteboard_finalize) | Pasteboard_Finalize | Defines a callback to be invoked to release the context when the pasteboard observer object is destroyed.|
49| [OH_PasteboardObserver* OH_PasteboardObserver_Create()](#oh_pasteboardobserver_create) | - | Creates an [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) instance and a pointer to it.|
50| [int OH_PasteboardObserver_Destroy(OH_PasteboardObserver* observer)](#oh_pasteboardobserver_destroy) | - | Destroys the [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) instance.|
51| [int OH_PasteboardObserver_SetData(OH_PasteboardObserver* observer, void* context,const Pasteboard_Notify callback, const Pasteboard_Finalize finalize)](#oh_pasteboardobserver_setdata) | - | Sets a callback for the pasteboard observer.|
52| [OH_Pasteboard* OH_Pasteboard_Create()](#oh_pasteboard_create) | - | Creates an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance and a pointer to it.|
53| [void OH_Pasteboard_Destroy(OH_Pasteboard* pasteboard)](#oh_pasteboard_destroy) | - | Destroys the [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
54| [int OH_Pasteboard_Subscribe(OH_Pasteboard* pasteboard, int type, const OH_PasteboardObserver* observer)](#oh_pasteboard_subscribe) | - | Subscribes to the pasteboard observer.|
55| [int OH_Pasteboard_Unsubscribe(OH_Pasteboard* pasteboard, int type, const OH_PasteboardObserver* observer)](#oh_pasteboard_unsubscribe) | - | Unsubscribes from the pasteboard observer.|
56| [bool OH_Pasteboard_IsRemoteData(OH_Pasteboard* pasteboard)](#oh_pasteboard_isremotedata) | - | Checks whether the pasteboard data comes from remote devices.|
57| [int OH_Pasteboard_GetDataSource(OH_Pasteboard* pasteboard, char* source, unsigned int len)](#oh_pasteboard_getdatasource) | - | Obtains the pasteboard data source.|
58| [bool OH_Pasteboard_HasType(OH_Pasteboard* pasteboard, const char* type)](#oh_pasteboard_hastype) | - | Checks whether the pasteboard contains data of the specified type.|
59| [bool OH_Pasteboard_HasData(OH_Pasteboard* pasteboard)](#oh_pasteboard_hasdata) | - | Checks whether the pasteboard contains data.|
60| [OH_UdmfData* OH_Pasteboard_GetData(OH_Pasteboard* pasteboard, int* status)](#oh_pasteboard_getdata) | - | Obtains data from the pasteboard.|
61| [int OH_Pasteboard_SetData(OH_Pasteboard* pasteboard, OH_UdmfData* data)](#oh_pasteboard_setdata) | - | Sets the unified data object in the OH_Pasteboard instance.|
62| [int OH_Pasteboard_ClearData(OH_Pasteboard* pasteboard)](#oh_pasteboard_cleardata) | - | Clears data from the pasteboard.|
63| [char **OH_Pasteboard_GetMimeTypes(OH_Pasteboard *pasteboard, unsigned int *count)](#oh_pasteboard_getmimetypes) | - | Obtains the MIME types from the pasteboard.|
64| [Pasteboard_GetDataParams *OH_Pasteboard_GetDataParams_Create(void)](#oh_pasteboard_getdataparams_create) | - | Creates a [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance and a pointer to it.|
65| [void OH_Pasteboard_GetDataParams_Destroy(Pasteboard_GetDataParams* params)](#oh_pasteboard_getdataparams_destroy) | - | Destroys the [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance.|
66| [void OH_Pasteboard_GetDataParams_SetProgressIndicator(Pasteboard_GetDataParams* params,Pasteboard_ProgressIndicator progressIndicator)](#oh_pasteboard_getdataparams_setprogressindicator) | - | Sets a progress indicator in [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md). You can use the default progress indicator as required.|
67| [void OH_Pasteboard_GetDataParams_SetDestUri(Pasteboard_GetDataParams* params, const char* destUri, uint32_t destUriLen)](#oh_pasteboard_getdataparams_setdesturi) | - | Sets the destination URI in a [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance for copying files. If file processing is not supported, this parameter is not required. If the application involves complex file processing policies or needs to distinguish file multipathing storage, you are advised not to set this parameter but let the application copies files by itself.|
68| [void OH_Pasteboard_GetDataParams_SetFileConflictOptions(Pasteboard_GetDataParams* params,Pasteboard_FileConflictOptions option)](#oh_pasteboard_getdataparams_setfileconflictoptions) | - | Sets the options used to resolve file copy conflicts in a [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance.|
69| [void OH_Pasteboard_GetDataParams_SetProgressListener(Pasteboard_GetDataParams* params,const OH_Pasteboard_ProgressListener listener)](#oh_pasteboard_getdataparams_setprogresslistener) | - | Sets a progress listener in a [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance.|
70| [int OH_Pasteboard_ProgressInfo_GetProgress(Pasteboard_ProgressInfo* progressInfo)](#oh_pasteboard_progressinfo_getprogress) | - | Obtains the paste progress in a [Pasteboard_ProgressInfo](capi-pasteboard-progressinfo.md) instance.|
71| [void OH_Pasteboard_ProgressCancel(Pasteboard_GetDataParams* params)](#oh_pasteboard_progresscancel) | - | Cancels the ongoing paste operation when the pasteboard data is obtained.|
72| [OH_UdmfData* OH_Pasteboard_GetDataWithProgress(OH_Pasteboard* pasteboard, Pasteboard_GetDataParams* params,int* status)](#oh_pasteboard_getdatawithprogress) | - | Obtains the pasteboard data and paste progress. Folders cannot be copied.|
73| [uint32_t OH_Pasteboard_GetChangeCount(OH_Pasteboard *pasteboard)](#oh_pasteboard_getchangecount) | - | Obtains the number of pasteboard content changes.|
74
75## Enum Description
76
77### Pasteboard_NotifyType
78
79```
80enum Pasteboard_NotifyType
81```
82
83**Description**
84
85Enumerates the data change types of the pasteboard.
86
87**Since**: 13
88
89| Enum Item| Description|
90| -- | -- |
91| NOTIFY_LOCAL_DATA_CHANGE = 1 | The pasteboard data of the local device is changed.|
92| NOTIFY_REMOTE_DATA_CHANGE = 2 | The pasteboard data of a non-local device on the network is changed.|
93
94### Pasteboard_FileConflictOptions
95
96```
97enum Pasteboard_FileConflictOptions
98```
99
100**Description**
101
102Enumerates the options used to resolve file copy conflicts.
103
104**Since**: 15
105
106| Enum Item| Description|
107| -- | -- |
108| PASTEBOARD_OVERWRITE = 0 | Overwrites the file with the same name in the destination directory.|
109| PASTEBOARD_SKIP = 1 | Skips the file if there is a file with the same name in the destination directory.|
110
111### Pasteboard_ProgressIndicator
112
113```
114enum Pasteboard_ProgressIndicator
115```
116
117**Description**
118
119Enumerates the progress indicator options. You can use the default progress indicator as required.
120
121**Since**: 15
122
123| Enum Item| Description|
124| -- | -- |
125| PASTEBOARD_NONE = 0 | The default progress indicator is not used.|
126| PASTEBOARD_DEFAULT = 1 | The default progress indicator is used.|
127
128
129## Function Description
130
131### OH_Pasteboard_ProgressListener()
132
133```
134typedef void (*OH_Pasteboard_ProgressListener)(Pasteboard_ProgressInfo* progressInfo)
135```
136
137**Description**
138
139Defines a callback to be invoked to obtain the progress information when the default progress indicator is not used.
140
141**Since**: 15
142
143
144**Parameters**
145
146| Name| Description|
147| -- | -- |
148| [Pasteboard_ProgressInfo](capi-pasteboard-progressinfo.md)* progressInfo | A struct for the progress information. This information is reported only when [Pasteboard_ProgressInfo](capi-pasteboard-progressinfo.md) is set to **NONE**.|
149
150### Pasteboard_Notify()
151
152```
153typedef void (*Pasteboard_Notify)(void* context, Pasteboard_NotifyType type)
154```
155
156**Description**
157
158Defines a callback to be invoked when the pasteboard content changes.
159
160**Since**: 13
161
162
163**Parameters**
164
165| Name| Description|
166| -- | -- |
167| void* context | Context information, which is passed by the [OH_PasteboardObserver_SetData](capi-oh-pasteboard-h.md#oh_pasteboardobserver_setdata) function.|
168| [Pasteboard_NotifyType](capi-oh-pasteboard-h.md#pasteboard_notifytype) type | Data change type. For details, see [Pasteboard_NotifyType](capi-oh-pasteboard-h.md#pasteboard_notifytype).|
169
170### Pasteboard_Finalize()
171
172```
173typedef void (*Pasteboard_Finalize)(void* context)
174```
175
176**Description**
177
178Defines a callback to be invoked to release the context when the pasteboard observer object is destroyed.
179
180**Since**: 13
181
182
183**Parameters**
184
185| Name| Description|
186| -- | -- |
187| void* context | Pointer to the context to release.|
188
189### OH_PasteboardObserver_Create()
190
191```
192OH_PasteboardObserver* OH_PasteboardObserver_Create()
193```
194
195**Description**
196
197Creates an [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) instance and a pointer to it.
198
199**Since**: 13
200
201**Returns**
202
203| Type| Description|
204| -- | -- |
205| [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md)* | Returns a pointer to the [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) instance created if the operation is successful; returns **nullptr** otherwise.<br> If this pointer is no longer required, use [OH_PasteboardObserver_Destroy](capi-oh-pasteboard-h.md#oh_pasteboardobserver_destroy) to destroy it. Otherwise, memory leaks may occur.|
206
207### OH_PasteboardObserver_Destroy()
208
209```
210int OH_PasteboardObserver_Destroy(OH_PasteboardObserver* observer)
211```
212
213**Description**
214
215Destroys the [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) instance.
216
217**Since**: 13
218
219
220**Parameters**
221
222| Name| Description|
223| -- | -- |
224| [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md)* observer | Pointer to an [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) instance.|
225
226**Returns**
227
228| Type| Description                                                                                                                                                                                                                                 |
229| -- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
230| int | Error code. For details about the error codes, see [PASTEBOARD_ErrCode](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode).<br>         Returns [ERR_OK](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if the operation is successful.<br>         Returns [ERR_INVALID_PARAMETER](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if an invalid parameter is passed in.|
231
232### OH_PasteboardObserver_SetData()
233
234```
235int OH_PasteboardObserver_SetData(OH_PasteboardObserver* observer, void* context,const Pasteboard_Notify callback, const Pasteboard_Finalize finalize)
236```
237
238**Description**
239
240Sets a callback for the pasteboard observer.
241
242**Since**: 13
243
244
245**Parameters**
246
247| Name                                                             | Description|
248|------------------------------------------------------------------| -- |
249| [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md)* observer | Pointer to an [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) instance.|
250| void* context                                                    | Pointer to the context, which is passed to [Pasteboard_Notify](capi-oh-pasteboard-h.md#pasteboard_notify) as the first parameter.|
251| const [Pasteboard_Notify](capi-oh-pasteboard-h.md#pasteboard_notify) callback           | Callback to be invoked when the data changes. For details, see [Pasteboard_Notify](capi-oh-pasteboard-h.md#pasteboard_notify).|
252| const [Pasteboard_Finalize](capi-oh-pasteboard-h.md#pasteboard_finalize) finalize                               | Optional callback, which can be used to release context data when the pasteboard observer is destroyed. For details, see [Pasteboard_Finalize](capi-oh-pasteboard-h.md#pasteboard_finalize).|
253
254**Returns**
255
256| Type| Description|
257| -- | -- |
258| int | Error code. For details about the error codes, see [PASTEBOARD_ErrCode](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode).<br>         Returns [ERR_OK](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if the operation is successful.<br>         Returns [ERR_INVALID_PARAMETER](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if an invalid parameter is passed in.|
259
260### OH_Pasteboard_Create()
261
262```
263OH_Pasteboard* OH_Pasteboard_Create()
264```
265
266**Description**
267
268Creates an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance and a pointer to it.
269
270**Since**: 13
271
272**Returns**
273
274| Type| Description|
275| -- | -- |
276| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* | Returns a pointer to the [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance created if the operation is successful; returns **nullptr** otherwise.|
277
278### OH_Pasteboard_Destroy()
279
280```
281void OH_Pasteboard_Destroy(OH_Pasteboard* pasteboard)
282```
283
284**Description**
285
286Destroys the [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.
287
288**Since**: 13
289
290
291**Parameters**
292
293| Name| Description|
294| -- | -- |
295| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
296
297### OH_Pasteboard_Subscribe()
298
299```
300int OH_Pasteboard_Subscribe(OH_Pasteboard* pasteboard, int type, const OH_PasteboardObserver* observer)
301```
302
303**Description**
304
305Subscribes to the pasteboard observer.
306
307**Since**: 13
308
309
310**Parameters**
311
312| Name| Description|
313| -- | -- |
314| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
315| int type | Subscribed data change type of the pasteboard. For details, see [Pasteboard_NotifyType](capi-oh-pasteboard-h.md#pasteboard_notifytype).|
316| const [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md)* observer | Pointer to an [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) instance. It specifies the callback to be invoked when the pasteboard data changes. For details, see [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md).|
317
318**Returns**
319
320| Type| Description|
321| -- | -- |
322| int | Error code. For details about the error codes, see [PASTEBOARD_ErrCode](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode).<br>         Returns [ERR_OK](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if the operation is successful.<br>         Returns [ERR_INVALID_PARAMETER](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if an invalid parameter is passed in.|
323
324### OH_Pasteboard_Unsubscribe()
325
326```
327int OH_Pasteboard_Unsubscribe(OH_Pasteboard* pasteboard, int type, const OH_PasteboardObserver* observer)
328```
329
330**Description**
331
332Unsubscribes from the pasteboard observer.
333
334**Since**: 13
335
336
337**Parameters**
338
339| Name| Description|
340| -- | -- |
341| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
342| int type | Subscribed data change type of the pasteboard. For details, see [Pasteboard_NotifyType](capi-oh-pasteboard-h.md#pasteboard_notifytype).|
343| const [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md)* observer | Pointer to an [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md) instance. It specifies the callback to be invoked when the pasteboard data changes. For details, see [OH_PasteboardObserver](capi-pasteboard-oh-pasteboardobserver.md).|
344
345**Returns**
346
347| Type| Description|
348| -- | -- |
349| int | Error code. For details about the error codes, see [PASTEBOARD_ErrCode](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode).<br>         Returns [ERR_OK](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if the operation is successful.<br>         Returns [ERR_INVALID_PARAMETER](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if an invalid parameter is passed in.|
350
351### OH_Pasteboard_IsRemoteData()
352
353```
354bool OH_Pasteboard_IsRemoteData(OH_Pasteboard* pasteboard)
355```
356
357**Description**
358
359Checks whether the pasteboard data comes from remote devices.
360
361**Since**: 13
362
363
364**Parameters**
365
366| Name| Description|
367| -- | -- |
368| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
369
370**Returns**
371
372| Type| Description|
373| -- | -- |
374| bool | Returns a Boolean value indicating whether the data is from a remote device. The value **true** means the data is from a remote device; **false** means the data is from the local device.|
375
376### OH_Pasteboard_GetDataSource()
377
378```
379int OH_Pasteboard_GetDataSource(OH_Pasteboard* pasteboard, char* source, unsigned int len)
380```
381
382**Description**
383
384Obtains the pasteboard data source.
385
386**Since**: 13
387
388
389**Parameters**
390
391| Name| Description|
392| -- | -- |
393| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
394| char* source | Pointer to the pasteboard data source instance. You need to allocate the memory for the pointer before calling this API.|
395| unsigned int len | Memory length corresponding to the source. If the memory length is insufficient, the API call will fail. The recommended length is 128.|
396
397**Returns**
398
399| Type| Description|
400| -- | -- |
401| int | Error code. For details about the error codes, see [PASTEBOARD_ErrCode](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode).<br>         Returns [ERR_OK](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if the operation is successful.<br>         Returns [ERR_INVALID_PARAMETER](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if an invalid parameter is passed in.|
402
403### OH_Pasteboard_HasType()
404
405```
406bool OH_Pasteboard_HasType(OH_Pasteboard* pasteboard, const char* type)
407```
408
409**Description**
410
411Checks whether the pasteboard contains data of the specified type.
412
413**Since**: 13
414
415
416**Parameters**
417
418| Name| Description|
419| -- | -- |
420| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
421| const char* type | Data type to be checked, which is classified into basic types and custom types. The basic data types include text/plain, text/html, text/uri, text/want, and pixelMap.|
422
423**Returns**
424
425| Type| Description|
426| -- | -- |
427| bool | Returns a Boolean value indicating whether the pasteboard contains data of the specified type. The value **true** means the pasteboard contains data of the specified type; the value **false** means the opposite.|
428
429### OH_Pasteboard_HasData()
430
431```
432bool OH_Pasteboard_HasData(OH_Pasteboard* pasteboard)
433```
434
435**Description**
436
437Checks whether the pasteboard contains data.
438
439**Since**: 13
440
441
442**Parameters**
443
444| Name| Description|
445| -- | -- |
446| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
447
448**Returns**
449
450| Type| Description|
451| -- | -- |
452| bool | Returns a Boolean value indicating whether the pasteboard contains data. The value **true** means the pasteboard contains data; the value **false** means the opposite.|
453
454### OH_Pasteboard_GetData()
455
456```
457OH_UdmfData* OH_Pasteboard_GetData(OH_Pasteboard* pasteboard, int* status)
458```
459
460**Description**
461
462Obtains data from the pasteboard.
463
464**Since**: 13
465
466
467**Parameters**
468
469| Name| Description|
470| -- | -- |
471| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
472| int* status | Output parameter, indicating the error code of the operation. For details about the error codes, see [PASTEBOARD_ErrCode](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode).|
473
474**Returns**
475
476| Type| Description|
477| -- | -- |
478| [OH_UdmfData](../apis-arkdata/capi-udmf-oh-udmfdata.md)* | Returns the pointer to an [OH_UdmfData](../apis-arkdata/capi-udmf-oh-udmfdata.md) instance obtained if the operation is successful; returns a null pointer otherwise.|
479
480### OH_Pasteboard_SetData()
481
482```
483int OH_Pasteboard_SetData(OH_Pasteboard* pasteboard, OH_UdmfData* data)
484```
485
486**Description**
487
488Sets the unified data object in the OH_Pasteboard instance.
489
490**Since**: 13
491
492
493**Parameters**
494
495| Name| Description|
496| -- | -- |
497| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
498| [OH_UdmfData](../apis-arkdata/capi-udmf-oh-udmfdata.md)* data | Pointer to an [OH_UdmfData](../apis-arkdata/capi-udmf-oh-udmfdata.md) instance.|
499
500**Returns**
501
502| Type| Description|
503| -- | -- |
504| int | Error code. For details about the error codes, see [PASTEBOARD_ErrCode](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode).<br>         Returns [ERR_OK](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if the operation is successful.<br>         Returns [ERR_INVALID_PARAMETER](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if an invalid parameter is passed in.|
505
506### OH_Pasteboard_ClearData()
507
508```
509int OH_Pasteboard_ClearData(OH_Pasteboard* pasteboard)
510```
511
512**Description**
513
514Clears data from the pasteboard.
515
516**Since**: 13
517
518
519**Parameters**
520
521| Name| Description|
522| -- | -- |
523| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
524
525**Returns**
526
527| Type| Description|
528| -- | -- |
529| int | Error code. For details about the error codes, see [PASTEBOARD_ErrCode](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode).<br>         Returns [ERR_OK](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if the operation is successful.<br>         Returns [ERR_INVALID_PARAMETER](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode) if an invalid parameter is passed in.|
530
531### OH_Pasteboard_GetMimeTypes()
532
533```
534char **OH_Pasteboard_GetMimeTypes(OH_Pasteboard *pasteboard, unsigned int *count)
535```
536
537**Description**
538
539Obtains the MIME types from the pasteboard.
540
541**Since**: 14
542
543
544**Parameters**
545
546| Name| Description|
547| -- | -- |
548| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) *pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
549| unsigned int *count | Pointer to the number of MIME types obtained.|
550
551**Returns**
552
553| Type| Description|
554| -- | -- |
555| char | Returns the MIME types obtained if the operation is successful; returns **nullptr** otherwise.|
556
557### OH_Pasteboard_GetDataParams_Create()
558
559```
560Pasteboard_GetDataParams *OH_Pasteboard_GetDataParams_Create(void)
561```
562
563**Description**
564
565Creates a [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance and a pointer to it.
566
567**Since**: 15
568
569**Returns**
570
571| Type| Description|
572| -- | -- |
573| [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) | Returns a pointer to the [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance created if the operation is successful; returns **nullptr** otherwise. If this pointer is no longer required,<br> use [OH_Pasteboard_GetDataParams_Destroy](capi-oh-pasteboard-h.md#oh_pasteboard_getdataparams_destroy) to destroy it. Otherwise, memory leaks may occur.|
574
575### OH_Pasteboard_GetDataParams_Destroy()
576
577```
578void OH_Pasteboard_GetDataParams_Destroy(Pasteboard_GetDataParams* params)
579```
580
581**Description**
582
583Destroys the [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance.
584
585**Since**: 15
586
587
588**Parameters**
589
590| Name| Description|
591| -- | -- |
592| [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md)* params | Pointer to an **OH_Pasteboard_GetDataParams** instance.|
593
594### OH_Pasteboard_GetDataParams_SetProgressIndicator()
595
596```
597void OH_Pasteboard_GetDataParams_SetProgressIndicator(Pasteboard_GetDataParams* params,Pasteboard_ProgressIndicator progressIndicator)
598```
599
600**Description**
601
602Sets a progress indicator in [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md). You can use the default progress indicator as required.
603
604**Since**: 15
605
606
607**Parameters**
608
609| Name| Description|
610| -- | -- |
611| [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md)* params | Pointer to an **OH_Pasteboard_GetDataParams** instance.|
612| [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) progressIndicator | Progress indicator to set.|
613
614### OH_Pasteboard_GetDataParams_SetDestUri()
615
616```
617void OH_Pasteboard_GetDataParams_SetDestUri(Pasteboard_GetDataParams* params, const char* destUri, uint32_t destUriLen)
618```
619
620**Description**
621
622Sets the destination URI for copying files. If file processing is not supported, this parameter is not required. If the application involves complex file processing policies or needs to distinguish file multipathing storage, you are advised not to set this parameter but let the application copies files by itself.
623
624**Since**: 15
625
626
627**Parameters**
628
629| Name| Description|
630| -- | -- |
631| [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md)* params | Pointer to an **OH_Pasteboard_GetDataParams** instance.|
632| const char* destUri | Destination URI of the copied file.|
633| uint32_t destUriLen | Length of the destination URI of the copied file.|
634
635### OH_Pasteboard_GetDataParams_SetFileConflictOptions()
636
637```
638void OH_Pasteboard_GetDataParams_SetFileConflictOptions(Pasteboard_GetDataParams* params,Pasteboard_FileConflictOptions option)
639```
640
641**Description**
642
643Sets the options used to resolve file copy conflicts in a [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance.
644
645**Since**: 15
646
647
648**Parameters**
649
650| Name| Description|
651| -- | -- |
652| [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md)* params | Pointer to an **OH_Pasteboard_GetDataParams** instance.|
653| [Pasteboard_FileConflictOptions](#pasteboard_fileconflictoptions) option | Options used to resolve file copy conflicts. The default value is **PASTEBOARD_OVERWRITE**.|
654
655### OH_Pasteboard_GetDataParams_SetProgressListener()
656
657```
658void OH_Pasteboard_GetDataParams_SetProgressListener(Pasteboard_GetDataParams* params,const OH_Pasteboard_ProgressListener listener)
659```
660
661**Description**
662
663Sets a progress listener in a [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md) instance.
664
665**Since**: 15
666
667
668**Parameters**
669
670| Name                                                                             | Description|
671|----------------------------------------------------------------------------------| -- |
672| [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md)* params             | Pointer to an **OH_Pasteboard_GetDataParams** instance.|
673| const [OH_Pasteboard_ProgressListener](#oh_pasteboard_progresslistener) listener | Progress listener.|
674
675### OH_Pasteboard_ProgressInfo_GetProgress()
676
677```
678int OH_Pasteboard_ProgressInfo_GetProgress(Pasteboard_ProgressInfo* progressInfo)
679```
680
681**Description**
682
683Obtains the paste progress in a [Pasteboard_ProgressInfo](capi-pasteboard-progressinfo.md) instance.
684
685**Since**: 15
686
687
688**Parameters**
689
690| Name| Description|
691| -- | -- |
692| [Pasteboard_ProgressInfo](capi-pasteboard-progressinfo.md)* progressInfo | Pointer to a [Pasteboard_ProgressInfo](capi-pasteboard-progressinfo.md) instance.|
693
694**Returns**
695
696| Type| Description|
697| -- | -- |
698| int | Percentage of the paste progress.|
699
700### OH_Pasteboard_ProgressCancel()
701
702```
703void OH_Pasteboard_ProgressCancel(Pasteboard_GetDataParams* params)
704```
705
706**Description**
707
708Cancels the ongoing paste operation when the pasteboard data is obtained.
709
710**Since**: 15
711
712
713**Parameters**
714
715| Name| Description|
716| -- | -- |
717| [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md)* params | Pointer to an **OH_Pasteboard_GetDataParams** instance.|
718
719### OH_Pasteboard_GetDataWithProgress()
720
721```
722OH_UdmfData* OH_Pasteboard_GetDataWithProgress(OH_Pasteboard* pasteboard, Pasteboard_GetDataParams* params,int* status)
723```
724
725**Description**
726
727Obtains the pasteboard data and paste progress. Folders cannot be copied.
728
729**Since**: 15
730
731
732**Parameters**
733
734| Name| Description|
735| -- | -- |
736| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md)* pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
737| [Pasteboard_GetDataParams](capi-pasteboard-getdataparams.md)* params | Pointer to an **OH_Pasteboard_GetDataParams** instance.|
738| int* status | Output parameter, indicating the error code of the operation. For details about the error codes, see [PASTEBOARD_ErrCode](capi-oh-pasteboard-err-code-h.md#pasteboard_errcode).|
739
740**Returns**
741
742| Type| Description|
743| -- | -- |
744| [OH_UdmfData](../apis-arkdata/capi-udmf-oh-udmfdata.md)* | Returns the pointer to an **OH_PasteData** instance obtained if the operation is successful; returns a null pointer otherwise.|
745
746### OH_Pasteboard_GetChangeCount()
747
748```
749uint32_t OH_Pasteboard_GetChangeCount(OH_Pasteboard *pasteboard)
750```
751
752**Description**
753
754Obtains the number of pasteboard content changes.
755
756**Since**: 18
757
758
759**Parameters**
760
761| Name| Description|
762| -- | -- |
763| [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) *pasteboard | Pointer to an [OH_Pasteboard](capi-pasteboard-oh-pasteboard.md) instance.|
764
765**Returns**
766
767| Type| Description|
768| -- | -- |
769| uint32_t | Returns the number of pasteboard content changes if this API is called successfully; otherwise, returns **0**.<br> Even though the pasteboard data expires, or the data becomes empty because of the called **OH_Pasteboard_ClearData** API, the number of data changes remains.<br> When the system is restarted, or the pasteboard service is restarted due to an exception, the number of pasteboard data changes counts from 0. In addition, copying the same data repeatedly is considered to change the data for multiple times. Therefore, each time the data is copied, the number of data changes increases.|
770