Remove activity services creation.

This commit is contained in:
Marco Pesenti Gritti 2007-10-09 12:22:20 +02:00
parent 177ee7220a
commit fc6ded013f
2 changed files with 0 additions and 82 deletions

View File

@ -44,38 +44,6 @@ def _load_mime_defaults():
return defaults return defaults
class _ServiceManager(object):
"""Internal class responsible for creating dbus service files
DBUS services are defined in files which bind a service name
to the name of an executable which provides the service name.
In Sugar, the service files are automatically generated from
the activity registry (by this class). When an activity's
dbus launch service is requested, dbus will launch the
specified executable in order to allow it to provide the
requested activity-launching service.
In the case of activities which provide a "class", instead of
an "exec" attribute in their activity.info, the
sugar-activity-factory script is used with an appropriate
argument to service that bundle.
"""
SERVICE_DIRECTORY = '~/.local/share/dbus-1/services'
def __init__(self):
service_dir = os.path.expanduser(self.SERVICE_DIRECTORY)
if not os.path.isdir(service_dir):
os.makedirs(service_dir)
self._path = service_dir
def add(self, bundle):
util.write_service(bundle.get_service_name(),
bundle.get_command(), self._path)
def remove(self, bundle):
util.delete_service(bundle.get_service_name(), self._path)
class BundleRegistry(gobject.GObject): class BundleRegistry(gobject.GObject):
"""Service that tracks the available activity bundles""" """Service that tracks the available activity bundles"""
@ -91,7 +59,6 @@ class BundleRegistry(gobject.GObject):
self._bundles = [] self._bundles = []
self._search_path = [] self._search_path = []
self._service_manager = _ServiceManager()
self._mime_defaults = _load_mime_defaults() self._mime_defaults = _load_mime_defaults()
def get_bundle(self, service_name): def get_bundle(self, service_name):
@ -134,7 +101,6 @@ class BundleRegistry(gobject.GObject):
return False return False
self._bundles.append(bundle) self._bundles.append(bundle)
self._service_manager.add(bundle)
self.emit('bundle-added', bundle) self.emit('bundle-added', bundle)
return True return True
@ -142,7 +108,6 @@ class BundleRegistry(gobject.GObject):
for bundle in self._bundles: for bundle in self._bundles:
if bundle.get_path() == bundle_path: if bundle.get_path() == bundle_path:
self._bundles.remove(bundle) self._bundles.remove(bundle)
self._service_manager.remove(bundle)
self.emit('bundle-removed', bundle) self.emit('bundle-removed', bundle)
return True return True
return False return False

View File

@ -73,53 +73,6 @@ def validate_activity_id(actid):
return False return False
return True return True
class _ServiceParser(ConfigParser):
def optionxform(self, option):
return option
def write_service(name, bin, path):
"""Write a D-BUS service definition file
These are written by the bundleregistry when
a new activity is registered. They bind a
D-BUS bus-name with an executable which is
to provide the named service.
name -- D-BUS service name, must be a valid
filename/D-BUS name
bin -- executable providing named service
path -- directory into which to write the
name.service file
The service files themselves are written using
the _ServiceParser class, which is a subclass
of the standard ConfigParser class.
"""
service_cp = _ServiceParser()
section = 'D-BUS Service'
service_cp.add_section(section)
service_cp.set(section, 'Name', name)
service_cp.set(section, 'Exec', bin)
dest_filename = os.path.join(path, name + '.service')
fileobject = open(dest_filename, 'w')
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): def set_proc_title(title):
"""Sets the process title so ps and top show more """Sets the process title so ps and top show more
descriptive names. This does not modify argv[0] descriptive names. This does not modify argv[0]