diff --git a/distributeddatamgr/relational_store/BUILD.gn b/distributeddatamgr/relational_store/BUILD.gn index 01334de44290803b45dd45de94b0f63764523f0e..a720869f7ad9535b58e3c9104cfef3166c6d54e1 100644 --- a/distributeddatamgr/relational_store/BUILD.gn +++ b/distributeddatamgr/relational_store/BUILD.gn @@ -13,6 +13,7 @@ import("//build/ohos.gni") import("//build/ohos/ndk/ndk.gni") +import("//foundation/distributeddatamgr/relational_store/relational_store.gni") ohos_ndk_headers("native_rdb_ndk_header") { dest_dir = "$ndk_headers_out_dir/database/rdb/" @@ -26,13 +27,19 @@ ohos_ndk_headers("native_rdb_ndk_header") { ] } +ohos_ndk_headers("data_ndk_header") { + dest_dir = "$ndk_headers_out_dir/database/data/" + sources = [ "./include/data_asset.h" ] +} + ohos_ndk_library("libnative_rdb_ndk") { output_name = "native_rdb_ndk" system_capability = "SystemCapability.DistributedDataManager.RelationalStore.Core" ndk_description_file = "./libnative_rdb.ndk.json" - min_compact_version = "10" + min_compact_version = "11" system_capability_headers = [ + "$ndk_headers_out_dir/database/data/data_asset.h", "$ndk_headers_out_dir/database/rdb/oh_cursor.h", "$ndk_headers_out_dir/database/rdb/oh_predicates.h", "$ndk_headers_out_dir/database/rdb/oh_value_object.h", diff --git a/distributeddatamgr/relational_store/include/data_asset.h b/distributeddatamgr/relational_store/include/data_asset.h new file mode 100644 index 0000000000000000000000000000000000000000..bbbb71f1267d1c2bae300e38bd8c8dd46c5229b0 --- /dev/null +++ b/distributeddatamgr/relational_store/include/data_asset.h @@ -0,0 +1,317 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DATA_ASSET_H +#define DATA_ASSET_H +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. + * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations + * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @since 11 + */ + +/** + * @file data_asset.h + * + * @brief Provides the data type of asset. + * @library libnative_rdb_ndk.z.so + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 11 + */ +#include +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief Describes the status of asset. + * + * @since 11 + */ +typedef enum Data_AssetStatus { + /** + * @brief Means the status of asset is null. + */ + ASSET_NULL = 0, + + /** + * @brief Means the status of asset is normal. + */ + ASSET_NORMAL, + + /** + * @brief Means the asset needs to be inserted. + */ + ASSET_INSERT, + + /** + * @brief Means the asset needs to be updated. + */ + ASSET_UPDATE, + + /** + * @brief Means the asset needs to be deleted. + */ + ASSET_DELETE, + + /** + * @brief Means the status of asset is abnormal. + */ + ASSET_ABNORMAL, + + /** + * @brief Means the status of asset is downloading. + */ + ASSET_DOWNLOADING +} Data_AssetStatus; + +/** + * @brief Define the Data_Asset structure type. + * + * Provides information of an asset. + * + * @since 11 + */ +typedef struct Data_Asset Data_Asset; + +/** + * @brief Set the name of the Data_Asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param name Indicates the name to set. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetName(Data_Asset *asset, const char *name); + +/** + * @brief Set the uri of the Data_Asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param uri Indicates the uri to set. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetUri(Data_Asset *asset, const char *uri); + +/** + * @brief Set the path of the Data_Asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param path Indicates the path to set. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetPath(Data_Asset *asset, const char *path); + +/** + * @brief Set the create time of the Data_Asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param createTime Indicates the create time to set. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetCreateTime(Data_Asset *asset, int64_t createTime); + +/** + * @brief Set the modify time of the Data_Asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param modifyTime Indicates the create time to set. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetModifyTime(Data_Asset *asset, int64_t modifyTime); + +/** + * @brief Set the size of the Data_Asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param size Indicates the size to set. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_SetSize(Data_Asset *asset, size_t size); + +/** + * @brief Set the status of the Data_Asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param status Indicates the status to set. Specific status can be referenced {@link Data_AssetStatus}. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset, Data_AssetStatus + * @since 11 + */ +int OH_Data_Asset_SetStatus(Data_Asset *asset, Data_AssetStatus status); + +/** + * @brief Obtains the name of the asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param name This parameter is the output parameter, + * and the name of the asset as a char * is written to this variable. + * @param length Indicates the length of the name. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetName(Data_Asset *asset, char *name, size_t *length); + +/** + * @brief Obtains the uri of the asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param uri This parameter is the output parameter, + * and the uri of the asset as a char * is written to this variable. + * @param length Indicates the length of the uri. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetUri(Data_Asset *asset, char *uri, size_t *length); + +/** + * @brief Obtains the path of the asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param path This parameter is the output parameter, + * and the path of the asset as a char * is written to this variable. + * @param length Indicates the length of the path. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetPath(Data_Asset *asset, char *path, size_t *length); + +/** + * @brief Obtains the create time of the asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param createTime This parameter is the output parameter, + * and the create time of the asset as a int64_t is written to this variable. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetCreateTime(Data_Asset *asset, int64_t *createTime); + +/** + * @brief Obtains the modify time of the asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param modifyTime This parameter is the output parameter, + * and the create time of the asset as a int64_t is written to this variable. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetModifyTime(Data_Asset *asset, int64_t *modifyTime); + +/** + * @brief Obtains the size of the asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param size This parameter is the output parameter, + * and the size of the asset as a size_t is written to this variable. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset + * @since 11 + */ +int OH_Data_Asset_GetSize(Data_Asset *asset, size_t *size); + +/** + * @brief Obtains the status of the asset. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @param status This parameter is the output parameter, + * and the size of the status as a {@link Data_AssetStatus} is written to this variable. + * @return Returns a specific error code. + * Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset Data_AssetStatus. + * @since 11 + */ +int OH_Data_Asset_GetStatus(Data_Asset *asset, Data_AssetStatus *status); + +/** + * @brief Creates an {@link Data_Asset} instance. + * + * @return If the creation is successful, a pointer to the instance of the @link Data_Asset} structure is returned, + * otherwise NULL is returned. + * @see Data_Asset. + * @since 11 + */ +Data_Asset *OH_Data_Asset_CreateOne(); + +/** + * @brief Destroy the {@link Data_Asset} object and reclaim the memory occupied by the object. + * + * @param asset Represents a pointer to an {@link Data_Asset} instance. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * while failure returns a specific error code. Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset, OH_Rdb_ErrCode. + * @since 11 + */ +int OH_Data_Asset_DestroyOne(Data_Asset *asset); + +/** + * @brief Creates {@link Data_Asset} instances of given number. + * + * @param count Represents the count of {@link Data_Asset} to create. + * @return If the creation is successful, a pointer to the instance of the @link Data_Asset} structure is returned, + * otherwise NULL is returned. + * @see Data_Asset. + * @since 11 + */ +Data_Asset **OH_Data_Asset_CreateMultiple(uint32_t count); + +/** + * @brief Destroy the {@link Data_Asset} objects and reclaim the memory occupied by the objects. + * + * @param assets Represents a pointer to an {@link Data_Asset} instance. + * @param count Represents the count of {@link Data_Asset} to destroy. + * @return Returns the status code of the execution. Successful execution returns RDB_OK, + * while failure returns a specific error code. Specific error codes can be referenced {@link OH_Rdb_ErrCode}. + * @see Data_Asset, OH_Rdb_ErrCode. + * @since 11 + */ +int OH_Data_Asset_DestroyMultiple(Data_Asset **assets, uint32_t count); +#ifdef __cplusplus +}; +#endif +#endif //DATA_ASSET_H diff --git a/distributeddatamgr/relational_store/include/oh_cursor.h b/distributeddatamgr/relational_store/include/oh_cursor.h index 165da158ee6c968130b3883150ac7f72b2200b0d..02e9549b3cf685eabbfbc5efebed5694821f8afe 100644 --- a/distributeddatamgr/relational_store/include/oh_cursor.h +++ b/distributeddatamgr/relational_store/include/oh_cursor.h @@ -40,6 +40,7 @@ #include #include #include +#include "data_asset.h" #ifdef __cplusplus extern "C" { #endif @@ -70,6 +71,18 @@ typedef enum OH_ColumnType { * Indicates the column type is BLOB. */ TYPE_BLOB, + /** + * Indicates the column type is {@link Data_Asset}. + * + * @since 11 + */ + TYPE_ASSET, + /** + * Indicates the column type is array of {@link Data_Asset}. + * + * @since 11 + */ + TYPE_ASSETS } OH_ColumnType; /** @@ -245,6 +258,33 @@ typedef struct OH_Cursor { * @since 10 */ int (*destroy)(OH_Cursor *cursor); + + /** + * @brief Function pointer. Obtains the value of the requested column as an {@link Data_Asset} instance. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based column index. + * @param value This parameter is the output parameter, + * and the value of the requested column as an {@link Data_Asset} instance is written to this variable. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 11 + */ + int (*getAsset)(OH_Cursor *cursor, int32_t columnIndex, Data_Asset *value); + + /** + * @brief Function pointer. Obtains the value of the requested column as an {@link Data_Asset} instance. + * + * @param cursor Represents a pointer to an {@link OH_Cursor} instance. + * @param columnIndex Indicates the zero-based column index. + * @param value This parameter is the output parameter, + * and the value of the requested column as an {@link Data_Asset} instance is written to this variable. + * @param length Indicates the length of the value. + * @return Returns the status code of the execution. + * @see OH_Cursor. + * @since 11 + */ + int (*getAssets)(OH_Cursor *cursor, int32_t columnIndex, Data_Asset **value, uint32_t *length); } OH_Cursor; #ifdef __cplusplus diff --git a/distributeddatamgr/relational_store/include/oh_values_bucket.h b/distributeddatamgr/relational_store/include/oh_values_bucket.h index e966956b68a49fc04e7adda371c2c57cd10ef29c..66a923e2609a10cd404b661515bf51f3b1763b07 100644 --- a/distributeddatamgr/relational_store/include/oh_values_bucket.h +++ b/distributeddatamgr/relational_store/include/oh_values_bucket.h @@ -38,6 +38,7 @@ */ #include +#include "data_asset.h" #ifdef __cplusplus extern "C" { #endif @@ -139,6 +140,30 @@ typedef struct OH_VBucket { int (*destroy)(OH_VBucket *bucket); } OH_VBucket; +/** + * @brief Put the {@link Data_Asset} * value to this {@link OH_VBucket} object for the given column name. + * + * @param bucket Represents a pointer to an {@link OH_VBucket} instance. + * @param field Indicates the name of the column. + * @param value Indicates the const {@link Data_Asset} * value. + * @return Returns the status code of the execution. + * @see OH_VBucket. + * @since 11 + */ +int OH_VBucket_PutAsset(OH_VBucket *bucket, const char *field, Data_Asset *value); + +/** + * @brief Put the {@link Data_Asset} * value of given count to this {@link OH_VBucket} object for the given column name. + * + * @param bucket Represents a pointer to an {@link OH_VBucket} instance. + * @param field Indicates the name of the column. + * @param value Indicates the {@link Data_Asset} value of given count. + * @param count Indicates the count of value. + * @return Returns the status code of the execution. + * @see OH_VBucket. + * @since 11 + */ +int OH_VBucket_PutAssets(OH_VBucket *bucket, const char *field, Data_Asset **value, uint32_t count); #ifdef __cplusplus }; #endif diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index 7b009ec34bb0f750e0d0d61a99ab534409a7f982..f32c252d81863be1dec55c7842b740a3934666bf 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -70,6 +70,30 @@ typedef enum OH_Rdb_SecurityLevel { S4 } OH_Rdb_SecurityLevel; +/** + * @brief Describe the security area of the database. + * + * @since 11 + */ +typedef enum Rdb_SecurityArea { + /** + * @brief Security Area 1. + */ + RDB_SECURITY_AREA_EL1 = 1, + /** + * @brief Security Area 2. + */ + RDB_SECURITY_AREA_EL2, + /** + * @brief Security Area 3. + */ + RDB_SECURITY_AREA_EL3, + /** + * @brief Security Area 4. + */ + RDB_SECURITY_AREA_EL4, +} Rdb_SecurityArea; + /** * @brief Manages relational database configurations. * @@ -105,6 +129,12 @@ typedef struct { * Indicates the security level {@link OH_Rdb_SecurityLevel} of the database. */ int securityLevel; + /** + * Indicates the security area {@link Rdb_SecurityArea} of the database. + * + * @since 11 + */ + int area; } OH_Rdb_Config; #pragma pack() @@ -343,6 +373,394 @@ int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version); */ int OH_Rdb_SetVersion(OH_Rdb_Store *store, int version); +/** + * @brief Describes the distribution type of the tables. + * + * @since 11 + */ +typedef enum Rdb_DistributedType { + /** + * @brief Indicates the table is distributed among the devices. + */ + RDB_DISTRIBUTED_CLOUD +} Rdb_DistributedType; + +/** + * @brief Indicates version of {@link Rdb_DistributedConfig} + * + * @since 11 + */ +#define DISTRIBUTED_CONFIG_VERSION 1 +/** + * @brief Manages the distributed configuration of the table. + * + * @since 11 + */ +typedef struct Rdb_DistributedConfig { + /** + * The version used to uniquely identify the Rdb_DistributedConfig struct. + */ + int version; + /** + * Specifies whether the table auto syncs. + */ + bool isAutoSync; +} Rdb_DistributedConfig; + +/** + * @brief Set table to be distributed table. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param tables Indicates the table names you want to set. + * @param count Indicates the count of tables you want to set. + * @param type Indicates the distributed type {@link Rdb_DistributedType}. + * @param config Indicates the distributed config of the tables. For details, see {@link Rdb_DistributedConfig}. + * @return Returns the status code of the execution. See {@link OH_Rdb_ErrCode}. + * @see OH_Rdb_Store. + * @see Rdb_DistributedConfig. + * @since 11 + */ +int OH_Rdb_SetDistributedTables(OH_Rdb_Store *store, const char *tables[], uint32_t count, Rdb_DistributedType type, + const Rdb_DistributedConfig *config); + +/** + * @brief Set table to be distributed table. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param tableName Indicates the name of the table to check. + * @param columnName Indicates the name of the column corresponding to the primary key. + * If the table has no primary key , please pass in "rowid". + * @param values Indicates the primary keys of the rows to check. + * If the table has no primary key , please pass in the row-ids of the rows to check. + * @return If the operation is successful, a pointer to the instance of the @link OH_Cursor} structure is returned. + * There are two columns, "data_key" and "timestamp". Otherwise NULL is returned. + * @see OH_Rdb_Store. + * @see OH_VObject. + * @see OH_Cursor. + * @since 11 + */ +OH_Cursor *OH_Rdb_FindModifyTime(OH_Rdb_Store *store, const char *tableName, const char *columnName, + OH_VObject *values); + +/** + * @brief Describes the change type. + * + * @since 11 + */ +typedef enum Rdb_ChangeType { + /** + * @brief Means the change type is data change. + */ + RDB_DATA_CHANGE, + /** + * @brief Means the change type is asset change. + */ + RDB_ASSET_CHANGE +} Rdb_ChangeType; + +/** + * @brief Describes the primary keys or row-ids of changed rows. + * + * @since 11 + */ +typedef struct Rdb_KeyInfo { + /** + * Indicates the count of the primary keys or row-ids. + */ + int count; + + /** + * Indicates data type {@link OH_ColumnType} of the key. + */ + int type; + + /** + * Indicates the data of the key info. + */ + union Rdb_KeyData { + /** + * Indicates uint64_t type of the data. + */ + uint64_t integer; + + /** + * Indicates double type of the data. + */ + double real; + + /** + * Indicates const char * type of the data. + */ + const char *text; + } *data; +} Rdb_KeyInfo; + +/** + * @brief Indicates version of {@link Rdb_ChangeInfo} + * + * @since 11 + */ +#define DISTRIBUTED_CHANGE_INFO_VERSION 1 + +/** + * @brief Describes the notify info of data change. + * + * @since 11 + */ +typedef struct Rdb_ChangeInfo { + /** + * The version used to uniquely identify the Rdb_ChangeInfo struct. + */ + int version; + + /** + * The name of changed table. + */ + const char *tableName; + + /** + * The {@link Rdb_ChangeType} of changed table. + */ + int ChangeType; + + /** + * The {@link Rdb_KeyInfo} of inserted rows. + */ + Rdb_KeyInfo inserted; + + /** + * The {@link Rdb_KeyInfo} of updated rows. + */ + Rdb_KeyInfo updated; + + /** + * The {@link Rdb_KeyInfo} of deleted rows. + */ + Rdb_KeyInfo deleted; +} Rdb_ChangeInfo; + +/** + * @brief Indicates the subscribe type. + * + * @since 11 + */ +typedef enum Rdb_SubscribeType { + /** + * @brief Subscription to cloud data changes. + */ + RDB_SUBSCRIBE_TYPE_CLOUD, + + /** + * @brief Subscription to cloud data change details. + */ + RDB_SUBSCRIBE_TYPE_CLOUD_DETAILS, +} Rdb_SubscribeType; + +/** + * @brief Indicates the database synchronization mode. + * + * @since 11 + */ +typedef enum Rdb_SyncMode { + /** + * @brief Indicates that data is synchronized from the end with the closest modification time + * to the end with a more distant modification time. + */ + RDB_SYNC_MODE_TIME_FIRST, + /** + * @brief Indicates that data is synchronized from local to cloud. + */ + RDB_SYNC_MODE_NATIVE_FIRST, + /** + * @brief Indicates that data is synchronized from cloud to local. + */ + RDB_SYNC_MODE_CLOUD_FIRST +} Rdb_SyncMode; + +/** + * @brief Describes the statistic of the cloud sync process. + * + * @since 11 + */ +typedef struct Rdb_Statistic { + /** + * Describes the total number of data to sync. + */ + int total; + + /** + * Describes the number of successfully synced data. + */ + int successful; + + /** + * Describes the number of data failed to sync. + */ + int failed; + + /** + * Describes the number of data remained to sync. + */ + int remained; +} Rdb_Statistic; + +/** + * @brief Describes the {@link Rdb_Statistic} details of the table. + * + * @since 11 + */ +typedef struct Rdb_TableDetails { + /** + * Indicates the name of changed table. + */ + const char *table; + + /** + * Describes the {@link Rdb_Statistic} details of the upload process. + */ + Rdb_Statistic upload; + + /** + * Describes the {@link Rdb_Statistic} details of the download process. + */ + Rdb_Statistic download; +} Rdb_TableDetails; + +/** + * The cloud sync progress + * + * @since 11 + */ +typedef enum Rdb_Progress { + /** + * @brief Means the sync process begin. + */ + RDB_SYNC_BEGIN, + + /** + * @brief Means the sync process is in progress + */ + RDB_SYNC_IN_PROGRESS, + + /** + * @brief Means the sync process is finished + */ + RDB_SYNC_FINISH +} Rdb_Progress; + +/** + * Describes the status of cloud sync progress. + * + * @since 11 + */ +typedef enum Rdb_ProgressCode { + /** + * @brief Means the status of progress is success. + */ + RDB_SUCCESS, + + /** + * @brief Means the progress meets unknown error. + */ + RDB_UNKNOWN_ERROR, + + /** + * @brief Means the progress meets network error. + */ + RDB_NETWORK_ERROR, + + /** + * @brief Means cloud is disabled. + */ + RDB_CLOUD_DISABLED, + + /** + * @brief Means the progress is locked by others. + */ + RDB_LOCKED_BY_OTHERS, + + /** + * @brief Means the record exceeds the limit. + */ + RDB_RECORD_LIMIT_EXCEEDED, + + /** + * Means the cloud has no space for the asset. + */ + RDB_NO_SPACE_FOR_ASSET +} Rdb_ProgressCode; + +/** + * @brief Indicates version of {@link Rdb_ProgressDetails} + * + * @since 11 + */ +#define DISTRIBUTED_PROGRESS_DETAIL_VERSION 1 + +/** + * @brief Describes detail of the cloud sync progress. + * + * @since 11 + */ +typedef struct Rdb_ProgressDetails { + /** + * The version used to uniquely identify the Rdb_ProgressDetails struct. + */ + int version; + + /** + * Describes the status of data sync progress. Defined in {@link Rdb_Progress}. + */ + int schedule; + + /** + * Describes the code of data sync progress. Defined in {@link Rdb_ProgressCode}. + */ + int code; + + /** + * Describes the length of changed tables in data sync progress. + */ + int32_t tableLength; +} Rdb_ProgressDetails; + +/** + * @brief Get table details from progress details. + * + * @param progress Represents a pointer to an {@link Rdb_ProgressDetails} instance. + * @param version Indicates the version of current {@link Rdb_ProgressDetails}. + * @return If the operation is successful, a pointer to the instance of the @link Rdb_TableDetails} structure is returned. + * Otherwise NULL is returned. + * @see Rdb_ProgressDetails + * @see Rdb_TableDetails + * @since 11 + */ +Rdb_TableDetails *OH_Rdb_GetTableDetails(Rdb_ProgressDetails *progress, int32_t version); + +/** + * @brief The callback function of sync. + * + * @param progressDetails The details of the sync progress. + * @see Rdb_ProgressDetails. + * @since 11 + */ +typedef void (*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails); + +/** + * @brief Sync data to cloud. + * + * @param store Represents a pointer to an {@link OH_Rdb_Store} instance. + * @param mode Represents the {@link Rdb_SyncMode} of sync progress. + * @param tables Indicates the names of tables to sync. + * @param count The count of tables to sync. If value equals 0, sync all tables of the store. + * @param callback The {@link Rdb_SyncCallback} of cloud sync progress. + * @return Returns the status code of the execution. See {@link OH_Rdb_ErrCode}. + * @see OH_Rdb_Store. + * @see Rdb_SyncCallback. + * @since 11 + */ +int OH_Rdb_CloudSync(OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables[], uint32_t count, + Rdb_SyncCallback *callback); #ifdef __cplusplus }; #endif diff --git a/distributeddatamgr/relational_store/libnative_rdb.ndk.json b/distributeddatamgr/relational_store/libnative_rdb.ndk.json index 84901bb5404a0d1dd5886ce860473a2756d7e697..190d3cbb00fce469dd7a1261f1c51bb4bfc7ebbe 100644 --- a/distributeddatamgr/relational_store/libnative_rdb.ndk.json +++ b/distributeddatamgr/relational_store/libnative_rdb.ndk.json @@ -17,5 +17,29 @@ {"name":"OH_Rdb_Backup" }, {"name":"OH_Rdb_Restore"}, {"name":"OH_Rdb_GetVersion"}, - {"name":"OH_Rdb_SetVersion"} + {"name":"OH_Rdb_SetVersion"}, + {"name":"OH_Rdb_SetDistributedTables"}, + {"name":"OH_Rdb_FindModifyTime"}, + {"name":"OH_Rdb_GetTableDetails"}, + {"name":"OH_Rdb_CloudSync"}, + {"name":"OH_VBucket_PutAsset"}, + {"name":"OH_VBucket_PutAssets"}, + {"name":"OH_Data_Asset_SetName"}, + {"name":"OH_Data_Asset_SetUri"}, + {"name":"OH_Data_Asset_SetPath"}, + {"name":"OH_Data_Asset_SetCreateTime"}, + {"name":"OH_Data_Asset_SetModifyTime"}, + {"name":"OH_Data_Asset_SetSize"}, + {"name":"OH_Data_Asset_SetStatus"}, + {"name":"OH_Data_Asset_GetName"}, + {"name":"OH_Data_Asset_GetUri"}, + {"name":"OH_Data_Asset_GetPath"}, + {"name":"OH_Data_Asset_GetCreateTime"}, + {"name":"OH_Data_Asset_GetModifyTime"}, + {"name":"OH_Data_Asset_GetSize"}, + {"name":"OH_Data_Asset_GetStatus"}, + {"name":"OH_Data_Asset_CreateOne"}, + {"name":"OH_Data_Asset_DestroyOne"}, + {"name":"OH_Data_Asset_CreateMultiple"}, + {"name":"OH_Data_Asset_DestroyMultiple"} ] \ No newline at end of file