Rename activity service_name to bundle_id

master
Marco Pesenti Gritti 17 years ago
parent 57961d17bc
commit 6073a396b3

@ -46,8 +46,11 @@ def create_activity_instance(constructor, handle):
activity_instances.append(activity)
def get_single_process_path(service_name):
return '/' + service_name.replace('.', '/')
def get_single_process_name(bundle_id):
return bundle_id
def get_single_process_path(bundle_id):
return '/' + bundle_id.replace('.', '/')
class SingleProcess(dbus.service.Object):
def __init__(self, service_name, constructor):
@ -64,6 +67,8 @@ class SingleProcess(dbus.service.Object):
create_activity_instance(self.constructor, handle)
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",
help="identifier of the activity instance")
parser.add_option("-o", "--object-id", dest="object_id",
@ -88,15 +93,15 @@ sys.path.append(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())
gettext.textdomain(bundle.get_service_name())
gettext.textdomain(bundle.get_bundle_id())
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())
splitted_module = args[0].rsplit('.', 1)
@ -116,7 +121,10 @@ handle = activityhandle.ActivityHandle(
if options.single_process is True:
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(
'org.freedesktop.DBus', '/org/freedesktop/DBus')
@ -129,8 +137,7 @@ if options.single_process is True:
if not name:
service = SingleProcess(service_name, constructor)
else:
single_process = bus.get_object(
service_name, get_single_process_path(service_name))
single_process = bus.get_object(service_name, service_path)
single_process.create(handle.get_dict())
print 'Created %s in a single process.' % service_name

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

@ -61,10 +61,10 @@ class BundleRegistry(gobject.GObject):
self._search_path = []
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"""
for bundle in self._bundles:
if bundle.get_service_name() == service_name:
if bundle.get_bundle_id() == bundle_id:
return bundle
return None
@ -116,7 +116,7 @@ class BundleRegistry(gobject.GObject):
result = []
for bundle in self._bundles:
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)
else:
result.append(bundle)

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

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

@ -156,9 +156,9 @@ class HomeActivity(gobject.GObject):
return self._window
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:
return self._activity_info.service_name
return self._activity_info.bundle_id
else:
return None

@ -91,9 +91,9 @@ class ActivitiesTray(hippo.CanvasBox):
while activity_list:
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)
else:
unknown_activities.append(info)

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

@ -274,7 +274,7 @@ class ActivityView(hippo.CanvasBox):
del self._icons[key]
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())
class MeshBox(hippo.CanvasBox):

@ -299,7 +299,7 @@ class Activity(Window, gtk.Container):
self._jobject.metadata['title'] = _('%s Activity') % get_bundle_name()
self.set_title(self._jobject.metadata['title'])
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['keep'] = '0'
self._jobject.metadata['preview'] = ''
@ -362,7 +362,7 @@ class Activity(Window, gtk.Container):
def get_id(self):
return self._activity_id
def get_service_name(self):
def get_bundle_id(self):
return _sugarext.get_prgname()
def set_canvas(self, canvas):
@ -594,7 +594,7 @@ class Activity(Window, gtk.Container):
self._pservice.share_activity(self, private=private)
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)
def _delete_event_cb(self, window, event):

@ -158,6 +158,7 @@ class ActivityCreationHandler(gobject.GObject):
env['PATH'] = bin_path + ':' + env['PATH']
command = activity.command
command += ' -b %s' % activity.bundle_id
if self._handle.activity_id is not None:
command += ' -a %s' % self._handle.activity_id
if self._handle.object_id is not None:
@ -165,7 +166,8 @@ class ActivityCreationHandler(gobject.GObject):
if self._handle.uri is not None:
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:
system_bus = dbus.SystemBus()
factory = system_bus.get_object(_RAINBOW_SERVICE_NAME,

@ -107,9 +107,9 @@ def _delete_backups(arg, dirname, names):
if name.endswith('~') or name.endswith('pyc'):
os.remove(os.path.join(dirname, name))
def _get_service_name():
def _get_bundle_id():
bundle = ActivityBundle(_get_source_path())
return bundle.get_service_name()
return bundle.get_bundle_id()
def cmd_help():
print 'Usage: \n\
@ -162,7 +162,7 @@ def _get_l10n_list(manifest):
l10n_list = []
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, 'activity.linfo'))
@ -256,7 +256,7 @@ def cmd_genl10n(bundle_name, manifest):
if not os.path.isdir(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]
retcode = subprocess.call(args)
if retcode:

@ -29,15 +29,15 @@ 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['bundle_id'], info_dict['path'],
info_dict['show_launcher'], info_dict['command'])
class ActivityInfo(object):
def __init__(self, name, icon, service_name,
def __init__(self, name, icon, bundle_id,
path, show_launcher, command):
self.name = name
self.icon = icon
self.service_name = service_name
self.bundle_id = bundle_id
self.path = path
self.command = command
self.show_launcher = show_launcher

@ -46,7 +46,7 @@ class ActivityBundle(Bundle):
self._name = None
self._icon = None
self._service_name = None
self._bundle_id = None
self._mime_types = None
self._show_launcher = True
self._activity_version = 0
@ -66,11 +66,14 @@ class ActivityBundle(Bundle):
section = 'Activity'
if cp.has_option(section, 'service_name'):
self._service_name = cp.get(section, 'service_name')
if cp.has_option(section, 'bundle_id'):
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:
raise MalformedBundleException(
'Activity bundle %s does not specify a service name' %
'Activity bundle %s does not specify a bundle id' %
self._path)
if cp.has_option(section, 'name'):
@ -155,9 +158,9 @@ class ActivityBundle(Bundle):
"""Get the activity user visible name."""
return self._name
def get_service_name(self):
"""Get the activity service name"""
return self._service_name
def get_bundle_id(self):
"""Get the activity bundle id"""
return self._bundle_id
# 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
@ -196,7 +199,7 @@ class ActivityBundle(Bundle):
return self._show_launcher
def is_installed(self):
if activity.get_registry().get_activity(self._service_name):
if activity.get_registry().get_activity(self._bundle_id):
return True
else:
return False
@ -218,7 +221,7 @@ class ActivityBundle(Bundle):
mime_pkg_dir = os.path.join(mime_dir, 'packages')
if not os.path.isdir(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.spawnlp(os.P_WAIT, 'update-mime-database',
'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'))
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):
os.remove(installed_mime_path)
os.spawnlp(os.P_WAIT, 'update-mime-database',

@ -129,7 +129,7 @@ class DSObject(object):
if mime_type:
activities_info = activity.get_registry().get_activities_for_type(mime_type)
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)
return activities
@ -155,7 +155,7 @@ class DSObject(object):
if not bundle.is_installed():
bundle.install()
activityfactory.create(bundle.get_service_name())
activityfactory.create(bundle.get_bundle_id())
else:
if not self.get_activities() and service_name is None:
logging.warning('No activity can open this object.')

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

Loading…
Cancel
Save