X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fnetworkconnection.h;h=959eb740e285708b917026976933a35fd0565903;hp=1a7aafaa14667edca95a275dee3c05ec9b6ccc0b;hb=c6b3980fe063e5022882a31a132dec6952f8c6a7;hpb=6ac855b96988ebc999f7017765ae3dbda527301a diff --git a/src/core/networkconnection.h b/src/core/networkconnection.h index 1a7aafaa..959eb740 100644 --- a/src/core/networkconnection.h +++ b/src/core/networkconnection.h @@ -33,12 +33,12 @@ # include #endif +#include "coresession.h" #include "identity.h" #include "message.h" #include "network.h" #include "signalproxy.h" -class CoreSession; class Network; class IrcServerHandler; @@ -52,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; @@ -86,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); @@ -100,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); @@ -138,11 +135,20 @@ private slots: 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; @@ -165,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);