From 59c777e1096d8b64b477b0647c336acb7b59f8ab Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 2 Nov 2006 17:42:39 +0100 Subject: [PATCH 1/2] Add /tmp/sugar-services --- dbus-installed.conf.in | 1 + 1 file changed, 1 insertion(+) diff --git a/dbus-installed.conf.in b/dbus-installed.conf.in index de7d01e2..7b6d6074 100644 --- a/dbus-installed.conf.in +++ b/dbus-installed.conf.in @@ -12,6 +12,7 @@ @prefix@/share/sugar/activities @prefix@/share/sugar/services + /tmp/sugar-services From 561169809b92e29cfd762c3cd673def881764dcc Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 2 Nov 2006 20:16:36 +0100 Subject: [PATCH 2/2] Install services in user dir if dbus is recent enough. --- sugar-emulator | 6 +++--- sugar/activity/bundleregistry.py | 7 +++++-- sugar/env.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/sugar-emulator b/sugar-emulator index 16e9da41..e9ba62c3 100755 --- a/sugar-emulator +++ b/sugar-emulator @@ -70,9 +70,9 @@ for i in range(1, len(sys.argv)): emulator = Emulator(fullscreen) emulator.start() -# FIXME temporary until dbus support services in home dir -if not os.path.isdir('/tmp/sugar-services'): - os.mkdir('/tmp/sugar-services') +if env.get_dbus_version() < '0.95': + if not os.path.isdir('/tmp/sugar-services'): + os.mkdir('/tmp/sugar-services') os.execlp('dbus-launch', 'dbus-launch', '--exit-with-session', '--config-file=%s' % env.get_dbus_config(), program) diff --git a/sugar/activity/bundleregistry.py b/sugar/activity/bundleregistry.py index 582c340b..c6d05319 100644 --- a/sugar/activity/bundleregistry.py +++ b/sugar/activity/bundleregistry.py @@ -10,10 +10,13 @@ class _ServiceParser(ConfigParser): class _ServiceManager(object): def __init__(self): - self._path = '/tmp/sugar-services' + if env.get_dbus_version() < '0.95': + self._path = '/tmp/sugar-services' + else: + self._path = os.path.expanduser('~/.local/share/dbus-1/services') if not os.path.isdir(self._path): - os.mkdir(self._path) + os.makedirs(self._path) def add(self, bundle): name = bundle.get_service_name() diff --git a/sugar/env.py b/sugar/env.py index f776865a..3f958b23 100644 --- a/sugar/env.py +++ b/sugar/env.py @@ -56,3 +56,15 @@ def get_dbus_config(): def get_shell_bin_dir(): return sugar_shell_bin_dir + +_dbus_version = None +def get_dbus_version(): + global _dbus_version + if _dbus_version == None: + f = os.popen('dbus-daemon --version') + version_line = f.readline() + if version_line: + splitted_line = version_line.split() + _dbus_version = splitted_line[len(splitted_line) - 1] + f.close() + return _dbus_version