[kupfer: 9/22] plugin.pidgin: Detect when a buddy's status changes and update
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer: 9/22] plugin.pidgin: Detect when a buddy's status changes and update
- Date: Fri, 30 Oct 2009 14:02:56 +0000 (UTC)
commit 0f3bd50be841de75fa2e6c935b7b66f8089d00a2
Author: Chmouel Boudjnah <chmouel boudjnah rackspace co uk>
Date: Tue Oct 27 23:08:56 2009 +0000
plugin.pidgin: Detect when a buddy's status changes and update
kupfer/plugin/pidgin.py | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/plugin/pidgin.py b/kupfer/plugin/pidgin.py
index 9335dd4..c99b2a3 100644
--- a/kupfer/plugin/pidgin.py
+++ b/kupfer/plugin/pidgin.py
@@ -133,7 +133,7 @@ class ContactsSource(AppLeafContentMixin, Source, PicklingHelperMixin):
def unpickle_finish(self):
self.mark_for_update()
self.all_buddies = {}
- self._signal_online_offline_buddies()
+ self._install_dbus_signal()
def pickle_prepare(self):
# delete data that we do not want to save to next session
@@ -198,7 +198,19 @@ class ContactsSource(AppLeafContentMixin, Source, PicklingHelperMixin):
del self.all_buddies[buddy]
self.mark_for_update()
- def _signal_online_offline_buddies(self):
+ def _buddy_status_changed(self, buddy, old, new):
+ '''Callback when status is changed reload the entry
+ which get the new status'''
+ interface = _create_dbus_connection()
+ status_message = interface.PurpleStatusGetAttrString(old, "message")
+
+ if buddy in self.all_buddies:
+ del self.all_buddies[buddy]
+
+ self.all_buddies[buddy] = self._get_pidgin_contact(interface, buddy)
+ self.mark_for_update()
+
+ def _install_dbus_signal(self):
'''Add signals to pidgin when buddy goes offline or
online to update the list'''
try:
@@ -212,6 +224,13 @@ class ContactsSource(AppLeafContentMixin, Source, PicklingHelperMixin):
dbus_interface="im.pidgin.purple.PurpleInterface",
byte_arrays=True)
+ buddy_status_changed_cb = DbusWeakCallback(self._buddy_status_changed)
+ buddy_status_changed_cb.token = session_bus.add_signal_receiver(
+ buddy_status_changed_cb,
+ "BuddyStatusChanged",
+ dbus_interface="im.pidgin.purple.PurpleInterface",
+ byte_arrays=True)
+
buddy_sign_off_cb = DbusWeakCallback(self._buddy_signed_off)
buddy_sign_off_cb.token = session_bus.add_signal_receiver(
buddy_sign_off_cb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]