From 9a428e684f47887e4b8b490122c0ff8164228693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=96=87=E9=9F=AC?= Date: Wed, 22 Nov 2023 10:54:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=A4=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 安文韬 --- .../include/relational_store.h | 57 ++++++++++++++++++- .../relational_store/libnative_rdb.ndk.json | 2 + 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index 3a1f47717..a9eb14428 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -746,6 +746,34 @@ Rdb_TableDetails *OH_Rdb_GetTableDetails(Rdb_ProgressDetails *progress, int32_t */ typedef void (*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails); +/** +* @brief The callback function of syncObserver. +* +* @param progressDetails The details of the sync progress. +* @see Rdb_ProgressDetails. +* @since 11 +*/ +typedef void (*Rdb_ProgressCallback)(void *context, Rdb_ProgressDetails *progressDetails); + +/** + * @brief The observer of sync. + * + * @param progressDetails The details of the sync progress. + * @see Rdb_ProgressDetails. + * @since 11 + */ +typedef struct Rdb_ProgressObserver { + /** + * The context of sync observer. + */ + void *context; + + /** + * The callback function of progress observer. + */ + Rdb_ProgressCallback callback; +} Rdb_ProgressObserver; + /** * @brief Sync data to cloud. * @@ -760,7 +788,34 @@ typedef void (*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails); * @since 11 */ int OH_Rdb_CloudSync(OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables[], uint32_t count, - Rdb_SyncCallback *callback); + Rdb_SyncCallback observer); + +/** +* @brief Subscribes to the automatic synchronization progress of an RDB store. +* A callback will be invoked when there is a notification of the automatic synchronization progress. +* +* @param store Indicates the pointer to the target {@Link OH_Rdb_Store} instance. +* @param observer The {@link Rdb_SyncObserver} for the automatic synchornizaiton progress +* @param Indicates the callback invoked to return the automatic synchronization progress. +* @return Returns the status code of the execution. See {@link OH_Rdb_ErrCode}. +* @see OH_Rdb_Store. +* @see Rdb_SyncObserver. +* @since 11 +*/ +int OH_Rdb_SubscribeAutoSyncProgress(OH_Rdb_Store *store, Rdb_ProgressObserver *observer); + +/** +* @brief Unsubscribes from the automatic synchronziation progress of an RDB store. +* +* @param store Indicates the pointer to the target {@Link OH_Rdb_Store} instance. +* @param observer Indicates the {@link Rdb_SyncObserver} callback for the automatic synchornizaiton progress. +* If it is a null pointer, all callbacks for the automatic synchornizaiton progress will be unregistered. +* @return Returns the status code of the execution. See {@link OH_Rdb_ErrCode}. +* @see OH_Rdb_Store. +* @see Rdb_SyncObserver. +* @since 11 +*/ +int OH_Rdb_UnsubscribeAutoSyncProgress(OH_Rdb_Store *store, Rdb_ProgressObserver *observer); #ifdef __cplusplus }; #endif diff --git a/distributeddatamgr/relational_store/libnative_rdb.ndk.json b/distributeddatamgr/relational_store/libnative_rdb.ndk.json index 190d3cbb0..295e40339 100644 --- a/distributeddatamgr/relational_store/libnative_rdb.ndk.json +++ b/distributeddatamgr/relational_store/libnative_rdb.ndk.json @@ -22,6 +22,8 @@ {"name":"OH_Rdb_FindModifyTime"}, {"name":"OH_Rdb_GetTableDetails"}, {"name":"OH_Rdb_CloudSync"}, + {"name": "OH_Rdb_SubscribeAutoSyncProgress"}, + {"name": "OH_Rdb_UnsubscribeAutoSyncProgress"}, {"name":"OH_VBucket_PutAsset"}, {"name":"OH_VBucket_PutAssets"}, {"name":"OH_Data_Asset_SetName"}, -- Gitee From 228bfba8683eff2bd179cf43954300d4ece50cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=96=87=E9=9F=AC?= Date: Wed, 22 Nov 2023 15:01:38 +0800 Subject: [PATCH 2/2] space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 安文韬 --- distributeddatamgr/relational_store/include/relational_store.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index a9eb14428..368ef89c3 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -788,7 +788,7 @@ typedef struct Rdb_ProgressObserver { * @since 11 */ int OH_Rdb_CloudSync(OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables[], uint32_t count, - Rdb_SyncCallback observer); + Rdb_SyncCallback observer); /** * @brief Subscribes to the automatic synchronization progress of an RDB store. -- Gitee