author | wazlaf <wazlaf> | 2002-09-23 22:12:39 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-23 22:12:39 (UTC) |
commit | 074769a4adb816153e47d63087e9e326bd3a04bf (patch) (unidiff) | |
tree | cc69651d9e9e5901696a55d9523e343125780705 | |
parent | e0b04701b3c9182ba22f56e329f98c57af4e1fe2 (diff) | |
download | opie-074769a4adb816153e47d63087e9e326bd3a04bf.zip opie-074769a4adb816153e47d63087e9e326bd3a04bf.tar.gz opie-074769a4adb816153e47d63087e9e326bd3a04bf.tar.bz2 |
configuration dialog + color configurability throughout the program + popup menu on the channel person list
-rw-r--r-- | noncore/net/opieirc/ircchannel.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 58 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.h | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.cpp | 31 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmisc.h | 44 | ||||
-rw-r--r-- | noncore/net/opieirc/ircperson.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 14 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.h | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservereditor.cpp | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.cpp | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 43 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.h | 11 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.cpp | 71 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.h | 46 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.cpp | 9 | ||||
-rw-r--r-- | noncore/net/opieirc/irctab.h | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/ircversion.h | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 40 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.h | 7 | ||||
-rw-r--r-- | noncore/net/opieirc/opieirc.pro | 6 |
21 files changed, 357 insertions, 53 deletions
diff --git a/noncore/net/opieirc/ircchannel.cpp b/noncore/net/opieirc/ircchannel.cpp index 9814a26..5c380e5 100644 --- a/noncore/net/opieirc/ircchannel.cpp +++ b/noncore/net/opieirc/ircchannel.cpp | |||
@@ -1,48 +1,47 @@ | |||
1 | #include "ircchannel.h" | 1 | #include "ircchannel.h" |
2 | #include <stdio.h> | ||
3 | 2 | ||
4 | IRCChannel::IRCChannel(QString channelname) { | 3 | IRCChannel::IRCChannel(QString channelname) { |
5 | m_hasPeople = FALSE; | 4 | m_hasPeople = FALSE; |
6 | m_channelname = channelname; | 5 | m_channelname = channelname; |
7 | } | 6 | } |
8 | 7 | ||
9 | IRCChannel::~IRCChannel() { | 8 | IRCChannel::~IRCChannel() { |
10 | /* We want this to get deleted */ | 9 | /* We want this to get deleted */ |
11 | m_people.setAutoDelete(TRUE); | 10 | m_people.setAutoDelete(TRUE); |
12 | } | 11 | } |
13 | 12 | ||
14 | QString IRCChannel::channelname() { | 13 | QString IRCChannel::channelname() { |
15 | return m_channelname; | 14 | return m_channelname; |
16 | } | 15 | } |
17 | 16 | ||
18 | bool IRCChannel::hasPeople() { | 17 | bool IRCChannel::hasPeople() { |
19 | return m_hasPeople; | 18 | return m_hasPeople; |
20 | } | 19 | } |
21 | 20 | ||
22 | void IRCChannel::setHasPeople(bool hasPeople) { | 21 | void IRCChannel::setHasPeople(bool hasPeople) { |
23 | m_hasPeople = hasPeople; | 22 | m_hasPeople = hasPeople; |
24 | } | 23 | } |
25 | 24 | ||
26 | void IRCChannel::addPerson(IRCChannelPerson *person) { | 25 | void IRCChannel::addPerson(IRCChannelPerson *person) { |
27 | m_people.append(person); | 26 | m_people.append(person); |
28 | } | 27 | } |
29 | 28 | ||
30 | void IRCChannel::removePerson(IRCChannelPerson *person) { | 29 | void IRCChannel::removePerson(IRCChannelPerson *person) { |
31 | m_people.remove(person); | 30 | m_people.remove(person); |
32 | } | 31 | } |
33 | 32 | ||
34 | QListIterator<IRCChannelPerson> IRCChannel::people() { | 33 | QListIterator<IRCChannelPerson> IRCChannel::people() { |
35 | QListIterator<IRCChannelPerson> it(m_people); | 34 | QListIterator<IRCChannelPerson> it(m_people); |
36 | return it; | 35 | return it; |
37 | } | 36 | } |
38 | 37 | ||
39 | IRCChannelPerson *IRCChannel::getPerson(QString nickname) { | 38 | IRCChannelPerson *IRCChannel::getPerson(QString nickname) { |
40 | QListIterator<IRCChannelPerson> it(m_people); | 39 | QListIterator<IRCChannelPerson> it(m_people); |
41 | for (; it.current(); ++it) { | 40 | for (; it.current(); ++it) { |
42 | if (it.current()->person->nick() == nickname) { | 41 | if (it.current()->person->nick() == nickname) { |
43 | return it.current(); | 42 | return it.current(); |
44 | } | 43 | } |
45 | } | 44 | } |
46 | return 0; | 45 | return 0; |
47 | } | 46 | } |
48 | 47 | ||
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index 4675265..c1695db 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -1,94 +1,146 @@ | |||
1 | #include <qpe/qpeapplication.h> | ||
2 | #include <qpe/resource.h> | ||
3 | #include <qcursor.h> | ||
1 | #include <qhbox.h> | 4 | #include <qhbox.h> |
2 | #include "ircchanneltab.h" | 5 | #include "ircchanneltab.h" |
3 | #include "ircservertab.h" | 6 | #include "ircservertab.h" |
4 | 7 | ||
5 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 8 | IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
6 | m_mainWindow = mainWindow; | 9 | m_mainWindow = mainWindow; |
7 | m_parentTab = parentTab; | 10 | m_parentTab = parentTab; |
8 | m_channel = channel; | 11 | m_channel = channel; |
9 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); | 12 | m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); |
10 | QHBox *hbox = new QHBox(this); | 13 | QHBox *hbox = new QHBox(this); |
11 | m_textview = new QTextView(hbox); | 14 | m_textview = new QTextView(hbox); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 15 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 16 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_listVisible = TRUE; | 17 | m_listVisible = TRUE; |
15 | m_listButton = new QPushButton(">", m_textview); | 18 | m_listButton = new QPushButton(">", m_textview); |
16 | m_textview->setCornerWidget(m_listButton); | 19 | m_textview->setCornerWidget(m_listButton); |
17 | m_textview->setTextFormat(RichText); | 20 | m_textview->setTextFormat(RichText); |
18 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); | 21 | connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); |
19 | m_list = new IRCChannelList(m_channel, hbox); | 22 | m_list = new IRCChannelList(m_channel, hbox); |
20 | m_list->update(); | 23 | m_list->update(); |
21 | m_list->setMaximumWidth(LISTWIDTH); | 24 | m_list->setMaximumWidth(LISTWIDTH); |
22 | m_field = new QLineEdit(this); | 25 | m_field = new QLineEdit(this); |
26 | m_popup = new QPopupMenu(m_list); | ||
27 | /* Required so that embedded-style "right" clicks work */ | ||
28 | QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); | ||
29 | connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); | ||
30 | /* Construct the popup menu */ | ||
31 | QPopupMenu *ctcpMenu = new QPopupMenu(m_list); | ||
32 | m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); | ||
33 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); | ||
34 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); | ||
35 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); | ||
36 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); | ||
37 | |||
23 | m_layout->add(hbox); | 38 | m_layout->add(hbox); |
24 | hbox->show(); | 39 | hbox->show(); |
25 | m_layout->add(m_field); | 40 | m_layout->add(m_field); |
26 | m_field->setFocus(); | 41 | m_field->setFocus(); |
27 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 42 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
28 | 43 | settingsChanged(); | |
29 | } | 44 | } |
30 | 45 | ||
31 | void IRCChannelTab::appendText(QString text) { | 46 | void IRCChannelTab::appendText(QString text) { |
32 | /* not using append because it creates layout problems */ | 47 | /* not using append because it creates layout problems */ |
33 | m_textview->setText(m_textview->text() + text); | 48 | m_textview->setText(m_textview->text() + text); |
34 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 49 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
35 | } | 50 | } |
36 | 51 | ||
37 | IRCChannelTab::~IRCChannelTab() { | 52 | IRCChannelTab::~IRCChannelTab() { |
38 | m_parentTab->removeChannelTab(this); | 53 | m_parentTab->removeChannelTab(this); |
39 | } | 54 | } |
40 | 55 | ||
41 | void IRCChannelTab::processCommand() { | 56 | void IRCChannelTab::processCommand() { |
42 | QString text = m_field->text(); | 57 | QString text = m_field->text(); |
43 | if (text.length()>0) { | 58 | if (text.length()>0) { |
44 | if (session()->isSessionActive()) { | 59 | if (session()->isSessionActive()) { |
45 | if (text.startsWith("/") && !text.startsWith("//")) { | 60 | if (text.startsWith("/") && !text.startsWith("//")) { |
46 | /* Command mode */ | 61 | /* Command mode */ |
47 | m_parentTab->executeCommand(this, text);; | 62 | m_parentTab->executeCommand(this, text);; |
48 | } else { | 63 | } else { |
49 | if (text.startsWith("//")) | 64 | if (text.startsWith("//")) |
50 | text = text.right(text.length()-1); | 65 | text = text.right(text.length()-1); |
51 | session()->sendMessage(m_channel, m_field->text()); | 66 | session()->sendMessage(m_channel, m_field->text()); |
52 | appendText("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); | 67 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">> "+IRCOutput::toHTML(m_field->text())+"</font><br>"); |
53 | } | 68 | } |
54 | } else { | 69 | } else { |
55 | appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); | 70 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
56 | } | 71 | } |
57 | } | 72 | } |
58 | m_field->clear(); | 73 | m_field->clear(); |
59 | } | 74 | } |
60 | 75 | ||
76 | void IRCChannelTab::settingsChanged() { | ||
77 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | ||
78 | } | ||
79 | |||
61 | void IRCChannelTab::toggleList() { | 80 | void IRCChannelTab::toggleList() { |
62 | if (m_listVisible) { | 81 | if (m_listVisible) { |
63 | m_list->setMaximumWidth(0); | 82 | m_list->setMaximumWidth(0); |
64 | m_listButton->setText("<"); | 83 | m_listButton->setText("<"); |
65 | } else { | 84 | } else { |
66 | m_list->setMaximumWidth(LISTWIDTH); | 85 | m_list->setMaximumWidth(LISTWIDTH); |
67 | m_listButton->setText(">"); | 86 | m_listButton->setText(">"); |
68 | } | 87 | } |
69 | m_listVisible = !m_listVisible; | 88 | m_listVisible = !m_listVisible; |
70 | } | 89 | } |
71 | 90 | ||
91 | void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { | ||
92 | switch (mouse) { | ||
93 | case 1: | ||
94 | break; | ||
95 | case 2: | ||
96 | m_popup->popup(point); | ||
97 | break; | ||
98 | }; | ||
99 | } | ||
100 | |||
101 | void IRCChannelTab::popupQuery() { | ||
102 | if (m_list->currentItem() != -1) { | ||
103 | IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); | ||
104 | if (person) { | ||
105 | IRCQueryTab *tab = m_parentTab->getTabForQuery(person); | ||
106 | if (!tab) { | ||
107 | tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); | ||
108 | m_parentTab->addQueryTab(tab); | ||
109 | m_mainWindow->addTab(tab); | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | |||
115 | void IRCChannelTab::popupPing() { | ||
116 | } | ||
117 | |||
118 | void IRCChannelTab::popupVersion() { | ||
119 | } | ||
120 | |||
121 | void IRCChannelTab::popupWhois() { | ||
122 | } | ||
123 | |||
72 | QString IRCChannelTab::title() { | 124 | QString IRCChannelTab::title() { |
73 | return m_channel->channelname(); | 125 | return m_channel->channelname(); |
74 | } | 126 | } |
75 | 127 | ||
76 | IRCSession *IRCChannelTab::session() { | 128 | IRCSession *IRCChannelTab::session() { |
77 | return m_parentTab->session(); | 129 | return m_parentTab->session(); |
78 | } | 130 | } |
79 | 131 | ||
80 | void IRCChannelTab::remove() { | 132 | void IRCChannelTab::remove() { |
81 | if (session()->isSessionActive()) { | 133 | if (session()->isSessionActive()) { |
82 | session()->part(m_channel); | 134 | session()->part(m_channel); |
83 | } else { | 135 | } else { |
84 | m_mainWindow->killTab(this); | 136 | m_mainWindow->killTab(this); |
85 | } | 137 | } |
86 | } | 138 | } |
87 | 139 | ||
88 | IRCChannel *IRCChannelTab::channel() { | 140 | IRCChannel *IRCChannelTab::channel() { |
89 | return m_channel; | 141 | return m_channel; |
90 | } | 142 | } |
91 | 143 | ||
92 | IRCChannelList *IRCChannelTab::list() { | 144 | IRCChannelList *IRCChannelTab::list() { |
93 | return m_list; | 145 | return m_list; |
94 | } | 146 | } |
diff --git a/noncore/net/opieirc/ircchanneltab.h b/noncore/net/opieirc/ircchanneltab.h index 2127c4d..971614b 100644 --- a/noncore/net/opieirc/ircchanneltab.h +++ b/noncore/net/opieirc/ircchanneltab.h | |||
@@ -1,60 +1,70 @@ | |||
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 __IRCCHANNELTAB_H | 21 | #ifndef __IRCCHANNELTAB_H |
22 | #define __IRCCHANNELTAB_H | 22 | #define __IRCCHANNELTAB_H |
23 | 23 | ||
24 | #include <qpopupmenu.h> | ||
24 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
25 | #include "irctab.h" | 26 | #include "irctab.h" |
26 | #include "ircsession.h" | 27 | #include "ircsession.h" |
27 | #include "mainwindow.h" | 28 | #include "mainwindow.h" |
28 | #include "ircchannellist.h" | 29 | #include "ircchannellist.h" |
29 | 30 | ||
30 | #define LISTWIDTH 70 | 31 | #define LISTWIDTH 70 |
31 | 32 | ||
32 | class IRCServerTab; | 33 | class IRCServerTab; |
33 | class IRCChannelTab : public IRCTab { | 34 | class IRCChannelTab : public IRCTab { |
34 | Q_OBJECT | 35 | Q_OBJECT |
35 | public: | 36 | public: |
36 | /* IRCTab implementation */ | 37 | /* IRCTab implementation */ |
37 | IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 38 | IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
38 | ~IRCChannelTab(); | 39 | ~IRCChannelTab(); |
39 | QString title(); | 40 | QString title(); |
40 | IRCSession *session(); | 41 | IRCSession *session(); |
41 | IRCChannel *channel(); | 42 | IRCChannel *channel(); |
42 | IRCChannelList *list(); | 43 | IRCChannelList *list(); |
43 | public: | 44 | public: |
44 | void appendText(QString text); | 45 | void appendText(QString text); |
45 | public slots: | 46 | public slots: |
46 | void remove(); | 47 | void remove(); |
48 | void settingsChanged(); | ||
49 | protected slots: | ||
47 | void processCommand(); | 50 | void processCommand(); |
48 | void toggleList(); | 51 | void toggleList(); |
52 | void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point); | ||
53 | /* Popup slots */ | ||
54 | void popupQuery(); | ||
55 | void popupPing(); | ||
56 | void popupVersion(); | ||
57 | void popupWhois(); | ||
49 | protected: | 58 | protected: |
50 | IRCServerTab *m_parentTab; | 59 | IRCServerTab *m_parentTab; |
51 | IRCChannel *m_channel; | 60 | IRCChannel *m_channel; |
52 | IRCChannelList *m_list; | 61 | IRCChannelList *m_list; |
53 | QPushButton *m_listButton; | 62 | QPushButton *m_listButton; |
54 | MainWindow *m_mainWindow; | 63 | MainWindow *m_mainWindow; |
55 | QTextView *m_textview; | 64 | QTextView *m_textview; |
56 | QLineEdit *m_field; | 65 | QLineEdit *m_field; |
66 | QPopupMenu *m_popup; | ||
57 | bool m_listVisible; | 67 | bool m_listVisible; |
58 | }; | 68 | }; |
59 | 69 | ||
60 | #endif /* __IRCCHANNELTAB_H */ | 70 | #endif /* __IRCCHANNELTAB_H */ |
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 3063741..5c70753 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -1,487 +1,486 @@ | |||
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 | #include <stdio.h> | ||
5 | 4 | ||
6 | /* Lookup table for literal commands */ | 5 | /* Lookup table for literal commands */ |
7 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { | 6 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { |
8 | { "PING", FUNC(parseLiteralPing) }, | 7 | { "PING", FUNC(parseLiteralPing) }, |
9 | { "NOTICE", FUNC(parseLiteralNotice) }, | 8 | { "NOTICE", FUNC(parseLiteralNotice) }, |
10 | { "JOIN", FUNC(parseLiteralJoin) }, | 9 | { "JOIN", FUNC(parseLiteralJoin) }, |
11 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, | 10 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, |
12 | { "NICK", FUNC(parseLiteralNick) }, | 11 | { "NICK", FUNC(parseLiteralNick) }, |
13 | { "PART", FUNC(parseLiteralPart) }, | 12 | { "PART", FUNC(parseLiteralPart) }, |
14 | { "QUIT", FUNC(parseLiteralQuit) }, | 13 | { "QUIT", FUNC(parseLiteralQuit) }, |
15 | { "ERROR", FUNC(parseLiteralError) }, | 14 | { "ERROR", FUNC(parseLiteralError) }, |
16 | { "ERROR:", FUNC(parseLiteralError) }, | 15 | { "ERROR:", FUNC(parseLiteralError) }, |
17 | { "MODE", FUNC(parseLiteralMode) }, | 16 | { "MODE", FUNC(parseLiteralMode) }, |
18 | { "KICK", FUNC(parseLiteralKick) }, | 17 | { "KICK", FUNC(parseLiteralKick) }, |
19 | { 0 , 0 } | 18 | { 0 , 0 } |
20 | }; | 19 | }; |
21 | 20 | ||
22 | /* Lookup table for literal commands */ | 21 | /* Lookup table for literal commands */ |
23 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { | 22 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { |
24 | { "PING", FUNC(parseCTCPPing) }, | 23 | { "PING", FUNC(parseCTCPPing) }, |
25 | { "VERSION", FUNC(parseCTCPVersion) }, | 24 | { "VERSION", FUNC(parseCTCPVersion) }, |
26 | { "ACTION", FUNC(parseCTCPAction) }, | 25 | { "ACTION", FUNC(parseCTCPAction) }, |
27 | { 0 , 0 } | 26 | { 0 , 0 } |
28 | }; | 27 | }; |
29 | 28 | ||
30 | /* Lookup table for numerical commands */ | 29 | /* Lookup table for numerical commands */ |
31 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { | 30 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { |
32 | { 1, FUNC(parseNumerical001) }, // RPL_WELCOME | 31 | { 1, FUNC(parseNumerical001) }, // RPL_WELCOME |
33 | { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST | 32 | { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST |
34 | { 3, FUNC(parseNumerical003) }, // RPL_CREATED | 33 | { 3, FUNC(parseNumerical003) }, // RPL_CREATED |
35 | { 4, FUNC(parseNumerical004) }, // RPL_MYINFO | 34 | { 4, FUNC(parseNumerical004) }, // RPL_MYINFO |
36 | { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL | 35 | { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL |
37 | { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT | 36 | { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT |
38 | { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS | 37 | { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS |
39 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME | 38 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME |
40 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY | 39 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY |
41 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES | 40 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES |
42 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART | 41 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART |
43 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD | 42 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD |
44 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD | 43 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD |
45 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 | 44 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 |
46 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 | 45 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 |
47 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK | 46 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK |
48 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK | 47 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK |
49 | { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND | 48 | { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND |
50 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE | 49 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE |
51 | { 0, 0 } | 50 | { 0, 0 } |
52 | }; | 51 | }; |
53 | 52 | ||
54 | IRCMessageParser::IRCMessageParser(IRCSession *session) { | 53 | IRCMessageParser::IRCMessageParser(IRCSession *session) { |
55 | m_session = session; | 54 | m_session = session; |
56 | } | 55 | } |
57 | 56 | ||
58 | void IRCMessageParser::parse(IRCMessage *message) { | 57 | void IRCMessageParser::parse(IRCMessage *message) { |
59 | /* Find out what kind of message we have here and call the appropriate handler using | 58 | /* Find out what kind of message we have here and call the appropriate handler using |
60 | the parser tables. If no handler can be found, print out an error message */ | 59 | the parser tables. If no handler can be found, print out an error message */ |
61 | if (message->isNumerical()) { | 60 | if (message->isNumerical()) { |
62 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { | 61 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { |
63 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { | 62 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { |
64 | (this->*(numericalParserProcTable[i].proc))(message); | 63 | (this->*(numericalParserProcTable[i].proc))(message); |
65 | return; | 64 | return; |
66 | } | 65 | } |
67 | } | 66 | } |
68 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); | 67 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); |
69 | } else if (message->isCTCP()) { | 68 | } else if (message->isCTCP()) { |
70 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { | 69 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { |
71 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { | 70 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { |
72 | (this->*(ctcpParserProcTable[i].proc))(message); | 71 | (this->*(ctcpParserProcTable[i].proc))(message); |
73 | return; | 72 | return; |
74 | } | 73 | } |
75 | } | 74 | } |
76 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); | 75 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); |
77 | } else { | 76 | } else { |
78 | for (int i=0; literalParserProcTable[i].commandName; i++) { | 77 | for (int i=0; literalParserProcTable[i].commandName; i++) { |
79 | if (message->command() == literalParserProcTable[i].commandName) { | 78 | if (message->command() == literalParserProcTable[i].commandName) { |
80 | (this->*(literalParserProcTable[i].proc))(message); | 79 | (this->*(literalParserProcTable[i].proc))(message); |
81 | return; | 80 | return; |
82 | } | 81 | } |
83 | } | 82 | } |
84 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); | 83 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); |
85 | } | 84 | } |
86 | } | 85 | } |
87 | 86 | ||
88 | void IRCMessageParser::nullFunc(IRCMessage *) { | 87 | void IRCMessageParser::nullFunc(IRCMessage *) { |
89 | /* Do nothing */ | 88 | /* Do nothing */ |
90 | } | 89 | } |
91 | 90 | ||
92 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { | 91 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { |
93 | m_session->m_connection->sendLine("PONG " + message->allParameters()); | 92 | m_session->m_connection->sendLine("PONG " + message->allParameters()); |
94 | } | 93 | } |
95 | 94 | ||
96 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { | 95 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { |
97 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 96 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
98 | } | 97 | } |
99 | 98 | ||
100 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { | 99 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { |
101 | QString channelName = message->param(0); | 100 | QString channelName = message->param(0); |
102 | IRCPerson mask(message->prefix()); | 101 | IRCPerson mask(message->prefix()); |
103 | IRCChannel *channel = m_session->getChannel(channelName); | 102 | IRCChannel *channel = m_session->getChannel(channelName); |
104 | if (!channel) { | 103 | if (!channel) { |
105 | /* We joined */ | 104 | /* We joined */ |
106 | if (mask.nick() == m_session->m_server->nick()) { | 105 | if (mask.nick() == m_session->m_server->nick()) { |
107 | channel = new IRCChannel(channelName); | 106 | channel = new IRCChannel(channelName); |
108 | m_session->addChannel(channel); | 107 | m_session->addChannel(channel); |
109 | } else { | 108 | } else { |
110 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); | 109 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); |
111 | } | 110 | } |
112 | } else { | 111 | } else { |
113 | /* Someone else joined */ | 112 | /* Someone else joined */ |
114 | if (mask.nick() != m_session->m_server->nick()) { | 113 | if (mask.nick() != m_session->m_server->nick()) { |
115 | if (!channel->getPerson(mask.nick())) { | 114 | if (!channel->getPerson(mask.nick())) { |
116 | IRCChannelPerson *chanperson = new IRCChannelPerson(); | 115 | IRCChannelPerson *chanperson = new IRCChannelPerson(); |
117 | IRCPerson *person = m_session->getPerson(mask.nick()); | 116 | IRCPerson *person = m_session->getPerson(mask.nick()); |
118 | if (!person) { | 117 | if (!person) { |
119 | person = new IRCPerson(message->prefix()); | 118 | person = new IRCPerson(message->prefix()); |
120 | m_session->addPerson(person); | 119 | m_session->addPerson(person); |
121 | } | 120 | } |
122 | chanperson->flags = 0; | 121 | chanperson->flags = 0; |
123 | chanperson->person = person; | 122 | chanperson->person = person; |
124 | channel->addPerson(chanperson); | 123 | channel->addPerson(chanperson); |
125 | IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); | 124 | IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); |
126 | output.addParam(channel); | 125 | output.addParam(channel); |
127 | output.addParam(chanperson); | 126 | output.addParam(chanperson); |
128 | emit outputReady(output); | 127 | emit outputReady(output); |
129 | } else { | 128 | } else { |
130 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); | 129 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); |
131 | } | 130 | } |
132 | } else { | 131 | } else { |
133 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); | 132 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); |
134 | } | 133 | } |
135 | } | 134 | } |
136 | } | 135 | } |
137 | 136 | ||
138 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { | 137 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { |
139 | QString channelName = message->param(0); | 138 | QString channelName = message->param(0); |
140 | IRCChannel *channel = m_session->getChannel(channelName); | 139 | IRCChannel *channel = m_session->getChannel(channelName); |
141 | IRCPerson mask(message->prefix()); | 140 | IRCPerson mask(message->prefix()); |
142 | if (channel) { | 141 | if (channel) { |
143 | if (mask.nick() == m_session->m_server->nick()) { | 142 | if (mask.nick() == m_session->m_server->nick()) { |
144 | m_session->removeChannel(channel); | 143 | m_session->removeChannel(channel); |
145 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); | 144 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); |
146 | output.addParam(channel); | 145 | output.addParam(channel); |
147 | emit outputReady(output); | 146 | emit outputReady(output); |
148 | delete channel; | 147 | delete channel; |
149 | } else { | 148 | } else { |
150 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 149 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
151 | if (person) { | 150 | if (person) { |
152 | channel->removePerson(person); | 151 | channel->removePerson(person); |
153 | IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); | 152 | IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); |
154 | output.addParam(channel); | 153 | output.addParam(channel); |
155 | output.addParam(person); | 154 | output.addParam(person); |
156 | emit outputReady(output); | 155 | emit outputReady(output); |
157 | delete person; | 156 | delete person; |
158 | } else { | 157 | } else { |
159 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); | 158 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); |
160 | } | 159 | } |
161 | } | 160 | } |
162 | } else { | 161 | } else { |
163 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); | 162 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); |
164 | } | 163 | } |
165 | } | 164 | } |
166 | 165 | ||
167 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | 166 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { |
168 | if (m_session->m_server->nick() == message->param(0)) { | 167 | if (m_session->m_server->nick() == message->param(0)) { |
169 | /* IRC Query message detected, verify sender and display it */ | 168 | /* IRC Query message detected, verify sender and display it */ |
170 | IRCPerson mask(message->prefix()); | 169 | IRCPerson mask(message->prefix()); |
171 | IRCPerson *person = m_session->getPerson(mask.nick()); | 170 | IRCPerson *person = m_session->getPerson(mask.nick()); |
172 | if (!person) { | 171 | if (!person) { |
173 | /* Person not yet known, create and add to the current session */ | 172 | /* Person not yet known, create and add to the current session */ |
174 | person = new IRCPerson(message->prefix()); | 173 | person = new IRCPerson(message->prefix()); |
175 | m_session->addPerson(person); | 174 | m_session->addPerson(person); |
176 | } | 175 | } |
177 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); | 176 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); |
178 | output.addParam(person); | 177 | output.addParam(person); |
179 | emit outputReady(output); | 178 | emit outputReady(output); |
180 | } else if (message->param(0).at(0) == '#') { | 179 | } else if (message->param(0).at(0) == '#') { |
181 | /* IRC Channel message detected, verify sender, channel and display it */ | 180 | /* IRC Channel message detected, verify sender, channel and display it */ |
182 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 181 | IRCChannel *channel = m_session->getChannel(message->param(0)); |
183 | if (channel) { | 182 | if (channel) { |
184 | IRCPerson mask(message->prefix()); | 183 | IRCPerson mask(message->prefix()); |
185 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 184 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
186 | if (person) { | 185 | if (person) { |
187 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); | 186 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); |
188 | output.addParam(channel); | 187 | output.addParam(channel); |
189 | output.addParam(person); | 188 | output.addParam(person); |
190 | emit outputReady(output); | 189 | emit outputReady(output); |
191 | } else { | 190 | } else { |
192 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); | 191 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); |
193 | } | 192 | } |
194 | } else { | 193 | } else { |
195 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel"))); | 194 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel"))); |
196 | } | 195 | } |
197 | } else { | 196 | } else { |
198 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); | 197 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); |
199 | } | 198 | } |
200 | } | 199 | } |
201 | 200 | ||
202 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | 201 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { |
203 | IRCPerson mask(message->prefix()); | 202 | IRCPerson mask(message->prefix()); |
204 | 203 | ||
205 | if (mask.nick() == m_session->m_server->nick()) { | 204 | if (mask.nick() == m_session->m_server->nick()) { |
206 | /* We are changing our nickname */ | 205 | /* We are changing our nickname */ |
207 | m_session->m_server->setNick(message->param(0)); | 206 | m_session->m_server->setNick(message->param(0)); |
208 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); | 207 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); |
209 | output.addParam(0); | 208 | output.addParam(0); |
210 | emit outputReady(output); | 209 | emit outputReady(output); |
211 | } else { | 210 | } else { |
212 | /* Someone else is */ | 211 | /* Someone else is */ |
213 | IRCPerson *person = m_session->getPerson(mask.nick()); | 212 | IRCPerson *person = m_session->getPerson(mask.nick()); |
214 | if (person) { | 213 | if (person) { |
215 | IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); | 214 | IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); |
216 | output.addParam(person); | 215 | output.addParam(person); |
217 | emit outputReady(output); | 216 | emit outputReady(output); |
218 | } else { | 217 | } else { |
219 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 218 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
220 | } | 219 | } |
221 | } | 220 | } |
222 | } | 221 | } |
223 | 222 | ||
224 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { | 223 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { |
225 | IRCPerson mask(message->prefix()); | 224 | IRCPerson mask(message->prefix()); |
226 | IRCPerson *person = m_session->getPerson(mask.nick()); | 225 | IRCPerson *person = m_session->getPerson(mask.nick()); |
227 | if (person) { | 226 | if (person) { |
228 | QList<IRCChannel> channels; | 227 | QList<IRCChannel> channels; |
229 | m_session->getChannelsByPerson(person, channels); | 228 | m_session->getChannelsByPerson(person, channels); |
230 | QListIterator<IRCChannel> it(channels); | 229 | QListIterator<IRCChannel> it(channels); |
231 | for (;it.current(); ++it) { | 230 | for (;it.current(); ++it) { |
232 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 231 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
233 | it.current()->removePerson(chanperson); | 232 | it.current()->removePerson(chanperson); |
234 | delete chanperson; | 233 | delete chanperson; |
235 | } | 234 | } |
236 | m_session->removePerson(person); | 235 | m_session->removePerson(person); |
237 | IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); | 236 | IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); |
238 | output.addParam(person); | 237 | output.addParam(person); |
239 | emit outputReady(output); | 238 | emit outputReady(output); |
240 | delete person; | 239 | delete person; |
241 | } else { | 240 | } else { |
242 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); | 241 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); |
243 | } | 242 | } |
244 | } | 243 | } |
245 | 244 | ||
246 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { | 245 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { |
247 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); | 246 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); |
248 | } | 247 | } |
249 | 248 | ||
250 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | 249 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { |
251 | IRCPerson mask(message->prefix()); | 250 | IRCPerson mask(message->prefix()); |
252 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); | 251 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); |
253 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); | 252 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); |
254 | } | 253 | } |
255 | 254 | ||
256 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { | 255 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { |
257 | IRCPerson mask(message->prefix()); | 256 | IRCPerson mask(message->prefix()); |
258 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); | 257 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); |
259 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); | 258 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); |
260 | } | 259 | } |
261 | 260 | ||
262 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | 261 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { |
263 | IRCPerson mask(message->prefix()); | 262 | IRCPerson mask(message->prefix()); |
264 | QString dest = message->ctcpDestination(); | 263 | QString dest = message->ctcpDestination(); |
265 | if (dest.startsWith("#")) { | 264 | if (dest.startsWith("#")) { |
266 | IRCChannel *channel = m_session->getChannel(dest); | 265 | IRCChannel *channel = m_session->getChannel(dest); |
267 | if (channel) { | 266 | if (channel) { |
268 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 267 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
269 | if (person) { | 268 | if (person) { |
270 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); | 269 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); |
271 | output.addParam(channel); | 270 | output.addParam(channel); |
272 | output.addParam(person); | 271 | output.addParam(person); |
273 | emit outputReady(output); | 272 | emit outputReady(output); |
274 | } else { | 273 | } else { |
275 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); | 274 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); |
276 | } | 275 | } |
277 | } else { | 276 | } else { |
278 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); | 277 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); |
279 | } | 278 | } |
280 | } else { | 279 | } else { |
281 | if (message->ctcpDestination() == m_session->m_server->nick()) { | 280 | if (message->ctcpDestination() == m_session->m_server->nick()) { |
282 | IRCPerson *person = m_session->getPerson(mask.nick()); | 281 | IRCPerson *person = m_session->getPerson(mask.nick()); |
283 | if (!person) { | 282 | if (!person) { |
284 | /* Person not yet known, create and add to the current session */ | 283 | /* Person not yet known, create and add to the current session */ |
285 | person = new IRCPerson(message->prefix()); | 284 | person = new IRCPerson(message->prefix()); |
286 | m_session->addPerson(person); | 285 | m_session->addPerson(person); |
287 | } | 286 | } |
288 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); | 287 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); |
289 | output.addParam(person); | 288 | output.addParam(person); |
290 | emit outputReady(output); | 289 | emit outputReady(output); |
291 | } else { | 290 | } else { |
292 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); | 291 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); |
293 | } | 292 | } |
294 | } | 293 | } |
295 | } | 294 | } |
296 | 295 | ||
297 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 296 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
298 | IRCPerson mask(message->prefix()); | 297 | IRCPerson mask(message->prefix()); |
299 | 298 | ||
300 | if (message->param(0).startsWith("#")) { | 299 | if (message->param(0).startsWith("#")) { |
301 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 300 | IRCChannel *channel = m_session->getChannel(message->param(0)); |
302 | if (channel) { | 301 | if (channel) { |
303 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); | 302 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); |
304 | QTextIStream stream(¶meters); | 303 | QTextIStream stream(¶meters); |
305 | bool set = FALSE; | 304 | bool set = FALSE; |
306 | while (!stream.atEnd()) { | 305 | while (!stream.atEnd()) { |
307 | stream >> temp; | 306 | stream >> temp; |
308 | if (temp.startsWith("+")) { | 307 | if (temp.startsWith("+")) { |
309 | set = TRUE; | 308 | set = TRUE; |
310 | temp = temp.right(1); | 309 | temp = temp.right(1); |
311 | } else if (temp.startsWith("-")) { | 310 | } else if (temp.startsWith("-")) { |
312 | set = FALSE; | 311 | set = FALSE; |
313 | temp = temp.right(1); | 312 | temp = temp.right(1); |
314 | } else { | 313 | } else { |
315 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); | 314 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); |
316 | return; | 315 | return; |
317 | } | 316 | } |
318 | if (temp == "o") { | 317 | if (temp == "o") { |
319 | stream >> temp; | 318 | stream >> temp; |
320 | IRCChannelPerson *person = channel->getPerson(temp); | 319 | IRCChannelPerson *person = channel->getPerson(temp); |
321 | if (person) { | 320 | if (person) { |
322 | if (set) { | 321 | if (set) { |
323 | person->flags |= PERSON_FLAG_OP; | 322 | person->flags |= PERSON_FLAG_OP; |
324 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); | 323 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); |
325 | output.addParam(channel); | 324 | output.addParam(channel); |
326 | output.addParam(person); | 325 | output.addParam(person); |
327 | emit outputReady(output); | 326 | emit outputReady(output); |
328 | } else { | 327 | } else { |
329 | person->flags &= 0xFFFF - PERSON_FLAG_OP; | 328 | person->flags &= 0xFFFF - PERSON_FLAG_OP; |
330 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); | 329 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); |
331 | output.addParam(channel); | 330 | output.addParam(channel); |
332 | output.addParam(person); | 331 | output.addParam(person); |
333 | emit outputReady(output); | 332 | emit outputReady(output); |
334 | } | 333 | } |
335 | } else { | 334 | } else { |
336 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); | 335 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); |
337 | } | 336 | } |
338 | } else if (temp == "v") { | 337 | } else if (temp == "v") { |
339 | stream >> temp; | 338 | stream >> temp; |
340 | IRCChannelPerson *person = channel->getPerson(temp); | 339 | IRCChannelPerson *person = channel->getPerson(temp); |
341 | if (person) { | 340 | if (person) { |
342 | if (set) { | 341 | if (set) { |
343 | person->flags |= PERSON_FLAG_VOICE; | 342 | person->flags |= PERSON_FLAG_VOICE; |
344 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); | 343 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); |
345 | output.addParam(channel); | 344 | output.addParam(channel); |
346 | output.addParam(person); | 345 | output.addParam(person); |
347 | emit outputReady(output); | 346 | emit outputReady(output); |
348 | } else { | 347 | } else { |
349 | person->flags &= 0xFFFF - PERSON_FLAG_VOICE; | 348 | person->flags &= 0xFFFF - PERSON_FLAG_VOICE; |
350 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick())); | 349 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick())); |
351 | output.addParam(channel); | 350 | output.addParam(channel); |
352 | output.addParam(person); | 351 | output.addParam(person); |
353 | emit outputReady(output); | 352 | emit outputReady(output); |
354 | } | 353 | } |
355 | } else { | 354 | } else { |
356 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); | 355 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); |
357 | } | 356 | } |
358 | } else { | 357 | } else { |
359 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); | 358 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); |
360 | } | 359 | } |
361 | } | 360 | } |
362 | } else { | 361 | } else { |
363 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); | 362 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); |
364 | } | 363 | } |
365 | } else { | 364 | } else { |
366 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); | 365 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); |
367 | } | 366 | } |
368 | } | 367 | } |
369 | 368 | ||
370 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | 369 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { |
371 | IRCPerson mask(message->prefix()); | 370 | IRCPerson mask(message->prefix()); |
372 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 371 | IRCChannel *channel = m_session->getChannel(message->param(0)); |
373 | if (channel) { | 372 | if (channel) { |
374 | IRCChannelPerson *person = channel->getPerson(message->param(1)); | 373 | IRCChannelPerson *person = channel->getPerson(message->param(1)); |
375 | if (person) { | 374 | if (person) { |
376 | if (person->person->nick() == m_session->m_server->nick()) { | 375 | if (person->person->nick() == m_session->m_server->nick()) { |
377 | m_session->removeChannel(channel); | 376 | m_session->removeChannel(channel); |
378 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); | 377 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); |
379 | output.addParam(channel); | 378 | output.addParam(channel); |
380 | emit outputReady(output); | 379 | emit outputReady(output); |
381 | } else { | 380 | } else { |
382 | channel->removePerson(person); | 381 | channel->removePerson(person); |
383 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); | 382 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); |
384 | output.addParam(channel); | 383 | output.addParam(channel); |
385 | output.addParam(person); | 384 | output.addParam(person); |
386 | emit outputReady(output); | 385 | emit outputReady(output); |
387 | } | 386 | } |
388 | } else { | 387 | } else { |
389 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); | 388 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); |
390 | } | 389 | } |
391 | } else { | 390 | } else { |
392 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); | 391 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); |
393 | } | 392 | } |
394 | } | 393 | } |
395 | 394 | ||
396 | void IRCMessageParser::parseNumerical001(IRCMessage *message) { | 395 | void IRCMessageParser::parseNumerical001(IRCMessage *message) { |
397 | /* Welcome to IRC message, display */ | 396 | /* Welcome to IRC message, display */ |
398 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 397 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
399 | } | 398 | } |
400 | 399 | ||
401 | void IRCMessageParser::parseNumerical002(IRCMessage *message) { | 400 | void IRCMessageParser::parseNumerical002(IRCMessage *message) { |
402 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 401 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
403 | } | 402 | } |
404 | 403 | ||
405 | void IRCMessageParser::parseNumerical003(IRCMessage *message) { | 404 | void IRCMessageParser::parseNumerical003(IRCMessage *message) { |
406 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 405 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
407 | } | 406 | } |
408 | 407 | ||
409 | void IRCMessageParser::parseNumerical004(IRCMessage *message) { | 408 | void IRCMessageParser::parseNumerical004(IRCMessage *message) { |
410 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 409 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
411 | } | 410 | } |
412 | 411 | ||
413 | void IRCMessageParser::parseNumerical005(IRCMessage *message) { | 412 | void IRCMessageParser::parseNumerical005(IRCMessage *message) { |
414 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 413 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
415 | } | 414 | } |
416 | 415 | ||
417 | void IRCMessageParser::parseNumericalStats(IRCMessage *message) { | 416 | void IRCMessageParser::parseNumericalStats(IRCMessage *message) { |
418 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 417 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
419 | } | 418 | } |
420 | 419 | ||
421 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { | 420 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { |
422 | /* Name list sent when joining a channel */ | 421 | /* Name list sent when joining a channel */ |
423 | IRCChannel *channel = m_session->getChannel(message->param(2)); | 422 | IRCChannel *channel = m_session->getChannel(message->param(2)); |
424 | if (channel != 0) { | 423 | if (channel != 0) { |
425 | QString people = message->param(3); | 424 | QString people = message->param(3); |
426 | QTextIStream stream(&people); | 425 | QTextIStream stream(&people); |
427 | QString temp; | 426 | QString temp; |
428 | 427 | ||
429 | while (!stream.atEnd()) { | 428 | while (!stream.atEnd()) { |
430 | stream >> temp; | 429 | stream >> temp; |
431 | 430 | ||
432 | char flagch = temp.at(0).latin1(); | 431 | char flagch = temp.at(0).latin1(); |
433 | int flag = 0; | 432 | int flag = 0; |
434 | QString nick; | 433 | QString nick; |
435 | /* Parse person flags */ | 434 | /* Parse person flags */ |
436 | if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { | 435 | if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { |
437 | 436 | ||
438 | nick = temp.right(temp.length()-1); | 437 | nick = temp.right(temp.length()-1); |
439 | switch (flagch) { | 438 | switch (flagch) { |
440 | case '@': flag = PERSON_FLAG_OP; break; | 439 | case '@': flag = PERSON_FLAG_OP; break; |
441 | case '+': flag = PERSON_FLAG_VOICE; break; | 440 | case '+': flag = PERSON_FLAG_VOICE; break; |
442 | case '%': flag = PERSON_FLAG_HALFOP; break; | 441 | case '%': flag = PERSON_FLAG_HALFOP; break; |
443 | default : flag = 0; break; | 442 | default : flag = 0; break; |
444 | } | 443 | } |
445 | } else { | 444 | } else { |
446 | nick = temp; | 445 | nick = temp; |
447 | } | 446 | } |
448 | 447 | ||
449 | IRCChannelPerson *chan_person = new IRCChannelPerson(); | 448 | IRCChannelPerson *chan_person = new IRCChannelPerson(); |
450 | IRCPerson *person = m_session->getPerson(nick); | 449 | IRCPerson *person = m_session->getPerson(nick); |
451 | if (person == 0) { | 450 | if (person == 0) { |
452 | person = new IRCPerson(); | 451 | person = new IRCPerson(); |
453 | person->setNick(nick); | 452 | person->setNick(nick); |
454 | m_session->addPerson(person); | 453 | m_session->addPerson(person); |
455 | } | 454 | } |
456 | chan_person->person = person; | 455 | chan_person->person = person; |
457 | chan_person->flags = flag; | 456 | chan_person->flags = flag; |
458 | channel->addPerson(chan_person); | 457 | channel->addPerson(chan_person); |
459 | } | 458 | } |
460 | } else { | 459 | } else { |
461 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 460 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); |
462 | } | 461 | } |
463 | } | 462 | } |
464 | 463 | ||
465 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { | 464 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { |
466 | /* Done syncing to channel */ | 465 | /* Done syncing to channel */ |
467 | IRCChannel *channel = m_session->getChannel(message->param(1)); | 466 | IRCChannel *channel = m_session->getChannel(message->param(1)); |
468 | if (channel) { | 467 | if (channel) { |
469 | channel->setHasPeople(TRUE); | 468 | channel->setHasPeople(TRUE); |
470 | /* Yes, we want the names before anything happens inside the GUI */ | 469 | /* Yes, we want the names before anything happens inside the GUI */ |
471 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); | 470 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); |
472 | output.addParam(channel); | 471 | output.addParam(channel); |
473 | emit outputReady(output); | 472 | emit outputReady(output); |
474 | } else { | 473 | } else { |
475 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 474 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); |
476 | } | 475 | } |
477 | } | 476 | } |
478 | 477 | ||
479 | 478 | ||
480 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { | 479 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { |
481 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); | 480 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); |
482 | m_session->endSession(); | 481 | m_session->endSession(); |
483 | } | 482 | } |
484 | 483 | ||
485 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { | 484 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { |
486 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); | 485 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); |
487 | } | 486 | } |
diff --git a/noncore/net/opieirc/ircmisc.cpp b/noncore/net/opieirc/ircmisc.cpp new file mode 100644 index 0000000..f41a89a --- a/dev/null +++ b/noncore/net/opieirc/ircmisc.cpp | |||
@@ -0,0 +1,31 @@ | |||
1 | #include <opie/colordialog.h> | ||
2 | #include <qlayout.h> | ||
3 | #include "ircmisc.h" | ||
4 | |||
5 | IRCColorLabel::IRCColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QLabel(parent, name, f) { | ||
6 | m_color = color; | ||
7 | setAlignment(AlignVCenter | AlignCenter); | ||
8 | setFrameStyle(QFrame::StyledPanel); | ||
9 | setFrameShadow(QFrame::Sunken); | ||
10 | setBackgroundColor(m_color); | ||
11 | } | ||
12 | |||
13 | void IRCColorLabel::mousePressEvent(QMouseEvent *) { | ||
14 | m_color = OColorDialog::getColor(m_color); | ||
15 | setBackgroundColor(m_color); | ||
16 | } | ||
17 | |||
18 | QColor IRCColorLabel::color() { | ||
19 | return m_color; | ||
20 | } | ||
21 | |||
22 | IRCFramedColorLabel::IRCFramedColorLabel(QColor color, QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { | ||
23 | QVBoxLayout *layout = new QVBoxLayout(this, 10, 0); | ||
24 | m_label = new IRCColorLabel(color, this); | ||
25 | layout->addWidget(m_label); | ||
26 | } | ||
27 | |||
28 | QColor IRCFramedColorLabel::color() { | ||
29 | return m_label->color(); | ||
30 | } | ||
31 | |||
diff --git a/noncore/net/opieirc/ircmisc.h b/noncore/net/opieirc/ircmisc.h new file mode 100644 index 0000000..1ea04c8 --- a/dev/null +++ b/noncore/net/opieirc/ircmisc.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | OpieIRC - An embedded IRC client | ||
3 | Copyright (C) 2002 Wenzel Jakob | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | |||
19 | */ | ||
20 | |||
21 | #ifndef __IRCMISC_H | ||
22 | #define __IRCMISC_H | ||
23 | |||
24 | #include <qlabel.h> | ||
25 | #include <qcolor.h> | ||
26 | |||
27 | class IRCColorLabel : public QLabel { | ||
28 | public: | ||
29 | IRCColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | ||
30 | QColor color(); | ||
31 | void mousePressEvent(QMouseEvent *event); | ||
32 | protected: | ||
33 | QColor m_color; | ||
34 | }; | ||
35 | |||
36 | class IRCFramedColorLabel : public QWidget { | ||
37 | public: | ||
38 | IRCFramedColorLabel(QColor color, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | ||
39 | QColor color(); | ||
40 | protected: | ||
41 | IRCColorLabel *m_label; | ||
42 | }; | ||
43 | |||
44 | #endif /* __IRCMISC_H */ | ||
diff --git a/noncore/net/opieirc/ircperson.cpp b/noncore/net/opieirc/ircperson.cpp index bd341f1..2f5b435 100644 --- a/noncore/net/opieirc/ircperson.cpp +++ b/noncore/net/opieirc/ircperson.cpp | |||
@@ -1,56 +1,55 @@ | |||
1 | #include "ircperson.h" | 1 | #include "ircperson.h" |
2 | #include <stdio.h> | ||
3 | 2 | ||
4 | IRCPerson::IRCPerson() { | 3 | IRCPerson::IRCPerson() { |
5 | m_nick = ""; | 4 | m_nick = ""; |
6 | m_user = ""; | 5 | m_user = ""; |
7 | m_host = ""; | 6 | m_host = ""; |
8 | } | 7 | } |
9 | 8 | ||
10 | IRCPerson::IRCPerson(const IRCPerson &person) { | 9 | IRCPerson::IRCPerson(const IRCPerson &person) { |
11 | m_nick = person.m_nick; | 10 | m_nick = person.m_nick; |
12 | m_user = person.m_user; | 11 | m_user = person.m_user; |
13 | m_host = person.m_host; | 12 | m_host = person.m_host; |
14 | } | 13 | } |
15 | 14 | ||
16 | IRCPerson::IRCPerson(QString mask) { | 15 | IRCPerson::IRCPerson(QString mask) { |
17 | IRCPerson(); | 16 | IRCPerson(); |
18 | fromMask(mask); | 17 | fromMask(mask); |
19 | } | 18 | } |
20 | 19 | ||
21 | void IRCPerson::fromMask(QString mask) { | 20 | void IRCPerson::fromMask(QString mask) { |
22 | int sep1 = mask.find("!"); | 21 | int sep1 = mask.find("!"); |
23 | int sep2 = mask.find("@"); | 22 | int sep2 = mask.find("@"); |
24 | 23 | ||
25 | m_nick = mask.left(sep1); | 24 | m_nick = mask.left(sep1); |
26 | m_user = mask.mid(sep1+1, sep2-sep1-1); | 25 | m_user = mask.mid(sep1+1, sep2-sep1-1); |
27 | m_host = mask.right(mask.length()-sep2-1); | 26 | m_host = mask.right(mask.length()-sep2-1); |
28 | } | 27 | } |
29 | 28 | ||
30 | QString IRCPerson::toMask() { | 29 | QString IRCPerson::toMask() { |
31 | return m_nick + "!" + m_user + "@" + m_host; | 30 | return m_nick + "!" + m_user + "@" + m_host; |
32 | } | 31 | } |
33 | 32 | ||
34 | void IRCPerson::setNick(QString nick) { | 33 | void IRCPerson::setNick(QString nick) { |
35 | m_nick = nick; | 34 | m_nick = nick; |
36 | } | 35 | } |
37 | 36 | ||
38 | void IRCPerson::setUser(QString user) { | 37 | void IRCPerson::setUser(QString user) { |
39 | m_user = user; | 38 | m_user = user; |
40 | } | 39 | } |
41 | 40 | ||
42 | void IRCPerson::setHost(QString host) { | 41 | void IRCPerson::setHost(QString host) { |
43 | m_host = host; | 42 | m_host = host; |
44 | } | 43 | } |
45 | 44 | ||
46 | QString IRCPerson::nick() { | 45 | QString IRCPerson::nick() { |
47 | return m_nick; | 46 | return m_nick; |
48 | } | 47 | } |
49 | 48 | ||
50 | QString IRCPerson::user() { | 49 | QString IRCPerson::user() { |
51 | return m_user; | 50 | return m_user; |
52 | } | 51 | } |
53 | 52 | ||
54 | QString IRCPerson::host() { | 53 | QString IRCPerson::host() { |
55 | return m_host; | 54 | return m_host; |
56 | } | 55 | } |
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp index 642cc5b..c6b8211 100644 --- a/noncore/net/opieirc/ircquerytab.cpp +++ b/noncore/net/opieirc/ircquerytab.cpp | |||
@@ -1,78 +1,82 @@ | |||
1 | #include <qhbox.h> | 1 | #include <qhbox.h> |
2 | #include "ircquerytab.h" | 2 | #include "ircquerytab.h" |
3 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
4 | 4 | ||
5 | IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 5 | IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
6 | m_mainWindow = mainWindow; | 6 | m_mainWindow = mainWindow; |
7 | m_parentTab = parentTab; | 7 | m_parentTab = parentTab; |
8 | m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ | 8 | m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ |
9 | m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); | 9 | m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); |
10 | QHBox *hbox = new QHBox(this); | 10 | QHBox *hbox = new QHBox(this); |
11 | m_textview = new QTextView(hbox); | 11 | m_textview = new QTextView(hbox); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_textview->setTextFormat(RichText); | 14 | m_textview->setTextFormat(RichText); |
15 | m_field = new QLineEdit(this); | 15 | m_field = new QLineEdit(this); |
16 | m_layout->add(hbox); | 16 | m_layout->add(hbox); |
17 | hbox->show(); | 17 | hbox->show(); |
18 | m_layout->add(m_field); | 18 | m_layout->add(m_field); |
19 | m_field->setFocus(); | 19 | m_field->setFocus(); |
20 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 20 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
21 | 21 | settingsChanged(); | |
22 | } | 22 | } |
23 | 23 | ||
24 | void IRCQueryTab::appendText(QString text) { | 24 | void IRCQueryTab::appendText(QString text) { |
25 | /* not using append because it creates layout problems */ | 25 | /* not using append because it creates layout problems */ |
26 | m_textview->setText(m_textview->text() + text); | 26 | m_textview->setText(m_textview->text() + text); |
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
28 | } | 28 | } |
29 | 29 | ||
30 | IRCQueryTab::~IRCQueryTab() { | 30 | IRCQueryTab::~IRCQueryTab() { |
31 | m_parentTab->removeQueryTab(this); | 31 | m_parentTab->removeQueryTab(this); |
32 | delete m_person; | 32 | delete m_person; |
33 | } | 33 | } |
34 | 34 | ||
35 | void IRCQueryTab::processCommand() { | 35 | void IRCQueryTab::processCommand() { |
36 | QString text = m_field->text(); | 36 | QString text = m_field->text(); |
37 | if (text.length()>0) { | 37 | if (text.length()>0) { |
38 | if (session()->isSessionActive()) { | 38 | if (session()->isSessionActive()) { |
39 | if (text.startsWith("/") && !text.startsWith("//")) { | 39 | if (text.startsWith("/") && !text.startsWith("//")) { |
40 | /* Command mode */ | 40 | /* Command mode */ |
41 | m_parentTab->executeCommand(this, text);; | 41 | m_parentTab->executeCommand(this, text);; |
42 | } else { | 42 | } else { |
43 | if (text.startsWith("//")) | 43 | if (text.startsWith("//")) |
44 | text = text.right(text.length()-1); | 44 | text = text.right(text.length()-1); |
45 | session()->sendMessage(m_person, m_field->text()); | 45 | session()->sendMessage(m_person, m_field->text()); |
46 | appendText("<<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>> "+IRCOutput::toHTML(m_field->text())+"<br>"); | 46 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">> "+IRCOutput::toHTML(m_field->text())+"</font><br>"); |
47 | } | 47 | } |
48 | } else { | 48 | } else { |
49 | appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); | 49 | appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); |
50 | } | 50 | } |
51 | } | 51 | } |
52 | m_field->clear(); | 52 | m_field->clear(); |
53 | } | 53 | } |
54 | 54 | ||
55 | void IRCQueryTab::display(IRCOutput output) { | 55 | void IRCQueryTab::display(IRCOutput output) { |
56 | if (output.type() == OUTPUT_QUERYPRIVMSG) { | 56 | if (output.type() == OUTPUT_QUERYPRIVMSG) { |
57 | appendText("<<font color=\"#0000dd\">"+m_person->nick()+"</font>> " + output.htmlMessage() + "<br>"); | 57 | appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage() + "</font><br>"); |
58 | } else if (output.type() == OUTPUT_QUERYACTION) { | 58 | } else if (output.type() == OUTPUT_QUERYACTION) { |
59 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "<br>"); | 59 | appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>"); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | void IRCQueryTab::settingsChanged() { | ||
64 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | ||
65 | } | ||
66 | |||
63 | QString IRCQueryTab::title() { | 67 | QString IRCQueryTab::title() { |
64 | return m_person->nick(); | 68 | return m_person->nick(); |
65 | } | 69 | } |
66 | 70 | ||
67 | IRCSession *IRCQueryTab::session() { | 71 | IRCSession *IRCQueryTab::session() { |
68 | return m_parentTab->session(); | 72 | return m_parentTab->session(); |
69 | } | 73 | } |
70 | 74 | ||
71 | void IRCQueryTab::remove() { | 75 | void IRCQueryTab::remove() { |
72 | m_mainWindow->killTab(this); | 76 | m_mainWindow->killTab(this); |
73 | } | 77 | } |
74 | 78 | ||
75 | IRCPerson *IRCQueryTab::person() { | 79 | IRCPerson *IRCQueryTab::person() { |
76 | return m_person; | 80 | return m_person; |
77 | } | 81 | } |
78 | 82 | ||
diff --git a/noncore/net/opieirc/ircquerytab.h b/noncore/net/opieirc/ircquerytab.h index ea777f4..07fa57f 100644 --- a/noncore/net/opieirc/ircquerytab.h +++ b/noncore/net/opieirc/ircquerytab.h | |||
@@ -1,51 +1,52 @@ | |||
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 __IRCQUERYTAB_H | 21 | #ifndef __IRCQUERYTAB_H |
22 | #define __IRCQUERYTAB_H | 22 | #define __IRCQUERYTAB_H |
23 | 23 | ||
24 | #include "ircsession.h" | 24 | #include "ircsession.h" |
25 | #include "mainwindow.h" | 25 | #include "mainwindow.h" |
26 | 26 | ||
27 | class IRCServerTab; | 27 | class IRCServerTab; |
28 | class IRCQueryTab : public IRCTab { | 28 | class IRCQueryTab : public IRCTab { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | /* IRCTab implementation */ | 31 | /* IRCTab implementation */ |
32 | IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 32 | IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
33 | ~IRCQueryTab(); | 33 | ~IRCQueryTab(); |
34 | QString title(); | 34 | QString title(); |
35 | IRCSession *session(); | 35 | IRCSession *session(); |
36 | IRCPerson *person(); | 36 | IRCPerson *person(); |
37 | void appendText(QString text); | 37 | void appendText(QString text); |
38 | public slots: | 38 | public slots: |
39 | void remove(); | 39 | void remove(); |
40 | void processCommand(); | 40 | void processCommand(); |
41 | void display(IRCOutput output); | 41 | void display(IRCOutput output); |
42 | void settingsChanged(); | ||
42 | protected: | 43 | protected: |
43 | bool m_close; | 44 | bool m_close; |
44 | MainWindow *m_mainWindow; | 45 | MainWindow *m_mainWindow; |
45 | IRCServerTab *m_parentTab; | 46 | IRCServerTab *m_parentTab; |
46 | IRCPerson *m_person; | 47 | IRCPerson *m_person; |
47 | QTextView *m_textview; | 48 | QTextView *m_textview; |
48 | QLineEdit *m_field; | 49 | QLineEdit *m_field; |
49 | }; | 50 | }; |
50 | 51 | ||
51 | #endif /* __IRCQUERYTAB_H */ | 52 | #endif /* __IRCQUERYTAB_H */ |
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp index c3a444d..5e916ae 100644 --- a/noncore/net/opieirc/ircservereditor.cpp +++ b/noncore/net/opieirc/ircservereditor.cpp | |||
@@ -1,76 +1,77 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include "ircservereditor.h" | 4 | #include "ircservereditor.h" |
5 | 5 | ||
6 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { | 6 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { |
7 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); | 7 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); |
8 | QLabel *label = new QLabel(tr("Profile name :"), this); | 8 | QLabel *label = new QLabel(tr("Profile name :"), this); |
9 | m_name = new QLineEdit(server.name(), this); | 9 | m_name = new QLineEdit(server.name(), this); |
10 | layout->addWidget(label, 0, 0); | 10 | layout->addWidget(label, 0, 0); |
11 | layout->addWidget(m_name, 0, 1); | 11 | layout->addWidget(m_name, 0, 1); |
12 | label = new QLabel(tr("Hostname :"), this); | 12 | label = new QLabel(tr("Hostname :"), this); |
13 | m_hostname = new QLineEdit(server.hostname(), this); | 13 | m_hostname = new QLineEdit(server.hostname(), this); |
14 | layout->addWidget(label, 1, 0); | 14 | layout->addWidget(label, 1, 0); |
15 | layout->addWidget(m_hostname, 1, 1); | 15 | layout->addWidget(m_hostname, 1, 1); |
16 | label = new QLabel(tr("Port :"), this); | 16 | label = new QLabel(tr("Port :"), this); |
17 | m_port = new QLineEdit(QString::number(server.port()), this); | 17 | m_port = new QLineEdit(QString::number(server.port()), this); |
18 | layout->addWidget(label, 2, 0); | 18 | layout->addWidget(label, 2, 0); |
19 | layout->addWidget(m_port, 2, 1); | 19 | layout->addWidget(m_port, 2, 1); |
20 | label = new QLabel(tr("Nickname :"), this); | 20 | label = new QLabel(tr("Nickname :"), this); |
21 | m_nickname = new QLineEdit(server.nick(), this); | 21 | m_nickname = new QLineEdit(server.nick(), this); |
22 | layout->addWidget(label, 3, 0); | 22 | layout->addWidget(label, 3, 0); |
23 | layout->addWidget(m_nickname, 3, 1); | 23 | layout->addWidget(m_nickname, 3, 1); |
24 | label = new QLabel(tr("Realname :"), this); | 24 | label = new QLabel(tr("Realname :"), this); |
25 | m_realname = new QLineEdit(server.realname(), this); | 25 | m_realname = new QLineEdit(server.realname(), this); |
26 | layout->addWidget(label, 4, 0); | 26 | layout->addWidget(label, 4, 0); |
27 | layout->addWidget(m_realname, 4, 1); | 27 | layout->addWidget(m_realname, 4, 1); |
28 | label = new QLabel(tr("Password :"), this); | 28 | label = new QLabel(tr("Password :"), this); |
29 | m_password = new QLineEdit(server.password(), this); | 29 | m_password = new QLineEdit(server.password(), this); |
30 | layout->addWidget(label, 5, 0); | 30 | layout->addWidget(label, 5, 0); |
31 | layout->addWidget(m_password, 5, 1); | 31 | layout->addWidget(m_password, 5, 1); |
32 | label = new QLabel(tr("Channels :"), this); | 32 | label = new QLabel(tr("Channels :"), this); |
33 | m_channels = new QLineEdit(server.channels(), this); | 33 | m_channels = new QLineEdit(server.channels(), this); |
34 | layout->addWidget(label, 6, 0); | 34 | layout->addWidget(label, 6, 0); |
35 | layout->addWidget(m_channels, 6, 1); | 35 | layout->addWidget(m_channels, 6, 1); |
36 | setCaption(tr("Edit server information")); | ||
36 | showMaximized(); | 37 | showMaximized(); |
37 | } | 38 | } |
38 | 39 | ||
39 | 40 | ||
40 | void IRCServerEditor::accept() { | 41 | void IRCServerEditor::accept() { |
41 | if (m_name->text().length()==0) | 42 | if (m_name->text().length()==0) |
42 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); | 43 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); |
43 | else if (m_hostname->text().length()==0) | 44 | else if (m_hostname->text().length()==0) |
44 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); | 45 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); |
45 | else if (m_port->text().toInt()<=0) | 46 | else if (m_port->text().toInt()<=0) |
46 | QMessageBox::critical(this, tr("Error"), tr("Port required")); | 47 | QMessageBox::critical(this, tr("Error"), tr("Port required")); |
47 | else if (m_nickname->text().length()==0) | 48 | else if (m_nickname->text().length()==0) |
48 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); | 49 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); |
49 | else if (m_realname->text().length()==0) | 50 | else if (m_realname->text().length()==0) |
50 | QMessageBox::critical(this, tr("Error"), tr("Realname required")); | 51 | QMessageBox::critical(this, tr("Error"), tr("Realname required")); |
51 | else { | 52 | else { |
52 | /* Now verify whether the channel list has a valid format */ | 53 | /* Now verify whether the channel list has a valid format */ |
53 | QStringList channels = QStringList::split(QChar(','), m_channels->text()); | 54 | QStringList channels = QStringList::split(QChar(','), m_channels->text()); |
54 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { | 55 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { |
55 | QString channelName = (*it).stripWhiteSpace(); | 56 | QString channelName = (*it).stripWhiteSpace(); |
56 | if (!channelName.startsWith("#")) { | 57 | if (!channelName.startsWith("#")) { |
57 | QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'")); | 58 | QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'")); |
58 | return; | 59 | return; |
59 | } | 60 | } |
60 | } | 61 | } |
61 | QDialog::accept(); | 62 | QDialog::accept(); |
62 | } | 63 | } |
63 | } | 64 | } |
64 | 65 | ||
65 | IRCServer IRCServerEditor::getServer() { | 66 | IRCServer IRCServerEditor::getServer() { |
66 | IRCServer server; | 67 | IRCServer server; |
67 | server.setName(m_name->text()); | 68 | server.setName(m_name->text()); |
68 | server.setHostname(m_hostname->text()); | 69 | server.setHostname(m_hostname->text()); |
69 | server.setPort(m_port->text().toInt()); | 70 | server.setPort(m_port->text().toInt()); |
70 | server.setNick(m_nickname->text()); | 71 | server.setNick(m_nickname->text()); |
71 | server.setRealname(m_realname->text()); | 72 | server.setRealname(m_realname->text()); |
72 | server.setUsername(m_nickname->text()); | 73 | server.setUsername(m_nickname->text()); |
73 | server.setPassword(m_password->text()); | 74 | server.setPassword(m_password->text()); |
74 | server.setChannels(m_channels->text()); | 75 | server.setChannels(m_channels->text()); |
75 | return server; | 76 | return server; |
76 | } | 77 | } |
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp index e664ba1..3293591 100644 --- a/noncore/net/opieirc/ircserverlist.cpp +++ b/noncore/net/opieirc/ircserverlist.cpp | |||
@@ -1,133 +1,130 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <qlayout.h> | 1 | #include <qlayout.h> |
3 | #include <qlabel.h> | 2 | #include <qlabel.h> |
4 | #include <qhbox.h> | 3 | #include <qhbox.h> |
5 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
6 | #include "ircserverlist.h" | 5 | #include "ircserverlist.h" |
7 | #include "ircservereditor.h" | 6 | #include "ircservereditor.h" |
8 | #include <stdio.h> | ||
9 | 7 | ||
10 | class IRCListBoxServer : public QListBoxText { | 8 | class IRCListBoxServer : public QListBoxText { |
11 | public: | 9 | public: |
12 | IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { | 10 | IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { |
13 | m_server = server; | 11 | m_server = server; |
14 | } | 12 | } |
15 | 13 | ||
16 | IRCServer server() { | 14 | IRCServer server() { |
17 | return m_server; | 15 | return m_server; |
18 | } | 16 | } |
19 | 17 | ||
20 | void setServer(IRCServer server) { | 18 | void setServer(IRCServer server) { |
21 | m_server = server; | 19 | m_server = server; |
22 | setText(m_server.name()); | 20 | setText(m_server.name()); |
23 | } | 21 | } |
24 | protected: | 22 | protected: |
25 | IRCServer m_server; | 23 | IRCServer m_server; |
26 | }; | 24 | }; |
27 | 25 | ||
28 | IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { | 26 | IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { |
29 | QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); | 27 | QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); |
30 | setCaption(tr("Serverlist Browser")); | 28 | setCaption(tr("Serverlist Browser")); |
31 | QLabel *label = new QLabel(tr("Please choose a server profile"), this); | 29 | QLabel *label = new QLabel(tr("Please choose a server profile"), this); |
32 | label->setAlignment(AlignHCenter); | 30 | label->setAlignment(AlignHCenter); |
33 | layout->addWidget(label); | 31 | layout->addWidget(label); |
34 | m_list = new QListBox(this); | 32 | m_list = new QListBox(this); |
35 | layout->addWidget(m_list); | 33 | layout->addWidget(m_list); |
36 | QHBox *buttons = new QHBox(this); | 34 | QHBox *buttons = new QHBox(this); |
37 | QPushButton *del = new QPushButton(tr("Delete"), buttons); | 35 | QPushButton *del = new QPushButton(tr("Delete"), buttons); |
38 | QPushButton *edit = new QPushButton(tr("Edit"), buttons); | 36 | QPushButton *edit = new QPushButton(tr("Edit"), buttons); |
39 | QPushButton *add = new QPushButton(tr("Add"), buttons); | 37 | QPushButton *add = new QPushButton(tr("Add"), buttons); |
40 | connect(del, SIGNAL(clicked()), this, SLOT(delServer())); | 38 | connect(del, SIGNAL(clicked()), this, SLOT(delServer())); |
41 | connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); | 39 | connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); |
42 | connect(add, SIGNAL(clicked()), this, SLOT(addServer())); | 40 | connect(add, SIGNAL(clicked()), this, SLOT(addServer())); |
43 | layout->addWidget(buttons); | 41 | layout->addWidget(buttons); |
44 | /* Load the configuration file */ | 42 | /* Load the configuration file */ |
45 | m_config = new Config("OpieIRC"); | 43 | m_config = new Config("OpieIRC"); |
46 | m_config->setGroup("OpieIRC"); | 44 | m_config->setGroup("OpieIRC"); |
47 | int count = m_config->readNumEntry("ServerCount", 0); | 45 | int count = m_config->readNumEntry("ServerCount", 0); |
48 | if (count) { | 46 | if (count) { |
49 | for (int i=0; i<count; i++) { | 47 | for (int i=0; i<count; i++) { |
50 | m_config->setGroup("OpieIRC"); | 48 | m_config->setGroup("OpieIRC"); |
51 | QString name = m_config->readEntry("Server"+QString::number(i)); | 49 | QString name = m_config->readEntry("Server"+QString::number(i)); |
52 | if (name.length() > 0) { | 50 | if (name.length() > 0) { |
53 | IRCServer server; | 51 | IRCServer server; |
54 | m_config->setGroup(name); | 52 | m_config->setGroup(name); |
55 | server.setName(name); | 53 | server.setName(name); |
56 | server.setHostname(m_config->readEntry("Hostname")); | 54 | server.setHostname(m_config->readEntry("Hostname")); |
57 | server.setPort(m_config->readNumEntry("Port")); | 55 | server.setPort(m_config->readNumEntry("Port")); |
58 | server.setUsername(m_config->readEntry("Username")); | 56 | server.setUsername(m_config->readEntry("Username")); |
59 | server.setPassword(m_config->readEntry("Password")); | 57 | server.setPassword(m_config->readEntry("Password")); |
60 | server.setNick(m_config->readEntry("Nick")); | 58 | server.setNick(m_config->readEntry("Nick")); |
61 | server.setRealname(m_config->readEntry("Realname")); | 59 | server.setRealname(m_config->readEntry("Realname")); |
62 | server.setChannels(m_config->readEntry("Channels")); | 60 | server.setChannels(m_config->readEntry("Channels")); |
63 | m_list->insertItem(new IRCListBoxServer(server)); | 61 | m_list->insertItem(new IRCListBoxServer(server)); |
64 | } | 62 | } |
65 | } | 63 | } |
66 | } | 64 | } |
67 | 65 | ||
68 | showMaximized(); | 66 | showMaximized(); |
69 | } | 67 | } |
70 | 68 | ||
71 | void IRCServerList::addServer() { | 69 | void IRCServerList::addServer() { |
72 | IRCServer server; | 70 | IRCServer server; |
73 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); | 71 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); |
74 | if (editor.exec() == QDialog::Accepted) { | 72 | if (editor.exec() == QDialog::Accepted) { |
75 | server = editor.getServer(); | 73 | server = editor.getServer(); |
76 | /* Gets deleted by QListBox, so this is ok */ | 74 | /* Gets deleted by QListBox, so this is ok */ |
77 | m_list->insertItem(new IRCListBoxServer(server)); | 75 | m_list->insertItem(new IRCListBoxServer(server)); |
78 | } | 76 | } |
79 | } | 77 | } |
80 | 78 | ||
81 | void IRCServerList::delServer() { | 79 | void IRCServerList::delServer() { |
82 | int index = m_list->currentItem(); | 80 | int index = m_list->currentItem(); |
83 | if (index != -1) { | 81 | if (index != -1) { |
84 | m_list->removeItem(index); | 82 | m_list->removeItem(index); |
85 | } | 83 | } |
86 | } | 84 | } |
87 | 85 | ||
88 | void IRCServerList::editServer() { | 86 | void IRCServerList::editServer() { |
89 | int index = m_list->currentItem(); | 87 | int index = m_list->currentItem(); |
90 | if (index != -1) { | 88 | if (index != -1) { |
91 | IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); | 89 | IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); |
92 | IRCServer server = item->server(); | 90 | IRCServer server = item->server(); |
93 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); | 91 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); |
94 | if (editor.exec() == QDialog::Accepted) { | 92 | if (editor.exec() == QDialog::Accepted) { |
95 | server = editor.getServer(); | 93 | server = editor.getServer(); |
96 | item->setServer(server); | 94 | item->setServer(server); |
97 | } | 95 | } |
98 | } | 96 | } |
99 | } | 97 | } |
100 | 98 | ||
101 | int IRCServerList::exec() { | 99 | int IRCServerList::exec() { |
102 | int returncode = QDialog::exec(); | 100 | int returncode = QDialog::exec(); |
103 | /* Now save the changes */ | 101 | /* Now save the changes */ |
104 | m_config->setGroup("OpieIRC"); | 102 | m_config->setGroup("OpieIRC"); |
105 | m_config->clearGroup(); | ||
106 | m_config->writeEntry("ServerCount", QString::number(m_list->count())); | 103 | m_config->writeEntry("ServerCount", QString::number(m_list->count())); |
107 | for (unsigned int i=0; i<m_list->count(); i++) { | 104 | for (unsigned int i=0; i<m_list->count(); i++) { |
108 | IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); | 105 | IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); |
109 | m_config->setGroup("OpieIRC"); | 106 | m_config->setGroup("OpieIRC"); |
110 | m_config->writeEntry("Server"+QString::number(i), server.name()); | 107 | m_config->writeEntry("Server"+QString::number(i), server.name()); |
111 | m_config->setGroup(server.name()); | 108 | m_config->setGroup(server.name()); |
112 | m_config->writeEntry("Hostname", server.hostname()); | 109 | m_config->writeEntry("Hostname", server.hostname()); |
113 | m_config->writeEntry("Port", QString::number(server.port())); | 110 | m_config->writeEntry("Port", QString::number(server.port())); |
114 | m_config->writeEntry("Username", server.username()); | 111 | m_config->writeEntry("Username", server.username()); |
115 | m_config->writeEntry("Password", server.password()); | 112 | m_config->writeEntry("Password", server.password()); |
116 | m_config->writeEntry("Nick", server.nick()); | 113 | m_config->writeEntry("Nick", server.nick()); |
117 | m_config->writeEntry("Realname", server.realname()); | 114 | m_config->writeEntry("Realname", server.realname()); |
118 | m_config->writeEntry("Channels", server.channels()); | 115 | m_config->writeEntry("Channels", server.channels()); |
119 | } | 116 | } |
120 | return returncode; | 117 | return returncode; |
121 | } | 118 | } |
122 | 119 | ||
123 | bool IRCServerList::hasServer() { | 120 | bool IRCServerList::hasServer() { |
124 | return (m_list->currentItem() != -1); | 121 | return (m_list->currentItem() != -1); |
125 | } | 122 | } |
126 | 123 | ||
127 | IRCServer IRCServerList::server() { | 124 | IRCServer IRCServerList::server() { |
128 | return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); | 125 | return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); |
129 | } | 126 | } |
130 | 127 | ||
131 | IRCServerList::~IRCServerList() { | 128 | IRCServerList::~IRCServerList() { |
132 | delete m_config; | 129 | delete m_config; |
133 | } | 130 | } |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 8b8771f..4be60ef 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -1,243 +1,252 @@ | |||
1 | #include <stdio.h> | 1 | #include <qpe/config.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
4 | 4 | ||
5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
6 | m_server = server; | 6 | m_server = server; |
7 | m_session = new IRCSession(&m_server); | 7 | m_session = new IRCSession(&m_server); |
8 | m_mainWindow = mainWindow; | 8 | m_mainWindow = mainWindow; |
9 | m_close = FALSE; | 9 | m_close = FALSE; |
10 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); | 10 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); |
11 | m_textview = new QTextView(this); | 11 | m_textview = new QTextView(this); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_textview->setTextFormat(RichText); | 14 | m_textview->setTextFormat(RichText); |
15 | m_layout->add(m_textview); | 15 | m_layout->add(m_textview); |
16 | m_field = new QLineEdit(this); | 16 | m_field = new QLineEdit(this); |
17 | m_layout->add(m_field); | 17 | m_layout->add(m_field); |
18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
19 | m_field->setFocus(); | 19 | m_field->setFocus(); |
20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
21 | settingsChanged(); | ||
21 | } | 22 | } |
22 | 23 | ||
23 | void IRCServerTab::appendText(QString text) { | 24 | void IRCServerTab::appendText(QString text) { |
24 | /* not using append because it creates layout problems */ | 25 | /* not using append because it creates layout problems */ |
25 | m_textview->setText(m_textview->text() + text); | 26 | m_textview->setText(m_textview->text() + text); |
26 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
27 | } | 28 | } |
28 | 29 | ||
29 | IRCServerTab::~IRCServerTab() { | 30 | IRCServerTab::~IRCServerTab() { |
30 | delete m_session; | 31 | delete m_session; |
31 | } | 32 | } |
32 | 33 | ||
33 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { | 34 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { |
34 | m_channelTabs.remove(tab); | 35 | m_channelTabs.remove(tab); |
35 | } | 36 | } |
36 | 37 | ||
37 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { | 38 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { |
38 | m_queryTabs.remove(tab); | 39 | m_queryTabs.remove(tab); |
39 | } | 40 | } |
40 | 41 | ||
42 | void IRCServerTab::addQueryTab(IRCQueryTab *tab) { | ||
43 | m_queryTabs.append(tab); | ||
44 | } | ||
45 | |||
41 | QString IRCServerTab::title() { | 46 | QString IRCServerTab::title() { |
42 | return "Server"; | 47 | return "Server"; |
43 | } | 48 | } |
44 | 49 | ||
45 | IRCSession *IRCServerTab::session() { | 50 | IRCSession *IRCServerTab::session() { |
46 | return m_session; | 51 | return m_session; |
47 | } | 52 | } |
48 | 53 | ||
49 | IRCServer *IRCServerTab::server() { | 54 | IRCServer *IRCServerTab::server() { |
50 | return &m_server; | 55 | return &m_server; |
51 | } | 56 | } |
52 | 57 | ||
58 | void IRCServerTab::settingsChanged() { | ||
59 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | ||
60 | } | ||
61 | |||
53 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | 62 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { |
54 | QTextIStream stream(&line); | 63 | QTextIStream stream(&line); |
55 | QString command; | 64 | QString command; |
56 | stream >> command; | 65 | stream >> command; |
57 | command = command.upper().right(command.length()-1); | 66 | command = command.upper().right(command.length()-1); |
58 | 67 | ||
59 | if (command == "JOIN") { | 68 | if (command == "JOIN") { |
60 | QString channel; | 69 | QString channel; |
61 | stream >> channel; | 70 | stream >> channel; |
62 | if (channel.length() > 0 && channel.startsWith("#")) { | 71 | if (channel.length() > 0 && channel.startsWith("#")) { |
63 | m_session->join(channel); | 72 | m_session->join(channel); |
64 | } else { | 73 | } else { |
65 | tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); | 74 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); |
66 | } | 75 | } |
67 | } else if (command == "ME") { | 76 | } else if (command == "ME") { |
68 | QString text = line.right(line.length()-4); | 77 | QString text = line.right(line.length()-4); |
69 | if (text.length() > 0) { | 78 | if (text.length() > 0) { |
70 | if (tab->isA("IRCChannelTab")) { | 79 | if (tab->isA("IRCChannelTab")) { |
71 | tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 80 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
72 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); | 81 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); |
73 | } else if (tab->isA("IRCQueryTab")) { | 82 | } else if (tab->isA("IRCQueryTab")) { |
74 | tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 83 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
75 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); | 84 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); |
76 | } else { | 85 | } else { |
77 | tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>"); | 86 | tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); |
78 | } | 87 | } |
79 | } | 88 | } |
80 | } else if (command == "MSG") { | 89 | } else if (command == "MSG") { |
81 | QString nickname; | 90 | QString nickname; |
82 | stream >> nickname; | 91 | stream >> nickname; |
83 | if (nickname.length() > 0) { | 92 | if (nickname.length() > 0) { |
84 | if (line.length() > 6 + nickname.length()) { | 93 | if (line.length() > 6 + nickname.length()) { |
85 | QString text = line.right(line.length()-nickname.length()-6); | 94 | QString text = line.right(line.length()-nickname.length()-6); |
86 | IRCPerson person; | 95 | IRCPerson person; |
87 | person.setNick(nickname); | 96 | person.setNick(nickname); |
88 | tab->appendText("><font color=\"#0000dd\">"+IRCOutput::toHTML(nickname)+"</font>< "+IRCOutput::toHTML(text)+"<br>"); | 97 | tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+IRCOutput::toHTML(text)+"</font><br>"); |
89 | m_session->sendMessage(&person, text); | 98 | m_session->sendMessage(&person, text); |
90 | } | 99 | } |
91 | } | 100 | } |
92 | } else { | 101 | } else { |
93 | tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); | 102 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); |
94 | } | 103 | } |
95 | } | 104 | } |
96 | 105 | ||
97 | void IRCServerTab::processCommand() { | 106 | void IRCServerTab::processCommand() { |
98 | QString text = m_field->text(); | 107 | QString text = m_field->text(); |
99 | if (text.startsWith("/") && !text.startsWith("//")) { | 108 | if (text.startsWith("/") && !text.startsWith("//")) { |
100 | /* Command mode */ | 109 | /* Command mode */ |
101 | executeCommand(this, text); | 110 | executeCommand(this, text); |
102 | } | 111 | } |
103 | m_field->clear(); | 112 | m_field->clear(); |
104 | } | 113 | } |
105 | 114 | ||
106 | void IRCServerTab::doConnect() { | 115 | void IRCServerTab::doConnect() { |
107 | m_session->beginSession(); | 116 | m_session->beginSession(); |
108 | } | 117 | } |
109 | 118 | ||
110 | void IRCServerTab::remove() { | 119 | void IRCServerTab::remove() { |
111 | /* Close requested */ | 120 | /* Close requested */ |
112 | if (m_session->isSessionActive()) { | 121 | if (m_session->isSessionActive()) { |
113 | /* While there is a running session */ | 122 | /* While there is a running session */ |
114 | m_close = TRUE; | 123 | m_close = TRUE; |
115 | m_session->endSession(); | 124 | m_session->endSession(); |
116 | } else { | 125 | } else { |
117 | /* Session has previously been closed */ | 126 | /* Session has previously been closed */ |
118 | m_channelTabs.first(); | 127 | m_channelTabs.first(); |
119 | while (m_channelTabs.current() != 0) { | 128 | while (m_channelTabs.current() != 0) { |
120 | m_mainWindow->killTab(m_channelTabs.current()); | 129 | m_mainWindow->killTab(m_channelTabs.current()); |
121 | } | 130 | } |
122 | m_queryTabs.first(); | 131 | m_queryTabs.first(); |
123 | while (m_queryTabs.current() != 0) { | 132 | while (m_queryTabs.current() != 0) { |
124 | m_mainWindow->killTab(m_queryTabs.current()); | 133 | m_mainWindow->killTab(m_queryTabs.current()); |
125 | } | 134 | } |
126 | m_mainWindow->killTab(this); | 135 | m_mainWindow->killTab(this); |
127 | } | 136 | } |
128 | } | 137 | } |
129 | 138 | ||
130 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { | 139 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { |
131 | QListIterator<IRCChannelTab> it(m_channelTabs); | 140 | QListIterator<IRCChannelTab> it(m_channelTabs); |
132 | 141 | ||
133 | for (; it.current(); ++it) { | 142 | for (; it.current(); ++it) { |
134 | if (it.current()->channel() == channel) | 143 | if (it.current()->channel() == channel) |
135 | return it.current(); | 144 | return it.current(); |
136 | } | 145 | } |
137 | return 0; | 146 | return 0; |
138 | } | 147 | } |
139 | 148 | ||
140 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { | 149 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { |
141 | QListIterator<IRCQueryTab> it(m_queryTabs); | 150 | QListIterator<IRCQueryTab> it(m_queryTabs); |
142 | 151 | ||
143 | for (; it.current(); ++it) { | 152 | for (; it.current(); ++it) { |
144 | if (it.current()->person()->nick() == person->nick()) | 153 | if (it.current()->person()->nick() == person->nick()) |
145 | return it.current(); | 154 | return it.current(); |
146 | } | 155 | } |
147 | return 0; | 156 | return 0; |
148 | } | 157 | } |
149 | 158 | ||
150 | void IRCServerTab::display(IRCOutput output) { | 159 | void IRCServerTab::display(IRCOutput output) { |
151 | 160 | ||
152 | /* All messages to be displayed inside the GUI get here */ | 161 | /* All messages to be displayed inside the GUI get here */ |
153 | switch (output.type()) { | 162 | switch (output.type()) { |
154 | case OUTPUT_CONNCLOSE: | 163 | case OUTPUT_CONNCLOSE: |
155 | if (m_close) { | 164 | if (m_close) { |
156 | m_channelTabs.first(); | 165 | m_channelTabs.first(); |
157 | while (m_channelTabs.current() != 0) { | 166 | while (m_channelTabs.current() != 0) { |
158 | m_mainWindow->killTab(m_channelTabs.current()); | 167 | m_mainWindow->killTab(m_channelTabs.current()); |
159 | } | 168 | } |
160 | m_queryTabs.first(); | 169 | m_queryTabs.first(); |
161 | while (m_queryTabs.current() != 0) { | 170 | while (m_queryTabs.current() != 0) { |
162 | m_mainWindow->killTab(m_queryTabs.current()); | 171 | m_mainWindow->killTab(m_queryTabs.current()); |
163 | } | 172 | } |
164 | m_mainWindow->killTab(this); | 173 | m_mainWindow->killTab(this); |
165 | } else { | 174 | } else { |
166 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); | 175 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); |
167 | QListIterator<IRCChannelTab> it(m_channelTabs); | 176 | QListIterator<IRCChannelTab> it(m_channelTabs); |
168 | for (; it.current(); ++it) { | 177 | for (; it.current(); ++it) { |
169 | it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>"); | 178 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); |
170 | } | 179 | } |
171 | } | 180 | } |
172 | break; | 181 | break; |
173 | case OUTPUT_SELFJOIN: { | 182 | case OUTPUT_SELFJOIN: { |
174 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 183 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
175 | m_channelTabs.append(channeltab); | 184 | m_channelTabs.append(channeltab); |
176 | m_mainWindow->addTab(channeltab); | 185 | m_mainWindow->addTab(channeltab); |
177 | } | 186 | } |
178 | break; | 187 | break; |
179 | case OUTPUT_CHANPRIVMSG: { | 188 | case OUTPUT_CHANPRIVMSG: { |
180 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 189 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
181 | channelTab->appendText("<<font color=\"#0000dd\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font>> "+output.htmlMessage()+"<br>"); | 190 | channelTab->appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage()+"</font><br>"); |
182 | } | 191 | } |
183 | break; | 192 | break; |
184 | case OUTPUT_QUERYACTION: | 193 | case OUTPUT_QUERYACTION: |
185 | case OUTPUT_QUERYPRIVMSG: { | 194 | case OUTPUT_QUERYPRIVMSG: { |
186 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); | 195 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); |
187 | if (!queryTab) { | 196 | if (!queryTab) { |
188 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 197 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
189 | m_queryTabs.append(queryTab); | 198 | m_queryTabs.append(queryTab); |
190 | m_mainWindow->addTab(queryTab); | 199 | m_mainWindow->addTab(queryTab); |
191 | } | 200 | } |
192 | queryTab->display(output); | 201 | queryTab->display(output); |
193 | } | 202 | } |
194 | break; | 203 | break; |
195 | case OUTPUT_SELFPART: { | 204 | case OUTPUT_SELFPART: { |
196 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 205 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
197 | if (channelTab) | 206 | if (channelTab) |
198 | m_mainWindow->killTab(channelTab); | 207 | m_mainWindow->killTab(channelTab); |
199 | } | 208 | } |
200 | break; | 209 | break; |
201 | case OUTPUT_SELFKICK: { | 210 | case OUTPUT_SELFKICK: { |
202 | appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>"); | 211 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
203 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 212 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
204 | if (channelTab) | 213 | if (channelTab) |
205 | m_mainWindow->killTab(channelTab); | 214 | m_mainWindow->killTab(channelTab); |
206 | } | 215 | } |
207 | break; | 216 | break; |
208 | case OUTPUT_CHANACTION: { | 217 | case OUTPUT_CHANACTION: { |
209 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 218 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
210 | channelTab->appendText("<font color=\"#cc0000\">"+output.htmlMessage()+"</font><br>"); | 219 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); |
211 | } | 220 | } |
212 | break; | 221 | break; |
213 | case OUTPUT_QUIT: { | 222 | case OUTPUT_QUIT: { |
214 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | 223 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); |
215 | QListIterator<IRCChannelTab> it(m_channelTabs); | 224 | QListIterator<IRCChannelTab> it(m_channelTabs); |
216 | for (; it.current(); ++it) { | 225 | for (; it.current(); ++it) { |
217 | if (it.current()->list()->hasPerson(nick)) { | 226 | if (it.current()->list()->hasPerson(nick)) { |
218 | it.current()->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>"); | 227 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
219 | it.current()->list()->update(); | 228 | it.current()->list()->update(); |
220 | } | 229 | } |
221 | } | 230 | } |
222 | } | 231 | } |
223 | break; | 232 | break; |
224 | case OUTPUT_OTHERJOIN: | 233 | case OUTPUT_OTHERJOIN: |
225 | case OUTPUT_OTHERKICK: | 234 | case OUTPUT_OTHERKICK: |
226 | case OUTPUT_CHANPERSONMODE: | 235 | case OUTPUT_CHANPERSONMODE: |
227 | case OUTPUT_OTHERPART: { | 236 | case OUTPUT_OTHERPART: { |
228 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 237 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
229 | channelTab->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>"); | 238 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
230 | channelTab->list()->update(); | 239 | channelTab->list()->update(); |
231 | } | 240 | } |
232 | break; | 241 | break; |
233 | case OUTPUT_CTCP: | 242 | case OUTPUT_CTCP: |
234 | appendText("<font color=\"#00bb00\">" + output.htmlMessage() + "</font><br>"); | 243 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); |
235 | break; | 244 | break; |
236 | case OUTPUT_ERROR: | 245 | case OUTPUT_ERROR: |
237 | appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>"); | 246 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
238 | break; | 247 | break; |
239 | default: | 248 | default: |
240 | appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "</font><br>"); | 249 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); |
241 | break; | 250 | break; |
242 | } | 251 | } |
243 | } | 252 | } |
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h index e439d84..698689a 100644 --- a/noncore/net/opieirc/ircservertab.h +++ b/noncore/net/opieirc/ircservertab.h | |||
@@ -1,70 +1,73 @@ | |||
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 | 23 | ||
24 | #include "irctab.h" | 24 | #include "irctab.h" |
25 | #include "ircsession.h" | 25 | #include "ircsession.h" |
26 | #include "mainwindow.h" | 26 | #include "mainwindow.h" |
27 | #include "ircchanneltab.h" | 27 | #include "ircchanneltab.h" |
28 | #include "ircquerytab.h" | 28 | #include "ircquerytab.h" |
29 | 29 | ||
30 | class IRCServerTab : public IRCTab { | 30 | class IRCServerTab : public IRCTab { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | /* IRCTab implementation */ | 33 | /* IRCTab implementation */ |
34 | IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 34 | IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
35 | ~IRCServerTab(); | 35 | ~IRCServerTab(); |
36 | QString title(); | 36 | QString title(); |
37 | IRCSession *session(); | 37 | IRCSession *session(); |
38 | IRCServer *server(); | 38 | IRCServer *server(); |
39 | 39 | ||
40 | /* Start the server session */ | 40 | /* Start the server session */ |
41 | void doConnect(); | 41 | void doConnect(); |
42 | /* Remove tabs from the internal tab lists */ | 42 | /* Remove tabs from the internal tab lists */ |
43 | void removeChannelTab(IRCChannelTab *tab); | 43 | void removeChannelTab(IRCChannelTab *tab); |
44 | void removeQueryTab(IRCQueryTab *tab); | 44 | void removeQueryTab(IRCQueryTab *tab); |
45 | 45 | /* Return tabs from the internal tab lists */ | |
46 | /* Execute a user command such as /join */ | 46 | IRCChannelTab *getTabForChannel(IRCChannel *channel); |
47 | IRCQueryTab *getTabForQuery(IRCPerson *person); | ||
48 | /* Add tabs to the internal tab lists */ | ||
49 | void addQueryTab(IRCQueryTab *tab); | ||
50 | /* Execute a user command such as /join, /msg etc */ | ||
47 | void executeCommand(IRCTab *tab, QString line); | 51 | void executeCommand(IRCTab *tab, QString line); |
48 | protected: | 52 | protected: |
49 | void appendText(QString text); | 53 | void appendText(QString text); |
50 | IRCChannelTab *getTabForChannel(IRCChannel *channel); | ||
51 | IRCQueryTab *getTabForQuery(IRCPerson *person); | ||
52 | public slots: | 54 | public slots: |
53 | void remove(); | 55 | void remove(); |
54 | void processCommand(); | 56 | void processCommand(); |
57 | void settingsChanged(); | ||
55 | protected slots: | 58 | protected slots: |
56 | void display(IRCOutput output); | 59 | void display(IRCOutput output); |
57 | protected: | 60 | protected: |
58 | bool m_close; | 61 | bool m_close; |
59 | IRCServer m_server; | 62 | IRCServer m_server; |
60 | IRCSession *m_session; | 63 | IRCSession *m_session; |
61 | MainWindow *m_mainWindow; | 64 | MainWindow *m_mainWindow; |
62 | QTextView *m_textview; | 65 | QTextView *m_textview; |
63 | QLineEdit *m_field; | 66 | QLineEdit *m_field; |
64 | /* Channel tabs associated with this server tab */ | 67 | /* Channel tabs associated with this server tab */ |
65 | QList<IRCChannelTab> m_channelTabs; | 68 | QList<IRCChannelTab> m_channelTabs; |
66 | /* Query tabs associated with this server tab */ | 69 | /* Query tabs associated with this server tab */ |
67 | QList<IRCQueryTab> m_queryTabs; | 70 | QList<IRCQueryTab> m_queryTabs; |
68 | }; | 71 | }; |
69 | 72 | ||
70 | #endif /* __IRCSERVERTAB_H */ | 73 | #endif /* __IRCSERVERTAB_H */ |
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp new file mode 100644 index 0000000..d1fef67 --- a/dev/null +++ b/noncore/net/opieirc/ircsettings.cpp | |||
@@ -0,0 +1,71 @@ | |||
1 | #include <qlayout.h> | ||
2 | #include "ircsettings.h" | ||
3 | #include "irctab.h" | ||
4 | #include "ircmisc.h" | ||
5 | #include <stdio.h> | ||
6 | |||
7 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { | ||
8 | m_config = new Config("OpieIRC"); | ||
9 | m_config->setGroup("OpieIRC"); | ||
10 | |||
11 | setCaption("Settings"); | ||
12 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 0); | ||
13 | QLabel *label = new QLabel(tr("Background color :"), this); | ||
14 | layout->addWidget(label, 0, 0); | ||
15 | m_background = new IRCFramedColorLabel(QColor(m_config->readEntry("BackgroundColor", "#FFFFFF")), this); | ||
16 | layout->addWidget(m_background, 0, 1); | ||
17 | label = new QLabel(tr("Normal text color :"), this); | ||
18 | layout->addWidget(label, 1, 0); | ||
19 | m_text = new IRCFramedColorLabel(m_config->readEntry("TextColor", "#000000"), this); | ||
20 | layout->addWidget(m_text, 1, 1); | ||
21 | label = new QLabel(tr("Error color :"), this); | ||
22 | layout->addWidget(label, 2, 0); | ||
23 | m_error = new IRCFramedColorLabel(m_config->readEntry("ErrorColor", "#FF0000"), this); | ||
24 | layout->addWidget(m_error, 2, 1); | ||
25 | label = new QLabel(tr("Text written by yourself :"), this); | ||
26 | layout->addWidget(label, 3, 0); | ||
27 | m_self = new IRCFramedColorLabel(m_config->readEntry("SelfColor", "#CC0000"), this); | ||
28 | layout->addWidget(m_self, 3, 1); | ||
29 | label = new QLabel(tr("Text written by others :"), this); | ||
30 | layout->addWidget(label, 4, 0); | ||
31 | m_other = new IRCFramedColorLabel(m_config->readEntry("OtherColor", "#0000BB"), this); | ||
32 | layout->addWidget(m_other, 4, 1); | ||
33 | label = new QLabel(tr("Text written by the server :"), this); | ||
34 | layout->addWidget(label, 5, 0); | ||
35 | m_server = new IRCFramedColorLabel(m_config->readEntry("ServerColor", "#0000FF"), this); | ||
36 | layout->addWidget(m_server, 5, 1); | ||
37 | label = new QLabel(tr("Notifications :"), this); | ||
38 | layout->addWidget(label, 6, 0); | ||
39 | m_notification = new IRCFramedColorLabel(m_config->readEntry("NotificationColor", "#AAE300"), this); | ||
40 | layout->addWidget(m_notification, 6, 1); | ||
41 | showMaximized(); | ||
42 | } | ||
43 | |||
44 | QString IRCSettings::getColorString(QWidget *widget) { | ||
45 | QColor color = ((IRCFramedColorLabel *)widget)->color(); | ||
46 | QString temp; | ||
47 | temp.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue()); | ||
48 | return temp; | ||
49 | } | ||
50 | |||
51 | void IRCSettings::accept() { | ||
52 | IRCTab::m_backgroundColor = getColorString(m_background); | ||
53 | IRCTab::m_textColor = getColorString(m_text); | ||
54 | IRCTab::m_errorColor = getColorString(m_error); | ||
55 | IRCTab::m_selfColor = getColorString(m_self); | ||
56 | IRCTab::m_otherColor = getColorString(m_other); | ||
57 | IRCTab::m_serverColor = getColorString(m_server); | ||
58 | IRCTab::m_notificationColor = getColorString(m_notification); | ||
59 | m_config->writeEntry("BackgroundColor", getColorString(m_background)); | ||
60 | m_config->writeEntry("TextColor", getColorString(m_text)); | ||
61 | m_config->writeEntry("ErrorColor", getColorString(m_error)); | ||
62 | m_config->writeEntry("SelfColor", getColorString(m_self)); | ||
63 | m_config->writeEntry("OtherColor", getColorString(m_other)); | ||
64 | m_config->writeEntry("ServerColor", getColorString(m_server)); | ||
65 | m_config->writeEntry("NotificationColor", getColorString(m_notification)); | ||
66 | QDialog::accept(); | ||
67 | } | ||
68 | |||
69 | IRCSettings::~IRCSettings() { | ||
70 | delete m_config; | ||
71 | } | ||
diff --git a/noncore/net/opieirc/ircsettings.h b/noncore/net/opieirc/ircsettings.h new file mode 100644 index 0000000..1d3aeb7 --- a/dev/null +++ b/noncore/net/opieirc/ircsettings.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | OpieIRC - An embedded IRC client | ||
3 | Copyright (C) 2002 Wenzel Jakob | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | |||
19 | */ | ||
20 | |||
21 | #ifndef __IRCSETTINGS_H | ||
22 | #define __IRCSETTINGS_H | ||
23 | |||
24 | #include <qpe/config.h> | ||
25 | #include <qdialog.h> | ||
26 | |||
27 | class IRCSettings : public QDialog { | ||
28 | Q_OBJECT | ||
29 | public: | ||
30 | IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); | ||
31 | QString getColorString(QWidget *widget); | ||
32 | ~IRCSettings(); | ||
33 | protected slots: | ||
34 | void accept(); | ||
35 | protected: | ||
36 | Config *m_config; | ||
37 | QWidget *m_background; | ||
38 | QWidget *m_text; | ||
39 | QWidget *m_error; | ||
40 | QWidget *m_self; | ||
41 | QWidget *m_server; | ||
42 | QWidget *m_other; | ||
43 | QWidget *m_notification; | ||
44 | }; | ||
45 | |||
46 | #endif /* __IRCSETTINGS_H */ | ||
diff --git a/noncore/net/opieirc/irctab.cpp b/noncore/net/opieirc/irctab.cpp index 653a5de..6b578d1 100644 --- a/noncore/net/opieirc/irctab.cpp +++ b/noncore/net/opieirc/irctab.cpp | |||
@@ -1,19 +1,28 @@ | |||
1 | #include <qpe/resource.h> | 1 | #include <qpe/resource.h> |
2 | #include <qpixmap.h> | 2 | #include <qpixmap.h> |
3 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
4 | #include "irctab.h" | 4 | #include "irctab.h" |
5 | 5 | ||
6 | QString IRCTab::m_errorColor; | ||
7 | QString IRCTab::m_serverColor; | ||
8 | QString IRCTab::m_textColor; | ||
9 | QString IRCTab::m_backgroundColor; | ||
10 | QString IRCTab::m_selfColor; | ||
11 | QString IRCTab::m_otherColor; | ||
12 | QString IRCTab::m_notificationColor; | ||
13 | |||
14 | |||
6 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { | 15 | IRCTab::IRCTab(QWidget *parent, const char *name, WFlags f) : QWidget(parent, name, f) { |
7 | m_layout = new QVBoxLayout(this); | 16 | m_layout = new QVBoxLayout(this); |
8 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); | 17 | QHBoxLayout *descLayout = new QHBoxLayout(m_layout); |
9 | descLayout->setMargin(5); | 18 | descLayout->setMargin(5); |
10 | m_description = new QLabel(tr("Missing description"), this); | 19 | m_description = new QLabel(tr("Missing description"), this); |
11 | descLayout->addWidget(m_description); | 20 | descLayout->addWidget(m_description); |
12 | descLayout->setStretchFactor(m_description, 5); | 21 | descLayout->setStretchFactor(m_description, 5); |
13 | QPushButton *close = new QPushButton(this); | 22 | QPushButton *close = new QPushButton(this); |
14 | close->setPixmap(Resource::loadPixmap("close")); | 23 | close->setPixmap(Resource::loadPixmap("close")); |
15 | connect(close, SIGNAL(clicked()), this, SLOT(remove())); | 24 | connect(close, SIGNAL(clicked()), this, SLOT(remove())); |
16 | descLayout->addWidget(close); | 25 | descLayout->addWidget(close); |
17 | descLayout->setStretchFactor(m_description, 1); | 26 | descLayout->setStretchFactor(m_description, 1); |
18 | } | 27 | } |
19 | 28 | ||
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h index 0ce9777..248ea13 100644 --- a/noncore/net/opieirc/irctab.h +++ b/noncore/net/opieirc/irctab.h | |||
@@ -1,48 +1,58 @@ | |||
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 | ||
34 | class IRCTab : public QWidget { | 34 | class IRCTab : public QWidget { |
35 | Q_OBJECT | 35 | Q_OBJECT |
36 | public: | 36 | public: |
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 | virtual QString title() = 0; | 38 | virtual QString title() = 0; |
39 | virtual IRCSession *session() = 0; | 39 | virtual IRCSession *session() = 0; |
40 | virtual void appendText(QString text) = 0; | 40 | virtual void appendText(QString text) = 0; |
41 | public slots: | 41 | public slots: |
42 | virtual void remove() = 0; | 42 | virtual void remove() = 0; |
43 | virtual void settingsChanged() = 0; | ||
43 | protected: | 44 | protected: |
44 | QLabel *m_description; | 45 | QLabel *m_description; |
45 | QVBoxLayout *m_layout; | 46 | QVBoxLayout *m_layout; |
47 | public: | ||
48 | /* Configuration shared accross all instances - contains HTML style colors (#rrggbb) */ | ||
49 | static QString m_errorColor; | ||
50 | static QString m_serverColor; | ||
51 | static QString m_textColor; | ||
52 | static QString m_backgroundColor; | ||
53 | static QString m_selfColor; | ||
54 | static QString m_otherColor; | ||
55 | static QString m_notificationColor; | ||
46 | }; | 56 | }; |
47 | 57 | ||
48 | #endif /* __IRCTAB_H */ | 58 | #endif /* __IRCTAB_H */ |
diff --git a/noncore/net/opieirc/ircversion.h b/noncore/net/opieirc/ircversion.h index f8510e6..f0f196e 100644 --- a/noncore/net/opieirc/ircversion.h +++ b/noncore/net/opieirc/ircversion.h | |||
@@ -1,27 +1,27 @@ | |||
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 __IRCVERSION_H | 21 | #ifndef __IRCVERSION_H |
22 | #define __IRCVERSION_H | 22 | #define __IRCVERSION_H |
23 | 23 | ||
24 | #define APP_VERSION "OpieIRC 0.2" | 24 | #define APP_VERSION "OpieIRC 0.3" |
25 | #define APP_COPYSTR "(c) 2002 by Wenzel Jakob" | 25 | #define APP_COPYSTR "(c) 2002 by Wenzel Jakob" |
26 | 26 | ||
27 | #endif /* __IRCVERSION_H */ | 27 | #endif /* __IRCVERSION_H */ |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index af4ce78..d78e5ab 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -1,55 +1,71 @@ | |||
1 | #include <qpe/qpemenubar.h> | 1 | #include <qpe/qpemenubar.h> |
2 | #include <qpe/resource.h> | 2 | #include <qpe/resource.h> |
3 | #include <qpe/config.h> | 3 | #include <qpe/config.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | 5 | ||
6 | #include "mainwindow.h" | 6 | #include "mainwindow.h" |
7 | #include "ircservertab.h" | 7 | #include "ircservertab.h" |
8 | #include "ircserverlist.h" | 8 | #include "ircserverlist.h" |
9 | #include "ircsettings.h" | ||
9 | 10 | ||
10 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { | 11 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { |
11 | setCaption(tr("IRC Client")); | 12 | setCaption(tr("IRC Client")); |
12 | m_tabWidget = new QTabWidget(this); | 13 | m_tabWidget = new QTabWidget(this); |
13 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabSelected(QWidget *))); | ||
14 | setCentralWidget(m_tabWidget); | 14 | setCentralWidget(m_tabWidget); |
15 | setToolBarsMovable(FALSE); | 15 | setToolBarsMovable(FALSE); |
16 | QPEMenuBar *menuBar = new QPEMenuBar(this); | 16 | QPEMenuBar *menuBar = new QPEMenuBar(this); |
17 | QPopupMenu *irc = new QPopupMenu(this); | 17 | QPopupMenu *irc = new QPopupMenu(this); |
18 | menuBar->insertItem(tr("IRC"), irc); | 18 | menuBar->insertItem(tr("IRC"), irc); |
19 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); | 19 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); |
20 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | 20 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); |
21 | a->addTo(irc); | 21 | a->addTo(irc); |
22 | a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); | ||
23 | connect(a, SIGNAL(activated()), this, SLOT(settings())); | ||
24 | a->addTo(irc); | ||
25 | loadSettings(); | ||
22 | } | 26 | } |
23 | 27 | ||
24 | void MainWindow::tabSelected(QWidget *) { | 28 | void MainWindow::loadSettings() { |
25 | } | 29 | Config config("OpieIRC"); |
26 | 30 | config.setGroup("OpieIRC"); | |
27 | void MainWindow::closeTab() { | 31 | IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); |
28 | /* Does not directly close the tab but triggers an action | 32 | IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); |
29 | which at some point will close the tab using a callback */ | 33 | IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); |
30 | IRCTab *tab = (IRCTab *)m_tabWidget->currentPage(); | 34 | IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); |
31 | if (tab) { | 35 | IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); |
32 | tab->remove(); | 36 | IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); |
33 | } | 37 | IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); |
34 | } | 38 | } |
35 | 39 | ||
36 | void MainWindow::addTab(IRCTab *tab) { | 40 | void MainWindow::addTab(IRCTab *tab) { |
37 | m_tabWidget->addTab(tab, tab->title()); | 41 | m_tabWidget->addTab(tab, tab->title()); |
38 | m_tabWidget->showPage(tab); | 42 | m_tabWidget->showPage(tab); |
39 | tabSelected(tab); | 43 | m_tabs.append(tab); |
40 | } | 44 | } |
41 | 45 | ||
42 | void MainWindow::killTab(IRCTab *tab) { | 46 | void MainWindow::killTab(IRCTab *tab) { |
43 | m_tabWidget->removePage(tab); | 47 | m_tabWidget->removePage(tab); |
48 | m_tabs.remove(tab); | ||
44 | /* there might be nicer ways to do this .. */ | 49 | /* there might be nicer ways to do this .. */ |
45 | delete tab; | 50 | delete tab; |
46 | } | 51 | } |
47 | 52 | ||
48 | void MainWindow::newConnection() { | 53 | void MainWindow::newConnection() { |
49 | IRCServerList list(this, "ServerList", TRUE); | 54 | IRCServerList list(this, "ServerList", TRUE); |
50 | if (list.exec() == QDialog::Accepted && list.hasServer()) { | 55 | if (list.exec() == QDialog::Accepted && list.hasServer()) { |
51 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); | 56 | IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); |
52 | addTab(serverTab); | 57 | addTab(serverTab); |
53 | serverTab->doConnect(); | 58 | serverTab->doConnect(); |
54 | } | 59 | } |
55 | } | 60 | } |
61 | |||
62 | void MainWindow::settings() { | ||
63 | IRCSettings settings(this, "Settings", TRUE); | ||
64 | if (settings.exec() == QDialog::Accepted) { | ||
65 | QListIterator<IRCTab> it(m_tabs); | ||
66 | for (; it.current(); ++it) { | ||
67 | /* Inform all tabs about the new settings */ | ||
68 | it.current()->settingsChanged(); | ||
69 | } | ||
70 | } | ||
71 | } | ||
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h index dcb782f..d057178 100644 --- a/noncore/net/opieirc/mainwindow.h +++ b/noncore/net/opieirc/mainwindow.h | |||
@@ -1,45 +1,48 @@ | |||
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 <qtabwidget.h> | 27 | #include <qtabwidget.h> |
27 | #include "mainwindow.h" | 28 | #include "mainwindow.h" |
28 | #include "irctab.h" | 29 | #include "irctab.h" |
29 | 30 | ||
30 | class MainWindow : public QMainWindow { | 31 | class MainWindow : public QMainWindow { |
31 | Q_OBJECT | 32 | Q_OBJECT |
32 | public: | 33 | public: |
33 | MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); | 34 | MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); |
34 | 35 | ||
35 | void addTab(IRCTab *tab); | 36 | void addTab(IRCTab *tab); |
36 | void killTab(IRCTab *tab); | 37 | void killTab(IRCTab *tab); |
37 | protected slots: | 38 | protected slots: |
38 | void newConnection(); | 39 | void newConnection(); |
39 | void closeTab(); | 40 | void settings(); |
40 | void tabSelected(QWidget *widget); | 41 | protected: |
42 | void loadSettings(); | ||
41 | protected: | 43 | protected: |
42 | QTabWidget *m_tabWidget; | 44 | QTabWidget *m_tabWidget; |
45 | QList<IRCTab> m_tabs; | ||
43 | }; | 46 | }; |
44 | 47 | ||
45 | #endif /* __MAINWINDOW_H */ | 48 | #endif /* __MAINWINDOW_H */ |
diff --git a/noncore/net/opieirc/opieirc.pro b/noncore/net/opieirc/opieirc.pro index 0e188e4..37742f5 100644 --- a/noncore/net/opieirc/opieirc.pro +++ b/noncore/net/opieirc/opieirc.pro | |||
@@ -1,24 +1,24 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = ircchannel.h ircconnection.h \ | 4 | HEADERS = ircchannel.h ircconnection.h \ |
5 | ircmessage.h \ | 5 | ircmessage.h \ |
6 | ircmessageparser.h ircoutput.h \ | 6 | ircmessageparser.h ircoutput.h \ |
7 | ircperson.h ircserver.h ircsession.h \ | 7 | ircperson.h ircserver.h ircsession.h \ |
8 | mainwindow.h irctab.h ircservertab.h \ | 8 | mainwindow.h irctab.h ircservertab.h \ |
9 | ircchanneltab.h ircchannellist.h \ | 9 | ircchanneltab.h ircchannellist.h \ |
10 | ircserverlist.h ircservereditor.h \ | 10 | ircserverlist.h ircservereditor.h \ |
11 | ircquerytab.h | 11 | ircquerytab.h ircsettings.h ircmisc.h |
12 | SOURCES = ircchannel.cpp ircconnection.cpp \ | 12 | SOURCES = ircchannel.cpp ircconnection.cpp \ |
13 | ircmessage.cpp \ | 13 | ircmessage.cpp \ |
14 | ircmessageparser.cpp ircoutput.cpp \ | 14 | ircmessageparser.cpp ircoutput.cpp \ |
15 | ircperson.cpp ircserver.cpp \ | 15 | ircperson.cpp ircserver.cpp \ |
16 | ircsession.cpp main.cpp mainwindow.cpp \ | 16 | ircsession.cpp main.cpp mainwindow.cpp \ |
17 | irctab.cpp ircservertab.cpp \ | 17 | irctab.cpp ircservertab.cpp \ |
18 | ircchanneltab.cpp ircchannellist.cpp \ | 18 | ircchanneltab.cpp ircchannellist.cpp \ |
19 | ircserverlist.cpp ircservereditor.cpp \ | 19 | ircserverlist.cpp ircservereditor.cpp \ |
20 | ircquerytab.cpp | 20 | ircquerytab.cpp ircsettings.cpp ircmisc.cpp |
21 | INCLUDEPATH += $(OPIEDIR)/include | 21 | INCLUDEPATH += $(OPIEDIR)/include |
22 | DEPENDPATH+= $(OPIEDIR)/include | 22 | DEPENDPATH+= $(OPIEDIR)/include |
23 | LIBS += -lqpe | 23 | LIBS += -lqpe -lopie |
24 | 24 | ||