1 /* 2 * Copyright (c) 2023-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 COOPERATE_OUT_H 17 #define COOPERATE_OUT_H 18 19 #include "i_cooperate_state.h" 20 21 namespace OHOS { 22 namespace Msdp { 23 namespace DeviceStatus { 24 namespace Cooperate { 25 class CooperateOut : public ICooperateState { 26 public: 27 CooperateOut(IStateMachine &parent, IContext *env); 28 ~CooperateOut(); 29 30 void OnEvent(Context &context, const CooperateEvent &event) override; 31 void OnEnterState(Context &context) override; 32 void OnLeaveState(Context &context) override; 33 34 private: 35 class Initial final : public ICooperateStep { 36 public: 37 Initial(CooperateOut &parent); 38 ~Initial() = default; 39 40 void OnProgress(Context &context, const CooperateEvent &event) override; 41 void OnReset(Context &context, const CooperateEvent &event) override; 42 43 static void BuildChains(std::shared_ptr<Initial> self, CooperateOut &parent); 44 static void RemoveChains(std::shared_ptr<Initial> self); 45 46 private: 47 void OnDisable(Context &context, const CooperateEvent &event); 48 void OnStart(Context &context, const CooperateEvent &event); 49 void OnStop(Context &context, const CooperateEvent &event); 50 void OnComeBack(Context &context, const CooperateEvent &event); 51 void OnRemoteStart(Context &context, const CooperateEvent &event); 52 void OnRemoteStop(Context &context, const CooperateEvent &event); 53 void OnRelay(Context &context, const CooperateEvent &event); 54 void OnHotplug(Context &context, const CooperateEvent &event); 55 void OnAppClosed(Context &context, const CooperateEvent &event); 56 void OnPointerEvent(Context &context, const CooperateEvent &event); 57 void OnBoardOffline(Context &context, const CooperateEvent &event); 58 void OnSwitchChanged(Context &context, const CooperateEvent &event); 59 void OnSoftbusSessionClosed(Context &context, const CooperateEvent &event); 60 61 CooperateOut &parent_; 62 }; 63 64 void StopCooperate(Context &context, const CooperateEvent &event); 65 void SetPointerVisible(Context &context); 66 void UnchainConnections(Context &context, const StopCooperateEvent &event) const; 67 void OnSetCooperatePriv(uint32_t priv); 68 69 IContext *env_ { nullptr }; 70 std::shared_ptr<Initial> initial_ { nullptr }; 71 }; 72 } // namespace Cooperate 73 } // namespace DeviceStatus 74 } // namespace Msdp 75 } // namespace OHOS 76 #endif // COOPERATE_OUT_H 77