-rw-r--r-- | noncore/net/opieirc/config.in | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchannellist.cpp | 11 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchannellist.h | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 23 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 26 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 4 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsession.h | 1 |
8 files changed, 54 insertions, 15 deletions
diff --git a/noncore/net/opieirc/config.in b/noncore/net/opieirc/config.in index 30184a9..7c6949d 100644 --- a/noncore/net/opieirc/config.in +++ b/noncore/net/opieirc/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config OPIEIRC | 1 | config OPIEIRC |
2 | boolean "opieirc" | 2 | boolean "opie-irc (chat via your favorite IRC server)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE |
diff --git a/noncore/net/opieirc/ircchannellist.cpp b/noncore/net/opieirc/ircchannellist.cpp index e592d05..566b223 100644 --- a/noncore/net/opieirc/ircchannellist.cpp +++ b/noncore/net/opieirc/ircchannellist.cpp | |||
@@ -32,6 +32,17 @@ bool IRCChannelList::hasPerson(QString nick) { | |||
32 | for (unsigned int i=0; i<count(); i++) { | 32 | for (unsigned int i=0; i<count(); i++) { |
33 | if (text(i) == nick) | 33 | if (text(i) == nick) |
34 | return TRUE; | 34 | return TRUE; |
35 | } | 35 | } |
36 | return FALSE; | 36 | return FALSE; |
37 | } | 37 | } |
38 | |||
39 | bool IRCChannelList::removePerson(QString nick) { | ||
40 | for (unsigned int i=0; i<count(); i++) { | ||
41 | if (text(i) == nick){ | ||
42 | removeItem(i); | ||
43 | return TRUE; | ||
44 | } | ||
45 | } | ||
46 | return FALSE; | ||
47 | } | ||
48 | |||
diff --git a/noncore/net/opieirc/ircchannellist.h b/noncore/net/opieirc/ircchannellist.h index fa3c8cd..deab649 100644 --- a/noncore/net/opieirc/ircchannellist.h +++ b/noncore/net/opieirc/ircchannellist.h | |||
@@ -26,11 +26,12 @@ | |||
26 | 26 | ||
27 | class IRCChannelList : public QListBox { | 27 | class IRCChannelList : public QListBox { |
28 | public: | 28 | public: |
29 | IRCChannelList(IRCChannel *channel, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 29 | IRCChannelList(IRCChannel *channel, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
30 | void update(); | 30 | void update(); |
31 | bool hasPerson(QString nick); | 31 | bool hasPerson(QString nick); |
32 | bool removePerson(QString nick); | ||
32 | protected: | 33 | protected: |
33 | IRCChannel *m_channel; | 34 | IRCChannel *m_channel; |
34 | }; | 35 | }; |
35 | 36 | ||
36 | #endif /* __IRCCHANNELLIST_H */ | 37 | #endif /* __IRCCHANNELLIST_H */ |
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index beb8bce..2b8b65e 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -59,12 +59,13 @@ void IRCChannelTab::appendText(QString text) { | |||
59 | if (firstBreak != -1) { | 59 | if (firstBreak != -1) { |
60 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); | 60 | txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); |
61 | } | 61 | } |
62 | } else { | 62 | } else { |
63 | m_lines++; | 63 | m_lines++; |
64 | } | 64 | } |
65 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | ||
65 | m_textview->setText(txt); | 66 | m_textview->setText(txt); |
66 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 67 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
67 | emit changed(this); | 68 | emit changed(this); |
68 | } | 69 | } |
69 | 70 | ||
70 | IRCChannelTab::~IRCChannelTab() { | 71 | IRCChannelTab::~IRCChannelTab() { |
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 6b88f34..400ff41 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -203,27 +203,41 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | |||
203 | } else { | 203 | } else { |
204 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); | 204 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | 208 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { |
209 | |||
209 | IRCPerson mask(message->prefix()); | 210 | IRCPerson mask(message->prefix()); |
210 | 211 | /* this way of handling nick changes really sucks */ | |
211 | if (mask.nick() == m_session->m_server->nick()) { | 212 | if (mask.nick() == m_session->m_server->nick()) { |
212 | /* We are changing our nickname */ | 213 | /* We are changing our nickname */ |
213 | m_session->m_server->setNick(message->param(0)); | 214 | m_session->m_server->setNick(message->param(0)); |
214 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); | 215 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); |
215 | output.addParam(0); | 216 | output.addParam(0); |
216 | emit outputReady(output); | 217 | emit outputReady(output); |
217 | } else { | 218 | } else { |
218 | /* Someone else is */ | 219 | /* Someone else is */ |
219 | IRCPerson *person = m_session->getPerson(mask.nick()); | 220 | IRCPerson *person = m_session->getPerson(mask.nick()); |
220 | if (person) { | 221 | if (person) { |
221 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0 ))); | 222 | //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); |
222 | output.addParam(person); | 223 | |
223 | emit outputReady(output); | 224 | /* new code starts here -- this removes the person from all channels */ |
225 | QList<IRCChannel> channels; | ||
226 | m_session->getChannelsByPerson(person, channels); | ||
227 | QListIterator<IRCChannel> it(channels); | ||
228 | for (;it.current(); ++it) { | ||
229 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | ||
230 | it.current()->removePerson(chanperson); | ||
231 | chanperson->person->setNick(message->param(0)); | ||
232 | it.current()->addPerson(chanperson); | ||
233 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); | ||
234 | output.addParam(person); | ||
235 | emit outputReady(output); | ||
236 | } | ||
237 | /* new code ends here */ | ||
224 | } else { | 238 | } else { |
225 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 239 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
226 | } | 240 | } |
227 | } | 241 | } |
228 | } | 242 | } |
229 | 243 | ||
@@ -394,12 +408,13 @@ void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | |||
394 | if (person->person->nick() == m_session->m_server->nick()) { | 408 | if (person->person->nick() == m_session->m_server->nick()) { |
395 | m_session->removeChannel(channel); | 409 | m_session->removeChannel(channel); |
396 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); | 410 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); |
397 | output.addParam(channel); | 411 | output.addParam(channel); |
398 | emit outputReady(output); | 412 | emit outputReady(output); |
399 | } else { | 413 | } else { |
414 | /* someone else got kicked */ | ||
400 | channel->removePerson(person); | 415 | channel->removePerson(person); |
401 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); | 416 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); |
402 | output.addParam(channel); | 417 | output.addParam(channel); |
403 | output.addParam(person); | 418 | output.addParam(person); |
404 | emit outputReady(output); | 419 | emit outputReady(output); |
405 | } | 420 | } |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 1d9520a..2c28507 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -119,25 +119,19 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | |||
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | else if (command == "OP"){ | 122 | else if (command == "OP"){ |
123 | QString nickname; | 123 | QString nickname; |
124 | stream >> nickname; | 124 | stream >> nickname; |
125 | if (nickname.length() > 0) { | 125 | if (nickname.length() > 0) { |
126 | if (line.length() > 7 + nickname.length()) { | 126 | QString text = line.right(line.length()-nickname.length()-5); |
127 | QString text = line.right(line.length()-nickname.length()-7); | ||
128 | IRCPerson person; | ||
129 | person.setNick(nickname); | ||
130 | m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text); | ||
131 | } else { | ||
132 | IRCPerson person; | 127 | IRCPerson person; |
133 | person.setNick(nickname); | 128 | person.setNick(nickname); |
134 | m_session->kick(((IRCChannelTab *)tab)->channel(), &person); | 129 | m_session->op(((IRCChannelTab *)tab)->channel(), &person); |
135 | } | 130 | } |
136 | } | 131 | } |
137 | } | ||
138 | 132 | ||
139 | //SEND MODES | 133 | //SEND MODES |
140 | else if (command == "MODE"){ | 134 | else if (command == "MODE"){ |
141 | QString text = line.right(line.length()-6); | 135 | QString text = line.right(line.length()-6); |
142 | if (text.length() > 0) { | 136 | if (text.length() > 0) { |
143 | m_session->mode(text); | 137 | m_session->mode(text); |
@@ -343,13 +337,25 @@ void IRCServerTab::display(IRCOutput output) { | |||
343 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 337 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
344 | it.current()->list()->update(); | 338 | it.current()->list()->update(); |
345 | } | 339 | } |
346 | } | 340 | } |
347 | } | 341 | } |
348 | break; | 342 | break; |
349 | case OUTPUT_OTHERJOIN: | 343 | /* case OUTPUT_NICKCHANGE: { |
344 | //WAS HERE | ||
345 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | ||
346 | QListIterator<IRCChannelTab> it(m_channelTabs); | ||
347 | for (; it.current(); ++it) { | ||
348 | if (it.current()->list()->hasPerson(nick)) { | ||
349 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | ||
350 | it.current()->list()->update(); | ||
351 | } | ||
352 | } | ||
353 | } | ||
354 | break; | ||
355 | */ case OUTPUT_OTHERJOIN: | ||
350 | case OUTPUT_OTHERKICK: | 356 | case OUTPUT_OTHERKICK: |
351 | case OUTPUT_CHANPERSONMODE: | 357 | case OUTPUT_CHANPERSONMODE: |
352 | case OUTPUT_OTHERPART: { | 358 | case OUTPUT_OTHERPART: { |
353 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 359 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
354 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 360 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
355 | channelTab->list()->update(); | 361 | channelTab->list()->update(); |
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp index 1cc1ee2..6404d71 100644 --- a/noncore/net/opieirc/ircsession.cpp +++ b/noncore/net/opieirc/ircsession.cpp | |||
@@ -57,12 +57,16 @@ void IRCSession::raw(QString message){ | |||
57 | } | 57 | } |
58 | 58 | ||
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 | } |
62 | 62 | ||
63 | void IRCSession::op(IRCChannel *channel, IRCPerson *person) { | ||
64 | m_connection->sendLine("MODE "+ channel->channelname() + " +ooo " + person->nick()); | ||
65 | } | ||
66 | |||
63 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { | 67 | void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { |
64 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); | 68 | m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); |
65 | } | 69 | } |
66 | 70 | ||
67 | void IRCSession::sendMessage(IRCPerson *person, QString message) { | 71 | void IRCSession::sendMessage(IRCPerson *person, QString message) { |
68 | m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); | 72 | m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); |
diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h index a6a3e50..f6330d8 100644 --- a/noncore/net/opieirc/ircsession.h +++ b/noncore/net/opieirc/ircsession.h | |||
@@ -48,12 +48,13 @@ public: | |||
48 | void raw(QString message); | 48 | void raw(QString message); |
49 | void topic(IRCChannel *channel, QString message); | 49 | void topic(IRCChannel *channel, QString message); |
50 | void mode(IRCChannel *channel, QString message); | 50 | void mode(IRCChannel *channel, QString message); |
51 | void mode(IRCPerson *person, QString message); | 51 | void mode(IRCPerson *person, QString message); |
52 | void mode(QString message); | 52 | void mode(QString message); |
53 | void part(IRCChannel *channel); | 53 | void part(IRCChannel *channel); |
54 | void op(IRCChannel *channel, IRCPerson *person); | ||
54 | void kick(IRCChannel *channel, IRCPerson *person); | 55 | void kick(IRCChannel *channel, IRCPerson *person); |
55 | void kick(IRCChannel *channel, IRCPerson *person, QString message); | 56 | void kick(IRCChannel *channel, IRCPerson *person, QString message); |
56 | void beginSession(); | 57 | void beginSession(); |
57 | bool isSessionActive(); | 58 | bool isSessionActive(); |
58 | void endSession(); | 59 | void endSession(); |
59 | void sendMessage(IRCPerson *person, QString message); | 60 | void sendMessage(IRCPerson *person, QString message); |