]> ToastFreeware Gitweb - gregoa/zavai.git/blob - src/zavai.vala
Bluetooth start/stop button
[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 /*
45         int id = at.earliestID();
46         stderr.printf("%d\n", id);
47         if (id != -1)
48         {
49                 string? label = zavai.clock.Alarm.getLabel(id);
50                 if (label == null)
51                         stdout.printf("generic at job\n");
52                 else
53                         stdout.printf("zavai at job: %s\n", label);
54         }
55
56         zavai.clock.Alarm.schedule("now + 1 hour", "An\"\'\'\n\n\ttani blinda la supercazzola");
57
58         return 0;
59 */
60
61         if (args.length > 1 && args[1] == "notify")
62         {
63                 stdout.printf("NOTIFY\n");
64                 DBus.Connection sbus;
65                 dynamic DBus.Object zav;
66                 try {
67                         sbus = DBus.Bus.get(DBus.BusType.SYSTEM);
68                 } catch (DBus.Error e) {
69                         stderr.printf("Cannot access system DBus bus: %s\n", e.message);
70                         return 1;
71                 }
72                 // see mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage
73                 zav = sbus.get_object(
74                         "org.enricozini.zavai",
75                         "/org/enricozini/Zavai/Clock",
76                         "org.enricozini.zavai.Alarm");
77                 if (args.length > 2)
78                 {
79                         stdout.printf("NOTIFY %s\n", args[2]);
80                         zav.Notify(args[2]);
81                 }
82                 else
83                         zav.Notify("Alarm");
84                 
85                 return 0;
86         }
87
88     // Core infrastructure
89         zavai.config = new zavai.Config();
90         zavai.config.argv0 = args[0];
91         zavai.registry = new zavai.Registry();
92
93     zavai.main.init();
94
95     // Additional infrastructure
96         zavai.input.init();
97         zavai.uevent.init();
98         zavai.power.init();
99         zavai.gps.init();
100         zavai.gsm.init();
101         zavai.clock.init();
102         zavai.audio.init();
103         zavai.log.init();
104         zavai.bluetooth.init();
105
106         /*
107         zavai.clock.clock.schedule(new zavai.clock.Alarm(123456, "Second"));
108         zavai.clock.clock.schedule(new zavai.clock.Alarm(1234567, "Third"));
109         zavai.clock.clock.schedule(new zavai.clock.Alarm(12345, "First"));
110         zavai.clock.clock.check_alarms();
111         */
112
113         // User interface
114         zavai.ui.main.init();
115         zavai.ui.gps.init();
116         zavai.ui.gsm.init();
117         zavai.app.run_script(zavai.config.homedir + "/display init");
118         zavai.ui.power.init();
119         zavai.ui.aux.init();
120         zavai.ui.kbd.init();
121         zavai.ui.wm.init();
122         zavai.ui.calendar.init();
123         zavai.ui.alarm.init();
124         zavai.ui.bluetooth.init();
125         zavai.ui.debug.init();
126
127         //zavai.app.show_applet("menu.main");
128         zavai.app.show_applet(zavai.ui.main.status);
129
130 /*
131         zavai.clock.clock.schedule(new zavai.clock.Alarm(time_t() + 10, "Test second"));
132         zavai.clock.clock.schedule(new zavai.clock.Alarm(time_t() + 5, "Test first"));
133         zavai.clock.clock.schedule(new zavai.clock.Alarm(time_t() + 300, "Test third"));
134 */
135
136         //zavai.ui.power.power_menu.toggle();
137
138         // # Shutdown the main loop on SIGINT
139         // def on_kill(signum, frame):
140         //     gtk.main_quit()
141         // signal.signal(signal.SIGINT, on_kill)
142         // signal.signal(signal.SIGTERM, on_kill)
143
144         // zavai.info("Starting")
145         // app = registry.resource("app")
146         // app.connect("destroy", gtk.main_quit)
147         // app.run()
148
149 /*
150         dynamic DBus.Object otime = zavai.registry.sbus.get_object(
151                         "org.freesmartphone.otimed",
152                         "/org/freesmartphone/Time/Alarm",
153                         "org.freesmartphone.Time.Alarm");
154
155         otime.ClearAlarm();
156         otime.SetAlarm(time_t() + 10);
157
158         dynamic DBus.Object notification = zavai.registry.sbus.get_object(
159                         "org.freesmartphone",
160                         "org/freesmartphone/Notification",
161                         "org.freesmartphone.Notification");
162         notification.Alarm += on_alarm;
163 */
164
165         zavai.app.run();
166
167         if (args.length > 1 && args[1] == "alarm")
168     {
169         zavai.clock.AlarmTriggerInfo alarm = new zavai.clock.AlarmTriggerInfo("Prova");
170         zavai.clock.alarm_trigger_queue.enqueue_trigger(alarm);
171     }
172
173         Gtk.main();
174
175         // zavai.info("Shutting down")
176         zavai.registry.shutdown();
177
178         return 0;
179 }