Make the DBUS call async
authorJavier Jardón <javier.jardon@codethink.co.uk>
Mon, 9 May 2011 15:49:51 +0000 (17:49 +0200)
committerJavier Jardón <javier.jardon@codethink.co.uk>
Mon, 9 May 2011 16:32:19 +0000 (18:32 +0200)
So we wait until the user press the "send" button to reply

src/moonshot-dbus-server.vala
src/moonshot-window.vala

index 5c46297..2ad35d5 100644 (file)
@@ -14,12 +14,15 @@ public class MoonshotServer : Object {
         return counter++;
     }
 
-    public string[] get_identity (string identity,
+    public async string[] get_identity (string identity,
                                   string password,
                                   string service)
     {
         string[3] information = new string[3];
 
+        main_window.set_callback (get_identity.callback);
+        yield;
+
         var id_card = this.main_window.selected_id_card_widget.id_card;
 
         information[0] = "identity";
index 17a711a..56c7f5d 100644 (file)
@@ -21,6 +21,8 @@ class MainWindow : Window
 
     public IdCardWidget selected_id_card_widget;
 
+    private SourceFunc callback;
+
     private enum Columns
     {
         IDCARD_COL,
@@ -326,9 +328,15 @@ class MainWindow : Window
         dialog.destroy ();
     }
 
+    public void set_callback (SourceFunc callback)
+    {
+        this.callback = callback;
+    }
+
     public void send_identity_cb (IdCardWidget id_card_widget)
     {
         this.selected_id_card_widget = id_card_widget;
+        this.callback ();
     }
 
     private void label_make_bold (Label label)