Diffstat (limited to 'noncore/net/opieirc/ircservertab.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index e031d4d..90353f2 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -8,42 +8,43 @@ | |||
8 | bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) { | 8 | bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) { |
9 | return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) || | 9 | return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) || |
10 | (text.find("ping") != -1 && text.find( tab->server()->nick() != -1)); | 10 | (text.find("ping") != -1 && text.find( tab->server()->nick() != -1)); |
11 | } | 11 | } |
12 | 12 | ||
13 | 13 | ||
14 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 14 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
15 | m_server = server; | 15 | m_server = server; |
16 | m_session = new IRCSession(&m_server); | 16 | m_session = new IRCSession(&m_server); |
17 | m_mainWindow = mainWindow; | 17 | m_mainWindow = mainWindow; |
18 | m_close = FALSE; | 18 | m_close = FALSE; |
19 | m_lines = 0; | 19 | m_lines = 0; |
20 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); | 20 | m_description->setText(tr("Connecting to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); |
21 | m_textview = new QTextView(this); | 21 | m_textview = new QTextView(this); |
22 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 22 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
23 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 23 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
24 | m_textview->setTextFormat(RichText); | 24 | m_textview->setTextFormat(RichText); |
25 | QWhatsThis::add(m_textview, tr("Server messages")); | 25 | QWhatsThis::add(m_textview, tr("Server messages")); |
26 | m_layout->add(m_textview); | 26 | m_layout->add(m_textview); |
27 | m_field = new IRCHistoryLineEdit(this); | 27 | m_field = new IRCHistoryLineEdit(this); |
28 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); | 28 | connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); |
29 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); | 29 | connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); |
30 | connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); | 30 | connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); |
31 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); | 31 | connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); |
32 | 32 | ||
33 | QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); | 33 | QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); |
34 | m_layout->add(m_field); | 34 | m_layout->add(m_field); |
35 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 35 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
36 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 36 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
37 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); | 37 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); |
38 | connect(m_session, SIGNAL(updateChannels()), this, SLOT(slotUpdateChannels())); | ||
38 | settingsChanged(); | 39 | settingsChanged(); |
39 | 40 | ||
40 | m_field->setFocus(); | 41 | m_field->setFocus(); |
41 | m_field->setActiveWindow(); | 42 | m_field->setActiveWindow(); |
42 | 43 | ||
43 | } | 44 | } |
44 | 45 | ||
45 | void IRCServerTab::scrolling(){ | 46 | void IRCServerTab::scrolling(){ |
46 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 47 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
47 | } | 48 | } |
48 | 49 | ||
49 | 50 | ||
@@ -104,25 +105,31 @@ void IRCServerTab::settingsChanged() { | |||
104 | } | 105 | } |
105 | 106 | ||
106 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | 107 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { |
107 | QTextIStream stream(&line); | 108 | QTextIStream stream(&line); |
108 | QString command; | 109 | QString command; |
109 | stream >> command; | 110 | stream >> command; |
110 | command = command.upper().right(command.length()-1); | 111 | command = command.upper().right(command.length()-1); |
111 | 112 | ||
112 | //JOIN | 113 | //JOIN |
113 | if (command == "JOIN" || command == "J") { | 114 | if (command == "JOIN" || command == "J") { |
114 | QString channel; | 115 | QString channel; |
115 | stream >> channel; | 116 | stream >> channel; |
116 | if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { | 117 | /* According to RFC 1459 */ |
118 | if (channel.length() > 0 && channel.length() < 200 && | ||
119 | channel.find(",") == -1 && channel.find("") == -1) { | ||
120 | |||
121 | if (!channel.startsWith("#") && !channel.startsWith("&")) { | ||
122 | channel = channel.prepend("#"); | ||
123 | } | ||
117 | m_session->join(channel); | 124 | m_session->join(channel); |
118 | } else { | 125 | } else { |
119 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); | 126 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); |
120 | } | 127 | } |
121 | } | 128 | } |
122 | 129 | ||
123 | //KICK | 130 | //KICK |
124 | else if (command == "KICK"){ | 131 | else if (command == "KICK"){ |
125 | QString nickname; | 132 | QString nickname; |
126 | stream >> nickname; | 133 | stream >> nickname; |
127 | if (nickname.length() > 0) { | 134 | if (nickname.length() > 0) { |
128 | if (line.length() > 7 + nickname.length()) { | 135 | if (line.length() > 7 + nickname.length()) { |
@@ -336,58 +343,72 @@ void IRCServerTab::display(IRCOutput output) { | |||
336 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); | 343 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); |
337 | } | 344 | } |
338 | break; | 345 | break; |
339 | case OUTPUT_TOPIC: { | 346 | case OUTPUT_TOPIC: { |
340 | IRCChannel *channel = (IRCChannel *) output.getParam(0); | 347 | IRCChannel *channel = (IRCChannel *) output.getParam(0); |
341 | if (channel) { | 348 | if (channel) { |
342 | IRCChannelTab *channelTab = getTabForChannel(channel); | 349 | IRCChannelTab *channelTab = getTabForChannel(channel); |
343 | if (channelTab) { | 350 | if (channelTab) { |
344 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 351 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
345 | return; | 352 | return; |
346 | } | 353 | } |
347 | } | 354 | } |
348 | appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 355 | IRCChannelTab::enqueue(channel->channelname(), "<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
349 | } | 356 | } |
350 | break; | 357 | break; |
351 | case OUTPUT_QUIT: { | 358 | case OUTPUT_QUIT: { |
352 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | 359 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); |
353 | QListIterator<IRCChannelTab> it(m_channelTabs); | 360 | QListIterator<IRCChannelTab> it(m_channelTabs); |
354 | for (; it.current(); ++it) { | 361 | for (; it.current(); ++it) { |
355 | if (it.current()->list()->hasPerson(nick)) { | 362 | if (it.current()->list()->hasPerson(nick)) { |
356 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 363 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
357 | it.current()->list()->update(); | 364 | it.current()->list()->update(); |
358 | } | 365 | } |
359 | } | 366 | } |
360 | } | 367 | } |
361 | break; | 368 | break; |
362 | /* case OUTPUT_NICKCHANGE: { | 369 | case OUTPUT_NICKCHANGE: { |
363 | //WAS HERE | 370 | QString *nick = static_cast<QString*>(output.getParam(0)); |
364 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | 371 | if(!nick) { |
372 | appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | ||
373 | break; | ||
374 | } | ||
365 | QListIterator<IRCChannelTab> it(m_channelTabs); | 375 | QListIterator<IRCChannelTab> it(m_channelTabs); |
366 | for (; it.current(); ++it) { | 376 | for (; it.current(); ++it) { |
367 | if (it.current()->list()->hasPerson(nick)) { | 377 | if (it.current()->list()->hasPerson(*nick)) { |
368 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 378 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
369 | it.current()->list()->update(); | ||
370 | } | 379 | } |
371 | } | 380 | } |
381 | delete nick; | ||
372 | } | 382 | } |
373 | break; | 383 | break; |
374 | */ case OUTPUT_OTHERJOIN: | 384 | case OUTPUT_OTHERJOIN: |
375 | case OUTPUT_OTHERKICK: | 385 | case OUTPUT_OTHERKICK: |
376 | case OUTPUT_CHANPERSONMODE: | 386 | case OUTPUT_CHANPERSONMODE: |
377 | case OUTPUT_OTHERPART: { | 387 | case OUTPUT_OTHERPART: { |
378 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 388 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
379 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 389 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
380 | channelTab->list()->update(); | 390 | channelTab->list()->update(); |
381 | } | 391 | } |
382 | break; | 392 | break; |
383 | case OUTPUT_CTCP: | 393 | case OUTPUT_CTCP: |
384 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); | 394 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); |
385 | break; | 395 | break; |
386 | case OUTPUT_ERROR: | 396 | case OUTPUT_ERROR: |
387 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); | 397 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
388 | break; | 398 | break; |
399 | case OUTPUT_TITLE: | ||
400 | m_description->setText(output.message()); | ||
401 | break; | ||
389 | default: | 402 | default: |
390 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); | 403 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); |
391 | break; | 404 | break; |
392 | } | 405 | } |
393 | } | 406 | } |
407 | |||
408 | void IRCServerTab::slotUpdateChannels() { | ||
409 | QListIterator<IRCChannelTab> it(m_channelTabs); | ||
410 | for (; it.current(); ++it) { | ||
411 | it.current()->list()->update(); | ||
412 | } | ||
413 | } | ||
414 | |||