Skip to content

Commit

Permalink
Added support for Attentions (XEP-0224)
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-izo committed Apr 17, 2012
1 parent 831d9ed commit c6054fa
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version ***
* Added support for XEP-224: Attentions

Version 1.1.0
* Added PGP payloads
* Added support for Message Forwarding
Expand Down
45 changes: 45 additions & 0 deletions src/attention.cpp
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions src/attention.h
Original file line number Diff line number Diff line change
@@ -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
88 changes: 88 additions & 0 deletions src/attentionfactory.cpp
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions src/attentionfactory_p.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c6054fa

Please sign in to comment.