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 class MediaDataShareStubImpl : public DataShareStub { 28 public: MediaDataShareStubImpl(const std::shared_ptr<MediaDataShareExtAbility> & extension,napi_env env)29 explicit MediaDataShareStubImpl(const std::shared_ptr<MediaDataShareExtAbility>& extension, napi_env env) 30 : extension_(extension) 31 { 32 } 33 ~MediaDataShareStubImpl()34 virtual ~MediaDataShareStubImpl() {} 35 36 std::vector<std::string> GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) override; 37 38 int OpenFile(const Uri &uri, const std::string &mode) override; 39 40 int OpenRawFile(const Uri &uri, const std::string &mode) override; 41 42 int Insert(const Uri &uri, const DataShareValuesBucket &value) override; 43 44 int Update(const Uri &uri, const DataSharePredicates &predicates, 45 const DataShareValuesBucket &value) override; 46 47 int Delete(const Uri &uri, const DataSharePredicates &predicates) override; 48 49 std::shared_ptr<DataShareResultSet> Query(const Uri &uri, 50 const DataSharePredicates &predicates, std::vector<std::string> &columns) override; 51 52 std::string GetType(const Uri &uri) override; 53 54 int BatchInsert(const Uri &uri, const std::vector<DataShareValuesBucket> &values) override; 55 56 bool RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) override; 57 58 bool UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) override; 59 60 bool NotifyChange(const Uri &uri) override; 61 62 Uri NormalizeUri(const Uri &uri) override; 63 64 Uri DenormalizeUri(const Uri &uri) override; 65 66 private: 67 std::shared_ptr<MediaDataShareExtAbility> GetOwner(); 68 69 private: 70 std::shared_ptr<MediaDataShareExtAbility> extension_; 71 }; 72 } // namespace DataShare 73 } // namespace OHOS 74 #endif // DATASHARE_STUB_IMPL_H 75 76