• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "i_observer_manager_interface.h"
24 #include "media_observer_manager.h"
25 
26 namespace OHOS {
27 namespace DataShare {
28 using DataShare::MediaDataShareExtAbility;
29 #define EXPORT __attribute__ ((visibility ("default")))
30 class EXPORT MediaDataShareStubImpl : public DataShareStub {
31 public:
MediaDataShareStubImpl(const std::shared_ptr<MediaDataShareExtAbility> & extension,napi_env env)32     EXPORT explicit MediaDataShareStubImpl(const std::shared_ptr<MediaDataShareExtAbility>& extension, napi_env env)
33         : extension_(extension)
34     {
35     }
36 
~MediaDataShareStubImpl()37     EXPORT virtual ~MediaDataShareStubImpl() {}
38 
39     EXPORT std::vector<std::string> GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) override;
40 
41     EXPORT int OpenFile(const Uri &uri, const std::string &mode) override;
42 
43     EXPORT int OpenRawFile(const Uri &uri, const std::string &mode) override;
44 
45     EXPORT int Insert(const Uri &uri, const DataShareValuesBucket &value) override;
46 
47     EXPORT int InsertExt(const Uri &uri, const DataShareValuesBucket &value, std::string &result) override;
48 
49     EXPORT int Update(const Uri &uri, const DataSharePredicates &predicates,
50         const DataShareValuesBucket &value) override;
51 
52     EXPORT int Delete(const Uri &uri, const DataSharePredicates &predicates) override;
53 
54     EXPORT std::shared_ptr<DataShareResultSet> Query(const Uri &uri, const DataSharePredicates &predicates,
55         std::vector<std::string> &columns, DatashareBusinessError &businessError) override;
56 
57     EXPORT std::string GetType(const Uri &uri) override;
58 
59     EXPORT int BatchInsert(const Uri &uri, const std::vector<DataShareValuesBucket> &values) override;
60 
61     EXPORT bool RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) override;
62 
63     EXPORT bool UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) override;
64 
65     EXPORT int RegisterObserverExtProvider(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver,
66         bool isDescendants, RegisterOption option) override;
67 
68     EXPORT int UnregisterObserverExtProvider(const Uri &uri,
69         const sptr<AAFwk::IDataAbilityObserver> &dataObserver) override;
70 
71     EXPORT bool NotifyChange(const Uri &uri) override;
72 
73     EXPORT Uri NormalizeUri(const Uri &uri) override;
74 
75     EXPORT Uri DenormalizeUri(const Uri &uri) override;
76 
77     EXPORT int32_t UserDefineFunc(MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
78 
79 private:
80     EXPORT std::shared_ptr<MediaDataShareExtAbility> GetOwner();
81 
82 private:
83     std::shared_ptr<MediaDataShareExtAbility> extension_;
84 };
85 } // namespace DataShare
86 } // namespace OHOS
87 #endif // DATASHARE_STUB_IMPL_H
88 
89