Permalink
Browse files

Added support for Attentions (XEP-0224)

  • Loading branch information...
nico-izo committed Apr 17, 2012
1 parent 831d9ed commit c6054fad392cb7d00288fa8ef6636dd20b1f65d4
Showing with 235 additions and 0 deletions.
  1. +3 −0 ChangeLog
  2. +45 −0 src/attention.cpp
  3. +48 −0 src/attention.h
  4. +88 −0 src/attentionfactory.cpp
  5. +49 −0 src/attentionfactory_p.h
  6. +2 −0 src/client.cpp
View
@@ -1,3 +1,6 @@
+Version ***
+ * Added support for XEP-224: Attentions
+
Version 1.1.0
* Added PGP payloads
* Added support for Message Forwarding
View
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Jreen
+**
+** Copyright © 2012 Nicolay Izoderov <nico-izo@ya.ru>
+**
+*****************************************************************************
+**
+** $JREEN_BEGIN_LICENSE$
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+** See the GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see http://www.gnu.org/licenses/.
+** $JREEN_END_LICENSE$
+**
+****************************************************************************/
+
+#include "attention.h"
+
+namespace Jreen {
+
+class AttentionPrivate
+{
+public:
+};
+
+Attention::Attention()
+ : d_ptr(new AttentionPrivate)
+{
+}
+
+Attention::~Attention()
+{
+}
+
+}
+ // namespace Jreen
View
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Jreen
+**
+** Copyright © 2012 Nicolay Izoderov <nico-izo@ya.ru>
+**
+*****************************************************************************
+**
+** $JREEN_BEGIN_LICENSE$
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+** See the GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see http://www.gnu.org/licenses/.
+** $JREEN_END_LICENSE$
+**
+****************************************************************************/
+#ifndef ATTENTION_H
+#define ATTENTION_H
+#include "stanzaextension.h"
+
+namespace Jreen {
+
+class AttentionPrivate;
+
+//XEP-0224 Attention
+//http://xmpp.org/extensions/xep-0224.html
+class JREEN_EXPORT Attention : public Payload
+{
+ Q_DECLARE_PRIVATE(Attention)
+ J_PAYLOAD(Jreen::Attention)
+public:
+ Attention();
+ ~Attention();
+private:
+ QScopedPointer<AttentionPrivate> d_ptr;
+};
+
+} // namespace Jreen
+
+#endif // ATTENTION_H
View
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Jreen
+**
+** Copyright © 2012 Nicolay Izoderov <nico-izo@ya.ru>
+**
+*****************************************************************************
+**
+** $JREEN_BEGIN_LICENSE$
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+** See the GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see http://www.gnu.org/licenses/.
+** $JREEN_END_LICENSE$
+**
+****************************************************************************/
+
+#include "attentionfactory_p.h"
+#include <QMap>
+#include <QXmlStreamReader>
+#include <QStringList>
+#include "jstrings.h"
+
+#define NS_ATTENTION QLatin1String("urn:xmpp:attention:0")
+
+namespace Jreen {
+
+AttentionFactory::AttentionFactory()
+{
+
+}
+
+AttentionFactory::~AttentionFactory()
+{
+
+}
+
+QStringList AttentionFactory::features() const
+{
+ return QStringList(NS_ATTENTION);
+}
+
+bool AttentionFactory::canParse(const QStringRef &name,
+ const QStringRef &uri, const QXmlStreamAttributes &attributes)
+{
+ Q_UNUSED(attributes);
+ return name == QLatin1String("attention") && uri == NS_ATTENTION;
+}
+
+void AttentionFactory::handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes)
+{
+ Q_UNUSED(uri);
+ Q_UNUSED(attributes);
+ Q_UNUSED(name);
+}
+
+void AttentionFactory::handleEndElement(const QStringRef &name, const QStringRef &uri)
+{
+ Q_UNUSED(name);
+ Q_UNUSED(uri);
+}
+
+void AttentionFactory::handleCharacterData(const QStringRef &text)
+{
+ Q_UNUSED(text);
+}
+
+void AttentionFactory::serialize(Payload *extension, QXmlStreamWriter *writer)
+{
+ writer->writeStartElement(QLatin1String("attention"));
+ writer->writeDefaultNamespace(NS_ATTENTION);
+ writer->writeEndElement();
+}
+
+Payload::Ptr AttentionFactory::createPayload()
+{
+ return Payload::Ptr(new Attention());
+}
+
+} // namespace Jreen
View
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Jreen
+**
+** Copyright © 2012 Nicolay Izoderov <nico-izo@ya.ru>
+**
+*****************************************************************************
+**
+** $JREEN_BEGIN_LICENSE$
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+** See the GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see http://www.gnu.org/licenses/.
+** $JREEN_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ATTENTIONFACTORY_P_H
+#define ATTENTIONFACTORY_P_H
+#include "stanzaextension.h"
+#include "attention.h"
+
+namespace Jreen {
+
+class JREEN_AUTOTEST_EXPORT AttentionFactory : public PayloadFactory<Attention>
+{
+public:
+ AttentionFactory();
+ virtual ~AttentionFactory();
+ QStringList features() const;
+ bool canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
+ void handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
+ void handleEndElement(const QStringRef &name, const QStringRef &uri);
+ void handleCharacterData(const QStringRef &text);
+ void serialize(Payload *extension, QXmlStreamWriter *writer);
+ Payload::Ptr createPayload();
+};
+
+} // namespace Jreen
+
+#endif // ATTENTIONFACTORY_P_H
View
@@ -64,6 +64,7 @@
#include "captchafactory_p.h"
#include "pgpfactory_p.h"
#include "forwardedfactory_p.h"
+#include "attentionfactory_p.h"
// Features
#include "nonsaslauth_p.h"
@@ -179,6 +180,7 @@ void ClientPrivate::init()
q_ptr->registerPayload(new PGPSignedFactory);
q_ptr->registerPayload(new PGPEncryptedFactory);
q_ptr->registerPayload(new ForwardedFactory(q_ptr));
+ q_ptr->registerPayload(new AttentionFactory);
q_ptr->registerStreamFeature(new NonSaslAuth);
q_ptr->registerStreamFeature(new SASLFeature);

0 comments on commit c6054fa

Please sign in to comment.