1 /*
2  * Copyright (c) 2021-2024 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 OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_STUB_H
17 #define OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_STUB_H
18 
19 #include <map>
20 #include <unordered_set>
21 
22 #include "iremote_stub.h"
23 
24 #include "distributed_device_profile_errors.h"
25 #include "i_distributed_device_profile.h"
26 #include "ipc_utils.h"
27 
28 namespace OHOS {
29 namespace DistributedDeviceProfile {
30 class DistributedDeviceProfileStubNew : public IRemoteStub<IDistributedDeviceProfile> {
31 public:
32     DistributedDeviceProfileStubNew();
33     ~DistributedDeviceProfileStubNew();
34 
35     int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
36 
37     int32_t PutAccessControlProfileInner(MessageParcel& data, MessageParcel& reply);
38     int32_t UpdateAccessControlProfileInner(MessageParcel& data, MessageParcel& reply);
39     int32_t GetTrustDeviceProfileInner(MessageParcel& data, MessageParcel& reply);
40     int32_t GetAllTrustDeviceProfileInner(MessageParcel& data, MessageParcel& reply);
41     int32_t GetAccessControlProfileInner(MessageParcel& data, MessageParcel& reply);
42     int32_t GetAllAccessControlProfileInner(MessageParcel& data, MessageParcel& reply);
43     int32_t DeleteAccessControlProfileInner(MessageParcel& data, MessageParcel& reply);
44     int32_t PutServiceProfileInner(MessageParcel& data, MessageParcel& reply);
45     int32_t PutServiceProfileBatchInner(MessageParcel& data, MessageParcel& reply);
46     int32_t PutCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply);
47     int32_t PutCharacteristicProfileBatchInner(MessageParcel& data, MessageParcel& reply);
48     int32_t GetDeviceProfileInner(MessageParcel& data, MessageParcel& reply);
49     int32_t GetServiceProfileInner(MessageParcel& data, MessageParcel& reply);
50     int32_t GetCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply);
51     int32_t DeleteServiceProfileInner(MessageParcel& data, MessageParcel& reply);
52     int32_t DeleteCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply);
53     int32_t SubscribeDeviceProfileInner(MessageParcel& data, MessageParcel& reply);
54     int32_t UnSubscribeDeviceProfileInner(MessageParcel& data, MessageParcel& reply);
55     int32_t SyncDeviceProfileInner(MessageParcel& data, MessageParcel& reply);
56     int32_t SendSubscribeInfosInner(MessageParcel& data, MessageParcel& reply);
57     int32_t SubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply);
58     int32_t UnSubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply);
59     virtual void DelayUnloadTask() = 0;
60     virtual bool IsInited() = 0;
61 
62 private:
63     using Func = int32_t(DistributedDeviceProfileStubNew::*)(MessageParcel& data, MessageParcel& reply);
64     bool IsInterfaceTokenValid(MessageParcel& data);
65     void InitAclAndSubscribe();
66     int32_t NotifyEventInner(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option);
67     int32_t NotifyAclEventInner(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option);
68 private:
69     std::map<uint32_t, Func> funcsMap_;
70     std::unordered_set<uint32_t> aclAndSubscribeFuncs_;
71 };
72 } // namespace DeviceProfile
73 } // namespace OHOS
74 #endif // OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_STUB_H
75