Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/activity
diff options
context:
space:
mode:
Diffstat (limited to 'sugar/activity')
-rw-r--r--sugar/activity/activityfactory.py7
-rw-r--r--sugar/activity/bundle.py14
-rw-r--r--sugar/activity/bundlebuilder.py3
-rw-r--r--sugar/activity/registry.py37
4 files changed, 41 insertions, 20 deletions
diff --git a/sugar/activity/activityfactory.py b/sugar/activity/activityfactory.py
index 404e5f4..b1d55eb 100644
--- a/sugar/activity/activityfactory.py
+++ b/sugar/activity/activityfactory.py
@@ -114,7 +114,7 @@ class ActivityCreationHandler(gobject.GObject):
self._factory.create(self._activity_handle.get_dict(),
timeout=120 * 1000,
- reply_handler=self._no_reply_handler,
+ reply_handler=self._create_reply_handler,
error_handler=self._create_error_handler)
def get_activity_id(self):
@@ -137,7 +137,10 @@ class ActivityCreationHandler(gobject.GObject):
def _activate_error_handler(self, err):
logging.debug("Activity activation request failed %s" % err)
- def _create_reply_handler(self, xid):
+ def _create_reply_handler(self, xid=None):
+ if xid is None:
+ self._create_error_handler('D-Bus error')
+ return
logging.debug("Activity created %s (%s)." %
(self._activity_handle.activity_id, self._service_name))
diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py
index a9c246d..d361c62 100644
--- a/sugar/activity/bundle.py
+++ b/sugar/activity/bundle.py
@@ -41,6 +41,7 @@ class NotInstalledException(Exception): pass
class InvalidPathException(Exception): pass
class ZipExtractException(Exception): pass
class RegistrationException(Exception): pass
+class MalformedBundleException(Exception): pass
class Bundle:
"""Metadata description of a given application/activity
@@ -265,10 +266,12 @@ class Bundle:
if not bundle_root_dir:
bundle_root_dir = file_name.split('/')[0]
if not bundle_root_dir.endswith('.activity'):
- raise 'Incorrect bundle.'
+ raise MalformedBundleException(
+ 'The activity directory name must end with .activity')
else:
if not file_name.startswith(bundle_root_dir):
- raise 'Incorrect bundle.'
+ raise MalformedBundleException(
+ 'All files in the bundle must be inside the activity directory')
return bundle_root_dir
@@ -293,11 +296,8 @@ class Bundle:
raise ZipExtractException
self._init_with_path(bundle_path)
-
- bus = dbus.SessionBus()
- proxy_obj = bus.get_object(_DBUS_SHELL_SERVICE, _DBUS_SHELL_PATH)
- dbus_service = dbus.Interface(proxy_obj, _DBUS_ACTIVITY_REGISTRY_IFACE)
- if not dbus_service.AddBundle(bundle_path):
+
+ if not activity.get_registry().add_bundle(bundle_path):
raise RegistrationException
def deinstall(self):
diff --git a/sugar/activity/bundlebuilder.py b/sugar/activity/bundlebuilder.py
index b255cfb..3bbe454 100644
--- a/sugar/activity/bundlebuilder.py
+++ b/sugar/activity/bundlebuilder.py
@@ -162,8 +162,7 @@ def _get_mo_list(manifest):
for lang in _get_po_list(manifest).keys():
filename = _get_service_name() + '.mo'
- mo_list.append(os.path.join(_get_source_path(), 'locale',
- lang, 'LC_MESSAGES', filename))
+ mo_list.append(os.path.join('locale', lang, 'LC_MESSAGES', filename))
return mo_list
diff --git a/sugar/activity/registry.py b/sugar/activity/registry.py
index b19abee..1483a78 100644
--- a/sugar/activity/registry.py
+++ b/sugar/activity/registry.py
@@ -1,4 +1,5 @@
# Copyright (C) 2006-2007 Red Hat, Inc.
+# Copyright (C) 2007 One Laptop Per Child
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -18,29 +19,39 @@
import logging
import dbus
+import gobject
-_SHELL_SERVICE = "org.laptop.Shell"
-_SHELL_PATH = "/org/laptop/Shell"
-_REGISTRY_IFACE = "org.laptop.Shell.ActivityRegistry"
+_ACTIVITY_REGISTRY_SERVICE_NAME = 'org.laptop.ActivityRegistry'
+_ACTIVITY_REGISTRY_IFACE = 'org.laptop.ActivityRegistry'
+_ACTIVITY_REGISTRY_PATH = '/org/laptop/ActivityRegistry'
def _activity_info_from_dict(info_dict):
if not info_dict:
return None
return ActivityInfo(info_dict['name'], info_dict['icon'],
- info_dict['service_name'], info_dict['path'])
+ info_dict['service_name'], info_dict['path'],
+ info_dict['show_launcher'])
class ActivityInfo(object):
- def __init__(self, name, icon, service_name, path):
+ def __init__(self, name, icon, service_name, path, show_launcher):
self.name = name
self.icon = icon
self.service_name = service_name
self.path = path
+ self.show_launcher = show_launcher
-class ActivityRegistry(object):
+class ActivityRegistry(gobject.GObject):
+ __gsignals__ = {
+ 'activity-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT]))
+ }
def __init__(self):
+ gobject.GObject.__init__(self)
+
bus = dbus.SessionBus()
- bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH)
- self._registry = dbus.Interface(bus_object, _REGISTRY_IFACE)
+ bus_object = bus.get_object(_ACTIVITY_REGISTRY_SERVICE_NAME,
+ _ACTIVITY_REGISTRY_PATH)
+ self._registry = dbus.Interface(bus_object, _ACTIVITY_REGISTRY_IFACE)
self._registry.connect_to_signal('ActivityAdded', self._activity_added_cb)
# Two caches fo saving some travel across dbus.
@@ -55,6 +66,10 @@ class ActivityRegistry(object):
return result
+ def get_activities(self):
+ info_list = self._registry.GetActivities()
+ return self._convert_info_list(info_list)
+
def get_activity(self, service_name):
if self._service_name_to_activity_info.has_key(service_name):
return self._service_name_to_activity_info[service_name]
@@ -79,10 +94,14 @@ class ActivityRegistry(object):
self._mime_type_to_activities[mime_type] = activities
return activities
- def _activity_added_cb(self, bundle):
+ def add_bundle(self, bundle_path):
+ return self._registry.AddBundle(bundle_path)
+
+ def _activity_added_cb(self, info_dict):
logging.debug('ActivityRegistry._activity_added_cb: flushing caches')
self._service_name_to_activity_info.clear()
self._mime_type_to_activities.clear()
+ self.emit('activity-added', _activity_info_from_dict(info_dict))
_registry = None