1 /*
2  * Copyright (c) 2023 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_STUB_H
17 #define UDMF_SERVICE_STUB_H
18 
19 #include <map>
20 #include <string>
21 
22 #include "feature/feature_system.h"
23 #include "message_parcel.h"
24 
25 #include "distributeddata_udmf_ipc_interface_code.h"
26 #include "error_code.h"
27 #include "udmf_service.h"
28 
29 namespace OHOS {
30 namespace UDMF {
31 /*
32  * UDMF server stub
33  */
34 class UdmfServiceStub : public UdmfService, public DistributedData::FeatureSystem::Feature {
35 public:
36     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply) override;
37 
38 private:
39     int32_t OnSetData(MessageParcel &data, MessageParcel &reply);
40     int32_t OnGetData(MessageParcel &data, MessageParcel &reply);
41     int32_t OnGetBatchData(MessageParcel &data, MessageParcel &reply);
42     int32_t OnUpdateData(MessageParcel &data, MessageParcel &reply);
43     int32_t OnDeleteData(MessageParcel &data, MessageParcel &reply);
44     int32_t OnGetSummary(MessageParcel &data, MessageParcel &reply);
45     int32_t OnAddPrivilege(MessageParcel &data, MessageParcel &reply);
46     int32_t OnSync(MessageParcel &data, MessageParcel &reply);
47     int32_t OnIsRemoteData(MessageParcel &data, MessageParcel &reply);
48     int32_t OnSetAppShareOption(MessageParcel &data, MessageParcel &reply);
49     int32_t OnGetAppShareOption(MessageParcel &data, MessageParcel &reply);
50     int32_t OnRemoveAppShareOption(MessageParcel &data, MessageParcel &reply);
51 
52     using Handler = int32_t (UdmfServiceStub::*)(MessageParcel &data, MessageParcel &reply);
53     static constexpr Handler HANDLERS[static_cast<uint32_t>(UdmfServiceInterfaceCode::CODE_BUTT)] = {
54         &UdmfServiceStub::OnSetData,
55         &UdmfServiceStub::OnGetData,
56         &UdmfServiceStub::OnGetBatchData,
57         &UdmfServiceStub::OnUpdateData,
58         &UdmfServiceStub::OnDeleteData,
59         &UdmfServiceStub::OnGetSummary,
60         &UdmfServiceStub::OnAddPrivilege,
61         &UdmfServiceStub::OnSync,
62         &UdmfServiceStub::OnIsRemoteData,
63         &UdmfServiceStub::OnSetAppShareOption,
64         &UdmfServiceStub::OnGetAppShareOption,
65         &UdmfServiceStub::OnRemoveAppShareOption
66     };
67 };
68 } // namespace UDMF
69 } // namespace OHOS
70 #endif // UDMF_SERVICE_STUB_H
71