Diffstat (limited to 'noncore/net/opieirc/ircsession.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp index c8d7869..d87ff80 100644 --- a/noncore/net/opieirc/ircsession.cpp +++ b/noncore/net/opieirc/ircsession.cpp | |||
@@ -95,99 +95,101 @@ bool IRCSession::isSessionActive() { | |||
95 | bool IRCSession::isLoggedIn() { | 95 | bool IRCSession::isLoggedIn() { |
96 | return m_connection->isLoggedIn(); | 96 | return m_connection->isLoggedIn(); |
97 | } | 97 | } |
98 | 98 | ||
99 | void IRCSession::endSession() { | 99 | void IRCSession::endSession() { |
100 | if (m_connection->isLoggedIn()) | 100 | if (m_connection->isLoggedIn()) |
101 | quit(APP_VERSION); | 101 | quit(APP_VERSION); |
102 | else | 102 | else |
103 | m_connection->close(); | 103 | m_connection->close(); |
104 | } | 104 | } |
105 | 105 | ||
106 | void IRCSession::part(IRCChannel *channel) { | 106 | void IRCSession::part(IRCChannel *channel) { |
107 | m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); | 107 | m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); |
108 | } | 108 | } |
109 | 109 | ||
110 | void IRCSession::setValidUsermodes(const QString &modes) { | 110 | void IRCSession::setValidUsermodes(const QString &modes) { |
111 | m_validUsermodes = modes; | 111 | m_validUsermodes = modes; |
112 | } | 112 | } |
113 | 113 | ||
114 | void IRCSession::setValidChannelmodes(const QString &modes) { | 114 | void IRCSession::setValidChannelmodes(const QString &modes) { |
115 | m_validChannelmodes = modes; | 115 | m_validChannelmodes = modes; |
116 | } | 116 | } |
117 | 117 | ||
118 | void IRCSession::updateNickname(const QString &oldNickname, const QString &newNickname) { | 118 | void IRCSession::updateNickname(const QString &oldNickname, const QString &newNickname) { |
119 | QList<IRCChannel> channels; | 119 | QList<IRCChannel> channels; |
120 | IRCOutput output; | 120 | IRCOutput output; |
121 | 121 | ||
122 | if (oldNickname == m_server->nick()) { | 122 | if (oldNickname == m_server->nick()) { |
123 | m_server->setNick(newNickname); | 123 | m_server->setNick(newNickname); |
124 | output = IRCOutput(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg(newNickname)); | 124 | output = IRCOutput(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg(newNickname)); |
125 | channels = m_channels; | 125 | channels = m_channels; |
126 | } | 126 | } |
127 | 127 | ||
128 | else { | 128 | else { |
129 | IRCPerson *person = getPerson(oldNickname); | 129 | IRCPerson *person = getPerson(oldNickname); |
130 | 130 | ||
131 | if(!person) { | 131 | if(!person) { |
132 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 132 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
133 | return; | 133 | return; |
134 | } | 134 | } |
135 | 135 | ||
136 | getChannelsByPerson(person, channels); | 136 | getChannelsByPerson(person, channels); |
137 | output = IRCOutput(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg(oldNickname).arg(newNickname)); | 137 | output = IRCOutput(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg(oldNickname).arg(newNickname)); |
138 | } | 138 | } |
139 | 139 | ||
140 | QListIterator<IRCChannel> it(channels); | 140 | QListIterator<IRCChannel> it(channels); |
141 | for (;it.current(); ++it) { | 141 | for (;it.current(); ++it) { |
142 | IRCChannelPerson *chanperson = it.current()->getPerson(oldNickname); | 142 | IRCChannelPerson *chanperson = it.current()->getPerson(oldNickname); |
143 | it.current()->removePerson(chanperson); | 143 | if (chanperson) { |
144 | chanperson->setNick(newNickname); | 144 | it.current()->removePerson(chanperson); |
145 | it.current()->addPerson(chanperson); | 145 | chanperson->setNick(newNickname); |
146 | it.current()->addPerson(chanperson); | ||
147 | } | ||
146 | } | 148 | } |
147 | 149 | ||
148 | emit updateChannels(); | 150 | emit updateChannels(); |
149 | output.addParam(new QString(newNickname)); | 151 | output.addParam(new QString(newNickname)); |
150 | emit outputReady(output); | 152 | emit outputReady(output); |
151 | } | 153 | } |
152 | 154 | ||
153 | IRCChannel *IRCSession::getChannel(QString channelname) { | 155 | IRCChannel *IRCSession::getChannel(QString channelname) { |
154 | QListIterator<IRCChannel> it(m_channels); | 156 | QListIterator<IRCChannel> it(m_channels); |
155 | for (; it.current(); ++it) { | 157 | for (; it.current(); ++it) { |
156 | if (it.current()->channelname() == channelname) { | 158 | if (it.current()->channelname() == channelname) { |
157 | return it.current(); | 159 | return it.current(); |
158 | } | 160 | } |
159 | } | 161 | } |
160 | return 0; | 162 | return 0; |
161 | } | 163 | } |
162 | 164 | ||
163 | IRCPerson *IRCSession::getPerson(QString nickname) { | 165 | IRCPerson *IRCSession::getPerson(QString nickname) { |
164 | QListIterator<IRCPerson> it(m_people); | 166 | QListIterator<IRCPerson> it(m_people); |
165 | for (; it.current(); ++it) { | 167 | for (; it.current(); ++it) { |
166 | if (it.current()->nick() == nickname) { | 168 | if (it.current()->nick() == nickname) { |
167 | return it.current(); | 169 | return it.current(); |
168 | } | 170 | } |
169 | } | 171 | } |
170 | return 0; | 172 | return 0; |
171 | } | 173 | } |
172 | 174 | ||
173 | void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) { | 175 | void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) { |
174 | QListIterator<IRCChannel> it(m_channels); | 176 | QListIterator<IRCChannel> it(m_channels); |
175 | for (; it.current(); ++it) { | 177 | for (; it.current(); ++it) { |
176 | if (it.current()->getPerson(person->nick()) != 0) { | 178 | if (it.current()->getPerson(person->nick()) != 0) { |
177 | channels.append(it.current()); | 179 | channels.append(it.current()); |
178 | } | 180 | } |
179 | } | 181 | } |
180 | } | 182 | } |
181 | 183 | ||
182 | void IRCSession::addPerson(IRCPerson *person) { | 184 | void IRCSession::addPerson(IRCPerson *person) { |
183 | m_people.append(person); | 185 | m_people.append(person); |
184 | } | 186 | } |
185 | 187 | ||
186 | void IRCSession::addChannel(IRCChannel *channel) { | 188 | void IRCSession::addChannel(IRCChannel *channel) { |
187 | m_channels.append(channel); | 189 | m_channels.append(channel); |
188 | } | 190 | } |
189 | 191 | ||
190 | void IRCSession::removeChannel(IRCChannel *channel) { | 192 | void IRCSession::removeChannel(IRCChannel *channel) { |
191 | m_channels.remove(channel); | 193 | m_channels.remove(channel); |
192 | } | 194 | } |
193 | 195 | ||