Added dbus config
[gregoa/zavai.git] / src / app_gps.vala
index 7f919190c21c1aa968da3fed9634e49b4ecdfd96..72545bcfd10a5f1a16a29f71643a36b9ea799449 100644 (file)
@@ -24,62 +24,6 @@ namespace zavai {
 namespace ui {
 namespace gps {
 
-/*
-class GPSOn(gtk.ToggleAction):
-    states = [_("GPS always on"), _("GPS on when needed")]
-
-    def __init__(self, registry, **kw):
-        self.state = 0
-        super(GPSOn, self).__init__("menu.main.gps.alwayson", self.states[self.state], None, None)
-
-        self.registry = registry
-        self.set_active(False)
-
-        self.connect("toggled", self.on_toggle)
-
-    def on_toggle(self, *args):
-        self.state = (self.state + 1) % len(self.states)
-        self.set_property("label", self.states[self.state])
-        if self.get_active():
-            self.start()
-        else:
-            self.stop()
-
-    def start(self):
-        self.registry.resource("gps").connect("gps", self)
-
-    def stop(self):
-        self.registry.resource("gps").disconnect("gps", self)
-
-class GPXTracer(gtk.ToggleAction):
-    states = [_("Start GPX trace"), _("Stop GPX trace")]
-
-    def __init__(self, registry, **kw):
-        self.state = 0
-        super(GPXTracer, self).__init__("menu.main.gps.gpx", self.states[self.state], None, None)
-
-        self.registry = registry
-        self.set_active(False)
-
-        self.connect("toggled", self.on_toggle)
-
-    def on_toggle(self, *args):
-        self.state = (self.state + 1) % len(self.states)
-        self.set_property("label", self.states[self.state])
-        if self.get_active():
-            self.start()
-        else:
-            self.stop()
-
-    def start(self):
-        zavai.info("GPX trace started")
-        self.registry.resource("gpx").connect("gpx", self)
-
-    def stop(self):
-        zavai.info("GPX trace ended")
-        self.registry.resource("gpx").disconnect("gpx", self)
-*/
-
 public class Waypoint : BigButton
 {
        public Waypoint()
@@ -216,164 +160,22 @@ public class GPSRequestLink : Gtk.ToggleButton
        }
 }
 
-static string[] SAT_QI_NAMES;
-
-public class SatelliteMonitor : Applet
-{
-       Gtk.ListStore store;
-       Gtk.TreeView view;
-
-       public SatelliteMonitor()
-       {
-               _label = "Satellite monitor";
-
-               store = new Gtk.ListStore(11, typeof(string), typeof(string), typeof(string),
-                             typeof(string), typeof(string), typeof(string), typeof(string),
-                             typeof(string), typeof(string), typeof(string), typeof(string));
-               view = new Gtk.TreeView();
-               view.set_model(store);
-
-               var renderer = new Gtk.CellRendererText();
-               view.insert_column_with_attributes(-1, "CH", renderer, "text", 0, null);
-               view.insert_column_with_attributes(-1, "ID", renderer, "text", 1, null);
-               view.insert_column_with_attributes(-1, "SN", renderer, "text", 2, null);
-               view.insert_column_with_attributes(-1, "ELE", renderer, "text", 3, null);
-               view.insert_column_with_attributes(-1, "AZI", renderer, "text", 4, null);
-               view.insert_column_with_attributes(-1, "Used", renderer, "text", 5, null);
-               view.insert_column_with_attributes(-1, "Diff", renderer, "text", 6, null);
-               view.insert_column_with_attributes(-1, "Alm", renderer, "text", 7, null);
-               view.insert_column_with_attributes(-1, "Eph", renderer, "text", 8, null);
-               view.insert_column_with_attributes(-1, "Bad", renderer, "text", 9, null);
-               view.insert_column_with_attributes(-1, "Status", renderer, "text", 10, null);
-               pack_start(view, true, true, 0);
-       }
-
-       public override void start()
-       {
-               zavai.gps.monitor.sat_info += on_sat_info;
-               zavai.gps.monitor.request("app.satmonitor");
-       }
-
-       public override void stop()
-       {
-               zavai.gps.monitor.release("app.satmonitor");
-               zavai.gps.monitor.sat_info -= on_sat_info;
-       }
-
-       public void on_sat_info(PtrArray< HashTable<string, Value?> > data)
-       {
-               store.clear();
-stderr.printf("CH ID SN ELE AZI Used Diff Alm Eph Bad Status\n");
-               for (int i = 0; i < data.len; ++i)
-               {
-                       HashTable<string, Value?> sv  = (HashTable<string, Value?>)data.pdata[i];
-
-                       Value v = sv.lookup("Flags");
-                       int flags = (int)v;
-
-                       v = sv.lookup("chn");
-                       int chn = (int)v;
-
-                       v = sv.lookup("SVID");
-                       int svid = (int)v;
-
-                       v = sv.lookup("CNO");
-                       int cno = (int)v;
-
-                       v = sv.lookup("Elev");
-                       int elev = (int)v;
-
-                       v = sv.lookup("Azim");
-                       int azim = (int)v;
-
-                       bool used = (flags & 0x01) != 0;
-                       bool diff = (flags & 0x02) != 0;
-                       bool almoreph = (flags & 0x04) != 0;
-                       bool eph = (flags & 0x08) != 0;
-                       bool bad = (flags & 0x10) != 0;
-                       v = sv.lookup("QI");
-                       string sqi = "Unknown";
-
-                       int qi = (int)v;
-                       if (qi < SAT_QI_NAMES.length)
-                               sqi = "%i: %s".printf(qi, SAT_QI_NAMES[qi]);
-
-                       Gtk.TreeIter iter;
-                       store.append(out iter);
-                       store.set(iter, "%2d".printf(chn),
-                                       "%2d".printf(svid),
-                                       "%2d".printf(cno),
-                                       "%3d".printf(elev),
-                                       "%3d".printf(azim),
-                                       used ? "used" : "",
-                                       diff ? "diff" : "",
-                                       almoreph ? "alm" : "",
-                                       eph ? "eph" : "",
-                                       bad ? "bad" : "", sqi);
-stderr.printf("%2d %2d %2d %3d %3d %d %d %d %d %d %s\n", chn, svid, cno, elev, azim, (int)used, (int)diff, (int)almoreph, (int)eph, (int)bad, sqi);
-               }
-    /*
-    def on_ubxdebug_packet(self, clid, length, data):
-        # In zhone it is cbUBXDebugPacket
-        #if clid == "NAV-STATUS" and data:
-        #    i = ["%s: %d" % (k, data[0][k]) for k in sorted(data[0].keys())]
-        #    zavai.info("Status:", " ".join(i))
-        ##    if data[0]['TTFF']:
-        ##        zavai.info("TTFF: %f", data[0]['TTFF']/1000.0)
-        if clid == "NAV-SVINFO":
-            self.handle_ubx_sat_data(data[1:])
-        #else:
-        #    zavai.info("gps got ubxdebug packet", clid)
-        #    zavai.info("DATA:", data)
-    */
-
-       }
-}
-
-
 public void init()
 {
-       SAT_QI_NAMES = new string[] {
-               "idle",
-               "searching",
-               "signal acquired",
-               "signal unusable",
-               "code lock",
-               "code&carrier lock",
-               "code&carrier lock",
-               "receiving data"
-       };
-
     /*
     registry.register(GPXAudioTracer(registry))
-    registry.register(GPXWaypoint(registry))
     */
 
     // Apps
-    var window_list = new SatelliteMonitor();
-    zavai.registry.register_applet("ui.gps.monitor", window_list);
-
     var menu_waypoint = new Waypoint();
     var menu_gpsrequest = new GPSRequestLink();
-               //label_on = "Stop GPX trace";
-               //label_off = "Start GPX trace";
-               //label_on = "Stop GPS monitor";
-               //label_off = "Start GPS monitor";
-               //label_on = "Stop GPS position tracking";
-               //label_off = "Start GPS position tracking";
-               //label_on = "Stop keeping GPS on";
-               //label_off = "Keep GPS on";
 
     // Menus
-    var menu_gps = new zavai.Menu("GPS");
-    //menu_gps.add_applet("app.debug.useless");
+    var menu_gps = zavai.registry.getmenu("menu.gps");
     menu_gps.add_service_toggle("gps.gpx", "Start GPX trace", "Stop GPX trace");
     menu_gps.add_applet("ui.gps.monitor");
     menu_gps.add_widget(menu_waypoint);
     menu_gps.add_widget(menu_gpsrequest);
-
-    zavai.registry.register_menu("menu.gps", menu_gps);
-    zavai.registry.getmenu("menu.main").add_applet("menu.gps");
 }
 
 }