Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added support for Attentions (XEP-0224)

  • Loading branch information...
commit c6054fad392cb7d00288fa8ef6636dd20b1f65d4 1 parent 831d9ed
Nicolay Izoderov authored April 18, 2012
3  ChangeLog
... ...
@@ -1,3 +1,6 @@
  1
+Version ***
  2
+	* Added support for XEP-224: Attentions
  3
+
1 4
 Version 1.1.0
2 5
 	* Added PGP payloads
3 6
 	* Added support for Message Forwarding
45  src/attention.cpp
... ...
@@ -0,0 +1,45 @@
  1
+/****************************************************************************
  2
+**
  3
+** Jreen
  4
+**
  5
+** Copyright © 2012 Nicolay Izoderov <nico-izo@ya.ru>
  6
+**
  7
+*****************************************************************************
  8
+**
  9
+** $JREEN_BEGIN_LICENSE$
  10
+** This program is free software: you can redistribute it and/or modify
  11
+** it under the terms of the GNU General Public License as published by
  12
+** the Free Software Foundation, either version 2 of the License, or
  13
+** (at your option) any later version.
  14
+**
  15
+** This program is distributed in the hope that it will be useful,
  16
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
  17
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18
+** See the GNU General Public License for more details.
  19
+**
  20
+** You should have received a copy of the GNU General Public License
  21
+** along with this program.  If not, see http://www.gnu.org/licenses/.
  22
+** $JREEN_END_LICENSE$
  23
+**
  24
+****************************************************************************/
  25
+
  26
+#include "attention.h"
  27
+
  28
+namespace Jreen {
  29
+
  30
+class AttentionPrivate
  31
+{
  32
+public:
  33
+};
  34
+
  35
+Attention::Attention()
  36
+	: d_ptr(new AttentionPrivate)
  37
+{
  38
+}
  39
+
  40
+Attention::~Attention()
  41
+{
  42
+}
  43
+
  44
+}
  45
+ // namespace Jreen
48  src/attention.h
... ...
@@ -0,0 +1,48 @@
  1
+/****************************************************************************
  2
+**
  3
+** Jreen
  4
+**
  5
+** Copyright © 2012 Nicolay Izoderov <nico-izo@ya.ru>
  6
+**
  7
+*****************************************************************************
  8
+**
  9
+** $JREEN_BEGIN_LICENSE$
  10
+** This program is free software: you can redistribute it and/or modify
  11
+** it under the terms of the GNU General Public License as published by
  12
+** the Free Software Foundation, either version 2 of the License, or
  13
+** (at your option) any later version.
  14
+**
  15
+** This program is distributed in the hope that it will be useful,
  16
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
  17
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18
+** See the GNU General Public License for more details.
  19
+**
  20
+** You should have received a copy of the GNU General Public License
  21
+** along with this program.  If not, see http://www.gnu.org/licenses/.
  22
+** $JREEN_END_LICENSE$
  23
+**
  24
+****************************************************************************/
  25
+#ifndef ATTENTION_H
  26
+#define ATTENTION_H
  27
+#include "stanzaextension.h"
  28
+
  29
+namespace Jreen {
  30
+
  31
+class AttentionPrivate;
  32
+
  33
+//XEP-0224 Attention
  34
+//http://xmpp.org/extensions/xep-0224.html
  35
+class JREEN_EXPORT Attention : public Payload
  36
+{
  37
+	Q_DECLARE_PRIVATE(Attention)
  38
+	J_PAYLOAD(Jreen::Attention)
  39
+public:
  40
+	Attention();
  41
+	~Attention();
  42
+private:
  43
+	QScopedPointer<AttentionPrivate> d_ptr;
  44
+};
  45
+
  46
+} // namespace Jreen
  47
+
  48
+#endif // ATTENTION_H
88  src/attentionfactory.cpp
... ...
@@ -0,0 +1,88 @@
  1
+/****************************************************************************
  2
+**
  3
+** Jreen
  4
+**
  5
+** Copyright © 2012 Nicolay Izoderov <nico-izo@ya.ru>
  6
+**
  7
+*****************************************************************************
  8
+**
  9
+** $JREEN_BEGIN_LICENSE$
  10
+** This program is free software: you can redistribute it and/or modify
  11
+** it under the terms of the GNU General Public License as published by
  12
+** the Free Software Foundation, either version 2 of the License, or
  13
+** (at your option) any later version.
  14
+**
  15
+** This program is distributed in the hope that it will be useful,
  16
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
  17
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18
+** See the GNU General Public License for more details.
  19
+**
  20
+** You should have received a copy of the GNU General Public License
  21
+** along with this program.  If not, see http://www.gnu.org/licenses/.
  22
+** $JREEN_END_LICENSE$
  23
+**
  24
+****************************************************************************/
  25
+
  26
+#include "attentionfactory_p.h"
  27
+#include <QMap>
  28
+#include <QXmlStreamReader>
  29
+#include <QStringList>
  30
+#include "jstrings.h"
  31
+
  32
+#define NS_ATTENTION QLatin1String("urn:xmpp:attention:0")
  33
+
  34
+namespace Jreen {
  35
+
  36
+AttentionFactory::AttentionFactory()
  37
+{
  38
+
  39
+}
  40
+
  41
+AttentionFactory::~AttentionFactory()
  42
+{
  43
+
  44
+}
  45
+
  46
+QStringList AttentionFactory::features() const
  47
+{
  48
+	return QStringList(NS_ATTENTION);
  49
+}
  50
+
  51
+bool AttentionFactory::canParse(const QStringRef &name,
  52
+								const QStringRef &uri, const QXmlStreamAttributes &attributes)
  53
+{
  54
+	Q_UNUSED(attributes);
  55
+	return name == QLatin1String("attention") && uri == NS_ATTENTION;
  56
+}
  57
+
  58
+void AttentionFactory::handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes)
  59
+{
  60
+	Q_UNUSED(uri);
  61
+	Q_UNUSED(attributes);
  62
+	Q_UNUSED(name);
  63
+}
  64
+
  65
+void AttentionFactory::handleEndElement(const QStringRef &name, const QStringRef &uri)
  66
+{
  67
+	Q_UNUSED(name);
  68
+	Q_UNUSED(uri);
  69
+}
  70
+
  71
+void AttentionFactory::handleCharacterData(const QStringRef &text)
  72
+{
  73
+	Q_UNUSED(text);
  74
+}
  75
+
  76
+void AttentionFactory::serialize(Payload *extension, QXmlStreamWriter *writer)
  77
+{
  78
+	writer->writeStartElement(QLatin1String("attention"));
  79
+	writer->writeDefaultNamespace(NS_ATTENTION);
  80
+	writer->writeEndElement();
  81
+}
  82
+
  83
+Payload::Ptr AttentionFactory::createPayload()
  84
+{
  85
+	return Payload::Ptr(new Attention());
  86
+}
  87
+
  88
+} // namespace Jreen
49  src/attentionfactory_p.h
... ...
@@ -0,0 +1,49 @@
  1
+/****************************************************************************
  2
+**
  3
+** Jreen
  4
+**
  5
+** Copyright © 2012 Nicolay Izoderov <nico-izo@ya.ru>
  6
+**
  7
+*****************************************************************************
  8
+**
  9
+** $JREEN_BEGIN_LICENSE$
  10
+** This program is free software: you can redistribute it and/or modify
  11
+** it under the terms of the GNU General Public License as published by
  12
+** the Free Software Foundation, either version 2 of the License, or
  13
+** (at your option) any later version.
  14
+**
  15
+** This program is distributed in the hope that it will be useful,
  16
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
  17
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18
+** See the GNU General Public License for more details.
  19
+**
  20
+** You should have received a copy of the GNU General Public License
  21
+** along with this program.  If not, see http://www.gnu.org/licenses/.
  22
+** $JREEN_END_LICENSE$
  23
+**
  24
+****************************************************************************/
  25
+
  26
+#ifndef ATTENTIONFACTORY_P_H
  27
+#define ATTENTIONFACTORY_P_H
  28
+#include "stanzaextension.h"
  29
+#include "attention.h"
  30
+
  31
+namespace Jreen {
  32
+
  33
+class JREEN_AUTOTEST_EXPORT AttentionFactory : public PayloadFactory<Attention>
  34
+{
  35
+public:
  36
+	AttentionFactory();
  37
+	virtual ~AttentionFactory();
  38
+	QStringList features() const;
  39
+	bool canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
  40
+	void handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
  41
+	void handleEndElement(const QStringRef &name, const QStringRef &uri);
  42
+	void handleCharacterData(const QStringRef &text);
  43
+	void serialize(Payload *extension, QXmlStreamWriter *writer);
  44
+	Payload::Ptr createPayload();
  45
+};
  46
+
  47
+} // namespace Jreen
  48
+
  49
+#endif // ATTENTIONFACTORY_P_H
2  src/client.cpp
@@ -64,6 +64,7 @@
64 64
 #include "captchafactory_p.h"
65 65
 #include "pgpfactory_p.h"
66 66
 #include "forwardedfactory_p.h"
  67
+#include "attentionfactory_p.h"
67 68
 
68 69
 // Features
69 70
 #include "nonsaslauth_p.h"
@@ -179,6 +180,7 @@ void ClientPrivate::init()
179 180
 	q_ptr->registerPayload(new PGPSignedFactory);
180 181
 	q_ptr->registerPayload(new PGPEncryptedFactory);
181 182
 	q_ptr->registerPayload(new ForwardedFactory(q_ptr));
  183
+	q_ptr->registerPayload(new AttentionFactory);
182 184
 
183 185
 	q_ptr->registerStreamFeature(new NonSaslAuth);
184 186
 	q_ptr->registerStreamFeature(new SASLFeature);

0 notes on commit c6054fa

Please sign in to comment.
Something went wrong with that request. Please try again.