From 2bcbde6e441ee5ab5743f6b45b5f85e85bbb644f Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 04 Oct 2007 19:59:23 +0000 Subject: Add bundle removing methods/signals to the activity registry, and use them --- (limited to 'sugar') diff --git a/sugar/activity/registry.py b/sugar/activity/registry.py index 39c2b3c..8b1d440 100644 --- a/sugar/activity/registry.py +++ b/sugar/activity/registry.py @@ -43,6 +43,8 @@ class ActivityInfo(object): class ActivityRegistry(gobject.GObject): __gsignals__ = { 'activity-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])), + 'activity-removed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])) } def __init__(self): @@ -60,6 +62,7 @@ class ActivityRegistry(gobject.GObject): follow_name_owner_changes = True) self._registry = dbus.Interface(bus_object, _ACTIVITY_REGISTRY_IFACE) self._registry.connect_to_signal('ActivityAdded', self._activity_added_cb) + self._registry.connect_to_signal('ActivityRemoved', self._activity_removed_cb) # Two caches fo saving some travel across dbus. self._service_name_to_activity_info = {} @@ -133,6 +136,15 @@ class ActivityRegistry(gobject.GObject): self._mime_type_to_activities.clear() self.emit('activity-added', _activity_info_from_dict(info_dict)) + def remove_bundle(self, bundle_path): + return self._registry.RemoveBundle(bundle_path) + + def _activity_removed_cb(self, info_dict): + logging.debug('ActivityRegistry._activity_removed_cb: flushing caches') + self._service_name_to_activity_info.clear() + self._mime_type_to_activities.clear() + self.emit('activity-removed', _activity_info_from_dict(info_dict)) + _registry = None def get_registry(): diff --git a/sugar/bundle/activitybundle.py b/sugar/bundle/activitybundle.py index d13f93c..0d5a5b4 100644 --- a/sugar/bundle/activitybundle.py +++ b/sugar/bundle/activitybundle.py @@ -280,6 +280,7 @@ class ActivityBundle(Bundle): os.remove(path) self._uninstall(install_path) - - # FIXME: notify shell + + if not activity.get_registry().remove_bundle(install_path): + raise RegistrationException diff --git a/sugar/util.py b/sugar/util.py index 5f01848..2780427 100644 --- a/sugar/util.py +++ b/sugar/util.py @@ -106,6 +106,20 @@ def write_service(name, bin, path): service_cp.write(fileobject) fileobject.close() +def delete_service(name, path): + """Delete a D-BUS service definition file + + Deletes a D-BUS service file previously + created by write_service(). + + name -- D-BUS service name, must be a valid + filename/D-BUS name + path -- directory containing the name.service + file + """ + + os.remove(os.path.join(path, name + '.service')) + def set_proc_title(title): """Sets the process title so ps and top show more descriptive names. This does not modify argv[0] -- cgit v0.9.1