--- /dev/null
+#!/usr/bin/python
+
+# zavai - simple interface to the OpenMoko (or to the FSO stack)
+#
+# Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import sys
+import signal
+import optparse
+import gtk
+import dbus
+import dbus.mainloop.glib
+import zavai
+
+VERSION=zavai.VERSION
+
+class Parser(optparse.OptionParser):
+ def __init__(self, *args, **kwargs):
+ # Yes, in 2009 optparse from the *standard library* still uses old
+ # style classes
+ optparse.OptionParser.__init__(self, *args, **kwargs)
+
+ def error(self, msg):
+ sys.stderr.write("%s: error: %s\n\n" % (self.get_prog_name(), msg))
+ self.print_help(sys.stderr)
+ sys.exit(2)
+
+parser = Parser(usage="usage: %prog [options]",
+ version="%prog "+ VERSION,
+ description="Simple interactive interface for the OpenMoko")
+parser.add_option("-v", "--verbose", action="store_true", help="verbose mode")
+
+(opts, args) = parser.parse_args()
+
+if not opts.verbose:
+ zavai.set_quiet()
+
+# Read configuration
+zavai.info("Loading configuration")
+conf = zavai.Config()
+
+# Set up dbus
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+dbus_system_bus = dbus.SystemBus()
+
+# Set up zavai
+registry = zavai.Registry()
+
+# Register main factories
+registry.register(dbus_system_bus, "dbus.system_bus")
+registry.register(conf, "conf")
+registry.register_factory(zavai.Zavai, "app")
+registry.register_factory(zavai.GPS, "gps")
+registry.register_factory(zavai.GPX, "gpx")
+registry.register_factory(zavai.Audio, "audio")
+
+# Load plugins
+zavai.info("Loading plugins")
+for p in zavai.load_plugins(nick="zavai"):
+ try:
+ p.init(conf = conf, registry = registry)
+ except Exception, e:
+ print >>sys.stderr, "Exception caught loading plugin %s: skipping plugin" % p
+ print >>sys.stderr, "Exception details:"
+ import traceback
+ details = traceback.format_exc()
+ print >>sys.stderr, "\t"+details.rstrip().replace("\n", "\n\t")
+
+# Shutdown the main loop on SIGINT
+def on_kill(signum, frame):
+ gtk.main_quit()
+signal.signal(signal.SIGINT, on_kill)
+signal.signal(signal.SIGTERM, on_kill)
+
+zavai.info("Starting")
+app = registry.resource("app")
+app.connect("destroy", gtk.main_quit)
+app.run()
+
+zavai.info("Shutting down")
+registry.shutdown()
+
+sys.exit(0)