]> ToastFreeware Gitweb - gregoa/zavai.git/blob - src/zavai.vala
Merge branch 'master' into alarm
[gregoa/zavai.git] / src / zavai.vala
1 /*
2  * zavai - simple interface to the OpenMoko (or to the FSO stack)
3  *
4  * Copyright (C) 2009  Enrico Zini <enrico@enricozini.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 using GLib;
22
23 //string VERSION = "0.1";
24
25 static int main (string[] args) {
26         Gtk.init (ref args);
27
28         // parser = Parser(usage="usage: %prog [options]",
29         //                 version="%prog "+ VERSION,
30         //                 description="Simple interactive interface for the OpenMoko")
31         // parser.add_option("-v", "--verbose", action="store_true", help="verbose mode")
32         // 
33         // (opts, args) = parser.parse_args()
34         // 
35         // if not opts.verbose:
36         //     zavai.set_quiet()
37         // 
38         // # Read configuration
39         // zavai.info("Loading configuration")
40         // conf = zavai.Config()
41
42         // Set up zavai
43
44         int id = at.earliestID();
45         stderr.printf("%d\n", id);
46         bool res = at.jobContents(id, fd => {
47                 FileStream fs = FileStream.fdopen(fd, "r");
48                 if (fs == null)
49                         return false;
50                 string? line;
51                 while ((line = fs.read_line()) != null)
52                         stdout.printf(" LN %s\n", line);
53         });
54
55         return 0;
56
57     // Core infrastructure
58         zavai.config = new zavai.Config();
59         zavai.registry = new zavai.Registry();
60         zavai.app = new zavai.Zavai();
61
62         zavai.registry.register_resource("zavai", zavai.app);
63
64     // Additional infrastructure
65         zavai.input.init();
66         zavai.gps.init();
67         zavai.gsm.init();
68         zavai.audio.init();
69         zavai.clock.init();
70
71         /*
72         zavai.clock.clock.schedule(new zavai.clock.Alarm(123456, "Second"));
73         zavai.clock.clock.schedule(new zavai.clock.Alarm(1234567, "Third"));
74         zavai.clock.clock.schedule(new zavai.clock.Alarm(12345, "First"));
75         zavai.clock.clock.check_alarms();
76         */
77
78         // Create menus
79         zavai.registry.register_menu("menu.main", new zavai.Menu("Main menu"));
80
81         var menu_gps = new zavai.Menu("GPS");
82         zavai.registry.register_menu("menu.gps", menu_gps);
83         zavai.registry.getmenu("menu.main").add_applet("menu.gps");
84
85         var menu_gsm = new zavai.Menu("GSM");
86         zavai.registry.register_menu("menu.gsm", menu_gsm);
87         zavai.registry.getmenu("menu.main").add_applet("menu.gsm");
88
89         var menu_misc = new zavai.Menu("Misc");
90         zavai.registry.register_menu("menu.misc", menu_misc);
91         zavai.registry.getmenu("menu.main").add_applet("menu.misc");
92
93         // User interface
94         zavai.ui.main.init();
95         zavai.ui.gps.init();
96         zavai.ui.gsm.init();
97         zavai.app.run_script(zavai.config.homedir + "/display init");
98         zavai.ui.power.init();
99         zavai.ui.kbd.init();
100         zavai.ui.wm.init();
101         zavai.ui.calendar.init();
102         zavai.ui.polygen.init();
103         zavai.ui.debug.init();
104
105         //zavai.app.show_applet("menu.main");
106         zavai.app.show_applet("zavai.status");
107
108 /*
109         zavai.clock.clock.schedule(new zavai.clock.Alarm(time_t() + 10, "Test second"));
110         zavai.clock.clock.schedule(new zavai.clock.Alarm(time_t() + 5, "Test first"));
111         zavai.clock.clock.schedule(new zavai.clock.Alarm(time_t() + 300, "Test third"));
112 */
113
114         //zavai.ui.power.power_menu.toggle();
115
116         // # Shutdown the main loop on SIGINT
117         // def on_kill(signum, frame):
118         //     gtk.main_quit()
119         // signal.signal(signal.SIGINT, on_kill)
120         // signal.signal(signal.SIGTERM, on_kill)
121
122         // zavai.info("Starting")
123         // app = registry.resource("app")
124         // app.connect("destroy", gtk.main_quit)
125         // app.run()
126
127 /*
128         dynamic DBus.Object otime = zavai.registry.sbus.get_object(
129                         "org.freesmartphone.otimed",
130                         "/org/freesmartphone/Time/Alarm",
131                         "org.freesmartphone.Time.Alarm");
132
133         otime.ClearAlarm();
134         otime.SetAlarm(time_t() + 10);
135
136         dynamic DBus.Object notification = zavai.registry.sbus.get_object(
137                         "org.freesmartphone",
138                         "org/freesmartphone/Notification",
139                         "org.freesmartphone.Notification");
140         notification.Alarm += on_alarm;
141 */
142
143         zavai.app.run();
144         Gtk.main();
145
146         // zavai.info("Shutting down")
147         zavai.registry.shutdown();
148
149         return 0;
150 }