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