Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tutorius/engine.py40
-rw-r--r--tutorius/service.py47
2 files changed, 87 insertions, 0 deletions
diff --git a/tutorius/engine.py b/tutorius/engine.py
new file mode 100644
index 0000000..396a9e1
--- /dev/null
+++ b/tutorius/engine.py
@@ -0,0 +1,40 @@
+import dbus.mainloop.glib
+from sugar.tutorius.TProbe import ProbeProxy
+import sugar.tutorius.addon as addon
+
+class Engine:
+ """
+ Driver for the execution of tutorials
+ """
+
+ def __init__(self):
+ # FIXME Probe management should be in the probe manager
+ dbus.mainloop.DBusGMainLoop(set_as_default=True)
+ self._probe = ProbeProxy("org.laptop.Calculate")
+
+
+ def launch(self, tutorialID):
+ """ Launch a tutorial
+ @param tutorialID unique tutorial identifier used to retrieve it from the disk
+ """
+ if self._bm = None:
+ self._bm = addon.create("BubbleMessage")
+
+ self._bm.position = (300,300)
+ self._bm.message = "Tutorial Started"
+
+ self._probe.install(self._bm)
+
+
+ def stop(self):
+ """ Stop the current tutorial
+ """
+ self._probe.uninstall(self._bm)
+ self._bm = None
+
+ def pause(self):
+ """ Interrupt the current tutorial and save its state in the journal
+ """
+ self._bm.message = "Tutorial State would be saved"
+ self._probe.update(self._bm)
+
diff --git a/tutorius/service.py b/tutorius/service.py
new file mode 100644
index 0000000..02c93b1
--- /dev/null
+++ b/tutorius/service.py
@@ -0,0 +1,47 @@
+from engine import Engine
+import dbus
+
+_DBUS_SERVICE = "org.tutorius.Service"
+_DBUS_PATH = "org/tutorius/Service"
+_DBUS_SERVICE_IFACE = "org.tutorius.Service"
+
+class Service(dbus.service.Object):
+ """
+ Global tutorius entry point to control the whole system
+ """
+
+ def __init__(self):
+ bus = dbus.SessionBus()
+ bus_name = dbus.service.BusName(_DBUS_SERVICE, bus=bus)
+ dbus.service.Object.__init__(self, bus_name, _DBUS_PATH)
+
+ self._engine = Engine()
+
+ def start(self):
+ """ Start the service itself
+ """
+ # For the moment there is nothing to do
+ pass
+
+
+ @@dbus.service.method(_DBUS_SERVICE_IFACE,
+ in_signature="s", out_signature="")
+ def launch(self, tutorialID):
+ """ Launch a tutorial
+ @param tutorialID unique tutorial identifier used to retrieve it from the disk
+ """
+ self._engine.launch(tutorialID)
+
+ @@dbus.service.method(_DBUS_SERVICE_IFACE,
+ in_signature="", out_signature="")
+ def stop(self):
+ """ Stop the current tutorial
+ """
+ self._engine.stop()
+
+ @@dbus.service.method(_DBUS_SERVICE_IFACE,
+ in_signature="", out_signature="")
+ def pause(self):
+ """ Interrupt the current tutorial and save its state in the journal
+ """
+ self._engine.pause()