X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fnetworkconnection.h;h=959eb740e285708b917026976933a35fd0565903;hp=649171dbf048219ca134b91a0efaae3a2c1aa539;hb=600a5683c1a8e679b7b63a00d5b1211b5b9771c7;hpb=236e70030428e5b85309d6ddb97b772fa3efe61a diff --git a/src/core/networkconnection.h b/src/core/networkconnection.h index 649171db..959eb740 100644 --- a/src/core/networkconnection.h +++ b/src/core/networkconnection.h @@ -24,15 +24,21 @@ #include #include #include -#include #include +#ifndef QT_NO_OPENSSL +# include +# include +#else +# include +#endif + +#include "coresession.h" #include "identity.h" #include "message.h" #include "network.h" #include "signalproxy.h" -class CoreSession; class Network; class IrcServerHandler; @@ -46,18 +52,18 @@ public: NetworkConnection(Network *network, CoreSession *session); ~NetworkConnection(); - NetworkId networkId() const; - QString networkName() const; - Network *network() const; - Identity *identity() const; - CoreSession *coreSession() const; + inline NetworkId networkId() const { return network()->networkId(); } + inline QString networkName() const { return network()->networkName(); } + inline Network *network() const { return _network; } + inline Identity *identity() const { return coreSession()->identity(network()->identity()); } + inline CoreSession *coreSession() const { return _coreSession; } - bool isConnected() const; - Network::ConnectionState connectionState() const; + inline bool isConnected() const { return connectionState() == Network::Initialized; } + inline Network::ConnectionState connectionState() const { return _connectionState; } - IrcServerHandler *ircServerHandler() const; - UserInputHandler *userInputHandler() const; - CtcpHandler *ctcpHandler() const; + inline IrcServerHandler *ircServerHandler() const { return _ircServerHandler; } + inline UserInputHandler *userInputHandler() const { return _userInputHandler; } + inline CtcpHandler *ctcpHandler() const { return _ctcpHandler; } //! Decode a string using the server (network) decoding. QString serverDecode(const QByteArray &string) const; @@ -80,6 +86,8 @@ public: inline QString channelKey(const QString &channel) const { return _channelKeys.value(channel.toLower(), QString()); } inline QStringList persistentChannels() const { return _channelKeys.keys(); } + inline bool isAutoWhoInProgress(const QString &channel) const { return _autoWhoInProgress.contains(channel); } + public slots: // void setServerOptions(); void connectToIrc(bool reconnecting = false); @@ -94,12 +102,7 @@ public slots: void addChannelKey(const QString &channel, const QString &key); void removeChannelKey(const QString &channel); -private slots: - void sendPerform(); - void autoReconnectSettingsChanged(); - void doAutoReconnect(); - void sendWho(); - void nickChanged(const QString &newNick, const QString &oldNick); // this signal is inteded to rename query buffers in the storage backend + bool setAutoWhoDone(const QString &channel); signals: // #void networkState(QString net, QVariantMap data); @@ -120,17 +123,39 @@ signals: void channelJoined(NetworkId, const QString &channel, const QString &key = QString()); void channelParted(NetworkId, const QString &channel); + void sslErrors(const QVariant &errorData); + private slots: void socketHasData(); void socketError(QAbstractSocket::SocketError); void socketConnected(); + void socketInitialized(); void socketDisconnected(); void socketStateChanged(QAbstractSocket::SocketState); void setConnectionState(Network::ConnectionState); void networkInitialized(const QString ¤tServer); + void sendPerform(); + void autoReconnectSettingsChanged(); + void doAutoReconnect(); + void sendAutoWho(); + void startAutoWhoCycle(); + void nickChanged(const QString &newNick, const QString &oldNick); // this signal is inteded to rename query buffers in the storage backend + +#ifndef QT_NO_OPENSSL + void socketEncrypted(); + void sslErrors(const QList &errors); +#endif + + void fillBucketAndProcessQueue(); + private: +#ifndef QT_NO_OPENSSL + QSslSocket socket; +#else QTcpSocket socket; +#endif + Network::ConnectionState _connectionState; Network *_network; @@ -146,11 +171,27 @@ private: QTimer _autoReconnectTimer; int _autoReconnectCount; - QTimer _whoTimer; - bool _previousConnectionAttemptFailed; int _lastUsedServerlistIndex; - + + bool _autoWhoEnabled; + QStringList _autoWhoQueue; + QSet _autoWhoInProgress; + int _autoWhoInterval; + int _autoWhoNickLimit; + int _autoWhoDelay; + QTimer _autoWhoTimer, _autoWhoCycleTimer; + + QTimer _tokenBucketTimer; + int _messagesPerSecond; // token refill speed + int _burstSize; // size of the token bucket + int _tokenBucket; // the virtual bucket that holds the tokens + QList _msgQueue; + + void writeToSocket(QByteArray s); + + + class ParseError : public Exception { public: ParseError(QString cmd, QString prefix, QStringList params);