author | skyhusker <skyhusker> | 2005-01-26 22:45:53 (UTC) |
---|---|---|
committer | skyhusker <skyhusker> | 2005-01-26 22:45:53 (UTC) |
commit | f85af28663814f3262f5ecfcd20a4b4f67c23067 (patch) (unidiff) | |
tree | 994bd8c5a9f361ca7eff8ef9fb404f89f6f90f78 | |
parent | cbaf2c1c6eb42bc8a283a40fe922603a44c29304 (diff) | |
download | opie-f85af28663814f3262f5ecfcd20a4b4f67c23067.zip opie-f85af28663814f3262f5ecfcd20a4b4f67c23067.tar.gz opie-f85af28663814f3262f5ecfcd20a4b4f67c23067.tar.bz2 |
* Created new class for IRCChannelPerson.
* Added whois, ping and version entries to channel popup menu.
* Fixed action on CTCP PING reply (was interpreted as a request).
-rw-r--r-- | noncore/net/opieirc/ircchannel.cpp | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchannel.h | 15 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchannellist.cpp | 16 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchannelperson.cpp | 62 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchannelperson.h | 34 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchanneltab.cpp | 18 | ||||
-rw-r--r-- | noncore/net/opieirc/ircconnection.cpp | 24 | ||||
-rw-r--r-- | noncore/net/opieirc/ircconnection.h | 6 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 100 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.h | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsession.cpp | 20 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsession.h | 4 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/net/opieirc/opieirc.pro | 6 |
15 files changed, 242 insertions, 75 deletions
diff --git a/noncore/net/opieirc/ircchannel.cpp b/noncore/net/opieirc/ircchannel.cpp index 5c380e5..5d81596 100644 --- a/noncore/net/opieirc/ircchannel.cpp +++ b/noncore/net/opieirc/ircchannel.cpp | |||
@@ -1,3 +1,4 @@ | |||
1 | #include "ircchannel.h" | 1 | #include "ircchannel.h" |
2 | #include "ircchannelperson.h" | ||
2 | 3 | ||
3 | IRCChannel::IRCChannel(QString channelname) { | 4 | IRCChannel::IRCChannel(QString channelname) { |
@@ -39,5 +40,5 @@ IRCChannelPerson *IRCChannel::getPerson(QString nickname) { | |||
39 | QListIterator<IRCChannelPerson> it(m_people); | 40 | QListIterator<IRCChannelPerson> it(m_people); |
40 | for (; it.current(); ++it) { | 41 | for (; it.current(); ++it) { |
41 | if (it.current()->person->nick() == nickname) { | 42 | if (it.current()->nick() == nickname) { |
42 | return it.current(); | 43 | return it.current(); |
43 | } | 44 | } |
diff --git a/noncore/net/opieirc/ircchannel.h b/noncore/net/opieirc/ircchannel.h index e78f182..a276f10 100644 --- a/noncore/net/opieirc/ircchannel.h +++ b/noncore/net/opieirc/ircchannel.h | |||
@@ -25,19 +25,8 @@ | |||
25 | #include <qlist.h> | 25 | #include <qlist.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include "ircperson.h" | ||
28 | 27 | ||
29 | /* Flags which a person can have inside a channel */ | 28 | #include "ircperson.h" |
30 | enum IRCChannelPersonFlag { | ||
31 | PERSON_FLAG_OP = 0x01, | ||
32 | PERSON_FLAG_VOICE = 0x02, | ||
33 | PERSON_FLAG_HALFOP = 0x04 | ||
34 | }; | ||
35 | 29 | ||
36 | /* This struct encapsulates a IRCPerson and adds | 30 | class IRCChannelPerson; |
37 | channel specific information */ | ||
38 | typedef struct IRCChannelPerson { | ||
39 | IRCPerson *person; | ||
40 | unsigned int flags; | ||
41 | }; | ||
42 | 31 | ||
43 | /* IRCChannel is the object-oriented representation | 32 | /* IRCChannel is the object-oriented representation |
diff --git a/noncore/net/opieirc/ircchannellist.cpp b/noncore/net/opieirc/ircchannellist.cpp index c32c535..8cf144e 100644 --- a/noncore/net/opieirc/ircchannellist.cpp +++ b/noncore/net/opieirc/ircchannellist.cpp | |||
@@ -1,4 +1,6 @@ | |||
1 | #include <qpe/resource.h> | 1 | #include <qpe/resource.h> |
2 | |||
2 | #include "ircchannellist.h" | 3 | #include "ircchannellist.h" |
4 | #include "ircchannelperson.h" | ||
3 | 5 | ||
4 | IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) { | 6 | IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) { |
@@ -14,12 +16,12 @@ void IRCChannelList::update() { | |||
14 | for (; it.current(); ++it) { | 16 | for (; it.current(); ++it) { |
15 | IRCChannelPerson *person = it.current(); | 17 | IRCChannelPerson *person = it.current(); |
16 | if (person->flags & PERSON_FLAG_OP) { | 18 | if (person->flags() & IRCChannelPerson::PERSON_FLAG_OP) { |
17 | insertItem(op, "1" + person->person->nick()); | 19 | insertItem(op, "1" + person->nick()); |
18 | } else if (person->flags & PERSON_FLAG_HALFOP) { | 20 | } else if (person->flags() & IRCChannelPerson::PERSON_FLAG_HALFOP) { |
19 | insertItem(op, "2" + person->person->nick()); | 21 | insertItem(op, "2" + person->nick()); |
20 | } else if (person->flags & PERSON_FLAG_VOICE) { | 22 | } else if (person->flags() & IRCChannelPerson::PERSON_FLAG_VOICE) { |
21 | insertItem(voice, "3" + person->person->nick()); | 23 | insertItem(voice, "3" + person->nick()); |
22 | } else { | 24 | } else { |
23 | insertItem("4" + person->person->nick()); | 25 | insertItem("4" + person->nick()); |
24 | } | 26 | } |
25 | } | 27 | } |
diff --git a/noncore/net/opieirc/ircchannelperson.cpp b/noncore/net/opieirc/ircchannelperson.cpp new file mode 100644 index 0000000..1e8ebe4 --- a/dev/null +++ b/noncore/net/opieirc/ircchannelperson.cpp | |||
@@ -0,0 +1,62 @@ | |||
1 | #include "ircperson.h" | ||
2 | #include "ircchannelperson.h" | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qobject.h> | ||
6 | |||
7 | IRCChannelPerson::IRCChannelPerson(IRCPerson *person) | ||
8 | { | ||
9 | m_person = person; | ||
10 | m_flags = 0; | ||
11 | } | ||
12 | |||
13 | IRCChannelPerson::~IRCChannelPerson() | ||
14 | { | ||
15 | //if(m_person) | ||
16 | // delete m_person; | ||
17 | } | ||
18 | |||
19 | QString IRCChannelPerson::setOp(const QString &nickname, bool set) | ||
20 | { | ||
21 | if(set) { | ||
22 | m_flags |= PERSON_FLAG_OP; | ||
23 | return ( nickname + QObject::tr(" gives channel operator status to ") + nick()); | ||
24 | } | ||
25 | |||
26 | m_flags &= 0xFFFF - PERSON_FLAG_OP; | ||
27 | return ( nickname + QObject::tr(" removes channel operator status from ") + nick()); | ||
28 | } | ||
29 | |||
30 | QString IRCChannelPerson::setVoice(const QString &nickname, bool set) | ||
31 | { | ||
32 | if(set) { | ||
33 | m_flags |= PERSON_FLAG_VOICE; | ||
34 | return ( nickname + QObject::tr(" gives voice to ") + nick() ); | ||
35 | } | ||
36 | |||
37 | m_flags &= 0xFFFF - PERSON_FLAG_VOICE; | ||
38 | return ( nickname + QObject::tr(" removes voice from ") + nick()); | ||
39 | } | ||
40 | |||
41 | QString IRCChannelPerson::nick() | ||
42 | { | ||
43 | if(m_person) | ||
44 | return m_person->nick(); | ||
45 | |||
46 | return QString::null; | ||
47 | } | ||
48 | |||
49 | void IRCChannelPerson::setFlags(int flags) | ||
50 | { | ||
51 | m_flags = flags; | ||
52 | } | ||
53 | |||
54 | void IRCChannelPerson::setNick(const QString &nickname) | ||
55 | { | ||
56 | m_person->setNick(nickname); | ||
57 | } | ||
58 | |||
59 | const unsigned int IRCChannelPerson::flags() | ||
60 | { | ||
61 | return m_flags; | ||
62 | } | ||
diff --git a/noncore/net/opieirc/ircchannelperson.h b/noncore/net/opieirc/ircchannelperson.h new file mode 100644 index 0000000..a8c4791 --- a/dev/null +++ b/noncore/net/opieirc/ircchannelperson.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef IRCCHANNELPERSON_H | ||
2 | #define IRCCHANNELPERSON_H | ||
3 | |||
4 | class QString; | ||
5 | class IRCPerson; | ||
6 | |||
7 | /* This class encapsulates a IRCPerson and adds | ||
8 | * channel specific information */ | ||
9 | class IRCChannelPerson { | ||
10 | |||
11 | public: | ||
12 | /* Flags which a person can have inside a channel */ | ||
13 | enum IRCChannelPersonFlag { | ||
14 | PERSON_FLAG_OP = 0x01, | ||
15 | PERSON_FLAG_VOICE = 0x02, | ||
16 | PERSON_FLAG_HALFOP = 0x04 | ||
17 | }; | ||
18 | |||
19 | IRCChannelPerson(IRCPerson *person = 0); | ||
20 | ~IRCChannelPerson(); | ||
21 | |||
22 | QString setOp(const QString &nickname, bool set); | ||
23 | QString setVoice(const QString &nickname, bool set); | ||
24 | QString nick(); | ||
25 | const unsigned int flags(); | ||
26 | void setFlags(int flags); | ||
27 | void setNick(const QString &nickname); | ||
28 | |||
29 | protected: | ||
30 | IRCPerson *m_person; | ||
31 | unsigned int m_flags; | ||
32 | }; | ||
33 | |||
34 | #endif | ||
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index 4a35929..3272a8a 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp | |||
@@ -8,4 +8,5 @@ | |||
8 | #include "ircmessageparser.h" | 8 | #include "ircmessageparser.h" |
9 | 9 | ||
10 | #include <opie2/odebug.h> | ||
10 | QDict<QString> IRCChannelTab::m_queuedMessages (17); | 11 | QDict<QString> IRCChannelTab::m_queuedMessages (17); |
11 | 12 | ||
@@ -42,9 +43,11 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW | |||
42 | connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); | 43 | connect(m_list, SIGNAL(mouseButtonPressed(int,QListBoxItem*,const QPoint&)), this, SLOT(mouseButtonPressed(int,QListBoxItem*,const QPoint&))); |
43 | /* Construct the popup menu */ | 44 | /* Construct the popup menu */ |
44 | QPopupMenu *ctcpMenu = new QPopupMenu(m_list); | 45 | //QPopupMenu *ctcpMenu = new QPopupMenu(m_list); |
45 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); | 46 | m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); |
46 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); | 47 | m_popup->insertSeparator(); |
47 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); | 48 | m_popup->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); |
48 | ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); | 49 | m_popup->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); |
50 | m_popup->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); | ||
51 | //m_popup->insertItem(ctcpMenu, "CTCP"); | ||
49 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); | 52 | connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); |
50 | m_layout->add(hbox); | 53 | m_layout->add(hbox); |
@@ -167,11 +170,16 @@ void IRCChannelTab::popupQuery() { | |||
167 | 170 | ||
168 | void IRCChannelTab::popupPing() { | 171 | void IRCChannelTab::popupPing() { |
169 | //HAHA, no wonder these don't work | 172 | if(m_list->currentItem() != -1) |
173 | m_parentTab->session()->sendCTCPPing(m_list->text(m_list->currentItem())); | ||
170 | } | 174 | } |
171 | 175 | ||
172 | void IRCChannelTab::popupVersion() { | 176 | void IRCChannelTab::popupVersion() { |
177 | if(m_list->currentItem() != -1) | ||
178 | m_parentTab->session()->sendCTCPRequest(m_list->text(m_list->currentItem()), "VERSION", ""); | ||
173 | } | 179 | } |
174 | 180 | ||
175 | void IRCChannelTab::popupWhois() { | 181 | void IRCChannelTab::popupWhois() { |
182 | if(m_list->currentItem() != -1) | ||
183 | m_parentTab->session()->whois(m_list->text(m_list->currentItem())); | ||
176 | } | 184 | } |
177 | 185 | ||
diff --git a/noncore/net/opieirc/ircconnection.cpp b/noncore/net/opieirc/ircconnection.cpp index 2325cca..88e63f7 100644 --- a/noncore/net/opieirc/ircconnection.cpp +++ b/noncore/net/opieirc/ircconnection.cpp | |||
@@ -1,4 +1,8 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | #include <string.h> | 2 | #include <string.h> |
3 | |||
4 | #include <qstringlist.h> | ||
5 | #include <qdatetime.h> | ||
6 | |||
3 | #include "ircconnection.h" | 7 | #include "ircconnection.h" |
4 | 8 | ||
@@ -29,6 +33,21 @@ void IRCConnection::sendLine(QString line) { | |||
29 | } | 33 | } |
30 | 34 | ||
31 | void IRCConnection::sendCTCP(QString nick, QString line) { | 35 | void IRCConnection::sendCTCPReply(const QString &nickname, const QString &type, const QString &args) { |
32 | sendLine("NOTICE " + nick + " :\001"+line+"\001"); | 36 | sendLine("NOTICE " + nickname + " :\001" + type + " " + args + "\001"); |
37 | } | ||
38 | |||
39 | void IRCConnection::sendCTCPRequest(const QString &nickname, const QString &type, const QString &args) { | ||
40 | sendLine("PRIVMSG " + nickname + " :\001" + type + " " + args + "\001"); | ||
41 | } | ||
42 | |||
43 | void IRCConnection::sendCTCPPing(const QString &nickname) { | ||
44 | QDateTime tm; | ||
45 | tm.setTime_t(0); | ||
46 | QString strtime = QString::number(tm.secsTo(QDateTime::currentDateTime())); | ||
47 | sendCTCPRequest(nickname, "PING", strtime); | ||
48 | } | ||
49 | |||
50 | void IRCConnection::whois(const QString &nickname) { | ||
51 | sendLine("WHOIS " + nickname); | ||
33 | } | 52 | } |
34 | 53 | ||
@@ -101,2 +120,3 @@ void IRCConnection::close() { | |||
101 | } | 120 | } |
102 | } | 121 | } |
122 | |||
diff --git a/noncore/net/opieirc/ircconnection.h b/noncore/net/opieirc/ircconnection.h index 75cdf6d..382b1c0 100644 --- a/noncore/net/opieirc/ircconnection.h +++ b/noncore/net/opieirc/ircconnection.h | |||
@@ -38,5 +38,9 @@ public: | |||
38 | void sendLine(QString line); | 38 | void sendLine(QString line); |
39 | /* used to send CTCP commands to the IRC server */ | 39 | /* used to send CTCP commands to the IRC server */ |
40 | void sendCTCP(QString nick, QString line); | 40 | void sendCTCPReply(const QString &nickname, const QString &type, const QString &args); |
41 | void sendCTCPRequest(const QString &nickname, const QString &type, const QString &args); | ||
42 | void sendCTCPPing(const QString &nickname); | ||
43 | void whois(const QString &nickname); | ||
44 | void sendCTCPping(const QString &nickname); | ||
41 | void close(); | 45 | void close(); |
42 | bool isConnected(); | 46 | bool isConnected(); |
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index cfad2c1..9c1492c 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -4,4 +4,6 @@ | |||
4 | #include "ircmessageparser.h" | 4 | #include "ircmessageparser.h" |
5 | #include "ircversion.h" | 5 | #include "ircversion.h" |
6 | #include "ircchannelperson.h" | ||
7 | //#include "transferreceiver.h" | ||
6 | 8 | ||
7 | /* Lookup table for literal commands */ | 9 | /* Lookup table for literal commands */ |
@@ -27,4 +29,5 @@ IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { | |||
27 | { "VERSION", FUNC(parseCTCPVersion) }, | 29 | { "VERSION", FUNC(parseCTCPVersion) }, |
28 | { "ACTION", FUNC(parseCTCPAction) }, | 30 | { "ACTION", FUNC(parseCTCPAction) }, |
31 | { "DCC", FUNC(parseCTCPDCC) }, | ||
29 | { 0 , 0 } | 32 | { 0 , 0 } |
30 | }; | 33 | }; |
@@ -51,8 +54,9 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { | |||
51 | { 265, "%1", "1", 0 }, // RPL_LOCALUSERS | 54 | { 265, "%1", "1", 0 }, // RPL_LOCALUSERS |
52 | { 266, "%1", "1", 0 }, // RPL_GLOBALUSERS | 55 | { 266, "%1", "1", 0 }, // RPL_GLOBALUSERS |
53 | { 311, QT_TR_NOOP("Whois %1 (%2@%3)\nReal name: %4"), "1:3,5" }, // RPL_WHOISUSER | 56 | { 311, QT_TR_NOOP("Whois %1 (%2@%3)\nReal name: %4"), "1:3,5", 0 }, // RPL_WHOISUSER |
54 | { 312, QT_TR_NOOP("%1 is using server %2"), "1,2", 0 }, // RPL_WHOISSERVER | 57 | { 312, QT_TR_NOOP("%1 is using server %2"), "1,2", 0 }, // RPL_WHOISSERVER |
55 | { 317, 0, 0, FUNC(parseNumericalWhoisIdle) }, // RPL_WHOISIDLE | 58 | { 317, 0, 0, FUNC(parseNumericalWhoisIdle) }, // RPL_WHOISIDLE |
56 | { 318, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOIS | 59 | { 318, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOIS |
60 | { 319, QT_TR_NOOP("%1 is on channels: %2"), "1,2", 0 }, // RPL_WHOISCHANNELS | ||
57 | { 320, "%1 %2", "1,2", 0}, // RPL_WHOISVIRT | 61 | { 320, "%1 %2", "1,2", 0}, // RPL_WHOISVIRT |
58 | { 332, 0, 0, FUNC(parseNumericalTopic) }, // RPL_TOPIC | 62 | { 332, 0, 0, FUNC(parseNumericalTopic) }, // RPL_TOPIC |
@@ -68,5 +72,5 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { | |||
68 | { 391, QT_TR_NOOP("Time on server %1 is %2"), "1,2", 0 }, // RPL_TIME | 72 | { 391, QT_TR_NOOP("Time on server %1 is %2"), "1,2", 0 }, // RPL_TIME |
69 | { 401, QT_TR_NOOP("Channel or nick %1 doesn't exists"), "1", 0 }, // ERR_NOSUCHNICK | 73 | { 401, QT_TR_NOOP("Channel or nick %1 doesn't exists"), "1", 0 }, // ERR_NOSUCHNICK |
70 | { 406, QT_TR_NOOP("There is no history information for %1"), "1" }, // ERR_WASNOSUCHNICK | 74 | { 406, QT_TR_NOOP("There is no history information for %1"), "1", 0 }, // ERR_WASNOSUCHNICK |
71 | { 409, "%1", "1", 0 }, // ERR_NOORIGIN | 75 | { 409, "%1", "1", 0 }, // ERR_NOORIGIN |
72 | { 411, "%1", "1", 0 }, // ERR_NORECIPIENT | 76 | { 411, "%1", "1", 0 }, // ERR_NORECIPIENT |
@@ -100,5 +104,5 @@ void IRCMessageParser::parse(IRCMessage *message) { | |||
100 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { | 104 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { |
101 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { | 105 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { |
102 | (this->*(ctcpParserProcTable[i].proc))(message); | 106 | parseCTCP(message, i); |
103 | return; | 107 | return; |
104 | } | 108 | } |
@@ -135,7 +139,14 @@ void IRCMessageParser::parseNumerical(IRCMessage *message, int position) { | |||
135 | } | 139 | } |
136 | 140 | ||
141 | void IRCMessageParser::parseCTCP(IRCMessage *message, int position) { | ||
142 | if(ctcpParserProcTable[position].proc) | ||
143 | (this->*(ctcpParserProcTable[position].proc))(message); | ||
144 | } | ||
145 | |||
146 | |||
147 | |||
137 | void IRCMessageParser::parseNumericalServerName(IRCMessage *message) { | 148 | void IRCMessageParser::parseNumericalServerName(IRCMessage *message) { |
138 | emit outputReady(IRCOutput(OUTPUT_TITLE, tr("Connected to")+" <b>" + message->prefix() + "</b>")); | 149 | emit outputReady(IRCOutput(OUTPUT_TITLE, tr("Connected to")+" <b>" + message->prefix() + "</b>")); |
139 | /* Register EFFECTIVE nickname, some networks (as irc-hispano) uses nick:password | 150 | /* Register EFFECTIVE nickname, some networks (as irc-hispano) use nick:password |
140 | * for authentication and the parser gets confused */ | 151 | * for authentication and the parser gets confused */ |
141 | m_session->m_server->setNick(message->param(0)); | 152 | m_session->m_server->setNick(message->param(0)); |
@@ -190,5 +201,4 @@ void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { | |||
190 | if (mask.nick() != m_session->m_server->nick()) { | 201 | if (mask.nick() != m_session->m_server->nick()) { |
191 | if (!channel->getPerson(mask.nick())) { | 202 | if (!channel->getPerson(mask.nick())) { |
192 | IRCChannelPerson *chanperson = new IRCChannelPerson(); | ||
193 | IRCPerson *person = m_session->getPerson(mask.nick()); | 203 | IRCPerson *person = m_session->getPerson(mask.nick()); |
194 | if (!person) { | 204 | if (!person) { |
@@ -196,6 +206,5 @@ void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { | |||
196 | m_session->addPerson(person); | 206 | m_session->addPerson(person); |
197 | } | 207 | } |
198 | chanperson->flags = 0; | 208 | IRCChannelPerson *chanperson = new IRCChannelPerson(person); |
199 | chanperson->person = person; | ||
200 | channel->addPerson(chanperson); | 209 | channel->addPerson(chanperson); |
201 | IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName )); | 210 | IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName )); |
@@ -356,5 +365,5 @@ void IRCMessageParser::parseLiteralError(IRCMessage *message) { | |||
356 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | 365 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { |
357 | IRCPerson mask(message->prefix()); | 366 | IRCPerson mask(message->prefix()); |
358 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); | 367 | m_session->m_connection->sendCTCPReply(mask.nick(), "PING", message->allParameters()); |
359 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); | 368 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); |
360 | 369 | ||
@@ -396,6 +405,14 @@ void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | |||
396 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { | 405 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { |
397 | IRCPerson mask(message->prefix()); | 406 | IRCPerson mask(message->prefix()); |
398 | m_session->m_connection->sendCTCP(mask.nick(), "VERSION " APP_VERSION " " APP_COPYSTR); | 407 | IRCOutput output(OUTPUT_CTCP); |
399 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); | 408 | if(message->isCTCPRequest()) { |
409 | m_session->m_connection->sendCTCPReply(mask.nick(), "VERSION", APP_VERSION " " APP_COPYSTR); | ||
410 | output.setMessage(tr("Received a CTCP VERSION request from ") + mask.nick()); | ||
411 | } | ||
412 | |||
413 | else { | ||
414 | output.setMessage("Received CTCP VERSION reply from " + mask.nick() + ":" + message->param(0)); | ||
415 | } | ||
416 | emit outputReady(output); | ||
400 | } | 417 | } |
401 | 418 | ||
@@ -435,4 +452,14 @@ void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | |||
435 | } | 452 | } |
436 | 453 | ||
454 | void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { | ||
455 | QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace()); | ||
456 | if( params.count() != 5) { | ||
457 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Malformed DCC request from ") + IRCPerson(message->prefix()).nick())); | ||
458 | return; | ||
459 | } | ||
460 | |||
461 | //TransferReceiver *foo = new TransferReceiver(params[2].toUInt(), params[3].toUInt(), params[1], params[4].toUInt()); | ||
462 | } | ||
463 | |||
437 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 464 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
438 | IRCPerson mask(message->prefix()); | 465 | IRCPerson mask(message->prefix()); |
@@ -449,8 +476,11 @@ void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | |||
449 | set = TRUE; | 476 | set = TRUE; |
450 | temp = temp.right(1); | 477 | temp = temp.right(1); |
451 | } else if (temp.startsWith("-")) { | 478 | } |
479 | else | ||
480 | if (temp.startsWith("-")) { | ||
452 | set = FALSE; | 481 | set = FALSE; |
453 | temp = temp.right(1); | 482 | temp = temp.right(1); |
454 | } else { | 483 | } |
484 | else { | ||
455 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); | 485 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); |
456 | return; | 486 | return; |
@@ -460,41 +490,28 @@ void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | |||
460 | IRCChannelPerson *person = channel->getPerson(temp); | 490 | IRCChannelPerson *person = channel->getPerson(temp); |
461 | if (person) { | 491 | if (person) { |
462 | if (set) { | 492 | IRCOutput output(OUTPUT_CHANPERSONMODE, person->setOp(mask.nick(), set)); |
463 | person->flags |= PERSON_FLAG_OP; | ||
464 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); | ||
465 | output.addParam(channel); | ||
466 | output.addParam(person); | ||
467 | emit outputReady(output); | ||
468 | } else { | ||
469 | person->flags &= 0xFFFF - PERSON_FLAG_OP; | ||
470 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); | ||
471 | output.addParam(channel); | 493 | output.addParam(channel); |
472 | output.addParam(person); | 494 | output.addParam(person); |
473 | emit outputReady(output); | 495 | emit outputReady(output); |
474 | } | 496 | } |
475 | } else { | 497 | else { |
476 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); | 498 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); |
477 | } | 499 | } |
478 | } else if (temp == "v") { | 500 | } |
501 | else | ||
502 | if (temp == "v") { | ||
479 | stream >> temp; | 503 | stream >> temp; |
480 | IRCChannelPerson *person = channel->getPerson(temp); | 504 | IRCChannelPerson *person = channel->getPerson(temp); |
481 | if (person) { | 505 | if (person) { |
482 | if (set) { | 506 | IRCOutput output(OUTPUT_CHANPERSONMODE, person->setVoice(mask.nick(), set)); |
483 | person->flags |= PERSON_FLAG_VOICE; | ||
484 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); | ||
485 | output.addParam(channel); | ||
486 | output.addParam(person); | ||
487 | emit outputReady(output); | ||
488 | } else { | ||
489 | person->flags &= 0xFFFF - PERSON_FLAG_VOICE; | ||
490 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick())); | ||
491 | output.addParam(channel); | 507 | output.addParam(channel); |
492 | output.addParam(person); | 508 | output.addParam(person); |
493 | emit outputReady(output); | 509 | emit outputReady(output); |
494 | } | 510 | } |
495 | } else { | 511 | else { |
496 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); | 512 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); |
497 | } | 513 | } |
498 | } else { | 514 | } |
515 | else { | ||
499 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); | 516 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); |
500 | } | 517 | } |
@@ -514,5 +531,5 @@ void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | |||
514 | IRCChannelPerson *person = channel->getPerson(message->param(1)); | 531 | IRCChannelPerson *person = channel->getPerson(message->param(1)); |
515 | if (person) { | 532 | if (person) { |
516 | if (person->person->nick() == m_session->m_server->nick()) { | 533 | if (person->nick() == m_session->m_server->nick()) { |
517 | m_session->removeChannel(channel); | 534 | m_session->removeChannel(channel); |
518 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); | 535 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); |
@@ -522,5 +539,5 @@ void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | |||
522 | /* someone else got kicked */ | 539 | /* someone else got kicked */ |
523 | channel->removePerson(person); | 540 | channel->removePerson(person); |
524 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); | 541 | IRCOutput output(OUTPUT_OTHERKICK, person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); |
525 | output.addParam(channel); | 542 | output.addParam(channel); |
526 | output.addParam(person); | 543 | output.addParam(person); |
@@ -554,7 +571,7 @@ void IRCMessageParser::parseNumericalNames(IRCMessage *message) { | |||
554 | nick = temp.right(temp.length()-1); | 571 | nick = temp.right(temp.length()-1); |
555 | switch (flagch) { | 572 | switch (flagch) { |
556 | case '@': flag = PERSON_FLAG_OP; break; | 573 | case '@': flag = IRCChannelPerson::PERSON_FLAG_OP; break; |
557 | case '+': flag = PERSON_FLAG_VOICE; break; | 574 | case '+': flag = IRCChannelPerson::PERSON_FLAG_VOICE; break; |
558 | case '%': flag = PERSON_FLAG_HALFOP; break; | 575 | case '%': flag = IRCChannelPerson::PERSON_FLAG_HALFOP; break; |
559 | default : flag = 0; break; | 576 | default : flag = 0; break; |
560 | } | 577 | } |
@@ -563,5 +580,4 @@ void IRCMessageParser::parseNumericalNames(IRCMessage *message) { | |||
563 | } | 580 | } |
564 | 581 | ||
565 | IRCChannelPerson *chan_person = new IRCChannelPerson(); | ||
566 | IRCPerson *person = m_session->getPerson(nick); | 582 | IRCPerson *person = m_session->getPerson(nick); |
567 | if (person == 0) { | 583 | if (person == 0) { |
@@ -570,6 +586,6 @@ void IRCMessageParser::parseNumericalNames(IRCMessage *message) { | |||
570 | m_session->addPerson(person); | 586 | m_session->addPerson(person); |
571 | } | 587 | } |
572 | chan_person->person = person; | 588 | IRCChannelPerson *chan_person = new IRCChannelPerson(person); |
573 | chan_person->flags = flag; | 589 | chan_person->setFlags(flag); |
574 | channel->addPerson(chan_person); | 590 | channel->addPerson(chan_person); |
575 | } | 591 | } |
diff --git a/noncore/net/opieirc/ircmessageparser.h b/noncore/net/opieirc/ircmessageparser.h index 2fca61e..4ebbddd 100644 --- a/noncore/net/opieirc/ircmessageparser.h +++ b/noncore/net/opieirc/ircmessageparser.h | |||
@@ -76,4 +76,5 @@ private: | |||
76 | void parseLiteralTopic(IRCMessage *message); | 76 | void parseLiteralTopic(IRCMessage *message); |
77 | void parseNumerical(IRCMessage *message, int position); | 77 | void parseNumerical(IRCMessage *message, int position); |
78 | void parseCTCP(IRCMessage *message, int position); | ||
78 | void parseNumericalServerName(IRCMessage *message); | 79 | void parseNumericalServerName(IRCMessage *message); |
79 | void parseNumericalServerFeatures(IRCMessage *message); | 80 | void parseNumericalServerFeatures(IRCMessage *message); |
@@ -89,4 +90,5 @@ private: | |||
89 | void parseCTCPVersion(IRCMessage *message); | 90 | void parseCTCPVersion(IRCMessage *message); |
90 | void parseCTCPAction(IRCMessage *message); | 91 | void parseCTCPAction(IRCMessage *message); |
92 | void parseCTCPDCC(IRCMessage *message); | ||
91 | protected: | 93 | protected: |
92 | IRCSession *m_session; | 94 | IRCSession *m_session; |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 90353f2..bddc37e 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -4,4 +4,5 @@ | |||
4 | #include "ircservertab.h" | 4 | #include "ircservertab.h" |
5 | #include "ircmessageparser.h" | 5 | #include "ircmessageparser.h" |
6 | #include "ircchannelperson.h" | ||
6 | 7 | ||
7 | 8 | ||
@@ -312,5 +313,5 @@ void IRCServerTab::display(IRCOutput output) { | |||
312 | case OUTPUT_CHANPRIVMSG: { | 313 | case OUTPUT_CHANPRIVMSG: { |
313 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 314 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
314 | channelTab->appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage()+"</font><br>"); | 315 | channelTab->appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->nick())+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage()+"</font><br>"); |
315 | } | 316 | } |
316 | break; | 317 | break; |
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp index ca0df50..80a327a 100644 --- a/noncore/net/opieirc/ircsession.cpp +++ b/noncore/net/opieirc/ircsession.cpp | |||
@@ -1,4 +1,6 @@ | |||
1 | |||
1 | #include "ircsession.h" | 2 | #include "ircsession.h" |
2 | #include "ircmessageparser.h" | 3 | #include "ircmessageparser.h" |
4 | #include "ircchannelperson.h" | ||
3 | #include "ircversion.h" | 5 | #include "ircversion.h" |
4 | 6 | ||
@@ -138,5 +140,5 @@ void IRCSession::updateNickname(const QString &oldNickname, const QString &newNi | |||
138 | IRCChannelPerson *chanperson = it.current()->getPerson(oldNickname); | 140 | IRCChannelPerson *chanperson = it.current()->getPerson(oldNickname); |
139 | it.current()->removePerson(chanperson); | 141 | it.current()->removePerson(chanperson); |
140 | chanperson->person->setNick(newNickname); | 142 | chanperson->setNick(newNickname); |
141 | it.current()->addPerson(chanperson); | 143 | it.current()->addPerson(chanperson); |
142 | } | 144 | } |
@@ -195,2 +197,18 @@ void IRCSession::handleMessage(IRCMessage *message) { | |||
195 | m_parser->parse(message); | 197 | m_parser->parse(message); |
196 | } | 198 | } |
199 | |||
200 | void IRCSession::whois(const QString &nickname) { | ||
201 | m_connection->whois(nickname); | ||
202 | } | ||
203 | |||
204 | void IRCSession::sendCTCPPing(const QString &nickname) { | ||
205 | m_connection->sendCTCPPing(nickname); | ||
206 | } | ||
207 | |||
208 | void IRCSession::sendCTCPRequest(const QString &nickname, const QString &type, const QString &args) { | ||
209 | m_connection->sendCTCPRequest(nickname, type, args); | ||
210 | } | ||
211 | |||
212 | void IRCSession::sendCTCPReply(const QString &nickname, const QString &type, const QString &args) { | ||
213 | m_connection->sendCTCPReply(nickname, type, args); | ||
214 | } | ||
diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h index 96de3e4..3859b68 100644 --- a/noncore/net/opieirc/ircsession.h +++ b/noncore/net/opieirc/ircsession.h | |||
@@ -66,4 +66,8 @@ public: | |||
66 | void setValidUsermodes(const QString &modes); | 66 | void setValidUsermodes(const QString &modes); |
67 | void setValidChannelmodes(const QString &modes); | 67 | void setValidChannelmodes(const QString &modes); |
68 | void whois(const QString &nickname); | ||
69 | void sendCTCPPing(const QString &nickname); | ||
70 | void sendCTCPRequest(const QString &nickname, const QString &type, const QString &args); | ||
71 | void sendCTCPReply(const QString &nickname, const QString &type, const QString &args); | ||
68 | IRCChannel *getChannel(QString channelname); | 72 | IRCChannel *getChannel(QString channelname); |
69 | IRCPerson *getPerson(QString nickname); | 73 | IRCPerson *getPerson(QString nickname); |
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp index 2562f33..1811a0c 100644 --- a/noncore/net/opieirc/mainwindow.cpp +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -1,4 +1,7 @@ | |||
1 | #include <qmenubar.h> | 1 | #include <qmenubar.h> |
2 | #include <qpe/resource.h> | 2 | #include <qpe/resource.h> |
3 | |||
4 | #include <opie2/odebug.h> | ||
5 | |||
3 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
4 | 7 | ||
@@ -86,4 +89,5 @@ void MainWindow::slotKillTabsLater() { | |||
86 | for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) { | 89 | for ( QListIterator<IRCTab> it(m_toDelete); it.current(); ++it ) { |
87 | m_tabWidget->removePage( it.current() ); | 90 | m_tabWidget->removePage( it.current() ); |
91 | odebug << it.current() << oendl; | ||
88 | m_tabs.remove( it.current() ); | 92 | m_tabs.remove( it.current() ); |
89 | } | 93 | } |
diff --git a/noncore/net/opieirc/opieirc.pro b/noncore/net/opieirc/opieirc.pro index db89fa6..1ef9be2 100644 --- a/noncore/net/opieirc/opieirc.pro +++ b/noncore/net/opieirc/opieirc.pro | |||
@@ -7,5 +7,6 @@ HEADERS = ircchannel.h ircconnection.h \ | |||
7 | ircchanneltab.h ircchannellist.h \ | 7 | ircchanneltab.h ircchannellist.h \ |
8 | ircserverlist.h ircservereditor.h \ | 8 | ircserverlist.h ircservereditor.h \ |
9 | ircquerytab.h ircsettings.h ircmisc.h | 9 | ircquerytab.h ircsettings.h ircmisc.h \ |
10 | ircchannelperson.h | ||
10 | SOURCES = ircchannel.cpp ircconnection.cpp \ | 11 | SOURCES = ircchannel.cpp ircconnection.cpp \ |
11 | ircmessage.cpp \ | 12 | ircmessage.cpp \ |
@@ -16,5 +17,6 @@ SOURCES = ircchannel.cpp ircconnection.cpp \ | |||
16 | ircchanneltab.cpp ircchannellist.cpp \ | 17 | ircchanneltab.cpp ircchannellist.cpp \ |
17 | ircserverlist.cpp ircservereditor.cpp \ | 18 | ircserverlist.cpp ircservereditor.cpp \ |
18 | ircquerytab.cpp ircsettings.cpp ircmisc.cpp | 19 | ircquerytab.cpp ircsettings.cpp ircmisc.cpp \ |
20 | ircchannelperson.cpp | ||
19 | INCLUDEPATH += $(OPIEDIR)/include | 21 | INCLUDEPATH += $(OPIEDIR)/include |
20 | DEPENDPATH += $(OPIEDIR)/include | 22 | DEPENDPATH += $(OPIEDIR)/include |