I4SBL6: Open interfaces to apply to references

Signed-off-by: MangTsang <mang.tsang@huawei.com>
This commit is contained in:
MangTsang
2022-01-26 17:53:40 +08:00
parent e22fdb5ed0
commit 026b590941
64 changed files with 372 additions and 407 deletions
+1
View File
@@ -1,5 +1,6 @@
.idea/
.DS_Store
*.iml
._*
CMakeLists.txt
cmake-build-debug
+7 -6
View File
@@ -72,9 +72,10 @@
"//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_preferences:native_preferences",
"//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_dataability:native_dataability",
"//foundation/distributeddatamgr/appdatamgr/interfaces/innerkits/native_rdb:native_rdb",
"//foundation/distributeddatamgr/appdatamgr/interfaces/jskits:dataability",
"//foundation/distributeddatamgr/appdatamgr/interfaces/jskits:storage",
"//foundation/distributeddatamgr/appdatamgr/interfaces/jskits:rdb"
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_dataability:dataability",
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_preferences:storage",
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_resultset:resultset",
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_rdb:rdb"
],
"inner_kits": [
{
@@ -138,9 +139,9 @@
"//foundation/distributeddatamgr/appdatamgr/frameworks/innerkitsimpl/native_preferences/test:unittest",
"//foundation/distributeddatamgr/appdatamgr/frameworks/innerkitsimpl/native_dataability/test:unittest",
"//foundation/distributeddatamgr/appdatamgr/frameworks/innerkitsimpl/native_rdb/test:unittest",
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/native_rdb/test:unittest",
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/native_preferences/test:unittest",
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/native_dataability/test:unittest"
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_rdb/test:unittest",
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_preferences/test:unittest",
"//foundation/distributeddatamgr/appdatamgr/frameworks/jskitsimpl/napi_dataability/test:unittest"
]
}
}
@@ -15,7 +15,7 @@
#include "preferences_impl.h"
#include <inttypes.h>
#include <cinttypes>
#include <limits.h>
#include <stdlib.h>
@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DA_JSKIT_NAPI_COMMON_PREDICATES_H
#define DA_JSKIT_NAPI_COMMON_PREDICATES_H
#ifndef RDB_JSKIT_COMMON_H
#define RDB_JSKIT_COMMON_H
#include <string>
#include <vector>
@@ -21,15 +21,14 @@
#include "hilog/log.h"
namespace OHOS {
namespace DataAbilityJsKit {
static const OHOS::HiviewDFX::HiLogLabel PREFIX_LABEL = { LOG_CORE, 0xD001650, "DataAbilityJsKit" };
namespace AppDataMgrJsKit {
static const OHOS::HiviewDFX::HiLogLabel PREFIX_LABEL = { LOG_CORE, 0xD001650, "AppDataMgrJsKit" };
#define LOG_DEBUG(...) ((void)OHOS::HiviewDFX::HiLog::Debug(PREFIX_LABEL, __VA_ARGS__))
#define LOG_INFO(...) ((void)OHOS::HiviewDFX::HiLog::Info(PREFIX_LABEL, __VA_ARGS__))
#define LOG_WARN(...) ((void)OHOS::HiviewDFX::HiLog::Warn(PREFIX_LABEL, __VA_ARGS__))
#define LOG_ERROR(...) ((void)OHOS::HiviewDFX::HiLog::Error(PREFIX_LABEL, __VA_ARGS__))
#define LOG_FATAL(...) ((void)OHOS::HiviewDFX::HiLog::Fatal(PREFIX_LABEL, __VA_ARGS__))
} // namespace DataAbilityJsKit
} // namespace RdbJsKit
} // namespace OHOS
#endif // DA_JSKIT_NAPI_COMMON_PREDICATES_H
#endif
@@ -23,13 +23,13 @@
#include "napi/native_node_api.h"
namespace OHOS {
namespace JsKit {
namespace AppDataMgrJsKit {
class JSAbility final {
public:
static std::string GetDatabaseDir(napi_env env);
static std::string GetBundleName(napi_env env);
};
} // namespace JsKit
} // namespace AppDataMgrJsKit
} // namespace OHOS
#endif // DISTRIBUTEDDATAMGR_APPDATAMGR_JSABILITY_H
@@ -24,7 +24,7 @@
#include "napi/native_node_api.h"
namespace OHOS {
namespace JsKit {
namespace AppDataMgrJsKit {
class JSUtils final {
public:
static constexpr int32_t DEFAULT_BUF_SIZE = 1024;
@@ -42,7 +42,7 @@ public:
static napi_value Convert2JSValue(napi_env env, double value);
static napi_value Convert2JSValue(napi_env env, bool value);
};
} // namespace JsKit
} // namespace AppDataMgrJsKit
} // namespace OHOS
#endif // DISTRIBUTEDDATAMGR_APPDATAMGR_JSUTILS_H
@@ -22,7 +22,7 @@
#include "securec.h"
namespace OHOS {
namespace JsKit {
namespace AppDataMgrJsKit {
constexpr int MAX_INPUT_COUNT = 10;
constexpr int OK = 0;
constexpr int ERR = -1;
@@ -165,6 +165,6 @@ public:
private:
T *asyncContext;
};
} // namespace JsKit
} // namespace AppDataMgrJsKit
} // namespace OHOS
#endif
@@ -24,7 +24,7 @@
#endif
namespace OHOS {
namespace JsKit {
namespace AppDataMgrJsKit {
static const OHOS::HiviewDFX::HiLogLabel PREFIX_LABEL = { LOG_CORE, 0xD001650, "JOHOS_JsKit_Ability" };
#define LOG_DEBUG(...) ((void)OHOS::HiviewDFX::HiLog::Debug(PREFIX_LABEL, __VA_ARGS__))
@@ -111,5 +111,5 @@ std::string JSAbility::GetDatabaseDir(napi_env env)
return databaseDir;
}
#endif
} // namespace JsKit
} // namespace AppDataMgrJsKit
} // namespace OHOS
@@ -18,7 +18,7 @@
#include "securec.h"
namespace OHOS {
namespace JsKit {
namespace AppDataMgrJsKit {
std::string JSUtils::Convert2String(napi_env env, napi_value jsStr, const size_t max)
{
NAPI_ASSERT_BASE(env, max > 0, "failed on max > 0", std::string());
@@ -173,5 +173,5 @@ napi_value JSUtils::Convert2JSValue(napi_env env, bool value)
}
return jsValue;
}
} // namespace JsKit
} // namespace AppDataMgrJsKit
} // namespace OHOS
@@ -0,0 +1,51 @@
# Copyright (c) 2022 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.
import("//build/ohos.gni")
import("//build/ohos/ace/ace.gni")
ohos_copy("appdatamgr_declaration") {
sources = [ "./api" ]
outputs = [ target_out_dir + "/$target_name/" ]
module_source_dir = target_out_dir + "/$target_name"
module_install_name = ""
}
ohos_shared_library("dataability") {
include_dirs = [
"include",
"../common/include",
"../napi_rdb/include",
"//third_party/node/src",
"//utils/native/base/include",
]
sources = [
"../common/src/js_utils.cpp",
"src/entry_point.cpp",
"src/napi_data_ability_predicates.cpp",
"src/napi_predicates_utils.cpp",
]
deps = [ "../napi_rdb:rdb" ]
external_deps = [
"hilog_native:libhilog",
"napi:ace_napi",
"native_appdatamgr:native_dataability",
"native_appdatamgr:native_rdb",
]
subsystem_name = "distributeddatamgr"
part_name = "native_appdatamgr"
relative_install_dir = "module/data"
}
@@ -24,7 +24,6 @@
namespace OHOS {
namespace DataAbilityJsKit {
class DataAbilityPredicatesProxy {
public:
static void Init(napi_env env, napi_value exports);
@@ -25,4 +25,4 @@ namespace DataAbilityJsKit {
napi_value InitPredicatesUtils(napi_env env, napi_value info);
} // namespace DataAbilityJsKit
} // namespace OHOS
#endif //APPDATAMGR_NAPI_PREDICATES_UTILS_H
#endif // APPDATAMGR_NAPI_PREDICATES_UTILS_H
@@ -20,7 +20,7 @@
#include "napi_async_proxy.h"
using namespace OHOS::NativeRdb;
using namespace OHOS::JsKit;
using namespace OHOS::AppDataMgrJsKit;
namespace OHOS {
namespace DataAbilityJsKit {
@@ -21,6 +21,8 @@
#include "napi_rdb_predicates.h"
#include "predicates_utils.h"
using namespace OHOS::AppDataMgrJsKit;
namespace OHOS {
namespace DataAbilityJsKit {
napi_value CreateRdbPredicates(napi_env env, napi_callback_info info)
@@ -35,7 +37,7 @@ napi_value CreateRdbPredicates(napi_env env, napi_callback_info info)
napi_valuetype valueType;
NAPI_CALL(env, napi_typeof(env, args[0], &valueType));
NAPI_ASSERT(env, valueType == napi_string, "Table name should be a string.");
std::string tableName = JsKit::JSUtils::Convert2String(env, args[0], JsKit::JSUtils::DEFAULT_BUF_SIZE);
std::string tableName = JSUtils::Convert2String(env, args[0], JSUtils::DEFAULT_BUF_SIZE);
NAPI_CALL(env, napi_typeof(env, args[1], &valueType));
NAPI_ASSERT(env, valueType == napi_object, "Table name should be an object.");
@@ -0,0 +1,46 @@
# Copyright (c) 2022 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.
import("//build/ohos.gni")
import("//build/ohos/ace/ace.gni")
ohos_copy("appdatamgr_declaration") {
sources = [ "./api" ]
outputs = [ target_out_dir + "/$target_name/" ]
module_source_dir = target_out_dir + "/$target_name"
module_install_name = ""
}
ohos_shared_library("storage") {
include_dirs = [
"include",
"../common/include",
"//third_party/node/src",
"//utils/native/base/include",
]
sources = [
"src/entry_point.cpp",
"src/napi_preference.cpp",
"src/napi_preference_helper.cpp",
]
external_deps = [
"hilog_native:libhilog",
"napi:ace_napi",
"native_appdatamgr:native_preferences",
]
subsystem_name = "distributeddatamgr"
part_name = "native_appdatamgr"
relative_install_dir = "module/data"
}
@@ -15,20 +15,21 @@
#include "napi_preference.h"
#include <linux/limits.h>
#include <cerrno>
#include <cmath>
#include <limits>
#include <linux/limits.h>
#include "securec.h"
#include "common.h"
#include "common.h"
#include "napi_async_proxy.h"
#include "preferences.h"
#include "preferences_errno.h"
#include "preferences_value.h"
#include "napi_async_proxy.h"
#include "securec.h"
using namespace OHOS::NativePreferences;
using namespace OHOS::JsKit;
using namespace OHOS::AppDataMgrJsKit;
namespace OHOS {
namespace PreferencesJsKit {
@@ -13,16 +13,18 @@
* limitations under the License.
*/
#include "napi_preference_helper.h"
#include <string>
#include <linux/limits.h>
#include "common.h"
#include "napi_async_proxy.h"
#include "napi_preference.h"
#include "preferences_errno.h"
#include "securec.h"
#include "napi_preference.h"
#include "common.h"
#include "preferences_errno.h"
#include "napi_async_proxy.h"
using namespace OHOS::NativePreferences;
using namespace OHOS::JsKit;
using namespace OHOS::AppDataMgrJsKit;
namespace OHOS {
namespace PreferencesJsKit {
@@ -118,7 +120,7 @@ napi_value DeleteStorageSync(napi_env env, napi_callback_info info)
int errCode = PreferencesHelper::DeletePreferences(path);
if (errCode != E_OK) {
LOG_ERROR("deleteStorage failed %{public}d", errCode);
napi_throw_error(env, GetErrStr(errCode), "deleteStorage failed");
napi_throw_error(env, std::to_string(errCode).c_str(), "deleteStorage failed");
}
LOG_DEBUG("deleteStorage end");
@@ -159,7 +161,7 @@ napi_value RemoveStorageFromCacheSync(napi_env env, napi_callback_info info)
int errCode = PreferencesHelper::RemovePreferencesFromCache(path);
if (errCode != E_OK) {
LOG_ERROR("removeStorageFromCache failed %{public}d", errCode);
napi_throw_error(env, GetErrStr(errCode), "removeStorageFromCache failed");
napi_throw_error(env, std::to_string(errCode).c_str(), "removeStorageFromCache failed");
}
LOG_DEBUG("removeStorageFromCache end");
+71
View File
@@ -0,0 +1,71 @@
# Copyright (c) 2022 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.
import("//build/ohos.gni")
import("//build/ohos/ace/ace.gni")
ohos_copy("appdatamgr_declaration") {
sources = [ "./api" ]
outputs = [ target_out_dir + "/$target_name/" ]
module_source_dir = target_out_dir + "/$target_name"
module_install_name = ""
}
ohos_shared_library("rdb") {
include_dirs = [
"include",
"../common/include",
"../napi_resultset/include",
"//third_party/node/src",
"//utils/native/base/include",
]
sources = [
"../common/src/js_ability.cpp",
"../common/src/js_utils.cpp",
"src/entry_point.cpp",
"src/napi_rdb_predicates.cpp",
"src/napi_rdb_store.cpp",
"src/napi_rdb_store_helper.cpp",
"src/napi_values_bucket.cpp",
]
deps = [
"../napi_resultset:resultset",
"//utils/native/base:utils",
]
external_deps = [
"hilog_native:libhilog",
"napi:ace_napi",
"native_appdatamgr:native_appdatafwk",
"native_appdatamgr:native_rdb",
]
if (is_standard_system) {
defines = [ "STANDARD_SYSTEM_ENABLE" ]
deps += [ "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native" ]
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"ability_runtime:want",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
]
}
subsystem_name = "distributeddatamgr"
part_name = "native_appdatamgr"
relative_install_dir = "module/data"
}
@@ -27,4 +27,4 @@ __attribute__((visibility("default"))) napi_value NAPI_OHOS_Data_RdbJsKit_Values
__attribute__((visibility("default"))) OHOS::NativeRdb::ValuesBucket *
NAPI_OHOS_Data_RdbJsKit_ValuesBucketProxy_GetNativeObject(napi_env env, napi_value &value);
EXTERN_C_END
#endif //APPDATAMGR_NAPI_VALUES_BUCKET_H
#endif // APPDATAMGR_NAPI_VALUES_BUCKET_H
@@ -13,11 +13,11 @@
* limitations under the License.
*/
#include "napi/native_api.h"
#include "napi/native_node_api.h"
#include "napi_rdb_predicates.h"
#include "napi_rdb_store.h"
#include "napi_rdb_store_helper.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
using namespace OHOS::RdbJsKit;
@@ -20,7 +20,7 @@
#include "napi_async_proxy.h"
using namespace OHOS::NativeRdb;
using namespace OHOS::JsKit;
using namespace OHOS::AppDataMgrJsKit;
namespace OHOS {
namespace RdbJsKit {
@@ -14,16 +14,19 @@
*/
#include "napi_rdb_store.h"
#include <inttypes.h>
#include <cinttypes>
#include "common.h"
#include "js_utils.h"
#include "napi_async_proxy.h"
#include "napi_rdb_predicates.h"
#include "napi_result_set.h"
#include "rdb_errno.h"
#include "securec.h"
using namespace OHOS::NativeRdb;
using namespace OHOS::JsKit;
using namespace OHOS::AppDataMgrJsKit;
namespace OHOS {
namespace RdbJsKit {
@@ -89,19 +92,19 @@ void RdbStoreContext::BindArgs(napi_env env, napi_value arg)
napi_typeof(env, element, &type);
switch (type) {
case napi_boolean: {
bool value;
napi_status status = napi_get_value_bool(env, element, &value);
if (status == napi_ok) {
bindArgs.push_back(ValueObject(value));
}
} break;
bool value;
napi_status status = napi_get_value_bool(env, element, &value);
if (status == napi_ok) {
bindArgs.push_back(ValueObject(value));
}
} break;
case napi_number: {
double value;
napi_status status = napi_get_value_double(env, element, &value);
if (status == napi_ok) {
bindArgs.push_back(ValueObject(value));
}
} break;
double value;
napi_status status = napi_get_value_double(env, element, &value);
if (status == napi_ok) {
bindArgs.push_back(ValueObject(value));
}
} break;
case napi_null:
bindArgs.push_back(ValueObject());
break;
@@ -28,7 +28,7 @@
#include "unistd.h"
using namespace OHOS::NativeRdb;
using namespace OHOS::JsKit;
using namespace OHOS::AppDataMgrJsKit;
namespace OHOS {
namespace RdbJsKit {
@@ -259,50 +259,6 @@ void ParseStoreConfig(const napi_env &env, const napi_value &object, HelperRdbCo
LOG_DEBUG("ParseStoreConfig name=%{public}s", name.c_str());
asyncContext->config.SetName(std::move(name));
value = nullptr;
napi_get_named_property(env, object, "storageMode", &value);
if (value != nullptr) {
int32_t mode = 0;
napi_status status = napi_get_value_int32(env, value, &mode);
if (status == napi_ok) {
StorageMode storageMode = StorageMode(mode);
asyncContext->config.SetStorageMode(storageMode);
LOG_DEBUG("ParseStoreConfig storageMode=%{public}d", mode);
}
}
value = nullptr;
napi_get_named_property(env, object, "readOnly", &value);
if (value != nullptr) {
bool readOnly = true;
napi_status status = napi_get_value_bool(env, value, &readOnly);
if (status == napi_ok) {
asyncContext->config.SetReadOnly(readOnly);
LOG_DEBUG("ParseStoreConfig SetReadOnly=%{public}d", readOnly);
}
}
value = nullptr;
napi_get_named_property(env, object, "fileType", &value);
if (value != nullptr) {
int32_t mode = 0;
napi_status status = napi_get_value_int32(env, value, &mode);
if (status == napi_ok) {
asyncContext->config.SetDatabaseFileType(DatabaseFileType(mode));
LOG_DEBUG("ParseStoreConfig fileType=%{public}d", mode);
}
}
value = nullptr;
napi_get_named_property(env, object, "journalMode", &value);
if (value != nullptr) {
int32_t mode = 0;
napi_status status = napi_get_value_int32(env, value, &mode);
if (status == napi_ok) {
asyncContext->config.SetJournalMode(static_cast<JournalMode>(mode));
LOG_DEBUG("ParseStoreConfig journalMode=%{public}d", mode);
}
}
value = nullptr;
napi_get_named_property(env, object, "encryptKey", &value);
if (value != nullptr) {
@@ -19,8 +19,7 @@
#include "js_utils.h"
#include "value_object.h"
using namespace OHOS::JsKit;
using namespace OHOS::RdbJsKit;
using namespace OHOS::AppDataMgrJsKit;
using namespace OHOS::NativeRdb;
__attribute__((visibility("default"))) napi_value NAPI_OHOS_Data_RdbJsKit_ValuesBucketProxy_NewInstance(
@@ -37,33 +36,33 @@ __attribute__((visibility("default"))) napi_value NAPI_OHOS_Data_RdbJsKit_Values
napi_value value = nullptr;
switch (valueObject.GetType()) {
case ValueObjectType::TYPE_NULL: {
value = nullptr;
} break;
value = nullptr;
} break;
case ValueObjectType::TYPE_INT: {
int64_t intVal = 0;
valueObject.GetLong(intVal);
value = JSUtils::Convert2JSValue(env, intVal);
} break;
int64_t intVal = 0;
valueObject.GetLong(intVal);
value = JSUtils::Convert2JSValue(env, intVal);
} break;
case ValueObjectType::TYPE_DOUBLE: {
double doubleVal = 0L;
valueObject.GetDouble(doubleVal);
value = JSUtils::Convert2JSValue(env, doubleVal);
} break;
double doubleVal = 0L;
valueObject.GetDouble(doubleVal);
value = JSUtils::Convert2JSValue(env, doubleVal);
} break;
case ValueObjectType::TYPE_BLOB: {
std::vector<uint8_t> blobVal;
valueObject.GetBlob(blobVal);
value = JSUtils::Convert2JSValue(env, blobVal);
} break;
std::vector<uint8_t> blobVal;
valueObject.GetBlob(blobVal);
value = JSUtils::Convert2JSValue(env, blobVal);
} break;
case ValueObjectType::TYPE_BOOL: {
bool boolVal = false;
valueObject.GetBool(boolVal);
value = JSUtils::Convert2JSValue(env, boolVal);
} break;
bool boolVal = false;
valueObject.GetBool(boolVal);
value = JSUtils::Convert2JSValue(env, boolVal);
} break;
default: {
std::string strVal = "";
valueObject.GetString(strVal);
value = JSUtils::Convert2JSValue(env, strVal);
} break;
std::string strVal = "";
valueObject.GetString(strVal);
value = JSUtils::Convert2JSValue(env, strVal);
} break;
}
NAPI_CALL(env, napi_set_named_property(env, ret, key.c_str(), value));
}
@@ -190,4 +190,4 @@ describe('rdbStorePredicatesJoinTest', function () {
})
console.log(TAG + "*************Unit Test End*************");
})
})
@@ -0,0 +1,58 @@
# Copyright (c) 2022 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.
import("//build/ohos.gni")
import("//build/ohos/ace/ace.gni")
ohos_copy("appdatamgr_declaration") {
sources = [ "./api" ]
outputs = [ target_out_dir + "/$target_name/" ]
module_source_dir = target_out_dir + "/$target_name"
module_install_name = ""
}
ohos_shared_library("resultset") {
include_dirs = [
"include",
"../common/include",
"//third_party/node/src",
"//utils/native/base/include",
]
sources = [
"../common/src/js_utils.cpp",
"src/entry_point.cpp",
"src/napi_result_set.cpp",
]
deps = [ "//utils/native/base:utils" ]
external_deps = [
"hilog_native:libhilog",
"napi:ace_napi",
"native_appdatamgr:native_appdatafwk",
"native_appdatamgr:native_rdb",
]
if (is_standard_system) {
defines = [ "STANDARD_SYSTEM_ENABLE" ]
external_deps += [
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
]
}
subsystem_name = "distributeddatamgr"
part_name = "native_appdatamgr"
relative_install_dir = "module/data"
}
@@ -33,10 +33,10 @@ public:
static napi_value NewInstance(napi_env env, std::shared_ptr<NativeRdb::AbsSharedResultSet> resultSet);
static std::shared_ptr<NativeRdb::AbsSharedResultSet> GetNativePredicates(
const napi_env &env, const napi_value &arg);
static napi_value GetConstructor(napi_env env);
private:
static std::shared_ptr<NativeRdb::AbsSharedResultSet> &GetInnerResultSet(napi_env env, napi_callback_info info);
static napi_value GetConstructor(napi_env env);
static napi_value Initialize(napi_env env, napi_callback_info info);
static napi_value GetAllColumnNames(napi_env env, napi_callback_info info);
static napi_value GoToRow(napi_env env, napi_callback_info info);
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2021 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.
*/
#include "napi_result_set.h"
EXTERN_C_START
/*
* function for module exports
*/
static napi_value Init(napi_env env, napi_value exports)
{
OHOS::RdbJsKit::ResultSetProxy::GetConstructor(env);
return exports;
}
EXTERN_C_END
/*
* Module define
*/
static napi_module _module = {
.nm_version = 1,
.nm_flags = 0,
.nm_filename = nullptr,
.nm_register_func = Init,
.nm_modname = "data.resultSet",
.nm_priv = ((void *)0),
.reserved = { 0 }
};
/*
* Module register function
*/
static __attribute__((constructor)) void RegisterModule(void)
{
napi_module_register(&_module);
}
@@ -14,21 +14,22 @@
*/
#include "napi_result_set.h"
#include <functional>
#include "message_parcel.h"
#include "abs_shared_result_set.h"
#include "common.h"
#include "abs_shared_result_set.h"
#include "js_utils.h"
#include "napi_async_proxy.h"
#include "string_ex.h"
using namespace OHOS::NativeRdb;
using namespace OHOS::JsKit;
using namespace OHOS::AppDataMgrJsKit;
namespace OHOS {
namespace RdbJsKit {
static napi_ref __thread ctorRef_ = nullptr;
static const int E_OK = 0;
napi_value ResultSetProxy::NewInstance(napi_env env, std::shared_ptr<AbsSharedResultSet> resultSet)
{
napi_value cons = GetConstructor(env);
@@ -1,65 +0,0 @@
/*
* Copyright (c) 2021 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 PREFERENCES_JSKIT_COMMON_H
#define PREFERENCES_JSKIT_COMMON_H
#include <string>
#include <vector>
#include "hilog/log.h"
#include "preferences_errno.h"
namespace OHOS {
namespace PreferencesJsKit {
static const OHOS::HiviewDFX::HiLogLabel PREFIX_LABEL = { LOG_CORE, 0xD001650, "PreferencesJsKit" };
#define LOG_DEBUG(...) ((void)OHOS::HiviewDFX::HiLog::Debug(PREFIX_LABEL, __VA_ARGS__))
#define LOG_INFO(...) ((void)OHOS::HiviewDFX::HiLog::Info(PREFIX_LABEL, __VA_ARGS__))
#define LOG_WARN(...) ((void)OHOS::HiviewDFX::HiLog::Warn(PREFIX_LABEL, __VA_ARGS__))
#define LOG_ERROR(...) ((void)OHOS::HiviewDFX::HiLog::Error(PREFIX_LABEL, __VA_ARGS__))
#define LOG_FATAL(...) ((void)OHOS::HiviewDFX::HiLog::Fatal(PREFIX_LABEL, __VA_ARGS__))
static const std::vector<std::string> ERR_INFO {
"E_ERROR",
"E_STALE",
"E_INVALID_ARGS",
"E_OUT_OF_MEMORY",
"E_NOT_PERMIT",
"E_KEY_EMPTY",
"E_KEY_EXCEED_MAX_LENGTH",
"E_PTR_EXIST_ANOTHER_HOLD",
"E_DELETE_FILE_FAIL",
"E_EMPTY_FILE_PATH",
"E_RELATIVE_PATH",
"E_EMPTY_FILE_NAME",
"E_INVALID_FILE_PATH",
"E_PATH_EXCEED_MAX_LENGTH"
};
static inline const char *GetErrStr(int err)
{
if (err == OHOS::NativePreferences::E_OK) {
return nullptr;
}
size_t index = err - OHOS::NativePreferences::E_BASE - 1;
if (index >= ERR_INFO.size() || index < 0) {
return "Unknown error";
}
return ERR_INFO.at(index).c_str();
}
} // namespace PreferencesJsKit
} // namespace OHOS
#endif
-87
View File
@@ -1,87 +0,0 @@
/*
* Copyright (c) 2021 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 RDB_JSKIT_COMMON_H
#define RDB_JSKIT_COMMON_H
#include <string>
#include <vector>
#include "hilog/log.h"
#include "rdb_errno.h"
namespace OHOS {
namespace RdbJsKit {
static const OHOS::HiviewDFX::HiLogLabel PREFIX_LABEL = { LOG_CORE, 0xD001650, "RdbJsKit" };
#define LOG_DEBUG(...) ((void)OHOS::HiviewDFX::HiLog::Debug(PREFIX_LABEL, __VA_ARGS__))
#define LOG_INFO(...) ((void)OHOS::HiviewDFX::HiLog::Info(PREFIX_LABEL, __VA_ARGS__))
#define LOG_WARN(...) ((void)OHOS::HiviewDFX::HiLog::Warn(PREFIX_LABEL, __VA_ARGS__))
#define LOG_ERROR(...) ((void)OHOS::HiviewDFX::HiLog::Error(PREFIX_LABEL, __VA_ARGS__))
#define LOG_FATAL(...) ((void)OHOS::HiviewDFX::HiLog::Fatal(PREFIX_LABEL, __VA_ARGS__))
static const std::vector<std::string> ERR_INFO {
"E_ERROR",
"E_CANNOT_UPDATE_READONLY",
"E_REMOVE_FILE",
"E_EMPTY_FILE_NAME",
"E_EMPTY_TABLE_NAME",
"E_EMPTY_VALUES_BUCKET",
"E_INVALID_STATEMENT",
"E_INVALID_COLUMN_INDEX",
"E_INVALID_COLUMN_TYPE",
"E_INVALID_COLUMN_NAME",
"E_QUERY_IN_EXECUTE",
"E_TRANSACTION_IN_EXECUTE",
"E_EXECUTE_IN_STEP_QUERY",
"E_EXECUTE_WRITE_IN_READ_CONNECTION",
"E_BEGIN_TRANSACTION_IN_READ_CONNECTION",
"E_NO_TRANSACTION_IN_SESSION",
"E_MORE_STEP_QUERY_IN_ONE_SESSION",
"E_NO_ROW_IN_QUERY",
"E_INVALID_BIND_ARGS_COUNT",
"E_INVALID_OBJECT_TYPE",
"E_INVALID_CONFLICT_FLAG",
"E_HAVING_CLAUSE_NOT_IN_GROUP_BY",
"E_NOT_SUPPORTED_BY_STEP_RESULT_SET",
"E_STEP_RESULT_SET_CROSS_THREADS",
"E_STEP_RESULT_QUERY_NOT_EXECUTED",
"E_STEP_RESULT_IS_AFTER_LAST",
"E_STEP_RESULT_QUERY_EXCEEDED",
"E_STATEMENT_NOT_PREPARED",
"E_EXECUTE_RESULT_INCORRECT",
"E_STEP_RESULT_CLOSED",
"E_RELATIVE_PATH",
"E_EMPTY_NEW_ENCRYPT_KEY",
"E_CHANGE_UNENCRYPTED_TO_ENCRYPTED",
"E_CHANGE_ENCRYPT_KEY_IN_BUSY",
"E_STEP_STATEMENT_NOT_INIT",
"E_NOT_SUPPORTED_ATTACH_IN_WAL_MODE"
};
static inline const char *GetErrStr(int err)
{
if (err == OHOS::NativeRdb::E_OK) {
return nullptr;
}
size_t index = err - OHOS::NativeRdb::E_BASE - 1;
if (index >= ERR_INFO.size() || index < 0) {
return "Unkown error";
}
return ERR_INFO.at(index).c_str();
}
} // namespace RdbJsKit
} // namespace OHOS
#endif
@@ -16,7 +16,7 @@
#ifndef SHARED_BLOCK_H
#define SHARED_BLOCK_H
#include <inttypes.h>
#include <cinttypes>
#include <string>
#include <ashmem.h>
-121
View File
@@ -1,121 +0,0 @@
# Copyright (c) 2021 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.
import("//build/ohos.gni")
import("//build/ohos/ace/ace.gni")
ohos_copy("appdatamgr_declaration") {
sources = [ "./api" ]
outputs = [ target_out_dir + "/$target_name/" ]
module_source_dir = target_out_dir + "/$target_name"
module_install_name = ""
}
ohos_shared_library("storage") {
include_dirs = [
"//third_party/node/src",
"//utils/native/base/include",
"../../frameworks/jskitsimpl/common",
]
sources = [
"../../frameworks/jskitsimpl/native_preferences/entry_point.cpp",
"../../frameworks/jskitsimpl/native_preferences/napi_preference.cpp",
"../../frameworks/jskitsimpl/native_preferences/napi_preference_helper.cpp",
]
external_deps = [
"hilog_native:libhilog",
"napi:ace_napi",
"native_appdatamgr:native_preferences",
]
subsystem_name = "distributeddatamgr"
part_name = "native_appdatamgr"
relative_install_dir = "module/data"
}
ohos_shared_library("rdb") {
include_dirs = [
"//third_party/node/src",
"//utils/native/base/include",
"../../frameworks/jskitsimpl/common",
]
sources = [
"../../frameworks/jskitsimpl/common/js_ability.cpp",
"../../frameworks/jskitsimpl/common/js_utils.cpp",
"../../frameworks/jskitsimpl/native_rdb/entry_point.cpp",
"../../frameworks/jskitsimpl/native_rdb/napi_rdb_predicates.cpp",
"../../frameworks/jskitsimpl/native_rdb/napi_rdb_store.cpp",
"../../frameworks/jskitsimpl/native_rdb/napi_rdb_store_helper.cpp",
"../../frameworks/jskitsimpl/native_rdb/napi_result_set.cpp",
"../../frameworks/jskitsimpl/native_rdb/napi_values_bucket.cpp",
]
deps = [ "//utils/native/base:utils" ]
external_deps = [
"hilog_native:libhilog",
"napi:ace_napi",
"native_appdatamgr:native_appdatafwk",
"native_appdatamgr:native_rdb",
]
if (is_standard_system) {
defines = [ "STANDARD_SYSTEM_ENABLE" ]
deps += [ "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native" ]
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"ability_runtime:want",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
]
}
subsystem_name = "distributeddatamgr"
part_name = "native_appdatamgr"
relative_install_dir = "module/data"
}
ohos_shared_library("dataability") {
include_dirs = [
"//third_party/node/src",
"//utils/native/base/include",
"../../frameworks/jskitsimpl/common",
"../../frameworks/jskitsimpl/native_rdb",
]
sources = [
"../../frameworks/jskitsimpl/common/js_utils.cpp",
"../../frameworks/jskitsimpl/native_dataability/entry_point.cpp",
"../../frameworks/jskitsimpl/native_dataability/napi_data_ability_predicates.cpp",
"../../frameworks/jskitsimpl/native_dataability/napi_predicates_utils.cpp",
]
deps = [ "../../interfaces/jskits:rdb" ]
external_deps = [
"hilog_native:libhilog",
"napi:ace_napi",
"native_appdatamgr:native_dataability",
"native_appdatamgr:native_rdb",
]
subsystem_name = "distributeddatamgr"
part_name = "native_appdatamgr"
relative_install_dir = "module/data"
}