Diffstat (limited to 'noncore/net/opieirc/ircsession.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 56 |
1 files changed, 51 insertions, 5 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 @@ -26,5 +26,5 @@ void IRCSession::beginSession() { void IRCSession::join(QString channelname) { - m_connection->sendLine("JOIN "+channelname); + m_connection->sendLine("JOIN " + channelname); } @@ -58,13 +58,13 @@ void IRCSession::raw(QString message){ void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { - m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); + m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); } void IRCSession::op(IRCChannel *channel, IRCPerson *person) { - m_connection->sendLine("MODE "+ channel->channelname() + " +ooo " + person->nick()); + m_connection->sendLine("MODE " + channel->channelname() + " +ooo " + person->nick()); } void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { - m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); + m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :" + message); } @@ -89,7 +89,11 @@ bool IRCSession::isSessionActive() { } +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(); @@ -100,4 +104,46 @@ void IRCSession::part(IRCChannel *channel) { } +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) { |