2012-12-31 23:37:39 +01:00
|
|
|
#ifndef NETWORKREMOTE_H
|
|
|
|
#define NETWORKREMOTE_H
|
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
#include <memory>
|
2013-01-14 17:18:24 +01:00
|
|
|
|
2012-12-31 23:37:39 +01:00
|
|
|
#include <QTcpServer>
|
|
|
|
#include <QTcpSocket>
|
|
|
|
|
|
|
|
#include "core/player.h"
|
|
|
|
#include "core/application.h"
|
2013-01-03 21:40:47 +01:00
|
|
|
#include "incomingdataparser.h"
|
|
|
|
#include "outgoingdatacreator.h"
|
2013-01-10 21:21:55 +01:00
|
|
|
#include "remoteclient.h"
|
2013-01-09 20:07:28 +01:00
|
|
|
|
2013-01-14 17:23:06 +01:00
|
|
|
class NetworkRemote : public QObject {
|
2014-02-07 16:34:20 +01:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-12-31 23:37:39 +01:00
|
|
|
static const char* kSettingsGroup;
|
2013-01-14 17:18:24 +01:00
|
|
|
static const quint16 kDefaultServerPort;
|
2014-11-13 22:31:49 +01:00
|
|
|
static const char* kTranscoderSettingPostfix;
|
2012-12-31 23:37:39 +01:00
|
|
|
|
2014-02-10 16:03:54 +01:00
|
|
|
explicit NetworkRemote(Application* app, QObject* parent = nullptr);
|
2012-12-31 23:37:39 +01:00
|
|
|
~NetworkRemote();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public slots:
|
2012-12-31 23:37:39 +01:00
|
|
|
void SetupServer();
|
|
|
|
void StartServer();
|
|
|
|
void ReloadSettings();
|
|
|
|
void AcceptConnection();
|
2013-12-22 15:16:42 +01:00
|
|
|
void EnableKittens(bool aww);
|
|
|
|
void SendKitten(quint64 id, const QImage& kitten);
|
2012-12-31 23:37:39 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2014-02-06 14:48:00 +01:00
|
|
|
std::unique_ptr<QTcpServer> server_;
|
|
|
|
std::unique_ptr<QTcpServer> server_ipv6_;
|
|
|
|
std::unique_ptr<IncomingDataParser> incoming_data_parser_;
|
|
|
|
std::unique_ptr<OutgoingDataCreator> outgoing_data_creator_;
|
2013-01-14 17:18:24 +01:00
|
|
|
|
|
|
|
quint16 port_;
|
2012-12-31 23:37:39 +01:00
|
|
|
bool use_remote_;
|
2013-01-10 21:21:55 +01:00
|
|
|
bool only_non_public_ip_;
|
2013-01-09 20:07:28 +01:00
|
|
|
bool signals_connected_;
|
2012-12-31 23:37:39 +01:00
|
|
|
Application* app_;
|
2013-01-09 20:07:28 +01:00
|
|
|
|
2013-01-10 21:21:55 +01:00
|
|
|
QList<RemoteClient*> clients_;
|
2012-12-31 23:37:39 +01:00
|
|
|
|
|
|
|
void StopServer();
|
|
|
|
void ReadSettings();
|
2013-01-10 21:21:55 +01:00
|
|
|
void CreateRemoteClient(QTcpSocket* client_socket);
|
2013-01-11 13:55:09 +01:00
|
|
|
bool IpIsPrivate(const QHostAddress& address);
|
2012-12-31 23:37:39 +01:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // NETWORKREMOTE_H
|