Added AttentionPayload + parser and serializer
This commit is contained in:
parent
18d3aa4b00
commit
d6c003bad3
7 changed files with 135 additions and 0 deletions
14
include/Swiften/Elements/AttentionPayload.cpp
Normal file
14
include/Swiften/Elements/AttentionPayload.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jan Kaluza
|
||||
* Licensed under the Simplified BSD license.
|
||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||
*/
|
||||
|
||||
#include <Swiften/Elements/AttentionPayload.h>
|
||||
|
||||
namespace Swift {
|
||||
|
||||
AttentionPayload::AttentionPayload() {
|
||||
}
|
||||
|
||||
}
|
23
include/Swiften/Elements/AttentionPayload.h
Normal file
23
include/Swiften/Elements/AttentionPayload.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jan Kaluza
|
||||
* Licensed under the Simplified BSD license.
|
||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <Swiften/Elements/Payload.h>
|
||||
|
||||
namespace Swift {
|
||||
class AttentionPayload : public Payload {
|
||||
public:
|
||||
typedef boost::shared_ptr<AttentionPayload> ref;
|
||||
|
||||
public:
|
||||
AttentionPayload();
|
||||
};
|
||||
}
|
24
include/Swiften/Parser/PayloadParsers/AttentionParser.cpp
Normal file
24
include/Swiften/Parser/PayloadParsers/AttentionParser.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jan Kaluza
|
||||
* Licensed under the Simplified BSD license.
|
||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||
*/
|
||||
|
||||
#include <Swiften/Parser/PayloadParsers/AttentionParser.h>
|
||||
|
||||
namespace Swift {
|
||||
|
||||
AttentionParser::AttentionParser() /*: level_(0)*/ {
|
||||
}
|
||||
|
||||
void AttentionParser::handleStartElement(const std::string& /*element*/, const std::string& /*ns*/, const AttributeMap& /*attributes*/) {
|
||||
}
|
||||
|
||||
void AttentionParser::handleEndElement(const std::string&, const std::string&) {
|
||||
}
|
||||
|
||||
void AttentionParser::handleCharacterData(const std::string&) {
|
||||
|
||||
}
|
||||
|
||||
}
|
24
include/Swiften/Parser/PayloadParsers/AttentionParser.h
Normal file
24
include/Swiften/Parser/PayloadParsers/AttentionParser.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jan Kaluza
|
||||
* Licensed under the Simplified BSD license.
|
||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Swiften/Elements/AttentionPayload.h>
|
||||
#include <Swiften/Parser/GenericPayloadParser.h>
|
||||
|
||||
namespace Swift {
|
||||
class AttentionParser : public GenericPayloadParser<AttentionPayload> {
|
||||
public:
|
||||
AttentionParser();
|
||||
|
||||
virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes);
|
||||
virtual void handleEndElement(const std::string& element, const std::string&);
|
||||
virtual void handleCharacterData(const std::string& data);
|
||||
|
||||
// private:
|
||||
// int level_;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jan Kaluza
|
||||
* Licensed under the Simplified BSD license.
|
||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||
*/
|
||||
|
||||
#include <Swiften/Serializer/PayloadSerializers/AttentionSerializer.h>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <Swiften/Serializer/XML/XMLTextNode.h>
|
||||
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
|
||||
#include <Swiften/Serializer/XML/XMLElement.h>
|
||||
|
||||
namespace Swift {
|
||||
|
||||
AttentionSerializer::AttentionSerializer() : GenericPayloadSerializer<AttentionPayload>() {
|
||||
}
|
||||
|
||||
std::string AttentionSerializer::serializePayload(boost::shared_ptr<AttentionPayload> attention) const {
|
||||
XMLElement attentionElement("attention", "urn:xmpp:attention:0");
|
||||
|
||||
return attentionElement.serialize();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jan Kaluza
|
||||
* Licensed under the Simplified BSD license.
|
||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
||||
#include <Swiften/Elements/AttentionPayload.h>
|
||||
|
||||
namespace Swift {
|
||||
class AttentionSerializer : public GenericPayloadSerializer<AttentionPayload> {
|
||||
public:
|
||||
AttentionSerializer();
|
||||
|
||||
virtual std::string serializePayload(boost::shared_ptr<AttentionPayload>) const;
|
||||
};
|
||||
}
|
|
@ -28,6 +28,8 @@
|
|||
#include "Swiften/TLS/OpenSSL/OpenSSLServerContext.h"
|
||||
#include "Swiften/TLS/PKCS12Certificate.h"
|
||||
#include "Swiften/TLS/OpenSSL/OpenSSLServerContextFactory.h"
|
||||
#include "Swiften/Parser/PayloadParsers/AttentionParser.h"
|
||||
#include "Swiften/Serializer/PayloadSerializers/AttentionSerializer.h"
|
||||
#include "log4cxx/logger.h"
|
||||
#include "log4cxx/consoleappender.h"
|
||||
#include "log4cxx/patternlayout.h"
|
||||
|
@ -101,6 +103,9 @@ Component::Component(Swift::EventLoop *loop, Config *config, Factory *factory) {
|
|||
m_iqRouter = m_server->getIQRouter();
|
||||
|
||||
m_server->addPayloadParserFactory(new GenericPayloadParserFactory<StorageParser>("private", "jabber:iq:private"));
|
||||
m_server->addPayloadParserFactory(new GenericPayloadParserFactory<Swift::AttentionParser>("attention", "urn:xmpp:attention:0"));
|
||||
|
||||
m_server->addPayloadSerializer(new Swift::AttentionSerializer());
|
||||
|
||||
m_server->onDataRead.connect(bind(&Component::handleDataRead, this, _1));
|
||||
m_server->onDataWritten.connect(bind(&Component::handleDataWritten, this, _1));
|
||||
|
|
Loading…
Add table
Reference in a new issue