• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 COOPERATE_PARAMS_H
17 #define COOPERATE_PARAMS_H
18 
19 #include <string>
20 
21 #include "coordination_message.h"
22 #include "intention_identity.h"
23 
24 namespace OHOS {
25 namespace Msdp {
26 namespace DeviceStatus {
27 enum CooperateRequestID : uint32_t {
28     UNKNOWN_COOPERATE_ACTION,
29     REGISTER_LISTENER,
30     UNREGISTER_LISTENER,
31     REGISTER_HOTAREA_LISTENER,
32     UNREGISTER_HOTAREA_LISTENER,
33     GET_COOPERATE_STATE,
34     GET_COOPERATE_STATE_SYNC,
35     REGISTER_EVENT_LISTENER,
36     UNREGISTER_EVENT_LISTENER,
37     SET_DAMPLING_COEFFICIENT,
38 };
39 
40 struct StartCooperateParam final : public ParamBase {
41     StartCooperateParam() = default;
42     StartCooperateParam(int32_t userData, const std::string &remoteNetworkId,
43                         int32_t startDeviceId, bool checkPermission, const CooperateOptions &options,
44                         int32_t cooperateParamType);
45     bool Marshalling(MessageParcel &parcel) const override;
46     bool Unmarshalling(MessageParcel &parcel) override;
47 
48     std::string remoteNetworkId;
49     int32_t userData { -1 };
50     int32_t startDeviceId { -1 };
51     bool checkPermission { false };
52     CooperateOptions options;
53     int32_t cooperateParamType { 0 };
54 };
55 
56 struct StopCooperateParam final : public ParamBase {
57     StopCooperateParam() = default;
58     StopCooperateParam(int32_t userData, bool isUnchained, bool checkPermission);
59     bool Marshalling(MessageParcel &parcel) const override;
60     bool Unmarshalling(MessageParcel &parcel) override;
61 
62     int32_t userData { -1 };
63     bool isUnchained { false };
64     bool checkPermission { false };
65 };
66 
67 struct GetCooperateStateParam final : public ParamBase {
68     GetCooperateStateParam() = default;
69     GetCooperateStateParam(int32_t userData, const std::string &networkId, bool checkPermission);
70     bool Marshalling(MessageParcel &parcel) const override;
71     bool Unmarshalling(MessageParcel &parcel) override;
72 
73     std::string networkId;
74     int32_t userData { -1 };
75     bool checkPermission { false };
76 };
77 
78 struct RegisterEventListenerParam final : public ParamBase {
79     RegisterEventListenerParam() = default;
80     RegisterEventListenerParam(const std::string &networkId);
81     bool Marshalling(MessageParcel &parcel) const override;
82     bool Unmarshalling(MessageParcel &parcel) override;
83     std::string networkId;
84 };
85 
86 using UnregisterEventListenerParam = RegisterEventListenerParam;
87 
88 struct SetDamplingCoefficientParam final : public ParamBase {
89     SetDamplingCoefficientParam() = default;
90     SetDamplingCoefficientParam(uint32_t direction, double coefficient);
91     bool Marshalling(MessageParcel &parcel) const override;
92     bool Unmarshalling(MessageParcel &parcel) override;
93 
94     uint32_t direction {};
95     double coefficient { 1.0 };
96 };
97 
98 struct GetCooperateStateSyncParam final : public ParamBase {
99     GetCooperateStateSyncParam() = default;
100     GetCooperateStateSyncParam(const std::string &udId);
101     bool Marshalling(MessageParcel &parcel) const override;
102     bool Unmarshalling(MessageParcel &parcel) override;
103 
104     std::string udId;
105 };
106 
107 struct RegisterHotAreaListenerParam final : public ParamBase {
108     RegisterHotAreaListenerParam() = default;
109     RegisterHotAreaListenerParam(int32_t userData, bool checkPermission);
110     bool Marshalling(MessageParcel &parcel) const override;
111     bool Unmarshalling(MessageParcel &parcel) override;
112     int32_t userData { -1 };
113     bool checkPermission { false };
114 };
115 
116 using UnregisterHotAreaListenerParam = RegisterHotAreaListenerParam;
117 } // namespace DeviceStatus
118 } // namespace Msdp
119 } // namespace OHOS
120 #endif // COOPERATE_PARAMS_H
121