Remoto - VFS: VFS_tcp_client.h Source File
Remoto - VFS
VFS_tcp_client.h
Go to the documentation of this file.
1 #ifndef VFS_TCP_CLIENT_H
2 #define VFS_TCP_CLIENT_H
3 
4 #include <QTcpSocket>
5 #include <QHostAddress>
6 #include <QSslError>
7 #include <QSslSocket>
8 #include <QSslConfiguration>
9 
10 #include "VFS_base/VFS_node.h"
11 
12 class VFS_tcp_server;
13 
14 typedef quint32 MESSAGE_SIZE;
15 //#define MAX_MESSAGE_SIZE 65000
16 #define MAX_MESSAGE_SIZE 2147483648 //max = 2^31, which is like 2 gigabytes
17 
18 class VFS_tcp_client : public VFS_node
19 {
20  Q_OBJECT
21 
22  friend class VFS_tcp_server;
23 
24  public:
25  explicit VFS_tcp_client(QTcpSocket *socket, bool ssl=false, QSslConfiguration sslConfiguration=QSslConfiguration());
26  explicit VFS_tcp_client(QTcpSocket *socket, bool ssl=false, QString sslCertPath="");
27  explicit VFS_tcp_client(QString address, quint16 port, bool ssl=false, QString sslCertPath="");
28  virtual ~VFS_tcp_client();
29 
30  virtual void write(VFS_request *r);
31 
32  virtual bool isContainer();
33 
34  virtual QString reportDetails();
35 
36  virtual void writeMessage(QByteArray data);
37 
38  //FIXME: should be made protected with an access function
39  //QMap<VFS_node *, QString> _subscriptionPaths;
40  //QString _subscriptionPath; //the path leading to the other side of this endpoint
41 
42  protected:
43  QTcpSocket *_socket;
45 
46  bool _initialized;
47  QString _address;
48  quint16 _port;
49  bool _ssl;
50  QString _sslCertPath;
51 
52  signals:
53  void connected();
54  void disconnected();
55  void readyMessage(QByteArray message);
56  void moreToRead();
57  void error(QAbstractSocket::SocketError);
58 
59  public slots:
60  virtual void init();
61  virtual void close();
62  void readyRead();
63  void initSSL();
64 
65  protected slots:
66  void peerVerifyError(const QSslError &error);
67  void sslErrors(const QList<QSslError> &errors);
68  void modeChanged(QSslSocket::SslMode mode);
69  void sslReady();
70 };
71 
72 #endif // VFS_TCP_CONNECTION_H
73 
quint32 MESSAGE_SIZE
VFS_node is the base class from which all other VFS_node classes derive.
Definition: VFS_node.h:143
The base class for all requests between nodes.
Definition: VFS_node.h:54
void error(QAbstractSocket::SocketError)
Emitted when a socket error occurs.
void connected()
Emitted when a connection has been made.
QString _address
The address resolved by peerAddress(), or the address to connect to.
MESSAGE_SIZE _messageSize
The message size received. Will wait for this many bytes before emitting messageReady.
void readyRead()
DOCME.
void sslErrors(const QList< QSslError > &errors)
VFS_tcp_client::sslErrors.
void initSSL()
DOCME.
void sslReady()
Signal that an SSL connnection has been established.
QTcpSocket * _socket
The socket connection.
VFS_tcp_client(QTcpSocket *socket, bool ssl=false, QSslConfiguration sslConfiguration=QSslConfiguration())
VFS_tcp_client constructor for client mode.
virtual QString reportDetails()
Report data about this client.
void readyMessage(QByteArray message)
Emitted when a message is ready for processing.
virtual bool isContainer()
DOCME.
bool _initialized
Has this node been initialized?
void peerVerifyError(const QSslError &error)
VFS_tcp_client::peerVerifyError.
virtual void init()
DOCME.
virtual void close()
DOCME.
quint16 _port
The port to connect to.
QString _sslCertPath
ssl cert file path.
virtual void write(VFS_request *r)
DOCME.
bool _ssl
Use ssl?
virtual void writeMessage(QByteArray data)
DOCME.
void modeChanged(QSslSocket::SslMode mode)
A slot for when the SSL mode has changed.
void disconnected()
Emitted when a connection has been lost.
void moreToRead()
Emitted when an incoming message has additional data.
virtual ~VFS_tcp_client()
Open a listening TCP port for other clients to connect to.