Test receiving/dumping messages
authorEnrico Zini <enrico@enricozini.org>
Sun, 28 Mar 2010 11:12:42 +0000 (12:12 +0100)
committerEnrico Zini <enrico@enricozini.org>
Sun, 28 Mar 2010 11:12:42 +0000 (12:12 +0100)
test/test-gsm-receive.vala

index 79539627662e906a00d162c704a2e03a47920657..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 sim;
     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");
+        sim = sbus.get_object(
+            "org.freesmartphone.ogsmd", 
+            "/org/freesmartphone/GSM/Device",
+            "org.freesmartphone.GSM.SIM");
 
         call = sbus.get_object(
                 "org.freesmartphone.ogsmd",
@@ -59,6 +64,7 @@ public class GSMReceive: Object //, zavai.Resource
         network.Status += on_network_Status;
         network.SignalStrength += on_network_SignalStrength;
         call.CallStatus += on_call_Status;
+       sim.IncomingStoredMessage += on_sim_IncomingStoredMessage;
     }
 
     public void shutdown()
@@ -75,6 +81,23 @@ public class GSMReceive: Object //, zavai.Resource
        });
     }
 
+    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);
@@ -424,6 +447,9 @@ static int main (string[] args) {
     // PLAY here
     var gr = new GSMReceive();
 
+       if (args.length > 1)
+               gr.dump_message(args[1].to_int());
+
        Gtk.main();
 
        // zavai.info("Shutting down")