• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 IF_MMI_CLIENT_H
17 #define IF_MMI_CLIENT_H
18 
19 #include "event_handler.h"
20 
21 namespace OHOS {
22 namespace MMI {
23 class NetPacket;
24 class IfMMIClient;
25 using MMIClientPtr = std::shared_ptr<IfMMIClient>;
26 using EventHandlerPtr = std::shared_ptr<AppExecFwk::EventHandler>;
27 typedef std::function<void(const IfMMIClient&)> ConnectCallback;
28 class IfMMIClient {
29 public:
30     virtual MMIClientPtr GetSharedPtr() = 0;
31     virtual bool GetCurrentConnectedStatus() const = 0;
32     virtual bool Start() = 0;
33     virtual bool SendMessage(const NetPacket& pkt) const = 0;
34     virtual void RegisterConnectedFunction(ConnectCallback fun) = 0;
35     virtual void RegisterDisconnectedFunction(ConnectCallback fun) = 0;
36     virtual void OnRecvMsg(const char *buf, size_t size) = 0;
37     virtual int32_t Reconnect() = 0;
38     virtual void OnDisconnect() = 0;
39     virtual void SetEventHandler(EventHandlerPtr eventHandler) = 0;
40     virtual void MarkIsEventHandlerChanged(EventHandlerPtr eventHandler) = 0;
41     virtual bool IsEventHandlerChanged() = 0;
42     virtual EventHandlerPtr GetEventHandler() const = 0;
43 };
44 } // namespace MMI
45 } // namespace OHOS
46 #endif // IF_MMI_CLIENT_H