[telepathy-gabble/telepathy-gabble-0.8] normalize_room: use gabble_decode_jid to shorten the function
Jonny Lamb
jonny.lamb at collabora.co.uk
Mon Dec 7 04:12:59 PST 2009
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
src/util.c | 24 +++++-------------------
1 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/src/util.c b/src/util.c
index 3a7a983..e0e6e18 100644
--- a/src/util.c
+++ b/src/util.c
@@ -588,7 +588,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);
@@ -601,33 +601,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)
- {
- INVALID_HANDLE (error,
- "invalid room JID %s: does not contain '@'", qualified_name);
- g_free (qualified_name);
- return NULL;
- }
- if (at == qualified_name)
+ if (!gabble_decode_jid (qualified_name, NULL, NULL, &resource))
{
- 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;
}
--
1.5.6.5
More information about the telepathy-commits
mailing list