Diffstat (limited to 'noncore/net/opieirc/ircservertab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 724f4bd..2ad56a8 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -1,2 +1,3 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <qtextstream.h> | ||
2 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
@@ -27,6 +28,2 @@ void IRCServerTab::appendText(QString text) { | |||
27 | IRCServerTab::~IRCServerTab() { | 28 | IRCServerTab::~IRCServerTab() { |
28 | QListIterator<IRCChannelTab> it(m_channelTabs); | ||
29 | for (; it.current(); ++it) { | ||
30 | m_mainWindow->killTab(it.current()); | ||
31 | } | ||
32 | delete m_session; | 29 | delete m_session; |
@@ -50,5 +47,28 @@ IRCServer *IRCServerTab::server() { | |||
50 | 47 | ||
48 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | ||
49 | QTextIStream stream(&line); | ||
50 | QString command; | ||
51 | stream >> command; | ||
52 | command = command.upper().right(command.length()-1); | ||
53 | |||
54 | if (command == "JOIN") { | ||
55 | QString channel; | ||
56 | stream >> channel; | ||
57 | if (channel.length() > 0 && channel.startsWith("#")) { | ||
58 | m_session->join(channel); | ||
59 | } else { | ||
60 | tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); | ||
61 | } | ||
62 | } else { | ||
63 | tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); | ||
64 | } | ||
65 | } | ||
66 | |||
51 | void IRCServerTab::processCommand() { | 67 | void IRCServerTab::processCommand() { |
68 | QString text = m_field->text(); | ||
69 | if (text.startsWith("/") && !text.startsWith("//")) { | ||
70 | /* Command mode */ | ||
71 | executeCommand(this, text); | ||
72 | } | ||
52 | m_field->clear(); | 73 | m_field->clear(); |
53 | appendText("<font color=\"#ff0000\">Not supported yet</font><br>"); | ||
54 | } | 74 | } |
@@ -60,3 +80,5 @@ void IRCServerTab::doConnect() { | |||
60 | void IRCServerTab::remove() { | 80 | void IRCServerTab::remove() { |
81 | /* Close requested */ | ||
61 | if (m_session->isSessionActive()) { | 82 | if (m_session->isSessionActive()) { |
83 | /* While there is a running session */ | ||
62 | m_close = TRUE; | 84 | m_close = TRUE; |
@@ -64,2 +86,7 @@ void IRCServerTab::remove() { | |||
64 | } else { | 86 | } else { |
87 | /* Session has previously been closed */ | ||
88 | m_channelTabs.first(); | ||
89 | while (m_channelTabs.current() != 0) { | ||
90 | m_mainWindow->killTab(m_channelTabs.current()); | ||
91 | } | ||
65 | m_mainWindow->killTab(this); | 92 | m_mainWindow->killTab(this); |
@@ -79,8 +106,19 @@ IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { | |||
79 | void IRCServerTab::display(IRCOutput output) { | 106 | void IRCServerTab::display(IRCOutput output) { |
107 | |||
108 | /* All messages to be displayed inside the GUI get here */ | ||
80 | switch (output.type()) { | 109 | switch (output.type()) { |
81 | case OUTPUT_CONNCLOSE: | 110 | case OUTPUT_CONNCLOSE: |
82 | if (m_close) | 111 | if (m_close) { |
112 | m_channelTabs.first(); | ||
113 | while (m_channelTabs.current() != 0) { | ||
114 | m_mainWindow->killTab(m_channelTabs.current()); | ||
115 | } | ||
83 | m_mainWindow->killTab(this); | 116 | m_mainWindow->killTab(this); |
84 | else | 117 | } else { |
85 | appendText("<font color=\"#0000dd\">" + output.message() +"</font><br>"); | 118 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); |
119 | QListIterator<IRCChannelTab> it(m_channelTabs); | ||
120 | for (; it.current(); ++it) { | ||
121 | it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); | ||
122 | } | ||
123 | } | ||
86 | break; | 124 | break; |
@@ -94,3 +132,3 @@ void IRCServerTab::display(IRCOutput output) { | |||
94 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 132 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
95 | channelTab->appendText("<<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>> "+output.message()+"<br>"); | 133 | channelTab->appendText("<<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>> "+output.htmlMessage()+"<br>"); |
96 | } | 134 | } |
@@ -104,3 +142,3 @@ void IRCServerTab::display(IRCOutput output) { | |||
104 | case OUTPUT_SELFKICK: { | 142 | case OUTPUT_SELFKICK: { |
105 | appendText("<font color=\"#ff0000\">" + output.message() + "</font><br>"); | 143 | appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>"); |
106 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 144 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
@@ -112,3 +150,3 @@ void IRCServerTab::display(IRCOutput output) { | |||
112 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 150 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
113 | channelTab->appendText("<font color=\"#cc0000\">"+output.message()+"</font><br>"); | 151 | channelTab->appendText("<font color=\"#cc0000\">"+output.htmlMessage()+"</font><br>"); |
114 | } | 152 | } |
@@ -120,3 +158,3 @@ void IRCServerTab::display(IRCOutput output) { | |||
120 | if (it.current()->list()->hasPerson(nick)) { | 158 | if (it.current()->list()->hasPerson(nick)) { |
121 | it.current()->appendText("<font color=\"#aa3e00\">"+output.message()+"</font><br>"); | 159 | it.current()->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>"); |
122 | it.current()->list()->update(); | 160 | it.current()->list()->update(); |
@@ -131,3 +169,3 @@ void IRCServerTab::display(IRCOutput output) { | |||
131 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 169 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
132 | channelTab->appendText("<font color=\"#aa3e00\">"+output.message()+"</font><br>"); | 170 | channelTab->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>"); |
133 | channelTab->list()->update(); | 171 | channelTab->list()->update(); |
@@ -136,9 +174,9 @@ void IRCServerTab::display(IRCOutput output) { | |||
136 | case OUTPUT_CTCP: | 174 | case OUTPUT_CTCP: |
137 | appendText("<font color=\"#00bb00\">" + output.message() + "</font><br>"); | 175 | appendText("<font color=\"#00bb00\">" + output.htmlMessage() + "</font><br>"); |
138 | break; | 176 | break; |
139 | case OUTPUT_ERROR: | 177 | case OUTPUT_ERROR: |
140 | appendText("<font color=\"#ff0000\">" + output.message() + "</font><br>"); | 178 | appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>"); |
141 | break; | 179 | break; |
142 | default: | 180 | default: |
143 | appendText("<font color=\"#0000dd\">" + output.message() + "</font><br>"); | 181 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "</font><br>"); |
144 | break; | 182 | break; |