[gnome-shell] get presence changes from TpContact
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] get presence changes from TpContact
- Date: Wed, 16 Feb 2011 09:16:00 +0000 (UTC)
commit 4ef192357377e1c65a767f6a30c9ec74ee605249
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Tue Feb 8 14:50:06 2011 +0100
get presence changes from TpContact
js/ui/telepathyClient.js | 21 +++++++--------------
1 files changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/js/ui/telepathyClient.js b/js/ui/telepathyClient.js
index ac9fd9b..fd3956c 100644
--- a/js/ui/telepathyClient.js
+++ b/js/ui/telepathyClient.js
@@ -54,7 +54,6 @@ Client.prototype = {
this._sources = {};
contactManager = new ContactManager();
- contactManager.connect('presence-changed', Lang.bind(this, this._presenceChanged));
// Set up a SimpleObserver, which will call _observeChannels whenever a
// channel matching its filters is detected.
@@ -125,15 +124,6 @@ Client.prototype = {
// Allow dbus method to return
context.accept();
- },
-
- _presenceChanged: function(contactManager, connPath, handle,
- type, message) {
- let source = this._sources[connPath + ':' + handle];
- if (!source)
- return;
-
- source.setPresence(type, message);
}
};
@@ -312,9 +302,7 @@ Source.prototype = {
this._notification = new Notification(this);
this._notification.setUrgency(MessageTray.Urgency.HIGH);
- // Since we only create sources when receiving a message, this
- // is a plausible default
- this._presence = Tp.ConnectionPresenceType.AVAILABLE;
+ this._presence = contact.get_presence_type();
this._channelText = new Telepathy.ChannelText(DBus.session, conn.get_bus_name(), channel.get_object_path());
this._sentId = this._channelText.connect('Sent', Lang.bind(this, this._messageSent));
@@ -326,6 +314,7 @@ Source.prototype = {
this._notifyAliasId = this._contact.connect('notify::alias', Lang.bind(this, this._updateAlias));
this._notifyAvatarId = this._contact.connect('notify::avatar-file', Lang.bind(this, this._updateAvatarIcon));
+ this._presenceChangedId = this._contact.connect('presence-changed', Lang.bind(this, this._presenceChanged));
},
_updateAlias: function() {
@@ -380,6 +369,7 @@ Source.prototype = {
this._contact.disconnect(this._notifyAliasId);
this._contact.disconnect(this._notifyAvatarId);
+ this._contact.disconnect(this._presenceChangedId);
this.destroy();
},
@@ -406,9 +396,12 @@ Source.prototype = {
this._channelText.SendRemote(Tp.ChannelTextMessageType.NORMAL, text);
},
- setPresence: function(presence, message) {
+ _presenceChanged: function (contact, presence, type, status, message) {
let msg, shouldNotify, title;
+ if (this._presence == presence)
+ return;
+
title = GLib.markup_escape_text(this.title, -1);
if (presence == Tp.ConnectionPresenceType.AVAILABLE) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]