Ticket #2967: 0001-Disable-telepathy-plugins-on-sugar-shell-level-2967.patch

File 0001-Disable-telepathy-plugins-on-sugar-shell-level-2967.patch, 5.1 KB (added by alsroot, 10 years ago)
  • src/jarabe/model/neighborhood.py

    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  
    1414# along with this program; if not, write to the Free Software
    1515# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1616
     17import os
    1718import logging
    1819from functools import partial
    1920from hashlib import sha1
    class _Account(gobject.GObject): 
    192193        self._buddy_handles = {}
    193194        self._activity_handles = {}
    194195        self._self_handle = None
     196        self._disabled = False
    195197
    196198        self._buddies_per_activity = {}
    197199        self._activities_per_buddy = {}
    198200
    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()
    200216
    201217    def _start_listening(self):
    202218        bus = dbus.Bus()
    class _Account(gobject.GObject): 
    637653        self._connection = None
    638654
    639655    def _set_enabled(self, value):
     656        if self._disabled:
     657            return
     658
    640659        bus = dbus.Bus()
    641660        obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, self.object_path)
    642661        obj.Set(ACCOUNT, 'Enabled', value,
    class _Account(gobject.GObject): 
    646665                dbus_interface=dbus.PROPERTIES_IFACE)
    647666
    648667    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)
    650669
    651670
    652671class Neighborhood(gobject.GObject):
    class Neighborhood(gobject.GObject): 
    819838    def __jabber_server_changed_cb(self, client, timestamp, entry, *extra):
    820839        logging.debug('__jabber_server_changed_cb')
    821840
    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)
    837848        self._update_jid()
    838849
    839850    def __nick_changed_cb(self, client, timestamp, entry, *extra):
    class Neighborhood(gobject.GObject): 
    851862                                        self._link_local_account.object_path)
    852863        link_local_obj.Set(ACCOUNT, 'Nickname', nick,
    853864                           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)
    859870
    860871        self._update_jid()
    861872
    862873    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)
    872876
    873877    def __buddy_added_cb(self, account, contact_id, nick, handle):
    874878        logging.debug('__buddy_added_cb %r', contact_id)