[telepathy-gabble/telepathy-gabble-0.8] fd.o#22456: util: get the canonical room name in gabble_normalize_room
Jonny Lamb
jonny.lamb at collabora.co.uk
Mon Dec 7 04:12:59 PST 2009
This means that both RequestHandles and the TargetID property set
during a call to CreateChannel will use the canonical room
name. Previously, it only ever did this in a RequestHandles call.
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
src/connection.c | 2 +-
src/util.c | 36 ++++++++++++++++++++++++++----------
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index 4d15a05..5af1573 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -611,7 +611,7 @@ _gabble_connection_create_handle_repos (TpBaseConnection *conn,
gabble_normalize_contact, GUINT_TO_POINTER (GABBLE_JID_ANY));
repos[TP_HANDLE_TYPE_ROOM] =
tp_dynamic_handle_repo_new (TP_HANDLE_TYPE_ROOM, gabble_normalize_room,
- NULL);
+ conn);
repos[TP_HANDLE_TYPE_GROUP] =
tp_dynamic_handle_repo_new (TP_HANDLE_TYPE_GROUP, NULL, NULL);
repos[TP_HANDLE_TYPE_LIST] =
diff --git a/src/util.c b/src/util.c
index 95b1657..3a7a983 100644
--- a/src/util.c
+++ b/src/util.c
@@ -587,20 +587,37 @@ gabble_normalize_room (TpHandleRepoIface *repo,
gpointer context,
GError **error)
{
- char *at = strchr (jid, '@');
- char *slash = strchr (jid, '/');
+ GabbleConnection *conn = GABBLE_CONNECTION (context);
+ gchar *at, *slash, *qualified_name;
+
+ qualified_name = gabble_connection_get_canonical_room_name (conn, jid);
+
+ if (qualified_name == NULL)
+ {
+ INVALID_HANDLE (error,
+ "requested room handle %s does not specify a server, but we "
+ "have not discovered any local conference servers and no "
+ "fallback was provided", jid);
+ 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 '@'", jid);
+ "invalid room JID %s: does not contain '@'", qualified_name);
+ g_free (qualified_name);
return NULL;
}
- if (at == jid)
+ if (at == qualified_name)
{
INVALID_HANDLE (error,
- "invalid room JID %s: room name before '@' may not be empty", jid);
+ "invalid room JID %s: room name before '@' may not be empty",
+ qualified_name);
+ g_free (qualified_name);
return NULL;
}
@@ -608,14 +625,13 @@ gabble_normalize_room (TpHandleRepoIface *repo,
if (slash != NULL)
{
INVALID_HANDLE (error,
- "invalid room JID %s: contains nickname part after '/' too", jid);
+ "invalid room JID %s: contains nickname part after '/' too",
+ qualified_name);
+ g_free (qualified_name);
return NULL;
}
- /* the room and service parts are both case-insensitive, so lowercase
- * them both; gabble_decode_jid is overkill here
- */
- return g_utf8_strdown (jid, -1);
+ return qualified_name;
}
gchar *
--
1.5.6.5
More information about the telepathy-commits
mailing list