1# Pasteboard 2 3 4## Overview 5 6The **Pasteboard** module supports copying and pasting multiple types of data, including plain text, HTML, URI, and pixel map. 7 8**Since**: 13 9 10 11## Summary 12 13 14### Files 15 16| Name| Description| 17| -------- | -------- | 18| [oh_pasteboard.h](oh__pasteboard_8h.md) | Provides data structure, enum types, and APIs for accessing the system pasteboard.| 19| [oh_pasteboard_err_code.h](oh__pasteboard__err__code_8h.md) | Defines the error code information of the pasteboard.| 20 21 22### Types 23 24| Name| Description| 25| -------- | -------- | 26| typedef enum [Pasteboard_NotifyType](#pasteboard_notifytype) [Pasteboard_NotifyType](#pasteboard_notifytype) | Enumerates the data change types of the pasteboard. | 27| typedef void(\* [Pasteboard_Notify](#pasteboard_notify)) (void \*context, [Pasteboard_NotifyType](#pasteboard_notifytype) type) | Defines a callback to be invoked when the pasteboard content changes. | 28| typedef void(\* [Pasteboard_Finalize](#pasteboard_finalize)) (void \*context) | Defines a callback to be invoked to release the context when the pasteboard observer object is destroyed. | 29| typedef struct [OH_PasteboardObserver](#oh_pasteboardobserver) [OH_PasteboardObserver](#oh_pasteboardobserver) | Defines the pasteboard observer. | 30| typedef struct [OH_Pasteboard](#oh_pasteboard) [OH_Pasteboard](#oh_pasteboard) | Define the pasteboard object to operate the system pasteboard. | 31| typedef enum [PASTEBOARD_ErrCode](#pasteboard_errcode) [PASTEBOARD_ErrCode](#pasteboard_errcode) | Enumerates the error codes. | 32| typedef enum [Pasteboard_FileConflictOptions](#pasteboard_fileconflictoptions) [Pasteboard_FileConflictOptions](#pasteboard_fileconflictoptions) | Defines an enum for options for file copy conflicts.| 33| typedef enum [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) | Defines an enum for progress indicator options. You can use the default progress indicator as required.| 34| typedef struct [Pasteboard_ProgressInfo](#pasteboard_progressinfo) [Pasteboard_ProgressInfo](#pasteboard_progressinfo) | Defines the progress information. This information is reported only when [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) is set to **PASTEBOARD_NONE**.| 35| typedef void (* [OH_Pasteboard_ProgressListener](#oh_pasteboard_progresslistener))([Pasteboard_ProgressInfo](#pasteboard_progressinfo)* progressInfo) | Defines a callback function for obtaining the progress information. If the default progress indicator is not used, you can set this parameter to obtain the pasting progress.| 36| typedef struct [Pasteboard_GetDataParams](#pasteboard_getdataparams) [Pasteboard_GetDataParams](#pasteboard_getdataparams) | Defines a struct for the pasteboard parameters required for displaying progress, including progress indicator options, destination path, and file conflict options.| 37 38 39### Enumerated value 40 41| Name| Description| 42| -------- | -------- | 43| [Pasteboard_NotifyType](#pasteboard_notifytype) { NOTIFY_LOCAL_DATA_CHANGE = 1, NOTIFY_REMOTE_DATA_CHANGE = 2 } | Enumerates the data change types of the pasteboard. | 44| [PASTEBOARD_ErrCode](#pasteboard_errcode) {<br/>ERR_OK = 0, ERR_PERMISSION_ERROR = 201, ERR_INVALID_PARAMETER = 401, ERR_DEVICE_NOT_SUPPORTED = 801,<br/>ERR_INNER_ERROR = 12900000, ERR_BUSY = 12900003, ERR_PASTEBOARD_COPY_FILE_ERROR = 12900007, ERR_PASTEBOARD_PROGRESS_START_ERROR = 12900008, ERR_PASTEBOARD_PROGRESS_ABNORMAL = 12900009, ERR_PASTEBOARD_GET_DATA_FAILED = 12900010,<br/>} | Enumerates the error codes. | 45| [Pasteboard_FileConflictOptions](#pasteboard_fileconflictoptions) { PASTEBOARD_OVERWRITE = 0, PASTEBOARD_SKIP = 1} | Enumerates options for a file copy conflict.| 46| [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) { PASTEBOARD_NONE = 0, PASTEBOARD_DEFAULT = 1 } | Enumerates progress indicator types.| 47 48 49### Functions 50 51| Name| Description| 52| -------- | -------- | 53| [OH_PasteboardObserver](#oh_pasteboardobserver) \* [OH_PasteboardObserver_Create](#oh_pasteboardobserver_create) () | Creates an [OH_PasteboardObserver](#oh_pasteboardobserver) instance and a pointer to it. | 54| int [OH_PasteboardObserver_Destroy](#oh_pasteboardobserver_destroy) ([OH_PasteboardObserver](#oh_pasteboardobserver) \*observer) | Destroys an [OH_PasteboardObserver](#oh_pasteboardobserver) instance. | 55| int [OH_PasteboardObserver_SetData](#oh_pasteboardobserver_setdata) ([OH_PasteboardObserver](#oh_pasteboardobserver) \*observer, void \*context, const [Pasteboard_Notify](#pasteboard_notify) callback, const [Pasteboard_Finalize](#pasteboard_finalize) finalize) | Sets a callback for the pasteboard observer. | 56| [OH_Pasteboard](#oh_pasteboard) \* [OH_Pasteboard_Create](#oh_pasteboard_create) () | Creates an [OH_Pasteboard](#oh_pasteboard) instance and a pointer to it. | 57| void [OH_Pasteboard_Destroy](#oh_pasteboard_destroy) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard) | Destroys an [OH_Pasteboard](#oh_pasteboard) instance. | 58| int [OH_Pasteboard_Subscribe](#oh_pasteboard_subscribe) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard, int type, const [OH_PasteboardObserver](#oh_pasteboardobserver) \*observer) | Subscribes to the pasteboard observer. | 59| int [OH_Pasteboard_Unsubscribe](#oh_pasteboard_unsubscribe) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard, int type, const [OH_PasteboardObserver](#oh_pasteboardobserver) \*observer) | Unsubscribes from the pasteboard observer. | 60| bool [OH_Pasteboard_IsRemoteData](#oh_pasteboard_isremotedata) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard) | Checks whether the pasteboard data comes from remote devices. | 61| int [OH_Pasteboard_GetDataSource](#oh_pasteboard_getdatasource) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard, char \*source, unsigned int len) | Obtains the pasteboard data source. | 62| bool [OH_Pasteboard_HasType](#oh_pasteboard_hastype) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard, const char \*type) | Checks whether the pasteboard contains data of the specified type. | 63| bool [OH_Pasteboard_HasData](#oh_pasteboard_hasdata) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard) | Checks whether the pasteboard contains data. | 64| OH_UdmfData \* [OH_Pasteboard_GetData](#oh_pasteboard_getdata) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard, int \*status) | Obtains data from the pasteboard. | 65| int [OH_Pasteboard_SetData](#oh_pasteboard_setdata) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard, OH_UdmfData \*data) | Writes the unified data object to the pasteboard. | 66| int [OH_Pasteboard_ClearData](#oh_pasteboard_cleardata) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard) | Clears data from the pasteboard. | 67| char ** [OH_Pasteboard_GetMimeTypes](#oh_pasteboard_getmimetypes) ([OH_Pasteboard](#oh_pasteboard) \*pasteboard, unsigned int *count) | Obtains the MIME type from the pasteboard. | 68| [Pasteboard_GetDataParams](#pasteboard_getdataparams) *[OH_Pasteboard_GetDataParams_Create](#oh_pasteboard_getdataparams_create)(void) | Creates a [Pasteboard_GetDataParams](#pasteboard_getdataparams) instance and a pointer to it.| 69| void [OH_Pasteboard_GetDataParams_Destroy](#oh_pasteboard_getdataparams_destroy)([Pasteboard_GetDataParams](#pasteboard_getdataparams)* params) | Destroys a [Pasteboard_GetDataParams](#pasteboard_getdataparams) instance.| 70| void [OH_Pasteboard_GetDataParams_SetProgressIndicator](#oh_pasteboard_getdataparams_setprogressindicator)([Pasteboard_GetDataParams](#pasteboard_getdataparams)* params, [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) progressIndicator) | Sets the progress indication options in [Pasteboard_GetDataParams](#pasteboard_getdataparams). You can use the default progress indicator as required.| 71| void [OH_Pasteboard_GetDataParams_SetDestUri](#oh_pasteboard_getdataparams_setdesturi)([Pasteboard_GetDataParams](#pasteboard_getdataparams)* params, const char* destUri, uint32_t destUriLen) | Sets the destination path in [Pasteboard_GetDataParams](#pasteboard_getdataparams).| 72| void [OH_Pasteboard_GetDataParams_SetFileConflictOptions](#oh_pasteboard_getdataparams_setfileconflictoptions)([Pasteboard_GetDataParams](#pasteboard_getdataparams)* params, [Pasteboard_FileConflictOptions](#pasteboard_fileconflictoptions) option) | Sets the file copy conflict options in [Pasteboard_GetDataParams](#pasteboard_getdataparams).| 73| void [OH_Pasteboard_GetDataParams_SetProgressListener](#oh_pasteboard_getdataparams_setprogresslistener)([Pasteboard_GetDataParams](#pasteboard_getdataparams)* params, const [OH_Pasteboard_ProgressListener](#oh_pasteboard_progresslistener) listener) | Sets a progress listener in [Pasteboard_GetDataParams](#pasteboard_getdataparams).| 74| int [OH_Pasteboard_ProgressInfo_GetProgress](#oh_pasteboard_progressinfo_getprogress)([Pasteboard_ProgressInfo](#pasteboard_progressinfo)* progressInfo) | Obtains the pasting progress using [Pasteboard_ProgressInfo](#pasteboard_progressinfo).| 75| void [OH_Pasteboard_ProgressCancel](#oh_pasteboard_progresscancel)([Pasteboard_GetDataParams](#pasteboard_getdataparams)* params) | Cancels an ongoing copy and paste task using [Pasteboard_GetDataParams](#pasteboard_getdataparams).| 76| OH_UdmfData* [OH_Pasteboard_GetDataWithProgress](#oh_pasteboard_getdatawithprogress)([OH_Pasteboard](#oh_pasteboard)* pasteboard, [Pasteboard_GetDataParams](#pasteboard_getdataparams)* params, int* status) | Obtains the pasteboard data and pasting progress. Folders cannot be copied.| 77 78 79## Type Description 80 81 82### OH_Pasteboard 83 84``` 85typedef struct OH_Pasteboard OH_Pasteboard 86``` 87**Description** 88 89Define the pasteboard object to operate the system pasteboard. 90 91**Since**: 13 92 93 94### OH_PasteboardObserver 95 96``` 97typedef struct OH_PasteboardObserver OH_PasteboardObserver 98``` 99**Description** 100 101Defines the pasteboard observer. 102 103**Since**: 13 104 105 106### PASTEBOARD_ErrCode 107 108``` 109typedef enum PASTEBOARD_ErrCode PASTEBOARD_ErrCode 110``` 111**Description** 112 113Enumerates the error codes. 114 115**Since**: 13 116 117 118### Pasteboard_Finalize 119 120``` 121typedef void(* Pasteboard_Finalize) (void *context) 122``` 123**Description** 124 125Defines a callback to be invoked to release the context when the pasteboard observer object is destroyed. 126 127**Since**: 13 128 129**Parameters** 130 131| Name| Description| 132| -------- | -------- | 133| context | Pointer to the context to release. | 134 135 136### Pasteboard_Notify 137 138``` 139typedef void(* Pasteboard_Notify) (void *context, Pasteboard_NotifyType type) 140``` 141**Description** 142 143Defines a callback to be invoked when the pasteboard content changes. 144 145**Since**: 13 146 147**Parameters** 148 149| Name| Description| 150| -------- | -------- | 151| context | Context, which is passed in by the [OH_PasteboardObserver_SetData](#oh_pasteboardobserver_setdata) function. | 152| type | Data change type. For details, see [Pasteboard_NotifyType](#pasteboard_notifytype). | 153 154 155### Pasteboard_NotifyType 156 157``` 158typedef enum Pasteboard_NotifyType Pasteboard_NotifyType 159``` 160**Description** 161 162Enumerates the data change types of the pasteboard. 163 164**Since**: 13 165 166### Pasteboard_FileConflictOptions 167 168``` 169typedef enum Pasteboard_FileConflictOptions Pasteboard_FileConflictOptions 170``` 171 172**Description** 173 174File conflict options for a copy-and-paste task. The default value is **PASTEBOARD_OVERWRITE**. 175 176**Since**: 15 177 178### Pasteboard_ProgressIndicator 179 180``` 181typedef enum Pasteboard_ProgressIndicator Pasteboard_ProgressIndicator 182``` 183 184**Description** 185 186Defines options for the progress indicator. You can use the default progress indicator as required. 187 188**Since**: 15 189 190### Pasteboard_ProgressInfo 191 192``` 193typedef struct Pasteboard_ProgressInfo Pasteboard_ProgressInfo 194``` 195 196**Description** 197 198Defines the progress information. This information is reported only when [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) is set to **NONE**. 199 200**Since**: 15 201 202### OH_Pasteboard_ProgressListener 203 204``` 205typedef void (*OH_Pasteboard_ProgressListener)(Pasteboard_ProgressInfo* progressInfo); 206``` 207 208**Description** 209 210Notifies the application of the copy and paste task progress when the default progress indicator is not used. 211 212**Since**: 15 213 214**Parameters** 215 216| Name | Type | Description | 217| ------------ | --------------------------------------------------- | ------------------------------------------------------------ | 218| progressInfo | [Pasteboard_ProgressInfo](#pasteboard_progressinfo) | Defines the progress information. This information is reported only when [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) is set to **NONE**.| 219 220### Pasteboard_GetDataParams 221 222``` 223typedef struct Pasteboard_GetDataParams Pasteboard_GetDataParams; 224``` 225 226**Description** 227 228Defines a struct for the pasteboard parameters required for displaying progress, including progress indicator options, destination path, and file conflict options. 229 230**Since**: 15 231 232 233## Enum Description 234 235 236### PASTEBOARD_ErrCode 237 238``` 239enum PASTEBOARD_ErrCode 240``` 241**Description** 242 243Enumerates the error codes. 244 245**Since**: 13 246 247| Value| Description| 248| -------- | -------- | 249| ERR_OK | The operation is successful. | 250| ERR_PERMISSION_ERROR | Permission verification failed. | 251| ERR_INVALID_PARAMETER | Invalid parameter. | 252| ERR_DEVICE_NOT_SUPPORTED | The device capability is not supported. | 253| ERR_INNER_ERROR | Internal error. | 254| ERR_BUSY | System busy. | 255| ERR_PASTEBOARD_COPY_FILE_ERROR | File copying failed.| 256| ERR_PASTEBOARD_PROGRESS_START_ERROR | Progress indicator creation fails when the application uses the system progress indicator.| 257| ERR_PASTEBOARD_PROGRESS_ABNORMAL | Progress reporting is abnormal when the application stops using the system progress indicator.| 258| ERR_PASTEBOARD_GET_DATA_FAILED | Obtaining pasteboard data failed.| 259 260 261### Pasteboard_NotifyType 262 263``` 264enum Pasteboard_NotifyType 265``` 266**Description** 267 268Enumerates the data change types of the pasteboard. 269 270**Since**: 13 271 272| Value| Description| 273| -------- | -------- | 274| NOTIFY_LOCAL_DATA_CHANGE | The pasteboard data of the local device is changed. | 275| NOTIFY_REMOTE_DATA_CHANGE | The pasteboard data of a non-local device on the network is changed. | 276 277### Pasteboard_FileConflictOptions 278 279``` 280enum Pasteboard_FileConflictOptions 281``` 282 283**Description** 284 285Defines options for file copy conflicts. 286 287**Since**: 15 288 289| Value | Description | 290| -------------------- | ------------------------------------------------------------ | 291| PASTEBOARD_OVERWRITE | Overwrites the file with the same name in the destination path. | 292| PASTEBOARD_SKIP | Skips the file with the same name in the destination path. If **SKIP** is set, the pasteboard data of the skipped file is not pasted to the application.| 293 294### Pasteboard_ProgressIndicator 295 296``` 297enum Pasteboard_ProgressIndicator 298``` 299 300**Description** 301 302Defines options for the progress indicator. You can use the default progress indicator as required. 303 304**Since**: 15 305 306| Value | Description | 307| ------------------ | ------------------------ | 308| PASTEBOARD_NONE | The default progress indicator is not used.| 309| PASTEBOARD_DEFAULT | The default progress indicator is used. | 310 311## Function Description 312 313 314### OH_Pasteboard_ClearData() 315 316``` 317int OH_Pasteboard_ClearData (OH_Pasteboard * pasteboard) 318``` 319**Description** 320 321Clears data from the pasteboard. 322 323**Since**: 13 324 325**Parameters** 326 327| Name| Description| 328| -------- | -------- | 329| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 330 331**Returns** 332 333Returns an error code. For details, see [PASTEBOARD_ErrCode](#pasteboard_errcode).<br>Returns **ERR_OK** if the operation is successful.<br>Returns **ERR_INVALID_PARAMETER** if an invalid parameter is passed in. 334 335**See** 336 337[OH_Pasteboard](#oh_pasteboard) 338 339[PASTEBOARD_ErrCode](#pasteboard_errcode) 340 341 342### OH_Pasteboard_Create() 343 344``` 345OH_Pasteboard* OH_Pasteboard_Create () 346``` 347**Description** 348 349Creates an [OH_Pasteboard](#oh_pasteboard) instance and a pointer to it. 350 351**Since**: 13 352 353**Returns** 354 355Returns a pointer to the [OH_Pasteboard](#oh_pasteboard) instance created if the operation is successful; returns **nullptr** otherwise. 356 357**See** 358 359[OH_Pasteboard](#oh_pasteboard) 360 361 362### OH_Pasteboard_Destroy() 363 364``` 365void OH_Pasteboard_Destroy (OH_Pasteboard * pasteboard) 366``` 367**Description** 368 369Destroys an [OH_Pasteboard](#oh_pasteboard) instance. 370 371**Since**: 13 372 373**Parameters** 374 375| Name| Description| 376| -------- | -------- | 377| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 378 379**See** 380 381[OH_Pasteboard](#oh_pasteboard) 382 383 384### OH_Pasteboard_GetData() 385 386``` 387OH_UdmfData* OH_Pasteboard_GetData (OH_Pasteboard * pasteboard, int * status ) 388``` 389**Description** 390 391Obtains data from the pasteboard. 392 393**Since**: 13 394 395**Parameters** 396 397| Name| Description| 398| -------- | -------- | 399| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 400| status | Output parameter, indicating the error code of the operation. For details, see [PASTEBOARD_ErrCode](#pasteboard_errcode). | 401 402**Returns** 403 404Returns a pointer to the **OH_UdmfData** instance obtained if the operation is successful; returns <b>nullptr</b> otherwise. 405 406**See** 407 408[OH_Pasteboard](#oh_pasteboard) 409 410OH_UdmfData 411 412[PASTEBOARD_ErrCode](#pasteboard_errcode) 413 414 415### OH_Pasteboard_GetDataSource() 416 417``` 418int OH_Pasteboard_GetDataSource (OH_Pasteboard * pasteboard, char * source, unsigned int len ) 419``` 420**Description** 421 422Obtains the pasteboard data source. 423 424**Since**: 13 425 426**Parameters** 427 428| Name| Description| 429| -------- | -------- | 430| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 431| source | Output parameter, indicating the source string of the pasteboard data. | 432| len | Output parameter, indicating the length of the data source string. | 433 434**Returns** 435 436Returns an error code. For details, see [PASTEBOARD_ErrCode](#pasteboard_errcode).<br>Returns **ERR_OK** if the operation is successful.<br>Returns **ERR_INVALID_PARAMETER** if an invalid parameter is passed in. 437 438**See** 439 440[OH_Pasteboard](#oh_pasteboard) 441 442[PASTEBOARD_ErrCode](#pasteboard_errcode) 443 444 445### OH_Pasteboard_HasData() 446 447``` 448bool OH_Pasteboard_HasData (OH_Pasteboard * pasteboard) 449``` 450**Description** 451 452Checks whether the pasteboard contains data. 453 454**Since**: 13 455 456**Parameters** 457 458| Name| Description| 459| -------- | -------- | 460| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 461 462**Returns** 463 464Returns a Boolean value indicating whether the pasteboard contains data. The value **true** means the pasteboard contains data; the value **false** means the opposite. 465 466**See** 467 468[OH_Pasteboard](#oh_pasteboard) 469 470 471### OH_Pasteboard_HasType() 472 473``` 474bool OH_Pasteboard_HasType (OH_Pasteboard * pasteboard, const char * type ) 475``` 476**Description** 477 478Checks whether the pasteboard contains data of the specified type. 479 480**Since**: 13 481 482**Parameters** 483 484| Name| Description| 485| -------- | -------- | 486| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 487| type | Data type to be checked. | 488 489**Returns** 490 491Returns 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. 492 493**See** 494 495[OH_Pasteboard](#oh_pasteboard) 496 497 498### OH_Pasteboard_IsRemoteData() 499 500``` 501bool OH_Pasteboard_IsRemoteData (OH_Pasteboard * pasteboard) 502``` 503**Description** 504 505Checks whether the pasteboard data comes from remote devices. 506 507**Since**: 13 508 509**Parameters** 510 511| Name| Description| 512| -------- | -------- | 513| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 514 515**Returns** 516 517Returns a Boolean value indicating whether the data is from a remote device. The value **true** means the data is from a remote device. The value **false** means the data is from the local device. 518 519**See** 520 521[OH_Pasteboard](#oh_pasteboard) 522 523 524### OH_Pasteboard_SetData() 525 526``` 527int OH_Pasteboard_SetData (OH_Pasteboard * pasteboard, OH_UdmfData * data ) 528``` 529**Description** 530 531Writes the unified data object to the pasteboard. 532 533**Since**: 13 534 535**Parameters** 536 537| Name| Description| 538| -------- | -------- | 539| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 540| data | Pointer to an **OH_UdmfData** instance. | 541 542**Returns** 543 544Returns an error code. For details, see [PASTEBOARD_ErrCode](#pasteboard_errcode).<br> Returns **ERR_OK** if the operation is successful.<br> Returns **ERR_INVALID_PARAMETER** if an invalid parameter is passed in. 545 546**See** 547 548[OH_Pasteboard](#oh_pasteboard) 549 550OH_UdmfData 551 552[PASTEBOARD_ErrCode](#pasteboard_errcode) 553 554 555### OH_Pasteboard_Subscribe() 556 557``` 558int OH_Pasteboard_Subscribe (OH_Pasteboard * pasteboard, int type, const OH_PasteboardObserver * observer ) 559``` 560**Description** 561 562Subscribes to the pasteboard observer. 563 564**Since**: 13 565 566**Parameters** 567 568| Name| Description| 569| -------- | -------- | 570| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 571| type | Subscribed data change type of the pasteboard. For details, see [Pasteboard_NotifyType](#pasteboard_notifytype). | 572| observer | Pointer to an [OH_PasteboardObserver](#oh_pasteboardobserver) instance. It specifies the callback to be invoked when the pasteboard data changes. For details, see [OH_PasteboardObserver](#oh_pasteboardobserver). | 573 574**Returns** 575 576Returns an error code. For details, see [PASTEBOARD_ErrCode](#pasteboard_errcode).<br> Returns **ERR_OK** if the operation is successful.<br> Returns **ERR_INVALID_PARAMETER** if an invalid parameter is passed in. 577 578**See** 579 580[OH_Pasteboard](#oh_pasteboard) 581 582[OH_PasteboardObserver](#oh_pasteboardobserver) 583 584[Pasteboard_NotifyType](#pasteboard_notifytype) 585 586[PASTEBOARD_ErrCode](#pasteboard_errcode) 587 588 589### OH_Pasteboard_Unsubscribe() 590 591``` 592int OH_Pasteboard_Unsubscribe (OH_Pasteboard * pasteboard, int type, const OH_PasteboardObserver * observer ) 593``` 594**Description** 595 596Unsubscribes from the pasteboard observer. 597 598**Since**: 13 599 600**Parameters** 601 602| Name| Description| 603| -------- | -------- | 604| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 605| type | Subscribed data change type of the pasteboard. For details, see [Pasteboard_NotifyType](#pasteboard_notifytype). | 606| observer | Pointer to an [OH_PasteboardObserver](#oh_pasteboardobserver) instance. It specifies the callback to be invoked when the pasteboard data changes. For details, see [OH_PasteboardObserver](#oh_pasteboardobserver). | 607 608**Returns** 609 610Returns an error code. For details, see [PASTEBOARD_ErrCode](#pasteboard_errcode).<br> Returns **ERR_OK** if the operation is successful.<br> Returns **ERR_INVALID_PARAMETER** if an invalid parameter is passed in. 611 612**See** 613 614[OH_Pasteboard](#oh_pasteboard) 615 616[OH_PasteboardObserver](#oh_pasteboardobserver) 617 618[Pasteboard_NotifyType](#pasteboard_notifytype) 619 620[PASTEBOARD_ErrCode](#pasteboard_errcode) 621 622 623### OH_PasteboardObserver_Create() 624 625``` 626OH_PasteboardObserver* OH_PasteboardObserver_Create () 627``` 628**Description** 629 630Creates an [OH_PasteboardObserver](#oh_pasteboardobserver) instance and a pointer to it. 631 632**Since**: 13 633 634**Returns** 635 636Returns a pointer to the [OH_PasteboardObserver](#oh_pasteboardobserver) instance created if the operation is successful; returns **nullptr** otherwise. If this pointer is no longer required, use [OH_PasteboardObserver_Destroy](#oh_pasteboardobserver_destroy) to destroy it. Otherwise, memory leaks may occur. 637 638**See** 639 640[OH_PasteboardObserver](#oh_pasteboardobserver) 641 642 643### OH_PasteboardObserver_Destroy() 644 645``` 646int OH_PasteboardObserver_Destroy (OH_PasteboardObserver * observer) 647``` 648**Description** 649 650Destroys an [OH_PasteboardObserver](_pasteboard.md#oh_pasteboardobserver) instance. 651 652**Since**: 13 653 654**Parameters** 655 656| Name| Description| 657| -------- | -------- | 658| observer | Pointer to an [OH_PasteboardObserver](#oh_pasteboardobserver) instance. | 659 660**Returns** 661 662Returns an error code. For details, see [PASTEBOARD_ErrCode](#pasteboard_errcode).<br>Returns **ERR_OK** if the operation is successful.<br>Returns **ERR_INVALID_PARAMETER** if an invalid parameter is passed in. 663 664**See** 665 666[OH_PasteboardObserver](#oh_pasteboardobserver) 667 668[PASTEBOARD_ErrCode](#pasteboard_errcode) 669 670 671### OH_PasteboardObserver_SetData() 672 673``` 674int OH_PasteboardObserver_SetData (OH_PasteboardObserver * observer, void * context, const Pasteboard_Notify callback, const Pasteboard_Finalize finalize ) 675``` 676**Description** 677 678Sets a callback for the pasteboard observer. 679 680**Since**: 13 681 682**Parameters** 683 684| Name| Description| 685| -------- | -------- | 686| observer | Pointer to an [OH_PasteboardObserver](#oh_pasteboardobserver) instance. | 687| context | Pointer to the context data, which is passed to [Pasteboard_Notify](#pasteboard_notify) as the first parameter. | 688| callback | Callback to be invoked when the data changes. For details, see [Pasteboard_Notify](#pasteboard_notify). | 689| finalize | Optional callback, which can be used to release context data when the pasteboard observer is destroyed. For details, see [Pasteboard_Finalize](#pasteboard_finalize). | 690 691**Returns** 692 693Returns an error code. For details, see [PASTEBOARD_ErrCode](#pasteboard_errcode).<br> Returns **ERR_OK** if the operation is successful.<br> Returns **ERR_INVALID_PARAMETER** if an invalid parameter is passed in. 694 695**See** 696 697[OH_PasteboardObserver](#oh_pasteboardobserver) 698 699[Pasteboard_Notify](#pasteboard_notify) 700 701[PASTEBOARD_ErrCode](#pasteboard_errcode) 702 703### OH_Pasteboard_GetMimeTypes() 704 705``` 706char ** OH_Pasteboard_GetMimeTypes (OH_Pasteboard * pasteboard, unsigned int * count) 707``` 708**Description** 709 710Obtains the MIME type from the pasteboard. 711 712**Since**: 14 713 714**Parameters** 715 716| Name| Description| 717| -------- | -------- | 718| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 719| count | Pointer to the number of uniform data types obtained. | 720 721**Returns** 722 723Returns the MIME type obtained if the operation is successful; returns **nullptr** otherwise. 724 725The lifecycle of the object returned by this API is managed by the input parameter object **pasteboard**. When the application calls [OH_Pasteboard_Destroy](#oh_pasteboard_destroy) to destroy **pasteboard**, the result returned by this API is released synchronously. 726 727The **pasteboard** object saves only the latest result and the historical results obtained by the API become invalid. 728 729**See** 730 731[OH_Pasteboard](#oh_pasteboard) 732 733### OH_Pasteboard_GetDataParams_Create() 734 735```c 736Pasteboard_GetDataParams *OH_Pasteboard_GetDataParams_Create(void); 737``` 738 739**Description** 740 741Creates a [Pasteboard_GetDataParams](#pasteboard_getdataparams) instance and a pointer to it. 742 743**Since**: 15 744 745**Returns** 746 747Returns a pointer to the [Pasteboard_GetDataParams](#pasteboard_getdataparams) instance created if the operation is successful; returns **nullptr** otherwise. If this pointer is no longer required, use [OH_Pasteboard_GetDataParams_Destroy](#oh_pasteboard_getdataparams_destroy) to destroy it. Otherwise, memory leaks may occur. 748 749**See** 750 751[Pasteboard_GetDataParams](#pasteboard_getdataparams) 752 753### OH_Pasteboard_GetDataParams_Destroy() 754 755```c 756void OH_Pasteboard_GetDataParams_Destroy(Pasteboard_GetDataParams* params) 757``` 758 759**Description** 760 761Destroys a [Pasteboard_GetDataParams](#pasteboard_getdataparams) instance. 762 763**Since**: 15 764 765**Parameters** 766 767| Name | Description | 768| ------ | ------------------------------------------------------------ | 769| params | Pointer to a [Pasteboard_GetDataParams](#pasteboard_getdataparams) instance.| 770 771**See** 772 773[Pasteboard_GetDataParams](#pasteboard_getdataparams) 774 775### OH_Pasteboard_GetDataParams_SetProgressIndicator() 776 777```c 778void OH_Pasteboard_GetDataParams_SetProgressIndicator(Pasteboard_GetDataParams* params, 779 Pasteboard_ProgressIndicator progressIndicator) 780``` 781 782**Description** 783 784Sets the progress indication options in [Pasteboard_GetDataParams](#pasteboard_getdataparams). You can use the default progress indicator as required. 785 786**Since**: 15 787 788**Parameters** 789 790| Name | Description | 791| ----------------- | ---------------------------------------------------- | 792| params | Pointer to the context data. | 793| progressIndicator | Progress indicator options. You can use the default progress indicator as required.| 794 795**See** 796 797[Pasteboard_GetDataParams](#pasteboard_getdataparams) 798 799[Pasteboard_ProgressIndicator](#pasteboard_progressindicator) 800 801### OH_Pasteboard_GetDataParams_SetDestUri() 802 803```c 804void OH_Pasteboard_GetDataParams_SetDestUri(Pasteboard_GetDataParams* params, const char* destUri, uint32_t destUriLen) 805``` 806 807**Description** 808 809Sets the destination path in [Pasteboard_GetDataParams](#pasteboard_getdataparams) 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. 810 811**Since**: 15 812 813**Parameters** 814 815| Name | Description | 816| ---------- | -------------------------- | 817| params | Pointer to the context data.| 818| destUri | Destination path for copying files.| 819| destUriLen | Length of the destination path. | 820 821**See** 822 823[Pasteboard_GetDataParams](#pasteboard_getdataparams) 824 825[Pasteboard_ProgressIndicator](#pasteboard_progressindicator) 826 827### OH_Pasteboard_GetDataParams_SetFileConflictOptions() 828 829```c 830void OH_Pasteboard_GetDataParams_SetFileConflictOptions(Pasteboard_GetDataParams* params, 831 Pasteboard_FileConflictOptions option) 832``` 833 834**Description** 835 836Sets the file copy conflict options in [Pasteboard_GetDataParams](#pasteboard_getdataparams). The default value is **PASTEBOARD_OVERWRITE**. 837 838**Since**: 15 839 840**Parameters** 841 842| Name | Description | 843| ------ | ------------------------------------------------------ | 844| params | Pointer to the context data. | 845| option | File copy conflict options The default value is **PASTEBOARD_OVERWRITE**.| 846 847**See** 848 849[Pasteboard_GetDataParams](#pasteboard_getdataparams) 850 851[Pasteboard_FileConflictOptions](#pasteboard_fileconflictoptions) 852 853### OH_Pasteboard_GetDataParams_SetProgressListener() 854 855```c 856void OH_Pasteboard_GetDataParams_SetProgressListener(Pasteboard_GetDataParams* params, 857 const OH_Pasteboard_ProgressListener listener) 858``` 859 860**Description** 861 862Sets a progress listener in [Pasteboard_GetDataParams](#pasteboard_getdataparams). 863 864**Since**: 15 865 866**Parameters** 867 868| Name | Description | 869| -------- | ------------------------------------------------------------ | 870| params | Pointer to the context data. | 871| listener | A listener for progress data changes. If the default progress indicator is not used, you can set this parameter to obtain the pasting progress.| 872 873**See** 874 875[Pasteboard_GetDataParams](#pasteboard_getdataparams) 876 877[OH_Pasteboard_ProgressListener](#oh_pasteboard_progresslistener) 878 879### OH_Pasteboard_ProgressInfo_GetProgress() 880 881```c 882int OH_Pasteboard_ProgressInfo_GetProgress(Pasteboard_ProgressInfo* progressInfo) 883``` 884 885**Description** 886 887Obtains the pasting progress using [Pasteboard_ProgressInfo](#pasteboard_progressinfo). Result can be obtained only when [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) is set to **PASTEBOARD_NONE**. 888 889**Since**: 15 890 891**Parameters** 892 893| Name | Description | 894| ------------ | ------------------------------------------------------------ | 895| progressInfo | Defines the progress information. This information is reported only when [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) is set to **PASTEBOARD_NONE**.| 896 897**Returns** 898 899Returns progress percentage of a copy and paste task. 900 901**See** 902 903[Pasteboard_ProgressInfo](#pasteboard_progressinfo) 904 905### OH_Pasteboard_ProgressCancel() 906 907```c 908void OH_Pasteboard_ProgressCancel(Pasteboard_GetDataParams* params); 909``` 910 911**Description** 912 913Cancels an ongoing copy and paste task using [Pasteboard_GetDataParams](#pasteboard_getdataparams). This parameter is valid only when [Pasteboard_ProgressIndicator](#pasteboard_progressindicator) is set to **PASTEBOARD_NONE**. 914 915**Since**: 15 916 917**Parameters** 918 919| Name | Description | 920| ------ | -------------------------- | 921| params | Pointer to the context data.| 922 923**See** 924 925[Pasteboard_GetDataParams](#pasteboard_getdataparams) 926 927### OH_Pasteboard_GetDataWithProgress() 928 929```c 930OH_UdmfData* OH_Pasteboard_GetDataWithProgress(OH_Pasteboard* pasteboard, Pasteboard_GetDataParams* params, int* status); 931``` 932 933**Description** 934 935Obtains the pasteboard content and progress. Folders cannot be copied. 936 937**Since**: 15 938 939**Parameters** 940 941| Name | Description | 942| ---------- | ------------------------------------------------------------ | 943| pasteboard | Pointer to an [OH_Pasteboard](#oh_pasteboard) instance. | 944| params | Parameters required when an application uses the file copy capability provided by the pasteboard. For details, see [Pasteboard_GetDataParams](#pasteboard_getdataparams).| 945| status | Output parameter, indicating the error code of the operation. For details, see [PASTEBOARD_ErrCode](#pasteboard_errcode).| 946 947**Returns** 948 949Returns a pointer to the **OH_UdmfData** instance obtained if the operation is successful; returns <b>nullptr</b> otherwise. 950 951**See** 952 953[Pasteboard_GetDataParams](#pasteboard_getdataparams) 954