From a277dfa9ce7d28149dce3e3abcdc3c5439490d3d Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 7 Apr 2010 10:50:44 -0400 Subject: [PATCH] telepathyClient: only show single-user chats, not chat rooms eg, for IRC, show private messages, but not channel messages https://bugzilla.gnome.org/show_bug.cgi?id=614972 --- js/ui/telepathyClient.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/js/ui/telepathyClient.js b/js/ui/telepathyClient.js index 7434c354e..1c66ff139 100644 --- a/js/ui/telepathyClient.js +++ b/js/ui/telepathyClient.js @@ -82,7 +82,18 @@ Client.prototype = { get ApproverChannelFilter() { return [ - { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME } + // We only care about single-user text-based chats + { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME, + 'org.freedesktop.Telepathy.Channel.TargetHandleType': Telepathy.HandleType.CONTACT }, + + // Some protocols only support "multi-user" chats, and + // single-user chats are just treated as multi-user chats + // with only one other participant. Telepathy uses + // HandleType.NONE for all chats in these protocols; + // there's no good way for us to tell if the channel is + // single- or multi-user. + { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME, + 'org.freedesktop.Telepathy.Channel.TargetHandleType': Telepathy.HandleType.NONE } ]; }, @@ -94,8 +105,12 @@ Client.prototype = { }, get HandlerChannelFilter() { + // See ApproverChannelFilter return [ - { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME } + { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME, + 'org.freedesktop.Telepathy.Channel.TargetHandleType': Telepathy.HandleType.CONTACT }, + { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME, + 'org.freedesktop.Telepathy.Channel.TargetHandleType': Telepathy.HandleType.NONE } ]; }, @@ -106,8 +121,12 @@ Client.prototype = { }, get ObserverChannelFilter() { + // See ApproverChannelFilter return [ - { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME } + { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME, + 'org.freedesktop.Telepathy.Channel.TargetHandleType': Telepathy.HandleType.CONTACT }, + { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME, + 'org.freedesktop.Telepathy.Channel.TargetHandleType': Telepathy.HandleType.NONE } ]; }, @@ -123,12 +142,20 @@ Client.prototype = { if (this._channels[channelPath]) continue; + // If this is being called from the startup code then it + // won't have passed through our filters, so we need to + // check the channel/targetHandle type ourselves. + let channelType = props[Telepathy.CHANNEL_NAME + '.ChannelType']; if (channelType != Telepathy.CHANNEL_TEXT_NAME) continue; - let targetHandle = props[Telepathy.CHANNEL_NAME + '.TargetHandle']; let targetHandleType = props[Telepathy.CHANNEL_NAME + '.TargetHandleType']; + if (targetHandleType != Telepathy.HandleType.CONTACT && + targetHandleType != Telepathy.HandleType.NONE) + continue; + + let targetHandle = props[Telepathy.CHANNEL_NAME + '.TargetHandle']; let targetId = props[Telepathy.CHANNEL_NAME + '.TargetID']; let source = new Source(connPath, channelPath,