Remove the need for an extra dialog class
[moonshot-ui.git] / src / moonshot-server.vala
index 145d6bf..e9a39f4 100644 (file)
@@ -88,6 +88,55 @@ public class MoonshotServer : Object {
 
         return false;
     }
+    
+    public async bool install_id_card (string   display_name,
+                                       string   user_name,
+                                       string   password,
+                                       string   realm,
+                                       Rule[]   rules,
+                                       string[] services,
+                                       string   ca_cert,
+                                       string   subject,
+                                       string   subject_alt,
+                                       string   server_cert)
+    {
+      IdCard idcard = new IdCard ();
+      
+      idcard.display_name = display_name;
+      idcard.username = user_name;
+      idcard.password = password;
+      idcard.issuer = realm;
+      idcard.rules = rules;
+      idcard.services = services;
+      idcard.trust_anchor.ca_cert = ca_cert;
+      idcard.trust_anchor.subject = subject;
+      idcard.trust_anchor.subject_alt = subject_alt;
+      idcard.trust_anchor.server_cert = server_cert;
+
+      /* TODO: Check if display name already exists */
+      
+      idcard.pixbuf = find_icon ("avatar-default", 48);
+      
+      var dialog = new Gtk.MessageDialog (main_window,
+                                      Gtk.DialogFlags.DESTROY_WITH_PARENT,
+                                      Gtk.MessageType.QUESTION,
+                                      Gtk.ButtonsType.YES_NO,
+                                      _("Would you like to add '%s' ID Card to the ID Card Organizer?"),
+                                      idcard.display_name);
+      
+      dialog.show_all ();
+      var ret = dialog.run ();
+      dialog.hide ();
+
+      if (ret == Gtk.ResponseType.ACCEPT)      
+      {
+        main_window.insert_id_card (idcard);
+        return true;
+      }
+      
+      return false;
+    }
+                                       
 }
 
 #elif IPC_MSRPC
@@ -168,6 +217,10 @@ public class MoonshotServer : Object {
 
             return_if_fail (nai_out != null);
             return_if_fail (password_out != null);
+            return_if_fail (server_certificate_hash != null);
+            return_if_fail (ca_certificate != null);
+            return_if_fail (subject_name_constraint != null);
+            return_if_fail (subject_alt_name_constraint != null);
 
             result = true;
         }
@@ -185,7 +238,11 @@ public class MoonshotServer : Object {
     [CCode (cname = "moonshot_get_default_identity_rpc")]
     public static void get_default_identity (Rpc.AsyncCall call,
                                              ref string nai_out,
-                                             ref string password_out)
+                                             ref string password_out,
+                                             ref string server_certificate_hash,
+                                             ref string ca_certificate,
+                                             ref string subject_name_constraint,
+                                             ref string subject_alt_name_constraint)
     {
         bool result;
 
@@ -202,14 +259,23 @@ public class MoonshotServer : Object {
 
         nai_out = "";
         password_out = "";
+        server_certificate_hash = "";
+        ca_certificate = "";
+        subject_name_constraint = "";
+        subject_alt_name_constraint = "";
 
         if (request.id_card != null)
         {
             nai_out = request.id_card.nai;
             password_out = request.id_card.password;
+            server_certificate_hash = "certificate";
 
             return_if_fail (nai_out != null);
             return_if_fail (password_out != null);
+            return_if_fail (server_certificate_hash != null);
+            return_if_fail (ca_certificate != null);
+            return_if_fail (subject_name_constraint != null);
+            return_if_fail (subject_alt_name_constraint != null);
 
             result = true;
         }