]> ToastFreeware Gitweb - gregoa/zavai.git/blobdiff - src/gsm.vala
Notify calls and SMSes
[gregoa/zavai.git] / src / gsm.vala
index ed9c60b9c9835466b5ca34e15ed999474e59f047..de96ee389dd51c508680d0df58837fab083dcdfb 100644 (file)
@@ -138,6 +138,9 @@ public class GSM: zavai.ScriptMonitorService
 
     public signal void status_changed(string message);
     public signal void info_changed();
+    public signal void new_call(int index);
+    public signal void end_call(int index);
+    public signal void new_sms();
 
     protected void dump_table(HashTable<string, Value?> vals)
     {
@@ -342,12 +345,15 @@ stderr.printf("ACQUIRE SIG %d\n", info_signal_strength);
 
     public void on_call_status(int index, string status, HashTable<string, Value?> properties)
     {
+        bool is_new = false;
+        bool is_done = false;
         stderr.printf("CALL STATUS %d %s\n", index, status);
         dump_table(properties);
 
         CallInfo? info = lookup_call(index);
         if (info == null)
         {
+            is_new = true;
             Value? v = properties.lookup("peer");
             string title;
             if (v != null)
@@ -380,6 +386,7 @@ stderr.printf("ACQUIRE SIG %d\n", info_signal_strength);
                     calls.delete_link(i);
                     break;
                 }
+            is_done = true;
         }
 
         /*
@@ -399,6 +406,11 @@ stderr.printf("ACQUIRE SIG %d\n", info_signal_strength);
             os.system("vibrator-stop")
             os.system("ledctrl --off gta02-aux:red");
         */
+
+        if (is_new && !is_done)
+            new_call(index);
+        if (is_done)
+            end_call(index);
     }
 
     public async void sms_log_and_delete(int idx)
@@ -421,6 +433,9 @@ stderr.printf("ACQUIRE SIG %d\n", info_signal_strength);
 
         // Delete message
         yield sim.delete_message(idx);
+
+        // Notify reception of the sms
+        new_sms();
     }
 }