1 /* 2 * Copyright (c) 2022 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 16 #ifndef DATASHARE_STUB_IMPL_H 17 #define DATASHARE_STUB_IMPL_H 18 19 #include <memory> 20 #include "datashare_stub.h" 21 #include "media_datashare_ext_ability.h" 22 #include "native_engine/native_value.h" 23 24 namespace OHOS { 25 namespace DataShare { 26 using DataShare::MediaDataShareExtAbility; 27 #define EXPORT __attribute__ ((visibility ("default"))) 28 class EXPORT MediaDataShareStubImpl : public DataShareStub { 29 public: MediaDataShareStubImpl(const std::shared_ptr<MediaDataShareExtAbility> & extension,napi_env env)30 EXPORT explicit MediaDataShareStubImpl(const std::shared_ptr<MediaDataShareExtAbility>& extension, napi_env env) 31 : extension_(extension) 32 { 33 } 34 ~MediaDataShareStubImpl()35 EXPORT virtual ~MediaDataShareStubImpl() {} 36 37 EXPORT std::vector<std::string> GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) override; 38 39 EXPORT int OpenFile(const Uri &uri, const std::string &mode) override; 40 41 EXPORT int OpenRawFile(const Uri &uri, const std::string &mode) override; 42 43 EXPORT int Insert(const Uri &uri, const DataShareValuesBucket &value) override; 44 45 EXPORT int InsertExt(const Uri &uri, const DataShareValuesBucket &value, std::string &result) override; 46 47 EXPORT int Update(const Uri &uri, const DataSharePredicates &predicates, 48 const DataShareValuesBucket &value) override; 49 50 EXPORT int Delete(const Uri &uri, const DataSharePredicates &predicates) override; 51 52 EXPORT std::shared_ptr<DataShareResultSet> Query(const Uri &uri, const DataSharePredicates &predicates, 53 std::vector<std::string> &columns, DatashareBusinessError &businessError) override; 54 55 EXPORT std::string GetType(const Uri &uri) override; 56 57 EXPORT int BatchInsert(const Uri &uri, const std::vector<DataShareValuesBucket> &values) override; 58 59 EXPORT bool RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) override; 60 61 EXPORT bool UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) override; 62 63 EXPORT bool NotifyChange(const Uri &uri) override; 64 65 EXPORT Uri NormalizeUri(const Uri &uri) override; 66 67 EXPORT Uri DenormalizeUri(const Uri &uri) override; 68 69 private: 70 EXPORT std::shared_ptr<MediaDataShareExtAbility> GetOwner(); 71 72 private: 73 std::shared_ptr<MediaDataShareExtAbility> extension_; 74 }; 75 } // namespace DataShare 76 } // namespace OHOS 77 #endif // DATASHARE_STUB_IMPL_H 78 79