From b55b3fb4e1bd02a9c9df46eb05d817c5f0132dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=96=87=E9=9F=AC?= Date: Thu, 25 Jan 2024 14:35:58 +0800 Subject: [PATCH 1/2] add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 安文韬 --- .../include/relational_store.h | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index 1079b1d60..231d1301f 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. * @@ -761,6 +789,33 @@ typedef void (*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails); */ int OH_Rdb_CloudSync(OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables[], uint32_t count, Rdb_SyncCallback *callback); + +/** +* @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 -- Gitee From d7f65c77002bdffff5066c5e916004211b82941d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=96=87=E9=9F=AC?= Date: Thu, 25 Jan 2024 17:49:03 +0800 Subject: [PATCH 2/2] add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 安文韬 --- .../relational_store/include/relational_store.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index 231d1301f..cf301687d 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -747,7 +747,7 @@ Rdb_TableDetails *OH_Rdb_GetTableDetails(Rdb_ProgressDetails *progress, int32_t typedef void (*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails); /** -* @brief The callback function of syncObserver. +* @brief The callback function of progress. * * @param progressDetails The details of the sync progress. * @see Rdb_ProgressDetails. @@ -756,15 +756,13 @@ typedef void (*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails); typedef void (*Rdb_ProgressCallback)(void *context, Rdb_ProgressDetails *progressDetails); /** - * @brief The observer of sync. + * @brief The observer of progress. * - * @param progressDetails The details of the sync progress. - * @see Rdb_ProgressDetails. * @since 11 */ typedef struct Rdb_ProgressObserver { /** - * The context of sync observer. + * The context of progress observer. */ void *context; @@ -796,13 +794,12 @@ int OH_Rdb_CloudSync(OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables[ * * @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. +* @see Rdb_ProgressObserver. * @since 11 */ -int OH_Rdb_SubscribeAutoSyncProgress(OH_Rdb_Store *store, Rdb_ProgressObserver *observer); +int OH_Rdb_SubscribeAutoSyncProgress(OH_Rdb_Store *store, const Rdb_ProgressObserver *observer); /** * @brief Unsubscribes from the automatic synchronziation progress of an RDB store. @@ -812,10 +809,10 @@ int OH_Rdb_SubscribeAutoSyncProgress(OH_Rdb_Store *store, Rdb_ProgressObserver * * 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. +* @see Rdb_ProgressObserver. * @since 11 */ -int OH_Rdb_UnsubscribeAutoSyncProgress(OH_Rdb_Store *store, Rdb_ProgressObserver *observer); +int OH_Rdb_UnsubscribeAutoSyncProgress(OH_Rdb_Store *store, const Rdb_ProgressObserver *observer); #ifdef __cplusplus }; #endif -- Gitee