API reference: Difference between revisions

From OLPC
Jump to navigation Jump to search
Line 31: Line 31:
** [http://www.vrplumber.com/sugar-docs/sugar.activity.html Activity Support] -- support mechanisms for writing activities
** [http://www.vrplumber.com/sugar-docs/sugar.activity.html Activity Support] -- support mechanisms for writing activities
** [http://www.vrplumber.com/sugar-docs/sugar.presence.html Presence] [http://www.vrplumber.com/sugar-docs/sugar.chat.html Chat] [http://www.vrplumber.com/sugar-docs/sugar.p2p.html P2P]-- activity's interfaces to the Telepathy engine
** [http://www.vrplumber.com/sugar-docs/sugar.presence.html Presence] [http://www.vrplumber.com/sugar-docs/sugar.chat.html Chat] [http://www.vrplumber.com/sugar-docs/sugar.p2p.html P2P]-- activity's interfaces to the Telepathy engine
** [http://www.vrplumber.com/sugar-docs/sugar.clipboard.clipboardservice.html Clipboard] -- activity's interface to the UI's clipboard interface
*** Note: this API is '''not''' necessary for most activities, the standard GTK clipboard can be used instead
** [http://www.vrplumber.com/sugar-docs/sugar.datastore.datastore.html Datastore] -- activity's interface to the datastore service
** [http://www.vrplumber.com/sugar-docs/sugar.datastore.datastore.html Datastore] -- activity's interface to the datastore service
** [[Sugar Code Snippets|Code Snippets]] -- short fragments of code describing the canonical way to achieve various effects
** [[Sugar Code Snippets|Code Snippets]] -- short fragments of code describing the canonical way to achieve various effects
Line 47: Line 45:
*** [http://dev.laptop.org/git?p=projects/games-misc;a=blob;f=olpcgames-src/olpcgames/svgsprite.py;hb=HEAD Example] -- renders an SVG file to a pygame sprite
*** [http://dev.laptop.org/git?p=projects/games-misc;a=blob;f=olpcgames-src/olpcgames/svgsprite.py;hb=HEAD Example] -- renders an SVG file to a pygame sprite
*** [http://dev.laptop.org/git?p=projects/calculate;a=blob;f=svgimage.py;hb=HEAD Example] -- rendering an SVG image to a GTK surface
*** [http://dev.laptop.org/git?p=projects/calculate;a=blob;f=svgimage.py;hb=HEAD Example] -- rendering an SVG image to a GTK surface
** [http://www.vrplumber.com/sugar-docs/sugar.clipboard.clipboardservice.html Clipboard] -- activity's interface to the UI's clipboard interface
*** Note: this API is '''not''' necessary for most activities, the standard GTK clipboard can be used instead


=== High-Level Widgets ===
=== High-Level Widgets ===

Revision as of 21:04, 19 December 2007

This page describes the components of the XO software environment. For the low-level API available to non-Python activities, see the Low-level Activity API page.

The OLPC platform includes a large number of libraries and services. This page attempts to gather links to reference works which can be used when programming the XO laptops. This reference is primarily intended for Software Developers. You may want to try out a few Tutorials before diving into these documents.

Platform

  • Software components is a somewhat old document describing the various pieces of software and libraries involved in the system.

Sugar Specs

Documentation describing how to integrate into the Sugar GUI shell:

  • Activity bundles -- reference to Sugar's activity bundle (.xo) file format/project structure
  • Low-level Activity API -- reference to the messages you activity should send/receive for Sugar integration

Python Libraries

Where official reference documentation isn't available, PyDoc-generated documentation is provided. See below for instructions on how to produce the PyDoc documentation in your own running image.

GUI Libraries

Libraries for creating standard Windows-Icon-Menu-Pointer (WIMP) GUI applications.

  • Sugar Architecture (PyDoc) -- core UI and service libraries
    • Activity Support -- support mechanisms for writing activities
    • Presence Chat P2P-- activity's interfaces to the Telepathy engine
    • Datastore -- activity's interface to the datastore service
    • Code Snippets -- short fragments of code describing the canonical way to achieve various effects
    • Graphics API (PyDoc) -- UI library based on Hippo Canvas
      • Note: this API is largely deprecated, please use standard GTK operations
    • Hippo Canvas -- canvas mechanism used by the Sugar.graphics libraries
      • Note: this API is largely deprecated, please use standard GTK operations
  • Gtk, (PyDoc) -- GUI library underlying the Sugar UI
  • Cairo (PyDoc) -- Low-level vector graphics rendering library
    • RSVG -- Library for rendering SVG text from files/strings onto Cairo Canvases
      • Example -- renders an SVG file to a pygame sprite
      • Example -- rendering an SVG image to a GTK surface
    • Clipboard -- activity's interface to the UI's clipboard interface
      • Note: this API is not necessary for most activities, the standard GTK clipboard can be used instead

High-Level Widgets

GUI (GTK) controls which expose the functionality of entire complex applications for use by other projects.

  • Abiword -- GTK widget embedding the Abiword Word-Processor
  • HulaHop -- embeds a Gecko 1.9 (Firefox 3.0 core) rendering widget
    • Example -- the browser module from the Web activity
  • Evince -- PDF (and similar) document viewer as a GTK widget

Multimedia Libraries

Libraries that deal with multimedia and gaming functionality.

  • GStreamer (PyDoc) -- multimedia streaming library
    • Example -- PenguinTV's gstreamer-based audio-visual control
    • Example -- Sugar's initial training/introduction video
  • CSound -- the CSound audio-generation library
    • Example -- using CSound to create an audio system-load monitor application
  • OLPC Games -- PyGame wrapper that makes working within the OLPC-XO environment relatively straightforward (Strongly recommended for PyGame usage on the XO!)
  • PyGame -- GUI library suitable for Sprite-based 2D game development

Communications and Networking

Libraries for connecting to other processes, either on the local machine or across the network

  • D-BUS (PyDoc) -- desktop messaging (Remote Procedure Call (RPC) and Asynchronous Signalling) engine
  • Telepathy -- buddy and connection management including cross-machine RPC over D-BUS
    • Shared Sugar Activities -- includes some minimalist code on how to use Telepathy in your activities
    • Example -- the OLPCGames mesh wrapper provides an example of how to use raw Tubes in a (Pygame) application, the complication being that it has to package incoming events as Pygame events.
  • PyXPCOM -- Library for controlling XPCOM applications (currently just XULRunner on the XO) XXX Should be available, but doesn't appear to be (that is, import xpcom doesn't work)

Support Libraries

Libraries which are neither GUI nor multi-media (necessarily)

  • Python Standard Modules -- modules which come with the Python language
  • SECore -- search engine implementation
  • Xapian -- Full-Text Search library
  • JSON -- Javascript Object Notation parser/linearisation library
  • UrlGrabber -- url downloading library
  • OLPC -- the data-store implementation
  • Unicode -- the laptop must provide internationalized software, as a result you will need to use Python's Unicode support

Extraneous Libraries

Libraries which are present in the current builds, but not particularly "part" of the Sugar environment and which may be removed eventually.

  • Yum -- package manager for RPM-based distributions
  • RPM -- RPM manipulation library

Building PyDoc Documentation

If you just want access to the PyDoc documentation yourself, you do not need to build the documentation. You can simply start a Terminal window and run the pydoc script like so:

pydoc -p 8080

Then start a Web Browser activity and go to the URL:

http://localhost:8080

to browse all of the Python packages which are available by default on your machine.

If you really do want to create documentation for uploading to a web-site or the like, you can do the following...

In a new emulator image (you likely don't want to do this on a real OLPC as it will fill up your flash ram). Start a developer's console, then do the following:

Change to the root account (to allow for installing software with yum):

su 
yum install bzr
exit

that will download and install the bzr and python-crypto packages (about 4.8 MB) after asking you to verify that you want to do it (it will also download the yum updates, which should be small if you are using a recent emulator image).

Now, as your regular user (olpc), in the same developer's console, download the script to produce the PyDoc documentation:

bzr branch  http://www.vrplumber.com/bzr/autodoc
cd autodoc
./builddocs.py

the documentation-building process will run for a short while and produce a very large number of reasonably large HTML files in the autodoc folder.

Smalltalk Libraries

D-BUS Services

  • Avahi -- local service discovery, e.g. for finding particular services provided on the mesh network
  • NetworkManager -- network management service
  • Hardware Abstraction Layer Daemon (hald) -- control of standard hardware functionality
  • Presence Service -- friend discovery and collaboration primitives, including a description of the Telepathy API
    • Telepathy Connection Manager
    • Telepathy StreamEngine
  • Activity DBus API -- Describes the API an activity must implement on D-BUS in order to interact with the Sugar desktop
    • Activity Service (Python implementation of the Activity DBus API)
  • Data Store Service (Journal) -- the core data-storage operation of the laptop
  • Clipboard Service -- manages cross-activity sharing of data and files
  • Hardware Manager Service -- provides access to the OLPC-specific hardware on the laptop
  • Activity Registry Service -- registry of installed activity bundles on the laptop
  • Object Type Registry Service -- MIME-type registry service
  • Sugar Console Service

System Services/Hardware

  • Open Firmware/Forth -- bios-replacement system on the laptop
  • Hardware specification -- general description of the hardware on the laptops
    • DCON -- the display controller ASIC and its interface (note that normally you would use the HardwareManager D-BUS interface to manipulate the DCON)
    • Geode -- the Geode CPU (assembly-language optimization guide, links to data-sheets)
    • Power Domains -- description of which parts of the hardware are kept live in what situations
  • Kernel
    • Rebuilding OLPC kernel -- describes how to rebuild the OLPC kernel, which is sometimes necessary if you need to support otherwise unsupported hardware