]> ToastFreeware Gitweb - gregoa/zavai.git/commitdiff
Merge branch 'master' into gregoa
authorgregor herrmann <gregoa@debian.org>
Sun, 28 Mar 2010 13:51:53 +0000 (15:51 +0200)
committergregor herrmann <gregoa@debian.org>
Sun, 28 Mar 2010 13:51:53 +0000 (15:51 +0200)
README
src/gsm.vala
test/test-gsm-receive.vala

diff --git a/README b/README
index c3dad671fe1a81ad13c05a155a2d0b5a194db125..97f1d24fc9e32609954449a1e459971a7ed57634 100644 (file)
--- a/README
+++ b/README
@@ -209,8 +209,6 @@ using vala-dbus-binding-tool:
       notify a call is there)
       (but stop ringtone if aux pressed in the meantime, to avoid annoying
       people)
-    - log incoming SMS messages
-      (first as a standalone app quick to compile)
     - pick up phone call
        - phone call applet (pushed when picking up)
           - buttons for dtmf
index e5545038cbcd197cafea0fb6eed035b4ea44fa19..ed9c60b9c9835466b5ca34e15ed999474e59f047 100644 (file)
@@ -240,6 +240,10 @@ stderr.printf("ACQUIRE SIG %d\n", info_signal_strength);
         };
 
         call.call_status += on_call_status;
+        sim.incoming_stored_message += (idx) => {
+            stderr.printf("INCOMING STORED MESSAGE %d\n", idx);
+            sms_log_and_delete(idx);
+        };
     }
 
     /// Request GPS resource
@@ -396,6 +400,28 @@ stderr.printf("ACQUIRE SIG %d\n", info_signal_strength);
             os.system("ledctrl --off gta02-aux:red");
         */
     }
+
+    public async void sms_log_and_delete(int idx)
+    {
+        // Retrieve message info
+        string state, sender, msg;
+        GLib.HashTable<string, GLib.Value?> info;
+        yield sim.retrieve_message(idx, out state, out sender, out msg, out info);
+
+        // Log message info
+        var sms_log = zavai.log.log.start("sms", msg);
+        string sms_info = "state: %s\nsender: %s\nmsg: %s\n".printf(state, sender, msg);
+        info.for_each((pk, pv) => {
+            string k = (string)pk;
+            Value? v = (Value?)pv;
+            sms_info = sms_info + "%s: %s\n".printf(k, v == null ? "(null)" : v.strdup_contents());
+        });
+        sms_log.add(sms_info);
+        zavai.log.log.end(sms_log);
+
+        // Delete message
+        yield sim.delete_message(idx);
+    }
 }
 
 public class GPRS: zavai.Service
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")