Low-level Activity API: Difference between revisions

From OLPC
Jump to navigation Jump to search
m (→‎Methods: add some methods)
(→‎Methods: add XID explanation)
Line 14: Line 14:


/my/organization/MyActivity com.redhat.Sugar.ActivityFactory.create()
/my/organization/MyActivity com.redhat.Sugar.ActivityFactory.create()

The <tt>create()</tt> method creates a new Activity instance. That instance is exposed on the dbus as <tt>/org/laptop/Activity/123456</tt>. The number 123456 is the instance's top-level window XID. An activity instance needs to support the following methods:


/org/laptop/Activity/123456 org.laptop.Activity.get_id()
/org/laptop/Activity/123456 org.laptop.Activity.get_id()

Revision as of 09:14, 22 May 2007

Most activities will use the Python API to implement activities. This page will document the underlying mechanism that non-Python activities need to conform to.

This documentation effort was started by Bert while implementing the Squeak-based Etoys activity. Please fill in missing pieces and correct mistakes!

Overview

An Activity Bundle can specify an executable in the activity.info's exec field. When installing the bundle, the path of this executable will be expanded and added to the list of DBus services in $HOME/.local/share/dbus-1/services/ using the DBus service name as specified in the service_name field. When launching an activity from Sugar shell, a request to that DBus service is made, which makes DBus run the previously specified executable. The executable must create a "factory service" on the DBus using the specified service name.

The most important method the factory service must provide is com.redhat.Sugar.ActivityFactory.create() which spawns an activity instance. Each activity instance has a unique activity_id which is passed as parameter to the create() method.

When the last activity instance exits, the factory service should quit.

Methods

These methods were collected by introspection on the DBus

/my/organization/MyActivity com.redhat.Sugar.ActivityFactory.create()

The create() method creates a new Activity instance. That instance is exposed on the dbus as /org/laptop/Activity/123456. The number 123456 is the instance's top-level window XID. An activity instance needs to support the following methods:

/org/laptop/Activity/123456 org.laptop.Activity.get_id()
/org/laptop/Activity/123456 org.laptop.Activity.get_service_name()
/org/laptop/Activity/123456 org.laptop.Activity.share()
/org/laptop/Activity/123456 org.laptop.Activity.get_shared()
/org/laptop/Activity/123456 org.laptop.Activity.execute(cmd, args[])

Signals

todo

Example

[Activity]
name = My Activity
activity_version = 1
host_version = 1
service_name = my.organization.MyActivity
icon = activity-my
exec = myactivityfactory
show_launcher = yes

Signal /org/freedesktop/DBus org.freedesktop.DBus.NameAcquired(':1.23')

Signal /org/freedesktop/DBus org.freedesktop.DBus.NameAcquired('my.organization.MyActivity')

MethodCall /my/organization/MyActivity org.freedesktop.DBus.Introspectable.Introspect()

MethodCall /my/organization/MyActivity com.redhat.Sugar.ActivityFactory.create(activity_id='6f7f3acacca87886332f50bdd522d805f0abbf1f')

this is as far as I got now ... what needs to happen next? I'll find out ... -- Bert