Return the info stored in the selected Id Card
authorJavier Jardón <javier.jardon@codethink.co.uk>
Mon, 9 May 2011 14:25:05 +0000 (16:25 +0200)
committerJavier Jardón <javier.jardon@codethink.co.uk>
Mon, 9 May 2011 14:25:05 +0000 (16:25 +0200)
Return the info of the id card wich send button is pressed

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

index 038d1dd..5c46297 100644 (file)
@@ -1,6 +1,12 @@
 [DBus (name = "org.janet.Moonshot")]
 public class MoonshotServer : Object {
     private int counter;
+    private MainWindow main_window;
+
+    public MoonshotServer (Gtk.Window window)
+    {
+        this.main_window = (MainWindow) window;
+    }
 
     public int ping (string msg)
     {
@@ -12,7 +18,13 @@ public class MoonshotServer : Object {
                                   string password,
                                   string service)
     {
-        string[3] information = {"identity", "password", "certificate"};
+        string[3] information = new string[3];
+
+        var id_card = this.main_window.selected_id_card_widget.id_card;
+
+        information[0] = "identity";
+        information[1] = id_card.password;
+        information[2] = "certificate";
 
         return information;
     }
index e945fdd..ea786e3 100644 (file)
@@ -15,6 +15,7 @@ class IdCardWidget : Box
     public signal void expanded ();
     public signal void remove_id ();
     public signal void details_id ();
+    public signal void send_id ();
 
     public void collapse ()
     {
@@ -45,6 +46,11 @@ class IdCardWidget : Box
        this.details_id ();
     }
 
+    private void send_button_cb ()
+    {
+       this.send_id ();
+    }
+
     private void set_idcard_color ()
     {
         var color = Gdk.Color ();
@@ -100,6 +106,7 @@ class IdCardWidget : Box
 
         delete_button.clicked.connect (delete_button_cb);
         details_button.clicked.connect (details_button_cb);
+        send_button.clicked.connect (send_button_cb);
 
         this.main_vbox = new VBox (false, 12);
         main_vbox.pack_start (table, true, true, 0);
index 7164c0a..17a711a 100644 (file)
@@ -19,6 +19,8 @@ class MainWindow : Window
 
     private MoonshotServer dbus_server;
 
+    public IdCardWidget selected_id_card_widget;
+
     private enum Columns
     {
         IDCARD_COL,
@@ -232,6 +234,7 @@ class MainWindow : Window
 
         id_card_widget.details_id.connect (details_identity_cb);
         id_card_widget.remove_id.connect (remove_identity_cb);
+        id_card_widget.send_id.connect (send_identity_cb);
         id_card_widget.expanded.connect (this.custom_vbox.receive_expanded_event);
         id_card_widget.expanded.connect (fill_details);
     }
@@ -323,6 +326,11 @@ class MainWindow : Window
         dialog.destroy ();
     }
 
+    public void send_identity_cb (IdCardWidget id_card_widget)
+    {
+        this.selected_id_card_widget = id_card_widget;
+    }
+
     private void label_make_bold (Label label)
     {
         var font_desc = new Pango.FontDescription ();
@@ -480,7 +488,7 @@ class MainWindow : Window
             uint reply = bus.request_name ("org.janet.Moonshot", (uint) 0);
             assert (reply == DBus.RequestNameReply.PRIMARY_OWNER);
 
-            this.dbus_server = new MoonshotServer ();
+            this.dbus_server = new MoonshotServer (this);
             conn.register_object ("/org/janet/moonshot", dbus_server);
 
         }