diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-10-07 10:50:19 +0100 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-11-23 17:46:31 +0000 |
commit | 2e2a062f8548ea3d88153d68fc62cdaba33fbb7e (patch) | |
tree | 966f9358ac748bd4c7f25b1be4f8a35b1b57a331 /src | |
parent | 557d0de3b6670e05e3ec662104db876dbbb9e9ad (diff) |
normalize_room: use gabble_decode_jid to shorten the function
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/util.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/util.c b/src/util.c index 64c1bb57e..bf6f9f4ef 100644 --- a/src/util.c +++ b/src/util.c @@ -416,7 +416,7 @@ gabble_normalize_room (TpHandleRepoIface *repo, GError **error) { GabbleConnection *conn = GABBLE_CONNECTION (context); - gchar *at, *slash, *qualified_name; + gchar *qualified_name, *resource; qualified_name = gabble_connection_get_canonical_room_name (conn, jid); @@ -429,33 +429,19 @@ gabble_normalize_room (TpHandleRepoIface *repo, return NULL; } - at = strchr (qualified_name, '@'); - slash = strchr (qualified_name, '/'); - - /* there'd better be an @ somewhere after the first character */ - if (at == NULL) + if (!gabble_decode_jid (qualified_name, NULL, NULL, &resource)) { - INVALID_HANDLE (error, - "invalid room JID %s: does not contain '@'", qualified_name); - g_free (qualified_name); - return NULL; - } - if (at == qualified_name) - { - INVALID_HANDLE (error, - "invalid room JID %s: room name before '@' may not be empty", - qualified_name); - g_free (qualified_name); + INVALID_HANDLE (error, "room JID %s is invalid", qualified_name); return NULL; } - /* room names can't contain the nick part */ - if (slash != NULL) + if (resource != NULL) { INVALID_HANDLE (error, "invalid room JID %s: contains nickname part after '/' too", qualified_name); g_free (qualified_name); + g_free (resource); return NULL; } |