]> ToastFreeware Gitweb - gregoa/zavai.git/commitdiff
Show gps time when available
authorEnrico Zini <enrico@enricozini.org>
Tue, 9 Mar 2010 00:37:51 +0000 (01:37 +0100)
committerEnrico Zini <enrico@enricozini.org>
Tue, 9 Mar 2010 00:37:51 +0000 (01:37 +0100)
README
debian/control
src/clock.vala
src/gps.vala

diff --git a/README b/README
index 6b418dabedda24a1aaa1656e15066d9dbfb3a42b..e276e7c0352fcdb0eeaa04e3def1cc683c7fa3af 100644 (file)
--- a/README
+++ b/README
@@ -161,7 +161,9 @@ TODO list / wish list
     + power on/off the gps and start/stop gpsd
     + set to keep the GPS on during suspend
     + use the gpsd protocol to know if there is a fix or not
+    + time from the GPS in main clock
     - suspend/resume hooks to put the GPS into low power mode
+    - GPS FixNow mode for sleeping
  - log
     - timestamp, coordinates
     - message (structured) (json?)
index e28616b6a95d49c1b2813a5ef957c63595c9010f..d8b1bcd78e5830db062e55d5e40edc01f4525be8 100644 (file)
@@ -2,7 +2,7 @@ Source: zavai
 Section: unknown
 Priority: extra
 Maintainer: Enrico Zini <enrico@enricozini.org>
-Build-Depends: debhelper (>= 7), cmake (>= 2.6), valac, libglib2.0-dev, libdbus-glib-1-dev, libgtk2.0-dev, libwnck-dev, libomhacks-dev (>= 0.5), liblua5.1-dev
+Build-Depends: debhelper (>= 7), cmake (>= 2.6), valac, libglib2.0-dev, libdbus-glib-1-dev, libgtk2.0-dev, libwnck-dev, libomhacks-dev (>= 0.5), liblua5.1-dev, libgps-dev
 Standards-Version: 3.8.4
 Homepage: http://git.debian.org/?p=users/enrico/zavai.git
 
index f01da084c9baf571881e7a8a8d39013bdf62d5e0..374e9d8d16d9824e55852001cf7b1b12c81fa372 100644 (file)
@@ -214,7 +214,6 @@ public class Clock: zavai.Service
     protected time_t last_gps_time;
     protected time_t last_gps_time_system_time;
     protected time_t last_system_time;
-    protected dynamic DBus.Object gps_time;
     protected uint system_time_timeout;
     protected time_t last_minute;
     protected time_t chosen_time;
@@ -240,11 +239,6 @@ public class Clock: zavai.Service
         last_system_time = time_t();
         chosen_time = last_system_time;
 
-        gps_time = zavai.registry.sbus.get_object(
-                "org.freesmartphone.ogpsd",
-                "/org/freedesktop/Gypsy",
-                "org.freedesktop.Gypsy.Time");
-
         // FSO alarm system
         otimed_alarm = zavai.registry.sbus.get_object(
                 "org.freesmartphone.otimed",
@@ -286,7 +280,7 @@ public class Clock: zavai.Service
         schedule_changed(next_alarm());
     }
 
-    private void on_gps_time(dynamic DBus.Object pos, int t)
+    private void on_gps_time(uint t)
     {
         if (t == 0)
         {
@@ -331,7 +325,7 @@ public class Clock: zavai.Service
         if (started) return;
 
         system_time_timeout = Timeout.add(5000, on_system_time);
-        gps_time.TimeChanged += on_gps_time;
+        zavai.gps.gps.time_changed += on_gps_time;
         last_system_time = time_t();
         update_time();
 
@@ -343,7 +337,7 @@ public class Clock: zavai.Service
         if (!started) return;
 
         Source.remove(system_time_timeout);
-        gps_time.TimeChanged -= on_gps_time;
+        zavai.gps.gps.time_changed -= on_gps_time;
 
         base.stop();
     }
index b8c2f9999f4c9a8e29fb4667f1d779e43a2316b8..50c722f5652e5568e411d6bbf6b65553b90a0c96 100644 (file)
@@ -31,8 +31,10 @@ public class GPS: zavai.Service
     protected uint gpsfd_watch = 0;
 
     protected int old_fix_status = libgps.STATUS_NO_FIX;
+    protected uint old_time = 0;
 
     public signal void fix_status_changed(int status);
+    public signal void time_changed(uint time);
 
     public GPS()
     {
@@ -41,6 +43,7 @@ public class GPS: zavai.Service
     }
 
     public int fix_status() { return old_fix_status; }
+    public double time() { return old_time; }
 
     protected bool on_input_data(IOChannel source, IOCondition condition)
     {
@@ -55,6 +58,14 @@ public class GPS: zavai.Service
                 fix_status_changed(data.status);
                 old_fix_status = data.status;
             }
+
+            uint cur_time = (uint)data.fix.time;
+            if (data.status != libgps.STATUS_NO_FIX && old_time != cur_time)
+            {
+                time_changed(cur_time);
+                old_time = cur_time;
+            }
+
             /*
             stderr.printf("GPSMSG %d %d\n", (int)data.set, data.status);
             stderr.printf("SATUSED %d\n", data.satellites_used);
@@ -137,6 +148,12 @@ public class GPS: zavai.Service
             fix_status_changed(old_fix_status);
         }
 
+        if (old_time != 0)
+        {
+            old_time = 0;
+            time_changed(old_time);
+        }
+
         base.stop();
     }
 }