-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 7 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessage.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.h | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircperson.cpp | 6 | ||||
-rw-r--r-- | noncore/net/opieirc/ircperson.h | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 76 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.h | 27 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 54 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.h | 7 |
10 files changed, 182 insertions, 10 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index 3267525..4675265 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -9,16 +9,17 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW | |||
9 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); | 9 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); |
10 | QHBox *hbox = new QHBox(this); | 10 | QHBox *hbox = new QHBox(this); |
11 | m_textview = new QTextView(hbox); | 11 | m_textview = new QTextView(hbox); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_listVisible = TRUE; | 14 | m_listVisible = TRUE; |
15 | m_listButton = new QPushButton(">", m_textview); | 15 | m_listButton = new QPushButton(">", m_textview); |
16 | m_textview->setCornerWidget(m_listButton); | 16 | m_textview->setCornerWidget(m_listButton); |
17 | m_textview->setTextFormat(RichText); | ||
17 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); | 18 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); |
18 | m_list = new IRCChannelList(m_channel, hbox); | 19 | m_list = new IRCChannelList(m_channel, hbox); |
19 | m_list->update(); | 20 | m_list->update(); |
20 | m_list->setMaximumWidth(LISTWIDTH); | 21 | m_list->setMaximumWidth(LISTWIDTH); |
21 | m_field = new QLineEdit(this); | 22 | m_field = new QLineEdit(this); |
22 | m_layout->add(hbox); | 23 | m_layout->add(hbox); |
23 | hbox->show(); | 24 | hbox->show(); |
24 | m_layout->add(m_field); | 25 | m_layout->add(m_field); |
@@ -42,20 +43,18 @@ void IRCChannelTab::processCommand() { | |||
42 | if (text.length()>0) { | 43 | if (text.length()>0) { |
43 | if (session()->isSessionActive()) { | 44 | if (session()->isSessionActive()) { |
44 | if (text.startsWith("/") && !text.startsWith("//")) { | 45 | if (text.startsWith("/") && !text.startsWith("//")) { |
45 | /* Command mode */ | 46 | /* Command mode */ |
46 | m_parentTab->executeCommand(this, text);; | 47 | m_parentTab->executeCommand(this, text);; |
47 | } else { | 48 | } else { |
48 | if (text.startsWith("//")) | 49 | if (text.startsWith("//")) |
49 | text = text.right(text.length()-1); | 50 | text = text.right(text.length()-1); |
50 | if (session()->isSessionActive()) { | 51 | session()->sendMessage(m_channel, m_field->text()); |
51 | session()->sendMessage(m_channel, m_field->text()); | 52 | appendText("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); |
52 | appendText("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); | ||
53 | } | ||
54 | } | 53 | } |
55 | } else { | 54 | } else { |
56 | appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); | 55 | appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); |
57 | } | 56 | } |
58 | } | 57 | } |
59 | m_field->clear(); | 58 | m_field->clear(); |
60 | } | 59 | } |
61 | 60 | ||
diff --git a/noncore/net/opieirc/ircmessage.cpp b/noncore/net/opieirc/ircmessage.cpp index 9c2869c..d823ad1 100644 --- a/noncore/net/opieirc/ircmessage.cpp +++ b/noncore/net/opieirc/ircmessage.cpp | |||
@@ -72,17 +72,16 @@ IRCMessage::IRCMessage(QString line) { | |||
72 | printf("Command : '%s'\n", m_command.ascii()); | 72 | printf("Command : '%s'\n", m_command.ascii()); |
73 | printf("Allparameters : '%s'\n", m_allParameters.ascii()); | 73 | printf("Allparameters : '%s'\n", m_allParameters.ascii()); |
74 | for (unsigned int i=0; i<m_parameters.count(); i++) { | 74 | for (unsigned int i=0; i<m_parameters.count(); i++) { |
75 | printf("Parameter %i : '%s'\n", i, m_parameters[i].ascii()); | 75 | printf("Parameter %i : '%s'\n", i, m_parameters[i].ascii()); |
76 | } | 76 | } |
77 | printf("CTCP Command : '%s'\n", m_ctcpCommand.latin1()); | 77 | printf("CTCP Command : '%s'\n", m_ctcpCommand.latin1()); |
78 | printf("CTCP Destination : '%s'\n", m_ctcpDestination.latin1()); | 78 | printf("CTCP Destination : '%s'\n", m_ctcpDestination.latin1()); |
79 | printf("CTCP param count is : '%i'\n", m_parameters.count()); | 79 | printf("CTCP param count is : '%i'\n", m_parameters.count()); |
80 | |||
81 | */ | 80 | */ |
82 | } | 81 | } |
83 | 82 | ||
84 | QString IRCMessage::param(int param) { | 83 | QString IRCMessage::param(int param) { |
85 | return m_parameters[param]; | 84 | return m_parameters[param]; |
86 | } | 85 | } |
87 | 86 | ||
88 | QString IRCMessage::prefix() { | 87 | QString IRCMessage::prefix() { |
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 4038673..3063741 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -39,17 +39,19 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { | |||
39 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME | 39 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME |
40 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY | 40 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY |
41 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES | 41 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES |
42 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART | 42 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART |
43 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD | 43 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD |
44 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD | 44 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD |
45 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 | 45 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 |
46 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 | 46 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 |
47 | { 412, FUNC(parseNumericalStats) }, // ERNOTEXTTOSEND | 47 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK |
48 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK | ||
49 | { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND | ||
48 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE | 50 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE |
49 | { 0, 0 } | 51 | { 0, 0 } |
50 | }; | 52 | }; |
51 | 53 | ||
52 | IRCMessageParser::IRCMessageParser(IRCSession *session) { | 54 | IRCMessageParser::IRCMessageParser(IRCSession *session) { |
53 | m_session = session; | 55 | m_session = session; |
54 | } | 56 | } |
55 | 57 | ||
@@ -167,17 +169,17 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | |||
167 | /* IRC Query message detected, verify sender and display it */ | 169 | /* IRC Query message detected, verify sender and display it */ |
168 | IRCPerson mask(message->prefix()); | 170 | IRCPerson mask(message->prefix()); |
169 | IRCPerson *person = m_session->getPerson(mask.nick()); | 171 | IRCPerson *person = m_session->getPerson(mask.nick()); |
170 | if (!person) { | 172 | if (!person) { |
171 | /* Person not yet known, create and add to the current session */ | 173 | /* Person not yet known, create and add to the current session */ |
172 | person = new IRCPerson(message->prefix()); | 174 | person = new IRCPerson(message->prefix()); |
173 | m_session->addPerson(person); | 175 | m_session->addPerson(person); |
174 | } | 176 | } |
175 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); | 177 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); |
176 | output.addParam(person); | 178 | output.addParam(person); |
177 | emit outputReady(output); | 179 | emit outputReady(output); |
178 | } else if (message->param(0).at(0) == '#') { | 180 | } else if (message->param(0).at(0) == '#') { |
179 | /* IRC Channel message detected, verify sender, channel and display it */ | 181 | /* IRC Channel message detected, verify sender, channel and display it */ |
180 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 182 | IRCChannel *channel = m_session->getChannel(message->param(0)); |
181 | if (channel) { | 183 | if (channel) { |
182 | IRCPerson mask(message->prefix()); | 184 | IRCPerson mask(message->prefix()); |
183 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 185 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
@@ -474,8 +476,12 @@ void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { | |||
474 | } | 476 | } |
475 | } | 477 | } |
476 | 478 | ||
477 | 479 | ||
478 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { | 480 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { |
479 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); | 481 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); |
480 | m_session->endSession(); | 482 | m_session->endSession(); |
481 | } | 483 | } |
484 | |||
485 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { | ||
486 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); | ||
487 | } | ||
diff --git a/noncore/net/opieirc/ircmessageparser.h b/noncore/net/opieirc/ircmessageparser.h index b45b8f0..f774047 100644 --- a/noncore/net/opieirc/ircmessageparser.h +++ b/noncore/net/opieirc/ircmessageparser.h | |||
@@ -76,16 +76,17 @@ private: | |||
76 | void parseNumerical002(IRCMessage *message); | 76 | void parseNumerical002(IRCMessage *message); |
77 | void parseNumerical003(IRCMessage *message); | 77 | void parseNumerical003(IRCMessage *message); |
78 | void parseNumerical004(IRCMessage *message); | 78 | void parseNumerical004(IRCMessage *message); |
79 | void parseNumerical005(IRCMessage *message); | 79 | void parseNumerical005(IRCMessage *message); |
80 | void parseNumericalStats(IRCMessage *message); | 80 | void parseNumericalStats(IRCMessage *message); |
81 | void parseNumericalNames(IRCMessage *message); | 81 | void parseNumericalNames(IRCMessage *message); |
82 | void parseNumericalEndOfNames(IRCMessage *message); | 82 | void parseNumericalEndOfNames(IRCMessage *message); |
83 | void parseNumericalNicknameInUse(IRCMessage *message); | 83 | void parseNumericalNicknameInUse(IRCMessage *message); |
84 | void parseNumericalNoSuchNick(IRCMessage *message); | ||
84 | void parseCTCPPing(IRCMessage *message); | 85 | void parseCTCPPing(IRCMessage *message); |
85 | void parseCTCPVersion(IRCMessage *message); | 86 | void parseCTCPVersion(IRCMessage *message); |
86 | void parseCTCPAction(IRCMessage *message); | 87 | void parseCTCPAction(IRCMessage *message); |
87 | protected: | 88 | protected: |
88 | IRCSession *m_session; | 89 | IRCSession *m_session; |
89 | /* Parser tables */ | 90 | /* Parser tables */ |
90 | static IRCLiteralMessageParserStruct literalParserProcTable[]; | 91 | static IRCLiteralMessageParserStruct literalParserProcTable[]; |
91 | static IRCNumericalMessageParserStruct numericalParserProcTable[]; | 92 | static IRCNumericalMessageParserStruct numericalParserProcTable[]; |
diff --git a/noncore/net/opieirc/ircperson.cpp b/noncore/net/opieirc/ircperson.cpp index bd6b8d6..bd341f1 100644 --- a/noncore/net/opieirc/ircperson.cpp +++ b/noncore/net/opieirc/ircperson.cpp | |||
@@ -2,16 +2,22 @@ | |||
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | 3 | ||
4 | IRCPerson::IRCPerson() { | 4 | IRCPerson::IRCPerson() { |
5 | m_nick = ""; | 5 | m_nick = ""; |
6 | m_user = ""; | 6 | m_user = ""; |
7 | m_host = ""; | 7 | m_host = ""; |
8 | } | 8 | } |
9 | 9 | ||
10 | IRCPerson::IRCPerson(const IRCPerson &person) { | ||
11 | m_nick = person.m_nick; | ||
12 | m_user = person.m_user; | ||
13 | m_host = person.m_host; | ||
14 | } | ||
15 | |||
10 | IRCPerson::IRCPerson(QString mask) { | 16 | IRCPerson::IRCPerson(QString mask) { |
11 | IRCPerson(); | 17 | IRCPerson(); |
12 | fromMask(mask); | 18 | fromMask(mask); |
13 | } | 19 | } |
14 | 20 | ||
15 | void IRCPerson::fromMask(QString mask) { | 21 | void IRCPerson::fromMask(QString mask) { |
16 | int sep1 = mask.find("!"); | 22 | int sep1 = mask.find("!"); |
17 | int sep2 = mask.find("@"); | 23 | int sep2 = mask.find("@"); |
diff --git a/noncore/net/opieirc/ircperson.h b/noncore/net/opieirc/ircperson.h index 850f91b..38732c4 100644 --- a/noncore/net/opieirc/ircperson.h +++ b/noncore/net/opieirc/ircperson.h | |||
@@ -26,17 +26,20 @@ | |||
26 | /* This class requires all required information relating to a person | 26 | /* This class requires all required information relating to a person |
27 | on the IRC network. This class can be used as an input mask for | 27 | on the IRC network. This class can be used as an input mask for |
28 | IRCMessage-prefixes too | 28 | IRCMessage-prefixes too |
29 | */ | 29 | */ |
30 | 30 | ||
31 | class IRCPerson { | 31 | class IRCPerson { |
32 | public: | 32 | public: |
33 | IRCPerson(); | 33 | IRCPerson(); |
34 | /* Create an IRCPerson from an IRC style description (nick!user@host) */ | ||
34 | IRCPerson(QString mask); | 35 | IRCPerson(QString mask); |
36 | /* Copy constructor */ | ||
37 | IRCPerson(const IRCPerson &person); | ||
35 | 38 | ||
36 | void fromMask(QString mask); | 39 | void fromMask(QString mask); |
37 | void setNick(QString name); | 40 | void setNick(QString name); |
38 | void setUser(QString user); | 41 | void setUser(QString user); |
39 | void setHost(QString host); | 42 | void setHost(QString host); |
40 | QString toMask(); | 43 | QString toMask(); |
41 | QString nick(); | 44 | QString nick(); |
42 | QString user(); | 45 | QString user(); |
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp index 6d24845..642cc5b 100644 --- a/noncore/net/opieirc/ircquerytab.cpp +++ b/noncore/net/opieirc/ircquerytab.cpp | |||
@@ -1,2 +1,78 @@ | |||
1 | #include <qhbox.h> | ||
1 | #include "ircquerytab.h" | 2 | #include "ircquerytab.h" |
3 | #include "ircservertab.h" | ||
4 | |||
5 | IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | ||
6 | m_mainWindow = mainWindow; | ||
7 | m_parentTab = parentTab; | ||
8 | m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ | ||
9 | m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); | ||
10 | QHBox *hbox = new QHBox(this); | ||
11 | m_textview = new QTextView(hbox); | ||
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | ||
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | ||
14 | m_textview->setTextFormat(RichText); | ||
15 | m_field = new QLineEdit(this); | ||
16 | m_layout->add(hbox); | ||
17 | hbox->show(); | ||
18 | m_layout->add(m_field); | ||
19 | m_field->setFocus(); | ||
20 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | ||
21 | |||
22 | } | ||
23 | |||
24 | void IRCQueryTab::appendText(QString text) { | ||
25 | /* not using append because it creates layout problems */ | ||
26 | m_textview->setText(m_textview->text() + text); | ||
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | ||
28 | } | ||
29 | |||
30 | IRCQueryTab::~IRCQueryTab() { | ||
31 | m_parentTab->removeQueryTab(this); | ||
32 | delete m_person; | ||
33 | } | ||
34 | |||
35 | void IRCQueryTab::processCommand() { | ||
36 | QString text = m_field->text(); | ||
37 | if (text.length()>0) { | ||
38 | if (session()->isSessionActive()) { | ||
39 | if (text.startsWith("/") && !text.startsWith("//")) { | ||
40 | /* Command mode */ | ||
41 | m_parentTab->executeCommand(this, text);; | ||
42 | } else { | ||
43 | if (text.startsWith("//")) | ||
44 | text = text.right(text.length()-1); | ||
45 | session()->sendMessage(m_person, m_field->text()); | ||
46 | appendText("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); | ||
47 | } | ||
48 | } else { | ||
49 | appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); | ||
50 | } | ||
51 | } | ||
52 | m_field->clear(); | ||
53 | } | ||
54 | |||
55 | void IRCQueryTab::display(IRCOutput output) { | ||
56 | if (output.type() == OUTPUT_QUERYPRIVMSG) { | ||
57 | appendText("<<font color=\"#0000dd\">"+m_person->nick()+"</font>> " + output.htmlMessage() + "<br>"); | ||
58 | } else if (output.type() == OUTPUT_QUERYACTION) { | ||
59 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "<br>"); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | QString IRCQueryTab::title() { | ||
64 | return m_person->nick(); | ||
65 | } | ||
66 | |||
67 | IRCSession *IRCQueryTab::session() { | ||
68 | return m_parentTab->session(); | ||
69 | } | ||
70 | |||
71 | void IRCQueryTab::remove() { | ||
72 | m_mainWindow->killTab(this); | ||
73 | } | ||
74 | |||
75 | IRCPerson *IRCQueryTab::person() { | ||
76 | return m_person; | ||
77 | } | ||
2 | 78 | ||
diff --git a/noncore/net/opieirc/ircquerytab.h b/noncore/net/opieirc/ircquerytab.h index fac976d..ea777f4 100644 --- a/noncore/net/opieirc/ircquerytab.h +++ b/noncore/net/opieirc/ircquerytab.h | |||
@@ -16,9 +16,36 @@ | |||
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCQUERYTAB_H | 21 | #ifndef __IRCQUERYTAB_H |
22 | #define __IRCQUERYTAB_H | 22 | #define __IRCQUERYTAB_H |
23 | 23 | ||
24 | #include "ircsession.h" | ||
25 | #include "mainwindow.h" | ||
26 | |||
27 | class IRCServerTab; | ||
28 | class IRCQueryTab : public IRCTab { | ||
29 | Q_OBJECT | ||
30 | public: | ||
31 | /* IRCTab implementation */ | ||
32 | IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | ||
33 | ~IRCQueryTab(); | ||
34 | QString title(); | ||
35 | IRCSession *session(); | ||
36 | IRCPerson *person(); | ||
37 | void appendText(QString text); | ||
38 | public slots: | ||
39 | void remove(); | ||
40 | void processCommand(); | ||
41 | void display(IRCOutput output); | ||
42 | protected: | ||
43 | bool m_close; | ||
44 | MainWindow *m_mainWindow; | ||
45 | IRCServerTab *m_parentTab; | ||
46 | IRCPerson *m_person; | ||
47 | QTextView *m_textview; | ||
48 | QLineEdit *m_field; | ||
49 | }; | ||
50 | |||
24 | #endif /* __IRCQUERYTAB_H */ | 51 | #endif /* __IRCQUERYTAB_H */ |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 503a758..8b8771f 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -6,16 +6,17 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa | |||
6 | m_server = server; | 6 | m_server = server; |
7 | m_session = new IRCSession(&m_server); | 7 | m_session = new IRCSession(&m_server); |
8 | m_mainWindow = mainWindow; | 8 | m_mainWindow = mainWindow; |
9 | m_close = FALSE; | 9 | m_close = FALSE; |
10 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); | 10 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); |
11 | m_textview = new QTextView(this); | 11 | m_textview = new QTextView(this); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_textview->setTextFormat(RichText); | ||
14 | m_layout->add(m_textview); | 15 | m_layout->add(m_textview); |
15 | m_field = new QLineEdit(this); | 16 | m_field = new QLineEdit(this); |
16 | m_layout->add(m_field); | 17 | m_layout->add(m_field); |
17 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
18 | m_field->setFocus(); | 19 | m_field->setFocus(); |
19 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
20 | } | 21 | } |
21 | 22 | ||
@@ -28,16 +29,20 @@ void IRCServerTab::appendText(QString text) { | |||
28 | IRCServerTab::~IRCServerTab() { | 29 | IRCServerTab::~IRCServerTab() { |
29 | delete m_session; | 30 | delete m_session; |
30 | } | 31 | } |
31 | 32 | ||
32 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { | 33 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { |
33 | m_channelTabs.remove(tab); | 34 | m_channelTabs.remove(tab); |
34 | } | 35 | } |
35 | 36 | ||
37 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { | ||
38 | m_queryTabs.remove(tab); | ||
39 | } | ||
40 | |||
36 | QString IRCServerTab::title() { | 41 | QString IRCServerTab::title() { |
37 | return "Server"; | 42 | return "Server"; |
38 | } | 43 | } |
39 | 44 | ||
40 | IRCSession *IRCServerTab::session() { | 45 | IRCSession *IRCServerTab::session() { |
41 | return m_session; | 46 | return m_session; |
42 | } | 47 | } |
43 | 48 | ||
@@ -55,26 +60,40 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | |||
55 | QString channel; | 60 | QString channel; |
56 | stream >> channel; | 61 | stream >> channel; |
57 | if (channel.length() > 0 && channel.startsWith("#")) { | 62 | if (channel.length() > 0 && channel.startsWith("#")) { |
58 | m_session->join(channel); | 63 | m_session->join(channel); |
59 | } else { | 64 | } else { |
60 | tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); | 65 | tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); |
61 | } | 66 | } |
62 | } else if (command == "ME") { | 67 | } else if (command == "ME") { |
63 | QString text = IRCOutput::toHTML(line.right(line.length()-4)); | 68 | QString text = line.right(line.length()-4); |
64 | if (text.length() > 0) { | 69 | if (text.length() > 0) { |
65 | if (tab->isA("IRCChannelTab")) { | 70 | if (tab->isA("IRCChannelTab")) { |
66 | tab->appendText("<font color=\"#cc0000\">*" + m_server.nick() + " " + text + "</font><br>"); | 71 | tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
67 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); | 72 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); |
68 | } else if (tab->isA("IRCQueryTab")) { | 73 | } else if (tab->isA("IRCQueryTab")) { |
74 | tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | ||
75 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); | ||
69 | } else { | 76 | } else { |
70 | tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>"); | 77 | tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>"); |
71 | } | 78 | } |
72 | } | 79 | } |
80 | } else if (command == "MSG") { | ||
81 | QString nickname; | ||
82 | stream >> nickname; | ||
83 | if (nickname.length() > 0) { | ||
84 | if (line.length() > 6 + nickname.length()) { | ||
85 | QString text = line.right(line.length()-nickname.length()-6); | ||
86 | IRCPerson person; | ||
87 | person.setNick(nickname); | ||
88 | tab->appendText("><font color=\"#0000dd\">"+IRCOutput::toHTML(nickname)+"</font>< "+IRCOutput::toHTML(text)+"<br>"); | ||
89 | m_session->sendMessage(&person, text); | ||
90 | } | ||
91 | } | ||
73 | } else { | 92 | } else { |
74 | tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); | 93 | tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); |
75 | } | 94 | } |
76 | } | 95 | } |
77 | 96 | ||
78 | void IRCServerTab::processCommand() { | 97 | void IRCServerTab::processCommand() { |
79 | QString text = m_field->text(); | 98 | QString text = m_field->text(); |
80 | if (text.startsWith("/") && !text.startsWith("//")) { | 99 | if (text.startsWith("/") && !text.startsWith("//")) { |
@@ -95,40 +114,58 @@ void IRCServerTab::remove() { | |||
95 | m_close = TRUE; | 114 | m_close = TRUE; |
96 | m_session->endSession(); | 115 | m_session->endSession(); |
97 | } else { | 116 | } else { |
98 | /* Session has previously been closed */ | 117 | /* Session has previously been closed */ |
99 | m_channelTabs.first(); | 118 | m_channelTabs.first(); |
100 | while (m_channelTabs.current() != 0) { | 119 | while (m_channelTabs.current() != 0) { |
101 | m_mainWindow->killTab(m_channelTabs.current()); | 120 | m_mainWindow->killTab(m_channelTabs.current()); |
102 | } | 121 | } |
122 | m_queryTabs.first(); | ||
123 | while (m_queryTabs.current() != 0) { | ||
124 | m_mainWindow->killTab(m_queryTabs.current()); | ||
125 | } | ||
103 | m_mainWindow->killTab(this); | 126 | m_mainWindow->killTab(this); |
104 | } | 127 | } |
105 | } | 128 | } |
106 | 129 | ||
107 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { | 130 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { |
108 | QListIterator<IRCChannelTab> it(m_channelTabs); | 131 | QListIterator<IRCChannelTab> it(m_channelTabs); |
109 | 132 | ||
110 | for (; it.current(); ++it) { | 133 | for (; it.current(); ++it) { |
111 | if (it.current()->channel() == channel) | 134 | if (it.current()->channel() == channel) |
112 | return it.current(); | 135 | return it.current(); |
113 | } | 136 | } |
114 | return 0; | 137 | return 0; |
115 | } | 138 | } |
116 | 139 | ||
140 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { | ||
141 | QListIterator<IRCQueryTab> it(m_queryTabs); | ||
142 | |||
143 | for (; it.current(); ++it) { | ||
144 | if (it.current()->person()->nick() == person->nick()) | ||
145 | return it.current(); | ||
146 | } | ||
147 | return 0; | ||
148 | } | ||
149 | |||
117 | void IRCServerTab::display(IRCOutput output) { | 150 | void IRCServerTab::display(IRCOutput output) { |
118 | 151 | ||
119 | /* All messages to be displayed inside the GUI get here */ | 152 | /* All messages to be displayed inside the GUI get here */ |
120 | switch (output.type()) { | 153 | switch (output.type()) { |
121 | case OUTPUT_CONNCLOSE: | 154 | case OUTPUT_CONNCLOSE: |
122 | if (m_close) { | 155 | if (m_close) { |
123 | m_channelTabs.first(); | 156 | m_channelTabs.first(); |
124 | while (m_channelTabs.current() != 0) { | 157 | while (m_channelTabs.current() != 0) { |
125 | m_mainWindow->killTab(m_channelTabs.current()); | 158 | m_mainWindow->killTab(m_channelTabs.current()); |
126 | } | 159 | } |
160 | m_queryTabs.first(); | ||
161 | while (m_queryTabs.current() != 0) { | ||
162 | m_mainWindow->killTab(m_queryTabs.current()); | ||
163 | } | ||
127 | m_mainWindow->killTab(this); | 164 | m_mainWindow->killTab(this); |
128 | } else { | 165 | } else { |
129 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); | 166 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); |
130 | QListIterator<IRCChannelTab> it(m_channelTabs); | 167 | QListIterator<IRCChannelTab> it(m_channelTabs); |
131 | for (; it.current(); ++it) { | 168 | for (; it.current(); ++it) { |
132 | it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); | 169 | it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); |
133 | } | 170 | } |
134 | } | 171 | } |
@@ -136,17 +173,28 @@ void IRCServerTab::display(IRCOutput output) { | |||
136 | case OUTPUT_SELFJOIN: { | 173 | case OUTPUT_SELFJOIN: { |
137 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 174 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
138 | m_channelTabs.append(channeltab); | 175 | m_channelTabs.append(channeltab); |
139 | m_mainWindow->addTab(channeltab); | 176 | m_mainWindow->addTab(channeltab); |
140 | } | 177 | } |
141 | break; | 178 | break; |
142 | case OUTPUT_CHANPRIVMSG: { | 179 | case OUTPUT_CHANPRIVMSG: { |
143 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 180 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
144 | channelTab->appendText("<<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>> "+output.htmlMessage()+"<br>"); | 181 | channelTab->appendText("<<font color=\"#0000dd\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font>> "+output.htmlMessage()+"<br>"); |
182 | } | ||
183 | break; | ||
184 | case OUTPUT_QUERYACTION: | ||
185 | case OUTPUT_QUERYPRIVMSG: { | ||
186 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); | ||
187 | if (!queryTab) { | ||
188 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | ||
189 | m_queryTabs.append(queryTab); | ||
190 | m_mainWindow->addTab(queryTab); | ||
191 | } | ||
192 | queryTab->display(output); | ||
145 | } | 193 | } |
146 | break; | 194 | break; |
147 | case OUTPUT_SELFPART: { | 195 | case OUTPUT_SELFPART: { |
148 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 196 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
149 | if (channelTab) | 197 | if (channelTab) |
150 | m_mainWindow->killTab(channelTab); | 198 | m_mainWindow->killTab(channelTab); |
151 | } | 199 | } |
152 | break; | 200 | break; |
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h index cfa0832..e439d84 100644 --- a/noncore/net/opieirc/ircservertab.h +++ b/noncore/net/opieirc/ircservertab.h | |||
@@ -20,44 +20,51 @@ | |||
20 | 20 | ||
21 | #ifndef __IRCSERVERTAB_H | 21 | #ifndef __IRCSERVERTAB_H |
22 | #define __IRCSERVERTAB_H | 22 | #define __IRCSERVERTAB_H |
23 | 23 | ||
24 | #include "irctab.h" | 24 | #include "irctab.h" |
25 | #include "ircsession.h" | 25 | #include "ircsession.h" |
26 | #include "mainwindow.h" | 26 | #include "mainwindow.h" |
27 | #include "ircchanneltab.h" | 27 | #include "ircchanneltab.h" |
28 | #include "ircquerytab.h" | ||
28 | 29 | ||
29 | class IRCServerTab : public IRCTab { | 30 | class IRCServerTab : public IRCTab { |
30 | Q_OBJECT | 31 | Q_OBJECT |
31 | public: | 32 | public: |
32 | /* IRCTab implementation */ | 33 | /* IRCTab implementation */ |
33 | IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 34 | IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
34 | ~IRCServerTab(); | 35 | ~IRCServerTab(); |
35 | QString title(); | 36 | QString title(); |
36 | IRCSession *session(); | 37 | IRCSession *session(); |
37 | IRCServer *server(); | 38 | IRCServer *server(); |
38 | 39 | ||
39 | /* Start the server session */ | 40 | /* Start the server session */ |
40 | void doConnect(); | 41 | void doConnect(); |
42 | /* Remove tabs from the internal tab lists */ | ||
41 | void removeChannelTab(IRCChannelTab *tab); | 43 | void removeChannelTab(IRCChannelTab *tab); |
44 | void removeQueryTab(IRCQueryTab *tab); | ||
42 | 45 | ||
43 | /* Execute a user command such as /join */ | 46 | /* Execute a user command such as /join */ |
44 | void executeCommand(IRCTab *tab, QString line); | 47 | void executeCommand(IRCTab *tab, QString line); |
45 | protected: | 48 | protected: |
46 | void appendText(QString text); | 49 | void appendText(QString text); |
47 | IRCChannelTab *getTabForChannel(IRCChannel *channel); | 50 | IRCChannelTab *getTabForChannel(IRCChannel *channel); |
51 | IRCQueryTab *getTabForQuery(IRCPerson *person); | ||
48 | public slots: | 52 | public slots: |
49 | void remove(); | 53 | void remove(); |
50 | void processCommand(); | 54 | void processCommand(); |
51 | protected slots: | 55 | protected slots: |
52 | void display(IRCOutput output); | 56 | void display(IRCOutput output); |
53 | protected: | 57 | protected: |
54 | bool m_close; | 58 | bool m_close; |
55 | IRCServer m_server; | 59 | IRCServer m_server; |
56 | IRCSession *m_session; | 60 | IRCSession *m_session; |
57 | MainWindow *m_mainWindow; | 61 | MainWindow *m_mainWindow; |
58 | QTextView *m_textview; | 62 | QTextView *m_textview; |
59 | QLineEdit *m_field; | 63 | QLineEdit *m_field; |
64 | /* Channel tabs associated with this server tab */ | ||
60 | QList<IRCChannelTab> m_channelTabs; | 65 | QList<IRCChannelTab> m_channelTabs; |
66 | /* Query tabs associated with this server tab */ | ||
67 | QList<IRCQueryTab> m_queryTabs; | ||
61 | }; | 68 | }; |
62 | 69 | ||
63 | #endif /* __IRCSERVERTAB_H */ | 70 | #endif /* __IRCSERVERTAB_H */ |