summaryrefslogtreecommitdiff
authorfliplap <fliplap>2003-07-22 05:36:18 (UTC)
committer fliplap <fliplap>2003-07-22 05:36:18 (UTC)
commitd672a787dd122410063ac6cb721be8b5f8cd418e (patch) (unidiff)
treed29b21fc979c41a48b2d201c9b37647e729c521c
parent2fdb15d45c336bbe1540bd9de6b5bfaea13df163 (diff)
downloadopie-d672a787dd122410063ac6cb721be8b5f8cd418e.zip
opie-d672a787dd122410063ac6cb721be8b5f8cd418e.tar.gz
opie-d672a787dd122410063ac6cb721be8b5f8cd418e.tar.bz2
fixed scroll issue, added many commands
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp8
-rw-r--r--noncore/net/opieirc/ircchanneltab.h1
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp6
-rw-r--r--noncore/net/opieirc/ircquerytab.h1
-rw-r--r--noncore/net/opieirc/ircservertab.cpp111
-rw-r--r--noncore/net/opieirc/ircservertab.h6
-rw-r--r--noncore/net/opieirc/ircsession.cpp37
-rw-r--r--noncore/net/opieirc/ircsession.h10
-rw-r--r--noncore/net/opieirc/mainwindow.cpp5
-rw-r--r--noncore/net/opieirc/mainwindow.h4
10 files changed, 172 insertions, 17 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index c1964c8..beb8bce 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,162 +1,166 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/resource.h> 2#include <qpe/resource.h>
3#include <qcursor.h> 3#include <qcursor.h>
4#include <qwhatsthis.h> 4#include <qwhatsthis.h>
5#include <qhbox.h> 5#include <qhbox.h>
6#include "ircchanneltab.h" 6#include "ircchanneltab.h"
7#include "ircservertab.h" 7#include "ircservertab.h"
8 8
9IRCChannelTab::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) {
10 m_mainWindow = mainWindow; 10 m_mainWindow = mainWindow;
11 m_parentTab = parentTab; 11 m_parentTab = parentTab;
12 m_channel = channel; 12 m_channel = channel;
13 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 13 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
14 QHBox *hbox = new QHBox(this); 14 QHBox *hbox = new QHBox(this);
15 m_textview = new QTextView(hbox); 15 m_textview = new QTextView(hbox);
16 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 16 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
17 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 17 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
18 m_listVisible = TRUE; 18 m_listVisible = TRUE;
19 m_listButton = new QPushButton(">", m_textview); 19 m_listButton = new QPushButton(">", m_textview);
20 m_textview->setCornerWidget(m_listButton); 20 m_textview->setCornerWidget(m_listButton);
21 m_textview->setTextFormat(RichText); 21 m_textview->setTextFormat(RichText);
22 QWhatsThis::add(m_textview, tr("Channel discussion")); 22 QWhatsThis::add(m_textview, tr("Channel discussion"));
23 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 23 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
24 m_list = new IRCChannelList(m_channel, hbox); 24 m_list = new IRCChannelList(m_channel, hbox);
25 m_list->update(); 25 m_list->update();
26 m_list->setMaximumWidth(LISTWIDTH); 26 m_list->setMaximumWidth(LISTWIDTH);
27 m_field = new IRCHistoryLineEdit(this); 27 m_field = new IRCHistoryLineEdit(this);
28 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); 28 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
29 m_popup = new QPopupMenu(m_list); 29 m_popup = new QPopupMenu(m_list);
30 m_lines = 0; 30 m_lines = 0;
31 /* Required so that embedded-style "right" clicks work */ 31 /* Required so that embedded-style "right" clicks work */
32 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 32 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
33 connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); 33 connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &)));
34
35 /* Construct the popup menu */ 34 /* Construct the popup menu */
36 QPopupMenu *ctcpMenu = new QPopupMenu(m_list); 35 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
37 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); 36 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
38 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); 37 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
39 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); 38 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
40 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); 39 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
41 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 40 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
42 41 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
43 m_layout->add(hbox); 42 m_layout->add(hbox);
44 hbox->show(); 43 hbox->show();
45 m_layout->add(m_field); 44 m_layout->add(m_field);
46 m_field->setFocus(); 45 m_field->setFocus();
47 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 46 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
48 settingsChanged(); 47 settingsChanged();
49} 48}
50 49
50void IRCChannelTab::scrolling(){
51 m_textview->ensureVisible(0, m_textview->contentsHeight());
52}
53
51void IRCChannelTab::appendText(QString text) { 54void IRCChannelTab::appendText(QString text) {
52 /* not using append because it creates layout problems */ 55 /* not using append because it creates layout problems */
53 QString txt = m_textview->text() + text + "\n"; 56 QString txt = m_textview->text() + text + "\n";
54 if (m_maxLines > 0 && m_lines >= m_maxLines) { 57 if (m_maxLines > 0 && m_lines >= m_maxLines) {
55 int firstBreak = txt.find('\n'); 58 int firstBreak = txt.find('\n');
56 if (firstBreak != -1) { 59 if (firstBreak != -1) {
57 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 60 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
58 } 61 }
59 } else { 62 } else {
60 m_lines++; 63 m_lines++;
61 } 64 }
62 m_textview->setText(txt); 65 m_textview->setText(txt);
63 m_textview->ensureVisible(0, m_textview->contentsHeight()); 66 m_textview->ensureVisible(0, m_textview->contentsHeight());
64 emit changed(this); 67 emit changed(this);
65} 68}
66 69
67IRCChannelTab::~IRCChannelTab() { 70IRCChannelTab::~IRCChannelTab() {
68 m_parentTab->removeChannelTab(this); 71 m_parentTab->removeChannelTab(this);
69} 72}
70 73
71void IRCChannelTab::processCommand() { 74void IRCChannelTab::processCommand() {
72 QString text = m_field->text(); 75 QString text = m_field->text();
73 if (text.length()>0) { 76 if (text.length()>0) {
74 if (session()->isSessionActive()) { 77 if (session()->isSessionActive()) {
75 if (text.startsWith("/") && !text.startsWith("//")) { 78 if (text.startsWith("/") && !text.startsWith("//")) {
76 /* Command mode */ 79 /* Command mode */
77 m_parentTab->executeCommand(this, text);; 80 m_parentTab->executeCommand(this, text);;
78 } else { 81 } else {
79 if (text.startsWith("//")) 82 if (text.startsWith("//"))
80 text = text.right(text.length()-1); 83 text = text.right(text.length()-1);
81 session()->sendMessage(m_channel, m_field->text()); 84 session()->sendMessage(m_channel, m_field->text());
82 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>"); 85 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>");
83 } 86 }
84 } else { 87 } else {
85 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 88 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
86 } 89 }
87 } 90 }
88 m_field->clear(); 91 m_field->clear();
89} 92}
90 93
91void IRCChannelTab::settingsChanged() { 94void IRCChannelTab::settingsChanged() {
92 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 95 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
93 m_lines = 0; 96 m_lines = 0;
94} 97}
95 98
96void IRCChannelTab::toggleList() { 99void IRCChannelTab::toggleList() {
97 if (m_listVisible) { 100 if (m_listVisible) {
98 m_list->setMaximumWidth(0); 101 m_list->setMaximumWidth(0);
99 m_listButton->setText("<"); 102 m_listButton->setText("<");
100 } else { 103 } else {
101 m_list->setMaximumWidth(LISTWIDTH); 104 m_list->setMaximumWidth(LISTWIDTH);
102 m_listButton->setText(">"); 105 m_listButton->setText(">");
103 } 106 }
104 m_listVisible = !m_listVisible; 107 m_listVisible = !m_listVisible;
105} 108}
106 109
107void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { 110void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
108 switch (mouse) { 111 switch (mouse) {
109 case 1: 112 case 1:
110 break; 113 break;
111 case 2: 114 case 2:
112 m_popup->popup(point); 115 m_popup->popup(point);
113 break; 116 break;
114 }; 117 };
115} 118}
116 119
117void IRCChannelTab::popupQuery() { 120void IRCChannelTab::popupQuery() {
118 if (m_list->currentItem() != -1) { 121 if (m_list->currentItem() != -1) {
119 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); 122 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
120 if (person) { 123 if (person) {
121 IRCQueryTab *tab = m_parentTab->getTabForQuery(person); 124 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
122 if (!tab) { 125 if (!tab) {
123 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); 126 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
124 m_parentTab->addQueryTab(tab); 127 m_parentTab->addQueryTab(tab);
125 m_mainWindow->addTab(tab); 128 m_mainWindow->addTab(tab);
126 } 129 }
127 } 130 }
128 } 131 }
129} 132}
130 133
131void IRCChannelTab::popupPing() { 134void IRCChannelTab::popupPing() {
135 //HAHA, no wonder these don't work
132} 136}
133 137
134void IRCChannelTab::popupVersion() { 138void IRCChannelTab::popupVersion() {
135} 139}
136 140
137void IRCChannelTab::popupWhois() { 141void IRCChannelTab::popupWhois() {
138} 142}
139 143
140QString IRCChannelTab::title() { 144QString IRCChannelTab::title() {
141 return m_channel->channelname(); 145 return m_channel->channelname();
142} 146}
143 147
144IRCSession *IRCChannelTab::session() { 148IRCSession *IRCChannelTab::session() {
145 return m_parentTab->session(); 149 return m_parentTab->session();
146} 150}
147 151
148void IRCChannelTab::remove() { 152void IRCChannelTab::remove() {
149 if (session()->isSessionActive()) { 153 if (session()->isSessionActive()) {
150 session()->part(m_channel); 154 session()->part(m_channel);
151 } else { 155 } else {
152 m_mainWindow->killTab(this); 156 m_mainWindow->killTab(this);
153 } 157 }
154} 158}
155 159
156IRCChannel *IRCChannelTab::channel() { 160IRCChannel *IRCChannelTab::channel() {
157 return m_channel; 161 return m_channel;
158} 162}
159 163
160IRCChannelList *IRCChannelTab::list() { 164IRCChannelList *IRCChannelTab::list() {
161 return m_list; 165 return m_list;
162} 166}
diff --git a/noncore/net/opieirc/ircchanneltab.h b/noncore/net/opieirc/ircchanneltab.h
index a03ee3e..001c96d 100644
--- a/noncore/net/opieirc/ircchanneltab.h
+++ b/noncore/net/opieirc/ircchanneltab.h
@@ -1,72 +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 __IRCCHANNELTAB_H 21#ifndef __IRCCHANNELTAB_H
22#define __IRCCHANNELTAB_H 22#define __IRCCHANNELTAB_H
23 23
24#include <qpopupmenu.h> 24#include <qpopupmenu.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include "irctab.h" 26#include "irctab.h"
27#include "ircsession.h" 27#include "ircsession.h"
28#include "ircmisc.h" 28#include "ircmisc.h"
29#include "mainwindow.h" 29#include "mainwindow.h"
30#include "ircchannellist.h" 30#include "ircchannellist.h"
31 31
32#define LISTWIDTH 70 32#define LISTWIDTH 70
33 33
34class IRCServerTab; 34class IRCServerTab;
35class IRCChannelTab : public IRCTab { 35class IRCChannelTab : public IRCTab {
36 Q_OBJECT 36 Q_OBJECT
37public: 37public:
38 /* IRCTab implementation */ 38 /* IRCTab implementation */
39 IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 39 IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
40 ~IRCChannelTab(); 40 ~IRCChannelTab();
41 QString title(); 41 QString title();
42 IRCSession *session(); 42 IRCSession *session();
43 IRCChannel *channel(); 43 IRCChannel *channel();
44 IRCChannelList *list(); 44 IRCChannelList *list();
45public: 45public:
46 void appendText(QString text); 46 void appendText(QString text);
47public slots: 47public slots:
48 void remove(); 48 void remove();
49 void settingsChanged(); 49 void settingsChanged();
50 void scrolling();
50protected slots: 51protected slots:
51 void processCommand(); 52 void processCommand();
52 void toggleList(); 53 void toggleList();
53 void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point); 54 void mouseButtonPressed(int mouse, QListBoxItem *item, const QPoint &point);
54 /* Popup slots */ 55 /* Popup slots */
55 void popupQuery(); 56 void popupQuery();
56 void popupPing(); 57 void popupPing();
57 void popupVersion(); 58 void popupVersion();
58 void popupWhois(); 59 void popupWhois();
59protected: 60protected:
60 IRCServerTab *m_parentTab; 61 IRCServerTab *m_parentTab;
61 IRCChannel *m_channel; 62 IRCChannel *m_channel;
62 IRCChannelList *m_list; 63 IRCChannelList *m_list;
63 QPushButton *m_listButton; 64 QPushButton *m_listButton;
64 MainWindow *m_mainWindow; 65 MainWindow *m_mainWindow;
65 QTextView *m_textview; 66 QTextView *m_textview;
66 IRCHistoryLineEdit *m_field; 67 IRCHistoryLineEdit *m_field;
67 QPopupMenu *m_popup; 68 QPopupMenu *m_popup;
68 bool m_listVisible; 69 bool m_listVisible;
69 int m_lines; 70 int m_lines;
70}; 71};
71 72
72#endif /* __IRCCHANNELTAB_H */ 73#endif /* __IRCCHANNELTAB_H */
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp
index 21a53dc..a113b04 100644
--- a/noncore/net/opieirc/ircquerytab.cpp
+++ b/noncore/net/opieirc/ircquerytab.cpp
@@ -1,97 +1,103 @@
1#include <qhbox.h> 1#include <qhbox.h>
2#include <qwhatsthis.h> 2#include <qwhatsthis.h>
3#include "ircquerytab.h" 3#include "ircquerytab.h"
4#include "ircservertab.h" 4#include "ircservertab.h"
5 5
6IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 6IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
7 m_mainWindow = mainWindow; 7 m_mainWindow = mainWindow;
8 m_parentTab = parentTab; 8 m_parentTab = parentTab;
9 m_lines = 0; 9 m_lines = 0;
10 m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */ 10 m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */
11 m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>"); 11 m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>");
12 QHBox *hbox = new QHBox(this); 12 QHBox *hbox = new QHBox(this);
13 m_textview = new QTextView(hbox); 13 m_textview = new QTextView(hbox);
14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_textview->setTextFormat(RichText); 16 m_textview->setTextFormat(RichText);
17 QWhatsThis::add(m_textview, tr("Private discussion")); 17 QWhatsThis::add(m_textview, tr("Private discussion"));
18 m_field = new IRCHistoryLineEdit(this); 18 m_field = new IRCHistoryLineEdit(this);
19 QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person")); 19 QWhatsThis::add(m_field, tr("Type your text here in order to send a message to the other person"));
20 m_layout->add(hbox); 20 m_layout->add(hbox);
21 hbox->show(); 21 hbox->show();
22 m_layout->add(m_field); 22 m_layout->add(m_field);
23 m_field->setFocus(); 23 m_field->setFocus();
24 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 24 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
25 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
25 settingsChanged(); 26 settingsChanged();
26} 27}
27 28
29void IRCQueryTab::scrolling(){
30 m_textview->ensureVisible(0, m_textview->contentsHeight());
31}
32
33
28void IRCQueryTab::appendText(QString text) { 34void IRCQueryTab::appendText(QString text) {
29 /* not using append because it creates layout problems */ 35 /* not using append because it creates layout problems */
30 QString txt = m_textview->text() + text + "\n"; 36 QString txt = m_textview->text() + text + "\n";
31 if (m_maxLines > 0 && m_lines >= m_maxLines) { 37 if (m_maxLines > 0 && m_lines >= m_maxLines) {
32 int firstBreak = txt.find('\n'); 38 int firstBreak = txt.find('\n');
33 if (firstBreak != -1) { 39 if (firstBreak != -1) {
34 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 40 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
35 } 41 }
36 } else { 42 } else {
37 m_lines++; 43 m_lines++;
38 } 44 }
39 m_textview->setText(txt); 45 m_textview->setText(txt);
40 m_textview->ensureVisible(0, m_textview->contentsHeight()); 46 m_textview->ensureVisible(0, m_textview->contentsHeight());
41 emit changed(this); 47 emit changed(this);
42} 48}
43 49
44IRCQueryTab::~IRCQueryTab() { 50IRCQueryTab::~IRCQueryTab() {
45 m_parentTab->removeQueryTab(this); 51 m_parentTab->removeQueryTab(this);
46 delete m_person; 52 delete m_person;
47} 53}
48 54
49void IRCQueryTab::processCommand() { 55void IRCQueryTab::processCommand() {
50 QString text = m_field->text(); 56 QString text = m_field->text();
51 if (text.length()>0) { 57 if (text.length()>0) {
52 if (session()->isSessionActive()) { 58 if (session()->isSessionActive()) {
53 if (text.startsWith("/") && !text.startsWith("//")) { 59 if (text.startsWith("/") && !text.startsWith("//")) {
54 /* Command mode */ 60 /* Command mode */
55 m_parentTab->executeCommand(this, text);; 61 m_parentTab->executeCommand(this, text);;
56 } else { 62 } else {
57 if (text.startsWith("//")) 63 if (text.startsWith("//"))
58 text = text.right(text.length()-1); 64 text = text.right(text.length()-1);
59 session()->sendMessage(m_person, m_field->text()); 65 session()->sendMessage(m_person, m_field->text());
60 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>"); 66 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
61 } 67 }
62 } else { 68 } else {
63 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 69 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
64 } 70 }
65 } 71 }
66 m_field->clear(); 72 m_field->clear();
67} 73}
68 74
69void IRCQueryTab::display(IRCOutput output) { 75void IRCQueryTab::display(IRCOutput output) {
70 if (output.type() == OUTPUT_QUERYPRIVMSG) { 76 if (output.type() == OUTPUT_QUERYPRIVMSG) {
71 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage() + "</font><br>"); 77 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+m_person->nick()+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage() + "</font><br>");
72 } else if (output.type() == OUTPUT_QUERYACTION) { 78 } else if (output.type() == OUTPUT_QUERYACTION) {
73 appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>"); 79 appendText("<font color=\"" + m_otherColor + "\">" + output.htmlMessage() + "<br>");
74 } 80 }
75} 81}
76 82
77void IRCQueryTab::settingsChanged() { 83void IRCQueryTab::settingsChanged() {
78 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 84 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
79 m_lines = 0; 85 m_lines = 0;
80} 86}
81 87
82QString IRCQueryTab::title() { 88QString IRCQueryTab::title() {
83 return m_person->nick(); 89 return m_person->nick();
84} 90}
85 91
86IRCSession *IRCQueryTab::session() { 92IRCSession *IRCQueryTab::session() {
87 return m_parentTab->session(); 93 return m_parentTab->session();
88} 94}
89 95
90void IRCQueryTab::remove() { 96void IRCQueryTab::remove() {
91 m_mainWindow->killTab(this); 97 m_mainWindow->killTab(this);
92} 98}
93 99
94IRCPerson *IRCQueryTab::person() { 100IRCPerson *IRCQueryTab::person() {
95 return m_person; 101 return m_person;
96} 102}
97 103
diff --git a/noncore/net/opieirc/ircquerytab.h b/noncore/net/opieirc/ircquerytab.h
index f9cc8e1..b3b04fb 100644
--- a/noncore/net/opieirc/ircquerytab.h
+++ b/noncore/net/opieirc/ircquerytab.h
@@ -1,54 +1,55 @@
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 "mainwindow.h" 24#include "mainwindow.h"
25#include "ircsession.h" 25#include "ircsession.h"
26#include "ircmisc.h" 26#include "ircmisc.h"
27 27
28class IRCServerTab; 28class IRCServerTab;
29class IRCQueryTab : public IRCTab { 29class IRCQueryTab : public IRCTab {
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 /* IRCTab implementation */ 32 /* IRCTab implementation */
33 IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 33 IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
34 ~IRCQueryTab(); 34 ~IRCQueryTab();
35 QString title(); 35 QString title();
36 IRCSession *session(); 36 IRCSession *session();
37 IRCPerson *person(); 37 IRCPerson *person();
38 void appendText(QString text); 38 void appendText(QString text);
39public slots: 39public slots:
40 void scrolling();
40 void remove(); 41 void remove();
41 void processCommand(); 42 void processCommand();
42 void display(IRCOutput output); 43 void display(IRCOutput output);
43 void settingsChanged(); 44 void settingsChanged();
44protected: 45protected:
45 bool m_close; 46 bool m_close;
46 MainWindow *m_mainWindow; 47 MainWindow *m_mainWindow;
47 IRCServerTab *m_parentTab; 48 IRCServerTab *m_parentTab;
48 IRCPerson *m_person; 49 IRCPerson *m_person;
49 QTextView *m_textview; 50 QTextView *m_textview;
50 IRCHistoryLineEdit *m_field; 51 IRCHistoryLineEdit *m_field;
51 int m_lines; 52 int m_lines;
52}; 53};
53 54
54#endif /* __IRCQUERYTAB_H */ 55#endif /* __IRCQUERYTAB_H */
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 5aa447f..1d9520a 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,279 +1,368 @@
1#include <qpe/config.h> 1#include <qpe/config.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include <qwhatsthis.h> 3#include <qwhatsthis.h>
4#include "ircservertab.h" 4#include "ircservertab.h"
5 5
6IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 6IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
7 m_server = server; 7 m_server = server;
8 m_session = new IRCSession(&m_server); 8 m_session = new IRCSession(&m_server);
9 m_mainWindow = mainWindow; 9 m_mainWindow = mainWindow;
10 m_close = FALSE; 10 m_close = FALSE;
11 m_lines = 0; 11 m_lines = 0;
12 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); 12 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
13 m_textview = new QTextView(this); 13 m_textview = new QTextView(this);
14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_textview->setTextFormat(RichText); 16 m_textview->setTextFormat(RichText);
17 QWhatsThis::add(m_textview, tr("Server messages")); 17 QWhatsThis::add(m_textview, tr("Server messages"));
18 m_layout->add(m_textview); 18 m_layout->add(m_textview);
19 m_field = new IRCHistoryLineEdit(this); 19 m_field = new IRCHistoryLineEdit(this);
20 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); 20 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
21 m_layout->add(m_field); 21 m_layout->add(m_field);
22 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 22 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
23 m_field->setFocus(); 23 m_field->setFocus();
24 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 24 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
25 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
25 settingsChanged(); 26 settingsChanged();
26} 27}
27 28
29void IRCServerTab::scrolling(){
30 m_textview->ensureVisible(0, m_textview->contentsHeight());
31}
32
33
28void IRCServerTab::appendText(QString text) { 34void IRCServerTab::appendText(QString text) {
29 /* not using append because it creates layout problems */ 35 /* not using append because it creates layout problems */
30 QString txt = m_textview->text() + text + "\n"; 36 QString txt = m_textview->text() + text + "\n";
31 if (m_maxLines > 0 && m_lines >= m_maxLines) { 37 if (m_maxLines > 0 && m_lines >= m_maxLines) {
32 int firstBreak = txt.find('\n'); 38 int firstBreak = txt.find('\n');
33 if (firstBreak != -1) { 39 if (firstBreak != -1) {
34 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 40 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
35 } 41 }
36 } else { 42 } else {
37 m_lines++; 43 m_lines++;
38 } 44 }
39 m_textview->setText(txt); 45 m_textview->setText(txt);
40 m_textview->ensureVisible(0, m_textview->contentsHeight()); 46 m_textview->ensureVisible(0, m_textview->contentsHeight());
41 emit changed(this); 47 emit changed(this);
42} 48}
43 49
44IRCServerTab::~IRCServerTab() { 50IRCServerTab::~IRCServerTab() {
45 delete m_session; 51 delete m_session;
46} 52}
47 53
48void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 54void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
49 m_channelTabs.remove(tab); 55 m_channelTabs.remove(tab);
50} 56}
51 57
52void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { 58void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
53 m_queryTabs.remove(tab); 59 m_queryTabs.remove(tab);
54} 60}
55 61
56void IRCServerTab::addQueryTab(IRCQueryTab *tab) { 62void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
57 m_queryTabs.append(tab); 63 m_queryTabs.append(tab);
58} 64}
59 65
60QString IRCServerTab::title() { 66QString IRCServerTab::title() {
61 return "Server"; 67 return "Server";
62} 68}
63 69
64IRCSession *IRCServerTab::session() { 70IRCSession *IRCServerTab::session() {
65 return m_session; 71 return m_session;
66} 72}
73/*
74QString *IRCServerTab::mynick() {
75 return (*m_server->nick());
76} */
67 77
68IRCServer *IRCServerTab::server() { 78IRCServer *IRCServerTab::server() {
69 return &m_server; 79 return &m_server;
70} 80}
71 81
72void IRCServerTab::settingsChanged() { 82void IRCServerTab::settingsChanged() {
73 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 83 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
74 m_lines = 0; 84 m_lines = 0;
75} 85}
76 86
77void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 87void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
78 QTextIStream stream(&line); 88 QTextIStream stream(&line);
79 QString command; 89 QString command;
80 stream >> command; 90 stream >> command;
81 command = command.upper().right(command.length()-1); 91 command = command.upper().right(command.length()-1);
82 92
83 if (command == "JOIN") { 93 //JOIN
94 if (command == "JOIN" || command == "J") {
84 QString channel; 95 QString channel;
85 stream >> channel; 96 stream >> channel;
86 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { 97 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) {
87 m_session->join(channel); 98 m_session->join(channel);
88 } else { 99 } else {
89 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); 100 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
90 } 101 }
91 } else if (command == "ME") { 102 }
103
104 //KICK
105 else if (command == "KICK"){
106 QString nickname;
107 stream >> nickname;
108 if (nickname.length() > 0) {
109 if (line.length() > 7 + nickname.length()) {
110 QString text = line.right(line.length()-nickname.length()-7);
111 IRCPerson person;
112 person.setNick(nickname);
113 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
114 } else {
115 IRCPerson person;
116 person.setNick(nickname);
117 m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
118 }
119 }
120 }
121
122 else if (command == "OP"){
123 QString nickname;
124 stream >> nickname;
125 if (nickname.length() > 0) {
126 if (line.length() > 7 + nickname.length()) {
127 QString text = line.right(line.length()-nickname.length()-7);
128 IRCPerson person;
129 person.setNick(nickname);
130 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
131 } else {
132 IRCPerson person;
133 person.setNick(nickname);
134 m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
135 }
136 }
137 }
138
139 //SEND MODES
140 else if (command == "MODE"){
141 QString text = line.right(line.length()-6);
142 if (text.length() > 0) {
143 m_session->mode(text);
144 } else {
145 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>");
146 }
147 }
148 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want
149 else if (command == "RAW"){
150 QString text = line.right(line.length()-5);
151 if (text.length() > 0) {
152 m_session->raw(text);
153 }
154 }
155 else if (command == "SUSPEND"){
156 QString text = line.right(line.length()-9);
157 if (text.upper() == "ON") {
158 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
159 }
160 else if (text.upper() == "OFF"){
161 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
162 } else {
163 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text);
164 }
165 }
166
167 else if (command == "QUIT"){
168 QString text = line.right(line.length()-6);
169 if (text.length() > 0) {
170 m_session->quit(text);
171 } else {
172 m_session->quit();
173 }
174 }
175
176 //SEND ACTION
177 else if (command == "ME") {
92 QString text = line.right(line.length()-4); 178 QString text = line.right(line.length()-4);
93 if (text.length() > 0) { 179 if (text.length() > 0) {
94 if (tab->isA("IRCChannelTab")) { 180 if (tab->isA("IRCChannelTab")) {
95 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 181 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
96 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); 182 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
97 } else if (tab->isA("IRCQueryTab")) { 183 } else if (tab->isA("IRCQueryTab")) {
98 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 184 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
99 m_session->sendAction(((IRCQueryTab *)tab)->person(), text); 185 m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
100 } else { 186 } else {
101 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); 187 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
102 } 188 }
103 } 189 }
104 } else if (command == "MSG") { 190 }
191 //SEND PRIVMSG
192 else if (command == "MSG") {
105 QString nickname; 193 QString nickname;
106 stream >> nickname; 194 stream >> nickname;
107 if (nickname.length() > 0) { 195 if (nickname.length() > 0) {
108 if (line.length() > 6 + nickname.length()) { 196 if (line.length() > 6 + nickname.length()) {
109 QString text = line.right(line.length()-nickname.length()-6); 197 QString text = line.right(line.length()-nickname.length()-6);
110 IRCPerson person; 198 IRCPerson person;
111 person.setNick(nickname); 199 person.setNick(nickname);
112 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>"); 200 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>");
113 m_session->sendMessage(&person, text); 201 m_session->sendMessage(&person, text);
114 } 202 }
115 } 203 }
116 } else { 204 }
117 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); 205 else {
206 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>");
118 } 207 }
119} 208}
120 209
121void IRCServerTab::processCommand() { 210void IRCServerTab::processCommand() {
122 QString text = m_field->text(); 211 QString text = m_field->text();
123 if (text.startsWith("/") && !text.startsWith("//")) { 212 if (text.startsWith("/") && !text.startsWith("//")) {
124 /* Command mode */ 213 /* Command mode */
125 executeCommand(this, text); 214 executeCommand(this, text);
126 } 215 }
127 m_field->clear(); 216 m_field->clear();
128} 217}
129 218
130void IRCServerTab::doConnect() { 219void IRCServerTab::doConnect() {
131 m_session->beginSession(); 220 m_session->beginSession();
132} 221}
133 222
134void IRCServerTab::remove() { 223void IRCServerTab::remove() {
135 /* Close requested */ 224 /* Close requested */
136 if (m_session->isSessionActive()) { 225 if (m_session->isSessionActive()) {
137 /* While there is a running session */ 226 /* While there is a running session */
138 m_close = TRUE; 227 m_close = TRUE;
139 m_session->endSession(); 228 m_session->endSession();
140 } else { 229 } else {
141 /* Session has previously been closed */ 230 /* Session has previously been closed */
142 m_channelTabs.first(); 231 m_channelTabs.first();
143 while (m_channelTabs.current() != 0) { 232 while (m_channelTabs.current() != 0) {
144 m_mainWindow->killTab(m_channelTabs.current()); 233 m_mainWindow->killTab(m_channelTabs.current());
145 } 234 }
146 m_queryTabs.first(); 235 m_queryTabs.first();
147 while (m_queryTabs.current() != 0) { 236 while (m_queryTabs.current() != 0) {
148 m_mainWindow->killTab(m_queryTabs.current()); 237 m_mainWindow->killTab(m_queryTabs.current());
149 } 238 }
150 m_mainWindow->killTab(this); 239 m_mainWindow->killTab(this);
151 } 240 }
152} 241}
153 242
154IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { 243IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
155 QListIterator<IRCChannelTab> it(m_channelTabs); 244 QListIterator<IRCChannelTab> it(m_channelTabs);
156 245
157 for (; it.current(); ++it) { 246 for (; it.current(); ++it) {
158 if (it.current()->channel() == channel) 247 if (it.current()->channel() == channel)
159 return it.current(); 248 return it.current();
160 } 249 }
161 return 0; 250 return 0;
162} 251}
163 252
164IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { 253IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) {
165 QListIterator<IRCQueryTab> it(m_queryTabs); 254 QListIterator<IRCQueryTab> it(m_queryTabs);
166 255
167 for (; it.current(); ++it) { 256 for (; it.current(); ++it) {
168 if (it.current()->person()->nick() == person->nick()) 257 if (it.current()->person()->nick() == person->nick())
169 return it.current(); 258 return it.current();
170 } 259 }
171 return 0; 260 return 0;
172} 261}
173 262
174void IRCServerTab::display(IRCOutput output) { 263void IRCServerTab::display(IRCOutput output) {
175 264
176 /* All messages to be displayed inside the GUI get here */ 265 /* All messages to be displayed inside the GUI get here */
177 switch (output.type()) { 266 switch (output.type()) {
178 case OUTPUT_CONNCLOSE: 267 case OUTPUT_CONNCLOSE:
179 if (m_close) { 268 if (m_close) {
180 m_channelTabs.first(); 269 m_channelTabs.first();
181 while (m_channelTabs.current() != 0) { 270 while (m_channelTabs.current() != 0) {
182 m_mainWindow->killTab(m_channelTabs.current()); 271 m_mainWindow->killTab(m_channelTabs.current());
183 } 272 }
184 m_queryTabs.first(); 273 m_queryTabs.first();
185 while (m_queryTabs.current() != 0) { 274 while (m_queryTabs.current() != 0) {
186 m_mainWindow->killTab(m_queryTabs.current()); 275 m_mainWindow->killTab(m_queryTabs.current());
187 } 276 }
188 m_mainWindow->killTab(this); 277 m_mainWindow->killTab(this);
189 } else { 278 } else {
190 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); 279 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>");
191 QListIterator<IRCChannelTab> it(m_channelTabs); 280 QListIterator<IRCChannelTab> it(m_channelTabs);
192 for (; it.current(); ++it) { 281 for (; it.current(); ++it) {
193 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); 282 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>");
194 } 283 }
195 } 284 }
196 break; 285 break;
197 case OUTPUT_SELFJOIN: { 286 case OUTPUT_SELFJOIN: {
198 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 287 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
199 m_channelTabs.append(channeltab); 288 m_channelTabs.append(channeltab);
200 m_mainWindow->addTab(channeltab); 289 m_mainWindow->addTab(channeltab);
201 } 290 }
202 break; 291 break;
203 case OUTPUT_CHANPRIVMSG: { 292 case OUTPUT_CHANPRIVMSG: {
204 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 293 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
205 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>"); 294 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>");
206 } 295 }
207 break; 296 break;
208 case OUTPUT_QUERYACTION: 297 case OUTPUT_QUERYACTION:
209 case OUTPUT_QUERYPRIVMSG: { 298 case OUTPUT_QUERYPRIVMSG: {
210 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); 299 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0));
211 if (!queryTab) { 300 if (!queryTab) {
212 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 301 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
213 m_queryTabs.append(queryTab); 302 m_queryTabs.append(queryTab);
214 m_mainWindow->addTab(queryTab); 303 m_mainWindow->addTab(queryTab);
215 } 304 }
216 queryTab->display(output); 305 queryTab->display(output);
217 } 306 }
218 break; 307 break;
219 case OUTPUT_SELFPART: { 308 case OUTPUT_SELFPART: {
220 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 309 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
221 if (channelTab) 310 if (channelTab)
222 m_mainWindow->killTab(channelTab); 311 m_mainWindow->killTab(channelTab);
223 } 312 }
224 break; 313 break;
225 case OUTPUT_SELFKICK: { 314 case OUTPUT_SELFKICK: {
226 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 315 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
227 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 316 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
228 if (channelTab) 317 if (channelTab)
229 m_mainWindow->killTab(channelTab); 318 m_mainWindow->killTab(channelTab);
230 } 319 }
231 break; 320 break;
232 case OUTPUT_CHANACTION: { 321 case OUTPUT_CHANACTION: {
233 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 322 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
234 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); 323 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
235 } 324 }
236 break; 325 break;
237 case OUTPUT_TOPIC: { 326 case OUTPUT_TOPIC: {
238 IRCChannel *channel = (IRCChannel *) output.getParam(0); 327 IRCChannel *channel = (IRCChannel *) output.getParam(0);
239 if (channel) { 328 if (channel) {
240 IRCChannelTab *channelTab = getTabForChannel(channel); 329 IRCChannelTab *channelTab = getTabForChannel(channel);
241 if (channelTab) { 330 if (channelTab) {
242 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 331 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
243 return; 332 return;
244 } 333 }
245 } 334 }
246 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 335 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
247 } 336 }
248 break; 337 break;
249 case OUTPUT_QUIT: { 338 case OUTPUT_QUIT: {
250 QString nick = ((IRCPerson *)output.getParam(0))->nick(); 339 QString nick = ((IRCPerson *)output.getParam(0))->nick();
251 QListIterator<IRCChannelTab> it(m_channelTabs); 340 QListIterator<IRCChannelTab> it(m_channelTabs);
252 for (; it.current(); ++it) { 341 for (; it.current(); ++it) {
253 if (it.current()->list()->hasPerson(nick)) { 342 if (it.current()->list()->hasPerson(nick)) {
254 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 343 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
255 it.current()->list()->update(); 344 it.current()->list()->update();
256 } 345 }
257 } 346 }
258 } 347 }
259 break; 348 break;
260 case OUTPUT_OTHERJOIN: 349 case OUTPUT_OTHERJOIN:
261 case OUTPUT_OTHERKICK: 350 case OUTPUT_OTHERKICK:
262 case OUTPUT_CHANPERSONMODE: 351 case OUTPUT_CHANPERSONMODE:
263 case OUTPUT_OTHERPART: { 352 case OUTPUT_OTHERPART: {
264 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 353 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
265 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 354 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
266 channelTab->list()->update(); 355 channelTab->list()->update();
267 } 356 }
268 break; 357 break;
269 case OUTPUT_CTCP: 358 case OUTPUT_CTCP:
270 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); 359 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>");
271 break; 360 break;
272 case OUTPUT_ERROR: 361 case OUTPUT_ERROR:
273 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 362 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
274 break; 363 break;
275 default: 364 default:
276 appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); 365 appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>");
277 break; 366 break;
278 } 367 }
279} 368}
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h
index 8d24cba..48200d7 100644
--- a/noncore/net/opieirc/ircservertab.h
+++ b/noncore/net/opieirc/ircservertab.h
@@ -1,75 +1,79 @@
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#include <qpe/qpeapplication.h>
24#include <qpe/qcopenvelope_qws.h>
24#include "irctab.h" 25#include "irctab.h"
25#include "ircsession.h" 26#include "ircsession.h"
26#include "mainwindow.h" 27#include "mainwindow.h"
27#include "ircchanneltab.h" 28#include "ircchanneltab.h"
28#include "ircquerytab.h" 29#include "ircquerytab.h"
29#include "ircmisc.h" 30#include "ircmisc.h"
30 31
32
31class IRCServerTab : public IRCTab { 33class IRCServerTab : public IRCTab {
32 Q_OBJECT 34 Q_OBJECT
33public: 35public:
34 /* IRCTab implementation */ 36 /* IRCTab implementation */
35 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 37 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
36 ~IRCServerTab(); 38 ~IRCServerTab();
37 QString title(); 39 QString title();
38 IRCSession *session(); 40 IRCSession *session();
39 IRCServer *server(); 41 IRCServer *server();
40 42
41 /* Start the server session */ 43 /* Start the server session */
42 void doConnect(); 44 void doConnect();
45// QString *mynick();
43 /* Remove tabs from the internal tab lists */ 46 /* Remove tabs from the internal tab lists */
44 void removeChannelTab(IRCChannelTab *tab); 47 void removeChannelTab(IRCChannelTab *tab);
45 void removeQueryTab(IRCQueryTab *tab); 48 void removeQueryTab(IRCQueryTab *tab);
46 /* Return tabs from the internal tab lists */ 49 /* Return tabs from the internal tab lists */
47 IRCChannelTab *getTabForChannel(IRCChannel *channel); 50 IRCChannelTab *getTabForChannel(IRCChannel *channel);
48 IRCQueryTab *getTabForQuery(IRCPerson *person); 51 IRCQueryTab *getTabForQuery(IRCPerson *person);
49 /* Add tabs to the internal tab lists */ 52 /* Add tabs to the internal tab lists */
50 void addQueryTab(IRCQueryTab *tab); 53 void addQueryTab(IRCQueryTab *tab);
51 /* Execute a user command such as /join, /msg etc */ 54 /* Execute a user command such as /join, /msg etc */
52 void executeCommand(IRCTab *tab, QString line); 55 void executeCommand(IRCTab *tab, QString line);
53protected: 56protected:
54 void appendText(QString text); 57 void appendText(QString text);
55public slots: 58public slots:
59 void scrolling();
56 void remove(); 60 void remove();
57 void processCommand(); 61 void processCommand();
58 void settingsChanged(); 62 void settingsChanged();
59protected slots: 63protected slots:
60 void display(IRCOutput output); 64 void display(IRCOutput output);
61protected: 65protected:
62 int m_lines; 66 int m_lines;
63 bool m_close; 67 bool m_close;
64 IRCServer m_server; 68 IRCServer m_server;
65 IRCSession *m_session; 69 IRCSession *m_session;
66 MainWindow *m_mainWindow; 70 MainWindow *m_mainWindow;
67 QTextView *m_textview; 71 QTextView *m_textview;
68 IRCHistoryLineEdit *m_field; 72 IRCHistoryLineEdit *m_field;
69 /* Channel tabs associated with this server tab */ 73 /* Channel tabs associated with this server tab */
70 QList<IRCChannelTab> m_channelTabs; 74 QList<IRCChannelTab> m_channelTabs;
71 /* Query tabs associated with this server tab */ 75 /* Query tabs associated with this server tab */
72 QList<IRCQueryTab> m_queryTabs; 76 QList<IRCQueryTab> m_queryTabs;
73}; 77};
74 78
75#endif /* __IRCSERVERTAB_H */ 79#endif /* __IRCSERVERTAB_H */
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp
index 122a943..1cc1ee2 100644
--- a/noncore/net/opieirc/ircsession.cpp
+++ b/noncore/net/opieirc/ircsession.cpp
@@ -1,111 +1,146 @@
1#include "ircsession.h" 1#include "ircsession.h"
2#include "ircmessageparser.h" 2#include "ircmessageparser.h"
3#include "ircversion.h" 3#include "ircversion.h"
4 4
5IRCSession::IRCSession(IRCServer *server) { 5IRCSession::IRCSession(IRCServer *server) {
6 m_server = server; 6 m_server = server;
7 m_connection = new IRCConnection(m_server); 7 m_connection = new IRCConnection(m_server);
8 m_parser = new IRCMessageParser(this); 8 m_parser = new IRCMessageParser(this);
9 connect(m_connection, SIGNAL(messageArrived(IRCMessage *)), this, SLOT(handleMessage(IRCMessage *))); 9 connect(m_connection, SIGNAL(messageArrived(IRCMessage *)), this, SLOT(handleMessage(IRCMessage *)));
10 connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); 10 connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
11 connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); 11 connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
12} 12}
13 13
14IRCSession::~IRCSession() { 14IRCSession::~IRCSession() {
15 /* We want this to get deleted automatically */ 15 /* We want this to get deleted automatically */
16 m_channels.setAutoDelete(TRUE); 16 m_channels.setAutoDelete(TRUE);
17 m_people.setAutoDelete(TRUE); 17 m_people.setAutoDelete(TRUE);
18 18
19 delete m_parser; 19 delete m_parser;
20 delete m_connection; 20 delete m_connection;
21} 21}
22 22
23void IRCSession::beginSession() { 23void IRCSession::beginSession() {
24 m_connection->doConnect(); 24 m_connection->doConnect();
25} 25}
26 26
27void IRCSession::join(QString channelname) { 27void IRCSession::join(QString channelname) {
28 m_connection->sendLine("JOIN "+channelname); 28 m_connection->sendLine("JOIN "+channelname);
29} 29}
30 30
31void IRCSession::quit(){
32 m_connection->sendLine("QUIT :[OI] I'm too good to need a reason");
33}
34
35void IRCSession::quit(QString message){
36 m_connection->sendLine("QUIT :" + message);
37}
38
39void IRCSession::topic(IRCChannel *channel, QString message){
40 m_connection->sendLine("TOPIC :" + channel->channelname() + " " + message);
41}
42
43void IRCSession::mode(IRCChannel *channel, QString message){
44 m_connection->sendLine("MODE " + channel->channelname() + " " + message);
45}
46
47void IRCSession::mode(IRCPerson *person, QString message){
48 m_connection->sendLine("MODE " + person->nick() + " " + message);
49}
50
51void IRCSession::mode(QString message){
52 m_connection->sendLine("MODE " + message);
53}
54
55void IRCSession::raw(QString message){
56 m_connection->sendLine(message);
57}
58
59void IRCSession::kick(IRCChannel *channel, IRCPerson *person) {
60 m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason");
61}
62
63void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) {
64 m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message);
65}
66
31void IRCSession::sendMessage(IRCPerson *person, QString message) { 67void IRCSession::sendMessage(IRCPerson *person, QString message) {
32 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); 68 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message);
33} 69}
34 70
35void IRCSession::sendMessage(IRCChannel *channel, QString message) { 71void IRCSession::sendMessage(IRCChannel *channel, QString message) {
36 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); 72 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message);
37} 73}
38 74
39void IRCSession::sendAction(IRCChannel *channel, QString message) { 75void IRCSession::sendAction(IRCChannel *channel, QString message) {
40 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001"); 76 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001");
41} 77}
42 78
43void IRCSession::sendAction(IRCPerson *person, QString message) { 79void IRCSession::sendAction(IRCPerson *person, QString message) {
44 m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001"); 80 m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001");
45} 81}
46 82
47bool IRCSession::isSessionActive() { 83bool IRCSession::isSessionActive() {
48 return m_connection->isConnected(); 84 return m_connection->isConnected();
49} 85}
50 86
51void IRCSession::endSession() { 87void IRCSession::endSession() {
52 if (m_connection->isLoggedIn()) 88 if (m_connection->isLoggedIn())
53 m_connection->sendLine("QUIT :" APP_VERSION); 89 m_connection->sendLine("QUIT :" APP_VERSION);
54 else 90 else
55 m_connection->close(); 91 m_connection->close();
56} 92}
57 93
58void IRCSession::part(IRCChannel *channel) { 94void IRCSession::part(IRCChannel *channel) {
59 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); 95 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION);
60} 96}
61 97
62 98
63IRCChannel *IRCSession::getChannel(QString channelname) { 99IRCChannel *IRCSession::getChannel(QString channelname) {
64 QListIterator<IRCChannel> it(m_channels); 100 QListIterator<IRCChannel> it(m_channels);
65 for (; it.current(); ++it) { 101 for (; it.current(); ++it) {
66 if (it.current()->channelname() == channelname) { 102 if (it.current()->channelname() == channelname) {
67 return it.current(); 103 return it.current();
68 } 104 }
69 } 105 }
70 return 0; 106 return 0;
71} 107}
72 108
73IRCPerson *IRCSession::getPerson(QString nickname) { 109IRCPerson *IRCSession::getPerson(QString nickname) {
74 QListIterator<IRCPerson> it(m_people); 110 QListIterator<IRCPerson> it(m_people);
75 for (; it.current(); ++it) { 111 for (; it.current(); ++it) {
76 if (it.current()->nick() == nickname) { 112 if (it.current()->nick() == nickname) {
77 return it.current(); 113 return it.current();
78 } 114 }
79 } 115 }
80 return 0; 116 return 0;
81} 117}
82 118
83void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) { 119void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) {
84 QListIterator<IRCChannel> it(m_channels); 120 QListIterator<IRCChannel> it(m_channels);
85 for (; it.current(); ++it) { 121 for (; it.current(); ++it) {
86 if (it.current()->getPerson(person->nick()) != 0) { 122 if (it.current()->getPerson(person->nick()) != 0) {
87 channels.append(it.current()); 123 channels.append(it.current());
88 } 124 }
89 } 125 }
90} 126}
91 127
92void IRCSession::addPerson(IRCPerson *person) { 128void IRCSession::addPerson(IRCPerson *person) {
93 m_people.append(person); 129 m_people.append(person);
94} 130}
95 131
96void IRCSession::addChannel(IRCChannel *channel) { 132void IRCSession::addChannel(IRCChannel *channel) {
97 m_channels.append(channel); 133 m_channels.append(channel);
98} 134}
99 135
100void IRCSession::removeChannel(IRCChannel *channel) { 136void IRCSession::removeChannel(IRCChannel *channel) {
101 m_channels.remove(channel); 137 m_channels.remove(channel);
102} 138}
103 139
104void IRCSession::removePerson(IRCPerson *person) { 140void IRCSession::removePerson(IRCPerson *person) {
105 m_people.remove(person); 141 m_people.remove(person);
106} 142}
107 143
108void IRCSession::handleMessage(IRCMessage *message) { 144void IRCSession::handleMessage(IRCMessage *message) {
109 m_parser->parse(message); 145 m_parser->parse(message);
110} 146}
111
diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h
index aa4bed3..a6a3e50 100644
--- a/noncore/net/opieirc/ircsession.h
+++ b/noncore/net/opieirc/ircsession.h
@@ -1,75 +1,83 @@
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 __IRCSESSION_H 21#ifndef __IRCSESSION_H
22#define __IRCSESSION_H 22#define __IRCSESSION_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qlist.h> 25#include <qlist.h>
26#include "ircserver.h" 26#include "ircserver.h"
27#include "ircconnection.h" 27#include "ircconnection.h"
28#include "ircmessage.h" 28#include "ircmessage.h"
29#include "ircchannel.h" 29#include "ircchannel.h"
30#include "ircoutput.h" 30#include "ircoutput.h"
31 31
32class IRCMessageParser; 32class IRCMessageParser;
33 33
34/* The IRCSession stores all information relating to the connection 34/* The IRCSession stores all information relating to the connection
35 to one IRC server. IRCSession makes it possible to run multiple 35 to one IRC server. IRCSession makes it possible to run multiple
36 IRC server connections from within the same program */ 36 IRC server connections from within the same program */
37 37
38class IRCSession : public QObject { 38class IRCSession : public QObject {
39friend class IRCMessageParser; 39friend class IRCMessageParser;
40 Q_OBJECT 40 Q_OBJECT
41public: 41public:
42 IRCSession(IRCServer *server); 42 IRCSession(IRCServer *server);
43 ~IRCSession(); 43 ~IRCSession();
44 44
45 void join(QString channel); 45 void join(QString channel);
46 void quit(QString message);
47 void quit();
48 void raw(QString message);
49 void topic(IRCChannel *channel, QString message);
50 void mode(IRCChannel *channel, QString message);
51 void mode(IRCPerson *person, QString message);
52 void mode(QString message);
46 void part(IRCChannel *channel); 53 void part(IRCChannel *channel);
54 void kick(IRCChannel *channel, IRCPerson *person);
55 void kick(IRCChannel *channel, IRCPerson *person, QString message);
47 void beginSession(); 56 void beginSession();
48 bool isSessionActive(); 57 bool isSessionActive();
49 void endSession(); 58 void endSession();
50
51 void sendMessage(IRCPerson *person, QString message); 59 void sendMessage(IRCPerson *person, QString message);
52 void sendMessage(IRCChannel *channel, QString message); 60 void sendMessage(IRCChannel *channel, QString message);
53 void sendAction(IRCPerson *person, QString message); 61 void sendAction(IRCPerson *person, QString message);
54 void sendAction(IRCChannel *channel, QString message); 62 void sendAction(IRCChannel *channel, QString message);
55 IRCChannel *getChannel(QString channelname); 63 IRCChannel *getChannel(QString channelname);
56 IRCPerson *getPerson(QString nickname); 64 IRCPerson *getPerson(QString nickname);
57protected: 65protected:
58 void addPerson(IRCPerson *person); 66 void addPerson(IRCPerson *person);
59 void addChannel(IRCChannel *channel); 67 void addChannel(IRCChannel *channel);
60 void removeChannel(IRCChannel *channel); 68 void removeChannel(IRCChannel *channel);
61 void removePerson(IRCPerson *person); 69 void removePerson(IRCPerson *person);
62 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels); 70 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels);
63protected slots: 71protected slots:
64 void handleMessage(IRCMessage *message); 72 void handleMessage(IRCMessage *message);
65signals: 73signals:
66 void outputReady(IRCOutput output); 74 void outputReady(IRCOutput output);
67protected: 75protected:
68 IRCServer *m_server; 76 IRCServer *m_server;
69 IRCConnection *m_connection; 77 IRCConnection *m_connection;
70 IRCMessageParser *m_parser; 78 IRCMessageParser *m_parser;
71 QList<IRCChannel> m_channels; 79 QList<IRCChannel> m_channels;
72 QList<IRCPerson> m_people; 80 QList<IRCPerson> m_people;
73}; 81};
74 82
75#endif /* __IRCSESSION_H */ 83#endif /* __IRCSESSION_H */
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp
index 3ed29e3..8f76cdd 100644
--- a/noncore/net/opieirc/mainwindow.cpp
+++ b/noncore/net/opieirc/mainwindow.cpp
@@ -1,88 +1,93 @@
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#include <qwhatsthis.h> 5#include <qwhatsthis.h>
6 6
7#include "mainwindow.h" 7#include "mainwindow.h"
8#include "ircservertab.h" 8#include "ircservertab.h"
9#include "ircserverlist.h" 9#include "ircserverlist.h"
10#include "ircsettings.h" 10#include "ircsettings.h"
11 11
12MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 12MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
13 setCaption(tr("IRC Client")); 13 setCaption(tr("IRC Client"));
14 m_tabWidget = new IRCTabWidget(this); 14 m_tabWidget = new IRCTabWidget(this);
15 QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here")); 15 QWhatsThis::add(m_tabWidget, tr("Server connections, channels, queries and other things will be placed here"));
16 connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *))); 16 connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(selected(QWidget *)));
17 setCentralWidget(m_tabWidget); 17 setCentralWidget(m_tabWidget);
18 setToolBarsMovable(FALSE); 18 setToolBarsMovable(FALSE);
19 QPEMenuBar *menuBar = new QPEMenuBar(this); 19 QPEMenuBar *menuBar = new QPEMenuBar(this);
20 QPopupMenu *irc = new QPopupMenu(this); 20 QPopupMenu *irc = new QPopupMenu(this);
21 menuBar->insertItem(tr("IRC"), irc); 21 menuBar->insertItem(tr("IRC"), irc);
22 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); 22 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0);
23 connect(a, SIGNAL(activated()), this, SLOT(newConnection())); 23 connect(a, SIGNAL(activated()), this, SLOT(newConnection()));
24 a->setWhatsThis(tr("Create a new connection to an IRC server")); 24 a->setWhatsThis(tr("Create a new connection to an IRC server"));
25 a->addTo(irc); 25 a->addTo(irc);
26 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0); 26 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0);
27 a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance")); 27 a->setWhatsThis(tr("Configure OpieIRC's behavior and appearance"));
28 connect(a, SIGNAL(activated()), this, SLOT(settings())); 28 connect(a, SIGNAL(activated()), this, SLOT(settings()));
29 a->addTo(irc); 29 a->addTo(irc);
30 loadSettings(); 30 loadSettings();
31} 31}
32 32
33/*IRCTabWidget MainWindow::getTabWidget(){
34 return m_tabWidget;
35} */
36
33void MainWindow::loadSettings() { 37void MainWindow::loadSettings() {
34 Config config("OpieIRC"); 38 Config config("OpieIRC");
35 config.setGroup("OpieIRC"); 39 config.setGroup("OpieIRC");
36 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF"); 40 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF");
37 IRCTab::m_textColor = config.readEntry("TextColor", "#000000"); 41 IRCTab::m_textColor = config.readEntry("TextColor", "#000000");
38 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000"); 42 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000");
39 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000"); 43 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000");
40 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB"); 44 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB");
41 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF"); 45 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
42 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300"); 46 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
43 IRCTab::m_maxLines = config.readNumEntry("Lines", 100); 47 IRCTab::m_maxLines = config.readNumEntry("Lines", 100);
44} 48}
45 49
46void MainWindow::selected(QWidget *) { 50void MainWindow::selected(QWidget *) {
47 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black); 51 m_tabWidget->setTabColor(m_tabWidget->currentPageIndex(), black);
52 emit updateScroll();
48} 53}
49 54
50void MainWindow::addTab(IRCTab *tab) { 55void MainWindow::addTab(IRCTab *tab) {
51 connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *))); 56 connect(tab, SIGNAL(changed(IRCTab *)), this, SLOT(changeEvent(IRCTab *)));
52 m_tabWidget->addTab(tab, tab->title()); 57 m_tabWidget->addTab(tab, tab->title());
53 m_tabWidget->showPage(tab); 58 m_tabWidget->showPage(tab);
54 tab->setID(m_tabWidget->currentPageIndex()); 59 tab->setID(m_tabWidget->currentPageIndex());
55 m_tabs.append(tab); 60 m_tabs.append(tab);
56} 61}
57 62
58void MainWindow::changeEvent(IRCTab *tab) { 63void MainWindow::changeEvent(IRCTab *tab) {
59 if (tab->id() != m_tabWidget->currentPageIndex()) 64 if (tab->id() != m_tabWidget->currentPageIndex())
60 m_tabWidget->setTabColor(tab->id(), blue); 65 m_tabWidget->setTabColor(tab->id(), blue);
61} 66}
62 67
63void MainWindow::killTab(IRCTab *tab) { 68void MainWindow::killTab(IRCTab *tab) {
64 m_tabWidget->removePage(tab); 69 m_tabWidget->removePage(tab);
65 m_tabs.remove(tab); 70 m_tabs.remove(tab);
66 /* there might be nicer ways to do this .. */ 71 /* there might be nicer ways to do this .. */
67 delete tab; 72 delete tab;
68} 73}
69 74
70void MainWindow::newConnection() { 75void MainWindow::newConnection() {
71 IRCServerList list(this, "ServerList", TRUE); 76 IRCServerList list(this, "ServerList", TRUE);
72 if (list.exec() == QDialog::Accepted && list.hasServer()) { 77 if (list.exec() == QDialog::Accepted && list.hasServer()) {
73 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget); 78 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget);
74 addTab(serverTab); 79 addTab(serverTab);
75 serverTab->doConnect(); 80 serverTab->doConnect();
76 } 81 }
77} 82}
78 83
79void MainWindow::settings() { 84void MainWindow::settings() {
80 IRCSettings settings(this, "Settings", TRUE); 85 IRCSettings settings(this, "Settings", TRUE);
81 if (settings.exec() == QDialog::Accepted) { 86 if (settings.exec() == QDialog::Accepted) {
82 QListIterator<IRCTab> it(m_tabs); 87 QListIterator<IRCTab> it(m_tabs);
83 for (; it.current(); ++it) { 88 for (; it.current(); ++it) {
84 /* Inform all tabs about the new settings */ 89 /* Inform all tabs about the new settings */
85 it.current()->settingsChanged(); 90 it.current()->settingsChanged();
86 } 91 }
87 } 92 }
88} 93}
diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h
index 9946f10..bd1a9ce 100644
--- a/noncore/net/opieirc/mainwindow.h
+++ b/noncore/net/opieirc/mainwindow.h
@@ -1,50 +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 __MAINWINDOW_H 21#ifndef __MAINWINDOW_H
22#define __MAINWINDOW_H 22#define __MAINWINDOW_H
23 23
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qaction.h> 25#include <qaction.h>
26#include <qlist.h> 26#include <qlist.h>
27#include "mainwindow.h" 27#include "mainwindow.h"
28#include "ircmisc.h" 28#include "ircmisc.h"
29#include "irctab.h" 29#include "irctab.h"
30 30
31class MainWindow : public QMainWindow { 31class MainWindow : public QMainWindow {
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 34 MainWindow(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
35 35// IRCTabWidget getTabWidget();
36 void addTab(IRCTab *tab); 36 void addTab(IRCTab *tab);
37 void killTab(IRCTab *tab); 37 void killTab(IRCTab *tab);
38signals:
39 void updateScroll();
38protected slots: 40protected slots:
39 void newConnection(); 41 void newConnection();
40 void settings(); 42 void settings();
41 void selected(QWidget *); 43 void selected(QWidget *);
42 void changeEvent(IRCTab *); 44 void changeEvent(IRCTab *);
43protected: 45protected:
44 void loadSettings(); 46 void loadSettings();
45protected: 47protected:
46 IRCTabWidget *m_tabWidget; 48 IRCTabWidget *m_tabWidget;
47 QList<IRCTab> m_tabs; 49 QList<IRCTab> m_tabs;
48}; 50};
49 51
50#endif /* __MAINWINDOW_H */ 52#endif /* __MAINWINDOW_H */