libgps19 -> 20
[gregoa/zavai.git] / test / test-gsm-receive.vala
index 0c1a19c601775f10c3425a98926e32576581597b..a9d360475bbe0e934cf615c0ae8fe1ca33c8789e 100644 (file)
@@ -28,6 +28,7 @@ public class GSMReceive: Object //, zavai.Resource
 {
     public dynamic DBus.Object device;
     public dynamic DBus.Object network;
 {
     public dynamic DBus.Object device;
     public dynamic DBus.Object network;
+    public dynamic DBus.Object sim;
     public dynamic DBus.Object call;
 
     public GSMReceive()
     public dynamic DBus.Object call;
 
     public GSMReceive()
@@ -43,6 +44,10 @@ public class GSMReceive: Object //, zavai.Resource
             "org.freesmartphone.ogsmd", 
             "/org/freesmartphone/GSM/Device",
             "org.freesmartphone.GSM.Network");
             "org.freesmartphone.ogsmd", 
             "/org/freesmartphone/GSM/Device",
             "org.freesmartphone.GSM.Network");
+        sim = sbus.get_object(
+            "org.freesmartphone.ogsmd", 
+            "/org/freesmartphone/GSM/Device",
+            "org.freesmartphone.GSM.SIM");
 
         call = sbus.get_object(
                 "org.freesmartphone.ogsmd",
 
         call = sbus.get_object(
                 "org.freesmartphone.ogsmd",
@@ -52,10 +57,14 @@ public class GSMReceive: Object //, zavai.Resource
        stderr.printf("Antenna is %s\n", device.GetAntennaPower() ? "on" : "off");
        stderr.printf("Signal strength: %d\n", network.GetSignalStrength());
        stderr.printf("Calling identification: %s\n", network.GetCallingIdentification());
        stderr.printf("Antenna is %s\n", device.GetAntennaPower() ? "on" : "off");
        stderr.printf("Signal strength: %d\n", network.GetSignalStrength());
        stderr.printf("Calling identification: %s\n", network.GetCallingIdentification());
+       GLib.HashTable<string, GLib.Value?> status = network.GetStatus();
+       stderr.printf("Network status:\n");
+       dump_table(status);
 
         network.Status += on_network_Status;
         network.SignalStrength += on_network_SignalStrength;
         call.CallStatus += on_call_Status;
 
         network.Status += on_network_Status;
         network.SignalStrength += on_network_SignalStrength;
         call.CallStatus += on_call_Status;
+       sim.IncomingStoredMessage += on_sim_IncomingStoredMessage;
     }
 
     public void shutdown()
     }
 
     public void shutdown()
@@ -63,6 +72,32 @@ public class GSMReceive: Object //, zavai.Resource
         //zavai.gsm.gsm.release("GSMReceive");
     }
 
         //zavai.gsm.gsm.release("GSMReceive");
     }
 
+    protected void dump_table(HashTable<string, Value?> vals)
+    {
+       vals.for_each((pk, pv) => {
+               string k = (string)pk;
+               Value? v = (Value?)pv;
+               stderr.printf("K: %s V: %s\n", k, v == null ? "(null)" : v.strdup_contents());
+       });
+    }
+
+    public void on_sim_IncomingStoredMessage(DBus.Object sender, int index)
+    {
+       stderr.printf("INCOMING STORED MESSAGE %d\n", index);
+       dump_message(index);
+    }
+
+    public void dump_message(int index)
+    {
+       string state, sender, msg;
+       GLib.HashTable<string, GLib.Value?> info;
+       sim.RetrieveMessage(index, out state, out sender, out msg, out info);
+       stderr.printf("state: %s\n", state);
+       stderr.printf("sender: %s\n", sender);
+       stderr.printf("msg: %s\n", msg);
+       dump_table(info);
+    }
+
     public void on_network_SignalStrength(DBus.Object sender, int strength)
     {
         stderr.printf("SIGNAL STRENGTH %d\n", strength);
     public void on_network_SignalStrength(DBus.Object sender, int strength)
     {
         stderr.printf("SIGNAL STRENGTH %d\n", strength);
@@ -71,6 +106,7 @@ public class GSMReceive: Object //, zavai.Resource
     public void on_network_Status(DBus.Object sender, HashTable<string, Value?> status)
     {
         stderr.printf("NETWORK STATUS\n");
     public void on_network_Status(DBus.Object sender, HashTable<string, Value?> status)
     {
         stderr.printf("NETWORK STATUS\n");
+       dump_table(status);
 
         // dbg("cbNetworkStatus %s" % formatDict(status))
     }
 
         // dbg("cbNetworkStatus %s" % formatDict(status))
     }
@@ -78,6 +114,7 @@ public class GSMReceive: Object //, zavai.Resource
     public void on_call_Status(DBus.Object sender, int index, string status, HashTable<string, Value?> properties)
     {
         stderr.printf("CALL STATUS %d %s\n", index, status);
     public void on_call_Status(DBus.Object sender, int index, string status, HashTable<string, Value?> properties)
     {
         stderr.printf("CALL STATUS %d %s\n", index, status);
+       dump_table(properties);
         /*
         dbg("cbCallStatus %d, %s, %s" % (id, status, formatDict(properties)))
         self.status = status
         /*
         dbg("cbCallStatus %d, %s, %s" % (id, status, formatDict(properties)))
         self.status = status
@@ -410,6 +447,9 @@ static int main (string[] args) {
     // PLAY here
     var gr = new GSMReceive();
 
     // PLAY here
     var gr = new GSMReceive();
 
+       if (args.length > 1)
+               gr.dump_message(args[1].to_int());
+
        Gtk.main();
 
        // zavai.info("Shutting down")
        Gtk.main();
 
        // zavai.info("Shutting down")