Use dbus activation to launch factories. This breaks
p-to-p chat and ./sugar/activities. Will fix tomorrow.master
parent
1d370ca8e5
commit
86bd6f50f0
@ -1 +1,7 @@
|
|||||||
SUBDIRS = activities shell sugar
|
SUBDIRS = activities shell sugar
|
||||||
|
|
||||||
|
dbusconfdir = $(pkgdatadir)
|
||||||
|
dbusconf_DATA = dbus-installed.conf
|
||||||
|
|
||||||
|
install-data-local:
|
||||||
|
sugar/setup.py $(top_srcdir)/activities $(pkgdatadir)/activities $(bindir)/sugar-activity-factory
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[Activity]
|
[Activity]
|
||||||
name = Web
|
name = Web
|
||||||
id = com.redhat.Sugar.BrowserActivity
|
id = com.redhat.Sugar.BrowserActivity
|
||||||
python_module = BrowserActivity.BrowserActivity
|
python_module = browser.BrowserActivity.BrowserActivity
|
||||||
default_type = _web_olpc._udp
|
default_type = _web_olpc._udp
|
||||||
show_launcher = yes
|
show_launcher = yes
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[Activity]
|
[Activity]
|
||||||
name = Chat
|
name = Chat
|
||||||
id = com.redhat.Sugar.ChatActivity
|
id = com.redhat.Sugar.ChatActivity
|
||||||
python_module = ChatActivity.ChatActivity
|
python_module = chat.ChatActivity.ChatActivity
|
||||||
default_type = _chat_activity._tcp
|
default_type = _chat_activity._tcp
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
sugardir = $(pkgdatadir)/activities/browser
|
sugardir = $(pkgdatadir)/activities/terminal
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
terminal.py
|
TerminalActivity.py
|
||||||
|
|
||||||
activitydir = $(pkgdatadir)/activities/browser
|
EXTRA_DIST = terminal.activity
|
||||||
activity_DATA = terminal.activity
|
|
||||||
|
|
||||||
EXTRA_DIST = $(activity_DATA)
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[Activity]
|
[Activity]
|
||||||
name = Terminal
|
name = Terminal
|
||||||
id = org.sugar.Terminal
|
id = org.sugar.Terminal
|
||||||
python_module = terminal.TerminalActivity
|
python_module = terminal.TerminalActivity.TerminalActivity
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
<!-- This configuration file controls the per-user-login-session message bus.
|
||||||
|
Add a session-local.conf and edit that rather than changing this
|
||||||
|
file directly. -->
|
||||||
|
|
||||||
|
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||||
|
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||||
|
<busconfig>
|
||||||
|
<!-- Our well-known bus type, don't change this -->
|
||||||
|
<type>session</type>
|
||||||
|
|
||||||
|
<listen>unix:tmpdir=/tmp</listen>
|
||||||
|
|
||||||
|
<servicedir>@prefix@/share/sugar/activities</servicedir>
|
||||||
|
|
||||||
|
<policy context="default">
|
||||||
|
<!-- Allow everything to be sent -->
|
||||||
|
<allow send_destination="*"/>
|
||||||
|
<!-- Allow everything to be received -->
|
||||||
|
<allow eavesdrop="true"/>
|
||||||
|
<!-- Allow anyone to own anything -->
|
||||||
|
<allow own="*"/>
|
||||||
|
</policy>
|
||||||
|
|
||||||
|
</busconfig>
|
@ -0,0 +1,24 @@
|
|||||||
|
<!-- This configuration file controls the per-user-login-session message bus.
|
||||||
|
Add a session-local.conf and edit that rather than changing this
|
||||||
|
file directly. -->
|
||||||
|
|
||||||
|
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||||
|
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||||
|
<busconfig>
|
||||||
|
<!-- Our well-known bus type, don't change this -->
|
||||||
|
<type>session</type>
|
||||||
|
|
||||||
|
<listen>unix:tmpdir=/tmp</listen>
|
||||||
|
|
||||||
|
<servicedir>/tmp/sugar</servicedir>
|
||||||
|
|
||||||
|
<policy context="default">
|
||||||
|
<!-- Allow everything to be sent -->
|
||||||
|
<allow send_destination="*"/>
|
||||||
|
<!-- Allow everything to be received -->
|
||||||
|
<allow eavesdrop="true"/>
|
||||||
|
<!-- Allow anyone to own anything -->
|
||||||
|
<allow own="*"/>
|
||||||
|
</policy>
|
||||||
|
|
||||||
|
</busconfig>
|
@ -1,3 +1,4 @@
|
|||||||
sugar_data_dir = '@prefix@/share/sugar'
|
sugar_data_dir = '@prefix@/share/sugar'
|
||||||
sugar_activity_runner = '@prefix@/bin/sugar-activity'
|
sugar_activity_runner = '@prefix@/bin/sugar-activity'
|
||||||
sugar_activities_dir = '@prefix@/share/sugar/activities'
|
sugar_activities_dir = '@prefix@/share/sugar/activities'
|
||||||
|
sugar_dbus_config = '@prefix@/share/sugar/dbus-installed.conf'
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import shutil
|
||||||
|
import logging
|
||||||
|
from ConfigParser import ConfigParser
|
||||||
|
from ConfigParser import NoOptionError
|
||||||
|
|
||||||
|
class ServiceParser(ConfigParser):
|
||||||
|
def optionxform(self, option):
|
||||||
|
return option
|
||||||
|
|
||||||
|
def _install_activity(activity_dir, filename, dest_path, bin):
|
||||||
|
source = os.path.join(activity_dir, filename)
|
||||||
|
dest = os.path.join(dest_path, filename)
|
||||||
|
print 'Install ' + filename + ' ...'
|
||||||
|
shutil.copyfile(source, dest)
|
||||||
|
|
||||||
|
cp = ConfigParser()
|
||||||
|
cp.read([source])
|
||||||
|
|
||||||
|
try:
|
||||||
|
activity_id = cp.get('Activity', 'id')
|
||||||
|
except NoOptionError:
|
||||||
|
logging.error('%s miss the required id option' % (path))
|
||||||
|
return False
|
||||||
|
|
||||||
|
if cp.has_option('Activity', 'default_type'):
|
||||||
|
default_type = cp.get('Activity', 'default_type')
|
||||||
|
else:
|
||||||
|
default_type = None
|
||||||
|
|
||||||
|
if cp.has_option('Activity', 'exec'):
|
||||||
|
activity_exec = cp.get('Activity', 'exec')
|
||||||
|
elif cp.has_option('Activity', 'python_module'):
|
||||||
|
python_module = cp.get('Activity', 'python_module')
|
||||||
|
python_module = cp.get('Activity', 'python_module')
|
||||||
|
activity_exec = '%s %s %s' % (bin, activity_id, python_module)
|
||||||
|
if default_type:
|
||||||
|
activity_exec += ' ' + default_type
|
||||||
|
else:
|
||||||
|
logging.error('%s must specifiy exec or python_module' % (source))
|
||||||
|
return False
|
||||||
|
|
||||||
|
service_cp = ServiceParser()
|
||||||
|
section = 'D-BUS Service'
|
||||||
|
service_cp.add_section(section)
|
||||||
|
service_cp.set(section, 'Name', activity_id + '.Factory')
|
||||||
|
service_cp.set(section, 'Exec', activity_exec)
|
||||||
|
|
||||||
|
fileobject = open(os.path.join(dest_path, activity_id + '.service'), 'w')
|
||||||
|
service_cp.write(fileobject)
|
||||||
|
fileobject.close()
|
||||||
|
|
||||||
|
def install_activities(source_path, dest_path, bin):
|
||||||
|
"""Scan a directory for activities and install them."""
|
||||||
|
if os.path.isdir(source_path):
|
||||||
|
for filename in os.listdir(source_path):
|
||||||
|
activity_dir = os.path.join(source_path, filename)
|
||||||
|
if os.path.isdir(activity_dir):
|
||||||
|
for filename in os.listdir(activity_dir):
|
||||||
|
if filename.endswith(".activity"):
|
||||||
|
_install_activity(activity_dir, filename, dest_path, bin)
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
install_activities(sys.argv[1], sys.argv[2], sys.argv[3])
|
Loading…
Reference in New Issue