Removed commented out and legacy code
authorEnrico Zini <enrico@enricozini.org>
Mon, 17 Aug 2009 10:35:40 +0000 (11:35 +0100)
committerEnrico Zini <enrico@enricozini.org>
Mon, 17 Aug 2009 10:35:40 +0000 (11:35 +0100)
src/app.vala
src/app_gps.vala
src/gps.vala
src/zavai.vala

index 8a293a34fde6315c732099c7f55653012f026371..80e2cc3ffe18093c4cf63c3f78816c92e12fae2b 100644 (file)
@@ -203,27 +203,6 @@ public abstract class Applet : Gtk.VBox, Resource
                pack_end(button_box, false, true, 0);
                _back_link = new AppletStraightLink();
        }
-/*
-    name = gobject.property(type=str)
-    label = gobject.property(type=str)
-
-    def __init__(self, registry, name, label = None):
-        super(Applet, self).__init__()
-
-        self.zavai_registry = registry
-
-        self.props.name = name
-        if label is None:
-            self.props.label = zavai.default_label(name)
-        else:
-            self.props.label = label
-
-        self.back_link = zavai.LinkButton(registry, zavai.get_parent(name), _("Back"))
-        self.pack_end(self.back_link, False, False)
-
-    def add(self, widget):
-        self.pack_start(widget, True, True)
-*/
 
        public virtual void back()
        {
index 7f919190c21c1aa968da3fed9634e49b4ecdfd96..7b7bb12aa97d8e4eda80da74c62198731614842b 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,137 +160,10 @@ 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
@@ -355,14 +172,6 @@ public void init()
 
     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");
index c7c99745467f729033cf49a9095bccc5c67714dd..b7a8a66c56e4833277823cd8d0bbbb11829b84e1 100644 (file)
@@ -43,22 +43,7 @@ public class GPS: zavai.Service
                        "org.freesmartphone.ogpsd", 
                        "/org/freedesktop/Gypsy",
                        "org.freedesktop.Gypsy.Device");
-
-//         # see mdbus -s org.freesmartphone.ogpsd /org/freedesktop/Gypsy
-//         gps = self.bus.get_object('org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy') 
-//         self.gps = dbus.Interface(gps, "org.freedesktop.Gypsy.Device")
-//         self.gps_time = dbus.Interface(gps, "org.freedesktop.Gypsy.Time")
-//         self.gps_position = dbus.Interface(gps, 'org.freedesktop.Gypsy.Position')
-//         self.gps_ubx = dbus.Interface(gps, 'org.freesmartphone.GPS.UBX')
-//             usage.ResourceChanged += on_resourcechanged;
-       }
-
-/*
-       public void on_resourcechanged(dynamic DBus.Object pos, string name, bool state, HashTable<string, Value?> attributes)
-       {
-               zavai.log.info("RESOURCE CHANGED " + name);
        }
-*/
 
        /// Request GPS resource
        public override void start()
@@ -89,201 +74,6 @@ public class GPS: zavai.Service
        }
 }
 
-public class Monitor : zavai.Service
-{
-       static const int NAV_STATUS=0;
-       static const int NAV_SVINFO=1;
-       static const int NAV_MAX=2;
-
-       dynamic DBus.Object ubx;
-       //dynamic DBus.Object time;
-
-    public signal void sat_info(PtrArray< HashTable<string, Value?> > data);
-
-       /*
-       string[] filters = { "NAV-STATUS", "NAV_SVINFO" };
-
-       int debug_busy;
-       int debug_want;
-       int debug_have;
-       int debug_error;
-       */
-
-
-       public Monitor()
-       {
-               name = "gps.monitor";
-
-               ubx = zavai.registry.sbus.get_object(
-                       "org.freesmartphone.ogpsd",
-                       "/org/freedesktop/Gypsy",
-                       "org.freesmartphone.GPS.UBX");
-        /*
-               time = zavai.registry.sbus.get_object(
-                       "org.freesmartphone.ogpsd",
-                       "/org/freedesktop/Gypsy",
-                       "org.freedesktop.Gypsy.Time");
-
-               zavai.log.info("SETSIG1");
-               time.TimeChanged += timechanged;
-               zavai.log.info("SETSIG2");
-         */
-
-               //ubx.DebugPacket += on_ubxdebug_packet;
-
-/*
-               // This piece of machinery is taken from Zhone
-               debug_busy = -1;
-               debug_want = (1 << NAV_STATUS) | (1 << NAV_SVINFO);
-               debug_have = 0;
-               debug_error = 0;
-*/
-       }
-
-/*
-       protected void timechanged(dynamic DBus.Object pos, int t)
-       {
-               zavai.log.info("TIMECHANGED");
-       }
-*/
-
-/*
-       protected void debug_update() throws GLib.Error
-       {
-               zavai.log.debug("UPDATE");
-               if (debug_busy != -1)
-                       return;
-               zavai.log.debug("UPD1");
-               int pending = debug_want & (~debug_have) & (~debug_error);
-               if (pending == 0)
-                       return;
-               zavai.log.debug("UPD2");
-               for (int i = 0; i < NAV_MAX; ++i)
-                       if ((pending & (1<<i)) != 0)
-                       {
-                               debug_busy = i;
-                               break;
-                       }
-               zavai.log.debug("UPD3 " + filters[debug_busy]);
-
-               ubx.SetDebugFilter(
-                       filters[debug_busy],
-                       true,
-                       on_debug_reply
-//                     on_debug_error
-               );
-               zavai.log.debug("UPD4");
-       }
-
-       protected void debug_request() throws GLib.Error
-       {
-               debug_have = 0;
-               debug_update();
-       }
-
-       protected void on_debug_reply() throws GLib.Error
-       {
-               debug_have |= (1<<debug_busy);
-               debug_busy = -1;
-               debug_update();
-       }
-
-       protected void on_debug_error(string e) throws GLib.Error
-       {
-               string name = debug_busy == -1 ? "none" : filters[debug_busy];
-               zavai.log.error("error while requesting debug packet " + name + ": " + e);
-               debug_error |= (1<<debug_busy);
-               debug_busy = -1;
-               debug_update();
-       }
-*/
-
-       /*
-       protected void on_satellites_changed(satellites)
-       {
-//         zavai.info("gps monitor: satellites changed")
-//         self.debug_request()
-       }
-       */
-
-    /*
-       protected void on_ubxdebug_packet(dynamic DBus.Object ubx, string clid, int length,
-                       HashTable<string, Value?>[] data)
-       {
-               zavai.log.info("gps monitor: UBX debug packet");
-               message("ZAZA %s %d", clid, length);
-               message("ZAZA %u %lu", data.length, sizeof(HashTable<string, Value?>));
-               message("ZAZA %p %p", (void*)data.length, this);
-               message("ZAZA %p", data[0]);
-               message("ZAZA %p", data[1]);
-               message("ZAZA %p", data[2]);
-               / *
-               message("ZAZA %u", data[0].size());
-               foreach (string k in data[0].get_keys())
-                       message("ZAZA %s", k);
-               * /
-               //PtrArray< HashTable<string, Value?> >* prova = (PtrArray< HashTable<string, Value?> >)data;
-               //message("ZAZA %u", prova->len);
-               / *
-               foreach (string k in prova[0].get_keys())
-                       message("ZAZA %s", k);
-                       * /
-               / *
-               for (int i = 0; data[i] != null; ++i)
-               {
-                       zavai.log.info("ZAZA");
-               }
-               * /
-               //message("Size: %d", data.size());
-//         self.notify("satellites", clid, length, data)
-        //sat_info(data);
-       }
-    */
-
-       protected override void start()
-       {
-               if (started) return;
-
-               zavai.log.info("Starting GPS Monitor");
-               gps.request("gps.monitor");
-//         # TODO: find out how come sometimes these events are not sent
-//         self.gps.bus.add_signal_receiver(
-//             self.on_satellites_changed, 'SatellitesChanged', 'org.freedesktop.Gypsy.Satellite',
-//             'org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
-               //ubx.DebugPacket += prova;
-               //try {
-                       //ubx.SetDebugFilter("NAV-STATUS", true);
-                       //ubx.SetDebugFilter("NAV-SVINFO", true);
-                       //debug_request();
-                       base.start();
-               //} catch (GLib.Error e) {
-                       //zavai.log.error(e.message);
-               //}
-       }
-
-       protected override void stop()
-       {
-               if (!started) return;
-               zavai.log.info("Stopping GPS Monitor");
-//         self.gps.bus.remove_signal_receiver(
-//             self.on_satellites_changed, 'SatellitesChanged', 'org.freedesktop.Gypsy.Satellite',
-//             'org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
-        /*
-               try {
-                       ubx.SetDebugFilter("NAV-STATUS", false);
-                       ubx.SetDebugFilter("NAV-SVINFO", false);
-               } catch (GLib.Error e) {
-                       zavai.log.error(e.message);
-               }
-        */
-               //ubx.DebugPacket -= on_ubxdebug_packet;
-               //ubx.DebugPacket -= prova;
-               gps.release("gps.monitor");
-               base.stop();
-       }
-}
-
-
 public class Position : zavai.Service
 {
        dynamic DBus.Object position;
@@ -338,19 +128,6 @@ public class Position : zavai.Service
 // #                'org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
 // #            return False
 // #
-// #    def on_fix_status_changed(self, status):
-// #        if status not in [2, 3]: return
-// #
-// #        zavai.info("Got GPS fix")
-// #        self.bus.remove_signal_receiver(
-// #            self.on_fix_status_changed, 'FixStatusChanged', 'org.freedesktop.Gypsy.Device',
-// #            'org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
-// #
-// #        if self.waiting_for_fix:
-// #            self.waiting_for_fix()
-// #            self.waiting_for_fix = None
-// #
-// 
 // #    def start_recording(self):
 // #        if self.gps_monitor:
 // #            self.gps_monitor.stop()
@@ -540,40 +317,13 @@ public class GPX : Service
        }
 }
 
-// #    def record(self):
-// #        self.audio = Audio(self.make_waypoint)
-// #        self.gps = GPS()
-// #        # Get a fix and start recording
-// #        if not self.gps.wait_for_fix(self.start_recording):
-// #            self.gps_monitor = GPSMonitor(self.gps)
-// #            self.gps_monitor.start()
-// #
-// #    def monitor(self):
-// #        self.audio = None
-// #        self.gps = GPS()
-// #        self.gps_monitor = GPSMonitor(self.gps)
-// #        self.gps_monitor.start()
-// #
-// #
-// #    def make_waypoint(self):
-// #        if self.gpx is None:
-// #            return
-// #        if self.last_pos is None:
-// #            self.last_pos = self.gps.gps_position.GetPosition()
-// #        (fields, tstamp, lat, lon, alt) = self.last_pos
-// #        self.gpx.waypoint(tstamp, lat, lon, alt)
-// #        zavai.info("Making waypoint at %s: %f, %f, %f" % (
-// #            time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(tstamp)), lat, lon, alt))
-
 public zavai.gps.GPS gps = null;
-public zavai.gps.Monitor monitor = null;
 public zavai.gps.Position position = null;
 public zavai.gps.GPX gpx = null;
 
 public void init()
 {
        gps = new GPS();
-       monitor = new Monitor();
        position = new Position();
        gpx = new GPX();
 
index 4b89f195006de7b2b3aea21966e988ee7ed15b6b..f3ba837011d1c2fe29fe913a02333f53800397ca 100644 (file)
@@ -43,10 +43,6 @@ static int main (string[] args) {
        // # Read configuration
        // zavai.info("Loading configuration")
        // conf = zavai.Config()
-       // 
-       // # Set up dbus
-       // dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-       // dbus_system_bus = dbus.SystemBus()
 
        // Set up zavai
 
@@ -77,23 +73,6 @@ static int main (string[] args) {
 
        //zavai.ui.power.power_menu.toggle();
 
-       // # Register main factories
-       // registry.register(conf, "conf")
-       // registry.register_factory(zavai.GPX, "gpx")
-       // registry.register_factory(zavai.Audio, "audio")
-
-       // # Load plugins
-       // zavai.info("Loading plugins")
-       // for p in zavai.load_plugins(nick="zavai"):
-       //     try:
-       //         p.init(conf = conf, registry = registry)
-       //     except Exception, e:
-       //         print >>sys.stderr, "Exception caught loading plugin %s: skipping plugin" % p
-       //         print >>sys.stderr, "Exception details:"
-       //         import traceback
-       //         details = traceback.format_exc()
-       //         print >>sys.stderr, "\t"+details.rstrip().replace("\n", "\n\t")
-
        // # Shutdown the main loop on SIGINT
        // def on_kill(signum, frame):
        //     gtk.main_quit()
@@ -123,7 +102,6 @@ static int main (string[] args) {
 
        zavai.app.run();
        Gtk.main();
-       //registry.loop.run();
 
        // zavai.info("Shutting down")
        zavai.registry.shutdown();