Changeset - 54dff8d28067
[Not reviewed]
include/Swiften/Elements/GatewayPayload.cpp
Show inline comments
 
new file 100644
 
/*
 
 * Copyright (c) 2011 Jan Kaluza
 
 * Licensed under the Simplified BSD license.
 
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 
 */
 

	
 
#include <Swiften/Elements/GatewayPayload.h>
 

	
 
namespace Swift {
 

	
 
GatewayPayload::GatewayPayload(const JID &jid, const std::string &desc, const std::string &prompt) :
 
	jid(jid), desc(desc), prompt(prompt) {
 
		
 
	}
 

	
 
}
include/Swiften/Elements/GatewayPayload.h
Show inline comments
 
new file 100644
 
/*
 
 * 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 <Swiften/Elements/Payload.h>
 
#include <Swiften/JID/JID.h>
 

	
 
namespace Swift {
 
	class GatewayPayload : public Payload {
 
		public:
 
			GatewayPayload(const JID &jid = JID(), const std::string &desc = "", const std::string &prompt = "");
 

	
 
			void setJID(const JID &jid) {
 
				this->jid = jid;
 
			}
 

	
 
			const JID &getJID() const {
 
				return jid;
 
			}
 

	
 
			void setDesc(const std::string &desc) {
 
				this->desc = desc;
 
			}
 

	
 
			const std::string &getDesc() const {
 
				return desc;
 
			}
 

	
 
			void setPrompt(const std::string &prompt) {
 
				this->prompt = prompt;
 
			}
 

	
 
			const std::string &getPrompt() const {
 
				return prompt;
 
			}
 

	
 
		private:
 
			JID jid;
 
			std::string desc;
 
			std::string prompt;
 
	};
 
}
include/Swiften/Parser/PayloadParsers/GatewayPayloadParser.cpp
Show inline comments
 
new file 100644
 
/*
 
 * Copyright (c) 2012 Jan Kaluza
 
 * Licensed under the Simplified BSD license.
 
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 
 */
 

	
 
#include <Swiften/Parser/PayloadParsers/GatewayPayloadParser.h>
 

	
 
#include <boost/lexical_cast.hpp>
 

	
 
#include <Swiften/Parser/PayloadParserFactoryCollection.h>
 
#include <Swiften/Parser/PayloadParserFactory.h>
 
#include <Swiften/Base/foreach.h>
 
#include <Swiften/Elements/MUCOccupant.h>
 
#include <Swiften/Parser/Tree/TreeReparser.h>
 

	
 
namespace Swift {
 

	
 
void GatewayPayloadParser::handleTree(ParserElement::ref root) {
 
	foreach (ParserElement::ref child, root->getAllChildren()) {
 
		if (child->getName() == "desc") {
 
			getPayloadInternal()->setDesc(child->getText());
 
		}
 
		else if (child->getName() == "prompt") {
 
			getPayloadInternal()->setPrompt(child->getText());
 
		}
 
		else if (child->getName() == "jid") {
 
			getPayloadInternal()->setJID(child->getText());
 
		}
 
	}
 
}
 

	
 
}
include/Swiften/Parser/PayloadParsers/GatewayPayloadParser.h
Show inline comments
 
new file 100644
 
/*
 
 * Copyright (c) 2012 Jan Kaluza
 
 * Licensed under the Simplified BSD license.
 
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 
 */
 

	
 
#pragma once
 

	
 
#include <boost/optional.hpp>
 

	
 
#include <Swiften/Elements/GatewayPayload.h>
 
#include <Swiften/Parser/GenericPayloadTreeParser.h>
 
#include <Swiften/Parser/PayloadParsers/MUCItemParser.h>
 

	
 
namespace Swift {
 
	class GatewayPayloadParser : public GenericPayloadTreeParser<GatewayPayload> {
 
		public:
 
			GatewayPayloadParser() {}
 
			virtual void handleTree(ParserElement::ref root);
 
	};
 
}
include/Swiften/Serializer/PayloadSerializers/GatewayPayloadSerializer.cpp
Show inline comments
 
new file 100644
 
/*
 
 * Copyright (c) 2011 Jan Kaluza
 
 * Licensed under the Simplified BSD license.
 
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 
 */
 

	
 
#include <Swiften/Serializer/PayloadSerializers/GatewayPayloadSerializer.h>
 
#include <Swiften/Base/foreach.h>
 
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
 
#include <Swiften/Serializer/XML/XMLTextNode.h>
 
#include <Swiften/Serializer/XML/XMLElement.h>
 
#include <Swiften/Serializer/PayloadSerializerCollection.h>
 

	
 
namespace Swift {
 

	
 
GatewayPayloadSerializer::GatewayPayloadSerializer()
 
	: GenericPayloadSerializer<GatewayPayload>() {
 
}
 

	
 
std::string GatewayPayloadSerializer::serializePayload(boost::shared_ptr<GatewayPayload> payload)  const {
 
	XMLElement query("query", "jabber:iq:gateway");
 

	
 
	if (!payload->getJID().isValid()) {
 
		boost::shared_ptr<XMLElement> jid(new XMLElement("jid", "", payload->getJID().toBare().toString()));
 
		query.addNode(jid);
 
	}
 

	
 
	if (!payload->getDesc().empty()) {
 
		boost::shared_ptr<XMLElement> desc(new XMLElement("desc", "", payload->getDesc()));
 
		query.addNode(desc);
 
	}
 

	
 
	if (!payload->getPrompt().empty()) {
 
		boost::shared_ptr<XMLElement> prompt(new XMLElement("prompt", "", payload->getPrompt()));
 
		query.addNode(prompt);
 
	}
 

	
 
	return query.serialize();
 
}
 

	
 
}
include/Swiften/Serializer/PayloadSerializers/GatewayPayloadSerializer.h
Show inline comments
 
new file 100644
 
/*
 
 * 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/GatewayPayload.h>
 

	
 
namespace Swift {
 
	class GatewayPayloadSerializer : public GenericPayloadSerializer<GatewayPayload> {
 
		public:
 
			GatewayPayloadSerializer();
 

	
 
			virtual std::string serializePayload(boost::shared_ptr<GatewayPayload> item)  const;
 
	};
 
}
0 comments (0 inline, 0 general)