comparison gui/src/qirc/IRCClientImpl.cpp @ 13598:a9b96f66202a

Further reworked on IRC backend.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Sun, 14 Aug 2011 23:36:38 +0200
parents 73a9ac1cdbf1
children e67616aca5a6
comparison
equal deleted inserted replaced
13597:73a9ac1cdbf1 13598:a9b96f66202a
142 IRCServerMessage::getStringToken (QString line, int &index) 142 IRCServerMessage::getStringToken (QString line, int &index)
143 { 143 {
144 return getStringToken (line.toStdString ().c_str (), index); 144 return getStringToken (line.toStdString ().c_str (), index);
145 } 145 }
146 146
147 IRCChannelProxy::IRCChannelProxy (IRCClientInterface *clientInterface, const QString& channelName) 147 IRCChannelProxy::IRCChannelProxy (IRCClientInterface *clientInterface, const QString& channelName, QObject *parent)
148 : IRCChannelProxyInterface (clientInterface, channelName), 148 : IRCChannelProxyInterface (clientInterface, channelName, parent),
149 m_clientInterface (clientInterface) 149 m_clientInterface (clientInterface)
150 { 150 {
151 m_channelName = channelName; 151 m_channelName = channelName;
152 } 152 }
153 153
170 } 170 }
171 171
172 void 172 void
173 IRCChannelProxy::sendMessage (const QString& message) 173 IRCChannelProxy::sendMessage (const QString& message)
174 { 174 {
175 Q_UNUSED (message); 175 QStringList arguments;
176 // TODO: implement. 176 arguments << m_channelName;
177 arguments << message;
178 m_clientInterface->sendIRCCommand (IRCCommand::PrivateMessage, arguments);
177 } 179 }
178 180
179 void 181 void
180 IRCChannelProxy::sendJoinRequest () 182 IRCChannelProxy::sendJoinRequest ()
181 { 183 {
182 //sendIRCCommand (IRCCommand::Join, QStringList (channel)); 184 m_clientInterface->sendIRCCommand (IRCCommand::Join, QStringList (m_channelName));
183 } 185 }
184 186
185 187
186 void 188 void
187 IRCChannelProxy::leave (const QString& reason) 189 IRCChannelProxy::leave (const QString& reason)
188 { 190 {
189 Q_UNUSED (reason); 191 Q_UNUSED (reason);
190 } 192 }
191 193
192 IRCClientImpl::IRCClientImpl () 194 IRCClientImpl::IRCClientImpl (QObject *parent)
193 : IRCClientInterface () 195 : IRCClientInterface (parent)
194 { 196 {
195 connect (&m_tcpSocket, SIGNAL (connected ()), this, SLOT (handleConnected ())); 197 connect (&m_tcpSocket, SIGNAL (connected ()), this, SLOT (handleConnected ()));
196 connect (&m_tcpSocket, SIGNAL (disconnected ()), this, SLOT (handleDisconnected ())); 198 connect (&m_tcpSocket, SIGNAL (disconnected ()), this, SLOT (handleDisconnected ()));
197 connect (&m_tcpSocket, SIGNAL (readyRead ()), this, SLOT (handleReadyRead ())); 199 connect (&m_tcpSocket, SIGNAL (readyRead ()), this, SLOT (handleReadyRead ()));
198 } 200 }
199 201
202 IRCClientImpl::~IRCClientImpl ()
203 {
204 foreach (IRCChannelProxyInterface *ircChannelProxy, m_channels)
205 {
206 delete ircChannelProxy;
207 }
208 }
209
200 void 210 void
201 IRCClientImpl::connectToHost (const QHostAddress& host, int port, const QString& initialNick) 211 IRCClientImpl::connectToHost (const QHostAddress& host, int port, const QString& initialNick)
202 { 212 {
203 m_host = host; 213 m_host = host;
204 m_nickname = initialNick; 214 m_nickname = initialNick;
243 m_channels[channel] = new IRCChannelProxy(this, channel); 253 m_channels[channel] = new IRCChannelProxy(this, channel);
244 return m_channels[channel]; 254 return m_channels[channel];
245 } 255 }
246 256
247 void 257 void
248 IRCClientImpl::focusChannel (const QString& channel)
249 {
250 m_focussedChannel = channel;
251 }
252
253 void
254 IRCClientImpl::sendNicknameChangeRequest (const QString &nickname) 258 IRCClientImpl::sendNicknameChangeRequest (const QString &nickname)
255 { 259 {
256 sendIRCCommand (IRCCommand::Nick, QStringList (nickname)); 260 sendIRCCommand (IRCCommand::Nick, QStringList (nickname));
257 }
258
259 void
260 IRCClientImpl::sendPublicMessage (const QString& message)
261 {
262 QStringList arguments;
263 arguments << m_focussedChannel;
264 arguments << message;
265 sendIRCCommand (IRCCommand::PrivateMessage, arguments);
266 } 261 }
267 262
268 void 263 void
269 IRCClientImpl::sendPrivateMessage (const QString &recipient, const QString &message) 264 IRCClientImpl::sendPrivateMessage (const QString &recipient, const QString &message)
270 { 265 {