[gnome-shell] telepathyClient: only notify on new channels when asked to do so



commit 69e26c6dee56c6bbedfa0a48d8aecea984f45a40
Author: Jonny Lamb <jonnylamb gnome org>
Date:   Thu Dec 15 11:24:38 2011 +0000

    telepathyClient: only notify on new channels when asked to do so
    
    We need to notify when the channel dispatcher calls HandleChannels on
    us with a channel we already handle. However, we don't want to notify
    if we claim a new incoming channel which doesn't actually have
    anything interesting in it yet.
    
    For example, a new channel pops up just to give a delivery
    notification. We want (or, need) to handle it but don't want to notify
    for it.
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=666243
    
    Signed-off-by: Jonny Lamb <jonnylamb gnome org>

 js/ui/telepathyClient.js |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/telepathyClient.js b/js/ui/telepathyClient.js
index 9f9d12e..90f6b67 100644
--- a/js/ui/telepathyClient.js
+++ b/js/ui/telepathyClient.js
@@ -197,11 +197,11 @@ const Client = new Lang.Class({
 
     _handleChannels: function(handler, account, conn, channels,
                               requests, user_action_time, context) {
-        this._handlingChannels(account, conn, channels);
+        this._handlingChannels(account, conn, channels, true);
         context.accept();
     },
 
-    _handlingChannels: function(account, conn, channels) {
+    _handlingChannels: function(account, conn, channels, notify) {
         let len = channels.length;
         for (let i = 0; i < len; i++) {
             let channel = channels[i];
@@ -212,7 +212,18 @@ const Client = new Lang.Class({
                 continue;
             }
 
-            if (this._tpClient.is_handling_channel(channel)) {
+            // 'notify' will be true when coming from an actual HandleChannels
+            // call, and not when from a successful Claim call. The point is
+            // we don't want to notify for a channel we just claimed which
+            // has no new messages (for example, a new channel which only has
+            // a delivery notification). We rely on _displayPendingMessages()
+            // and _messageReceived() to notify for new messages.
+
+            // But we should still notify from HandleChannels because the
+            // Telepathy spec states that handlers must foreground channels
+            // in HandleChannels calls which are already being handled.
+
+            if (notify && this._tpClient.is_handling_channel(channel)) {
                 // We are already handling the channel, display the source
                 let source = this._chatSources[channel.get_object_path()];
                 if (source)
@@ -285,7 +296,7 @@ const Client = new Lang.Class({
                                         Lang.bind(this, function(dispatchOp, result) {
                 try {
                     dispatchOp.claim_with_finish(result);
-                    this._handlingChannels(account, conn, [channel]);
+                    this._handlingChannels(account, conn, [channel], false);
                 } catch (err) {
                     throw new Error('Failed to Claim channel: ' + err);
                 }}));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]