1fc223305Sopenharmony_ci/*
2fc223305Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3fc223305Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fc223305Sopenharmony_ci * you may not use this file except in compliance with the License.
5fc223305Sopenharmony_ci * You may obtain a copy of the License at
6fc223305Sopenharmony_ci *
7fc223305Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fc223305Sopenharmony_ci *
9fc223305Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fc223305Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fc223305Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fc223305Sopenharmony_ci * See the License for the specific language governing permissions and
13fc223305Sopenharmony_ci * limitations under the License.
14fc223305Sopenharmony_ci */
15fc223305Sopenharmony_ci#ifndef PREFERENCES_FFI_H
16fc223305Sopenharmony_ci#define PREFERENCES_FFI_H
17fc223305Sopenharmony_ci
18fc223305Sopenharmony_ci#include <cstdint>
19fc223305Sopenharmony_ci
20fc223305Sopenharmony_ci#include "napi_base_context.h"
21fc223305Sopenharmony_ci#include "ffi_remote_data.h"
22fc223305Sopenharmony_ci#include "cj_common_ffi.h"
23fc223305Sopenharmony_ci#include "preferences_interface.h"
24fc223305Sopenharmony_ci
25fc223305Sopenharmony_cinamespace OHOS {
26fc223305Sopenharmony_cinamespace Preferences {
27fc223305Sopenharmony_ci
28fc223305Sopenharmony_ciextern "C" {
29fc223305Sopenharmony_ci    FFI_EXPORT int64_t FfiOHOSPreferencesGetPreferences(OHOS::AbilityRuntime::Context* context, const char* name,
30fc223305Sopenharmony_ci        const char* dataGroupId, int32_t* errCode);
31fc223305Sopenharmony_ci
32fc223305Sopenharmony_ci    FFI_EXPORT int32_t FfiOHOSPreferencesDeletePreferences(OHOS::AbilityRuntime::Context* context, const char* name,
33fc223305Sopenharmony_ci        const char* dataGroupId);
34fc223305Sopenharmony_ci
35fc223305Sopenharmony_ci    FFI_EXPORT int32_t FfiOHOSPreferencesRemovePreferencesFromCache(OHOS::AbilityRuntime::Context* context,
36fc223305Sopenharmony_ci        const char* name, const char* dataGroupId);
37fc223305Sopenharmony_ci
38fc223305Sopenharmony_ci    FFI_EXPORT int32_t FfiOHOSPreferencesDelete(int64_t id, const char* key);
39fc223305Sopenharmony_ci
40fc223305Sopenharmony_ci    FFI_EXPORT bool FfiOHOSPreferencesHas(int64_t id, const char* key);
41fc223305Sopenharmony_ci
42fc223305Sopenharmony_ci    FFI_EXPORT int32_t FfiOHOSPreferencesOn(int64_t id, const char* mode, void (*callbackRef)(const char* valueRef));
43fc223305Sopenharmony_ci
44fc223305Sopenharmony_ci    FFI_EXPORT int32_t FfiOHOSPreferencesOff(int64_t id, const char* mode, void (*callbackRef)(const char* valueRef));
45fc223305Sopenharmony_ci
46fc223305Sopenharmony_ci    FFI_EXPORT int32_t FfiOHOSPreferencesOffAll(int64_t id, const char* mode);
47fc223305Sopenharmony_ci
48fc223305Sopenharmony_ci    FFI_EXPORT ValueType FfiOHOSPreferencesGet(int64_t id, const char* key, ValueType defValue);
49fc223305Sopenharmony_ci
50fc223305Sopenharmony_ci    FFI_EXPORT int32_t FfiOHOSPreferencesPut(int64_t id, const char* key, ValueType value);
51fc223305Sopenharmony_ci
52fc223305Sopenharmony_ci    FFI_EXPORT ValueTypes FfiOHOSPreferencesGetAll(int64_t id);
53fc223305Sopenharmony_ci
54fc223305Sopenharmony_ci    FFI_EXPORT void FfiOHOSPreferencesFlush(int64_t id);
55fc223305Sopenharmony_ci
56fc223305Sopenharmony_ci    FFI_EXPORT void FfiOHOSPreferencesClear(int64_t id);
57fc223305Sopenharmony_ci}
58fc223305Sopenharmony_ci
59fc223305Sopenharmony_ci} // namespace Preferences
60fc223305Sopenharmony_ci} // namespace OHOS
61fc223305Sopenharmony_ci
62fc223305Sopenharmony_ci#endif