1 /***************************************************************************
2 * Copyright (C) 2005-2016 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
26 #include "corenetwork.h"
27 #include "eventmanager.h"
29 #include "ctcpevent.h"
34 class CtcpParser : public QObject
39 CtcpParser(CoreSession *coreSession, QObject *parent = 0);
41 inline CoreSession *coreSession() const { return _coreSession; }
43 void query(CoreNetwork *network, const QString &bufname, const QString &ctcpTag, const QString &message);
44 void reply(CoreNetwork *network, const QString &bufname, const QString &ctcpTag, const QString &message);
46 Q_INVOKABLE void processIrcEventRawNotice(IrcEventRawMessage *event);
47 Q_INVOKABLE void processIrcEventRawPrivmsg(IrcEventRawMessage *event);
49 Q_INVOKABLE void sendCtcpEvent(CtcpEvent *event);
52 void newEvent(Event *event);
55 inline CoreNetwork *coreNetwork(NetworkEvent *e) const { return qobject_cast<CoreNetwork *>(e->network()); }
57 // FIXME duplicates functionality in EventStringifier, maybe want to put that in something common
58 //! Creates and sends a MessageEvent
59 void displayMsg(NetworkEvent *event,
60 Message::Type msgType,
62 const QString &sender = QString(),
63 const QString &target = QString(),
64 Message::Flags msgFlags = Message::None);
66 void parse(IrcEventRawMessage *event, Message::Type msgType);
67 void parseSimple(IrcEventRawMessage *e, Message::Type messagetype, QByteArray dequotedMessage, CtcpEvent::CtcpType ctcptype, Message::Flags flags);
68 void parseStandard(IrcEventRawMessage *e, Message::Type messagetype, QByteArray dequotedMessage, CtcpEvent::CtcpType ctcptype, Message::Flags flags);
70 QByteArray lowLevelQuote(const QByteArray &);
71 QByteArray lowLevelDequote(const QByteArray &);
72 QByteArray xdelimQuote(const QByteArray &);
73 QByteArray xdelimDequote(const QByteArray &);
75 QByteArray pack(const QByteArray &ctcpTag, const QByteArray &message);
76 void packedReply(CoreNetwork *network, const QString &bufname, const QList<QByteArray> &replies);
79 void setStandardCtcp(bool enabled);
82 inline QString targetDecode(IrcEventRawMessage *e, const QByteArray &msg) { return coreNetwork(e)->userDecode(e->target(), msg); }
84 CoreSession *_coreSession;
89 QList<QByteArray> replies;
91 CtcpReply() : network(0) {}
92 CtcpReply(CoreNetwork *net, const QString &buf) : network(net), bufferName(buf) {}
95 QHash<QUuid, CtcpReply> _replies;
97 QHash<QByteArray, QByteArray> _ctcpMDequoteHash;
98 QHash<QByteArray, QByteArray> _ctcpXDelimDequoteHash;