Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
Diffstat (limited to 'sugar')
-rw-r--r--sugar/activity/Activity.py12
-rw-r--r--sugar/activity/ActivityFactory.py45
2 files changed, 38 insertions, 19 deletions
diff --git a/sugar/activity/Activity.py b/sugar/activity/Activity.py
index c0023ab..7926dae 100644
--- a/sugar/activity/Activity.py
+++ b/sugar/activity/Activity.py
@@ -62,9 +62,9 @@ class ActivityDbusService(dbus.service.Object):
self._pservice = PresenceService.get_instance()
@dbus.service.method(ACTIVITY_INTERFACE)
- def start(self):
- """Start the activity."""
- self._activity.start()
+ 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):
@@ -120,13 +120,13 @@ class Activity(gtk.Window):
self._bus = ActivityDbusService(self)
- def start(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 = sugar.util.unique_id()
+ self._activity_id = activity_id
#ds = datastore.get_instance()
#self._journal_object = ds.create('', {}, self._activity_id)
@@ -162,9 +162,9 @@ class Activity(gtk.Window):
if self._activity_id != None:
logging.warning('The activity has been already started.')
return
+ self._activity_id = activity_ps.get_id()
self._shared = True
- self._activity_id = activity_ps.get_id()
# Publish the default service, it's a copy of
# one of those we found on the network.
diff --git a/sugar/activity/ActivityFactory.py b/sugar/activity/ActivityFactory.py
index 481c5b9..94e765e 100644
--- a/sugar/activity/ActivityFactory.py
+++ b/sugar/activity/ActivityFactory.py
@@ -76,24 +76,43 @@ class ActivityFactory(dbus.service.Object):
if len(self._activities) == 0:
gtk.main_quit()
-def create(activity_name):
- """Create a new activity from his name."""
- bus = dbus.SessionBus()
+class ActivityCreationHandler(gobject.GObject):
+
+ __gsignals__ = {
+ 'error': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT])),
+ 'success': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT]))
+ }
- factory_name = activity_name
- factory_path = get_path(factory_name)
+ def __init__(self, activity_name):
+ gobject.GObject.__init__(self)
- proxy_obj = bus.get_object(factory_name, factory_path)
- factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
+ bus = dbus.SessionBus()
+ factory_name = activity_name
+ factory_path = get_path(factory_name)
- xid = factory.create()
+ proxy_obj = bus.get_object(factory_name, factory_path)
+ factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
- bus = dbus.SessionBus()
- proxy_obj = bus.get_object(Activity.get_service_name(xid),
- Activity.get_object_path(xid))
- activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
+ factory.create(reply_handler=self._reply_handler, error_handler=self._error_handler)
- return activity
+ def _reply_handler(self, xid):
+ bus = dbus.SessionBus()
+ proxy_obj = bus.get_object(Activity.get_service_name(xid),
+ Activity.get_object_path(xid))
+ activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
+ self.emit('success', activity)
+
+ def _error_handler(self, err):
+ logging.debug("Couldn't create activity: %s" % err)
+ self.emit('error', err)
+
+def create(activity_name):
+ """Create a new activity from its name."""
+ return ActivityCreationHandler(activity_name)
def start_factory(activity_class, bundle_path):
"""Start the activity factory."""