# HG changeset patch # User Jacob Dawid # Date 1313191600 -7200 # Node ID 73a9ac1cdbf18bfa5d1edaaf48a8cf5d7fd52491 # Parent f6bb482582000cab06157f28229b141e3bc57fef Further structured IRC interfaces. diff --git a/gui/src/qirc/IRCClientImpl.cpp b/gui/src/qirc/IRCClientImpl.cpp --- a/gui/src/qirc/IRCClientImpl.cpp +++ b/gui/src/qirc/IRCClientImpl.cpp @@ -144,10 +144,11 @@ return getStringToken (line.toStdString ().c_str (), index); } -IRCChannelProxy::IRCChannelProxy () - : IRCChannelProxyInterface () +IRCChannelProxy::IRCChannelProxy (IRCClientInterface *clientInterface, const QString& channelName) + : IRCChannelProxyInterface (clientInterface, channelName), + m_clientInterface (clientInterface) { - + m_channelName = channelName; } QTextDocument * @@ -162,6 +163,32 @@ return &m_userListModel; } +QString +IRCChannelProxy::channelName () +{ + return m_channelName; +} + +void +IRCChannelProxy::sendMessage (const QString& message) +{ + Q_UNUSED (message); + // TODO: implement. +} + +void +IRCChannelProxy::sendJoinRequest () +{ + //sendIRCCommand (IRCCommand::Join, QStringList (channel)); +} + + +void +IRCChannelProxy::leave (const QString& reason) +{ + Q_UNUSED (reason); +} + IRCClientImpl::IRCClientImpl () : IRCClientInterface () { @@ -212,22 +239,9 @@ IRCChannelProxyInterface * IRCClientImpl::ircChannelProxy (const QString &channel) { - if (m_channels.contains (channel)) - return m_channels[channel]; - return 0; -} - -void -IRCClientImpl::sendJoinRequest (const QString& channel) -{ - sendIRCCommand (IRCCommand::Join, QStringList (channel)); -} - -void -IRCClientImpl::leaveChannel (const QString& channel, const QString& reason) -{ - Q_UNUSED (channel); - Q_UNUSED (reason); + if (!m_channels.contains (channel)) + m_channels[channel] = new IRCChannelProxy(this, channel); + return m_channels[channel]; } void diff --git a/gui/src/qirc/IRCClientImpl.h b/gui/src/qirc/IRCClientImpl.h --- a/gui/src/qirc/IRCClientImpl.h +++ b/gui/src/qirc/IRCClientImpl.h @@ -274,13 +274,21 @@ class IRCChannelProxy : public IRCChannelProxyInterface { public: - IRCChannelProxy (); + IRCChannelProxy (IRCClientInterface *clientInterface, const QString& channelName); QTextDocument *conversationModel (); QStringListModel *userListModel (); + QString channelName (); + + void sendMessage (const QString& message); + void sendJoinRequest (); + void leave (const QString &reason); + private: + QString m_channelName; QStringList m_userList; QStringListModel m_userListModel; QTextDocument m_conversationModel; + IRCClientInterface *m_clientInterface; }; class IRCClientImpl : public IRCClientInterface @@ -300,9 +308,6 @@ void disconnect (); void reconnect (); - void sendJoinRequest (const QString& channel); - void leaveChannel (const QString& channel, const QString& reason); - void focusChannel (const QString& channel); void sendNicknameChangeRequest (const QString &nickname); void sendPublicMessage (const QString& message); diff --git a/gui/src/qirc/IRCClientInterface.h b/gui/src/qirc/IRCClientInterface.h --- a/gui/src/qirc/IRCClientInterface.h +++ b/gui/src/qirc/IRCClientInterface.h @@ -25,12 +25,17 @@ #include #include +class IRCClientInterface; class IRCChannelProxyInterface { public: - IRCChannelProxyInterface () { } + IRCChannelProxyInterface (IRCClientInterface *, const QString&) { } virtual QTextDocument *conversationModel () = 0; virtual QStringListModel *userListModel () = 0; + virtual QString channelName () = 0; + virtual void sendMessage (const QString& message) = 0; + virtual void sendJoinRequest () = 0; + virtual void leave (const QString& reason) = 0; }; /** @@ -56,9 +61,6 @@ virtual void disconnect () = 0; virtual void reconnect () = 0; - virtual void sendJoinRequest (const QString& channel) = 0; - virtual void leaveChannel (const QString& channel, const QString& reason) = 0; - // Messaging: virtual void focusChannel (const QString& channel) = 0; virtual void sendNicknameChangeRequest (const QString& nickname) = 0;