oh_pasteboard.h

Overview

Provides data structure, enum types, and APIs for accessing the system pasteboard.

Library: libpasteboard.so

File to include: <database/pasteboard/oh_pasteboard.h>

System capability: SystemCapability.MiscServices.Pasteboard

Since: 13

Related module: Pasteboard

Summary

Types

Name Description
typedef enum Pasteboard_NotifyType Pasteboard_NotifyType Defines an enum for the data change types of the pasteboard.
typedef void(* Pasteboard_Notify) (void *context, Pasteboard_NotifyType type) Defines a callback to be invoked when the pasteboard content changes.
typedef void(* Pasteboard_Finalize) (void *context) Defines a callback to be invoked to release the context when the pasteboard observer object is destroyed.
typedef struct OH_PasteboardObserver OH_PasteboardObserver Defines the pasteboard observer.
typedef struct OH_Pasteboard OH_Pasteboard Define the pasteboard object to operate the system pasteboard.

Enums

Name Description
Pasteboard_NotifyType { NOTIFY_LOCAL_DATA_CHANGE = 1, NOTIFY_REMOTE_DATA_CHANGE = 2 } Enumerates the data change types of the pasteboard.

Functions

Name Description
OH_PasteboardObserver * OH_PasteboardObserver_Create () Creates an OH_PasteboardObserver instance and a pointer to it.
int OH_PasteboardObserver_Destroy (OH_PasteboardObserver *observer) Destroys an OH_PasteboardObserver instance.
int OH_PasteboardObserver_SetData (OH_PasteboardObserver *observer, void *context, const Pasteboard_Notify callback, const Pasteboard_Finalize finalize) Sets a callback for the pasteboard observer.
OH_Pasteboard * OH_Pasteboard_Create () Creates an OH_Pasteboard instance and a pointer to it.
void OH_Pasteboard_Destroy (OH_Pasteboard *pasteboard) Destroys an OH_Pasteboard instance.
int OH_Pasteboard_Subscribe (OH_Pasteboard *pasteboard, int type, const OH_PasteboardObserver *observer) Subscribes to the pasteboard observer.
int OH_Pasteboard_Unsubscribe (OH_Pasteboard *pasteboard, int type, const OH_PasteboardObserver *observer) Unsubscribes from the pasteboard observer.
bool OH_Pasteboard_IsRemoteData (OH_Pasteboard *pasteboard) Checks whether the pasteboard data comes from remote devices.
int OH_Pasteboard_GetDataSource (OH_Pasteboard *pasteboard, char *source, unsigned int len) Obtains the pasteboard data source.
bool OH_Pasteboard_HasType (OH_Pasteboard *pasteboard, const char *type) Checks whether the pasteboard contains data of the specified type.
bool OH_Pasteboard_HasData (OH_Pasteboard *pasteboard) Checks whether the pasteboard contains data.
OH_UdmfData * OH_Pasteboard_GetData (OH_Pasteboard *pasteboard, int *status) Obtains data from the pasteboard.
int OH_Pasteboard_SetData (OH_Pasteboard *pasteboard, OH_UdmfData *data) Writes the unified data object to the pasteboard.
int OH_Pasteboard_ClearData (OH_Pasteboard *pasteboard) Clears data from the pasteboard.
char ** OH_Pasteboard_GetMimeTypes (OH_Pasteboard *pasteboard, unsigned int *count) Obtains the MIME type from the pasteboard.