1 /***************************************************************************
2 * Copyright (C) 2005-2012 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #ifndef REMOTECONNECTION_H
22 #define REMOTECONNECTION_H
28 #include "signalproxy.h"
32 class RemoteConnection : public SignalProxy::AbstractPeer
37 RemoteConnection(QTcpSocket *socket, QObject *parent = 0);
38 virtual ~RemoteConnection() {};
40 void setSignalProxy(SignalProxy *proxy);
42 QString description() const;
45 bool isSecure() const;
50 bool compressionEnabled() const;
51 void setCompressionEnabled(bool enabled);
53 QTcpSocket *socket() const;
55 // this is only used for the auth phase and should be replaced by something more generic
56 virtual void writeSocketData(const QVariant &item) = 0;
59 void close(const QString &reason = QString());
62 // this is only used for the auth phase and should be replaced by something more generic
63 void dataReceived(const QVariant &item);
66 void error(QAbstractSocket::SocketError);
68 void transferProgress(int current, int max);
71 SignalProxy *signalProxy() const;
74 void handle(const T &protoMessage);
76 // These protocol messages get handled internally and won't reach SignalProxy
77 void handle(const Protocol::HeartBeat &heartBeat);
78 void handle(const Protocol::HeartBeatReply &heartBeatReply);
79 virtual void dispatch(const Protocol::HeartBeat &msg) = 0;
80 virtual void dispatch(const Protocol::HeartBeatReply &msg) = 0;
84 void changeHeartBeatInterval(int secs);
88 SignalProxy *_signalProxy;
89 QTimer *_heartBeatTimer;
95 // Template methods we need in the header
96 template<class T> inline
97 void RemoteConnection::handle(const T &protoMessage)
100 qWarning() << Q_FUNC_INFO << "Cannot handle messages without a SignalProxy!";
104 // _heartBeatCount = 0;
106 signalProxy()->handle(this, protoMessage);