From: Enrico Zini Date: Fri, 27 Nov 2009 15:31:57 +0000 (+0100) Subject: Merge branch 'master' into alarm X-Git-Url: https://git.toastfreeware.priv.at/gregoa/zavai.git/commitdiff_plain/a7d1a285763bffe81b29c854b905d8ca83e9a2bd?hp=f4d40b59c9ff7acbd94cdbf2551c19d982af1876 Merge branch 'master' into alarm --- diff --git a/README b/README index bf56727..6906420 100644 --- a/README +++ b/README @@ -152,12 +152,14 @@ TODO list / wish list http://git.freesmartphone.org/?p=specs.git;a=blob_plain;f=html/index.html;hb=HEAD * Features to add: - - calendar: show preview of next 30 days - (not among the notes: it replaces the calendar view; unless we skip the empty dates, which is a good idea) - next30: when clicking on an item, show that day and switch to day notes (conflates next30 and day notes) - tab becomes day / month / all - next30: don't update if not shown currently on the notebook - gtk_calendar_set_detail_func + - alerts with at + - work without ogpsd + - use the gpsd dbus protocol + - power on/off the gps and start/stop gpsd + - set to keep the GPS on during suspend + - suspend/resume hooks to put the GPS into low power mode + - next30: don't update if not shown currently on the notebook + - gtk_calendar_set_detail_func - contacts: show as a fancy focus+context list (see prefuse) - GSM power and network - link to open SHR-dialer diff --git a/src/app_debug.vala b/src/app_debug.vala index e94cc1a..ec585ce 100644 --- a/src/app_debug.vala +++ b/src/app_debug.vala @@ -35,7 +35,7 @@ public class UselessService : Service { public UselessService() { - name = "app.debug.useless_service"; + Object(name: "app.debug.useless_service"); } } diff --git a/src/app_keyboard.vala b/src/app_keyboard.vala index 794bf01..c5caa3b 100644 --- a/src/app_keyboard.vala +++ b/src/app_keyboard.vala @@ -30,7 +30,7 @@ public class Keyboard : Service public Keyboard() { - name = "keyboard"; + Object(name: "keyboard"); } private void on_child_quit(Pid pid, int status) diff --git a/src/app_polygen.vala b/src/app_polygen.vala index 91f2412..17e26e7 100644 --- a/src/app_polygen.vala +++ b/src/app_polygen.vala @@ -34,7 +34,7 @@ protected class PolygenPage : Object public PolygenPage(string name) { - this.name = name; + Object(name: name); model = new Gtk.ListStore(3, typeof(string), typeof(string), typeof(string)); list = new Gtk.TreeView.with_model(model); list.insert_column_with_attributes (-1, "Name", new Gtk.CellRendererText(), "text", 0); @@ -79,7 +79,7 @@ protected class PolygenRun : Gtk.VBox public string grm_name { get; set; } public string grm_type { get; set; } - public PolygenRun() + public PolygenRun() throws RegexError { grm_name = ""; grm_type = ""; @@ -185,21 +185,21 @@ public class Polygen : Applet notebook.set_current_page(notebook.get_n_pages()-1); } - public Polygen(string label, IOChannel data) + public Polygen(string label, IOChannel data) throws ConvertError, IOChannelError, RegexError { _label = label; pages = new Gee.ArrayList(); while (true) { - string line; - var res = data.read_line(out line, null, null); - if (res != IOStatus.NORMAL) break; - string[] vals = line.split(" ", 3); - if (vals == null) break; - string[] np = vals[0].split("/", 2); - if (np == null) break; - add_grammar(np[0], np[1], vals[1], vals[2].strip()); + string line; + var res = data.read_line(out line, null, null); + if (res != IOStatus.NORMAL) break; + string[] vals = line.split(" ", 3); + if (vals == null) break; + string[] np = vals[0].split("/", 2); + if (np == null) break; + add_grammar(np[0], np[1], vals[1], vals[2].strip()); } notebook = new Gtk.Notebook(); diff --git a/src/app_power.vala b/src/app_power.vala index c1e0ec3..4c93581 100644 --- a/src/app_power.vala +++ b/src/app_power.vala @@ -394,7 +394,7 @@ public class Backlight: zavai.Service { public Backlight() { - name = "backlight"; + Object(name: "backlight"); } // Turn the backlight on and then let it fade off @@ -467,8 +467,10 @@ public class PowerMenu : zavai.Resource, Gtk.Window public PowerMenu() { - type = Gtk.WindowType.TOPLEVEL; - title = "Power Menu"; + Object( + type: Gtk.WindowType.TOPLEVEL, + title: "Power Menu" + ); shown = false; destroy_with_parent = true; set_transient_for(zavai.app); @@ -560,24 +562,29 @@ public void init() backlight = new Backlight(); zavai.registry.register_service(backlight); - battery_icons = new Gee.ArrayList(); - // Enumerate batteries - var c = new Dkp.Client(); - unowned GLib.PtrArray devs = c.enumerate_devices(); - for (int i = 0; i < devs.len; ++i) - { - Dkp.Device dev = (Dkp.Device)devs.pdata[i]; - stderr.printf("Found new device %s\n", dev.native_path); - dev.print(); - stderr.printf("Rechargeable: %s\n", dev.is_rechargeable ? "yes" : "no"); - if (!dev.is_rechargeable) continue; - var bi = new BatteryIcon(dev); - bi.set_visible(true); - battery_icons.add(bi); - } - - power_menu = new PowerMenu(); - zavai.registry.register_resource("powermenu", power_menu); + try { + battery_icons = new Gee.ArrayList(); + // Enumerate batteries + var c = new Dkp.Client(); + unowned GLib.PtrArray devs = c.enumerate_devices(); + for (int i = 0; i < devs.len; ++i) + { + Dkp.Device dev = (Dkp.Device)devs.pdata[i]; + stderr.printf("Found new device %s\n", dev.native_path); + dev.print(); + stderr.printf("Rechargeable: %s\n", dev.is_rechargeable ? "yes" : "no"); + if (!dev.is_rechargeable) continue; + var bi = new BatteryIcon(dev); + bi.set_visible(true); + battery_icons.add(bi); + } + + power_menu = new PowerMenu(); + zavai.registry.register_resource("powermenu", power_menu); + } catch (Error e) { + stderr.printf("Creating power menu: %s\n", e.message); + power_menu = null; + } //zavai.registry.getmenu("menu.main").add_applet("menu.power"); //tpm = new TogglePowerMenu(); diff --git a/src/app_wm.vala b/src/app_wm.vala index 45b3bb7..471f9fc 100644 --- a/src/app_wm.vala +++ b/src/app_wm.vala @@ -181,7 +181,7 @@ public class Launcher: Applet { static const string DENTRY_GROUP = "Desktop Entry"; - public Launcher(string label) + public Launcher(string label) throws Error { _label = label; @@ -300,8 +300,13 @@ public void init() app_shortcut = new AppShortcut(); - launcher = new Launcher("Run program"); - zavai.registry.register_applet("wm.launcher", launcher); + try { + launcher = new Launcher("Run program"); + zavai.registry.register_applet("wm.launcher", launcher); + } catch (Error e) { + stderr.printf("Error creating app launcher: %s\n", e.message); + launcher = null; + } window_list = new WindowList("Apps"); zavai.registry.register_applet("wm.list", window_list); diff --git a/src/at.vala b/src/at.vala index 1f72400..0eb17bb 100644 --- a/src/at.vala +++ b/src/at.vala @@ -40,8 +40,14 @@ public static int earliestID(string? queue = null) Pid pid; int stdout; - if (!Process.spawn_async_with_pipes("/", argv, null, SpawnFlags.STDERR_TO_DEV_NULL, null, out pid, null, out stdout, null)) + try + { + if (!Process.spawn_async_with_pipes("/", argv, null, SpawnFlags.STDERR_TO_DEV_NULL, null, out pid, null, out stdout, null)) + return -1; + } catch (SpawnError e) { + stderr.printf("Cannot run 'at -q': %s\n", e.message); return -1; + } FileStream fs = FileStream.fdopen(stdout, "r"); if (fs == null) @@ -56,7 +62,7 @@ public static int earliestID(string? queue = null) if (!line[0].isdigit()) continue; weak string rest; ulong id = line.to_ulong(out rest, 10); - Time t = new Time(); + Time t = Time(); rest = t.strptime(rest.offset(1), "%a %b %d %H:%M:%S %Y"); if (rest == null) continue; time_t tt = t.mktime(); @@ -84,8 +90,14 @@ public static bool jobContents(int id, jobParser parser) Pid pid; int stdoutfd; - if (!Process.spawn_async_with_pipes("/", argv, null, SpawnFlags.STDERR_TO_DEV_NULL, null, out pid, null, out stdoutfd, null)) + try + { + if (!Process.spawn_async_with_pipes("/", argv, null, SpawnFlags.STDERR_TO_DEV_NULL, null, out pid, null, out stdoutfd, null)) + return false; + } catch (SpawnError e) { + stderr.printf("Cannot run 'at -c': %s\n", e.message); return false; + } bool res = parser(stdoutfd); diff --git a/src/audio.vala b/src/audio.vala index 0b142f3..e1c32ca 100644 --- a/src/audio.vala +++ b/src/audio.vala @@ -30,7 +30,7 @@ public class Audio: zavai.Service public Audio() { - name = "audio"; + Object(name: "audio"); audiodev = zavai.registry.sbus.get_object( "org.freesmartphone.odeviced", "/org/freesmartphone/Device/Audio", diff --git a/src/clock.vala b/src/clock.vala index 9c021ad..bcd25e7 100644 --- a/src/clock.vala +++ b/src/clock.vala @@ -115,7 +115,7 @@ public class Clock: zavai.Service public Clock() { - name = "clock"; + Object(name: "clock"); alarms = null; listener = new AlarmNotification(); last_minute = 0; diff --git a/src/gps.vala b/src/gps.vala index 6c64880..6b37d80 100644 --- a/src/gps.vala +++ b/src/gps.vala @@ -31,7 +31,7 @@ public class GPS: zavai.Service public GPS() { - name = "gps"; + Object(name: "gps"); // see mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage usage = zavai.registry.sbus.get_object( @@ -113,7 +113,7 @@ public class Position : zavai.Service public Position() { - name = "gps.position"; + Object(name: "gps.position"); position = zavai.registry.sbus.get_object( "org.freesmartphone.ogpsd", "/org/freedesktop/Gypsy", @@ -206,7 +206,7 @@ public class GPX : Service public GPX() { - name = "gps.gpx"; + Object(name: "gps.gpx"); } public override void start() diff --git a/src/gsm.vala b/src/gsm.vala index 89ad394..5d55b61 100644 --- a/src/gsm.vala +++ b/src/gsm.vala @@ -29,7 +29,7 @@ public class GSM: zavai.Service public GSM() { - name = "gsm.gsm"; + Object(name: "gsm.gsm"); device = zavai.registry.sbus.get_object( "org.freesmartphone.ogpsd", @@ -72,7 +72,7 @@ public class GPRS: zavai.Service public GPRS() { - name = "gsm.gprs"; + Object(name: "gsm.gprs"); device = zavai.registry.sbus.get_object( "org.freesmartphone.ogsmd", diff --git a/src/input.vala b/src/input.vala index 8527ac1..19fc090 100644 --- a/src/input.vala +++ b/src/input.vala @@ -129,11 +129,13 @@ public class PowerButton : DevInput public PowerButton() { - name = "input.power_button"; // FIXME: change to event0 for the power button // FIXME: change to event4 for the aux button and headset button //device = "/dev/input/event1"; - device = "/dev/input/event0"; + Object( + name: "input.power_button", + device: "/dev/input/event0" + ); event += on_event; } diff --git a/src/registry.vala b/src/registry.vala index dffbfe0..181aa50 100644 --- a/src/registry.vala +++ b/src/registry.vala @@ -40,7 +40,12 @@ public class Registry : Object, Resource memb_applets = new HashMap(str_hash, str_equal); memb_menus = new HashMap(str_hash, str_equal); registration_order = new ArrayList(); - sbus = DBus.Bus.get(DBus.BusType.SYSTEM); + try { + sbus = DBus.Bus.get(DBus.BusType.SYSTEM); + } catch (DBus.Error e) { + stderr.printf("Cannot access system DBus bus: %s\n", e.message); + sbus = null; + } bus_name = DBus.bus_get_unique_name(sbus.get_connection()); zavai.log.info("My bus name: " + bus_name); diff --git a/src/widgets/calendar.vala b/src/widgets/calendar.vala index b66acab..7b0ab09 100644 --- a/src/widgets/calendar.vala +++ b/src/widgets/calendar.vala @@ -199,7 +199,6 @@ public class Calendar : Gtk.VBox protected int cur_year; protected int cur_month; protected int cur_day; - protected Regex re_dayfile; public Calendar() { @@ -227,8 +226,6 @@ public class Calendar : Gtk.VBox pack_start(notebook, true, true, 0); - re_dayfile = new Regex("[0-9][0-9]\\.txt"); - on_month_changed(); on_day_selected(); } @@ -263,7 +260,7 @@ public class Calendar : Gtk.VBox { var d = dir.read_name(); if (d == null) break; - if (re_dayfile.match(d)) + if (d[0].isdigit() && d.has_suffix(".txt") && d.size() == 6) { calendar.mark_day((int)d.to_ulong(null, 10)); }