File indexing completed on 2024-04-28 15:39:42
0001 // SPDX-FileCopyrightText: 2014-2022 Jesper K. Pedersen <blackie@kde.org> 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #ifndef REMOTECONNECTION_H 0006 #define REMOTECONNECTION_H 0007 0008 #include <QHostAddress> 0009 #include <QObject> 0010 0011 class QUdpSocket; 0012 class QTcpSocket; 0013 0014 namespace RemoteControl 0015 { 0016 class RemoteCommand; 0017 0018 class RemoteConnection : public QObject 0019 { 0020 Q_OBJECT 0021 public: 0022 const int UDPPORT = 23455; 0023 const int TCPPORT = 23456; 0024 explicit RemoteConnection(QObject *parent = 0); 0025 virtual bool isConnected() const = 0; 0026 void sendCommand(const RemoteCommand &); 0027 0028 Q_SIGNALS: 0029 void gotCommand(const RemoteCommand &); 0030 0031 protected Q_SLOTS: 0032 void dataReceived(); 0033 0034 protected: 0035 virtual QTcpSocket *socket() = 0; 0036 0037 private: 0038 enum ReadingState { WaitingForLength, 0039 WaitingForData }; 0040 ReadingState m_state = WaitingForLength; 0041 qint32 m_length; 0042 }; 0043 0044 } 0045 0046 #endif // REMOTECONNECTION_H