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_EVENTS_H 17 #define COOPERATE_EVENTS_H 18 19 #include <string> 20 #include <variant> 21 22 namespace OHOS { 23 namespace Msdp { 24 namespace DeviceStatus { 25 namespace Cooperate { 26 enum CooperateState : size_t { 27 COOPERATE_STATE_FREE = 0, 28 COOPERATE_STATE_OUT, 29 COOPERATE_STATE_IN, 30 N_COOPERATE_STATES, 31 }; 32 33 enum class CooperateEventType { 34 NOOP, 35 QUIT, 36 UPDATE_STATE, 37 REGISTER_LISTENER, 38 UNREGISTER_LISTENER, 39 REGISTER_HOTAREA_LISTENER, 40 UNREGISTER_HOTAREA_LISTENER, 41 ENABLE, 42 DISABLE, 43 START, 44 STOP, 45 GET_COOPERATE_STATE, 46 DUMP, 47 APP_CLOSED, 48 DDM_BOARD_ONLINE, 49 DDM_BOARD_OFFLINE, 50 DDP_COOPERATE_SWITCH_CHANGED, 51 INPUT_PLUG_KEYBOARD, 52 INPUT_UNPLUG_KEYBOARD, 53 INPUT_UNPLUG_POINTER, 54 INPUT_POINTER_MOVE, 55 DINPUT_PREPARE_RESULT, 56 DINPUT_START_RESULT, 57 DINPUT_SESSION_CLOSED, 58 DINPUT_STOP_RESULT, 59 DSOFTBUS_SESSION_OPEND, 60 DSOFTBUS_SESSION_CLOSED, 61 DSOFTBUS_START_COOPERATE, 62 DSOFTBUS_START_COOPERATE_RESPONSE, 63 DSOFTBUS_START_COOPERATE_FINISHED, 64 }; 65 66 struct UpdateStateEvent { 67 CooperateState current; 68 }; 69 70 struct RegisterListenerEvent { 71 int32_t pid; 72 }; 73 74 using UnregisterListenerEvent = RegisterListenerEvent; 75 using RegisterHotareaListenerEvent = RegisterListenerEvent; 76 using UnregisterHotareaListenerEvent = RegisterListenerEvent; 77 using EnableCooperateEvent = RegisterListenerEvent; 78 using DisableCooperateEvent = RegisterListenerEvent; 79 80 struct StartCooperateEvent { 81 int32_t pid; 82 int32_t userData; 83 std::string remoteNetworkId; 84 int32_t startDeviceId; 85 }; 86 87 struct StopCooperateEvent { 88 int32_t pid; 89 int32_t userData; 90 bool isUnchained; 91 }; 92 93 struct GetCooperateStateEvent { 94 int32_t pid; 95 int32_t userData; 96 std::string networkId; 97 }; 98 99 struct DumpEvent { 100 int32_t fd; 101 }; 102 103 struct DDMBoardOnlineEvent { 104 std::string networkId; 105 }; 106 107 using DDMBoardOfflineEvent = DDMBoardOnlineEvent; 108 109 struct DDPCooperateSwitchChanged { 110 std::string networkId; 111 bool status; 112 }; 113 114 struct InputHotplugEvent { 115 std::string dhid; 116 }; 117 118 struct DInputPrepareResult { 119 std::string remoteNetworkId; 120 std::string originNetworkId; 121 int32_t startDeviceId; 122 bool success; 123 }; 124 125 struct DInputStopResult { 126 std::string originNetworkId; 127 int32_t startDeviceId; 128 bool success; 129 }; 130 131 using DInputStartResult = DInputPrepareResult; 132 133 struct DSoftbusSessionClosed { 134 std::string networkId; 135 }; 136 137 using DSoftbusStartCooperate = DSoftbusSessionClosed; 138 139 struct DSoftbusStartCooperateResponse { 140 std::string networkId; 141 bool normal; 142 }; 143 144 struct Coordinate { 145 int32_t x; 146 int32_t y; 147 }; 148 149 struct DSoftbusStartCooperateFinished { 150 std::string networkId; 151 std::string startDeviceDhid; 152 bool success; 153 Coordinate cursorPos; 154 }; 155 156 struct CooperateEvent { CooperateEventCooperateEvent157 CooperateEvent() : type(CooperateEventType::QUIT) {} 158 CooperateEventCooperateEvent159 explicit CooperateEvent(CooperateEventType ty) : type(ty) {} 160 161 template<typename Event> CooperateEventCooperateEvent162 CooperateEvent(CooperateEventType ty, Event ev) : type(ty), event(ev) {} 163 164 CooperateEventType type; 165 std::variant< 166 UpdateStateEvent, 167 RegisterListenerEvent, 168 StartCooperateEvent, 169 StopCooperateEvent, 170 GetCooperateStateEvent, 171 DumpEvent, 172 DDMBoardOnlineEvent, 173 DDPCooperateSwitchChanged, 174 DInputPrepareResult, 175 DInputStopResult, 176 InputHotplugEvent, 177 DSoftbusSessionClosed, 178 DSoftbusStartCooperateResponse, 179 DSoftbusStartCooperateFinished 180 > event; 181 }; 182 } // namespace Cooperate 183 } // namespace DeviceStatus 184 } // namespace Msdp 185 } // namespace OHOS 186 #endif // COOPERATE_EVENTS_H 187