diff --git a/shell/view/Shell.py b/shell/view/Shell.py index d2527d8f..812698fb 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -103,9 +103,6 @@ class Shell(gobject.GObject): def get_popup_context(self): return self._popup_context - def _join_success_cb(self, handler, activity, activity_ps): - activity.join(activity_ps.object_path()) - def _join_error_cb(self, handler, err, home_model): home_mode.notify_activity_launch_failed(handler.get_activity_id()) @@ -132,13 +129,9 @@ class Shell(gobject.GObject): handle.pservice_id = activity_id handler = activityfactory.create(act_type, handle) - handler.connect('success', self._join_success_cb, activity_ps) handler.connect('error', self._join_error_cb, home_model) - def _start_success_cb(self, handler, activity): - activity.start(handler.get_activity_id()) - - def _start_error_cb(self, handler, err, home_model, activity_id, activity_type): + def _start_error_cb(self, handler, err, home_model): home_model.notify_activity_launch_failed(handler.get_activity_id()) def start_activity(self, activity_type): @@ -150,7 +143,6 @@ class Shell(gobject.GObject): home_model.notify_activity_launch(handler.get_activity_id(), activity_type) - handler.connect('success', self._start_success_cb) handler.connect('error', self._start_error_cb, home_model) # Zoom to Home for launch feedback diff --git a/sugar/activity/activity.py b/sugar/activity/activity.py index befcc31f..3b7d9cec 100644 --- a/sugar/activity/activity.py +++ b/sugar/activity/activity.py @@ -26,16 +26,19 @@ from sugar import env class Activity(gtk.Window): """Base Activity class that all other Activities derive from.""" - def __init__(self, activity_handle): + def __init__(self, handle): gtk.Window.__init__(self) self.connect('destroy', self._destroy_cb) self._shared = False - self._activity_id = None - self._service = None + self._activity_id = handle.activity_id self._pservice = PresenceService.get_instance() + service = handle.get_presence_service() + if service: + self._join(service) + self.realize() group = gtk.Window() @@ -44,14 +47,6 @@ class Activity(gtk.Window): self._bus = ActivityService(self) - def start(self, activity_id): - """Start the activity.""" - if self._activity_id != None: - logging.warning('The activity has been already started.') - return - - self._activity_id = activity_id - self.present() def get_type(self): @@ -70,13 +65,8 @@ class Activity(gtk.Window): """Get the unique activity identifier.""" return self._activity_id - def join(self, activity_ps): - """Join an activity shared on the network.""" - if self._activity_id != None: - logging.warning('The activity has been already started.') - return - self._activity_id = activity_ps.get_id() - + def _join(self, service): + self._service = service self._shared = True # Publish the default service, it's a copy of @@ -103,10 +93,6 @@ class Activity(gtk.Window): self._service = self._pservice.share_activity(self, default_type) self._shared = True - def execute(self, command, args): - """Execute the given command with args""" - return False - def _destroy_cb(self, window): if self._bus: del self._bus diff --git a/sugar/activity/activityfactory.py b/sugar/activity/activityfactory.py index 61484662..90b49f71 100644 --- a/sugar/activity/activityfactory.py +++ b/sugar/activity/activityfactory.py @@ -36,14 +36,13 @@ class ActivityCreationHandler(gobject.GObject): 'error': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), - 'success': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, - ([gobject.TYPE_PYOBJECT])) } def __init__(self, service_name, activity_handle): gobject.GObject.__init__(self) + self._service_name = service_name + if activity_handle: self._activity_handle = activity_handle else: @@ -91,14 +90,12 @@ class ActivityCreationHandler(gobject.GObject): return act_id def _reply_handler(self, xid): - bus = dbus.SessionBus() - proxy_obj = bus.get_object(_ACTIVITY_SERVICE_NAME + '%d' % xid, - _ACTIVITY_SERVICE_PATH + "/%s" % xid) - activity = dbus.Interface(proxy_obj, _ACTIVITY_INTERFACE) - self.emit('success', activity) + logging.debug("Activity created %s (%s)." % + (self._activity_handle.activity_id, self._service_name)) def _error_handler(self, err): - logging.debug("Couldn't create activity: %s" % err) + logging.debug("Couldn't create activity %s (%s): %s" % + (self._activity_handle.activity_id, self._service_name, err)) self.emit('error', err) def create(service_name, activity_handle=None): diff --git a/sugar/activity/activityservice.py b/sugar/activity/activityservice.py index 5c1654aa..c5a99e08 100644 --- a/sugar/activity/activityservice.py +++ b/sugar/activity/activityservice.py @@ -40,18 +40,6 @@ class ActivityService(dbus.service.Object): dbus.service.Object.__init__(self, bus_name, object_path) self._activity = activity - self._pservice = PresenceService.get_instance() - - @dbus.service.method(_ACTIVITY_INTERFACE) - def start(self, activity_id): - """Start the activity in unshared mode.""" - self._activity.start(activity_id) - - @dbus.service.method(_ACTIVITY_INTERFACE) - def join(self, activity_ps_path): - """Join the activity specified by its presence service path.""" - activity_ps = self._pservice.get(activity_ps_path) - return self._activity.join(activity_ps) @dbus.service.method(_ACTIVITY_INTERFACE) def share(self): @@ -72,8 +60,3 @@ class ActivityService(dbus.service.Object): def get_shared(self): """Returns True if the activity is shared on the mesh.""" return self._activity.get_shared() - - @dbus.service.method(_ACTIVITY_INTERFACE, - in_signature="sas", out_signature="b") - def execute(self, command, args): - return self._activity.execute(command, args)