[polari] room: Improve channel-name <-> channel matching
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] room: Improve channel-name <-> channel matching
- Date: Thu, 1 Oct 2015 21:25:59 +0000 (UTC)
commit 597c8c63d15c4f85224e18b8b526b63c6b2c5e25
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Oct 1 16:10:21 2015 +0200
room: Improve channel-name <-> channel matching
When we request a channel, we currently assume that the resulting
channel's identifier will match the channel name we used in the
request. However as telepathy-idle converts all channel names to
lowercase [0], we fail to match names containing uppercase characters
to their channel and end up creating a second room for the channel
instead. Fix this by using lower-case for both room IDs and channel
matching.
[0]
http://cgit.freedesktop.org/telepathy/telepathy-idle/tree/src/idle-handles.c#n158
https://bugzilla.gnome.org/show_bug.cgi?id=755722
src/lib/polari-room.c | 31 +++++++++++++++++++++++++------
1 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/src/lib/polari-room.c b/src/lib/polari-room.c
index 5667122..5dc074c 100644
--- a/src/lib/polari-room.c
+++ b/src/lib/polari-room.c
@@ -109,12 +109,18 @@ polari_create_room_id (TpAccount *account,
const char *name,
TpHandleType type)
{
+ char *id, *folded_name;
+
g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
g_return_val_if_fail (name != NULL, NULL);
- return g_strdup_printf ("%s/%d/%s",
- tp_proxy_get_object_path (TP_PROXY (account)),
- type, name);
+ folded_name = g_utf8_strdown (name, -1);
+ id = g_strdup_printf ("%s/%d/%s",
+ tp_proxy_get_object_path (TP_PROXY (account)),
+ type, folded_name);
+
+ g_free (folded_name);
+ return id;
}
gboolean
@@ -503,12 +509,25 @@ polari_room_set_channel_name (PolariRoom *room,
priv = room->priv;
g_free (priv->channel_name);
- priv->channel_name = g_strdup (channel_name);
if (channel_name)
- set_display_name (room, channel_name + (channel_name[0] == '#' ? 1 : 0));
+ {
+ /* Tp enforces lower-case for all channel names[0], so we need to either
+ * convert the name to lower-case once here or each time we compare it to
+ * a channel identifier in check_channel(); case isn't relevant for the
+ * display name on the other hand, so we can use the original string which
+ * matches what the user requested.
+ *
+ * [0] http://cgit.freedesktop.org/telepathy/telepathy-idle/tree/src/idle-handles.c#n158
+ */
+ priv->channel_name = g_utf8_strdown (channel_name, -1);
+ set_display_name (room, channel_name + (channel_name[0] == '#' ? 1 : 0));
+ }
else
- set_display_name (room, NULL);
+ {
+ priv->channel_name = NULL;
+ set_display_name (room, NULL);
+ }
g_object_notify_by_pspec (G_OBJECT (room), props[PROP_CHANNEL_NAME]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]