#include "network.h"
#include "coreircchannel.h"
+#include "coreircuser.h"
#include <QTimer>
# include <QTcpSocket>
#endif
+#ifdef HAVE_QCA2
+# include "cipher.h"
+#endif
+
#include "coresession.h"
class CoreIdentity;
-class IrcServerHandler;
-class UserInputHandler;
-class CtcpHandler;
+class CoreUserInputHandler;
+class CoreIgnoreListManager;
+class Event;
class CoreNetwork : public Network {
+ SYNCABLE_OBJECT
Q_OBJECT
public:
inline CoreSession *coreSession() const { return _coreSession; }
inline CoreNetworkConfig *networkConfig() const { return coreSession()->networkConfig(); }
- inline IrcServerHandler *ircServerHandler() const { return _ircServerHandler; }
- inline UserInputHandler *userInputHandler() const { return _userInputHandler; }
- inline CtcpHandler *ctcpHandler() const { return _ctcpHandler; }
+ inline CoreUserInputHandler *userInputHandler() const { return _userInputHandler; }
+ inline CoreIgnoreListManager *ignoreListManager() { return coreSession()->ignoreListManager(); }
//! Decode a string using the server (network) decoding.
inline QString serverDecode(const QByteArray &string) const { return decodeServerString(string); }
inline UserId userId() const { return _coreSession->user(); }
+ inline QAbstractSocket::SocketState socketState() const { return socket.state(); }
+ inline bool socketConnected() const { return socket.state() == QAbstractSocket::ConnectedState; }
+ inline QHostAddress localAddress() const { return socket.localAddress(); }
+ inline QHostAddress peerAddress() const { return socket.peerAddress(); }
+ inline quint16 localPort() const { return socket.localPort(); }
+ inline quint16 peerPort() const { return socket.peerPort(); }
+
public slots:
virtual void setMyNick(const QString &mynick);
void addChannelKey(const QString &channel, const QString &key);
void removeChannelKey(const QString &channel);
+ // Blowfish stuff
+#ifdef HAVE_QCA2
+ Cipher *cipher(const QString &recipient) const;
+ QByteArray cipherKey(const QString &recipient) const;
+ void setCipherKey(const QString &recipient, const QByteArray &key);
+#endif
+
void setAutoWhoEnabled(bool enabled);
void setAutoWhoInterval(int interval);
void setAutoWhoDelay(int delay);
bool setAutoWhoDone(const QString &channel);
+ void updateIssuedModes(const QString &requestedModes);
+ void updatePersistentModes(QString addModes, QString removeModes);
+ void resetPersistentModes();
+
Server usedServer() const;
inline void resetPingTimeout() { _pingCount = 0; }
void quitRequested(NetworkId networkId);
void sslErrors(const QVariant &errorData);
+ void newEvent(Event *event);
+ void socketInitialized(const CoreIdentity *identity, const QHostAddress &localAddress, quint16 localPort, const QHostAddress &peerAddress, quint16 peerPort);
+ void socketDisconnected(const CoreIdentity *identity, const QHostAddress &localAddress, quint16 localPort, const QHostAddress &peerAddress, quint16 peerPort);
+
protected:
inline virtual IrcChannel *ircChannelFactory(const QString &channelname) { return new CoreIrcChannel(channelname, this); }
+ inline virtual IrcUser *ircUserFactory(const QString &hostmask) { return new CoreIrcUser(hostmask, this); }
+
+protected slots:
+ // TODO: remove cached cipher keys, when appropriate
+ //virtual void removeIrcUser(IrcUser *ircuser);
+ //virtual void removeIrcChannel(IrcChannel *ircChannel);
+ //virtual void removeChansAndUsers();
private slots:
void socketHasData();
QTcpSocket socket;
#endif
- IrcServerHandler *_ircServerHandler;
- UserInputHandler *_userInputHandler;
- CtcpHandler *_ctcpHandler;
+ CoreUserInputHandler *_userInputHandler;
QHash<QString, QString> _channelKeys; // stores persistent channels and their passwords, if any
int _burstSize; // size of the token bucket
int _tokenBucket; // the virtual bucket that holds the tokens
QList<QByteArray> _msgQueue;
+
+ QString _requestedUserModes; // 2 strings separated by a '-' character. first part are requested modes to add, the second to remove
+
+ // Blowfish key map
+ QHash<QString, QByteArray> _cipherKeys;
};
#endif //CORENETWORK_H