2013-01-10 21:21:55 +01:00
|
|
|
#ifndef REMOTECLIENT_H
|
|
|
|
#define REMOTECLIENT_H
|
|
|
|
|
|
|
|
#include <QAbstractSocket>
|
|
|
|
#include <QTcpSocket>
|
|
|
|
#include <QBuffer>
|
|
|
|
|
|
|
|
#include "core/application.h"
|
2013-07-12 12:31:27 +02:00
|
|
|
#include "remotecontrolmessages.pb.h"
|
2013-01-10 21:21:55 +01:00
|
|
|
|
|
|
|
class RemoteClient : public QObject {
|
2014-02-07 16:34:20 +01:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-01-10 21:21:55 +01:00
|
|
|
RemoteClient(Application* app, QTcpSocket* client);
|
|
|
|
~RemoteClient();
|
|
|
|
|
2013-03-30 19:09:58 +01:00
|
|
|
// This method checks if client is authenticated before sending the data
|
2013-01-10 21:21:55 +01:00
|
|
|
void SendData(pb::remote::Message* msg);
|
|
|
|
QAbstractSocket::SocketState State();
|
2013-07-12 12:31:27 +02:00
|
|
|
void setDownloader(bool downloader);
|
|
|
|
bool isDownloader() { return downloader_; }
|
|
|
|
void DisconnectClient(pb::remote::ReasonDisconnect reason);
|
2013-01-10 21:21:55 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2013-01-10 21:21:55 +01:00
|
|
|
void IncomingData();
|
|
|
|
|
|
|
|
signals:
|
2013-01-23 20:02:12 +01:00
|
|
|
void Parse(const pb::remote::Message& msg);
|
2013-01-10 21:21:55 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2013-01-23 20:02:12 +01:00
|
|
|
void ParseMessage(const QByteArray& data);
|
|
|
|
|
2013-03-30 19:09:58 +01:00
|
|
|
// Sends data to client without check if authenticated
|
|
|
|
void SendDataToClient(pb::remote::Message* msg);
|
|
|
|
|
2013-01-10 21:21:55 +01:00
|
|
|
Application* app_;
|
|
|
|
|
2013-01-23 20:02:12 +01:00
|
|
|
bool use_auth_code_;
|
|
|
|
int auth_code_;
|
2013-03-21 10:57:52 +01:00
|
|
|
bool authenticated_;
|
2013-07-12 12:31:27 +02:00
|
|
|
bool allow_downloads_;
|
|
|
|
bool downloader_;
|
2013-01-23 20:02:12 +01:00
|
|
|
|
2013-01-10 21:21:55 +01:00
|
|
|
QTcpSocket* client_;
|
|
|
|
bool reading_protobuf_;
|
|
|
|
quint32 expected_length_;
|
|
|
|
QBuffer buffer_;
|
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // REMOTECLIENT_H
|