summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-12-09 21:45:33 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-12-09 21:45:33 (GMT)
commit9bcba37ce570e0ca839cf3489fd9e34b3b5d44c8 (patch)
tree469e6bcbfa6cd2d023d33d5e701b1c28ab414d6d /Swiften
parentedabab9987aa7fd74f7db5dcfc77677472406180 (diff)
downloadswift-contrib-9bcba37ce570e0ca839cf3489fd9e34b3b5d44c8.zip
swift-contrib-9bcba37ce570e0ca839cf3489fd9e34b3b5d44c8.tar.bz2
Added missing files & fixed stream error namespace.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Parser/XMPPParser.cpp2
-rw-r--r--Swiften/Serializer/StreamErrorSerializer.cpp58
-rw-r--r--Swiften/Serializer/StreamErrorSerializer.h19
3 files changed, 78 insertions, 1 deletions
diff --git a/Swiften/Parser/XMPPParser.cpp b/Swiften/Parser/XMPPParser.cpp
index 26cebe2..b274c94 100644
--- a/Swiften/Parser/XMPPParser.cpp
+++ b/Swiften/Parser/XMPPParser.cpp
@@ -137,7 +137,7 @@ ElementParser* XMPPParser::createElementParser(const String& element, const Stri
else if (element == "features" && ns == "http://etherx.jabber.org/streams") {
return new StreamFeaturesParser();
}
- else if (element == "error" && ns == "urn:ietf:params:xml:ns:xmpp-streams") {
+ else if (element == "error" && ns == "http://etherx.jabber.org/streams") {
return new StreamErrorParser();
}
else if (element == "auth") {
diff --git a/Swiften/Serializer/StreamErrorSerializer.cpp b/Swiften/Serializer/StreamErrorSerializer.cpp
new file mode 100644
index 0000000..720c414
--- /dev/null
+++ b/Swiften/Serializer/StreamErrorSerializer.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Serializer/StreamErrorSerializer.h>
+
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Serializer/XML/XMLElement.h>
+
+namespace Swift {
+
+StreamErrorSerializer::StreamErrorSerializer() : GenericElementSerializer<StreamError>() {
+}
+
+String StreamErrorSerializer::serialize(boost::shared_ptr<Element> element) const {
+ StreamError::ref error = boost::dynamic_pointer_cast<StreamError>(element);
+ XMLElement errorElement("error", "http://etherx.jabber.org/streams");
+
+ String typeTag;
+ switch (error->getType()) {
+ case StreamError::BadFormat: typeTag = "bad-format"; break;
+ case StreamError::BadNamespacePrefix: typeTag = "bad-namespace-prefix"; break;
+ case StreamError::Conflict: typeTag = "conflict"; break;
+ case StreamError::ConnectionTimeout: typeTag = "connection-timeout"; break;
+ case StreamError::HostGone: typeTag = "host-gone"; break;
+ case StreamError::HostUnknown: typeTag = "host-unknown"; break;
+ case StreamError::ImproperAddressing: typeTag = "improper-addressing"; break;
+ case StreamError::InternalServerError: typeTag = "internal-server-error"; break;
+ case StreamError::InvalidFrom: typeTag = "invalid-from"; break;
+ case StreamError::InvalidID: typeTag = "invalid-id"; break;
+ case StreamError::InvalidNamespace: typeTag = "invalid-namespace"; break;
+ case StreamError::InvalidXML: typeTag = "invalid-xml"; break;
+ case StreamError::NotAuthorized: typeTag = "not-authorized"; break;
+ case StreamError::PolicyViolation: typeTag = "policy-violation"; break;
+ case StreamError::RemoteConnectionFailed: typeTag = "remote-connection-failed"; break;
+ case StreamError::ResourceConstraint: typeTag = "resource-constraint"; break;
+ case StreamError::RestrictedXML: typeTag = "restricted-xml"; break;
+ case StreamError::SeeOtherHost: typeTag = "see-other-host"; break;
+ case StreamError::SystemShutdown: typeTag = "system-shutdown"; break;
+ case StreamError::UndefinedCondition: typeTag = "undefined-condition"; break;
+ case StreamError::UnsupportedEncoding: typeTag = "unsupported-encoding"; break;
+ case StreamError::UnsupportedStanzaType: typeTag = "unsupported-stanza-type"; break;
+ case StreamError::UnsupportedVersion: typeTag = "unsupported-version"; break;
+ case StreamError::XMLNotWellFormed: typeTag = "xml-not-well-formed"; break;
+ }
+ errorElement.addNode(boost::make_shared<XMLElement>(typeTag, ""));
+
+ if (!error->getText().isEmpty()) {
+ errorElement.addNode(boost::make_shared<XMLElement>("text", "", error->getText()));
+ }
+
+ return errorElement.serialize();
+}
+
+}
diff --git a/Swiften/Serializer/StreamErrorSerializer.h b/Swiften/Serializer/StreamErrorSerializer.h
new file mode 100644
index 0000000..1a7bb79
--- /dev/null
+++ b/Swiften/Serializer/StreamErrorSerializer.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Serializer/GenericElementSerializer.h>
+#include <Swiften/Elements/StreamError.h>
+
+namespace Swift {
+ class StreamErrorSerializer : public GenericElementSerializer<StreamError> {
+ public:
+ StreamErrorSerializer();
+
+ virtual String serialize(boost::shared_ptr<Element> error) const;
+ };
+}