From bf805bfa2f0ab822f88bcd85d0c4aa4cf3b0ca87 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 28 Mar 2007 12:17:34 +0200 Subject: [PATCH] Disable the presence service. You can reenable it by just changing the _ENABLE var to True. --- shell/model/Owner.py | 8 ++-- shell/view/ActivityHost.py | 3 +- sugar/presence/PresenceService.py | 74 ++++++++++++++++++++++++++++--- 3 files changed, 75 insertions(+), 10 deletions(-) diff --git a/shell/model/Owner.py b/shell/model/Owner.py index 3d5b3333..b0d020cc 100644 --- a/shell/model/Owner.py +++ b/shell/model/Owner.py @@ -89,11 +89,11 @@ class ShellOwner(gobject.GObject): props = {'color': color.to_string(), 'icon-hash': self._icon_hash} self._service = self._pservice.register_service(self._nick, PRESENCE_SERVICE_TYPE, properties=props) - logging.debug("Owner '%s' using port %d" % (self._nick, self._service.get_port())) + #logging.debug("Owner '%s' using port %d" % (self._nick, self._service.get_port())) - self._icon_stream = Stream.Stream.new_from_service(self._service) - self._icon_stream.register_reader_handler(self._handle_buddy_icon_request, "get_buddy_icon") - self._icon_stream.register_reader_handler(self._handle_invite, "invite") + #self._icon_stream = Stream.Stream.new_from_service(self._service) + #self._icon_stream.register_reader_handler(self._handle_buddy_icon_request, "get_buddy_icon") + #self._icon_stream.register_reader_handler(self._handle_invite, "invite") def _handle_buddy_icon_request(self): """XMLRPC method, return the owner's icon encoded with base64.""" diff --git a/shell/view/ActivityHost.py b/shell/view/ActivityHost.py index cc0c0ddb..9b742664 100644 --- a/shell/view/ActivityHost.py +++ b/shell/view/ActivityHost.py @@ -51,7 +51,8 @@ class ActivityHost: win = self._gdk_window #self._chat_widget = ActivityChat.ActivityChat(self) - #self._chat_window = ActivityChatWindow(win, self._chat_widget) + self._chat_widget = gtk.HBox() + self._chat_window = ActivityChatWindow(win, self._chat_widget) self._frame_was_visible = False diff --git a/sugar/presence/PresenceService.py b/sugar/presence/PresenceService.py index fd6091e8..a8cfd4d2 100644 --- a/sugar/presence/PresenceService.py +++ b/sugar/presence/PresenceService.py @@ -19,6 +19,8 @@ import dbus, dbus.glib, gobject import Buddy, Service, Activity +_ENABLED = False + class ObjectCache(object): def __init__(self): self._cache = {} @@ -223,15 +225,77 @@ class PresenceService(gobject.GObject): def unregister_service_type(self, stype): self._ps.unregisterServiceType(stype) +class _MockPresenceService(gobject.GObject): + + __gsignals__ = { + 'buddy-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), + 'buddy-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), + 'service-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), + 'service-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), + 'activity-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), + 'activity-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])) + } + + def __init__(self): + gobject.GObject.__init__(self) + + def get_services(self): + return [] + + def get_services_of_type(self, stype): + return [] + + def get_activities(self): + return [] + + def get_activity(self, activity_id): + return None + + def get_buddies(self): + return [] + + def get_buddy_by_name(self, name): + return None + + def get_buddy_by_address(self, addr): + return None + + def get_owner(self): + return None + + def share_activity(self, activity, stype, properties={}, address=None, port=-1, domain=u"local"): + return None + + def register_service(self, name, stype, properties={}, address=None, port=-1, domain=u"local"): + return None + + def unregister_service(self, service): + pass + + def register_service_type(self, stype): + pass + + def unregister_service_type(self, stype): + pass + _ps = None def get_instance(): global _ps if not _ps: - _ps = PresenceService() + if _ENABLED: + _ps = PresenceService() + else: + _ps = _MockPresenceService() return _ps - def start(): - bus = dbus.SessionBus() - ps = dbus.Interface(bus.get_object(DBUS_SERVICE, DBUS_PATH), DBUS_INTERFACE) - ps.start() + if _ENABLED: + bus = dbus.SessionBus() + ps = dbus.Interface(bus.get_object(DBUS_SERVICE, DBUS_PATH), DBUS_INTERFACE) + ps.start()