Q_PROPERTY(int autoWhoInterval READ autoWhoInterval WRITE setAutoWhoInterval)
Q_PROPERTY(int autoWhoNickLimit READ autoWhoNickLimit WRITE setAutoWhoNickLimit)
Q_PROPERTY(int autoWhoDelay READ autoWhoDelay WRITE setAutoWhoDelay)
+ Q_PROPERTY(bool standardCtcp READ standardCtcp WRITE setStandardCtcp)
public :
NetworkConfig(const QString &objectName = "GlobalNetworkConfig", QObject *parent = 0);
void setAutoWhoDelay(int);
virtual inline void requestSetAutoWhoDelay(int i) { REQUEST(ARG(i)) }
+ inline bool standardCtcp() const { return _standardCtcp; }
+ void setStandardCtcp(bool);
+ virtual inline void requestSetStandardCtcp(bool b) { REQUEST(ARG(b)) }
+
signals:
void pingTimeoutEnabledSet(bool);
void pingIntervalSet(int);
void autoWhoIntervalSet(int);
// void autoWhoNickLimitSet(int);
void autoWhoDelaySet(int);
+ void standardCtcpSet(bool);
// void setPingTimeoutEnabledRequested(bool);
// void setPingIntervalRequested(int);
int _autoWhoInterval;
int _autoWhoNickLimit;
int _autoWhoDelay;
+
+ bool _standardCtcp;
};
#include "ctcpparser.h"
+#include "corenetworkconfig.h"
#include "coresession.h"
#include "ctcpevent.h"
#include "messageevent.h"
void CtcpParser::parse(IrcEventRawMessage *e, Message::Type messagetype)
{
- QByteArray ctcp;
-
//lowlevel message dequote
QByteArray dequotedMessage = lowLevelDequote(e->rawMessage());
? Message::Redirected
: Message::None;
+ if (coreSession()->networkConfig()->standardCtcp())
+ parseStandard(e, messagetype, dequotedMessage, ctcptype, flags);
+ else
+ parseSimple(e, messagetype, dequotedMessage, ctcptype, flags);
+}
+
+
+// only accept CTCPs in their simplest form, i.e. one ctcp, from start to
+// end, no text around it; not as per the 'specs', but makes people happier
+void CtcpParser::parseSimple(IrcEventRawMessage *e, Message::Type messagetype, QByteArray dequotedMessage, CtcpEvent::CtcpType ctcptype, Message::Flags flags)
+{
+ if (dequotedMessage.count(XDELIM) != 2 || dequotedMessage[0] != '\001' || dequotedMessage[dequotedMessage.count() -1] != '\001') {
+ displayMsg(e, messagetype, targetDecode(e, dequotedMessage), e->prefix(), e->target(), flags);
+ } else {
+ int spacePos = -1;
+ QString ctcpcmd, ctcpparam;
+
+ QByteArray ctcp = xdelimDequote(dequotedMessage.mid(1, dequotedMessage.count() - 2));
+ spacePos = ctcp.indexOf(' ');
+ if (spacePos != -1) {
+ ctcpcmd = targetDecode(e, ctcp.left(spacePos));
+ ctcpparam = targetDecode(e, ctcp.mid(spacePos + 1));
+ } else {
+ ctcpcmd = targetDecode(e, ctcp);
+ ctcpparam = QString();
+ }
+ ctcpcmd = ctcpcmd.toUpper();
+
+ // we don't want to block /me messages by the CTCP ignore list
+ if (ctcpcmd == QLatin1String("ACTION") || !coreSession()->ignoreListManager()->ctcpMatch(e->prefix(), e->network()->networkName(), ctcpcmd)) {
+ QUuid uuid = QUuid::createUuid();
+ _replies.insert(uuid, CtcpReply(coreNetwork(e), nickFromMask(e->prefix())));
+ CtcpEvent *event = new CtcpEvent(EventManager::CtcpEvent, e->network(), e->prefix(), e->target(),
+ ctcptype, ctcpcmd, ctcpparam, e->timestamp(), uuid);
+ emit newEvent(event);
+ CtcpEvent *flushEvent = new CtcpEvent(EventManager::CtcpEventFlush, e->network(), e->prefix(), e->target(),
+ ctcptype, "INVALID", QString(), e->timestamp(), uuid);
+ emit newEvent(flushEvent);
+ }
+ }
+}
+
+
+void CtcpParser::parseStandard(IrcEventRawMessage *e, Message::Type messagetype, QByteArray dequotedMessage, CtcpEvent::CtcpType ctcptype, Message::Flags flags)
+{
+ QByteArray ctcp;
+
QList<CtcpEvent *> ctcpEvents;
QUuid uuid; // needed to group all replies together
#include "corenetwork.h"
#include "eventmanager.h"
#include "ircevent.h"
+#include "ctcpevent.h"
class CoreSession;
class CtcpEvent;
Message::Flags msgFlags = Message::None);
void parse(IrcEventRawMessage *event, Message::Type msgType);
+ void parseSimple(IrcEventRawMessage *e, Message::Type messagetype, QByteArray dequotedMessage, CtcpEvent::CtcpType ctcptype, Message::Flags flags);
+ void parseStandard(IrcEventRawMessage *e, Message::Type messagetype, QByteArray dequotedMessage, CtcpEvent::CtcpType ctcptype, Message::Flags flags);
QByteArray lowLevelQuote(const QByteArray &);
QByteArray lowLevelDequote(const QByteArray &);
return config->autoWhoNickLimit();
if (widgetName == "autoWhoDelay")
return config->autoWhoDelay();
+ if (widgetName == "standardCtcp")
+ return config->standardCtcp();
return SettingsPage::loadAutoWidgetValue(widgetName);
}
config->requestSetAutoWhoNickLimit(value.toInt());
else if (widgetName == "autoWhoDelay")
config->requestSetAutoWhoDelay(value.toInt());
+ else if (widgetName == "standardCtcp")
+ config->requestSetStandardCtcp(value.toBool());
else
SettingsPage::saveAutoWidgetValue(widgetName, value);