From: gregor herrmann Date: Sun, 28 Mar 2010 13:51:53 +0000 (+0200) Subject: Merge branch 'master' into gregoa X-Git-Url: https://git.toastfreeware.priv.at/gregoa/zavai.git/commitdiff_plain/d045a1d60e84f619f271b5d75509e81502ea2c77?hp=f93af025e8f7497912429e38eba07037598ff8ea Merge branch 'master' into gregoa --- diff --git a/README b/README index c3dad67..97f1d24 100644 --- 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 diff --git a/src/gsm.vala b/src/gsm.vala index e554503..ed9c60b 100644 --- a/src/gsm.vala +++ b/src/gsm.vala @@ -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 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 diff --git a/test/test-gsm-receive.vala b/test/test-gsm-receive.vala index 7953962..a9d3604 100644 --- a/test/test-gsm-receive.vala +++ b/test/test-gsm-receive.vala @@ -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 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")