Mercurial > hg > octave-lyh
changeset 13580:64a3a1f23718
Further developed new IRC class.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 01 Aug 2011 23:20:25 +0200 |
parents | 6568fccb8940 |
children | 3e5a8ef9c76d |
files | gui/src/qirc/IRCClientImpl.cpp gui/src/qirc/IRCClientImpl.h |
diffstat | 2 files changed, 58 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/qirc/IRCClientImpl.cpp +++ b/gui/src/qirc/IRCClientImpl.cpp @@ -3,6 +3,9 @@ IRCClientImpl::IRCClientImpl () : IRCClientInterface () { + connect (&m_tcpSocket, SIGNAL (connected ()), this, SLOT (handleConnected ())); + connect (&m_tcpSocket, SIGNAL (disconnected ()), this, SLOT (handleDisconnected ())); + connect (&m_tcpSocket, SIGNAL (readyRead ()), this, SLOT (handleReadyRead ())); } void @@ -26,52 +29,88 @@ bool IRCClientImpl::isConnected () { - + return m_connected; } const QHostAddress& IRCClientImpl::host() { - + return m_host; } int IRCClientImpl::port() { - + return m_port; } void IRCClientImpl::enterChannel (const QString& channel) { - + Q_UNUSED (channel); } void IRCClientImpl::leaveChannel (const QString& channel, const QString& reason) { + Q_UNUSED (channel); + Q_UNUSED (reason); } void IRCClientImpl::focusChannel (const QString& channel) { - + Q_UNUSED (channel); } void IRCClientImpl::sendNicknameChangeRequest (const QString &nickname) { - + Q_UNUSED (nickname); } void IRCClientImpl::sendMessage (const QString& message) { - + Q_UNUSED (message); } const QString& IRCClientImpl::nickname () { + return m_nickname; +} +void +IRCClientImpl::handleConnected () +{ + m_connected = true; } + +void +IRCClientImpl::handleDisconnected () +{ + m_connected = false; +} + +void +IRCClientImpl::handleReadyRead () +{ + QByteArray line; + do + { + line = m_tcpSocket.readLine(); + if (line.size ()) + handleIncomingLine(QString(line)); + else + break; + } + while (true); +} + +void +IRCClientImpl::handleIncomingLine (const QString &line) +{ + if (line.isEmpty()) + return; +}
--- a/gui/src/qirc/IRCClientImpl.h +++ b/gui/src/qirc/IRCClientImpl.h @@ -28,12 +28,20 @@ const QString& nickname (); +private slots: + void handleConnected (); + void handleDisconnected (); + void handleReadyRead (); + private: - QString m_server; - int m_port; - QString m_nickname; + void handleIncomingLine (const QString& line); - QTcpSocket m_tcpSocket; + QHostAddress m_host; + int m_port; + QString m_nickname; + bool m_connected; + + QTcpSocket m_tcpSocket; }; #endif // IRCCLIENTIMPL_H