summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/StreamErrorParser.cpp')
-rw-r--r--Swiften/Parser/StreamErrorParser.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/Swiften/Parser/StreamErrorParser.cpp b/Swiften/Parser/StreamErrorParser.cpp
new file mode 100644
index 0000000..b121ef2
--- /dev/null
+++ b/Swiften/Parser/StreamErrorParser.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Parser/StreamErrorParser.h>
+
+namespace Swift {
+
+StreamErrorParser::StreamErrorParser() : level(TopLevel) {
+}
+
+void StreamErrorParser::handleStartElement(const String&, const String&, const AttributeMap&) {
+ ++level;
+}
+
+void StreamErrorParser::handleEndElement(const String& element, const String&) {
+ --level;
+ if (level == ElementLevel) {
+ if (element == "text") {
+ getElementGeneric()->setText(currentText);
+ }
+ else if (element == "bad-format") {
+ getElementGeneric()->setType(StreamError::BadFormat);
+ }
+ else if(element == "bad-namespace-prefix") {
+ getElementGeneric()->setType(StreamError::BadNamespacePrefix);
+ }
+ else if(element == "conflict") {
+ getElementGeneric()->setType(StreamError::Conflict);
+ }
+ else if(element == "connection-timeout") {
+ getElementGeneric()->setType(StreamError::ConnectionTimeout);
+ }
+ else if(element == "host-gone") {
+ getElementGeneric()->setType(StreamError::HostGone);
+ }
+ else if(element == "host-unknown") {
+ getElementGeneric()->setType(StreamError::HostUnknown);
+ }
+ else if(element == "improper-addressing") {
+ getElementGeneric()->setType(StreamError::ImproperAddressing);
+ }
+ else if(element == "internal-server-error") {
+ getElementGeneric()->setType(StreamError::InternalServerError);
+ }
+ else if(element == "invalid-from") {
+ getElementGeneric()->setType(StreamError::InvalidFrom);
+ }
+ else if(element == "invalid-id") {
+ getElementGeneric()->setType(StreamError::InvalidID);
+ }
+ else if(element == "invalid-namespace") {
+ getElementGeneric()->setType(StreamError::InvalidNamespace);
+ }
+ else if(element == "invalid-xml") {
+ getElementGeneric()->setType(StreamError::InvalidXML);
+ }
+ else if(element == "not-authorized") {
+ getElementGeneric()->setType(StreamError::NotAuthorized);
+ }
+ else if(element == "policy-violation") {
+ getElementGeneric()->setType(StreamError::PolicyViolation);
+ }
+ else if(element == "remote-connection-failed") {
+ getElementGeneric()->setType(StreamError::RemoteConnectionFailed);
+ }
+ else if(element == "resource-constraint") {
+ getElementGeneric()->setType(StreamError::ResourceConstraint);
+ }
+ else if(element == "restricted-xml") {
+ getElementGeneric()->setType(StreamError::RestrictedXML);
+ }
+ else if(element == "see-other-host") {
+ getElementGeneric()->setType(StreamError::SeeOtherHost);
+ }
+ else if(element == "system-shutdown") {
+ getElementGeneric()->setType(StreamError::SystemShutdown);
+ }
+ else if(element == "undefined-condition") {
+ getElementGeneric()->setType(StreamError::UndefinedCondition);
+ }
+ else if(element == "unsupported-encoding") {
+ getElementGeneric()->setType(StreamError::UnsupportedEncoding);
+ }
+ else if(element == "unsupported-stanza-type") {
+ getElementGeneric()->setType(StreamError::UnsupportedStanzaType);
+ }
+ else if(element == "unsupported-version") {
+ getElementGeneric()->setType(StreamError::UnsupportedVersion);
+ }
+ else if(element == "xml-not-well-formed") {
+ getElementGeneric()->setType(StreamError::XMLNotWellFormed);
+ }
+ else {
+ getElementGeneric()->setType(StreamError::UndefinedCondition);
+ }
+ }
+}
+
+void StreamErrorParser::handleCharacterData(const String& data) {
+ currentText += data;
+}
+
+}