Rename activity service_name to bundle_id

This commit is contained in:
Marco Pesenti Gritti 2007-10-09 13:15:06 +02:00
parent 57961d17bc
commit 6073a396b3
16 changed files with 62 additions and 50 deletions

View File

@ -46,8 +46,11 @@ def create_activity_instance(constructor, handle):
activity_instances.append(activity) activity_instances.append(activity)
def get_single_process_path(service_name): def get_single_process_name(bundle_id):
return '/' + service_name.replace('.', '/') return bundle_id
def get_single_process_path(bundle_id):
return '/' + bundle_id.replace('.', '/')
class SingleProcess(dbus.service.Object): class SingleProcess(dbus.service.Object):
def __init__(self, service_name, constructor): def __init__(self, service_name, constructor):
@ -64,6 +67,8 @@ class SingleProcess(dbus.service.Object):
create_activity_instance(self.constructor, handle) create_activity_instance(self.constructor, handle)
parser = OptionParser() parser = OptionParser()
parser.add_option("-b", "--bundle-id", dest="bundle_id",
help="identifier of the activity bundle")
parser.add_option("-a", "--activity-id", dest="activity_id", parser.add_option("-a", "--activity-id", dest="activity_id",
help="identifier of the activity instance") help="identifier of the activity instance")
parser.add_option("-o", "--object-id", dest="object_id", parser.add_option("-o", "--object-id", dest="object_id",
@ -88,15 +93,15 @@ sys.path.append(bundle_path)
bundle = ActivityBundle(bundle_path) bundle = ActivityBundle(bundle_path)
logger.start(bundle.get_service_name()) logger.start(bundle.get_bundle_id())
gettext.bindtextdomain(bundle.get_service_name(), gettext.bindtextdomain(bundle.get_bundle_id(),
bundle.get_locale_path()) bundle.get_locale_path())
gettext.textdomain(bundle.get_service_name()) gettext.textdomain(bundle.get_bundle_id())
gtk.icon_theme_get_default().append_search_path(bundle.get_icons_path()) gtk.icon_theme_get_default().append_search_path(bundle.get_icons_path())
_sugarext.set_prgname(bundle.get_service_name()) _sugarext.set_prgname(bundle.get_bundle_id())
_sugarext.set_application_name(bundle.get_name()) _sugarext.set_application_name(bundle.get_name())
splitted_module = args[0].rsplit('.', 1) splitted_module = args[0].rsplit('.', 1)
@ -116,7 +121,10 @@ handle = activityhandle.ActivityHandle(
if options.single_process is True: if options.single_process is True:
bus = dbus.SessionBus() bus = dbus.SessionBus()
service_name = bundle.get_service_name()
bundle_id = bundle.get_bundle_id()
service_name = get_single_process_name(bundle_id)
service_path = get_single_process_path(bundle_id)
bus_object = bus.get_object( bus_object = bus.get_object(
'org.freedesktop.DBus', '/org/freedesktop/DBus') 'org.freedesktop.DBus', '/org/freedesktop/DBus')
@ -129,8 +137,7 @@ if options.single_process is True:
if not name: if not name:
service = SingleProcess(service_name, constructor) service = SingleProcess(service_name, constructor)
else: else:
single_process = bus.get_object( single_process = bus.get_object(service_name, service_path)
service_name, get_single_process_path(service_name))
single_process.create(handle.get_dict()) single_process.create(handle.get_dict())
print 'Created %s in a single process.' % service_name print 'Created %s in a single process.' % service_name

View File

@ -70,9 +70,9 @@ class ActivityRegistry(dbus.service.Object):
@dbus.service.method(_ACTIVITY_REGISTRY_IFACE, @dbus.service.method(_ACTIVITY_REGISTRY_IFACE,
in_signature='s', out_signature='a{sv}') in_signature='s', out_signature='a{sv}')
def GetActivity(self, service_name): def GetActivity(self, bundle_id):
registry = bundleregistry.get_registry() registry = bundleregistry.get_registry()
bundle = registry.get_bundle(service_name) bundle = registry.get_bundle(bundle_id)
if not bundle: if not bundle:
return {} return {}
@ -86,8 +86,8 @@ class ActivityRegistry(dbus.service.Object):
for bundle in bundleregistry.get_registry(): for bundle in bundleregistry.get_registry():
name = bundle.get_name().lower() name = bundle.get_name().lower()
service_name = bundle.get_service_name().lower() bundle_id = bundle.get_bundle_id().lower()
if name.find(key) != -1 or service_name.find(key) != -1: if name.find(key) != -1 or bundle_id.find(key) != -1:
result.append(self._bundle_to_dict(bundle)) result.append(self._bundle_to_dict(bundle))
return result return result
@ -112,7 +112,7 @@ class ActivityRegistry(dbus.service.Object):
def _bundle_to_dict(self, bundle): def _bundle_to_dict(self, bundle):
return {'name': bundle.get_name(), return {'name': bundle.get_name(),
'icon': bundle.get_icon(), 'icon': bundle.get_icon(),
'service_name': bundle.get_service_name(), 'bundle_id': bundle.get_bundle_id(),
'path': bundle.get_path(), 'path': bundle.get_path(),
'command': bundle.get_command(), 'command': bundle.get_command(),
'show_launcher': bundle.get_show_launcher()} 'show_launcher': bundle.get_show_launcher()}

View File

@ -61,10 +61,10 @@ class BundleRegistry(gobject.GObject):
self._search_path = [] self._search_path = []
self._mime_defaults = _load_mime_defaults() self._mime_defaults = _load_mime_defaults()
def get_bundle(self, service_name): def get_bundle(self, bundle_id):
"""Returns an bundle given his service name""" """Returns an bundle given his service name"""
for bundle in self._bundles: for bundle in self._bundles:
if bundle.get_service_name() == service_name: if bundle.get_bundle_id() == bundle_id:
return bundle return bundle
return None return None
@ -116,7 +116,7 @@ class BundleRegistry(gobject.GObject):
result = [] result = []
for bundle in self._bundles: for bundle in self._bundles:
if bundle.get_mime_types() and mime_type in bundle.get_mime_types(): if bundle.get_mime_types() and mime_type in bundle.get_mime_types():
if self.get_default_for_type(mime_type) == bundle.get_service_name(): if self.get_default_for_type(mime_type) == bundle.get_bundle_id():
result.insert(0, bundle) result.insert(0, bundle)
else: else:
result.append(bundle) result.append(bundle)

View File

@ -73,7 +73,7 @@ class ClipboardObject:
registry = bundleregistry.get_registry() registry = bundleregistry.get_registry()
activities = registry.get_activities_for_type(self.get_mime_type()) activities = registry.get_activities_for_type(self.get_mime_type())
if activities: if activities:
return [activity.get_service_name() for activity in activities] return [activity.get_bundle_id() for activity in activities]
else: else:
return '' return ''

View File

@ -39,8 +39,8 @@ class ActivityModel:
def get_color(self): def get_color(self):
return XoColor(self.activity.props.color) return XoColor(self.activity.props.color)
def get_service_name(self): def get_bundle_id(self):
return self.bundle.service_name return self.bundle.bundle_id
class MeshModel(gobject.GObject): class MeshModel(gobject.GObject):
__gsignals__ = { __gsignals__ = {

View File

@ -156,9 +156,9 @@ class HomeActivity(gobject.GObject):
return self._window return self._window
def get_type(self): def get_type(self):
"""Retrieve activity_info's "service_name" for future reference""" """Retrieve the activity bundle id for future reference"""
if self._activity_info: if self._activity_info:
return self._activity_info.service_name return self._activity_info.bundle_id
else: else:
return None return None

View File

@ -91,9 +91,9 @@ class ActivitiesTray(hippo.CanvasBox):
while activity_list: while activity_list:
info = activity_list.pop() info = activity_list.pop()
name_to_activity[info.service_name] = info name_to_activity[info.bundle_id] = info
if info.service_name in self._config: if info.bundle_id in self._config:
known_activities.append(info) known_activities.append(info)
else: else:
unknown_activities.append(info) unknown_activities.append(info)

View File

@ -47,7 +47,7 @@ class ActivityButton(TrayButton, gobject.GObject):
self.setup_rollover_options() self.setup_rollover_options()
def get_bundle_id(self): def get_bundle_id(self):
return self._activity_info.service_name return self._activity_info.bundle_id
def setup_rollover_options(self): def setup_rollover_options(self):
palette = Palette(self._activity_info.name) palette = Palette(self._activity_info.name)

View File

@ -274,7 +274,7 @@ class ActivityView(hippo.CanvasBox):
del self._icons[key] del self._icons[key]
def _clicked_cb(self, item): def _clicked_cb(self, item):
bundle_id = self._model.get_service_name() bundle_id = self._model.get_bundle_id()
self._shell.join_activity(bundle_id, self._model.get_id()) self._shell.join_activity(bundle_id, self._model.get_id())
class MeshBox(hippo.CanvasBox): class MeshBox(hippo.CanvasBox):

View File

@ -299,7 +299,7 @@ class Activity(Window, gtk.Container):
self._jobject.metadata['title'] = _('%s Activity') % get_bundle_name() self._jobject.metadata['title'] = _('%s Activity') % get_bundle_name()
self.set_title(self._jobject.metadata['title']) self.set_title(self._jobject.metadata['title'])
self._jobject.metadata['title_set_by_user'] = '0' self._jobject.metadata['title_set_by_user'] = '0'
self._jobject.metadata['activity'] = self.get_service_name() self._jobject.metadata['activity'] = self.get_bundle_id()
self._jobject.metadata['activity_id'] = self.get_id() self._jobject.metadata['activity_id'] = self.get_id()
self._jobject.metadata['keep'] = '0' self._jobject.metadata['keep'] = '0'
self._jobject.metadata['preview'] = '' self._jobject.metadata['preview'] = ''
@ -362,7 +362,7 @@ class Activity(Window, gtk.Container):
def get_id(self): def get_id(self):
return self._activity_id return self._activity_id
def get_service_name(self): def get_bundle_id(self):
return _sugarext.get_prgname() return _sugarext.get_prgname()
def set_canvas(self, canvas): def set_canvas(self, canvas):
@ -594,7 +594,7 @@ class Activity(Window, gtk.Container):
self._pservice.share_activity(self, private=private) self._pservice.share_activity(self, private=private)
def _realize_cb(self, window): def _realize_cb(self, window):
wm.set_bundle_id(window.window, self.get_service_name()) wm.set_bundle_id(window.window, self.get_bundle_id())
wm.set_activity_id(window.window, self._activity_id) wm.set_activity_id(window.window, self._activity_id)
def _delete_event_cb(self, window, event): def _delete_event_cb(self, window, event):

View File

@ -158,6 +158,7 @@ class ActivityCreationHandler(gobject.GObject):
env['PATH'] = bin_path + ':' + env['PATH'] env['PATH'] = bin_path + ':' + env['PATH']
command = activity.command command = activity.command
command += ' -b %s' % activity.bundle_id
if self._handle.activity_id is not None: if self._handle.activity_id is not None:
command += ' -a %s' % self._handle.activity_id command += ' -a %s' % self._handle.activity_id
if self._handle.object_id is not None: if self._handle.object_id is not None:
@ -165,7 +166,8 @@ class ActivityCreationHandler(gobject.GObject):
if self._handle.uri is not None: if self._handle.uri is not None:
command += ' -u %s' % self._handle.uri command += ' -u %s' % self._handle.uri
process = subprocess.Popen(command, env=env, shell=True) process = subprocess.Popen(command, env=env, shell=True,
cwd=activity.path)
else: else:
system_bus = dbus.SystemBus() system_bus = dbus.SystemBus()
factory = system_bus.get_object(_RAINBOW_SERVICE_NAME, factory = system_bus.get_object(_RAINBOW_SERVICE_NAME,

View File

@ -107,9 +107,9 @@ def _delete_backups(arg, dirname, names):
if name.endswith('~') or name.endswith('pyc'): if name.endswith('~') or name.endswith('pyc'):
os.remove(os.path.join(dirname, name)) os.remove(os.path.join(dirname, name))
def _get_service_name(): def _get_bundle_id():
bundle = ActivityBundle(_get_source_path()) bundle = ActivityBundle(_get_source_path())
return bundle.get_service_name() return bundle.get_bundle_id()
def cmd_help(): def cmd_help():
print 'Usage: \n\ print 'Usage: \n\
@ -162,7 +162,7 @@ def _get_l10n_list(manifest):
l10n_list = [] l10n_list = []
for lang in _get_po_list(manifest).keys(): for lang in _get_po_list(manifest).keys():
filename = _get_service_name() + '.mo' filename = _get_bundle_id() + '.mo'
l10n_list.append(os.path.join('locale', lang, 'LC_MESSAGES', filename)) l10n_list.append(os.path.join('locale', lang, 'LC_MESSAGES', filename))
l10n_list.append(os.path.join('locale', lang, 'activity.linfo')) l10n_list.append(os.path.join('locale', lang, 'activity.linfo'))
@ -256,7 +256,7 @@ def cmd_genl10n(bundle_name, manifest):
if not os.path.isdir(mo_path): if not os.path.isdir(mo_path):
os.makedirs(mo_path) os.makedirs(mo_path)
mo_file = os.path.join(mo_path, "%s.mo" % _get_service_name()) mo_file = os.path.join(mo_path, "%s.mo" % _get_bundle_id())
args = ["msgfmt", "--output-file=%s" % mo_file, file_name] args = ["msgfmt", "--output-file=%s" % mo_file, file_name]
retcode = subprocess.call(args) retcode = subprocess.call(args)
if retcode: if retcode:

View File

@ -29,15 +29,15 @@ def _activity_info_from_dict(info_dict):
if not info_dict: if not info_dict:
return None return None
return ActivityInfo(info_dict['name'], info_dict['icon'], return ActivityInfo(info_dict['name'], info_dict['icon'],
info_dict['service_name'], info_dict['path'], info_dict['bundle_id'], info_dict['path'],
info_dict['show_launcher'], info_dict['command']) info_dict['show_launcher'], info_dict['command'])
class ActivityInfo(object): class ActivityInfo(object):
def __init__(self, name, icon, service_name, def __init__(self, name, icon, bundle_id,
path, show_launcher, command): path, show_launcher, command):
self.name = name self.name = name
self.icon = icon self.icon = icon
self.service_name = service_name self.bundle_id = bundle_id
self.path = path self.path = path
self.command = command self.command = command
self.show_launcher = show_launcher self.show_launcher = show_launcher

View File

@ -46,7 +46,7 @@ class ActivityBundle(Bundle):
self._name = None self._name = None
self._icon = None self._icon = None
self._service_name = None self._bundle_id = None
self._mime_types = None self._mime_types = None
self._show_launcher = True self._show_launcher = True
self._activity_version = 0 self._activity_version = 0
@ -66,11 +66,14 @@ class ActivityBundle(Bundle):
section = 'Activity' section = 'Activity'
if cp.has_option(section, 'service_name'): if cp.has_option(section, 'bundle_id'):
self._service_name = cp.get(section, 'service_name') self._bundle_id = cp.get(section, 'bundle_id')
# FIXME deprecated
elif cp.has_option(section, 'service_name'):
self._bundle_id = cp.get(section, 'service_name')
else: else:
raise MalformedBundleException( raise MalformedBundleException(
'Activity bundle %s does not specify a service name' % 'Activity bundle %s does not specify a bundle id' %
self._path) self._path)
if cp.has_option(section, 'name'): if cp.has_option(section, 'name'):
@ -155,9 +158,9 @@ class ActivityBundle(Bundle):
"""Get the activity user visible name.""" """Get the activity user visible name."""
return self._name return self._name
def get_service_name(self): def get_bundle_id(self):
"""Get the activity service name""" """Get the activity bundle id"""
return self._service_name return self._bundle_id
# FIXME: this should return the icon data, not a filename, so that # FIXME: this should return the icon data, not a filename, so that
# we don't need to create a temp file in the zip case # we don't need to create a temp file in the zip case
@ -196,7 +199,7 @@ class ActivityBundle(Bundle):
return self._show_launcher return self._show_launcher
def is_installed(self): def is_installed(self):
if activity.get_registry().get_activity(self._service_name): if activity.get_registry().get_activity(self._bundle_id):
return True return True
else: else:
return False return False
@ -218,7 +221,7 @@ class ActivityBundle(Bundle):
mime_pkg_dir = os.path.join(mime_dir, 'packages') mime_pkg_dir = os.path.join(mime_dir, 'packages')
if not os.path.isdir(mime_pkg_dir): if not os.path.isdir(mime_pkg_dir):
os.makedirs(mime_pkg_dir) os.makedirs(mime_pkg_dir)
installed_mime_path = os.path.join(mime_pkg_dir, '%s.xml' % self._service_name) installed_mime_path = os.path.join(mime_pkg_dir, '%s.xml' % self._bundle_id)
os.symlink(mime_path, installed_mime_path) os.symlink(mime_path, installed_mime_path)
os.spawnlp(os.P_WAIT, 'update-mime-database', os.spawnlp(os.P_WAIT, 'update-mime-database',
'update-mime-database', mime_dir) 'update-mime-database', mime_dir)
@ -259,7 +262,7 @@ class ActivityBundle(Bundle):
xdg_data_home = os.getenv('XDG_DATA_HOME', os.path.expanduser('~/.local/share')) xdg_data_home = os.getenv('XDG_DATA_HOME', os.path.expanduser('~/.local/share'))
mime_dir = os.path.join(xdg_data_home, 'mime') mime_dir = os.path.join(xdg_data_home, 'mime')
installed_mime_path = os.path.join(mime_dir, 'packages', '%s.xml' % self._service_name) installed_mime_path = os.path.join(mime_dir, 'packages', '%s.xml' % self._bundle_id)
if os.path.exists(installed_mime_path): if os.path.exists(installed_mime_path):
os.remove(installed_mime_path) os.remove(installed_mime_path)
os.spawnlp(os.P_WAIT, 'update-mime-database', os.spawnlp(os.P_WAIT, 'update-mime-database',

View File

@ -129,7 +129,7 @@ class DSObject(object):
if mime_type: if mime_type:
activities_info = activity.get_registry().get_activities_for_type(mime_type) activities_info = activity.get_registry().get_activities_for_type(mime_type)
for activity_info in activities_info: for activity_info in activities_info:
if activity_info.service_name != self.metadata['activity']: if activity_info.bundle_id != self.metadata['activity']:
activities.append(activity_info) activities.append(activity_info)
return activities return activities
@ -155,7 +155,7 @@ class DSObject(object):
if not bundle.is_installed(): if not bundle.is_installed():
bundle.install() bundle.install()
activityfactory.create(bundle.get_service_name()) activityfactory.create(bundle.get_bundle_id())
else: else:
if not self.get_activities() and service_name is None: if not self.get_activities() and service_name is None:
logging.warning('No activity can open this object.') logging.warning('No activity can open this object.')

View File

@ -467,7 +467,7 @@ class PresenceService(gobject.GObject):
raise RuntimeError("Activity %s is already shared." % raise RuntimeError("Activity %s is already shared." %
actid) actid)
atype = activity.get_service_name() atype = activity.get_bundle_id()
name = activity.props.title name = activity.props.title
self._ps.ShareActivity(actid, atype, name, properties, self._ps.ShareActivity(actid, atype, name, properties,
reply_handler=lambda op: \ reply_handler=lambda op: \