Diffstat (limited to 'noncore/net/opieirc/ircsession.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp index 3b176d0..ca0df50 100644 --- a/noncore/net/opieirc/ircsession.cpp +++ b/noncore/net/opieirc/ircsession.cpp @@ -67,59 +67,105 @@ void IRCSession::op(IRCChannel *channel, IRCPerson *person) { void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); } void IRCSession::sendMessage(IRCPerson *person, QString message) { m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); } void IRCSession::sendMessage(IRCChannel *channel, QString message) { m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); } void IRCSession::sendAction(IRCChannel *channel, QString message) { m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001"); } void IRCSession::sendAction(IRCPerson *person, QString message) { m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001"); } bool IRCSession::isSessionActive() { return m_connection->isConnected(); } +bool IRCSession::isLoggedIn() { + return m_connection->isLoggedIn(); +} + void IRCSession::endSession() { if (m_connection->isLoggedIn()) - m_connection->sendLine("QUIT :" APP_VERSION); + quit(APP_VERSION); else m_connection->close(); } void IRCSession::part(IRCChannel *channel) { m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); } +void IRCSession::setValidUsermodes(const QString &modes) { + m_validUsermodes = modes; +} + +void IRCSession::setValidChannelmodes(const QString &modes) { + m_validChannelmodes = modes; +} + +void IRCSession::updateNickname(const QString &oldNickname, const QString &newNickname) { + QList<IRCChannel> channels; + IRCOutput output; + + if (oldNickname == m_server->nick()) { + m_server->setNick(newNickname); + output = IRCOutput(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg(newNickname)); + channels = m_channels; + } + + else { + IRCPerson *person = getPerson(oldNickname); + + if(!person) { + emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); + return; + } + + getChannelsByPerson(person, channels); + output = IRCOutput(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg(oldNickname).arg(newNickname)); + } + + QListIterator<IRCChannel> it(channels); + for (;it.current(); ++it) { + IRCChannelPerson *chanperson = it.current()->getPerson(oldNickname); + it.current()->removePerson(chanperson); + chanperson->person->setNick(newNickname); + it.current()->addPerson(chanperson); + } + + emit updateChannels(); + output.addParam(new QString(newNickname)); + emit outputReady(output); +} IRCChannel *IRCSession::getChannel(QString channelname) { QListIterator<IRCChannel> it(m_channels); for (; it.current(); ++it) { if (it.current()->channelname() == channelname) { return it.current(); } } return 0; } IRCPerson *IRCSession::getPerson(QString nickname) { QListIterator<IRCPerson> it(m_people); for (; it.current(); ++it) { if (it.current()->nick() == nickname) { return it.current(); } } return 0; } void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) { QListIterator<IRCChannel> it(m_channels); for (; it.current(); ++it) { |