From 1607ddce227bd26449c85c5d43eebedf598e28b0 Mon Sep 17 00:00:00 2001 From: Simon Poirier Date: Fri, 30 Oct 2009 03:27:19 +0000 Subject: demo fixes --- (limited to 'src/tutorius/engine.py') diff --git a/src/tutorius/engine.py b/src/tutorius/engine.py new file mode 100644 index 0000000..e77a018 --- /dev/null +++ b/src/tutorius/engine.py @@ -0,0 +1,46 @@ +import logging +import dbus.mainloop.glib +from jarabe.model import shell +from sugar.bundle.activitybundle import ActivityBundle + +from .vault import Vault + +class Engine: + """ + Driver for the execution of tutorials + """ + + def __init__(self): + # FIXME Probe management should be in the probe manager + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + #FIXME shell.get_model() will only be useful in the shell process + self._shell = shell.get_model() + self._tutorial = None + + def launch(self, tutorialID): + """ Launch a tutorial + @param tutorialID unique tutorial identifier used to retrieve it from the disk + """ + if self._tutorial: + self._tutorial.detach() + self._tutorial = None + + #Get the active activity from the shell + activity = self._shell.get_active_activity() + self._tutorial = Vault.loadTutorial(tutorialID) + + #TProbes automatically use the bundle id, available from the ActivityBundle + bundle = ActivityBundle(activity.get_bundle_path()) + self._tutorial.attach(bundle.get_bundle_id()) + + def stop(self): + """ Stop the current tutorial + """ + self._tutorial.detach() + self._tutorial = None + + def pause(self): + """ Interrupt the current tutorial and save its state in the journal + """ + raise NotImplementedError("Unable to store tutorial state") + -- cgit v0.9.1