Ticket #2483: 0001-Do-not-remove-bodies-on-offline-status-2483.patch

File 0001-Do-not-remove-bodies-on-offline-status-2483.patch, 4.7 KB (added by alsroot, 10 years ago)
  • src/jarabe/desktop/grid.py

    From 76b7b12b0b0e90a5460e7ce588fee6c30ed55576 Mon Sep 17 00:00:00 2001
    From: Aleksey Lim <alsroot@member.fsf.org>
    Date: Mon, 22 Nov 2010 13:56:03 +0000
    Subject: [PATCH] Do not remove bodies on offline status #2483
    
    While body is switching between offline/available only presence status
    is being changed, but previous code remove body on offline and did not add
    it back
    ---
     src/jarabe/desktop/grid.py       |    7 +++++++
     src/jarabe/model/buddy.py        |    3 +++
     src/jarabe/model/neighborhood.py |   28 ++++++++++++++++++++++++----
     3 files changed, 34 insertions(+), 4 deletions(-)
    
    diff --git a/src/jarabe/desktop/grid.py b/src/jarabe/desktop/grid.py
    index f3412c9..e42c5a5 100644
    a b  
    1616# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1717
    1818import random
     19import logging
    1920
    2021import gobject
    2122import gtk
    class Grid(_sugarext.Grid): 
    8384            self._collisions.remove(child)
    8485
    8586    def move(self, child, x, y, locked=False):
     87        if child not in self._child_rects:
     88            import traceback
     89            logging.warn('Grid.move, child %r is not counted:\n%s',
     90                    child, ''.join(traceback.format_stack()))
     91            return
     92
    8693        self.remove_weight(self._child_rects[child])
    8794
    8895        rect = self._child_rects[child]
  • src/jarabe/model/buddy.py

    diff --git a/src/jarabe/model/buddy.py b/src/jarabe/model/buddy.py
    index 5f3176e..77b500a 100644
    a b def get_owner_instance(): 
    190190
    191191class BuddyModel(BaseBuddyModel):
    192192    __gtype_name__ = 'SugarBuddyModel'
     193
     194    offline = True
     195
    193196    def __init__(self, **kwargs):
    194197
    195198        self._account = None
  • src/jarabe/model/neighborhood.py

    diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
    index 91dd059..e770cce 100644
    a b class _Account(gobject.GObject): 
    165165                                 gobject.TYPE_NONE, ([object, object])),
    166166        'buddy-removed':        (gobject.SIGNAL_RUN_FIRST,
    167167                                 gobject.TYPE_NONE, ([object])),
     168        'buddy-presence-changed': (gobject.SIGNAL_RUN_FIRST,
     169                                 gobject.TYPE_NONE, ([object, object])),
    168170        'buddy-joined-activity': (gobject.SIGNAL_RUN_FIRST,
    169171                                  gobject.TYPE_NONE, ([object, object])),
    170172        'buddy-left-activity':   (gobject.SIGNAL_RUN_FIRST,
    class _Account(gobject.GObject): 
    386388        for handle, presence in presences.iteritems():
    387389            if handle in self._buddy_handles:
    388390                presence_type, status_, message_ = presence
    389                 if presence_type == CONNECTION_PRESENCE_TYPE_OFFLINE:
    390                     contact_id = self._buddy_handles[handle]
    391                     del self._buddy_handles[handle]
    392                     self.emit('buddy-removed', contact_id)
     391                self.emit('buddy-presence-changed',
     392                        self._buddy_handles[handle], presence_type)
    393393
    394394    def __buddy_info_updated_cb(self, handle, properties):
    395395        logging.debug('_Account.__buddy_info_updated_cb %r', handle)
    class Neighborhood(gobject.GObject): 
    664664        account.connect('buddy-added', self.__buddy_added_cb)
    665665        account.connect('buddy-updated', self.__buddy_updated_cb)
    666666        account.connect('buddy-removed', self.__buddy_removed_cb)
     667        account.connect('buddy-presence-changed',
     668                self.__buddy_presence_changed_cb)
     669
    667670        account.connect('buddy-joined-activity',
    668671                        self.__buddy_joined_activity_cb)
    669672        account.connect('buddy-left-activity', self.__buddy_left_activity_cb)
    class Neighborhood(gobject.GObject): 
    863866        if buddy.props.key is not None:
    864867            self.emit('buddy-removed', buddy)
    865868
     869    def __buddy_presence_changed_cb(self, account, contact_id, presence_type):
     870        if contact_id not in self._buddies:
     871            logging.debug('Neighborhood.__buddy_presence_changed_cb Unknown ' \
     872                    'buddy with contact_id %r', contact_id)
     873            return
     874
     875        buddy = self._buddies[contact_id]
     876        offline = (presence_type == CONNECTION_PRESENCE_TYPE_OFFLINE);
     877
     878        if buddy.offline != offline:
     879            buddy.offline = offline
     880            if buddy.props.key is not None:
     881                if offline:
     882                    self.emit('buddy-removed', buddy)
     883                else:
     884                    self.emit('buddy-added', buddy)
     885
    866886    def __activity_added_cb(self, account, room_handle, activity_id):
    867887        logging.debug('__activity_added_cb %r %r', room_handle, activity_id)
    868888        if activity_id in self._activities: