2
* (c) 2007-2008 Maciej Niedzielski
10
#include "stanzafilter.h"
11
#include "stanzasender.h"
12
#include "stanzasendinghost.h"
14
class AntiEvilPlugin: public QObject, public PsiPlugin, public StanzaFilter, public StanzaSender
17
Q_INTERFACES(PsiPlugin StanzaFilter StanzaSender);
26
//-- PsiPlugin -------------------------------------------
28
virtual QString name() const
30
// this will be displayed
31
return "Machekku's Evil Blocker Plugin";
34
virtual QString shortName() const
36
// internal name, no spaces please!
40
virtual QString version() const
45
virtual QWidget* options() const
58
virtual bool disable()
65
//-- StanzaFilter ----------------------------------------
67
virtual bool incomingStanza(int account, const QDomElement& stanza)
72
for (QDomNode n = stanza.firstChild(); !n.isNull(); n = n.nextSibling()) {
73
QDomElement i = n.toElement();
74
if (!i.isNull() && i.tagName() == "evil" && i.attribute("xmlns") == "http://jabber.org/protocol/evil") {
75
qDebug("evil blocked! ;)");
77
if (stanza.tagName() == "iq") {
78
qDebug("sending 'forbidden' error");
79
QString sender = stanza.attribute("from");
80
QString reply = QString("<iq type='error' %1><error type='modify'><bad-request xmlns='urn:ietf:params:xml:xmpp-stanzas'/></error></iq>")
81
.arg(sender.isEmpty() ? "" : QString("to='%1'").arg(sender));
83
stanzaSender->sendStanza(account, reply);
86
blocked = true; // stop processing this stanza
96
//-- StanzaSender ----------------------------------------
98
virtual void setStanzaSendingHost(StanzaSendingHost *host)
105
StanzaSendingHost* stanzaSender;
109
Q_EXPORT_PLUGIN2(antievil, AntiEvilPlugin)
111
#include "antievil.moc"