diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-08-18 20:08:34 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-08-18 20:08:34 (GMT) |
commit | e1f9cdc38b600d930760ed0e0b867ab739127f5a (patch) | |
tree | 928b9ad82c1341640631035ffa28fdf01dc4dcc5 /Swiften/Serializer | |
parent | 6fd3078f8f512c74bfc54c3d31d6446098088a69 (diff) | |
download | swift-e1f9cdc38b600d930760ed0e0b867ab739127f5a.zip swift-e1f9cdc38b600d930760ed0e0b867ab739127f5a.tar.bz2 |
Added command parser.
Diffstat (limited to 'Swiften/Serializer')
3 files changed, 8 insertions, 11 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp index 3ac0c2c..eb45ca2 100644 --- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp @@ -13,10 +13,11 @@ #include "Swiften/Serializer/XML/XMLTextNode.h" #include "Swiften/Serializer/XML/XMLRawTextNode.h" #include "Swiften/Serializer/PayloadSerializerCollection.h" +#include "Swiften/Serializer/PayloadSerializers/FormSerializer.h" namespace Swift { -CommandSerializer::CommandSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) { +CommandSerializer::CommandSerializer() { } String CommandSerializer::serializePayload(boost::shared_ptr<Command> command) const { @@ -27,7 +28,7 @@ String CommandSerializer::serializePayload(boost::shared_ptr<Command> command) c commandElement.setAttribute("sessionid", command->getSessionID()); } - String action = actionToString(command->getPerformedAction()); + String action = actionToString(command->getAction()); if (!action.isEmpty()) { commandElement.setAttribute("action", action); } @@ -72,12 +73,9 @@ String CommandSerializer::serializePayload(boost::shared_ptr<Command> command) c commandElement.addNode(noteElement); } - boost::shared_ptr<Payload> payload = command->getPayload(); - if (payload) { - PayloadSerializer* serializer = serializers->getPayloadSerializer(payload); - if (serializer) { - commandElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(serializer->serialize(payload)))); - } + Form::ref form = command->getForm(); + if (form) { + commandElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(form)))); } return commandElement.serialize(); } diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.h b/Swiften/Serializer/PayloadSerializers/CommandSerializer.h index 6a0c067..4b71aea 100644 --- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.h @@ -14,12 +14,11 @@ namespace Swift { class CommandSerializer : public GenericPayloadSerializer<Command> { public: - CommandSerializer(PayloadSerializerCollection* serializers); + CommandSerializer(); virtual String serializePayload(boost::shared_ptr<Command>) const; private: - PayloadSerializerCollection* serializers; String actionToString(Command::Action action) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp index 04615a2..275cbf1 100644 --- a/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp +++ b/Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.cpp @@ -61,7 +61,7 @@ FullPayloadSerializerCollection::FullPayloadSerializerCollection() { serializers_.push_back(new DelaySerializer()); serializers_.push_back(new FormSerializer()); serializers_.push_back(new PrivateStorageSerializer(this)); - serializers_.push_back(new CommandSerializer(this)); + serializers_.push_back(new CommandSerializer()); foreach(PayloadSerializer* serializer, serializers_) { addSerializer(serializer); } |