[Sugar-devel] [FEATURE] Remove Presence Service

Marco Pesenti Gritti marco at marcopg.org
Mon Aug 16 17:33:46 EDT 2010


I don't have enough time for a very detailed review and I don't really
know telepathy, but here a few comments. Mostly nitpicks, it looks
great in general.

+        BuddyIcon.__init__(self, buddy=get_owner_instance(), size=size)

Maybe assign to self._buddy here and reuse later to pass to the menu?

+        if not self._buddy.props.present or \
+                not self._buddy.props.current_activity:

I would align the not :)

+        name = self._get_new_icon_name(self._buddy.props.current_activity)

Do we still need to use .props? I thought at some point gobject add
some magic to be able to just use properties.

+        p_text = glib.markup_escape_text(self._model.bundle.get_name())
+        p_icon = Icon(file=self._model.bundle.get_icon(),

Not your fault but I hate abbreviating like this... It's not
immediately clear what the variable refers to.

+        item.show()
+        self._invite_to_item[invite] = item

I'd /n here to make the two blocks separate.

+    def set_present(self, present):
+        self._present = present
+
+    present = gobject.property(type=bool, default=False, getter=is_present,
+                               setter=set_present)

I still think we should move away from GObject for non UI stuff :)

+            if service.startswith('org.freedesktop.Telepathy.Connection.'):
+                path = '/%s' % service.replace('.', '/')
+                Connection(service, path, bus,
+                           ready_handler=self.__connection_ready_cb)

I don't know enough about telepathy, but the path guessing here looks weird.

+        logging.debug('__got_dispatch_operation_cb')
+        dispatch_operation_path = kwargs['dispatch_operation_path']

Nitpicking again... In several places, I think it would be clearer to
separate the logging in its own block.

+        if connection_path == '/':
+            return

Why are we ignoring this? Unless it's obvious to someone that
understands telepathy, a comment would be useful here.

+        #self._start_listening()

Leftover?

+        if handle.invited:
+            wait_loop = gobject.MainLoop()
+            self._client_handler = _ClientHandler(
+                    self.get_bundle_id(),
+                    partial(self.__got_channel_cb, wait_loop))
+            # The current API requires that self.shared_activity is set before
+            # exiting from __init__, so we wait until we have got the shared
+            # activity.
+            wait_loop.run()

Ouch, quite an hack :) I'd open a bug and reference it here, it should
go away at some point.

+            # Cannot call datastore.write async for creates:
+            # https://dev.laptop.org/ticket/3071
+            datastore.write(self._jobject)

Update the bug reference to sugarlabs.org while you are changing this?

+        if handle.object_id is None and create_jobject:
+            logging.debug('Creating a jobject.')
+            self._jobject = datastore.create()
+            title = _('%s Activity') % get_bundle_name()
+            self._jobject.metadata['title'] = title
+            self.set_title(self._jobject.metadata['title'])
+            self._jobject.metadata['title_set_by_user'] = '0'
+            self._jobject.metadata['activity'] = self.get_bundle_id()
+            self._jobject.metadata['activity_id'] = self.get_id()
+            self._jobject.metadata['keep'] = '0'
+            self._jobject.metadata['preview'] = ''
+            self._jobject.metadata['share-scope'] = SCOPE_PRIVATE
+            if self.shared_activity is not None:
+                icon_color = self.shared_activity.props.color
+            else:
+                client = gconf.client_get_default()
+                icon_color = client.get_string('/desktop/sugar/user/color')
+            self._jobject.metadata['icon-color'] = icon_color

Separate blocks while you are at it :) It's really hard to read.

+++ b/src/sugar/presence/util.py

Maybe a more specific name for this module? connection or something...


More information about the Sugar-devel mailing list