summaryrefslogtreecommitdiff
authorar <ar>2004-09-09 14:08:16 (UTC)
committer ar <ar>2004-09-09 14:08:16 (UTC)
commit4e798036b423bcb8800f125357591e48b84594c8 (patch) (unidiff)
tree910654191df3bbf0972a35c05b3057455f895a81
parentb3259d2dcf3599828a4eaa0d8de8148ca1839aef (diff)
downloadopie-4e798036b423bcb8800f125357591e48b84594c8.zip
opie-4e798036b423bcb8800f125357591e48b84594c8.tar.gz
opie-4e798036b423bcb8800f125357591e48b84594c8.tar.bz2
- fix compile problems
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp2
-rw-r--r--noncore/net/opieirc/ircservertab.cpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index 7610058..581f9a5 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,189 +1,191 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qwhatsthis.h> 2#include <qwhatsthis.h>
3#include <qhbox.h> 3#include <qhbox.h>
4
4#include "ircchanneltab.h" 5#include "ircchanneltab.h"
5#include "ircservertab.h" 6#include "ircservertab.h"
7#include "ircmessageparser.h"
6 8
7IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 9IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
8 m_mainWindow = mainWindow; 10 m_mainWindow = mainWindow;
9 m_parentTab = parentTab; 11 m_parentTab = parentTab;
10 m_channel = channel; 12 m_channel = channel;
11 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 13 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
12 QHBox *hbox = new QHBox(this); 14 QHBox *hbox = new QHBox(this);
13 m_textview = new QTextView(hbox); 15 m_textview = new QTextView(hbox);
14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 16 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 17 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_listVisible = TRUE; 18 m_listVisible = TRUE;
17 m_listButton = new QPushButton(">", m_textview); 19 m_listButton = new QPushButton(">", m_textview);
18 m_listButton->setFlat( true ); 20 m_listButton->setFlat( true );
19 m_textview->setCornerWidget(m_listButton); 21 m_textview->setCornerWidget(m_listButton);
20 m_textview->setTextFormat(RichText); 22 m_textview->setTextFormat(RichText);
21 QWhatsThis::add(m_textview, tr("Channel discussion")); 23 QWhatsThis::add(m_textview, tr("Channel discussion"));
22 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 24 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
23 m_list = new IRCChannelList(m_channel, hbox); 25 m_list = new IRCChannelList(m_channel, hbox);
24 m_list->update(); 26 m_list->update();
25 m_list->setMaximumWidth(LISTWIDTH); 27 m_list->setMaximumWidth(LISTWIDTH);
26 m_field = new IRCHistoryLineEdit(this); 28 m_field = new IRCHistoryLineEdit(this);
27 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); 29 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
28 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); 30 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
29 connect(m_field, SIGNAL(closeTab()), this, SLOT(remove())); 31 connect(m_field, SIGNAL(closeTab()), this, SLOT(remove()));
30 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); 32 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
31 33
32 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); 34 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
33 m_popup = new QPopupMenu(m_list); 35 m_popup = new QPopupMenu(m_list);
34 m_lines = 0; 36 m_lines = 0;
35 /* Required so that embedded-style "right" clicks work */ 37 /* Required so that embedded-style "right" clicks work */
36 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 38 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
37 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); 39 connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&)));
38 /* Construct the popup menu */ 40 /* Construct the popup menu */
39 QPopupMenu *ctcpMenu = new QPopupMenu(m_list); 41 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
40 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); 42 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
41 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); 43 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
42 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); 44 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
43 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 45 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
44 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 46 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
45 m_layout->add(hbox); 47 m_layout->add(hbox);
46 hbox->show(); 48 hbox->show();
47 m_layout->add(m_field); 49 m_layout->add(m_field);
48 m_field->setFocus(); 50 m_field->setFocus();
49 m_field->setActiveWindow(); 51 m_field->setActiveWindow();
50 52
51 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 53 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
52 connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) )); 54 connect(m_list, SIGNAL(doubleClicked ( QListBoxItem * ) ), this, SLOT(popupQuery( QListBoxItem * ) ));
53 settingsChanged(); 55 settingsChanged();
54} 56}
55 57
56void IRCChannelTab::scrolling(){ 58void IRCChannelTab::scrolling(){
57 m_textview->ensureVisible(0, m_textview->contentsHeight()); 59 m_textview->ensureVisible(0, m_textview->contentsHeight());
58} 60}
59 61
60void IRCChannelTab::appendText(QString text) { 62void IRCChannelTab::appendText(QString text) {
61 /* not using append because it creates layout problems */ 63 /* not using append because it creates layout problems */
62 QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); 64 QString txt = m_textview->text() + IRCTab::appendTimestamp( text );
63 if (m_maxLines > 0 && m_lines >= m_maxLines) { 65 if (m_maxLines > 0 && m_lines >= m_maxLines) {
64 int firstBreak = txt.find('\n'); 66 int firstBreak = txt.find('\n');
65 if (firstBreak != -1) { 67 if (firstBreak != -1) {
66 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 68 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
67 } 69 }
68 } else { 70 } else {
69 m_lines++; 71 m_lines++;
70 } 72 }
71 m_textview->ensureVisible(0, m_textview->contentsHeight()); 73 m_textview->ensureVisible(0, m_textview->contentsHeight());
72 m_textview->setText(txt); 74 m_textview->setText(txt);
73 m_textview->ensureVisible(0, m_textview->contentsHeight()); 75 m_textview->ensureVisible(0, m_textview->contentsHeight());
74 76
75 int p1, p2; 77 int p1, p2;
76 if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) ) 78 if ( text.contains( IRCMessageParser::tr("Received a CTCP PING from ") ) )
77 emit ping( title() ); 79 emit ping( title() );
78 else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) { 80 else if ( (p1 = text.find("ping", 0, false) )!= -1 && (p2 = text.find( m_parentTab->server()->nick(), 0,false )) != -1 ) {
79 int col = text.findRev("color", -1, false); 81 int col = text.findRev("color", -1, false);
80 if ( col < p2 ) 82 if ( col < p2 )
81 emit ping( title() ); 83 emit ping( title() );
82 84
83 } 85 }
84 86
85 emit changed(this); 87 emit changed(this);
86} 88}
87 89
88IRCChannelTab::~IRCChannelTab() { 90IRCChannelTab::~IRCChannelTab() {
89 m_parentTab->removeChannelTab(this); 91 m_parentTab->removeChannelTab(this);
90} 92}
91 93
92void IRCChannelTab::processCommand() { 94void IRCChannelTab::processCommand() {
93 QString text = m_field->text(); 95 QString text = m_field->text();
94 if (text.length()>0) { 96 if (text.length()>0) {
95 if (session()->isSessionActive()) { 97 if (session()->isSessionActive()) {
96 if (text.startsWith("/") && !text.startsWith("//")) { 98 if (text.startsWith("/") && !text.startsWith("//")) {
97 /* Command mode */ 99 /* Command mode */
98 m_parentTab->executeCommand(this, text);; 100 m_parentTab->executeCommand(this, text);;
99 } else { 101 } else {
100 if (text.startsWith("//")) 102 if (text.startsWith("//"))
101 text = text.right(text.length()-1); 103 text = text.right(text.length()-1);
102 session()->sendMessage(m_channel, m_field->text()); 104 session()->sendMessage(m_channel, m_field->text());
103 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>"); 105 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
104 } 106 }
105 } else { 107 } else {
106 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 108 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
107 } 109 }
108 } 110 }
109 m_field->clear(); 111 m_field->clear();
110} 112}
111 113
112void IRCChannelTab::settingsChanged() { 114void IRCChannelTab::settingsChanged() {
113 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 115 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
114 m_lines = 0; 116 m_lines = 0;
115} 117}
116 118
117void IRCChannelTab::toggleList() { 119void IRCChannelTab::toggleList() {
118 if (m_listVisible) { 120 if (m_listVisible) {
119 m_list->setMaximumWidth(0); 121 m_list->setMaximumWidth(0);
120 m_listButton->setText("<"); 122 m_listButton->setText("<");
121 } else { 123 } else {
122 m_list->setMaximumWidth(LISTWIDTH); 124 m_list->setMaximumWidth(LISTWIDTH);
123 m_listButton->setText(">"); 125 m_listButton->setText(">");
124 } 126 }
125 m_listVisible = !m_listVisible; 127 m_listVisible = !m_listVisible;
126} 128}
127 129
128void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { 130void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
129 switch (mouse) { 131 switch (mouse) {
130 case 1: 132 case 1:
131 break; 133 break;
132 case 2: 134 case 2:
133 m_popup->popup(point); 135 m_popup->popup(point);
134 break; 136 break;
135 }; 137 };
136} 138}
137 139
138void IRCChannelTab::popupQuery( QListBoxItem *item) { 140void IRCChannelTab::popupQuery( QListBoxItem *item) {
139 if (item) { 141 if (item) {
140 IRCPerson *person = session()->getPerson(item->text()); 142 IRCPerson *person = session()->getPerson(item->text());
141 if (person) { 143 if (person) {
142 IRCQueryTab *tab = m_parentTab->getTabForQuery(person); 144 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
143 if (!tab) { 145 if (!tab) {
144 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); 146 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
145 m_parentTab->addQueryTab(tab); 147 m_parentTab->addQueryTab(tab);
146 m_mainWindow->addTab(tab); 148 m_mainWindow->addTab(tab);
147 } 149 }
148 } 150 }
149 } 151 }
150} 152}
151 153
152void IRCChannelTab::popupQuery() { 154void IRCChannelTab::popupQuery() {
153 if ( m_list->currentItem() != -1 ) 155 if ( m_list->currentItem() != -1 )
154 popupQuery( m_list->item(m_list->currentItem())); 156 popupQuery( m_list->item(m_list->currentItem()));
155} 157}
156 158
157void IRCChannelTab::popupPing() { 159void IRCChannelTab::popupPing() {
158 //HAHA, no wonder these don't work 160 //HAHA, no wonder these don't work
159} 161}
160 162
161void IRCChannelTab::popupVersion() { 163void IRCChannelTab::popupVersion() {
162} 164}
163 165
164void IRCChannelTab::popupWhois() { 166void IRCChannelTab::popupWhois() {
165} 167}
166 168
167QString IRCChannelTab::title() { 169QString IRCChannelTab::title() {
168 return m_channel->channelname(); 170 return m_channel->channelname();
169} 171}
170 172
171IRCSession *IRCChannelTab::session() { 173IRCSession *IRCChannelTab::session() {
172 return m_parentTab->session(); 174 return m_parentTab->session();
173} 175}
174 176
175void IRCChannelTab::remove() { 177void IRCChannelTab::remove() {
176 if (session()->isSessionActive()) { 178 if (session()->isSessionActive()) {
177 session()->part(m_channel); 179 session()->part(m_channel);
178 } else { 180 } else {
179 m_mainWindow->killTab(this); 181 m_mainWindow->killTab(this);
180 } 182 }
181} 183}
182 184
183IRCChannel *IRCChannelTab::channel() { 185IRCChannel *IRCChannelTab::channel() {
184 return m_channel; 186 return m_channel;
185} 187}
186 188
187IRCChannelList *IRCChannelTab::list() { 189IRCChannelList *IRCChannelTab::list() {
188 return m_list; 190 return m_list;
189} 191}
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 5ca7a29..e031d4d 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,387 +1,389 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include <qwhatsthis.h> 2#include <qwhatsthis.h>
3
3#include "ircservertab.h" 4#include "ircservertab.h"
5#include "ircmessageparser.h"
4 6
5 7
6bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) { 8bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) {
7 return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) || 9 return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) ||
8 (text.find("ping") != -1 && text.find( tab->server()->nick() != -1)); 10 (text.find("ping") != -1 && text.find( tab->server()->nick() != -1));
9} 11}
10 12
11 13
12IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 14IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
13 m_server = server; 15 m_server = server;
14 m_session = new IRCSession(&m_server); 16 m_session = new IRCSession(&m_server);
15 m_mainWindow = mainWindow; 17 m_mainWindow = mainWindow;
16 m_close = FALSE; 18 m_close = FALSE;
17 m_lines = 0; 19 m_lines = 0;
18 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); 20 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
19 m_textview = new QTextView(this); 21 m_textview = new QTextView(this);
20 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 22 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
21 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 23 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
22 m_textview->setTextFormat(RichText); 24 m_textview->setTextFormat(RichText);
23 QWhatsThis::add(m_textview, tr("Server messages")); 25 QWhatsThis::add(m_textview, tr("Server messages"));
24 m_layout->add(m_textview); 26 m_layout->add(m_textview);
25 m_field = new IRCHistoryLineEdit(this); 27 m_field = new IRCHistoryLineEdit(this);
26 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); 28 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
27 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); 29 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
28 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); 30 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab()));
29 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); 31 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
30 32
31 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); 33 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
32 m_layout->add(m_field); 34 m_layout->add(m_field);
33 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 35 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
34 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 36 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
35 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 37 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
36 settingsChanged(); 38 settingsChanged();
37 39
38 m_field->setFocus(); 40 m_field->setFocus();
39 m_field->setActiveWindow(); 41 m_field->setActiveWindow();
40 42
41} 43}
42 44
43void IRCServerTab::scrolling(){ 45void IRCServerTab::scrolling(){
44 m_textview->ensureVisible(0, m_textview->contentsHeight()); 46 m_textview->ensureVisible(0, m_textview->contentsHeight());
45} 47}
46 48
47 49
48void IRCServerTab::appendText(QString text) { 50void IRCServerTab::appendText(QString text) {
49 /* not using append because it creates layout problems */ 51 /* not using append because it creates layout problems */
50 QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); 52 QString txt = m_textview->text() + IRCTab::appendTimestamp( text );
51 53
52 54
53 55
54 if (m_maxLines > 0 && m_lines >= m_maxLines) { 56 if (m_maxLines > 0 && m_lines >= m_maxLines) {
55 int firstBreak = txt.find('\n'); 57 int firstBreak = txt.find('\n');
56 if (firstBreak != -1) { 58 if (firstBreak != -1) {
57 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 59 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
58 } 60 }
59 } else { 61 } else {
60 m_lines++; 62 m_lines++;
61 } 63 }
62 m_textview->setText(txt); 64 m_textview->setText(txt);
63 m_textview->ensureVisible(0, m_textview->contentsHeight()); 65 m_textview->ensureVisible(0, m_textview->contentsHeight());
64 emit changed(this); 66 emit changed(this);
65} 67}
66 68
67IRCServerTab::~IRCServerTab() { 69IRCServerTab::~IRCServerTab() {
68 delete m_session; 70 delete m_session;
69} 71}
70 72
71void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 73void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
72 m_channelTabs.remove(tab); 74 m_channelTabs.remove(tab);
73} 75}
74 76
75void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { 77void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
76 m_queryTabs.remove(tab); 78 m_queryTabs.remove(tab);
77} 79}
78 80
79void IRCServerTab::addQueryTab(IRCQueryTab *tab) { 81void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
80 m_queryTabs.append(tab); 82 m_queryTabs.append(tab);
81} 83}
82 84
83QString IRCServerTab::title() { 85QString IRCServerTab::title() {
84 return "Server"; 86 return "Server";
85} 87}
86 88
87IRCSession *IRCServerTab::session() { 89IRCSession *IRCServerTab::session() {
88 return m_session; 90 return m_session;
89} 91}
90/* 92/*
91QString *IRCServerTab::mynick() { 93QString *IRCServerTab::mynick() {
92 return (*m_server->nick()); 94 return (*m_server->nick());
93} */ 95} */
94 96
95IRCServer *IRCServerTab::server() { 97IRCServer *IRCServerTab::server() {
96 return &m_server; 98 return &m_server;
97} 99}
98 100
99void IRCServerTab::settingsChanged() { 101void IRCServerTab::settingsChanged() {
100 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 102 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
101 m_lines = 0; 103 m_lines = 0;
102} 104}
103 105
104void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 106void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
105 QTextIStream stream(&line); 107 QTextIStream stream(&line);
106 QString command; 108 QString command;
107 stream >> command; 109 stream >> command;
108 command = command.upper().right(command.length()-1); 110 command = command.upper().right(command.length()-1);
109 111
110 //JOIN 112 //JOIN
111 if (command == "JOIN" || command == "J") { 113 if (command == "JOIN" || command == "J") {
112 QString channel; 114 QString channel;
113 stream >> channel; 115 stream >> channel;
114 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { 116 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) {
115 m_session->join(channel); 117 m_session->join(channel);
116 } else { 118 } else {
117 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); 119 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
118 } 120 }
119 } 121 }
120 122
121 //KICK 123 //KICK
122 else if (command == "KICK"){ 124 else if (command == "KICK"){
123 QString nickname; 125 QString nickname;
124 stream >> nickname; 126 stream >> nickname;
125 if (nickname.length() > 0) { 127 if (nickname.length() > 0) {
126 if (line.length() > 7 + nickname.length()) { 128 if (line.length() > 7 + nickname.length()) {
127 QString text = line.right(line.length()-nickname.length()-7); 129 QString text = line.right(line.length()-nickname.length()-7);
128 IRCPerson person; 130 IRCPerson person;
129 person.setNick(nickname); 131 person.setNick(nickname);
130 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text); 132 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
131 } else { 133 } else {
132 IRCPerson person; 134 IRCPerson person;
133 person.setNick(nickname); 135 person.setNick(nickname);
134 m_session->kick(((IRCChannelTab *)tab)->channel(), &person); 136 m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
135 } 137 }
136 } 138 }
137 } 139 }
138 140
139 else if (command == "OP"){ 141 else if (command == "OP"){
140 QString nickname; 142 QString nickname;
141 stream >> nickname; 143 stream >> nickname;
142 if (nickname.length() > 0) { 144 if (nickname.length() > 0) {
143 QString text = line.right(line.length()-nickname.length()-5); 145 QString text = line.right(line.length()-nickname.length()-5);
144 IRCPerson person; 146 IRCPerson person;
145 person.setNick(nickname); 147 person.setNick(nickname);
146 m_session->op(((IRCChannelTab *)tab)->channel(), &person); 148 m_session->op(((IRCChannelTab *)tab)->channel(), &person);
147 } 149 }
148 } 150 }
149 151
150 //SEND MODES 152 //SEND MODES
151 else if (command == "MODE"){ 153 else if (command == "MODE"){
152 QString text = line.right(line.length()-6); 154 QString text = line.right(line.length()-6);
153 if (text.length() > 0) { 155 if (text.length() > 0) {
154 m_session->mode(text); 156 m_session->mode(text);
155 } else { 157 } else {
156 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>"); 158 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>");
157 } 159 }
158 } 160 }
159 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want 161 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want
160 else if (command == "RAW"){ 162 else if (command == "RAW"){
161 QString text = line.right(line.length()-5); 163 QString text = line.right(line.length()-5);
162 if (text.length() > 0) { 164 if (text.length() > 0) {
163 m_session->raw(text); 165 m_session->raw(text);
164 } 166 }
165 } 167 }
166 else if (command == "SUSPEND"){ 168 else if (command == "SUSPEND"){
167 QString text = line.right(line.length()-9); 169 QString text = line.right(line.length()-9);
168 if (text.upper() == "ON") { 170 if (text.upper() == "ON") {
169 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 171 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
170 } 172 }
171 else if (text.upper() == "OFF"){ 173 else if (text.upper() == "OFF"){
172 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 174 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
173 } else { 175 } else {
174 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text); 176 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text);
175 } 177 }
176 } 178 }
177 179
178 else if (command == "QUIT"){ 180 else if (command == "QUIT"){
179 QString text = line.right(line.length()-6); 181 QString text = line.right(line.length()-6);
180 if (text.length() > 0) { 182 if (text.length() > 0) {
181 m_session->quit(text); 183 m_session->quit(text);
182 } else { 184 } else {
183 m_session->quit(); 185 m_session->quit();
184 } 186 }
185 } 187 }
186 188
187 //SEND ACTION 189 //SEND ACTION
188 else if (command == "ME") { 190 else if (command == "ME") {
189 QString text = line.right(line.length()-4); 191 QString text = line.right(line.length()-4);
190 if (text.length() > 0) { 192 if (text.length() > 0) {
191 if (tab->isA("IRCChannelTab")) { 193 if (tab->isA("IRCChannelTab")) {
192 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 194 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
193 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); 195 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
194 } else if (tab->isA("IRCQueryTab")) { 196 } else if (tab->isA("IRCQueryTab")) {
195 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 197 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
196 m_session->sendAction(((IRCQueryTab *)tab)->person(), text); 198 m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
197 } else { 199 } else {
198 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); 200 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
199 } 201 }
200 } 202 }
201 } 203 }
202 //SEND PRIVMSG 204 //SEND PRIVMSG
203 else if (command == "MSG") { 205 else if (command == "MSG") {
204 QString nickname; 206 QString nickname;
205 stream >> nickname; 207 stream >> nickname;
206 if (nickname.length() > 0) { 208 if (nickname.length() > 0) {
207 if (line.length() > 6 + nickname.length()) { 209 if (line.length() > 6 + nickname.length()) {
208 QString text = line.right(line.length()-nickname.length()-6); 210 QString text = line.right(line.length()-nickname.length()-6);
209 IRCPerson person; 211 IRCPerson person;
210 person.setNick(nickname); 212 person.setNick(nickname);
211 tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>"); 213 tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>");
212 m_session->sendMessage(&person, text); 214 m_session->sendMessage(&person, text);
213 } 215 }
214 } 216 }
215 } 217 }
216 else { 218 else {
217 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); 219 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>");
218 } 220 }
219} 221}
220 222
221void IRCServerTab::processCommand() { 223void IRCServerTab::processCommand() {
222 QString text = m_field->text(); 224 QString text = m_field->text();
223 if (text.startsWith("/") && !text.startsWith("//")) { 225 if (text.startsWith("/") && !text.startsWith("//")) {
224 /* Command mode */ 226 /* Command mode */
225 executeCommand(this, text); 227 executeCommand(this, text);
226 } 228 }
227 m_field->clear(); 229 m_field->clear();
228} 230}
229 231
230void IRCServerTab::doConnect() { 232void IRCServerTab::doConnect() {
231 m_session->beginSession(); 233 m_session->beginSession();
232} 234}
233 235
234void IRCServerTab::remove() { 236void IRCServerTab::remove() {
235 /* Close requested */ 237 /* Close requested */
236 if (m_session->isSessionActive()) { 238 if (m_session->isSessionActive()) {
237 /* While there is a running session */ 239 /* While there is a running session */
238 m_close = TRUE; 240 m_close = TRUE;
239 m_session->endSession(); 241 m_session->endSession();
240 } else { 242 } else {
241 /* Session has previously been closed */ 243 /* Session has previously been closed */
242 m_channelTabs.first(); 244 m_channelTabs.first();
243 while (m_channelTabs.current() != 0) { 245 while (m_channelTabs.current() != 0) {
244 m_mainWindow->killTab(m_channelTabs.current(), true); 246 m_mainWindow->killTab(m_channelTabs.current(), true);
245 } 247 }
246 m_queryTabs.first(); 248 m_queryTabs.first();
247 while (m_queryTabs.current() != 0) { 249 while (m_queryTabs.current() != 0) {
248 m_mainWindow->killTab(m_queryTabs.current(), true); 250 m_mainWindow->killTab(m_queryTabs.current(), true);
249 } 251 }
250 m_mainWindow->killTab(this); 252 m_mainWindow->killTab(this);
251 } 253 }
252} 254}
253 255
254IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { 256IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
255 QListIterator<IRCChannelTab> it(m_channelTabs); 257 QListIterator<IRCChannelTab> it(m_channelTabs);
256 258
257 for (; it.current(); ++it) { 259 for (; it.current(); ++it) {
258 if (it.current()->channel() == channel) 260 if (it.current()->channel() == channel)
259 return it.current(); 261 return it.current();
260 } 262 }
261 return 0; 263 return 0;
262} 264}
263 265
264IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { 266IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) {
265 QListIterator<IRCQueryTab> it(m_queryTabs); 267 QListIterator<IRCQueryTab> it(m_queryTabs);
266 268
267 for (; it.current(); ++it) { 269 for (; it.current(); ++it) {
268 if (it.current()->person()->nick() == person->nick()) 270 if (it.current()->person()->nick() == person->nick())
269 return it.current(); 271 return it.current();
270 } 272 }
271 return 0; 273 return 0;
272} 274}
273 275
274void IRCServerTab::display(IRCOutput output) { 276void IRCServerTab::display(IRCOutput output) {
275 277
276 /* All messages to be displayed inside the GUI get here */ 278 /* All messages to be displayed inside the GUI get here */
277 switch (output.type()) { 279 switch (output.type()) {
278 case OUTPUT_CONNCLOSE: 280 case OUTPUT_CONNCLOSE:
279 if (m_close) { 281 if (m_close) {
280 m_channelTabs.first(); 282 m_channelTabs.first();
281 while (m_channelTabs.current() != 0) { 283 while (m_channelTabs.current() != 0) {
282 m_mainWindow->killTab(m_channelTabs.current(), true); 284 m_mainWindow->killTab(m_channelTabs.current(), true);
283 } 285 }
284 m_queryTabs.first(); 286 m_queryTabs.first();
285 while (m_queryTabs.current() != 0) { 287 while (m_queryTabs.current() != 0) {
286 m_mainWindow->killTab(m_queryTabs.current(), true); 288 m_mainWindow->killTab(m_queryTabs.current(), true);
287 } 289 }
288 m_mainWindow->killTab(this); 290 m_mainWindow->killTab(this);
289 } else { 291 } else {
290 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); 292 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>");
291 QListIterator<IRCChannelTab> it(m_channelTabs); 293 QListIterator<IRCChannelTab> it(m_channelTabs);
292 for (; it.current(); ++it) { 294 for (; it.current(); ++it) {
293 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); 295 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>");
294 } 296 }
295 } 297 }
296 break; 298 break;
297 case OUTPUT_SELFJOIN: { 299 case OUTPUT_SELFJOIN: {
298 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 300 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
299 m_channelTabs.append(channeltab); 301 m_channelTabs.append(channeltab);
300 m_mainWindow->addTab(channeltab); 302 m_mainWindow->addTab(channeltab);
301 } 303 }
302 break; 304 break;
303 case OUTPUT_CHANPRIVMSG: { 305 case OUTPUT_CHANPRIVMSG: {
304 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 306 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
305 channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>"); 307 channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>");
306 } 308 }
307 break; 309 break;
308 case OUTPUT_QUERYACTION: 310 case OUTPUT_QUERYACTION:
309 case OUTPUT_QUERYPRIVMSG: { 311 case OUTPUT_QUERYPRIVMSG: {
310 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); 312 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0));
311 if (!queryTab) { 313 if (!queryTab) {
312 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 314 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
313 m_queryTabs.append(queryTab); 315 m_queryTabs.append(queryTab);
314 m_mainWindow->addTab(queryTab); 316 m_mainWindow->addTab(queryTab);
315 } 317 }
316 queryTab->display(output); 318 queryTab->display(output);
317 } 319 }
318 break; 320 break;
319 case OUTPUT_SELFPART: { 321 case OUTPUT_SELFPART: {
320 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 322 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
321 if (channelTab) 323 if (channelTab)
322 m_mainWindow->killTab(channelTab, true); 324 m_mainWindow->killTab(channelTab, true);
323 } 325 }
324 break; 326 break;
325 case OUTPUT_SELFKICK: { 327 case OUTPUT_SELFKICK: {
326 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 328 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
327 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 329 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
328 if (channelTab) 330 if (channelTab)
329 m_mainWindow->killTab(channelTab, true); 331 m_mainWindow->killTab(channelTab, true);
330 } 332 }
331 break; 333 break;
332 case OUTPUT_CHANACTION: { 334 case OUTPUT_CHANACTION: {
333 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 335 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
334 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); 336 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
335 } 337 }
336 break; 338 break;
337 case OUTPUT_TOPIC: { 339 case OUTPUT_TOPIC: {
338 IRCChannel *channel = (IRCChannel *) output.getParam(0); 340 IRCChannel *channel = (IRCChannel *) output.getParam(0);
339 if (channel) { 341 if (channel) {
340 IRCChannelTab *channelTab = getTabForChannel(channel); 342 IRCChannelTab *channelTab = getTabForChannel(channel);
341 if (channelTab) { 343 if (channelTab) {
342 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 344 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
343 return; 345 return;
344 } 346 }
345 } 347 }
346 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 348 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
347 } 349 }
348 break; 350 break;
349 case OUTPUT_QUIT: { 351 case OUTPUT_QUIT: {
350 QString nick = ((IRCPerson *)output.getParam(0))->nick(); 352 QString nick = ((IRCPerson *)output.getParam(0))->nick();
351 QListIterator<IRCChannelTab> it(m_channelTabs); 353 QListIterator<IRCChannelTab> it(m_channelTabs);
352 for (; it.current(); ++it) { 354 for (; it.current(); ++it) {
353 if (it.current()->list()->hasPerson(nick)) { 355 if (it.current()->list()->hasPerson(nick)) {
354 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 356 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
355 it.current()->list()->update(); 357 it.current()->list()->update();
356 } 358 }
357 } 359 }
358 } 360 }
359 break; 361 break;
360/* case OUTPUT_NICKCHANGE: { 362/* case OUTPUT_NICKCHANGE: {
361 //WAS HERE 363 //WAS HERE
362 QString nick = ((IRCPerson *)output.getParam(0))->nick(); 364 QString nick = ((IRCPerson *)output.getParam(0))->nick();
363 QListIterator<IRCChannelTab> it(m_channelTabs); 365 QListIterator<IRCChannelTab> it(m_channelTabs);
364 for (; it.current(); ++it) { 366 for (; it.current(); ++it) {
365 if (it.current()->list()->hasPerson(nick)) { 367 if (it.current()->list()->hasPerson(nick)) {
366 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 368 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
367 it.current()->list()->update(); 369 it.current()->list()->update();
368 } 370 }
369 } 371 }
370 } 372 }
371 break; 373 break;
372 */ case OUTPUT_OTHERJOIN: 374 */ case OUTPUT_OTHERJOIN:
373 case OUTPUT_OTHERKICK: 375 case OUTPUT_OTHERKICK:
374 case OUTPUT_CHANPERSONMODE: 376 case OUTPUT_CHANPERSONMODE:
375 case OUTPUT_OTHERPART: { 377 case OUTPUT_OTHERPART: {
376 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 378 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
377 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 379 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
378 channelTab->list()->update(); 380 channelTab->list()->update();
379 } 381 }
380 break; 382 break;
381 case OUTPUT_CTCP: 383 case OUTPUT_CTCP:
382 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); 384 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>");
383 break; 385 break;
384 case OUTPUT_ERROR: 386 case OUTPUT_ERROR:
385 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 387 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
386 break; 388 break;
387 default: 389 default: