From 8baff21f8e30648790ac0bf055509488f06f1cb8 Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@activitycentral.org>
Date: Thu, 14 Jul 2011 15:38:23 +0000
Subject: [PATCH sugar] Disable telepathy plugins on sugar shell level #2967
---
src/jarabe/model/neighborhood.py | 66 ++++++++++++++++++++------------------
1 files changed, 35 insertions(+), 31 deletions(-)
diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
index 7f0d0ab..7dbc4af 100644
a
|
b
|
|
14 | 14 | # along with this program; if not, write to the Free Software |
15 | 15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
16 | 16 | |
| 17 | import os |
17 | 18 | import logging |
18 | 19 | from functools import partial |
19 | 20 | from hashlib import sha1 |
… |
… |
class _Account(gobject.GObject): |
192 | 193 | self._buddy_handles = {} |
193 | 194 | self._activity_handles = {} |
194 | 195 | self._self_handle = None |
| 196 | self._disabled = False |
195 | 197 | |
196 | 198 | self._buddies_per_activity = {} |
197 | 199 | self._activities_per_buddy = {} |
198 | 200 | |
199 | | self._start_listening() |
| 201 | cm_name = account_path.split('/')[-3] |
| 202 | debug_flags = os.environ.get('PRESENCE_SERVICE_DEBUG', '').split(',') |
| 203 | if 'disable-%s' % cm_name in debug_flags: |
| 204 | logging.info('%s disabled by PRESENCE_SERVICE_DEBUG', cm_name) |
| 205 | self._disabled = True |
| 206 | else: |
| 207 | self._start_listening() |
| 208 | |
| 209 | def update_parameters(self, parameters): |
| 210 | bus = dbus.Bus() |
| 211 | account = bus.get_object(ACCOUNT_MANAGER_SERVICE, self.object_path) |
| 212 | params_needing_reconnect = account.UpdateParameters( |
| 213 | parameters, dbus.Array([], 's'), dbus_interface=ACCOUNT) |
| 214 | if not self._disabled and params_needing_reconnect: |
| 215 | account.Reconnect() |
200 | 216 | |
201 | 217 | def _start_listening(self): |
202 | 218 | bus = dbus.Bus() |
… |
… |
class _Account(gobject.GObject): |
637 | 653 | self._connection = None |
638 | 654 | |
639 | 655 | def _set_enabled(self, value): |
| 656 | if self._disabled: |
| 657 | return |
| 658 | |
640 | 659 | bus = dbus.Bus() |
641 | 660 | obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, self.object_path) |
642 | 661 | obj.Set(ACCOUNT, 'Enabled', value, |
… |
… |
class _Account(gobject.GObject): |
646 | 665 | dbus_interface=dbus.PROPERTIES_IFACE) |
647 | 666 | |
648 | 667 | def __set_enabled_cb(self): |
649 | | logging.debug('_Account.__set_enabled_cb success') |
| 668 | logging.debug('_Account.__set_enabled_cb success %r', self.object_path) |
650 | 669 | |
651 | 670 | |
652 | 671 | class Neighborhood(gobject.GObject): |
… |
… |
class Neighborhood(gobject.GObject): |
819 | 838 | def __jabber_server_changed_cb(self, client, timestamp, entry, *extra): |
820 | 839 | logging.debug('__jabber_server_changed_cb') |
821 | 840 | |
822 | | bus = dbus.Bus() |
823 | | account = bus.get_object(ACCOUNT_MANAGER_SERVICE, |
824 | | self._server_account.object_path) |
825 | | |
826 | | server = client.get_string( |
827 | | '/desktop/sugar/collaboration/jabber_server') |
828 | | account_id = self._get_jabber_account_id() |
829 | | params_needing_reconnect = account.UpdateParameters( |
830 | | {'server': server, |
831 | | 'account': account_id, |
832 | | 'register': True}, |
833 | | dbus.Array([], 's'), dbus_interface=ACCOUNT) |
834 | | if params_needing_reconnect: |
835 | | account.Reconnect() |
836 | | |
| 841 | parameters = { |
| 842 | 'server': client.get_string( |
| 843 | '/desktop/sugar/collaboration/jabber_server'), |
| 844 | 'account': self._get_jabber_account_id(), |
| 845 | 'register': True, |
| 846 | } |
| 847 | self._server_account.update_parameters(parameters) |
837 | 848 | self._update_jid() |
838 | 849 | |
839 | 850 | def __nick_changed_cb(self, client, timestamp, entry, *extra): |
… |
… |
class Neighborhood(gobject.GObject): |
851 | 862 | self._link_local_account.object_path) |
852 | 863 | link_local_obj.Set(ACCOUNT, 'Nickname', nick, |
853 | 864 | dbus_interface=PROPERTIES_IFACE) |
854 | | params_needing_reconnect = link_local_obj.UpdateParameters( |
855 | | {'nickname': nick, 'published-name': self._get_published_name()}, |
856 | | dbus.Array([], 's'), dbus_interface=ACCOUNT) |
857 | | if params_needing_reconnect: |
858 | | link_local_obj.Reconnect() |
| 865 | |
| 866 | params = {'nickname': nick, |
| 867 | 'published-name': self._get_published_name(), |
| 868 | } |
| 869 | self._link_local_account.update_parameters(params) |
859 | 870 | |
860 | 871 | self._update_jid() |
861 | 872 | |
862 | 873 | def _update_jid(self): |
863 | | bus = dbus.Bus() |
864 | | account = bus.get_object(ACCOUNT_MANAGER_SERVICE, |
865 | | self._link_local_account.object_path) |
866 | | |
867 | | account_id = self._get_jabber_account_id() |
868 | | params_needing_reconnect = account.UpdateParameters( |
869 | | {'jid': account_id}, dbus.Array([], 's'), dbus_interface=ACCOUNT) |
870 | | if params_needing_reconnect: |
871 | | account.Reconnect() |
| 874 | parameters = {'jid': self._get_jabber_account_id()} |
| 875 | self._link_local_account.update_parameters(parameters) |
872 | 876 | |
873 | 877 | def __buddy_added_cb(self, account, contact_id, nick, handle): |
874 | 878 | logging.debug('__buddy_added_cb %r', contact_id) |