From 33faee3b59491b24571725140758b7751e90146c Mon Sep 17 00:00:00 2001 From: sunxuejiao Date: Fri, 22 Nov 2024 15:10:29 +0800 Subject: [PATCH] fix:add pasteboard interface Signed-off-by: sunxuejiao --- .../pasteboard/include/oh_pasteboard.h | 112 ++++++++++++++++++ .../pasteboard/libpasteboard.ndk.json | 4 + 2 files changed, 116 insertions(+) diff --git a/distributeddatamgr/pasteboard/include/oh_pasteboard.h b/distributeddatamgr/pasteboard/include/oh_pasteboard.h index 15d489623..50827bdea 100644 --- a/distributeddatamgr/pasteboard/include/oh_pasteboard.h +++ b/distributeddatamgr/pasteboard/include/oh_pasteboard.h @@ -63,6 +63,104 @@ typedef enum Pasteboard_NotifyType { NOTIFY_REMOTE_DATA_CHANGE = 2 } Pasteboard_NotifyType; +/** + * @brief Enumerates the types of file confilct options when getting data from the Pastedboard. + * + * @since 14 + */ +typedef enum Pasteboard_FileConflictOption { + /** + * @brief Overwrite when destUir has file with same name. + */ + OVERWRITE = 0, + /** + * @brief Skip when destUir has file with same name. + */ + SKIP = 1, + /** + * @brief Rename when destUir has file with same name. + */ + RENAME = 2 +} Pasteboard_FileConflictOption; + +/** + * @brief Enumerates the types of progress indicator when getting data from the Pastedboard. + * + * @since 14 + */ +typedef enum Pasteboard_ProgressIndicator { + /** + * @brief Getting data without system default progress indicator. + */ + NONE = 0, + /** + * @brief Getting data with system default progress indicator. + */ + DEFAULT = 1 +} Pasteboard_ProgressIndicator; + +/** + * @brief Represents the Pasteboard progress information. + * + * @since 14 + */ +typedef struct Pasteboard_ProgressInfo { + int percentage; +} Pasteboard_ProgressInfo; + +/** + * @brief Defines the callback function used to return the progress information when getting OH_UdmfData. + * + * @param progressInfo The progress information notified to Application. + * @since 14 + */ +typedef void (*Pasteboard_ProgressNotify)(Pasteboard_ProgressInfo progressInfo); + +/** + * @brief Represents the Pasteboard progress listener when getting OH_UdmfData. + * + * @since 14 + */ +typedef struct Pasteboard_ProgressListener { + Pasteboard_ProgressNotify callback; +} Pasteboard_ProgressListener; + +/** + * @brief Defines the cancel function used to cancel the progress when getting OH_PasteData. + * + * @since 14 + */ +typedef int (*Pasteboard_ProgressCancel)(); + +/** + * brief Represents the Pasteboard progress signal when getting data. + * + * @since 14 + */ +typedef struct Pasteboard_ProgressSignal { + Pasteboard_ProgressCancel cancel; +} Pasteboard_ProgressSignal; + +/** + * @brief Represents the pasteboard get data parameters when getting data from Pasteboard. + * + * @param destUri Indicates the dest path uri where copy file will be copied to in sandbox of Application. + * @param destUriLen Indicates the length of destUir. + * @param fileConflictOption Indicates fileConflictOption when dest path has file with same name. + * @param progressIndicator Indicates whether to use default system progress indacator. + * @param progressListener Indicates progress listener when getting OH_UdmfData. + * @param progressSignal Indicates progress signal when getting PasteData with system progress indacator. + * @since 14 + */ +typedef struct OH_Pasteboard_GetDataParams { + char *destUri; + unsigned int destUriLen; + Pasteboard_FileConflictOption fileConflictOption; + Pasteboard_ProgressIndicator progressIndicator; + Pasteboard_ProgressListener progressListener; + Pasteboard_ProgressSignal progressSignal; +} OH_Pasteboard_GetDataParams; + /** * @brief Defines the callback function used to return the Pasteboard data changed. * @@ -279,6 +377,20 @@ int OH_Pasteboard_ClearData(OH_Pasteboard* pasteboard); * @since 14 */ char **OH_Pasteboard_GetMimeTypes(OH_Pasteboard *pasteboard, unsigned int *count); + +/** + * @brief Obtains data from the Pasteboard with system progress indicator. + * + * @permission ohos.permission.READ_PASTEBOARD + * @param pasteboard Pointer to the {@link OH_Pasteboard} instance. + * @param params Pointer to indicates the {@link OH_Pasteboard_GetDataParams}. + * @param status The status code of the execution. For details, see {@link PASTEBOARD_Errcode}. + * @return Returns the pointer to the {@link OH_PasteData} instance. + * @see OH_Pasteboard OH_PasteData PASTEBOARD_ErrCode. + * @since 14 + */ +OH_UdmfData *OH_Pasteboard_GetDataWithProgress(OH_Pasteboard *pasteboard, OH_Pasteboard_GetDataParams *params, + int *status); #ifdef __cplusplus }; #endif diff --git a/distributeddatamgr/pasteboard/libpasteboard.ndk.json b/distributeddatamgr/pasteboard/libpasteboard.ndk.json index c47c8a475..4fe55b602 100644 --- a/distributeddatamgr/pasteboard/libpasteboard.ndk.json +++ b/distributeddatamgr/pasteboard/libpasteboard.ndk.json @@ -58,5 +58,9 @@ { "first_introduced": "14", "name": "OH_Pasteboard_GetMimeTypes" + }, + { + "first_introduced": "14", + "name": "OH_Pasteboard_GetDataWithProgress" } ] \ No newline at end of file -- Gitee