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 | |||
@@ -27,3 +27,3 @@ void IRCSession::beginSession() { | |||
27 | void IRCSession::join(QString channelname) { | 27 | void IRCSession::join(QString channelname) { |
28 | m_connection->sendLine("JOIN "+channelname); | 28 | m_connection->sendLine("JOIN " + channelname); |
29 | } | 29 | } |
@@ -59,3 +59,3 @@ void IRCSession::raw(QString message){ | |||
59 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { | 59 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { |
60 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); | 60 | m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); |
61 | } | 61 | } |
@@ -63,3 +63,3 @@ void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { | |||
63 | void IRCSession::op(IRCChannel *channel, IRCPerson *person) { | 63 | void IRCSession::op(IRCChannel *channel, IRCPerson *person) { |
64 | m_connection->sendLine("MODE "+ channel->channelname() + " +ooo " + person->nick()); | 64 | m_connection->sendLine("MODE " + channel->channelname() + " +ooo " + person->nick()); |
65 | } | 65 | } |
@@ -67,3 +67,3 @@ void IRCSession::op(IRCChannel *channel, IRCPerson *person) { | |||
67 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { | 67 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { |
68 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); | 68 | m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :" + message); |
69 | } | 69 | } |
@@ -90,5 +90,9 @@ bool IRCSession::isSessionActive() { | |||
90 | 90 | ||
91 | bool IRCSession::isLoggedIn() { | ||
92 | return m_connection->isLoggedIn(); | ||
93 | } | ||
94 | |||
91 | void IRCSession::endSession() { | 95 | void IRCSession::endSession() { |
92 | if (m_connection->isLoggedIn()) | 96 | if (m_connection->isLoggedIn()) |
93 | m_connection->sendLine("QUIT :" APP_VERSION); | 97 | quit(APP_VERSION); |
94 | else | 98 | else |
@@ -101,2 +105,44 @@ void IRCSession::part(IRCChannel *channel) { | |||
101 | 105 | ||
106 | void IRCSession::setValidUsermodes(const QString &modes) { | ||
107 | m_validUsermodes = modes; | ||
108 | } | ||
109 | |||
110 | void IRCSession::setValidChannelmodes(const QString &modes) { | ||
111 | m_validChannelmodes = modes; | ||
112 | } | ||
113 | |||
114 | void IRCSession::updateNickname(const QString &oldNickname, const QString &newNickname) { | ||
115 | QList<IRCChannel> channels; | ||
116 | IRCOutput output; | ||
117 | |||
118 | if (oldNickname == m_server->nick()) { | ||
119 | m_server->setNick(newNickname); | ||
120 | output = IRCOutput(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg(newNickname)); | ||
121 | channels = m_channels; | ||
122 | } | ||
123 | |||
124 | else { | ||
125 | IRCPerson *person = getPerson(oldNickname); | ||
126 | |||
127 | if(!person) { | ||
128 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | getChannelsByPerson(person, channels); | ||
133 | output = IRCOutput(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg(oldNickname).arg(newNickname)); | ||
134 | } | ||
135 | |||
136 | QListIterator<IRCChannel> it(channels); | ||
137 | for (;it.current(); ++it) { | ||
138 | IRCChannelPerson *chanperson = it.current()->getPerson(oldNickname); | ||
139 | it.current()->removePerson(chanperson); | ||
140 | chanperson->person->setNick(newNickname); | ||
141 | it.current()->addPerson(chanperson); | ||
142 | } | ||
143 | |||
144 | emit updateChannels(); | ||
145 | output.addParam(new QString(newNickname)); | ||
146 | emit outputReady(output); | ||
147 | } | ||
102 | 148 | ||