summaryrefslogtreecommitdiff
path: root/wocky/wocky-xmpp-error.c
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-01-29 17:08:36 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2010-02-03 15:18:16 +0000
commitd915abf0858f13c000203685bbfce8368803dd60 (patch)
treef0d48380194d05567204f4d562f78c85e481e911 /wocky/wocky-xmpp-error.c
parenta6fbbd4f2200563dde0fa9b26fcdc7390adf5435 (diff)
Convert to WockyXmppStreamError using GEnum
Diffstat (limited to 'wocky/wocky-xmpp-error.c')
-rw-r--r--wocky/wocky-xmpp-error.c56
1 files changed, 11 insertions, 45 deletions
diff --git a/wocky/wocky-xmpp-error.c b/wocky/wocky-xmpp-error.c
index 0c0a0ae..ff0ce0d 100644
--- a/wocky/wocky-xmpp-error.c
+++ b/wocky/wocky-xmpp-error.c
@@ -19,12 +19,13 @@
*/
#include "wocky-xmpp-error.h"
-#include "wocky-utils.h"
#include <stdlib.h>
#include <stdio.h>
#include "wocky-namespaces.h"
+#include "wocky-utils.h"
+#include "wocky-xmpp-error-enumtypes.h"
#define MAX_LEGACY_ERRORS 3
@@ -546,55 +547,20 @@ wocky_xmpp_stream_error_quark (void)
return quark;
}
-typedef struct
-{
- const gchar *name;
- WockyXmppStreamError error;
-} StreamErrorName;
-
-static const StreamErrorName stream_errors[] =
-{
- { "bad-format", WOCKY_XMPP_STREAM_ERROR_BAD_FORMAT },
- { "bad-namespace-prefix", WOCKY_XMPP_STREAM_ERROR_BAD_NAMESPACE_PREFIX },
- { "conflict", WOCKY_XMPP_STREAM_ERROR_CONFLICT },
- { "connection-timeout", WOCKY_XMPP_STREAM_ERROR_CONNECTION_TIMEOUT },
- { "host-gone", WOCKY_XMPP_STREAM_ERROR_HOST_GONE },
- { "host-unknown", WOCKY_XMPP_STREAM_ERROR_HOST_UNKNOWN },
- { "improper-addressing", WOCKY_XMPP_STREAM_ERROR_IMPROPER_ADDRESSING },
- { "internal-server-error", WOCKY_XMPP_STREAM_ERROR_INTERNAL_SERVER_ERROR },
- { "invalid-from", WOCKY_XMPP_STREAM_ERROR_INVALID_FROM },
- { "invalid-id", WOCKY_XMPP_STREAM_ERROR_INVALID_ID },
- { "invalid-namespace", WOCKY_XMPP_STREAM_ERROR_INVALID_NAMESPACE },
- { "invalid-xml", WOCKY_XMPP_STREAM_ERROR_INVALID_XML },
- { "not-authorized", WOCKY_XMPP_STREAM_ERROR_NOT_AUTHORIZED },
- { "policy-violation", WOCKY_XMPP_STREAM_ERROR_POLICY_VIOLATION },
- { "remote-connection-failed",
- WOCKY_XMPP_STREAM_ERROR_REMOTE_CONNECTION_FAILED },
- { "resource-constraint", WOCKY_XMPP_STREAM_ERROR_RESOURCE_CONSTRAINT },
- { "restricted-xml", WOCKY_XMPP_STREAM_ERROR_RESTRICTED_XML },
- { "see-other-host", WOCKY_XMPP_STREAM_ERROR_SEE_OTHER_HOST },
- { "system-shutdown", WOCKY_XMPP_STREAM_ERROR_SYSTEM_SHUTDOWN },
- { "undefined-condition", WOCKY_XMPP_STREAM_ERROR_UNDEFINED_CONDITION },
- { "unsupported-encoding", WOCKY_XMPP_STREAM_ERROR_UNSUPPORTED_ENCODING },
- { "unsupported-stanza-type",
- WOCKY_XMPP_STREAM_ERROR_UNSUPPORTED_STANZA_TYPE },
- { "unsupported-version", WOCKY_XMPP_STREAM_ERROR_UNSUPPORTED_VERSION },
- { "xml-not-well-formed", WOCKY_XMPP_STREAM_ERROR_XML_NOT_WELL_FORMED },
- { NULL, WOCKY_XMPP_STREAM_ERROR_UNKNOWN },
-};
-
WockyXmppStreamError
wocky_xmpp_stream_error_from_node (WockyXmppNode *node)
{
- guint i;
+ GSList *l = node->children;
- for (i = 0; stream_errors[i].name != NULL; i++)
+ while (l != NULL)
{
- if (wocky_xmpp_node_get_child_ns (node, stream_errors[i].name,
- WOCKY_XMPP_NS_STREAMS) != NULL)
- {
- return stream_errors[i].error;
- }
+ WockyXmppNode *child = l->data;
+ gint code;
+
+ if (wocky_xmpp_node_has_ns (child, WOCKY_XMPP_NS_STREAMS) &&
+ wocky_enum_from_nick (WOCKY_TYPE_XMPP_STREAM_ERROR, child->name,
+ &code))
+ return code;
}
return WOCKY_XMPP_STREAM_ERROR_UNKNOWN;