Merge branch 'master' into alarm
authorEnrico Zini <enrico@enricozini.org>
Fri, 27 Nov 2009 15:31:57 +0000 (16:31 +0100)
committerEnrico Zini <enrico@enricozini.org>
Fri, 27 Nov 2009 15:31:57 +0000 (16:31 +0100)
14 files changed:
README
src/app_debug.vala
src/app_keyboard.vala
src/app_polygen.vala
src/app_power.vala
src/app_wm.vala
src/at.vala
src/audio.vala
src/clock.vala
src/gps.vala
src/gsm.vala
src/input.vala
src/registry.vala
src/widgets/calendar.vala

diff --git a/README b/README
index bf567275aea1f323dc675dc6c1c07de193fe1e7d..69064200b70dba72cef405b291c975a38e173220 100644 (file)
--- 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
index e94cc1ab75b02a933cc976b3d46347aab7af4dba..ec585ceb2fc627089a1c680beba7ca68203e2a27 100644 (file)
@@ -35,7 +35,7 @@ public class UselessService : Service
 {
     public UselessService()
     {
-        name = "app.debug.useless_service";
+        Object(name: "app.debug.useless_service");
     }
 }
 
index 794bf01c9e02bbfa70d7901503839d3e06f2dbd0..c5caa3bab8783c3a5fbbfa124cc42af985dbaf05 100644 (file)
@@ -30,7 +30,7 @@ public class Keyboard : Service
 
        public Keyboard()
        {
-               name = "keyboard";
+               Object(name: "keyboard");
        }
 
        private void on_child_quit(Pid pid, int status)
index 91f24124f77952ca478257bb6572fa3bb6b904e0..17e26e7300a76971099c60f1b61a1cc733e485c8 100644 (file)
@@ -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<PolygenPage>();
 
         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();
index c1e0ec38c27cc303227834a5a3a0ff7fe42a690f..4c93581b28d4f1e725ab3c1ac8160b57aebedce3 100644 (file)
@@ -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<BatteryIcon>();
-       // 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<BatteryIcon>();
+               // 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();
index 45b3bb757850ea4287bf6000834663b014ac34d4..471f9fc9f5be1c7744489238f9d636f7512fe0f3 100644 (file)
@@ -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);
index 1f7240044531824a233b1a4cbed13a82970acd4f..0eb17bb78e3e03e8d4dbcd20bbb873cadc8cb87e 100644 (file)
@@ -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);
 
index 0b142f32e63a3cfefdf4ad83768f28fda6ae0def..e1c32cadbf8ad91883c3789fbdb2d3a980daec40 100644 (file)
@@ -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",
index 9c021ada6567733ef22a82df6b74dc3a92c0011b..bcd25e7fb2b9f94495cd20d787893aace7671bd6 100644 (file)
@@ -115,7 +115,7 @@ public class Clock: zavai.Service
 
        public Clock()
        {
-               name = "clock";
+               Object(name: "clock");
                alarms = null;
                listener = new AlarmNotification();
                last_minute = 0;
index 6c64880e329a4fdce349ad9d155624eecc62e4ed..6b37d80e012ab636a93e4494efaaf956e3d83137 100644 (file)
@@ -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()
index 89ad394516fee1400093f32d0c959c526dcfe55d..5d55b61c28391b5aaa24eb9b863ea98e4f075830 100644 (file)
@@ -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", 
index 8527ac101b3a6f97320bea22d402bd9742b97631..19fc0908b766abcdf4387bbc7840d96945197f2c 100644 (file)
@@ -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;
     }
index dffbfe0ba39baffd31b1106d673547a9d00a1038..181aa509d2197cb72cc1dfbecf6e8a2e1d63a9d5 100644 (file)
@@ -40,7 +40,12 @@ public class Registry : Object, Resource
                memb_applets = new HashMap<string, Applet>(str_hash, str_equal);
                memb_menus = new HashMap<string, Menu>(str_hash, str_equal);
                registration_order = new ArrayList<Resource>();
-               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);
index b66acabc3d36b2cfa7cb9942c88c7f2575f89b13..7b0ab09bf866a28f2990209520aa9f110d426643 100644 (file)
@@ -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));
                        }