176fd607bSopenharmony_ci/* 276fd607bSopenharmony_ci * Copyright (C) 2022-2024 Huawei Device Co., Ltd. 376fd607bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 476fd607bSopenharmony_ci * you may not use this file except in compliance with the License. 576fd607bSopenharmony_ci * You may obtain a copy of the License at 676fd607bSopenharmony_ci * 776fd607bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 876fd607bSopenharmony_ci * 976fd607bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1076fd607bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1176fd607bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1276fd607bSopenharmony_ci * See the License for the specific language governing permissions and 1376fd607bSopenharmony_ci * limitations under the License. 1476fd607bSopenharmony_ci */ 1576fd607bSopenharmony_ci 1676fd607bSopenharmony_ci#ifndef INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_USER_FILE_CLIENT_H 1776fd607bSopenharmony_ci#define INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_USER_FILE_CLIENT_H 1876fd607bSopenharmony_ci 1976fd607bSopenharmony_ci#include "datashare_helper.h" 2076fd607bSopenharmony_ci#include "datashare_predicates.h" 2176fd607bSopenharmony_ci#include "napi_base_context.h" 2276fd607bSopenharmony_ci#include "napi_error.h" 2376fd607bSopenharmony_ci#include "napi/native_api.h" 2476fd607bSopenharmony_ci#include "napi/native_node_api.h" 2576fd607bSopenharmony_ci#include "napi_remote_object.h" 2676fd607bSopenharmony_ci#include "rdb_store.h" 2776fd607bSopenharmony_ci#include "uri.h" 2876fd607bSopenharmony_ci 2976fd607bSopenharmony_cinamespace OHOS { 3076fd607bSopenharmony_cinamespace Media { 3176fd607bSopenharmony_ci#define EXPORT __attribute__ ((visibility ("default"))) 3276fd607bSopenharmony_ciclass UserFileClient { 3376fd607bSopenharmony_cipublic: 3476fd607bSopenharmony_ci EXPORT UserFileClient() {} 3576fd607bSopenharmony_ci EXPORT virtual ~UserFileClient() {} 3676fd607bSopenharmony_ci EXPORT static bool IsValid(); 3776fd607bSopenharmony_ci EXPORT static napi_status CheckIsStage(napi_env env, napi_callback_info info, bool &result); 3876fd607bSopenharmony_ci EXPORT static sptr<IRemoteObject> ParseTokenInStageMode(napi_env env, napi_callback_info info); 3976fd607bSopenharmony_ci EXPORT static sptr<IRemoteObject> ParseTokenInAbility(napi_env env, napi_callback_info info); 4076fd607bSopenharmony_ci 4176fd607bSopenharmony_ci EXPORT static void Init(const sptr<IRemoteObject> &token, bool isSetHelper = false); 4276fd607bSopenharmony_ci EXPORT static void Init(napi_env env, napi_callback_info info); 4376fd607bSopenharmony_ci EXPORT static std::shared_ptr<DataShare::DataShareResultSet> Query(Uri &uri, 4476fd607bSopenharmony_ci const DataShare::DataSharePredicates &predicates, std::vector<std::string> &columns, int &errCode); 4576fd607bSopenharmony_ci EXPORT static int Insert(Uri &uri, const DataShare::DataShareValuesBucket &value); 4676fd607bSopenharmony_ci EXPORT static int InsertExt(Uri &uri, const DataShare::DataShareValuesBucket &value, std::string &result); 4776fd607bSopenharmony_ci EXPORT static int BatchInsert(Uri &uri, const std::vector<DataShare::DataShareValuesBucket> &values); 4876fd607bSopenharmony_ci EXPORT static int Delete(Uri &uri, const DataShare::DataSharePredicates &predicates); 4976fd607bSopenharmony_ci EXPORT static void NotifyChange(const Uri &uri); 5076fd607bSopenharmony_ci EXPORT static void RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver); 5176fd607bSopenharmony_ci EXPORT static void UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver); 5276fd607bSopenharmony_ci EXPORT static int OpenFile(Uri &uri, const std::string &mode); 5376fd607bSopenharmony_ci EXPORT static int Update(Uri &uri, const DataShare::DataSharePredicates &predicates, 5476fd607bSopenharmony_ci const DataShare::DataShareValuesBucket &value); 5576fd607bSopenharmony_ci EXPORT static void RegisterObserverExt(const Uri &uri, 5676fd607bSopenharmony_ci std::shared_ptr<DataShare::DataShareObserver> dataObserver, bool isDescendants); 5776fd607bSopenharmony_ci EXPORT static void UnregisterObserverExt(const Uri &uri, 5876fd607bSopenharmony_ci std::shared_ptr<DataShare::DataShareObserver> dataObserver); 5976fd607bSopenharmony_ci EXPORT static void Clear(); 6076fd607bSopenharmony_ci EXPORT static std::shared_ptr<NativeRdb::AbsSharedResultSet> QueryRdb(Uri &uri, 6176fd607bSopenharmony_ci const DataShare::DataSharePredicates &predicates, std::vector<std::string> &columns); 6276fd607bSopenharmony_ciprivate: 6376fd607bSopenharmony_ci static inline std::shared_ptr<DataShare::DataShareHelper> sDataShareHelper_ = nullptr; 6476fd607bSopenharmony_ci static std::shared_ptr<DataShare::DataShareHelper> GetDataShareHelper(napi_env env, napi_callback_info info); 6576fd607bSopenharmony_ci}; 6676fd607bSopenharmony_ci} 6776fd607bSopenharmony_ci} 6876fd607bSopenharmony_ci 6976fd607bSopenharmony_ci#endif // INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_USER_FILE_CLIENT_H