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 UDMF_SERVICE_PROXY_H
17 #define UDMF_SERVICE_PROXY_H
18 
19 #include <string>
20 
21 #include "iremote_broker.h"
22 #include "iremote_proxy.h"
23 
24 #include "distributeddata_udmf_ipc_interface_code.h"
25 #include "udmf_service.h"
26 
27 namespace OHOS {
28 namespace UDMF {
29 class IUdmfService : public UdmfService, public IRemoteBroker {
30 public:
31     using UdmfService::UdmfService;
32 };
33 
34 class UdmfServiceProxy : public IRemoteProxy<IUdmfService> {
35 public:
36     explicit UdmfServiceProxy(const sptr<IRemoteObject> &object);
37 
38     int32_t SetData(CustomOption &option, UnifiedData &unifiedData, std::string &key) override;
39     int32_t GetData(const QueryOption &query, UnifiedData &unifiedData) override;
40     int32_t GetBatchData(const QueryOption &query, std::vector<UnifiedData> &unifiedDataSet) override;
41     int32_t UpdateData(const QueryOption &query, UnifiedData &unifiedData) override;
42     int32_t DeleteData(const QueryOption &query, std::vector<UnifiedData> &unifiedDataSet) override;
43     int32_t GetSummary(const QueryOption &query, Summary &summary) override;
44     int32_t AddPrivilege(const QueryOption &query, Privilege &privilege) override;
45     int32_t Sync(const QueryOption &query, const std::vector<std::string> &devices) override;
46     int32_t IsRemoteData(const QueryOption &query, bool &result) override;
47     int32_t SetAppShareOption(const std::string &intention, int32_t shareOption) override;
48     int32_t GetAppShareOption(const std::string &intention, int32_t &shareOption) override;
49     int32_t RemoveAppShareOption(const std::string &intention) override;
50 private:
51     static inline BrokerDelegator<UdmfServiceProxy> delegator_;
52     int32_t SendRequest(UdmfServiceInterfaceCode code, MessageParcel &data,
53                         MessageParcel &reply, MessageOption &option);
54 };
55 } // namespace UDMF
56 } // namespace OHOS
57 #endif // UDMF_SERVICE_PROXY_H