Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-08-20 14:25:13 (GMT)
committer Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-08-20 14:25:13 (GMT)
commitd156ff56a8f63dba184fe0984986bd4f39c206dd (patch)
tree1655b7c4931fe3f8c88fba0de2a726db382e2907
parent1af1bc97134663fdbb9a7c71fb1b1b4aad8545ed (diff)
Address comments from Simon's reviewHEADmaster
-rw-r--r--src/sugar/activity/activityservice.py4
-rw-r--r--src/sugar/presence/connectionmanager.py6
-rw-r--r--src/sugar/presence/presenceservice.py177
3 files changed, 8 insertions, 179 deletions
diff --git a/src/sugar/activity/activityservice.py b/src/sugar/activity/activityservice.py
index bdce898..ff15471 100644
--- a/src/sugar/activity/activityservice.py
+++ b/src/sugar/activity/activityservice.py
@@ -71,10 +71,6 @@ class ActivityService(dbus.service.Object):
self._activity.invite(account_path, contact_id)
@dbus.service.method(_ACTIVITY_INTERFACE)
- def Invite(self, buddy_key):
- raise NotImplementedError
-
- @dbus.service.method(_ACTIVITY_INTERFACE)
def HandleViewSource(self):
self._activity.handle_view_source()
diff --git a/src/sugar/presence/connectionmanager.py b/src/sugar/presence/connectionmanager.py
index cc57137..1165c45 100644
--- a/src/sugar/presence/connectionmanager.py
+++ b/src/sugar/presence/connectionmanager.py
@@ -15,6 +15,10 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
+"""
+UNSTABLE. It should really be internal to the sugar.presence package.
+"""
+
from functools import partial
import dbus
@@ -34,6 +38,8 @@ class Connection(object):
self.connected = False
class ConnectionManager(object):
+ """Track available telepathy connections"""
+
def __init__(self):
self._connections_per_account = {}
diff --git a/src/sugar/presence/presenceservice.py b/src/sugar/presence/presenceservice.py
index 4241cd4..326791b 100644
--- a/src/sugar/presence/presenceservice.py
+++ b/src/sugar/presence/presenceservice.py
@@ -16,8 +16,7 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-"""UI class to access system-level presence object
-
+"""
STABLE.
"""
@@ -44,27 +43,8 @@ ACCOUNT_MANAGER_SERVICE = 'org.freedesktop.Telepathy.AccountManager'
ACCOUNT_MANAGER_PATH = '/org/freedesktop/Telepathy/AccountManager'
class PresenceService(gobject.GObject):
- """UI-side interface to the dbus presence service
-
- This class provides UI programmers with simplified access
- to the dbus service of the same name. It allows for observing
- various events from the presence service as GObject events,
- as well as some basic introspection queries.
- """
+ """Provides simplified access to the Telepathy framework to activities"""
__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])),
- # parameters: (activity: Activity, inviter: Buddy, message: unicode)
- 'activity-invitation': (gobject.SIGNAL_RUN_FIRST, None, ([object]*3)),
- 'private-invitation': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT,
- gobject.TYPE_PYOBJECT, str])),
- 'activity-appeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT])),
- 'activity-disappeared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT])),
'activity-shared': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT,
gobject.TYPE_PYOBJECT])),
@@ -123,85 +103,6 @@ class PresenceService(gobject.GObject):
"""
del self._objcache[object_path]
- def _emit_buddy_appeared_signal(self, object_path):
- """Emit GObject event with presence.buddy.Buddy object"""
- self.emit('buddy-appeared', self._new_object(object_path))
- return False
-
- def _buddy_appeared_cb(self, op):
- """Callback for dbus event (forwards to method to emit GObject
- event)"""
- gobject.idle_add(self._emit_buddy_appeared_signal, op)
-
- def _emit_buddy_disappeared_signal(self, object_path):
- """Emit GObject event with presence.buddy.Buddy object"""
- # Don't try to create a new object here if needed; it will probably
- # fail anyway because the object has already been destroyed in the PS
- if self._have_object(object_path):
- obj = self._objcache[object_path]
- self.emit('buddy-disappeared', obj)
-
- # We cannot maintain the object in the cache because that would
- # keep a lot of objects from being collected. That includes UI
- # objects due to signals using strong references.
- # If we want to cache some despite the memory usage increase,
- # we could use a LRU cache limited to some value.
- del self._objcache[object_path]
- obj.destroy()
-
- return False
-
- def _buddy_disappeared_cb(self, object_path):
- """Callback for dbus event (forwards to method to emit GObject
- event)"""
- gobject.idle_add(self._emit_buddy_disappeared_signal, object_path)
-
- def _emit_activity_invitation_signal(self, activity_path, buddy_path,
- message):
- """Emit GObject event with presence.activity.Activity object"""
- self.emit('activity-invitation', self._new_object(activity_path),
- self._new_object(buddy_path), unicode(message))
- return False
-
- def _activity_invitation_cb(self, activity_path, buddy_path, message):
- """Callback for dbus event (forwards to method to emit GObject
- event)"""
- gobject.idle_add(self._emit_activity_invitation_signal, activity_path,
- buddy_path, message)
-
- def _emit_private_invitation_signal(self, bus_name, connection,
- channel, chan_type):
- """Emit GObject event with bus_name, connection and channel"""
- self.emit('private-invitation', bus_name, connection,
- channel, chan_type)
- return False
-
- def _private_invitation_cb(self, bus_name, connection, channel, chan_type):
- """Callback for dbus event (forwards to method to emit GObject
- event)"""
- gobject.idle_add(self._emit_private_invitation_signal, bus_name,
- connection, channel, chan_type)
-
- def _emit_activity_appeared_signal(self, object_path):
- """Emit GObject event with presence.activity.Activity object"""
- self.emit('activity-appeared', self._new_object(object_path))
- return False
-
- def _activity_appeared_cb(self, object_path):
- """Callback for dbus event (forwards to method to emit GObject
- event)"""
- gobject.idle_add(self._emit_activity_appeared_signal, object_path)
-
- def _emit_activity_disappeared_signal(self, object_path):
- """Emit GObject event with presence.activity.Activity object"""
- self.emit('activity-disappeared', self._new_object(object_path))
- return False
-
- def _activity_disappeared_cb(self, object_path):
- """Callback for dbus event (forwards to method to emit GObject
- event)"""
- gobject.idle_add(self._emit_activity_disappeared_signal, object_path)
-
def get(self, object_path):
"""Return the Buddy or Activity object corresponding to the given
D-Bus object path.
@@ -463,80 +364,6 @@ class PresenceService(gobject.GObject):
return connection.requested_bus_name, connection.object_path
-class _OfflineInterface(object):
- """Offline-presence-service interface
-
- Used to mimic the behaviour of a real PresenceService sufficiently
- to avoid crashing client code that expects the given interface.
-
- XXX we could likely return a "MockOwner" object reasonably
- easily, but would it be worth it?
- """
-
- def raiseException(self, *args, **named):
- """Raise dbus.exceptions.DBusException"""
- raise dbus.exceptions.DBusException('PresenceService Interface not '
- 'available')
-
- GetActivities = raiseException
- GetActivityById = raiseException
- GetBuddies = raiseException
- GetBuddyByPublicKey = raiseException
- GetOwner = raiseException
- GetPreferredConnection = raiseException
-
- def ShareActivity(self, actid, atype, name, properties, reply_handler,
- error_handler):
- """Pretend to share and fail..."""
- exc = IOError('Unable to share activity as PresenceService is not '
- 'currently available')
- return error_handler(exc)
-
-
-class _MockPresenceService(gobject.GObject):
- """Test fixture allowing testing of items that use PresenceService
-
- See PresenceService for usage and purpose
- """
-
- __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])),
- 'activity-invitation': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT])),
- 'private-invitation': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT,
- 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_activities(self):
- return []
-
- def get_activity(self, activity_id):
- return None
-
- def get_buddies(self):
- return []
-
- def get_buddy(self, key):
- return None
-
- def get_owner(self):
- return None
-
- def share_activity(self, activity, properties=None):
- return None
-
-
_ps = None