Use the label text 'Do not use a Moonshot identity for this service' if displaying...
[moonshot-ui.git] / src / moonshot-identity-management-view.vala
index 9d728e9..aebaec9 100644 (file)
@@ -63,7 +63,7 @@ public class IdentityManagerView : Window {
     internal IdentityManagerModel identities_manager;
     private unowned SList<IdCard>    candidates;
 
-    public GLib.Queue<IdentityRequest> request_queue;
+    private GLib.Queue<IdentityRequest> request_queue;
 
     internal CheckButton remember_identity_binding = null;
 
@@ -251,6 +251,10 @@ public class IdentityManagerView : Window {
 
         id_card.update_services_from_list(dialog.get_services());
 
+        if (dialog.clear_trust_anchor) {
+            id_card.clear_trust_anchor();
+        }
+
         return id_card;
     }
 
@@ -292,7 +296,7 @@ public class IdentityManagerView : Window {
 
     private IdCardWidget add_id_card_widget(IdCard id_card)
     {
-        var id_card_widget = new IdCardWidget(id_card);
+        var id_card_widget = new IdCardWidget(id_card, this);
         this.custom_vbox.add_id_card_widget(id_card_widget);
         id_card_widget.expanded.connect(this.widget_selected_cb);
         id_card_widget.collapsed.connect(this.widget_unselected_cb);
@@ -305,7 +309,7 @@ public class IdentityManagerView : Window {
         this.edit_button.set_sensitive(true);
         this.custom_vbox.receive_expanded_event(id_card_widget);
 
-        if (this.request_queue.length > 0)
+        if (this.selection_in_progress())
              this.send_button.set_sensitive(true);
     }
 
@@ -486,7 +490,7 @@ public class IdentityManagerView : Window {
 
     public void queue_identity_request(IdentityRequest request)
     {
-        if (this.request_queue.is_empty())
+        if (!this.selection_in_progress())
         { /* setup widgets */
             candidates = request.candidates;
             filter.refilter();
@@ -547,7 +551,7 @@ public class IdentityManagerView : Window {
 
     private void send_identity_cb(IdCard id)
     {
-        return_if_fail(request_queue.length > 0);
+        return_if_fail(this.selection_in_progress());
 
         if (!check_and_confirm_trust_anchor(id)) {
             // Allow user to pick again
@@ -560,7 +564,7 @@ public class IdentityManagerView : Window {
 
         candidates = null;
       
-        if (this.request_queue.is_empty())
+        if (!this.selection_in_progress())
         {
             candidates = null;
             clear_selection_prompts();
@@ -591,7 +595,7 @@ public class IdentityManagerView : Window {
     private bool check_and_confirm_trust_anchor(IdCard id)
     {
         if (!id.trust_anchor.is_empty() && id.trust_anchor.get_anchor_type() == TrustAnchor.TrustAnchorType.SERVER_CERT) {
-            if (get_string_setting("TrustAnchors", id.nai) != id.trust_anchor.server_cert) {
+            if (!id.trust_anchor.user_verified) {
 
                 bool ret = false;
                 int result = ResponseType.CANCEL;
@@ -601,7 +605,7 @@ public class IdentityManagerView : Window {
 
                 switch (result) {
                 case ResponseType.OK:
-                    set_string_setting("TrustAnchors", id.nai, id.trust_anchor.server_cert);
+                    id.trust_anchor.user_verified = true;
                     ret = true;
                     break;
                 default:
@@ -859,10 +863,14 @@ SUCH DAMAGE.
         add(main_vbox);
         main_vbox.show_all();
 
-        if (this.request_queue.length == 0)
+        if (!this.selection_in_progress())
             remember_identity_binding.hide();
     } 
 
+    internal bool selection_in_progress() {
+        return !this.request_queue.is_empty();
+    }
+
     private void set_atk_name_description(Widget widget, string name, string description)
     {
         var atk_widget = widget.get_accessible();