summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp4
-rw-r--r--noncore/net/opieirc/ircoutput.cpp6
-rw-r--r--noncore/net/opieirc/ircoutput.h2
-rw-r--r--noncore/net/opieirc/ircservertab.cpp11
-rw-r--r--noncore/net/opieirc/ircsession.cpp8
-rw-r--r--noncore/net/opieirc/ircsession.h2
6 files changed, 31 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index 754442a..3267525 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,93 +1,95 @@
1#include <qhbox.h> 1#include <qhbox.h>
2#include "ircchanneltab.h" 2#include "ircchanneltab.h"
3#include "ircservertab.h" 3#include "ircservertab.h"
4 4
5IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 5IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_mainWindow = mainWindow; 6 m_mainWindow = mainWindow;
7 m_parentTab = parentTab; 7 m_parentTab = parentTab;
8 m_channel = channel; 8 m_channel = channel;
9 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 9 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
10 QHBox *hbox = new QHBox(this); 10 QHBox *hbox = new QHBox(this);
11 m_textview = new QTextView(hbox); 11 m_textview = new QTextView(hbox);
12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
14 m_listVisible = TRUE; 14 m_listVisible = TRUE;
15 m_listButton = new QPushButton(">", m_textview); 15 m_listButton = new QPushButton(">", m_textview);
16 m_textview->setCornerWidget(m_listButton); 16 m_textview->setCornerWidget(m_listButton);
17 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 17 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
18 m_list = new IRCChannelList(m_channel, hbox); 18 m_list = new IRCChannelList(m_channel, hbox);
19 m_list->update(); 19 m_list->update();
20 m_list->setMaximumWidth(LISTWIDTH); 20 m_list->setMaximumWidth(LISTWIDTH);
21 m_field = new QLineEdit(this); 21 m_field = new QLineEdit(this);
22 m_layout->add(hbox); 22 m_layout->add(hbox);
23 hbox->show(); 23 hbox->show();
24 m_layout->add(m_field); 24 m_layout->add(m_field);
25 m_field->setFocus(); 25 m_field->setFocus();
26 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 26 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
27 27
28} 28}
29 29
30void IRCChannelTab::appendText(QString text) { 30void IRCChannelTab::appendText(QString text) {
31 /* not using append because it creates layout problems */ 31 /* not using append because it creates layout problems */
32 m_textview->setText(m_textview->text() + text); 32 m_textview->setText(m_textview->text() + text);
33 m_textview->ensureVisible(0, m_textview->contentsHeight()); 33 m_textview->ensureVisible(0, m_textview->contentsHeight());
34} 34}
35 35
36IRCChannelTab::~IRCChannelTab() { 36IRCChannelTab::~IRCChannelTab() {
37 m_parentTab->removeChannelTab(this); 37 m_parentTab->removeChannelTab(this);
38} 38}
39 39
40void IRCChannelTab::processCommand() { 40void IRCChannelTab::processCommand() {
41 QString text = m_field->text(); 41 QString text = m_field->text();
42 if (text.length()>0) { 42 if (text.length()>0) {
43 if (session()->isSessionActive()) { 43 if (session()->isSessionActive()) {
44 if (text.startsWith("/") && !text.startsWith("//")) { 44 if (text.startsWith("/") && !text.startsWith("//")) {
45 /* Command mode */ 45 /* Command mode */
46 m_parentTab->executeCommand(this, text);; 46 m_parentTab->executeCommand(this, text);;
47 } else { 47 } else {
48 if (text.startsWith("//"))
49 text = text.right(text.length()-1);
48 if (session()->isSessionActive()) { 50 if (session()->isSessionActive()) {
49 session()->sendMessage(m_channel, m_field->text()); 51 session()->sendMessage(m_channel, m_field->text());
50 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+m_field->text()+"<br>"); 52 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>");
51 } 53 }
52 } 54 }
53 } else { 55 } else {
54 appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); 56 appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>");
55 } 57 }
56 } 58 }
57 m_field->clear(); 59 m_field->clear();
58} 60}
59 61
60void IRCChannelTab::toggleList() { 62void IRCChannelTab::toggleList() {
61 if (m_listVisible) { 63 if (m_listVisible) {
62 m_list->setMaximumWidth(0); 64 m_list->setMaximumWidth(0);
63 m_listButton->setText("<"); 65 m_listButton->setText("<");
64 } else { 66 } else {
65 m_list->setMaximumWidth(LISTWIDTH); 67 m_list->setMaximumWidth(LISTWIDTH);
66 m_listButton->setText(">"); 68 m_listButton->setText(">");
67 } 69 }
68 m_listVisible = !m_listVisible; 70 m_listVisible = !m_listVisible;
69} 71}
70 72
71QString IRCChannelTab::title() { 73QString IRCChannelTab::title() {
72 return m_channel->channelname(); 74 return m_channel->channelname();
73} 75}
74 76
75IRCSession *IRCChannelTab::session() { 77IRCSession *IRCChannelTab::session() {
76 return m_parentTab->session(); 78 return m_parentTab->session();
77} 79}
78 80
79void IRCChannelTab::remove() { 81void IRCChannelTab::remove() {
80 if (session()->isSessionActive()) { 82 if (session()->isSessionActive()) {
81 session()->part(m_channel); 83 session()->part(m_channel);
82 } else { 84 } else {
83 m_mainWindow->killTab(this); 85 m_mainWindow->killTab(this);
84 } 86 }
85} 87}
86 88
87IRCChannel *IRCChannelTab::channel() { 89IRCChannel *IRCChannelTab::channel() {
88 return m_channel; 90 return m_channel;
89} 91}
90 92
91IRCChannelList *IRCChannelTab::list() { 93IRCChannelList *IRCChannelTab::list() {
92 return m_list; 94 return m_list;
93} 95}
diff --git a/noncore/net/opieirc/ircoutput.cpp b/noncore/net/opieirc/ircoutput.cpp
index 878bc9b..4822fc4 100644
--- a/noncore/net/opieirc/ircoutput.cpp
+++ b/noncore/net/opieirc/ircoutput.cpp
@@ -1,29 +1,33 @@
1#include "ircoutput.h" 1#include "ircoutput.h"
2 2
3IRCOutput::IRCOutput(IRCOutputType type, QString message) { 3IRCOutput::IRCOutput(IRCOutputType type, QString message) {
4 m_type = type; 4 m_type = type;
5 m_message = message; 5 m_message = message;
6} 6}
7 7
8IRCOutputType IRCOutput::type() { 8IRCOutputType IRCOutput::type() {
9 return m_type; 9 return m_type;
10} 10}
11 11
12QString IRCOutput::message() { 12QString IRCOutput::message() {
13 return m_message; 13 return m_message;
14} 14}
15 15
16QString IRCOutput::htmlMessage() { 16QString IRCOutput::htmlMessage() {
17 QString htmlMessage =m_message.replace(QRegExp("&"), "&amp;"); 17 return toHTML(m_message);
18}
19
20QString IRCOutput::toHTML(QString message) {
21 QString htmlMessage =message.replace(QRegExp("&"), "&amp;");
18 htmlMessage = htmlMessage.replace(QRegExp(">"), "&gt;"); 22 htmlMessage = htmlMessage.replace(QRegExp(">"), "&gt;");
19 htmlMessage = htmlMessage.replace(QRegExp("<"), "&lt;"); 23 htmlMessage = htmlMessage.replace(QRegExp("<"), "&lt;");
20 return htmlMessage; 24 return htmlMessage;
21} 25}
22 26
23void IRCOutput::addParam(void *data) { 27void IRCOutput::addParam(void *data) {
24 m_parameters.append(data); 28 m_parameters.append(data);
25} 29}
26 30
27void *IRCOutput::getParam(int index) { 31void *IRCOutput::getParam(int index) {
28 return m_parameters.at(index); 32 return m_parameters.at(index);
29} 33}
diff --git a/noncore/net/opieirc/ircoutput.h b/noncore/net/opieirc/ircoutput.h
index 72361d4..e8cc524 100644
--- a/noncore/net/opieirc/ircoutput.h
+++ b/noncore/net/opieirc/ircoutput.h
@@ -17,56 +17,58 @@
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 __IRCOUTPUT_H 21#ifndef __IRCOUTPUT_H
22#define __IRCOUTPUT_H 22#define __IRCOUTPUT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qlist.h> 25#include <qlist.h>
26#include "ircchannel.h" 26#include "ircchannel.h"
27 27
28/* Types of possible IRC output */ 28/* Types of possible IRC output */
29enum IRCOutputType { 29enum IRCOutputType {
30 OUTPUT_ERROR = -1, /* parameters : none */ 30 OUTPUT_ERROR = -1, /* parameters : none */
31 OUTPUT_SERVERMESSAGE = 0, /* parameters : none */ 31 OUTPUT_SERVERMESSAGE = 0, /* parameters : none */
32 OUTPUT_CLIENTMESSAGE = 1, /* parameters : none */ 32 OUTPUT_CLIENTMESSAGE = 1, /* parameters : none */
33 OUTPUT_CHANPRIVMSG = 2, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ 33 OUTPUT_CHANPRIVMSG = 2, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */
34 OUTPUT_QUERYPRIVMSG = 3, /* parameters : person (IRCPerson) */ 34 OUTPUT_QUERYPRIVMSG = 3, /* parameters : person (IRCPerson) */
35 OUTPUT_NICKCHANGE = 4, /* parameters : person (IRCPerson) */ 35 OUTPUT_NICKCHANGE = 4, /* parameters : person (IRCPerson) */
36 OUTPUT_SELFJOIN = 5, /* parameters : channel (IRCChannel) */ 36 OUTPUT_SELFJOIN = 5, /* parameters : channel (IRCChannel) */
37 OUTPUT_OTHERJOIN = 6, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ 37 OUTPUT_OTHERJOIN = 6, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */
38 OUTPUT_SELFPART = 7, /* parameters : channel (IRCChannel) */ 38 OUTPUT_SELFPART = 7, /* parameters : channel (IRCChannel) */
39 OUTPUT_OTHERPART = 8, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ 39 OUTPUT_OTHERPART = 8, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */
40 OUTPUT_QUIT = 9, /* parameters : person (IRCPerson) */ 40 OUTPUT_QUIT = 9, /* parameters : person (IRCPerson) */
41 OUTPUT_CONNCLOSE = 10, /* parameters : none */ 41 OUTPUT_CONNCLOSE = 10, /* parameters : none */
42 OUTPUT_CTCP = 11, /* parameters : none */ 42 OUTPUT_CTCP = 11, /* parameters : none */
43 OUTPUT_SELFKICK = 12, /* parameters : channel (IRCChannel) */ 43 OUTPUT_SELFKICK = 12, /* parameters : channel (IRCChannel) */
44 OUTPUT_OTHERKICK = 13, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */ 44 OUTPUT_OTHERKICK = 13, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */
45 OUTPUT_CHANACTION = 14, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */ 45 OUTPUT_CHANACTION = 14, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */
46 OUTPUT_QUERYACTION = 15, /* parameters : person (IRCPerson) */ 46 OUTPUT_QUERYACTION = 15, /* parameters : person (IRCPerson) */
47 OUTPUT_CHANPERSONMODE = 16 /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */ 47 OUTPUT_CHANPERSONMODE = 16 /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */
48}; 48};
49 49
50/* The IRCOutput class is used as a kind of message which is sent by the 50/* The IRCOutput class is used as a kind of message which is sent by the
51 IRC parser to inform the GUI of changes. This could for example be a 51 IRC parser to inform the GUI of changes. This could for example be a
52 channel message or a nickname change */ 52 channel message or a nickname change */
53 53
54class IRCOutput { 54class IRCOutput {
55public: 55public:
56 IRCOutput(IRCOutputType type, QString message); 56 IRCOutput(IRCOutputType type, QString message);
57 /* Used to add a parameter to this IRCOutput. Parameters are dependent 57 /* Used to add a parameter to this IRCOutput. Parameters are dependent
58 on which IRCOutputType we are using (see above) */ 58 on which IRCOutputType we are using (see above) */
59 void addParam(void *data); 59 void addParam(void *data);
60 60
61 IRCOutputType type(); 61 IRCOutputType type();
62 QString message(); 62 QString message();
63 /* Return the message with all HTML code escaped (for example &lt; instead of '<') */ 63 /* Return the message with all HTML code escaped (for example &lt; instead of '<') */
64 QString htmlMessage(); 64 QString htmlMessage();
65
66 static QString toHTML(QString message);
65 void *getParam(int index); 67 void *getParam(int index);
66protected: 68protected:
67 IRCOutputType m_type; 69 IRCOutputType m_type;
68 QString m_message; 70 QString m_message;
69 QList<void> m_parameters; 71 QList<void> m_parameters;
70}; 72};
71 73
72#endif 74#endif
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 2ad56a8..503a758 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -14,96 +14,107 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
14 m_layout->add(m_textview); 14 m_layout->add(m_textview);
15 m_field = new QLineEdit(this); 15 m_field = new QLineEdit(this);
16 m_layout->add(m_field); 16 m_layout->add(m_field);
17 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 17 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
18 m_field->setFocus(); 18 m_field->setFocus();
19 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 19 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
20} 20}
21 21
22void IRCServerTab::appendText(QString text) { 22void IRCServerTab::appendText(QString text) {
23 /* not using append because it creates layout problems */ 23 /* not using append because it creates layout problems */
24 m_textview->setText(m_textview->text() + text); 24 m_textview->setText(m_textview->text() + text);
25 m_textview->ensureVisible(0, m_textview->contentsHeight()); 25 m_textview->ensureVisible(0, m_textview->contentsHeight());
26} 26}
27 27
28IRCServerTab::~IRCServerTab() { 28IRCServerTab::~IRCServerTab() {
29 delete m_session; 29 delete m_session;
30} 30}
31 31
32void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 32void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
33 m_channelTabs.remove(tab); 33 m_channelTabs.remove(tab);
34} 34}
35 35
36QString IRCServerTab::title() { 36QString IRCServerTab::title() {
37 return "Server"; 37 return "Server";
38} 38}
39 39
40IRCSession *IRCServerTab::session() { 40IRCSession *IRCServerTab::session() {
41 return m_session; 41 return m_session;
42} 42}
43 43
44IRCServer *IRCServerTab::server() { 44IRCServer *IRCServerTab::server() {
45 return &m_server; 45 return &m_server;
46} 46}
47 47
48void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 48void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
49 QTextIStream stream(&line); 49 QTextIStream stream(&line);
50 QString command; 50 QString command;
51 stream >> command; 51 stream >> command;
52 command = command.upper().right(command.length()-1); 52 command = command.upper().right(command.length()-1);
53 53
54 if (command == "JOIN") { 54 if (command == "JOIN") {
55 QString channel; 55 QString channel;
56 stream >> channel; 56 stream >> channel;
57 if (channel.length() > 0 && channel.startsWith("#")) { 57 if (channel.length() > 0 && channel.startsWith("#")) {
58 m_session->join(channel); 58 m_session->join(channel);
59 } else { 59 } else {
60 tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); 60 tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>");
61 } 61 }
62 } else if (command == "ME") {
63 QString text = IRCOutput::toHTML(line.right(line.length()-4));
64 if (text.length() > 0) {
65 if (tab->isA("IRCChannelTab")) {
66 tab->appendText("<font color=\"#cc0000\">*" + m_server.nick() + " " + text + "</font><br>");
67 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
68 } else if (tab->isA("IRCQueryTab")) {
69 } else {
70 tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>");
71 }
72 }
62 } else { 73 } else {
63 tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); 74 tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>");
64 } 75 }
65} 76}
66 77
67void IRCServerTab::processCommand() { 78void IRCServerTab::processCommand() {
68 QString text = m_field->text(); 79 QString text = m_field->text();
69 if (text.startsWith("/") && !text.startsWith("//")) { 80 if (text.startsWith("/") && !text.startsWith("//")) {
70 /* Command mode */ 81 /* Command mode */
71 executeCommand(this, text); 82 executeCommand(this, text);
72 } 83 }
73 m_field->clear(); 84 m_field->clear();
74} 85}
75 86
76void IRCServerTab::doConnect() { 87void IRCServerTab::doConnect() {
77 m_session->beginSession(); 88 m_session->beginSession();
78} 89}
79 90
80void IRCServerTab::remove() { 91void IRCServerTab::remove() {
81 /* Close requested */ 92 /* Close requested */
82 if (m_session->isSessionActive()) { 93 if (m_session->isSessionActive()) {
83 /* While there is a running session */ 94 /* While there is a running session */
84 m_close = TRUE; 95 m_close = TRUE;
85 m_session->endSession(); 96 m_session->endSession();
86 } else { 97 } else {
87 /* Session has previously been closed */ 98 /* Session has previously been closed */
88 m_channelTabs.first(); 99 m_channelTabs.first();
89 while (m_channelTabs.current() != 0) { 100 while (m_channelTabs.current() != 0) {
90 m_mainWindow->killTab(m_channelTabs.current()); 101 m_mainWindow->killTab(m_channelTabs.current());
91 } 102 }
92 m_mainWindow->killTab(this); 103 m_mainWindow->killTab(this);
93 } 104 }
94} 105}
95 106
96IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { 107IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
97 QListIterator<IRCChannelTab> it(m_channelTabs); 108 QListIterator<IRCChannelTab> it(m_channelTabs);
98 109
99 for (; it.current(); ++it) { 110 for (; it.current(); ++it) {
100 if (it.current()->channel() == channel) 111 if (it.current()->channel() == channel)
101 return it.current(); 112 return it.current();
102 } 113 }
103 return 0; 114 return 0;
104} 115}
105 116
106void IRCServerTab::display(IRCOutput output) { 117void IRCServerTab::display(IRCOutput output) {
107 118
108 /* All messages to be displayed inside the GUI get here */ 119 /* All messages to be displayed inside the GUI get here */
109 switch (output.type()) { 120 switch (output.type()) {
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp
index 89df68c..122a943 100644
--- a/noncore/net/opieirc/ircsession.cpp
+++ b/noncore/net/opieirc/ircsession.cpp
@@ -1,86 +1,94 @@
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::sendMessage(IRCPerson *person, QString message) { 31void IRCSession::sendMessage(IRCPerson *person, QString message) {
32 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); 32 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message);
33} 33}
34 34
35void IRCSession::sendMessage(IRCChannel *channel, QString message) { 35void IRCSession::sendMessage(IRCChannel *channel, QString message) {
36 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); 36 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message);
37} 37}
38 38
39void IRCSession::sendAction(IRCChannel *channel, QString message) {
40 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001");
41}
42
43void IRCSession::sendAction(IRCPerson *person, QString message) {
44 m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001");
45}
46
39bool IRCSession::isSessionActive() { 47bool IRCSession::isSessionActive() {
40 return m_connection->isConnected(); 48 return m_connection->isConnected();
41} 49}
42 50
43void IRCSession::endSession() { 51void IRCSession::endSession() {
44 if (m_connection->isLoggedIn()) 52 if (m_connection->isLoggedIn())
45 m_connection->sendLine("QUIT :" APP_VERSION); 53 m_connection->sendLine("QUIT :" APP_VERSION);
46 else 54 else
47 m_connection->close(); 55 m_connection->close();
48} 56}
49 57
50void IRCSession::part(IRCChannel *channel) { 58void IRCSession::part(IRCChannel *channel) {
51 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); 59 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION);
52} 60}
53 61
54 62
55IRCChannel *IRCSession::getChannel(QString channelname) { 63IRCChannel *IRCSession::getChannel(QString channelname) {
56 QListIterator<IRCChannel> it(m_channels); 64 QListIterator<IRCChannel> it(m_channels);
57 for (; it.current(); ++it) { 65 for (; it.current(); ++it) {
58 if (it.current()->channelname() == channelname) { 66 if (it.current()->channelname() == channelname) {
59 return it.current(); 67 return it.current();
60 } 68 }
61 } 69 }
62 return 0; 70 return 0;
63} 71}
64 72
65IRCPerson *IRCSession::getPerson(QString nickname) { 73IRCPerson *IRCSession::getPerson(QString nickname) {
66 QListIterator<IRCPerson> it(m_people); 74 QListIterator<IRCPerson> it(m_people);
67 for (; it.current(); ++it) { 75 for (; it.current(); ++it) {
68 if (it.current()->nick() == nickname) { 76 if (it.current()->nick() == nickname) {
69 return it.current(); 77 return it.current();
70 } 78 }
71 } 79 }
72 return 0; 80 return 0;
73} 81}
74 82
75void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) { 83void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) {
76 QListIterator<IRCChannel> it(m_channels); 84 QListIterator<IRCChannel> it(m_channels);
77 for (; it.current(); ++it) { 85 for (; it.current(); ++it) {
78 if (it.current()->getPerson(person->nick()) != 0) { 86 if (it.current()->getPerson(person->nick()) != 0) {
79 channels.append(it.current()); 87 channels.append(it.current());
80 } 88 }
81 } 89 }
82} 90}
83 91
84void IRCSession::addPerson(IRCPerson *person) { 92void IRCSession::addPerson(IRCPerson *person) {
85 m_people.append(person); 93 m_people.append(person);
86} 94}
diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h
index 59c26aa..aa4bed3 100644
--- a/noncore/net/opieirc/ircsession.h
+++ b/noncore/net/opieirc/ircsession.h
@@ -5,69 +5,71 @@
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 part(IRCChannel *channel); 46 void part(IRCChannel *channel);
47 void beginSession(); 47 void beginSession();
48 bool isSessionActive(); 48 bool isSessionActive();
49 void endSession(); 49 void endSession();
50 50
51 void sendMessage(IRCPerson *person, QString message); 51 void sendMessage(IRCPerson *person, QString message);
52 void sendMessage(IRCChannel *channel, QString message); 52 void sendMessage(IRCChannel *channel, QString message);
53 void sendAction(IRCPerson *person, QString message);
54 void sendAction(IRCChannel *channel, QString message);
53 IRCChannel *getChannel(QString channelname); 55 IRCChannel *getChannel(QString channelname);
54 IRCPerson *getPerson(QString nickname); 56 IRCPerson *getPerson(QString nickname);
55protected: 57protected:
56 void addPerson(IRCPerson *person); 58 void addPerson(IRCPerson *person);
57 void addChannel(IRCChannel *channel); 59 void addChannel(IRCChannel *channel);
58 void removeChannel(IRCChannel *channel); 60 void removeChannel(IRCChannel *channel);
59 void removePerson(IRCPerson *person); 61 void removePerson(IRCPerson *person);
60 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels); 62 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels);
61protected slots: 63protected slots:
62 void handleMessage(IRCMessage *message); 64 void handleMessage(IRCMessage *message);
63signals: 65signals:
64 void outputReady(IRCOutput output); 66 void outputReady(IRCOutput output);
65protected: 67protected:
66 IRCServer *m_server; 68 IRCServer *m_server;
67 IRCConnection *m_connection; 69 IRCConnection *m_connection;
68 IRCMessageParser *m_parser; 70 IRCMessageParser *m_parser;
69 QList<IRCChannel> m_channels; 71 QList<IRCChannel> m_channels;
70 QList<IRCPerson> m_people; 72 QList<IRCPerson> m_people;
71}; 73};
72 74
73#endif /* __IRCSESSION_H */ 75#endif /* __IRCSESSION_H */