summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp18
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp24
-rw-r--r--noncore/net/opieirc/ircmisc.cpp19
-rw-r--r--noncore/net/opieirc/ircmisc.h8
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp9
-rw-r--r--noncore/net/opieirc/ircservertab.cpp15
-rw-r--r--noncore/net/opieirc/ircservertab.h2
-rw-r--r--noncore/net/opieirc/irctab.cpp7
-rw-r--r--noncore/net/opieirc/irctab.h10
-rw-r--r--noncore/net/opieirc/mainwindow.cpp37
-rw-r--r--noncore/net/opieirc/mainwindow.h7
11 files changed, 138 insertions, 18 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index 667e977..b6e3954 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,165 +1,181 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qwhatsthis.h> 2#include <qwhatsthis.h>
3#include <qhbox.h> 3#include <qhbox.h>
4#include "ircchanneltab.h" 4#include "ircchanneltab.h"
5#include "ircservertab.h" 5#include "ircservertab.h"
6 6
7IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 7IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
8 m_mainWindow = mainWindow; 8 m_mainWindow = mainWindow;
9 m_parentTab = parentTab; 9 m_parentTab = parentTab;
10 m_channel = channel; 10 m_channel = channel;
11 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 11 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
12 QHBox *hbox = new QHBox(this); 12 QHBox *hbox = new QHBox(this);
13 m_textview = new QTextView(hbox); 13 m_textview = new QTextView(hbox);
14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_listVisible = TRUE; 16 m_listVisible = TRUE;
17 m_listButton = new QPushButton(">", m_textview); 17 m_listButton = new QPushButton(">", m_textview);
18 m_textview->setCornerWidget(m_listButton); 18 m_textview->setCornerWidget(m_listButton);
19 m_textview->setTextFormat(RichText); 19 m_textview->setTextFormat(RichText);
20 QWhatsThis::add(m_textview, tr("Channel discussion")); 20 QWhatsThis::add(m_textview, tr("Channel discussion"));
21 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 21 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
22 m_list = new IRCChannelList(m_channel, hbox); 22 m_list = new IRCChannelList(m_channel, hbox);
23 m_list->update(); 23 m_list->update();
24 m_list->setMaximumWidth(LISTWIDTH); 24 m_list->setMaximumWidth(LISTWIDTH);
25 m_field = new IRCHistoryLineEdit(this); 25 m_field = new IRCHistoryLineEdit(this);
26 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
27 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
28 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab()));
29 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
30
26 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); 31 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
27 m_popup = new QPopupMenu(m_list); 32 m_popup = new QPopupMenu(m_list);
28 m_lines = 0; 33 m_lines = 0;
29 /* Required so that embedded-style "right" clicks work */ 34 /* Required so that embedded-style "right" clicks work */
30 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 35 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
31 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); 36 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&)));
32 /* Construct the popup menu */ 37 /* Construct the popup menu */
33 QPopupMenu *ctcpMenu = new QPopupMenu(m_list); 38 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
34 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); 39 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
35 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); 40 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
36 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); 41 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
37 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); 42 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
38 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 43 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
39 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 44 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
40 m_layout->add(hbox); 45 m_layout->add(hbox);
41 hbox->show(); 46 hbox->show();
42 m_layout->add(m_field); 47 m_layout->add(m_field);
43 m_field->setFocus(); 48 m_field->setFocus();
49 m_field->setActiveWindow();
50
44 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 51 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
45 settingsChanged(); 52 settingsChanged();
46} 53}
47 54
48void IRCChannelTab::scrolling(){ 55void IRCChannelTab::scrolling(){
49 m_textview->ensureVisible(0, m_textview->contentsHeight()); 56 m_textview->ensureVisible(0, m_textview->contentsHeight());
50} 57}
51 58
52void IRCChannelTab::appendText(QString text) { 59void IRCChannelTab::appendText(QString text) {
53 /* not using append because it creates layout problems */ 60 /* not using append because it creates layout problems */
54 QString txt = m_textview->text() + text + "\n"; 61 QString txt = m_textview->text() + text + "\n";
55 if (m_maxLines > 0 && m_lines >= m_maxLines) { 62 if (m_maxLines > 0 && m_lines >= m_maxLines) {
56 int firstBreak = txt.find('\n'); 63 int firstBreak = txt.find('\n');
57 if (firstBreak != -1) { 64 if (firstBreak != -1) {
58 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 65 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
59 } 66 }
60 } else { 67 } else {
61 m_lines++; 68 m_lines++;
62 } 69 }
63 m_textview->ensureVisible(0, m_textview->contentsHeight()); 70 m_textview->ensureVisible(0, m_textview->contentsHeight());
64 m_textview->setText(txt); 71 m_textview->setText(txt);
65 m_textview->ensureVisible(0, m_textview->contentsHeight()); 72 m_textview->ensureVisible(0, m_textview->contentsHeight());
73
74 int p1, p2;
75 if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) {
76 int col = text.findRev("color", -1, false);
77 if ( col < p2 )
78 emit ping( title() );
79
80 }
81
66 emit changed(this); 82 emit changed(this);
67} 83}
68 84
69IRCChannelTab::~IRCChannelTab() { 85IRCChannelTab::~IRCChannelTab() {
70 m_parentTab->removeChannelTab(this); 86 m_parentTab->removeChannelTab(this);
71} 87}
72 88
73void IRCChannelTab::processCommand() { 89void IRCChannelTab::processCommand() {
74 QString text = m_field->text(); 90 QString text = m_field->text();
75 if (text.length()>0) { 91 if (text.length()>0) {
76 if (session()->isSessionActive()) { 92 if (session()->isSessionActive()) {
77 if (text.startsWith("/") && !text.startsWith("//")) { 93 if (text.startsWith("/") && !text.startsWith("//")) {
78 /* Command mode */ 94 /* Command mode */
79 m_parentTab->executeCommand(this, text);; 95 m_parentTab->executeCommand(this, text);;
80 } else { 96 } else {
81 if (text.startsWith("//")) 97 if (text.startsWith("//"))
82 text = text.right(text.length()-1); 98 text = text.right(text.length()-1);
83 session()->sendMessage(m_channel, m_field->text()); 99 session()->sendMessage(m_channel, m_field->text());
84 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>"); 100 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
85 } 101 }
86 } else { 102 } else {
87 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 103 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
88 } 104 }
89 } 105 }
90 m_field->clear(); 106 m_field->clear();
91} 107}
92 108
93void IRCChannelTab::settingsChanged() { 109void IRCChannelTab::settingsChanged() {
94 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 110 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
95 m_lines = 0; 111 m_lines = 0;
96} 112}
97 113
98void IRCChannelTab::toggleList() { 114void IRCChannelTab::toggleList() {
99 if (m_listVisible) { 115 if (m_listVisible) {
100 m_list->setMaximumWidth(0); 116 m_list->setMaximumWidth(0);
101 m_listButton->setText("<"); 117 m_listButton->setText("<");
102 } else { 118 } else {
103 m_list->setMaximumWidth(LISTWIDTH); 119 m_list->setMaximumWidth(LISTWIDTH);
104 m_listButton->setText(">"); 120 m_listButton->setText(">");
105 } 121 }
106 m_listVisible = !m_listVisible; 122 m_listVisible = !m_listVisible;
107} 123}
108 124
109void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { 125void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
110 switch (mouse) { 126 switch (mouse) {
111 case 1: 127 case 1:
112 break; 128 break;
113 case 2: 129 case 2:
114 m_popup->popup(point); 130 m_popup->popup(point);
115 break; 131 break;
116 }; 132 };
117} 133}
118 134
119void IRCChannelTab::popupQuery() { 135void IRCChannelTab::popupQuery() {
120 if (m_list->currentItem() != -1) { 136 if (m_list->currentItem() != -1) {
121 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); 137 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
122 if (person) { 138 if (person) {
123 IRCQueryTab *tab = m_parentTab->getTabForQuery(person); 139 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
124 if (!tab) { 140 if (!tab) {
125 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); 141 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
126 m_parentTab->addQueryTab(tab); 142 m_parentTab->addQueryTab(tab);
127 m_mainWindow->addTab(tab); 143 m_mainWindow->addTab(tab);
128 } 144 }
129 } 145 }
130 } 146 }
131} 147}
132 148
133void IRCChannelTab::popupPing() { 149void IRCChannelTab::popupPing() {
134 //HAHA, no wonder these don't work 150 //HAHA, no wonder these don't work
135} 151}
136 152
137void IRCChannelTab::popupVersion() { 153void IRCChannelTab::popupVersion() {
138} 154}
139 155
140void IRCChannelTab::popupWhois() { 156void IRCChannelTab::popupWhois() {
141} 157}
142 158
143QString IRCChannelTab::title() { 159QString IRCChannelTab::title() {
144 return m_channel->channelname(); 160 return m_channel->channelname();
145} 161}
146 162
147IRCSession *IRCChannelTab::session() { 163IRCSession *IRCChannelTab::session() {
148 return m_parentTab->session(); 164 return m_parentTab->session();
149} 165}
150 166
151void IRCChannelTab::remove() { 167void IRCChannelTab::remove() {
152 if (session()->isSessionActive()) { 168 if (session()->isSessionActive()) {
153 session()->part(m_channel); 169 session()->part(m_channel);
154 } else { 170 } else {
155 m_mainWindow->killTab(this); 171 m_mainWindow->killTab(this);
156 } 172 }
157} 173}
158 174
159IRCChannel *IRCChannelTab::channel() { 175IRCChannel *IRCChannelTab::channel() {
160 return m_channel; 176 return m_channel;
161} 177}
162 178
163IRCChannelList *IRCChannelTab::list() { 179IRCChannelList *IRCChannelTab::list() {
164 return m_list; 180 return m_list;
165} 181}
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 400ff41..90280d7 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -1,79 +1,79 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include "ircmessageparser.h" 2#include "ircmessageparser.h"
3#include "ircversion.h" 3#include "ircversion.h"
4 4
5/* Lookup table for literal commands */ 5/* Lookup table for literal commands */
6IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { 6IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
7 { "PING", FUNC(parseLiteralPing) }, 7 { "PING", FUNC(parseLiteralPing) },
8 { "NOTICE", FUNC(parseLiteralNotice) }, 8 { "NOTICE", FUNC(parseLiteralNotice) },
9 { "JOIN", FUNC(parseLiteralJoin) }, 9 { "JOIN", FUNC(parseLiteralJoin) },
10 { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, 10 { "PRIVMSG", FUNC(parseLiteralPrivMsg) },
11 { "NICK", FUNC(parseLiteralNick) }, 11 { "NICK", FUNC(parseLiteralNick) },
12 { "PART", FUNC(parseLiteralPart) }, 12 { "PART", FUNC(parseLiteralPart) },
13 { "QUIT", FUNC(parseLiteralQuit) }, 13 { "QUIT", FUNC(parseLiteralQuit) },
14 { "ERROR", FUNC(parseLiteralError) }, 14 { "ERROR", FUNC(parseLiteralError) },
15 { "ERROR:", FUNC(parseLiteralError) }, 15 { "ERROR:", FUNC(parseLiteralError) },
16 { "MODE", FUNC(parseLiteralMode) }, 16 { "MODE", FUNC(parseLiteralMode) },
17 { "KICK", FUNC(parseLiteralKick) }, 17 { "KICK", FUNC(parseLiteralKick) },
18 { "TOPIC", FUNC(parseLiteralTopic) }, 18 { "TOPIC", FUNC(parseLiteralTopic) },
19 { 0 , 0 } 19 { 0 , 0 }
20}; 20};
21 21
22/* Lookup table for literal commands */ 22/* Lookup table for literal commands */
23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { 23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
24 { "PING", FUNC(parseCTCPPing) }, 24 { "PING", FUNC(parseCTCPPing) },
25 { "VERSION", FUNC(parseCTCPVersion) }, 25 { "VERSION", FUNC(parseCTCPVersion) },
26 { "ACTION", FUNC(parseCTCPAction) }, 26 { "ACTION", FUNC(parseCTCPAction) },
27 { 0 , 0 } 27 { 0 , 0 }
28}; 28};
29 29
30/* Lookup table for numerical commands */ 30/* Lookup table for numerical commands */
31IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { 31IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
32 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME 32 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME
33 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST 33 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST
34 { 3, FUNC(parseNumerical003) }, // RPL_CREATED 34 { 3, FUNC(parseNumerical003) }, // RPL_CREATED
35 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO 35 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO
36 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL 36 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL
37 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT 37 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT
38 { 252, FUNC(parseNumericalStats) }, // RPL_LUSEROP 38 { 252, FUNC(parseNumericalStats) }, // RPL_LUSEROP
39 { 265, FUNC(parseNumericalStats) }, // RPL_LOCALUSERS 39 { 265, FUNC(parseNumericalStats) }, // RPL_LOCALUSERS
40 { 266, FUNC(parseNumericalStats) }, // RPL_GLOBALUSERS 40 { 266, FUNC(parseNumericalStats) }, // RPL_GLOBALUSERS
41 { 250, FUNC(parseNumericalStats) }, // RPL_STATSCONN 41 { 250, FUNC(parseNumericalStats) }, // RPL_STATSCONN
42 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS 42 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS
43 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME 43 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME
44 { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC 44 { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC
45 { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME 45 { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME
46 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY 46 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY
47 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES 47 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES
48 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART 48 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART
49 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD 49 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD
50 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD 50 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD
51 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 51 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2
52 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 52 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3
53 { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK 53 { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK
54 { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK 54 { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK
55 { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND 55 { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND
56 { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE 56 { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE
57 { 0, 0 } 57 { 0, 0 }
58}; 58};
59 59
60IRCMessageParser::IRCMessageParser(IRCSession *session) { 60IRCMessageParser::IRCMessageParser(IRCSession *session) {
61 m_session = session; 61 m_session = session;
62} 62}
63 63
64void IRCMessageParser::parse(IRCMessage *message) { 64void IRCMessageParser::parse(IRCMessage *message) {
65 /* Find out what kind of message we have here and call the appropriate handler using 65 /* Find out what kind of message we have here and call the appropriate handler using
66 the parser tables. If no handler can be found, print out an error message */ 66 the parser tables. If no handler can be found, print out an error message */
67 if (message->isNumerical()) { 67 if (message->isNumerical()) {
68 for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { 68 for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) {
69 if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { 69 if (message->commandNumber() == numericalParserProcTable[i].commandNumber) {
70 (this->*(numericalParserProcTable[i].proc))(message); 70 (this->*(numericalParserProcTable[i].proc))(message);
71 return; 71 return;
72 } 72 }
73 } 73 }
74 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) ))); 74 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) )));
75 } else if (message->isCTCP()) { 75 } else if (message->isCTCP()) {
76 for (int i=0; ctcpParserProcTable[i].commandName; i++) { 76 for (int i=0; ctcpParserProcTable[i].commandName; i++) {
77 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { 77 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) {
78 (this->*(ctcpParserProcTable[i].proc))(message); 78 (this->*(ctcpParserProcTable[i].proc))(message);
79 return; 79 return;
@@ -126,251 +126,251 @@ void IRCMessageParser::parseLiteralJoin(IRCMessage *message) {
126 m_session->addPerson(person); 126 m_session->addPerson(person);
127 } 127 }
128 chanperson->flags = 0; 128 chanperson->flags = 0;
129 chanperson->person = person; 129 chanperson->person = person;
130 channel->addPerson(chanperson); 130 channel->addPerson(chanperson);
131 IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName )); 131 IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName ));
132 output.addParam(channel); 132 output.addParam(channel);
133 output.addParam(chanperson); 133 output.addParam(chanperson);
134 emit outputReady(output); 134 emit outputReady(output);
135 } else { 135 } else {
136 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); 136 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?")));
137 } 137 }
138 } else { 138 } else {
139 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); 139 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?")));
140 } 140 }
141 } 141 }
142} 142}
143 143
144void IRCMessageParser::parseLiteralPart(IRCMessage *message) { 144void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
145 QString channelName = message->param(0).lower(); 145 QString channelName = message->param(0).lower();
146 IRCChannel *channel = m_session->getChannel(channelName); 146 IRCChannel *channel = m_session->getChannel(channelName);
147 IRCPerson mask(message->prefix()); 147 IRCPerson mask(message->prefix());
148 if (channel) { 148 if (channel) {
149 if (mask.nick() == m_session->m_server->nick()) { 149 if (mask.nick() == m_session->m_server->nick()) {
150 m_session->removeChannel(channel); 150 m_session->removeChannel(channel);
151 IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName )); 151 IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName ));
152 output.addParam(channel); 152 output.addParam(channel);
153 emit outputReady(output); 153 emit outputReady(output);
154 delete channel; 154 delete channel;
155 } else { 155 } else {
156 IRCChannelPerson *person = channel->getPerson(mask.nick()); 156 IRCChannelPerson *person = channel->getPerson(mask.nick());
157 if (person) { 157 if (person) {
158 channel->removePerson(person); 158 channel->removePerson(person);
159 IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) ); 159 IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) );
160 output.addParam(channel); 160 output.addParam(channel);
161 output.addParam(person); 161 output.addParam(person);
162 emit outputReady(output); 162 emit outputReady(output);
163 delete person; 163 delete person;
164 } else { 164 } else {
165 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); 165 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?")));
166 } 166 }
167 } 167 }
168 } else { 168 } else {
169 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); 169 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?")));
170 } 170 }
171} 171}
172 172
173void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { 173void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
174 if (m_session->m_server->nick() == message->param(0)) { 174 if (m_session->m_server->nick().lower() == message->param(0).lower() ) {
175 /* IRC Query message detected, verify sender and display it */ 175 /* IRC Query message detected, verify sender and display it */
176 IRCPerson mask(message->prefix()); 176 IRCPerson mask(message->prefix());
177 IRCPerson *person = m_session->getPerson(mask.nick()); 177 IRCPerson *person = m_session->getPerson(mask.nick());
178 if (!person) { 178 if (!person) {
179 /* Person not yet known, create and add to the current session */ 179 /* Person not yet known, create and add to the current session */
180 person = new IRCPerson(message->prefix()); 180 person = new IRCPerson(message->prefix());
181 m_session->addPerson(person); 181 m_session->addPerson(person);
182 } 182 }
183 IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); 183 IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1));
184 output.addParam(person); 184 output.addParam(person);
185 emit outputReady(output); 185 emit outputReady(output);
186 } else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') { 186 } else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') {
187 /* IRC Channel message detected, verify sender, channel and display it */ 187 /* IRC Channel message detected, verify sender, channel and display it */
188 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 188 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
189 if (channel) { 189 if (channel) {
190 IRCPerson mask(message->prefix()); 190 IRCPerson mask(message->prefix());
191 IRCChannelPerson *person = channel->getPerson(mask.nick()); 191 IRCChannelPerson *person = channel->getPerson(mask.nick());
192 if (person) { 192 if (person) {
193 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); 193 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
194 output.addParam(channel); 194 output.addParam(channel);
195 output.addParam(person); 195 output.addParam(person);
196 emit outputReady(output); 196 emit outputReady(output);
197 } else { 197 } else {
198 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); 198 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender")));
199 } 199 }
200 } else { 200 } else {
201 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); 201 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) ));
202 } 202 }
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
208void IRCMessageParser::parseLiteralNick(IRCMessage *message) { 208void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
209 209
210 IRCPerson mask(message->prefix()); 210 IRCPerson mask(message->prefix());
211 /* this way of handling nick changes really sucks */ 211 /* this way of handling nick changes really sucks */
212 if (mask.nick() == m_session->m_server->nick()) { 212 if (mask.nick() == m_session->m_server->nick()) {
213 /* We are changing our nickname */ 213 /* We are changing our nickname */
214 m_session->m_server->setNick(message->param(0)); 214 m_session->m_server->setNick(message->param(0));
215 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)));
216 output.addParam(0); 216 output.addParam(0);
217 emit outputReady(output); 217 emit outputReady(output);
218 } else { 218 } else {
219 /* Someone else is */ 219 /* Someone else is */
220 IRCPerson *person = m_session->getPerson(mask.nick()); 220 IRCPerson *person = m_session->getPerson(mask.nick());
221 if (person) { 221 if (person) {
222 //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)));
223 223
224 /* new code starts here -- this removes the person from all channels */ 224 /* new code starts here -- this removes the person from all channels */
225 QList<IRCChannel> channels; 225 QList<IRCChannel> channels;
226 m_session->getChannelsByPerson(person, channels); 226 m_session->getChannelsByPerson(person, channels);
227 QListIterator<IRCChannel> it(channels); 227 QListIterator<IRCChannel> it(channels);
228 for (;it.current(); ++it) { 228 for (;it.current(); ++it) {
229 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 229 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
230 it.current()->removePerson(chanperson); 230 it.current()->removePerson(chanperson);
231 chanperson->person->setNick(message->param(0)); 231 chanperson->person->setNick(message->param(0));
232 it.current()->addPerson(chanperson); 232 it.current()->addPerson(chanperson);
233 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 233 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
234 output.addParam(person); 234 output.addParam(person);
235 emit outputReady(output); 235 emit outputReady(output);
236 } 236 }
237 /* new code ends here */ 237 /* new code ends here */
238 } else { 238 } else {
239 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")));
240 } 240 }
241 } 241 }
242} 242}
243 243
244void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { 244void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
245 IRCPerson mask(message->prefix()); 245 IRCPerson mask(message->prefix());
246 IRCPerson *person = m_session->getPerson(mask.nick()); 246 IRCPerson *person = m_session->getPerson(mask.nick());
247 if (person) { 247 if (person) {
248 QList<IRCChannel> channels; 248 QList<IRCChannel> channels;
249 m_session->getChannelsByPerson(person, channels); 249 m_session->getChannelsByPerson(person, channels);
250 QListIterator<IRCChannel> it(channels); 250 QListIterator<IRCChannel> it(channels);
251 for (;it.current(); ++it) { 251 for (;it.current(); ++it) {
252 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 252 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
253 it.current()->removePerson(chanperson); 253 it.current()->removePerson(chanperson);
254 delete chanperson; 254 delete chanperson;
255 } 255 }
256 m_session->removePerson(person); 256 m_session->removePerson(person);
257 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); 257 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) ));
258 output.addParam(person); 258 output.addParam(person);
259 emit outputReady(output); 259 emit outputReady(output);
260 delete person; 260 delete person;
261 } else { 261 } else {
262 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); 262 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?")));
263 } 263 }
264} 264}
265 265
266void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { 266void IRCMessageParser::parseLiteralTopic(IRCMessage *message) {
267 IRCPerson mask(message->prefix()); 267 IRCPerson mask(message->prefix());
268 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 268 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
269 if (channel) { 269 if (channel) {
270 IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); 270 IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\"");
271 output.addParam(channel); 271 output.addParam(channel);
272 emit outputReady(output); 272 emit outputReady(output);
273 } else { 273 } else {
274 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); 274 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?")));
275 } 275 }
276} 276}
277 277
278void IRCMessageParser::parseLiteralError(IRCMessage *message) { 278void IRCMessageParser::parseLiteralError(IRCMessage *message) {
279 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); 279 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters()));
280} 280}
281 281
282void IRCMessageParser::parseCTCPPing(IRCMessage *message) { 282void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
283 IRCPerson mask(message->prefix()); 283 IRCPerson mask(message->prefix());
284 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); 284 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters());
285 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); 285 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick()));
286} 286}
287 287
288void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { 288void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
289 IRCPerson mask(message->prefix()); 289 IRCPerson mask(message->prefix());
290 m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); 290 m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR);
291 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); 291 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick()));
292} 292}
293 293
294void IRCMessageParser::parseCTCPAction(IRCMessage *message) { 294void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
295 IRCPerson mask(message->prefix()); 295 IRCPerson mask(message->prefix());
296 QString dest = message->ctcpDestination(); 296 QString dest = message->ctcpDestination();
297 if (dest.startsWith("#")) { 297 if (dest.startsWith("#")) {
298 IRCChannel *channel = m_session->getChannel(dest.lower()); 298 IRCChannel *channel = m_session->getChannel(dest.lower());
299 if (channel) { 299 if (channel) {
300 IRCChannelPerson *person = channel->getPerson(mask.nick()); 300 IRCChannelPerson *person = channel->getPerson(mask.nick());
301 if (person) { 301 if (person) {
302 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); 302 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0));
303 output.addParam(channel); 303 output.addParam(channel);
304 output.addParam(person); 304 output.addParam(person);
305 emit outputReady(output); 305 emit outputReady(output);
306 } else { 306 } else {
307 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); 307 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?")));
308 } 308 }
309 } else { 309 } else {
310 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); 310 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?")));
311 } 311 }
312 } else { 312 } else {
313 if (message->ctcpDestination() == m_session->m_server->nick()) { 313 if (message->ctcpDestination() == m_session->m_server->nick()) {
314 IRCPerson *person = m_session->getPerson(mask.nick()); 314 IRCPerson *person = m_session->getPerson(mask.nick());
315 if (!person) { 315 if (!person) {
316 /* Person not yet known, create and add to the current session */ 316 /* Person not yet known, create and add to the current session */
317 person = new IRCPerson(message->prefix()); 317 person = new IRCPerson(message->prefix());
318 m_session->addPerson(person); 318 m_session->addPerson(person);
319 } 319 }
320 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); 320 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0));
321 output.addParam(person); 321 output.addParam(person);
322 emit outputReady(output); 322 emit outputReady(output);
323 } else { 323 } else {
324 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); 324 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
325 } 325 }
326 } 326 }
327} 327}
328 328
329void IRCMessageParser::parseLiteralMode(IRCMessage *message) { 329void IRCMessageParser::parseLiteralMode(IRCMessage *message) {
330 IRCPerson mask(message->prefix()); 330 IRCPerson mask(message->prefix());
331 331
332 if (message->param(0).startsWith("#")) { 332 if (message->param(0).startsWith("#")) {
333 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 333 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
334 if (channel) { 334 if (channel) {
335 QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); 335 QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1);
336 QTextIStream stream(&parameters); 336 QTextIStream stream(&parameters);
337 bool set = FALSE; 337 bool set = FALSE;
338 while (!stream.atEnd()) { 338 while (!stream.atEnd()) {
339 stream >> temp; 339 stream >> temp;
340 if (temp.startsWith("+")) { 340 if (temp.startsWith("+")) {
341 set = TRUE; 341 set = TRUE;
342 temp = temp.right(1); 342 temp = temp.right(1);
343 } else if (temp.startsWith("-")) { 343 } else if (temp.startsWith("-")) {
344 set = FALSE; 344 set = FALSE;
345 temp = temp.right(1); 345 temp = temp.right(1);
346 } else { 346 } else {
347 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); 347 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type")));
348 return; 348 return;
349 } 349 }
350 if (temp == "o") { 350 if (temp == "o") {
351 stream >> temp; 351 stream >> temp;
352 IRCChannelPerson *person = channel->getPerson(temp); 352 IRCChannelPerson *person = channel->getPerson(temp);
353 if (person) { 353 if (person) {
354 if (set) { 354 if (set) {
355 person->flags |= PERSON_FLAG_OP; 355 person->flags |= PERSON_FLAG_OP;
356 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); 356 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick()));
357 output.addParam(channel); 357 output.addParam(channel);
358 output.addParam(person); 358 output.addParam(person);
359 emit outputReady(output); 359 emit outputReady(output);
360 } else { 360 } else {
361 person->flags &= 0xFFFF - PERSON_FLAG_OP; 361 person->flags &= 0xFFFF - PERSON_FLAG_OP;
362 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); 362 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick()));
363 output.addParam(channel); 363 output.addParam(channel);
364 output.addParam(person); 364 output.addParam(person);
365 emit outputReady(output); 365 emit outputReady(output);
366 } 366 }
367 } else { 367 } else {
368 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); 368 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
369 } 369 }
370 } else if (temp == "v") { 370 } else if (temp == "v") {
371 stream >> temp; 371 stream >> temp;
372 IRCChannelPerson *person = channel->getPerson(temp); 372 IRCChannelPerson *person = channel->getPerson(temp);
373 if (person) { 373 if (person) {
374 if (set) { 374 if (set) {
375 person->flags |= PERSON_FLAG_VOICE; 375 person->flags |= PERSON_FLAG_VOICE;
376 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); 376 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick()));
@@ -416,114 +416,114 @@ void IRCMessageParser::parseLiteralKick(IRCMessage *message) {
416 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) + ")");
417 output.addParam(channel); 417 output.addParam(channel);
418 output.addParam(person); 418 output.addParam(person);
419 emit outputReady(output); 419 emit outputReady(output);
420 } 420 }
421 } else { 421 } else {
422 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); 422 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?")));
423 } 423 }
424 } else { 424 } else {
425 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); 425 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?")));
426 } 426 }
427} 427}
428 428
429void IRCMessageParser::parseNumerical001(IRCMessage *message) { 429void IRCMessageParser::parseNumerical001(IRCMessage *message) {
430 /* Welcome to IRC message, display */ 430 /* Welcome to IRC message, display */
431 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); 431 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
432} 432}
433 433
434void IRCMessageParser::parseNumerical002(IRCMessage *message) { 434void IRCMessageParser::parseNumerical002(IRCMessage *message) {
435 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); 435 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
436} 436}
437 437
438void IRCMessageParser::parseNumerical003(IRCMessage *message) { 438void IRCMessageParser::parseNumerical003(IRCMessage *message) {
439 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); 439 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
440} 440}
441 441
442void IRCMessageParser::parseNumerical004(IRCMessage *message) { 442void IRCMessageParser::parseNumerical004(IRCMessage *message) {
443 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); 443 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
444} 444}
445 445
446void IRCMessageParser::parseNumerical005(IRCMessage *message) { 446void IRCMessageParser::parseNumerical005(IRCMessage *message) {
447 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); 447 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
448} 448}
449 449
450void IRCMessageParser::parseNumericalStats(IRCMessage *message) { 450void IRCMessageParser::parseNumericalStats(IRCMessage *message) {
451 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); 451 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
452} 452}
453 453
454void IRCMessageParser::parseNumericalNames(IRCMessage *message) { 454void IRCMessageParser::parseNumericalNames(IRCMessage *message) {
455 /* Name list sent when joining a channel */ 455 /* Name list sent when joining a channel */
456 IRCChannel *channel = m_session->getChannel(message->param(2).lower()); 456 IRCChannel *channel = m_session->getChannel(message->param(2).lower());
457 if (channel != 0) { 457 if (channel != 0) {
458 QString people = message->param(3); 458 QString people = message->param(3);
459 QTextIStream stream(&people); 459 QTextIStream stream(&people);
460 QString temp; 460 QString temp;
461 461
462 while (!stream.atEnd()) { 462 while (!stream.atEnd()) {
463 stream >> temp; 463 stream >> temp;
464 464
465 char flagch = temp.at(0).latin1(); 465 char flagch = temp.at(0).latin1();
466 int flag = 0; 466 int flag = 0;
467 QString nick; 467 QString nick;
468 /* Parse person flags */ 468 /* Parse person flags */
469 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { 469 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') {
470 470
471 nick = temp.right(temp.length()-1); 471 nick = temp.right(temp.length()-1);
472 switch (flagch) { 472 switch (flagch) {
473 case '@': flag = PERSON_FLAG_OP; break; 473 case '@': flag = PERSON_FLAG_OP; break;
474 case '+': flag = PERSON_FLAG_VOICE; break; 474 case '+': flag = PERSON_FLAG_VOICE; break;
475 case '%': flag = PERSON_FLAG_HALFOP; break; 475 case '%': flag = PERSON_FLAG_HALFOP; break;
476 default : flag = 0; break; 476 default : flag = 0; break;
477 } 477 }
478 } else { 478 } else {
479 nick = temp; 479 nick = temp;
480 } 480 }
481 481
482 IRCChannelPerson *chan_person = new IRCChannelPerson(); 482 IRCChannelPerson *chan_person = new IRCChannelPerson();
483 IRCPerson *person = m_session->getPerson(nick); 483 IRCPerson *person = m_session->getPerson(nick);
484 if (person == 0) { 484 if (person == 0) {
485 person = new IRCPerson(); 485 person = new IRCPerson();
486 person->setNick(nick); 486 person->setNick(nick);
487 m_session->addPerson(person); 487 m_session->addPerson(person);
488 } 488 }
489 chan_person->person = person; 489 chan_person->person = person;
490 chan_person->flags = flag; 490 chan_person->flags = flag;
491 channel->addPerson(chan_person); 491 channel->addPerson(chan_person);
492 } 492 }
493 } else { 493 } else {
494 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); 494 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
495 } 495 }
496} 496}
497 497
498void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { 498void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) {
499 /* Done syncing to channel */ 499 /* Done syncing to channel */
500 IRCChannel *channel = m_session->getChannel(message->param(1).lower()); 500 IRCChannel *channel = m_session->getChannel(message->param(1).lower());
501 if (channel) { 501 if (channel) {
502 channel->setHasPeople(TRUE); 502 channel->setHasPeople(TRUE);
503 /* Yes, we want the names before anything happens inside the GUI */ 503 /* Yes, we want the names before anything happens inside the GUI */
504 IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); 504 IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname());
505 output.addParam(channel); 505 output.addParam(channel);
506 emit outputReady(output); 506 emit outputReady(output);
507 } else { 507 } else {
508 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); 508 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
509 } 509 }
510} 510}
511 511
512 512
513void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { 513void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) {
514 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); 514 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname")));
515 m_session->endSession(); 515 m_session->endSession();
516} 516}
517 517
518void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { 518void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) {
519 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); 519 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname")));
520} 520}
521 521
522void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { 522void IRCMessageParser::parseNumericalTopic(IRCMessage *message) {
523 IRCChannel *channel = m_session->getChannel(message->param(1).lower()); 523 IRCChannel *channel = m_session->getChannel(message->param(1).lower());
524 if (channel) { 524 if (channel) {
525 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); 525 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\""));
526 output.addParam(channel); 526 output.addParam(channel);
527 emit outputReady(output); 527 emit outputReady(output);
528 } else { 528 } else {
529 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\"")); 529 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\""));
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp
index 6d93a34..df6f874 100644
--- a/noncore/net/opieirc/ircmisc.cpp
+++ b/noncore/net/opieirc/ircmisc.cpp
@@ -21,66 +21,79 @@ int IRCTabBar::insertTab(QTab *tab, int index) {
21 21
22void IRCTabBar::setTabColor(int index, QColor color) { 22void IRCTabBar::setTabColor(int index, QColor color) {
23 ((QExtTab *)tab(index))->color = color; 23 ((QExtTab *)tab(index))->color = color;
24 update(); 24 update();
25} 25}
26 26
27void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const { 27void IRCTabBar::paintLabel(QPainter* p, const QRect& br, QTab* t, bool focus) const {
28 QRect r = br; 28 QRect r = br;
29 QTabBar::paintLabel(p, br, t, focus); 29 QTabBar::paintLabel(p, br, t, focus);
30 if (t->id == currentTab()) 30 if (t->id == currentTab())
31 r.setBottom(r.bottom() - style().defaultFrameWidth()); 31 r.setBottom(r.bottom() - style().defaultFrameWidth());
32 p->setPen(((QExtTab *)t)->color); 32 p->setPen(((QExtTab *)t)->color);
33 p->drawText(r, AlignCenter | ShowPrefix, t->label); 33 p->drawText(r, AlignCenter | ShowPrefix, t->label);
34} 34}
35 35
36IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) { 36IRCTabWidget::IRCTabWidget(QWidget *parent, const char *name) : QTabWidget(parent, name) {
37 setTabBar(new IRCTabBar(this, "tab control")); 37 setTabBar(new IRCTabBar(this, "tab control"));
38} 38}
39 39
40void IRCTabWidget::setTabColor(int index, QColor color) { 40void IRCTabWidget::setTabColor(int index, QColor color) {
41 ((IRCTabBar *)tabBar())->setTabColor(index, color); 41 ((IRCTabBar *)tabBar())->setTabColor(index, color);
42} 42}
43 43
44 44
45IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) { 45IRCHistoryLineEdit::IRCHistoryLineEdit(QWidget *parent, const char *name) : QLineEdit(parent, name) {
46 m_index = -1; 46 m_index = -1;
47 installEventFilter(this); 47 installEventFilter(this);
48} 48}
49 49
50void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) { 50void IRCHistoryLineEdit::keyPressEvent(QKeyEvent *event) {
51 int key = event->key(); 51 int key = event->key();
52 if (key == Key_Up) { 52 if (key == Key_Up) {
53 if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) { 53 if (m_history.count() > 0 && m_index < (signed int)m_history.count()-1) {
54 m_index++; 54 m_index++;
55 setText(m_history[m_index]); 55 setText(m_history[m_index]);
56 } 56 }
57 } else if (key == Key_Down) { 57 } else if (key == Key_Down) {
58 if (m_history.count() > 0 && m_index > 0) { 58 if (m_history.count() > 0 && m_index > 0) {
59 m_index--; 59 m_index--;
60 setText(m_history[m_index]); 60 setText(m_history[m_index]);
61 } 61 }
62 if (m_index == 0) { 62 if (m_index == 0) {
63 m_index = -1; 63 m_index = -1;
64 setText(""); 64 setText("");
65 } 65 }
66 } else if (key == Key_Return) { 66 } else if (key == Key_Return) {
67 m_history.prepend(text()); 67 m_history.prepend(text());
68 m_index = -1; 68 m_index = -1;
69 } else if (key == Key_Tab) { 69 } else if (key == Key_N && event->state() == Qt::ControlButton) {
70 odebug << "got tab" << oendl; 70 emit nextTab();
71 return;
72 } else if ( ( key == Key_Y || key == Key_Z ) && event->state() == Qt::ControlButton) {
73 emit closeTab();
74 return;
75 } else if (key == Key_P && event->state() == Qt::ControlButton) {
76 emit prevTab();
71 return; 77 return;
72 } 78 }
79
73 QLineEdit::keyPressEvent(event); 80 QLineEdit::keyPressEvent(event);
74} 81}
75 82
76bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) { 83bool IRCHistoryLineEdit::eventFilter(QObject *object, QEvent *event) {
77 if (event->type() == QEvent::KeyPress) { 84 if (event->type() == QEvent::KeyPress) {
78 QKeyEvent *k = (QKeyEvent *) event; 85 QKeyEvent *k = (QKeyEvent *) event;
79 /* Catch tab characters */ 86 /* Catch tab characters */
80 if (k->key() == Key_Tab) { 87 if (k->key() == Key_Tab) {
81 odebug << "tab!" << oendl; 88 emit nextTab();
82 return TRUE; 89 return TRUE;
83 } 90 }
84 } 91 }
85 return QLineEdit::eventFilter(object, event); 92 return QLineEdit::eventFilter(object, event);
86} 93}
94
95
96void IRCHistoryLineEdit::setEditFocus() {
97 setActiveWindow();
98 setFocus();
99}
diff --git a/noncore/net/opieirc/ircmisc.h b/noncore/net/opieirc/ircmisc.h
index b4a5b06..c42dcbd 100644
--- a/noncore/net/opieirc/ircmisc.h
+++ b/noncore/net/opieirc/ircmisc.h
@@ -16,56 +16,64 @@
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 __IRCMISC_H 21#ifndef __IRCMISC_H
22#define __IRCMISC_H 22#define __IRCMISC_H
23 23
24#include <qtabwidget.h> 24#include <qtabwidget.h>
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qtabbar.h> 26#include <qtabbar.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qcolor.h> 28#include <qcolor.h>
29#include <qarray.h> 29#include <qarray.h>
30 30
31/* Custom colored QTabWidget */ 31/* Custom colored QTabWidget */
32 32
33class QExtTab : public QTab { 33class QExtTab : public QTab {
34public: 34public:
35 QColor color; 35 QColor color;
36}; 36};
37 37
38class IRCTabWidget : public QTabWidget { 38class IRCTabWidget : public QTabWidget {
39 Q_OBJECT 39 Q_OBJECT
40public: 40public:
41 IRCTabWidget(QWidget *parent = 0, const char *name = 0); 41 IRCTabWidget(QWidget *parent = 0, const char *name = 0);
42 void setTabColor(int index, QColor color); 42 void setTabColor(int index, QColor color);
43}; 43};
44 44
45class IRCTabBar : public QTabBar { 45class IRCTabBar : public QTabBar {
46 Q_OBJECT 46 Q_OBJECT
47public: 47public:
48 IRCTabBar(QWidget *parent = 0, const char *name = 0); 48 IRCTabBar(QWidget *parent = 0, const char *name = 0);
49 void setTabColor(int index, QColor color); 49 void setTabColor(int index, QColor color);
50protected: 50protected:
51 void paintLabel(QPainter*, const QRect&, QTab*, bool) const; 51 void paintLabel(QPainter*, const QRect&, QTab*, bool) const;
52 int insertTab(QTab *, int index = -1); 52 int insertTab(QTab *, int index = -1);
53protected: 53protected:
54 QArray<QColor> m_colors; 54 QArray<QColor> m_colors;
55}; 55};
56 56
57/* A QLineEdit with history functionality and tab completion */ 57/* A QLineEdit with history functionality and tab completion */
58 58
59class IRCHistoryLineEdit : public QLineEdit { 59class IRCHistoryLineEdit : public QLineEdit {
60 Q_OBJECT 60 Q_OBJECT
61public: 61public:
62 IRCHistoryLineEdit(QWidget *parent = 0, const char *name = 0); 62 IRCHistoryLineEdit(QWidget *parent = 0, const char *name = 0);
63 virtual bool eventFilter(QObject *object, QEvent *event); 63 virtual bool eventFilter(QObject *object, QEvent *event);
64public slots:
65 void setEditFocus();
66signals:
67 void nextTab();
68 void prevTab();
69 void closeTab();
70
71
64protected: 72protected:
65 void keyPressEvent(QKeyEvent *); 73 void keyPressEvent(QKeyEvent *);
66protected: 74protected:
67 QStringList m_history; 75 QStringList m_history;
68 int m_index; 76 int m_index;
69}; 77};
70 78
71#endif /* __IRCMISC_H */ 79#endif /* __IRCMISC_H */
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp
index a113b04..1fddc6d 100644
--- a/noncore/net/opieirc/ircquerytab.cpp
+++ b/noncore/net/opieirc/ircquerytab.cpp
@@ -1,94 +1,103 @@
1#include <qhbox.h> 1#include <qhbox.h>
2#include <qwhatsthis.h> 2#include <qwhatsthis.h>
3#include "ircquerytab.h" 3#include "ircquerytab.h"
4#include "ircservertab.h" 4#include "ircservertab.h"
5 5
6IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 6IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
7 m_mainWindow = mainWindow; 7 m_mainWindow = mainWindow;
8 m_parentTab = parentTab; 8 m_parentTab = parentTab;
9 m_lines = 0; 9 m_lines = 0;
10 m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ 10 m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */
11 m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); 11 m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>");
12 QHBox *hbox = new QHBox(this); 12 QHBox *hbox = new QHBox(this);
13 m_textview = new QTextView(hbox); 13 m_textview = new QTextView(hbox);
14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_textview->setTextFormat(RichText); 16 m_textview->setTextFormat(RichText);
17 QWhatsThis::add(m_textview, tr("Private discussion")); 17 QWhatsThis::add(m_textview, tr("Private discussion"));
18 m_field = new IRCHistoryLineEdit(this); 18 m_field = new IRCHistoryLineEdit(this);
19 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
20 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
21 connect(m_field, SIGNAL(closeTab()),this, SIGNAL(closeTab()));
22
23
19 QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person")); 24 QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person"));
20 m_layout->add(hbox); 25 m_layout->add(hbox);
21 hbox->show(); 26 hbox->show();
22 m_layout->add(m_field); 27 m_layout->add(m_field);
23 m_field->setFocus(); 28 m_field->setFocus();
24 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 29 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
25 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 30 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
26 settingsChanged(); 31 settingsChanged();
27} 32}
28 33
29void IRCQueryTab::scrolling(){ 34void IRCQueryTab::scrolling(){
30 m_textview->ensureVisible(0, m_textview->contentsHeight()); 35 m_textview->ensureVisible(0, m_textview->contentsHeight());
31} 36}
32 37
33 38
34void IRCQueryTab::appendText(QString text) { 39void IRCQueryTab::appendText(QString text) {
35 /* not using append because it creates layout problems */ 40 /* not using append because it creates layout problems */
36 QString txt = m_textview->text() + text + "\n"; 41 QString txt = m_textview->text() + text + "\n";
37 if (m_maxLines > 0 && m_lines >= m_maxLines) { 42 if (m_maxLines > 0 && m_lines >= m_maxLines) {
38 int firstBreak = txt.find('\n'); 43 int firstBreak = txt.find('\n');
39 if (firstBreak != -1) { 44 if (firstBreak != -1) {
40 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 45 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
41 } 46 }
42 } else { 47 } else {
43 m_lines++; 48 m_lines++;
44 } 49 }
45 m_textview->setText(txt); 50 m_textview->setText(txt);
46 m_textview->ensureVisible(0, m_textview->contentsHeight()); 51 m_textview->ensureVisible(0, m_textview->contentsHeight());
52
53 if ( IRCServerTab::containsPing( text, m_parentTab ) )
54 emit ping( title() );
55
47 emit changed(this); 56 emit changed(this);
48} 57}
49 58
50IRCQueryTab::~IRCQueryTab() { 59IRCQueryTab::~IRCQueryTab() {
51 m_parentTab->removeQueryTab(this); 60 m_parentTab->removeQueryTab(this);
52 delete m_person; 61 delete m_person;
53} 62}
54 63
55void IRCQueryTab::processCommand() { 64void IRCQueryTab::processCommand() {
56 QString text = m_field->text(); 65 QString text = m_field->text();
57 if (text.length()>0) { 66 if (text.length()>0) {
58 if (session()->isSessionActive()) { 67 if (session()->isSessionActive()) {
59 if (text.startsWith("/") && !text.startsWith("//")) { 68 if (text.startsWith("/") && !text.startsWith("//")) {
60 /* Command mode */ 69 /* Command mode */
61 m_parentTab->executeCommand(this, text);; 70 m_parentTab->executeCommand(this, text);;
62 } else { 71 } else {
63 if (text.startsWith("//")) 72 if (text.startsWith("//"))
64 text = text.right(text.length()-1); 73 text = text.right(text.length()-1);
65 session()->sendMessage(m_person, m_field->text()); 74 session()->sendMessage(m_person, m_field->text());
66 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>"); 75 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
67 } 76 }
68 } else { 77 } else {
69 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 78 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
70 } 79 }
71 } 80 }
72 m_field->clear(); 81 m_field->clear();
73} 82}
74 83
75void IRCQueryTab::display(IRCOutput output) { 84void IRCQueryTab::display(IRCOutput output) {
76 if (output.type() == OUTPUT_QUERYPRIVMSG) { 85 if (output.type() == OUTPUT_QUERYPRIVMSG) {
77 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage() + "</font><br>"); 86 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage() + "</font><br>");
78 } else if (output.type() == OUTPUT_QUERYACTION) { 87 } else if (output.type() == OUTPUT_QUERYACTION) {
79 appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>"); 88 appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>");
80 } 89 }
81} 90}
82 91
83void IRCQueryTab::settingsChanged() { 92void IRCQueryTab::settingsChanged() {
84 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 93 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
85 m_lines = 0; 94 m_lines = 0;
86} 95}
87 96
88QString IRCQueryTab::title() { 97QString IRCQueryTab::title() {
89 return m_person->nick(); 98 return m_person->nick();
90} 99}
91 100
92IRCSession *IRCQueryTab::session() { 101IRCSession *IRCQueryTab::session() {
93 return m_parentTab->session(); 102 return m_parentTab->session();
94} 103}
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index d1aab40..2a34c0b 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,66 +1,77 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include <qwhatsthis.h> 2#include <qwhatsthis.h>
3#include "ircservertab.h" 3#include "ircservertab.h"
4 4
5
6bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) {
7 return (text.find("ping") != -1 && text.find( tab->server()->nick() != -1));
8}
9
10
5IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 11IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_server = server; 12 m_server = server;
7 m_session = new IRCSession(&m_server); 13 m_session = new IRCSession(&m_server);
8 m_mainWindow = mainWindow; 14 m_mainWindow = mainWindow;
9 m_close = FALSE; 15 m_close = FALSE;
10 m_lines = 0; 16 m_lines = 0;
11 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); 17 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
12 m_textview = new QTextView(this); 18 m_textview = new QTextView(this);
13 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 19 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
14 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 20 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
15 m_textview->setTextFormat(RichText); 21 m_textview->setTextFormat(RichText);
16 QWhatsThis::add(m_textview, tr("Server messages")); 22 QWhatsThis::add(m_textview, tr("Server messages"));
17 m_layout->add(m_textview); 23 m_layout->add(m_textview);
18 m_field = new IRCHistoryLineEdit(this); 24 m_field = new IRCHistoryLineEdit(this);
25 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
26 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
27 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab()));
28 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
29
19 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); 30 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
20 m_layout->add(m_field); 31 m_layout->add(m_field);
21 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 32 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
22 m_field->setFocus(); 33 m_field->setFocus();
23 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 34 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
24 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 35 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
25 settingsChanged(); 36 settingsChanged();
26} 37}
27 38
28void IRCServerTab::scrolling(){ 39void IRCServerTab::scrolling(){
29 m_textview->ensureVisible(0, m_textview->contentsHeight()); 40 m_textview->ensureVisible(0, m_textview->contentsHeight());
30} 41}
31 42
32 43
33void IRCServerTab::appendText(QString text) { 44void IRCServerTab::appendText(QString text) {
34 /* not using append because it creates layout problems */ 45 /* not using append because it creates layout problems */
35 QString txt = m_textview->text() + text + "\n"; 46 QString txt = m_textview->text() + text + "\n";
36 if (m_maxLines > 0 && m_lines >= m_maxLines) { 47 if (m_maxLines > 0 && m_lines >= m_maxLines) {
37 int firstBreak = txt.find('\n'); 48 int firstBreak = txt.find('\n');
38 if (firstBreak != -1) { 49 if (firstBreak != -1) {
39 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 50 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
40 } 51 }
41 } else { 52 } else {
42 m_lines++; 53 m_lines++;
43 } 54 }
44 m_textview->setText(txt); 55 m_textview->setText(txt);
45 m_textview->ensureVisible(0, m_textview->contentsHeight()); 56 m_textview->ensureVisible(0, m_textview->contentsHeight());
46 emit changed(this); 57 emit changed(this);
47} 58}
48 59
49IRCServerTab::~IRCServerTab() { 60IRCServerTab::~IRCServerTab() {
50 delete m_session; 61 delete m_session;
51} 62}
52 63
53void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 64void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
54 m_channelTabs.remove(tab); 65 m_channelTabs.remove(tab);
55} 66}
56 67
57void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { 68void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
58 m_queryTabs.remove(tab); 69 m_queryTabs.remove(tab);
59} 70}
60 71
61void IRCServerTab::addQueryTab(IRCQueryTab *tab) { 72void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
62 m_queryTabs.append(tab); 73 m_queryTabs.append(tab);
63} 74}
64 75
65QString IRCServerTab::title() { 76QString IRCServerTab::title() {
66 return "Server"; 77 return "Server";
@@ -76,104 +87,104 @@ QString *IRCServerTab::mynick() {
76 87
77IRCServer *IRCServerTab::server() { 88IRCServer *IRCServerTab::server() {
78 return &m_server; 89 return &m_server;
79} 90}
80 91
81void IRCServerTab::settingsChanged() { 92void IRCServerTab::settingsChanged() {
82 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 93 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
83 m_lines = 0; 94 m_lines = 0;
84} 95}
85 96
86void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 97void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
87 QTextIStream stream(&line); 98 QTextIStream stream(&line);
88 QString command; 99 QString command;
89 stream >> command; 100 stream >> command;
90 command = command.upper().right(command.length()-1); 101 command = command.upper().right(command.length()-1);
91 102
92 //JOIN 103 //JOIN
93 if (command == "JOIN" || command == "J") { 104 if (command == "JOIN" || command == "J") {
94 QString channel; 105 QString channel;
95 stream >> channel; 106 stream >> channel;
96 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { 107 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) {
97 m_session->join(channel); 108 m_session->join(channel);
98 } else { 109 } else {
99 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); 110 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
100 } 111 }
101 } 112 }
102 113
103 //KICK 114 //KICK
104 else if (command == "KICK"){ 115 else if (command == "KICK"){
105 QString nickname; 116 QString nickname;
106 stream >> nickname; 117 stream >> nickname;
107 if (nickname.length() > 0) { 118 if (nickname.length() > 0) {
108 if (line.length() > 7 + nickname.length()) { 119 if (line.length() > 7 + nickname.length()) {
109 QString text = line.right(line.length()-nickname.length()-7); 120 QString text = line.right(line.length()-nickname.length()-7);
110 IRCPerson person; 121 IRCPerson person;
111 person.setNick(nickname); 122 person.setNick(nickname);
112 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text); 123 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
113 } else { 124 } else {
114 IRCPerson person; 125 IRCPerson person;
115 person.setNick(nickname); 126 person.setNick(nickname);
116 m_session->kick(((IRCChannelTab *)tab)->channel(), &person); 127 m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
117 } 128 }
118 } 129 }
119 } 130 }
120 131
121 else if (command == "OP"){ 132 else if (command == "OP"){
122 QString nickname; 133 QString nickname;
123 stream >> nickname; 134 stream >> nickname;
124 if (nickname.length() > 0) { 135 if (nickname.length() > 0) {
125 QString text = line.right(line.length()-nickname.length()-5); 136 QString text = line.right(line.length()-nickname.length()-5);
126 IRCPerson person; 137 IRCPerson person;
127 person.setNick(nickname); 138 person.setNick(nickname);
128 m_session->op(((IRCChannelTab *)tab)->channel(), &person); 139 m_session->op(((IRCChannelTab *)tab)->channel(), &person);
129 } 140 }
130 } 141 }
131 142
132 //SEND MODES 143 //SEND MODES
133 else if (command == "MODE"){ 144 else if (command == "MODE"){
134 QString text = line.right(line.length()-6); 145 QString text = line.right(line.length()-6);
135 if (text.length() > 0) { 146 if (text.length() > 0) {
136 m_session->mode(text); 147 m_session->mode(text);
137 } else { 148 } else {
138 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>"); 149 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>");
139 } 150 }
140 } 151 }
141 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want 152 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want
142 else if (command == "RAW"){ 153 else if (command == "RAW"){
143 QString text = line.right(line.length()-5); 154 QString text = line.right(line.length()-5);
144 if (text.length() > 0) { 155 if (text.length() > 0) {
145 m_session->raw(text); 156 m_session->raw(text);
146 } 157 }
147 } 158 }
148 else if (command == "SUSPEND"){ 159 else if (command == "SUSPEND"){
149 QString text = line.right(line.length()-9); 160 QString text = line.right(line.length()-9);
150 if (text.upper() == "ON") { 161 if (text.upper() == "ON") {
151 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 162 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
152 } 163 }
153 else if (text.upper() == "OFF"){ 164 else if (text.upper() == "OFF"){
154 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 165 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
155 } else { 166 } else {
156 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text); 167 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text);
157 } 168 }
158 } 169 }
159 170
160 else if (command == "QUIT"){ 171 else if (command == "QUIT"){
161 QString text = line.right(line.length()-6); 172 QString text = line.right(line.length()-6);
162 if (text.length() > 0) { 173 if (text.length() > 0) {
163 m_session->quit(text); 174 m_session->quit(text);
164 } else { 175 } else {
165 m_session->quit(); 176 m_session->quit();
166 } 177 }
167 } 178 }
168 179
169 //SEND ACTION 180 //SEND ACTION
170 else if (command == "ME") { 181 else if (command == "ME") {
171 QString text = line.right(line.length()-4); 182 QString text = line.right(line.length()-4);
172 if (text.length() > 0) { 183 if (text.length() > 0) {
173 if (tab->isA("IRCChannelTab")) { 184 if (tab->isA("IRCChannelTab")) {
174 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 185 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
175 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); 186 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
176 } else if (tab->isA("IRCQueryTab")) { 187 } else if (tab->isA("IRCQueryTab")) {
177 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 188 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
178 m_session->sendAction(((IRCQueryTab *)tab)->person(), text); 189 m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
179 } else { 190 } else {
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h
index 48200d7..69543fc 100644
--- a/noncore/net/opieirc/ircservertab.h
+++ b/noncore/net/opieirc/ircservertab.h
@@ -1,79 +1,81 @@
1/* 1/*
2 OpieIRC - An embedded IRC client 2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob 3 Copyright (C) 2002 Wenzel Jakob
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
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 __IRCSERVERTAB_H 21#ifndef __IRCSERVERTAB_H
22#define __IRCSERVERTAB_H 22#define __IRCSERVERTAB_H
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include "irctab.h" 25#include "irctab.h"
26#include "ircsession.h" 26#include "ircsession.h"
27#include "mainwindow.h" 27#include "mainwindow.h"
28#include "ircchanneltab.h" 28#include "ircchanneltab.h"
29#include "ircquerytab.h" 29#include "ircquerytab.h"
30#include "ircmisc.h" 30#include "ircmisc.h"
31 31
32 32
33class IRCServerTab : public IRCTab { 33class IRCServerTab : public IRCTab {
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 static bool containsPing(const QString& text, IRCServerTab *tab);
37
36 /* IRCTab implementation */ 38 /* IRCTab implementation */
37 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 39 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
38 ~IRCServerTab(); 40 ~IRCServerTab();
39 QString title(); 41 QString title();
40 IRCSession *session(); 42 IRCSession *session();
41 IRCServer *server(); 43 IRCServer *server();
42 44
43 /* Start the server session */ 45 /* Start the server session */
44 void doConnect(); 46 void doConnect();
45// QString *mynick(); 47// QString *mynick();
46 /* Remove tabs from the internal tab lists */ 48 /* Remove tabs from the internal tab lists */
47 void removeChannelTab(IRCChannelTab *tab); 49 void removeChannelTab(IRCChannelTab *tab);
48 void removeQueryTab(IRCQueryTab *tab); 50 void removeQueryTab(IRCQueryTab *tab);
49 /* Return tabs from the internal tab lists */ 51 /* Return tabs from the internal tab lists */
50 IRCChannelTab *getTabForChannel(IRCChannel *channel); 52 IRCChannelTab *getTabForChannel(IRCChannel *channel);
51 IRCQueryTab *getTabForQuery(IRCPerson *person); 53 IRCQueryTab *getTabForQuery(IRCPerson *person);
52 /* Add tabs to the internal tab lists */ 54 /* Add tabs to the internal tab lists */
53 void addQueryTab(IRCQueryTab *tab); 55 void addQueryTab(IRCQueryTab *tab);
54 /* Execute a user command such as /join, /msg etc */ 56 /* Execute a user command such as /join, /msg etc */
55 void executeCommand(IRCTab *tab, QString line); 57 void executeCommand(IRCTab *tab, QString line);
56protected: 58protected:
57 void appendText(QString text); 59 void appendText(QString text);
58public slots: 60public slots:
59 void scrolling(); 61 void scrolling();
60 void remove(); 62 void remove();
61 void processCommand(); 63 void processCommand();
62 void settingsChanged(); 64 void settingsChanged();
63protected slots: 65protected slots:
64 void display(IRCOutput output); 66 void display(IRCOutput output);
65protected: 67protected:
66 int m_lines; 68 int m_lines;
67 bool m_close; 69 bool m_close;
68 IRCServer m_server; 70 IRCServer m_server;
69 IRCSession *m_session; 71 IRCSession *m_session;
70 MainWindow *m_mainWindow; 72 MainWindow *m_mainWindow;
71 QTextView *m_textview; 73 QTextView *m_textview;
72 IRCHistoryLineEdit *m_field; 74 IRCHistoryLineEdit *m_field;
73 /* Channel tabs associated with this server tab */ 75 /* Channel tabs associated with this server tab */
74 QList<IRCChannelTab> m_channelTabs; 76 QList<IRCChannelTab> m_channelTabs;
75 /* Query tabs associated with this server tab */ 77 /* Query tabs associated with this server tab */
76 QList<IRCQueryTab> m_queryTabs; 78 QList<IRCQueryTab> m_queryTabs;
77}; 79};
78 80
79#endif /* __IRCSERVERTAB_H */ 81#endif /* __IRCSERVERTAB_H */
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp
index 3351c3b..8e1dc16 100644
--- a/noncore/net/opieirc/irctab.cpp
+++ b/noncore/net/opieirc/irctab.cpp
@@ -1,38 +1,45 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3#include <qwhatsthis.h> 3#include <qwhatsthis.h>
4#include "irctab.h" 4#include "irctab.h"
5#include "mainwindow.h"
5 6
6QString IRCTab::m_errorColor; 7QString IRCTab::m_errorColor;
7QString IRCTab::m_serverColor; 8QString IRCTab::m_serverColor;
8QString IRCTab::m_textColor; 9QString IRCTab::m_textColor;
9QString IRCTab::m_backgroundColor; 10QString IRCTab::m_backgroundColor;
10QString IRCTab::m_selfColor; 11QString IRCTab::m_selfColor;
11QString IRCTab::m_otherColor; 12QString IRCTab::m_otherColor;
12QString IRCTab::m_notificationColor; 13QString IRCTab::m_notificationColor;
13int IRCTab::m_maxLines; 14int IRCTab::m_maxLines;
14 15
15IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { 16IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) {
16 m_layout = new QVBoxLayout(this); 17 m_layout = new QVBoxLayout(this);
17 QHBoxLayout *descLayout = new QHBoxLayout(m_layout); 18 QHBoxLayout *descLayout = new QHBoxLayout(m_layout);
18 descLayout->setMargin(5); 19 descLayout->setMargin(5);
19 m_description = new QLabel(tr("Missing description"), this); 20 m_description = new QLabel(tr("Missing description"), this);
20 QWhatsThis::add(m_description, tr("Description of the tab's content")); 21 QWhatsThis::add(m_description, tr("Description of the tab's content"));
21 descLayout->addWidget(m_description); 22 descLayout->addWidget(m_description);
22 descLayout->setStretchFactor(m_description, 5); 23 descLayout->setStretchFactor(m_description, 5);
23 QPushButton *close = new QPushButton(this); 24 QPushButton *close = new QPushButton(this);
24 QWhatsThis::add(close, tr("Close this tab")); 25 QWhatsThis::add(close, tr("Close this tab"));
25 close->setPixmap(Resource::loadPixmap("close")); 26 close->setPixmap(Resource::loadPixmap("close"));
26 connect(close, SIGNAL(clicked()), this, SLOT(remove())); 27 connect(close, SIGNAL(clicked()), this, SLOT(remove()));
27 descLayout->addWidget(close); 28 descLayout->addWidget(close);
28 descLayout->setStretchFactor(m_description, 1); 29 descLayout->setStretchFactor(m_description, 1);
29} 30}
30 31
31 32
32void IRCTab::setID(int id) { 33void IRCTab::setID(int id) {
33 m_id = id; 34 m_id = id;
34} 35}
35 36
36int IRCTab::id() { 37int IRCTab::id() {
37 return m_id; 38 return m_id;
38} 39}
40
41void IRCTab::showEvent( QShowEvent *ev ) {
42 topLevelWidget()->setCaption( MainWindow::appCaption() + " " + title() );
43 QWidget::showEvent( ev );
44 emit editFocus();
45}
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h
index 7a2d0a2..6c29ea5 100644
--- a/noncore/net/opieirc/irctab.h
+++ b/noncore/net/opieirc/irctab.h
@@ -1,66 +1,76 @@
1/* 1/*
2 OpieIRC - An embedded IRC client 2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob 3 Copyright (C) 2002 Wenzel Jakob
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
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 __IRCTAB_H 21#ifndef __IRCTAB_H
22#define __IRCTAB_H 22#define __IRCTAB_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qtextview.h> 25#include <qtextview.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include "ircsession.h" 29#include "ircsession.h"
30 30
31/* This is the base class for any tabs which need to be integrated into 31/* This is the base class for any tabs which need to be integrated into
32 the main GUI tab widget */ 32 the main GUI tab widget */
33 33
34class IRCTab : public QWidget { 34class IRCTab : public QWidget {
35 Q_OBJECT 35 Q_OBJECT
36public: 36public:
37 IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 37 IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
38 /* The ID is required to store the position of this IRCTab inside the IRCTabWidget */ 38 /* The ID is required to store the position of this IRCTab inside the IRCTabWidget */
39 void setID(int id); 39 void setID(int id);
40 int id(); 40 int id();
41 virtual QString title() = 0; 41 virtual QString title() = 0;
42 virtual IRCSession *session() = 0; 42 virtual IRCSession *session() = 0;
43 virtual void appendText(QString text) = 0; 43 virtual void appendText(QString text) = 0;
44signals: 44signals:
45 void changed(IRCTab *); 45 void changed(IRCTab *);
46 void ping(const QString& );
47 void nextTab();
48 void prevTab();
49 void closeTab();
50 void editFocus();
51
46public slots: 52public slots:
47 virtual void remove() = 0; 53 virtual void remove() = 0;
48 virtual void settingsChanged() = 0; 54 virtual void settingsChanged() = 0;
55
56protected:
57 void showEvent( QShowEvent* );
58
49protected: 59protected:
50 QLabel *m_description; 60 QLabel *m_description;
51 QVBoxLayout *m_layout; 61 QVBoxLayout *m_layout;
52 int m_id; 62 int m_id;
53public: 63public:
54 /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */ 64 /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */
55 static QString m_errorColor; 65 static QString m_errorColor;
56 static QString m_serverColor; 66 static QString m_serverColor;
57 static QString m_textColor; 67 static QString m_textColor;
58 static QString m_backgroundColor; 68 static QString m_backgroundColor;
59 static QString m_selfColor; 69 static QString m_selfColor;
60 static QString m_otherColor; 70 static QString m_otherColor;
61 static QString m_notificationColor; 71 static QString m_notificationColor;
62 /* Max number of lines to be displayed */ 72 /* Max number of lines to be displayed */
63 static int m_maxLines; 73 static int m_maxLines;
64}; 74};
65 75
66#endif /* __IRCTAB_H */ 76#endif /* __IRCTAB_H */
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp
index 0923a11..1143213 100644
--- a/noncore/net/opieirc/mainwindow.cpp
+++ b/noncore/net/opieirc/mainwindow.cpp
@@ -1,91 +1,128 @@
1#include <qmenubar.h> 1#include <qmenubar.h>
2#include <qpe/resource.h> 2#include <qpe/resource.h>
3#include <qwhatsthis.h> 3#include <qwhatsthis.h>
4 4
5#include "mainwindow.h" 5#include "mainwindow.h"
6#include "ircservertab.h" 6#include "ircservertab.h"
7#include "ircserverlist.h" 7#include "ircserverlist.h"
8#include "ircsettings.h" 8#include "ircsettings.h"
9 9
10QString MainWindow::appCaption() {
11 return QObject::tr("Opie IRC");
12}
13
14
10MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 15MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
11 setCaption(tr("IRC Client")); 16 setCaption(tr("IRC Client"));
12 m_tabWidget = new IRCTabWidget(this); 17 m_tabWidget = new IRCTabWidget(this);
13 QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); 18 QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here"));
14 connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*))); 19 connect(m_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(selected(QWidget*)));
15 setCentralWidget(m_tabWidget); 20 setCentralWidget(m_tabWidget);
16 setToolBarsMovable(FALSE); 21 setToolBarsMovable(FALSE);
17 QMenuBar *menuBar = new QMenuBar(this); 22 QMenuBar *menuBar = new QMenuBar(this);
18 QPopupMenu *irc = new QPopupMenu(this); 23 QPopupMenu *irc = new QPopupMenu(this);
19 menuBar->insertItem(tr("IRC"), irc); 24 menuBar->insertItem(tr("IRC"), irc);
20 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); 25 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0);
21 connect(a, SIGNAL(activated()), this, SLOT(newConnection())); 26 connect(a, SIGNAL(activated()), this, SLOT(newConnection()));
22 a->setWhatsThis(tr("Create a new connection to an IRC server")); 27 a->setWhatsThis(tr("Create a new connection to an IRC server"));
23 a->addTo(irc); 28 a->addTo(irc);
24 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); 29 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0);
25 a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); 30 a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance"));
26 connect(a, SIGNAL(activated()), this, SLOT(settings())); 31 connect(a, SIGNAL(activated()), this, SLOT(settings()));
27 a->addTo(irc); 32 a->addTo(irc);
28 loadSettings(); 33 loadSettings();
29} 34}
30 35
31/*IRCTabWidget MainWindow::getTabWidget(){ 36/*IRCTabWidget MainWindow::getTabWidget(){
32 return m_tabWidget; 37 return m_tabWidget;
33} */ 38} */
34 39
35void MainWindow::loadSettings() { 40void MainWindow::loadSettings() {
36 Config config("OpieIRC"); 41 Config config("OpieIRC");
37 config.setGroup("OpieIRC"); 42 config.setGroup("OpieIRC");
38 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); 43 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF");
39 IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); 44 IRCTab::m_textColor = config.readEntry("TextColor", "#000000");
40 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); 45 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000");
41 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); 46 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000");
42 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); 47 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB");
43 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); 48 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
44 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); 49 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
45 IRCTab::m_maxLines = config.readNumEntry("Lines", 100); 50 IRCTab::m_maxLines = config.readNumEntry("Lines", 100);
46} 51}
47 52
48void MainWindow::selected(QWidget *) { 53void MainWindow::selected(QWidget *) {
49 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); 54 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black);
50 emit updateScroll(); 55 emit updateScroll();
51} 56}
52 57
53void MainWindow::addTab(IRCTab *tab) { 58void MainWindow::addTab(IRCTab *tab) {
54 connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*))); 59 connect(tab, SIGNAL(changed(IRCTab*)), this, SLOT(changeEvent(IRCTab*)));
60 connect(tab, SIGNAL(ping (const QString&)), this, SLOT(slotPing(const QString&)));
61 connect(tab, SIGNAL(nextTab()), this, SLOT(slotNextTab()));
62 connect(tab, SIGNAL(prevTab()), this, SLOT(slotPrevTab()));
63 connect(tab, SIGNAL(closeTab()), this, SLOT(slotCloseTab()));
64
55 m_tabWidget->addTab(tab, tab->title()); 65 m_tabWidget->addTab(tab, tab->title());
56 m_tabWidget->showPage(tab); 66 m_tabWidget->showPage(tab);
57 tab->setID(m_tabWidget->currentPageIndex()); 67 tab->setID(m_tabWidget->currentPageIndex());
58 m_tabs.append(tab); 68 m_tabs.append(tab);
59} 69}
60 70
61void MainWindow::changeEvent(IRCTab *tab) { 71void MainWindow::changeEvent(IRCTab *tab) {
62 if (tab->id() != m_tabWidget->currentPageIndex()) 72 if (tab->id() != m_tabWidget->currentPageIndex())
63 m_tabWidget->setTabColor(tab->id(), blue); 73 m_tabWidget->setTabColor(tab->id(), blue);
64} 74}
65 75
66void MainWindow::killTab(IRCTab *tab) { 76void MainWindow::killTab(IRCTab *tab) {
67 m_tabWidget->removePage(tab); 77 m_tabWidget->removePage(tab);
68 m_tabs.remove(tab); 78 m_tabs.remove(tab);
69 /* there might be nicer ways to do this .. */ 79 /* there might be nicer ways to do this .. */
70 delete tab; 80 delete tab;
71} 81}
72 82
73void MainWindow::newConnection() { 83void MainWindow::newConnection() {
74 IRCServerList list(this, "ServerList", TRUE); 84 IRCServerList list(this, "ServerList", TRUE);
75 if (list.exec() == QDialog::Accepted && list.hasServer()) { 85 if (list.exec() == QDialog::Accepted && list.hasServer()) {
76 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); 86 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget);
77 addTab(serverTab); 87 addTab(serverTab);
78 serverTab->doConnect(); 88 serverTab->doConnect();
79 } 89 }
80} 90}
81 91
82void MainWindow::settings() { 92void MainWindow::settings() {
83 IRCSettings settings(this, "Settings", TRUE); 93 IRCSettings settings(this, "Settings", TRUE);
84 if (settings.exec() == QDialog::Accepted) { 94 if (settings.exec() == QDialog::Accepted) {
85 QListIterator<IRCTab> it(m_tabs); 95 QListIterator<IRCTab> it(m_tabs);
86 for (; it.current(); ++it) { 96 for (; it.current(); ++it) {
87 /* Inform all tabs about the new settings */ 97 /* Inform all tabs about the new settings */
88 it.current()->settingsChanged(); 98 it.current()->settingsChanged();
89 } 99 }
90 } 100 }
91} 101}
102
103
104void MainWindow::slotNextTab() {
105 int i = m_tabWidget->currentPageIndex ();
106 m_tabWidget->setCurrentPage ( i+1 );
107
108 int j = m_tabWidget->currentPageIndex ();
109 if ( i == j )
110 m_tabWidget->setCurrentPage ( 1 );
111}
112
113void MainWindow::slotPrevTab() {
114 int i = m_tabWidget->currentPageIndex ();
115 if ( i > 1 )
116 m_tabWidget->setCurrentPage ( i-1 );
117}
118
119void MainWindow::slotCloseTab() {
120 IRCTab *tab = (IRCTab *) m_tabWidget->currentPage ();
121 if ( tab )
122 killTab ( tab );
123}
124
125void MainWindow::slotPing( const QString& channel ) {
126 raise();
127}
128
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h
index 0f60855..945fc71 100644
--- a/noncore/net/opieirc/mainwindow.h
+++ b/noncore/net/opieirc/mainwindow.h
@@ -1,53 +1,60 @@
1/* 1/*
2 OpieIRC - An embedded IRC client 2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob 3 Copyright (C) 2002 Wenzel Jakob
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
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 __MAINWINDOW_H 21#ifndef __MAINWINDOW_H
22#define __MAINWINDOW_H 22#define __MAINWINDOW_H
23 23
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qaction.h> 25#include <qaction.h>
26#include <qlist.h> 26#include <qlist.h>
27#include "mainwindow.h" 27#include "mainwindow.h"
28#include "ircmisc.h" 28#include "ircmisc.h"
29#include "irctab.h" 29#include "irctab.h"
30 30
31class MainWindow : public QMainWindow { 31class MainWindow : public QMainWindow {
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
35// IRCTabWidget getTabWidget(); 35// IRCTabWidget getTabWidget();
36 void addTab(IRCTab *tab); 36 void addTab(IRCTab *tab);
37 void killTab(IRCTab *tab); 37 void killTab(IRCTab *tab);
38 static QString appName() { return QString::fromLatin1("opieirc"); } 38 static QString appName() { return QString::fromLatin1("opieirc"); }
39 static QString appCaption();
39signals: 40signals:
40 void updateScroll(); 41 void updateScroll();
41protected slots: 42protected slots:
42 void newConnection(); 43 void newConnection();
43 void settings(); 44 void settings();
44 void selected(QWidget *); 45 void selected(QWidget *);
45 void changeEvent(IRCTab *); 46 void changeEvent(IRCTab *);
47
48 void slotNextTab();
49 void slotPrevTab();
50 void slotCloseTab();
51 void slotPing(const QString&);
52
46protected: 53protected:
47 void loadSettings(); 54 void loadSettings();
48protected: 55protected:
49 IRCTabWidget *m_tabWidget; 56 IRCTabWidget *m_tabWidget;
50 QList<IRCTab> m_tabs; 57 QList<IRCTab> m_tabs;
51}; 58};
52 59
53#endif /* __MAINWINDOW_H */ 60#endif /* __MAINWINDOW_H */