Minor formatting changes
authorDan Breslau <dbreslau@painless-security.com>
Tue, 5 Apr 2016 01:50:54 +0000 (21:50 -0400)
committerDan Breslau <dbreslau@painless-security.com>
Tue, 5 Apr 2016 02:28:10 +0000 (22:28 -0400)
15 files changed:
src/moonshot-add-dialog.vala
src/moonshot-custom-vbox.vala
src/moonshot-id.vala
src/moonshot-idcard-widget.vala
src/moonshot-identities-manager.vala
src/moonshot-identity-management-view.vala
src/moonshot-identity-manager-app.vala
src/moonshot-identity-request.vala
src/moonshot-keyring-store.vala
src/moonshot-local-flat-file-store.vala
src/moonshot-password-dialog.vala
src/moonshot-provisioning-common.vala
src/moonshot-server.vala
src/moonshot-utils.vala
src/moonshot-webp-parser.vala

index ad4f241..dacf4f9 100644 (file)
 */
 using Gtk;
 
 */
 using Gtk;
 
+
+// Defined here as workaround for emacs vala-mode indentation failure.
+#if VALA_0_12
+static const string CANCEL = Stock.CANCEL;
+#else
+static const string CANCEL = STOCK_CANCEL;
+#endif
+
+
 class AddIdentityDialog : Dialog
 {
     static const string displayname_labeltext = _("Display Name");
 class AddIdentityDialog : Dialog
 {
     static const string displayname_labeltext = _("Display Name");
@@ -54,84 +63,79 @@ class AddIdentityDialog : Dialog
     }
 
     public string issuer {
     }
 
     public string issuer {
-        get { return issuer_entry.get_text (); }
+        get { return issuer_entry.get_text(); }
     }
 
     }
 
-     public string username {
-        get { return username_entry.get_text (); }
+    public string username {
+        get { return username_entry.get_text(); }
     }
 
     public string password {
     }
 
     public string password {
-        get { return password_entry.get_text (); }
+        get { return password_entry.get_text(); }
     }
 
     public bool store_password {
         get { return remember_checkbutton.active; }
     }
 
     }
 
     public bool store_password {
         get { return remember_checkbutton.active; }
     }
 
-    public AddIdentityDialog ()
+    public AddIdentityDialog()
     {
     {
-        this.set_title (_("Add ID Card"));
-        this.set_modal (true);
-
-        this.add_buttons (_("Add ID Card"), ResponseType.OK,
-#if VALA_0_12
-                          Stock.CANCEL, ResponseType.CANCEL);
-#else
-                          STOCK_CANCEL, ResponseType.CANCEL);
-#endif
+        this.set_title(_("Add ID Card"));
+        this.set_modal(true);
 
 
-        var content_area = this.get_content_area ();
-        ((Box) content_area).set_spacing (12);
+        this.add_buttons(_("Add ID Card"), ResponseType.OK,
+                         CANCEL, ResponseType.CANCEL);
+        var content_area = this.get_content_area();
+        ((Box) content_area).set_spacing(12);
         
         
-        displayname_label = new Label (@"$displayname_labeltext:");
-        displayname_label.set_alignment (1, (float) 0.5);
-        displayname_entry = new Entry ();
-        issuer_label = new Label (@"$issuer_labeltext:");
-        issuer_label.set_alignment (1, (float) 0.5);
-        this.issuer_entry = new Entry ();
-        username_label = new Label (@"$username_labeltext:");
-        username_label.set_alignment (1, (float) 0.5);
-        this.username_entry = new Entry ();
-        password_label = new Label (@"$password_labeltext:");
-        password_label.set_alignment (1, (float) 0.5);
-        this.password_entry = new Entry ();
-        password_entry.set_invisible_char ('*');
-        password_entry.set_visibility (false);
-        this.remember_checkbutton = new CheckButton.with_label (_("Remember password"));
+        displayname_label = new Label(@"$displayname_labeltext:");
+        displayname_label.set_alignment(1,(float) 0.5);
+        displayname_entry = new Entry();
+        issuer_label = new Label(@"$issuer_labeltext:");
+        issuer_label.set_alignment(1,(float) 0.5);
+        this.issuer_entry = new Entry();
+        username_label = new Label(@"$username_labeltext:");
+        username_label.set_alignment(1,(float) 0.5);
+        this.username_entry = new Entry();
+        password_label = new Label(@"$password_labeltext:");
+        password_label.set_alignment(1,(float) 0.5);
+        this.password_entry = new Entry();
+        password_entry.set_invisible_char('*');
+        password_entry.set_visibility(false);
+        this.remember_checkbutton = new CheckButton.with_label(_("Remember password"));
         this.message_label = new Label("");
         message_label.set_visible(false);
 
         this.message_label = new Label("");
         message_label.set_visible(false);
 
-        set_atk_relation (displayname_label, displayname_entry, Atk.RelationType.LABEL_FOR);
-        set_atk_relation (issuer_label, issuer_entry, Atk.RelationType.LABEL_FOR);
-        set_atk_relation (username_label, username_entry, Atk.RelationType.LABEL_FOR);
-        set_atk_relation (password_entry, password_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation(displayname_label, displayname_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation(issuer_label, issuer_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation(username_label, username_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation(password_entry, password_entry, Atk.RelationType.LABEL_FOR);
 
 
-        var table = new Table (6, 2, false);
-        table.set_col_spacings (10);
-        table.set_row_spacings (10);
+        var table = new Table(6, 2, false);
+        table.set_col_spacings(10);
+        table.set_row_spacings(10);
         
         
-        table.attach_defaults (message_label, 0, 2, 0, 1);
-        table.attach_defaults (displayname_label, 0, 1, 1, 2);
-        table.attach_defaults (displayname_entry, 1, 2, 1, 2);
-        table.attach_defaults (issuer_label, 0, 1, 2, 3);
-        table.attach_defaults (issuer_entry, 1, 2, 2, 3);
-        table.attach_defaults (username_label, 0, 1, 3, 4);
-        table.attach_defaults (username_entry, 1, 2, 3, 4);
-        table.attach_defaults (password_label, 0, 1, 4, 5);
-        table.attach_defaults (password_entry, 1, 2, 4, 5);
-        table.attach_defaults (remember_checkbutton,  1, 2, 5, 6);
+        table.attach_defaults(message_label, 0, 2, 0, 1);
+        table.attach_defaults(displayname_label, 0, 1, 1, 2);
+        table.attach_defaults(displayname_entry, 1, 2, 1, 2);
+        table.attach_defaults(issuer_label, 0, 1, 2, 3);
+        table.attach_defaults(issuer_entry, 1, 2, 2, 3);
+        table.attach_defaults(username_label, 0, 1, 3, 4);
+        table.attach_defaults(username_entry, 1, 2, 3, 4);
+        table.attach_defaults(password_label, 0, 1, 4, 5);
+        table.attach_defaults(password_entry, 1, 2, 4, 5);
+        table.attach_defaults(remember_checkbutton,  1, 2, 5, 6);
 
         this.response.connect(on_response);
 
         this.response.connect(on_response);
-        var vbox = new VBox (false, 0);
-        vbox.set_border_width (6);
-        vbox.pack_start (table, false, false, 0);
+        var vbox = new VBox(false, 0);
+        vbox.set_border_width(6);
+        vbox.pack_start(table, false, false, 0);
 
 
-        ((Container) content_area).add (vbox);
+        ((Container) content_area).add(vbox);
 
 
-        this.set_border_width (6);
-        this.set_resizable (false);
-        this.show_all ();
+        this.set_border_width(6);
+        this.set_resizable(false);
+        this.show_all();
     }
 
     private static string update_preamble(string preamble)
     }
 
     private static string update_preamble(string preamble)
@@ -179,7 +183,7 @@ class AddIdentityDialog : Dialog
         return true;
     }
 
         return true;
     }
 
-    private void on_response (Dialog source, int response_id)
+    private void on_response(Dialog source, int response_id)
     {
         switch (response_id) {
         case ResponseType.OK:
     {
         switch (response_id) {
         case ResponseType.OK:
@@ -191,11 +195,11 @@ class AddIdentityDialog : Dialog
         }
     }
 
         }
     }
 
-    private void set_atk_relation (Widget widget, Widget target_widget, Atk.RelationType relationship)
+    private void set_atk_relation(Widget widget, Widget target_widget, Atk.RelationType relationship)
     {
     {
-        var atk_widget = widget.get_accessible ();
-        var atk_target_widget = target_widget.get_accessible ();
+        var atk_widget = widget.get_accessible();
+        var atk_target_widget = target_widget.get_accessible();
 
 
-        atk_widget.add_relationship (relationship, atk_target_widget);
+        atk_widget.add_relationship(relationship, atk_target_widget);
     }
 }
     }
 }
index 13a6db3..6d48e14 100644 (file)
@@ -36,35 +36,35 @@ class CustomVBox : VBox
     public IdCardWidget current_idcard { get; set; default = null; }
     private IdentityManagerView main_window; 
 
     public IdCardWidget current_idcard { get; set; default = null; }
     private IdentityManagerView main_window; 
 
-    public CustomVBox (IdentityManagerView window, bool homogeneous, int spacing)
+    public CustomVBox(IdentityManagerView window, bool homogeneous, int spacing)
     {
         main_window = window;
     {
         main_window = window;
-        set_homogeneous (homogeneous);
-        set_spacing (spacing);
+        set_homogeneous(homogeneous);
+        set_spacing(spacing);
     }
 
     }
 
-    public void receive_expanded_event (IdCardWidget id_card_widget)
+    public void receive_expanded_event(IdCardWidget id_card_widget)
     {
     {
-        var list = get_children ();
+        var list = get_children();
         foreach (Widget id_card in list)
         {
             if (id_card != id_card_widget)
         foreach (Widget id_card in list)
         {
             if (id_card != id_card_widget)
-                ((IdCardWidget) id_card).collapse ();
+                ((IdCardWidget) id_card).collapse();
         }
         current_idcard = id_card_widget;
         
         if (current_idcard != null && main_window.request_queue.length > 0)
         }
         current_idcard = id_card_widget;
         
         if (current_idcard != null && main_window.request_queue.length > 0)
-            current_idcard.send_button.set_sensitive (true);
+            current_idcard.send_button.set_sensitive(true);
         check_resize();
     }
 
         check_resize();
     }
 
-    public void add_id_card_widget (IdCardWidget id_card_widget)
+    public void add_id_card_widget(IdCardWidget id_card_widget)
     {
     {
-        pack_start (id_card_widget, false, false);
+        pack_start(id_card_widget, false, false);
     }
 
     }
 
-    public void remove_id_card_widget (IdCardWidget id_card_widget)
+    public void remove_id_card_widget(IdCardWidget id_card_widget)
     {
     {
-        remove (id_card_widget);
+        remove(id_card_widget);
     }
 }
     }
 }
index 2e0af57..27d1c8b 100644 (file)
 */
 public class TrustAnchor : Object
 {
 */
 public class TrustAnchor : Object
 {
-  public string ca_cert {get; set; default = "";}
-  public string subject {get; set; default = "";}
-  public string subject_alt  {get; set; default = "";}
-  public string server_cert  {get; set; default = "";}
-  public int Compare(TrustAnchor other)
-  {
-    if (this.ca_cert != other.ca_cert)
-      return 1;
-    if (this.subject != other.subject)
-      return 1;
-    if (this.subject_alt != other.subject_alt)
-      return 1;
-    if (this.server_cert != other.server_cert)
-      return 1;
-    return 0;
-  }
+    public string ca_cert {get; set; default = "";}
+    public string subject {get; set; default = "";}
+    public string subject_alt  {get; set; default = "";}
+    public string server_cert  {get; set; default = "";}
+    public int Compare(TrustAnchor other)
+    {
+        if (this.ca_cert != other.ca_cert)
+            return 1;
+        if (this.subject != other.subject)
+            return 1;
+        if (this.subject_alt != other.subject_alt)
+            return 1;
+        if (this.server_cert != other.server_cert)
+            return 1;
+        return 0;
+    }
 }
 
 public struct Rule
 {
 }
 
 public struct Rule
 {
-  public string pattern;
-  public string always_confirm;
-  public int Compare(Rule other) {
-    if (this.pattern != other.pattern)
-      return 1;
-    if (this.always_confirm != other.always_confirm)
-      return 1;
-    return 0;
-  }
+    public string pattern;
+    public string always_confirm;
+    public int Compare(Rule other) {
+        if (this.pattern != other.pattern)
+            return 1;
+        if (this.always_confirm != other.always_confirm)
+            return 1;
+        return 0;
+    }
 }
 
 public class IdCard : Object
 {
 }
 
 public class IdCard : Object
 {
-  public const string NO_IDENTITY = "No Identity";
+    public const string NO_IDENTITY = "No Identity";
 
 
-  private string _nai;
+    private string _nai;
   
   
-  public string display_name { get; set; default = ""; }
+    public string display_name { get; set; default = ""; }
   
   
-  public string username { get; set; default = ""; }
-#if GNOME_KEYRING
-  private unowned string _password;
-  public string password {
-    get {
-      return (_password!=null) ? _password : "";
+    public string username { get; set; default = ""; }
+    #if GNOME_KEYRING
+        private unowned string _password;
+    public string password {
+        get {
+            return (_password!=null) ? _password : "";
+        }
+        set {
+            if (_password != null) {
+                GnomeKeyring.memory_free((void *)_password);
+                _password = null;
+            }
+            if (value != null)
+                _password = GnomeKeyring.memory_strdup(value); 
+        }
     }
     }
-    set {
-      if (_password != null) {
-        GnomeKeyring.memory_free((void *)_password);
-        _password = null;
-      }
-      if (value != null)
-        _password = GnomeKeyring.memory_strdup(value); 
-    }
-  }
-#else
-  public string password { get; set; default = null; }
-#endif
+    #else
+        public string password { get; set; default = null; }
+    #endif
 
 
-  public string issuer { get; set; default = ""; }
+        public string issuer { get; set; default = ""; }
   
   
-  public Rule[] rules {get; set; default = {};}
-  public string[] services { get; set; default = {}; }
-  public bool temporary {get; set; default = false; }
+    public Rule[] rules {get; set; default = {};}
+    public string[] services { get; set; default = {}; }
+    public bool temporary {get; set; default = false; }
 
 
-  public TrustAnchor trust_anchor  { get; set; default = new TrustAnchor (); }
+    public TrustAnchor trust_anchor  { get; set; default = new TrustAnchor (); }
   
   
-  public unowned string nai { get {  _nai = username + "@" + issuer; return _nai;}}
-
-  public bool store_password { get; set; default = false; }
-
-  public bool IsNoIdentity() 
-  {
-    return (display_name == NO_IDENTITY);
-  }
-
-  public enum DiffFlags {
-    DISPLAY_NAME,
-    USERNAME,
-    PASSWORD,
-    ISSUER,
-    RULES,
-    SERVICES,
-    TRUST_ANCHOR;
-  }
-
-  public int Compare(IdCard other)
-  {
-    int diff = 0;
-    if (this.display_name != other.display_name)
-      diff |= 1 << DiffFlags.DISPLAY_NAME;
-    if (this.username != other.username)
-      diff |= 1 << DiffFlags.USERNAME;
-    if (this.password != other.password)
-      diff |= 1 << DiffFlags.PASSWORD;
-    if (this.issuer != other.issuer)
-      diff |= 1 << DiffFlags.ISSUER;
-    if (CompareRules(this.rules, other.rules)!=0)
-      diff |= 1 << DiffFlags.RULES;
-    if (CompareStringArray(this.services, other.services)!=0)
-      diff |= 1 << DiffFlags.SERVICES;
-    if (this.trust_anchor.Compare(other.trust_anchor)!=0)
-      diff |= 1 << DiffFlags.TRUST_ANCHOR;
-    stdout.printf("Diff Flags: %x\n", diff);
-    return diff;
-  }
-
-  public static IdCard NewNoIdentity() 
-  { 
-    IdCard card = new IdCard();
-    card.display_name = NO_IDENTITY;
-    return card;
-  }
-
-  ~IdCard() {
-    password = null;
-  }
+    public unowned string nai { get {  _nai = username + "@" + issuer; return _nai;}}
+
+    public bool store_password { get; set; default = false; }
+
+    public bool IsNoIdentity() 
+    {
+        return (display_name == NO_IDENTITY);
+    }
+
+    public enum DiffFlags {
+        DISPLAY_NAME,
+        USERNAME,
+        PASSWORD,
+        ISSUER,
+        RULES,
+        SERVICES,
+        TRUST_ANCHOR;
+    }
+
+    public int Compare(IdCard other)
+    {
+        int diff = 0;
+        if (this.display_name != other.display_name)
+            diff |= 1 << DiffFlags.DISPLAY_NAME;
+
+        if (this.username != other.username)
+            diff |= 1 << DiffFlags.USERNAME;
+
+        if (this.password != other.password)
+            diff |= 1 << DiffFlags.PASSWORD;
+
+        if (this.issuer != other.issuer)
+            diff |= 1 << DiffFlags.ISSUER;
+
+        if (CompareRules(this.rules, other.rules)!=0)
+            diff |= 1 << DiffFlags.RULES;
+
+        if (CompareStringArray(this.services, other.services)!=0)
+            diff |= 1 << DiffFlags.SERVICES;
+
+        if (this.trust_anchor.Compare(other.trust_anchor)!=0)
+            diff |= 1 << DiffFlags.TRUST_ANCHOR;
+
+        stdout.printf("Diff Flags: %x\n", diff);
+        return diff;
+    }
+
+    public static IdCard NewNoIdentity() 
+    { 
+        IdCard card = new IdCard();
+        card.display_name = NO_IDENTITY;
+        return card;
+    }
+
+    ~IdCard() {
+        password = null;
+    }
 }
 
 public int CompareRules(Rule[] a, Rule[] b)
 {
 }
 
 public int CompareRules(Rule[] a, Rule[] b)
 {
-  if (a.length != b.length)
-    return 1;
-  for (int i=0; i<a.length; i++) {
-    if (a[i].Compare(b[i]) != 0)
-      return 1;
-  }
-  return 0;
+    if (a.length != b.length) {
+        return 1;
+    }
+
+    for (int i = 0; i < a.length; i++) {
+        if (a[i].Compare(b[i]) != 0) {
+            return 1;
+        }
+    }
+    return 0;
 }
 
 public int CompareStringArray(string[] a, string [] b)
 {
 }
 
 public int CompareStringArray(string[] a, string [] b)
 {
-  if (a.length != b.length)
-    return 1;
-  for (int i=0; i<a.length; i++) {
-    if (a[i] != b[i])
-      return 1;
-  }
-  return 0;
+    if (a.length != b.length) {
+        return 1;
+    }
+
+    for (int i = 0; i < a.length; i++) {
+        if (a[i] != b[i]) {
+            return 1;
+        }
+    }
+    return 0;
 }
 }
index 4f9e43e..6a9c8e8 100644 (file)
@@ -45,56 +45,56 @@ class IdCardWidget : Box
     
     private Label label;
 
     
     private Label label;
 
-    public signal void expanded ();
-    public signal void remove_id ();
-    public signal void details_id ();
-    public signal void send_id ();
+    public signal void expanded();
+    public signal void remove_id();
+    public signal void details_id();
+    public signal void send_id();
 
 
-    public void collapse ()
+    public void collapse()
     {
     {
-        this.hbutton_box.set_visible (false);
+        this.hbutton_box.set_visible(false);
 
 
-        set_idcard_color ();
+        set_idcard_color();
     }
 
     }
 
-    public void expand ()
+    public void expand()
     {
     {
-        this.hbutton_box.set_visible (true);
+        this.hbutton_box.set_visible(true);
 
 
-        set_idcard_color ();
-        this.expanded ();
+        set_idcard_color();
+        this.expanded();
     }
 
     }
 
-    private bool button_press_cb ()
+    private bool button_press_cb()
     {
     {
-        if (hbutton_box.get_visible ())
-            collapse ();
+        if (hbutton_box.get_visible())
+            collapse();
         else
         else
-            expand ();
+            expand();
 
         return false;
     }
 
 
         return false;
     }
 
-    private void delete_button_cb ()
+    private void delete_button_cb()
     {
     {
-       this.remove_id ();
+        this.remove_id();
     }
 
     }
 
-    private void details_button_cb ()
+    private void details_button_cb()
     {
     {
-       this.details_id ();
+        this.details_id();
     }
 
     }
 
-    private void send_button_cb ()
+    private void send_button_cb()
     {
     {
-       this.send_id ();
+        this.send_id();
     }
 
     }
 
-    private void set_idcard_color ()
+    private void set_idcard_color()
     {
     {
-        var color = Gdk.Color ();
+        var color = Gdk.Color();
 
 
-        if (hbutton_box.get_visible () == false)
+        if (hbutton_box.get_visible() == false)
         {
             color.red = 65535;
             color.green = 65535;
         {
             color.red = 65535;
             color.green = 65535;
@@ -106,80 +106,80 @@ class IdCardWidget : Box
             color.green = 33333;
             color.blue = 60000;
         }
             color.green = 33333;
             color.blue = 60000;
         }
-        var state = this.get_state ();
-        this.event_box.modify_bg (state, color);
+        var state = this.get_state();
+        this.event_box.modify_bg(state, color);
     }
     
     public void
     }
     
     public void
-    update_id_card_label ()
+    update_id_card_label()
     {
         string services_text = "";
 
     {
         string services_text = "";
 
-        var display_name = Markup.printf_escaped ("<big>%s</big>", this.id_card.display_name);
-        for (int i=0; i<id_card.services.length; i++)
+        var display_name = Markup.printf_escaped("<big>%s</big>", this.id_card.display_name);
+        for (int i = 0; i < id_card.services.length; i++)
         {
             var service = id_card.services[i];
             
             if (i == (id_card.services.length - 1))
         {
             var service = id_card.services[i];
             
             if (i == (id_card.services.length - 1))
-              services_text = services_text + Markup.printf_escaped ("<i>%s</i>", service);
+                services_text = services_text + Markup.printf_escaped("<i>%s</i>", service);
             else
             else
-              services_text = services_text + Markup.printf_escaped ("<i>%s, </i>", service);
+                services_text = services_text + Markup.printf_escaped("<i>%s, </i>", service);
         }
         }
-        label.set_markup (display_name + "\n" + services_text);
+        label.set_markup(display_name + "\n" + services_text);
     }
 
     }
 
-    public IdCardWidget (IdCard id_card)
+    public IdCardWidget(IdCard id_card)
     {
         this.id_card = id_card;
 
     {
         this.id_card = id_card;
 
-        var image = new Image.from_pixbuf (get_pixbuf(id_card));
+        var image = new Image.from_pixbuf(get_pixbuf(id_card));
 
 
-        label = new Label (null);
-        label.set_alignment ((float) 0, (float) 0.5);
-        label.set_ellipsize (Pango.EllipsizeMode.END);
+        label = new Label(null);
+        label.set_alignment((float) 0, (float) 0.5);
+        label.set_ellipsize(Pango.EllipsizeMode.END);
         update_id_card_label();
 
         update_id_card_label();
 
-        table = new Gtk.HBox (false, 6);
-        table.pack_start (image, false, false, 0);
-        table.pack_start (label, true, true, 0);
-
-        this.delete_button = new Button.with_label (_("Delete"));
-        this.details_button = new Button.with_label (_("View details"));
-        this.send_button = new Button.with_label (_("Send"));
-        set_atk_name_description (delete_button, _("Delete"), _("Delete this ID Card"));
-        set_atk_name_description (details_button, _("Details"), _("View the details of this ID Card"));
-        set_atk_name_description (send_button, _("Send"), _("Send this ID Card"));
-        this.hbutton_box = new HButtonBox ();
-        hbutton_box.pack_end (delete_button);
-        hbutton_box.pack_end (details_button);
-        hbutton_box.pack_end (send_button);
-        send_button.set_sensitive (false);
-
-        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);
-        main_vbox.pack_start (hbutton_box, false, false, 0);
-        main_vbox.set_border_width (12);
-
-        event_box = new EventBox ();
-        event_box.add (main_vbox);
-        event_box.button_press_event.connect (button_press_cb);
-        this.pack_start (event_box, true, true);
-
-        this.show_all ();
-        this.hbutton_box.hide ();
-
-        set_idcard_color ();
+        table = new Gtk.HBox(false, 6);
+        table.pack_start(image, false, false, 0);
+        table.pack_start(label, true, true, 0);
+
+        this.delete_button = new Button.with_label(_("Delete"));
+        this.details_button = new Button.with_label(_("View details"));
+        this.send_button = new Button.with_label(_("Send"));
+        set_atk_name_description(delete_button, _("Delete"), _("Delete this ID Card"));
+        set_atk_name_description(details_button, _("Details"), _("View the details of this ID Card"));
+        set_atk_name_description(send_button, _("Send"), _("Send this ID Card"));
+        this.hbutton_box = new HButtonBox();
+        hbutton_box.pack_end(delete_button);
+        hbutton_box.pack_end(details_button);
+        hbutton_box.pack_end(send_button);
+        send_button.set_sensitive(false);
+
+        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);
+        main_vbox.pack_start(hbutton_box, false, false, 0);
+        main_vbox.set_border_width(12);
+
+        event_box = new EventBox();
+        event_box.add(main_vbox);
+        event_box.button_press_event.connect(button_press_cb);
+        this.pack_start(event_box, true, true);
+
+        this.show_all();
+        this.hbutton_box.hide();
+
+        set_idcard_color();
     }
 
     }
 
-    private void set_atk_name_description (Widget widget, string name, string description)
+    private void set_atk_name_description(Widget widget, string name, string description)
     {
     {
-       var atk_widget = widget.get_accessible ();
+        var atk_widget = widget.get_accessible();
 
 
-       atk_widget.set_name (name);
-       atk_widget.set_description (description);
+        atk_widget.set_name(name);
+        atk_widget.set_description(description);
     }
 }
     }
 }
index 292fb0e..182f2d6 100644 (file)
@@ -90,52 +90,52 @@ public class IdentityManagerModel : Object {
     private PasswordHashTable password_table;
     private IIdentityCardStore store;
     public LinkedList<IdCard>  get_card_list() {
     private PasswordHashTable password_table;
     private IIdentityCardStore store;
     public LinkedList<IdCard>  get_card_list() {
-         var identities = store.get_card_list();
-         identities.sort( (a, b) => {
-             IdCard id_a = (IdCard )a;
-             IdCard id_b = (IdCard )b;
-             if (id_a.IsNoIdentity() && !id_b.IsNoIdentity()) {
-                return -1;
-             } else if (id_b.IsNoIdentity() && !id_a.IsNoIdentity()) {
-                return 1;
-             }
-             return strcmp(id_a.display_name, id_b.display_name);
-         });
-         if (identities.is_empty || !identities[0].IsNoIdentity())
-             identities.insert(0, IdCard.NewNoIdentity());
-         foreach (IdCard id_card in identities) {
-             if (!id_card.store_password) {
-                 password_table.RetrievePassword(id_card, store);
-             }
-         }
-         return identities;
+        var identities = store.get_card_list();
+        identities.sort((a, b) => {
+                IdCard id_a = (IdCard )a;
+                IdCard id_b = (IdCard )b;
+                if (id_a.IsNoIdentity() && !id_b.IsNoIdentity()) {
+                    return -1;
+                } else if (id_b.IsNoIdentity() && !id_a.IsNoIdentity()) {
+                    return 1;
+                }
+                return strcmp(id_a.display_name, id_b.display_name);
+            });
+        if (identities.is_empty || !identities[0].IsNoIdentity())
+            identities.insert(0, IdCard.NewNoIdentity());
+        foreach (IdCard id_card in identities) {
+            if (!id_card.store_password) {
+                password_table.RetrievePassword(id_card, store);
+            }
+        }
+        return identities;
     }
     public signal void card_list_changed();
 
     /* This method finds a valid display name */
     }
     public signal void card_list_changed();
 
     /* This method finds a valid display name */
-    public bool display_name_is_valid (string name,
-                                       out string? candidate)
+    public bool display_name_is_valid(string name,
+                                      out string? candidate)
     {
         if (&candidate != null)
     {
         if (&candidate != null)
-          candidate = null;
+            candidate = null;
         foreach (IdCard id_card in this.store.get_card_list())
         {
         foreach (IdCard id_card in this.store.get_card_list())
         {
-          if (id_card.display_name == name)
-          {
-            if (&candidate != null)
+            if (id_card.display_name == name)
             {
             {
-              for (int i=0; i<1000; i++)
-              {
-                string tmp = "%s %d".printf (name, i);
-                if (display_name_is_valid (tmp, null))
+                if (&candidate != null)
                 {
                 {
-                  candidate = tmp;
-                  break;
+                    for (int i = 0; i < 1000; i++)
+                    {
+                        string tmp = "%s %d".printf(name, i);
+                        if (display_name_is_valid(tmp, null))
+                        {
+                            candidate = tmp;
+                            break;
+                        }
+                    }
                 }
                 }
-              }
+                return false;
             }
             }
-            return false;
-          }
         }
         return true;
     }
         }
         return true;
     }
@@ -145,16 +145,16 @@ public class IdentityManagerModel : Object {
         bool duplicate_found = false;
         bool found = false;
         do {
         bool duplicate_found = false;
         bool found = false;
         do {
-           var cards = this.store.get_card_list();
-           found = false;
-           foreach (IdCard id_card in cards) {
-               if ((card != id_card) && (id_card.nai == card.nai)) {
-                  stdout.printf("removing duplicate id for '%s'\n", card.nai);
-                  remove_card_internal(id_card);
-                  found = duplicate_found = true;
-                  break;
-               }
-           }
+            var cards = this.store.get_card_list();
+            found = false;
+            foreach (IdCard id_card in cards) {
+                if ((card != id_card) && (id_card.nai == card.nai)) {
+                    stdout.printf("removing duplicate id for '%s'\n", card.nai);
+                    remove_card_internal(id_card);
+                    found = duplicate_found = true;
+                    break;
+                }
+            }
         } while (found);
         return duplicate_found;
     }
         } while (found);
         return duplicate_found;
     }
@@ -190,9 +190,9 @@ public class IdentityManagerModel : Object {
 
         remove_duplicates(card);
 
 
         remove_duplicates(card);
 
-        if (!display_name_is_valid (card.display_name, out candidate))
+        if (!display_name_is_valid(card.display_name, out candidate))
         {
         {
-          card.display_name = candidate;
+            card.display_name = candidate;
         }
 
         if (!card.store_password)
         }
 
         if (!card.store_password)
@@ -200,9 +200,9 @@ public class IdentityManagerModel : Object {
         store.add_card(card);
         set_store_type(saved_store_type);
         card_list_changed();
         store.add_card(card);
         set_store_type(saved_store_type);
         card_list_changed();
-     }
+    }
 
 
-     public IdCard update_card(IdCard card) {
+    public IdCard update_card(IdCard card) {
         IdCard retval;
         if (card.temporary) {
             retval = card;
         IdCard retval;
         if (card.temporary) {
             retval = card;
@@ -216,55 +216,55 @@ public class IdentityManagerModel : Object {
         retval = store.update_card(card);
         card_list_changed();
         return retval;
         retval = store.update_card(card);
         card_list_changed();
         return retval;
-     }
+    }
 
 
-     private bool remove_card_internal(IdCard card) {
-         if (card.temporary)
-             return false;
-         password_table.RemovePassword(card, store);
-         return store.remove_card(card);
-     }
+    private bool remove_card_internal(IdCard card) {
+        if (card.temporary)
+            return false;
+        password_table.RemovePassword(card, store);
+        return store.remove_card(card);
+    }
 
 
-     public bool remove_card(IdCard card) {
-         if (remove_card_internal(card)) {
+    public bool remove_card(IdCard card) {
+        if (remove_card_internal(card)) {
             card_list_changed();
             return true;
             card_list_changed();
             return true;
-         }
-         return false;
-     }
+        }
+        return false;
+    }
 
 
-     public void set_store_type(IIdentityCardStore.StoreType type) {
-         if ((store != null) && (store.get_store_type() == type))
-             return;
-         switch (type) {
-#if GNOME_KEYRING
-             case IIdentityCardStore.StoreType.KEYRING:
-                 store = new KeyringStore();
-                 break;
-#endif
-             case IIdentityCardStore.StoreType.FLAT_FILE:
-             default:
-                 store = new LocalFlatFileStore();
-                 break;
-         }
-     }
+    public void set_store_type(IIdentityCardStore.StoreType type) {
+        if ((store != null) && (store.get_store_type() == type))
+            return;
+        switch (type) {
+            #if GNOME_KEYRING
+        case IIdentityCardStore.StoreType.KEYRING:
+            store = new KeyringStore();
+            break;
+            #endif
+        case IIdentityCardStore.StoreType.FLAT_FILE:
+        default:
+            store = new LocalFlatFileStore();
+            break;
+        }
+    }
 
 
-     public IIdentityCardStore.StoreType get_store_type() {
-         return store.get_store_type();
-     }
+    public IIdentityCardStore.StoreType get_store_type() {
+        return store.get_store_type();
+    }
 
 
-     public bool HasNonTrivialIdentities() {
-         foreach (IdCard card in this.store.get_card_list()) {
-             // The 'NoIdentity' card is non-trivial if it has services or rules.
-             // All other cards are automatically non-trivial.
-             if ((!card.IsNoIdentity()) || 
-                 (card.services.length > 0) ||
-                 (card.rules.length > 0)) {
-                 return true;
-             }
-         }
-         return false;
-     }
+    public bool HasNonTrivialIdentities() {
+        foreach (IdCard card in this.store.get_card_list()) {
+            // The 'NoIdentity' card is non-trivial if it has services or rules.
+            // All other cards are automatically non-trivial.
+            if ((!card.IsNoIdentity()) || 
+                (card.services.length > 0) ||
+                (card.rules.length > 0)) {
+                return true;
+            }
+        }
+        return false;
+    }
 
 
     private IdentityManagerApp parent;
 
 
     private IdentityManagerApp parent;
index 2088e49..4c343a9 100644 (file)
@@ -36,9 +36,9 @@ public class IdentityManagerView : Window {
     private const int WINDOW_WIDTH = 400;
     private const int WINDOW_HEIGHT = 500;
     protected IdentityManagerApp parent_app;
     private const int WINDOW_WIDTH = 400;
     private const int WINDOW_HEIGHT = 500;
     protected IdentityManagerApp parent_app;
-#if OS_MACOS
-       public OSXApplication osxApp;
-#endif
+    #if OS_MACOS
+        public OSXApplication osxApp;
+    #endif
     private UIManager ui_manager = new UIManager();
     private Entry search_entry;
     private VBox vbox_right;
     private UIManager ui_manager = new UIManager();
     private Entry search_entry;
     private VBox vbox_right;
@@ -76,45 +76,45 @@ public class IdentityManagerView : Window {
     }
 
     private const string layout =
     }
 
     private const string layout =
-"<menubar name='MenuBar'>" +
-"        <menu name='FileMenu' action='FileMenuAction'>" +
-"            <menuitem name='AddIdCard' action='AddIdCardAction' />" +
-"            <separator />" +
-"            <menuitem name='Quit' action='QuitAction' />" +
-"        </menu>" +
-"" +
-"        <menu name='HelpMenu' action='HelpMenuAction'>" +
-"             <menuitem name='About' action='AboutAction' />" +
-"        </menu>" +
-"</menubar>";
+    "<menubar name='MenuBar'>" +
+    "        <menu name='FileMenu' action='FileMenuAction'>" +
+    "            <menuitem name='AddIdCard' action='AddIdCardAction' />" +
+    "            <separator />" +
+    "            <menuitem name='Quit' action='QuitAction' />" +
+    "        </menu>" +
+    "" +
+    "        <menu name='HelpMenu' action='HelpMenuAction'>" +
+    "             <menuitem name='About' action='AboutAction' />" +
+    "        </menu>" +
+    "</menubar>";
 
     public IdentityManagerView(IdentityManagerApp app) {
 
     public IdentityManagerView(IdentityManagerApp app) {
-       parent_app = app;
-#if OS_MACOS
-               osxApp = OSXApplication.get_instance();
-#endif
-          identities_manager = parent_app.model;
-       request_queue = new GLib.Queue<IdentityRequest>();
-       service_button_map = new HashTable<Gtk.Button, string> (direct_hash, direct_equal);
-       this.title = "Moonshot Identity Selector";
-       this.set_position (WindowPosition.CENTER);
-       set_default_size (WINDOW_WIDTH, WINDOW_HEIGHT);
-       build_ui();
-       setup_list_model(); 
-       load_id_cards(); 
-       connect_signals();
+        parent_app = app;
+        #if OS_MACOS
+            osxApp = OSXApplication.get_instance();
+        #endif
+        identities_manager = parent_app.model;
+        request_queue = new GLib.Queue<IdentityRequest>();
+        service_button_map = new HashTable<Gtk.Button, string>(direct_hash, direct_equal);
+        this.title = "Moonshot Identity Selector";
+        this.set_position(WindowPosition.CENTER);
+        set_default_size(WINDOW_WIDTH, WINDOW_HEIGHT);
+        build_ui();
+        setup_list_model(); 
+        load_id_cards(); 
+        connect_signals();
     }
     
     }
     
-    public void on_card_list_changed () {
+    public void on_card_list_changed() {
         load_id_cards();
     }
     
         load_id_cards();
     }
     
-    private bool visible_func (TreeModel model, TreeIter iter)
+    private bool visible_func(TreeModel model, TreeIter iter)
     {
         IdCard id_card;
 
     {
         IdCard id_card;
 
-        model.get (iter,
-                   Columns.IDCARD_COL, out id_card);
+        model.get(iter,
+                  Columns.IDCARD_COL, out id_card);
 
         if (id_card == null)
             return false;
 
         if (id_card == null)
             return false;
@@ -131,7 +131,7 @@ public class IdentityManagerView : Window {
                 return false;
         }
         
                 return false;
         }
         
-        string entry_text = search_entry.get_text ();
+        string entry_text = search_entry.get_text();
         if (entry_text == null || entry_text == "")
         {
             return true;
         if (entry_text == null || entry_text == "")
         {
             return true;
@@ -143,21 +143,21 @@ public class IdentityManagerView : Window {
                 continue;
          
 
                 continue;
          
 
-            string search_text_casefold = search_text.casefold ();
+            string search_text_casefold = search_text.casefold();
 
             if (id_card.issuer != null)
             {
 
             if (id_card.issuer != null)
             {
-              string issuer_casefold = id_card.issuer;
+                string issuer_casefold = id_card.issuer;
 
 
-              if (issuer_casefold.contains (search_text_casefold))
-                  return true;
+                if (issuer_casefold.contains(search_text_casefold))
+                    return true;
             }
 
             if (id_card.display_name != null)
             {
             }
 
             if (id_card.display_name != null)
             {
-                string display_name_casefold = id_card.display_name.casefold ();
+                string display_name_casefold = id_card.display_name.casefold();
               
               
-                if (display_name_casefold.contains (search_text_casefold))
+                if (display_name_casefold.contains(search_text_casefold))
                     return true;
             }
             
                     return true;
             }
             
@@ -165,9 +165,9 @@ public class IdentityManagerView : Window {
             {
                 foreach (string service in id_card.services)
                 {
             {
                 foreach (string service in id_card.services)
                 {
-                    string service_casefold = service.casefold ();
+                    string service_casefold = service.casefold();
 
 
-                    if (service_casefold.contains (search_text_casefold))
+                    if (service_casefold.contains(search_text_casefold))
                         return true;
                 }
             }
                         return true;
                 }
             }
@@ -175,46 +175,46 @@ public class IdentityManagerView : Window {
         return false;
     }
 
         return false;
     }
 
-    private void setup_list_model ()
+    private void setup_list_model()
     {
     {
-      this.listmodel = new Gtk.ListStore (Columns.N_COLUMNS, typeof (IdCard),
-                                                          typeof (Gdk.Pixbuf),
-                                                          typeof (string),
-                                                          typeof (string),
-                                                          typeof (string));
-      this.filter = new TreeModelFilter (listmodel, null);
+        this.listmodel = new Gtk.ListStore (Columns.N_COLUMNS, typeof(IdCard),
+                                            typeof(Gdk.Pixbuf),
+                                            typeof(string),
+                                            typeof(string),
+                                            typeof(string));
+        this.filter = new TreeModelFilter(listmodel, null);
 
 
-      filter.set_visible_func (visible_func);
+        filter.set_visible_func(visible_func);
     }
 
     }
 
-    private void search_entry_icon_press_cb (EntryIconPosition pos, Gdk.Event event)
+    private void search_entry_icon_press_cb(EntryIconPosition pos, Gdk.Event event)
     {
         if (pos == EntryIconPosition.PRIMARY)
         {
     {
         if (pos == EntryIconPosition.PRIMARY)
         {
-            print ("Search entry icon pressed\n");
+            print("Search entry icon pressed\n");
         }
         else
         {
         }
         else
         {
-            this.search_entry.set_text ("");
+            this.search_entry.set_text("");
         }
     }
 
         }
     }
 
-    private void search_entry_text_changed_cb ()
+    private void search_entry_text_changed_cb()
     {
     {
-        this.filter.refilter ();
-        redraw_id_card_widgets ();
+        this.filter.refilter();
+        redraw_id_card_widgets();
 
 
-        var has_text = this.search_entry.get_text_length () > 0;
-        this.search_entry.set_icon_sensitive (EntryIconPosition.PRIMARY, has_text);
-        this.search_entry.set_icon_sensitive (EntryIconPosition.SECONDARY, has_text);
+        var has_text = this.search_entry.get_text_length() > 0;
+        this.search_entry.set_icon_sensitive(EntryIconPosition.PRIMARY, has_text);
+        this.search_entry.set_icon_sensitive(EntryIconPosition.SECONDARY, has_text);
 
 
-        this.vbox_right.set_visible (false);
+        this.vbox_right.set_visible(false);
     }
 
     }
 
-    private bool search_entry_key_press_event_cb (Gdk.EventKey e)
+    private bool search_entry_key_press_event_cb(Gdk.EventKey e)
     {
         if(Gdk.keyval_name(e.keyval) == "Escape")
     {
         if(Gdk.keyval_name(e.keyval) == "Escape")
-           this.search_entry.set_text("");
+            this.search_entry.set_text("");
 
         // Continue processing this event, since the
         // text entry functionality needs to see it too.
 
         // Continue processing this event, since the
         // text entry functionality needs to see it too.
@@ -226,7 +226,7 @@ public class IdentityManagerView : Window {
         if (this.custom_vbox.current_idcard != null) {
             var identity = this.custom_vbox.current_idcard.id_card;
             var dialog = new AddPasswordDialog(identity, null);
         if (this.custom_vbox.current_idcard != null) {
             var identity = this.custom_vbox.current_idcard.id_card;
             var dialog = new AddPasswordDialog(identity, null);
-            var result = dialog.run ();
+            var result = dialog.run();
 
             switch (result) {
             case ResponseType.OK:
 
             switch (result) {
             case ResponseType.OK:
@@ -239,19 +239,19 @@ public class IdentityManagerView : Window {
             default:
                 break;
             }
             default:
                 break;
             }
-            dialog.destroy ();
+            dialog.destroy();
         }
     }
 
         }
     }
 
-    private void load_id_cards () {
+    private void load_id_cards() {
         string current_idcard_nai = null;
         if (this.custom_vbox.current_idcard != null) {
             current_idcard_nai = custom_vbox.current_idcard.id_card.nai;
             custom_vbox.current_idcard = null;
         }
         string current_idcard_nai = null;
         if (this.custom_vbox.current_idcard != null) {
             current_idcard_nai = custom_vbox.current_idcard.id_card.nai;
             custom_vbox.current_idcard = null;
         }
-        var children = this.custom_vbox.get_children ();
+        var children = this.custom_vbox.get_children();
         foreach (var id_card_widget in children) {
         foreach (var id_card_widget in children) {
-        remove_id_card_widget((IdCardWidget)id_card_widget);
+            remove_id_card_widget((IdCardWidget)id_card_widget);
         }   
         this.listmodel->clear();
         LinkedList<IdCard> card_list = identities_manager.get_card_list() ;
         }   
         this.listmodel->clear();
         LinkedList<IdCard> card_list = identities_manager.get_card_list() ;
@@ -260,8 +260,8 @@ public class IdentityManagerView : Window {
         }
 
         foreach (IdCard id_card in card_list) {
         }
 
         foreach (IdCard id_card in card_list) {
-            add_id_card_data (id_card);
-            IdCardWidget id_card_widget = add_id_card_widget (id_card);
+            add_id_card_data(id_card);
+            IdCardWidget id_card_widget = add_id_card_widget(id_card);
             if (id_card_widget.id_card.nai == current_idcard_nai) {
                 fill_details(id_card_widget);
                 id_card_widget.expand();
             if (id_card_widget.id_card.nai == current_idcard_nai) {
                 fill_details(id_card_widget);
                 id_card_widget.expand();
@@ -271,50 +271,52 @@ public class IdentityManagerView : Window {
             fill_details(null);
     }
     
             fill_details(null);
     }
     
-    private void fill_details (IdCardWidget? id_card_widget)
+    private void fill_details(IdCardWidget? id_card_widget)
     {
         var vr_children = this.vbox_right.get_children();
     {
         var vr_children = this.vbox_right.get_children();
-        foreach (var vr_child in vr_children)
+        foreach (var vr_child in vr_children) {
             this.vbox_right.remove(vr_child);
             this.vbox_right.remove(vr_child);
+        }
         if (id_card_widget != null) {
             var id_card = id_card_widget.id_card;
             if (id_card.display_name == IdCard.NO_IDENTITY) {
         if (id_card_widget != null) {
             var id_card = id_card_widget.id_card;
             if (id_card.display_name == IdCard.NO_IDENTITY) {
-               this.vbox_right.pack_start(no_identity_title, false, true, 0);
+                this.vbox_right.pack_start(no_identity_title, false, true, 0);
             } else {
             } else {
-                this.issuer_entry.set_text (id_card.issuer);
-               this.username_entry.set_text (id_card.username);
-               this.password_entry.set_text (id_card.password ?? "");
-               this.vbox_right.pack_start(login_vbox, false, true, 0);
-               this.remember_checkbutton.active = id_card.store_password;
+                this.issuer_entry.set_text(id_card.issuer);
+                this.username_entry.set_text(id_card.username);
+                this.password_entry.set_text(id_card.password ?? "");
+                this.vbox_right.pack_start(login_vbox, false, true, 0);
+                this.remember_checkbutton.active = id_card.store_password;
             }
             }
-            this.vbox_right.pack_start (services_vbox, false, true, 0);
+            this.vbox_right.pack_start(services_vbox, false, true, 0);
 
 
-            var children = this.services_internal_vbox.get_children ();
-            foreach (var hbox in children)
-               services_internal_vbox.remove(hbox);
-            fill_services_vbox (id_card_widget.id_card);
+            var children = this.services_internal_vbox.get_children();
+            foreach (var hbox in children) {
+                services_internal_vbox.remove(hbox);
+            }
+            fill_services_vbox(id_card_widget.id_card);
         }
     }
 
         }
     }
 
-    private void show_details (IdCard id_card)
+    private void show_details(IdCard id_card)
     {
     {
-       this.vbox_right.set_visible (!vbox_right.get_visible ());
+        this.vbox_right.set_visible(!vbox_right.get_visible());
 
 
-       if (this.vbox_right.get_visible () == false)
-       {
-           this.resize (WINDOW_WIDTH, WINDOW_HEIGHT);
-       }
+        if (this.vbox_right.get_visible() == false)
+        {
+            this.resize(WINDOW_WIDTH, WINDOW_HEIGHT);
+        }
     }
 
     }
 
-    private void details_identity_cb (IdCardWidget id_card_widget)
+    private void details_identity_cb(IdCardWidget id_card_widget)
     {
     {
-       fill_details (id_card_widget);
-       show_details (id_card_widget.id_card);
+        fill_details(id_card_widget);
+        show_details(id_card_widget.id_card);
     }
 
     }
 
-    private IdCard get_id_card_data (AddIdentityDialog dialog)
+    private IdCard get_id_card_data(AddIdentityDialog dialog)
     {
     {
-        var id_card = new IdCard ();
+        var id_card = new IdCard();
 
         id_card.display_name = dialog.display_name;
         id_card.issuer = dialog.issuer;
 
         id_card.display_name = dialog.display_name;
         id_card.issuer = dialog.issuer;
@@ -326,13 +328,13 @@ public class IdentityManagerView : Window {
         return id_card;
     }
 
         return id_card;
     }
 
-    private void add_id_card_data (IdCard id_card)
+    private void add_id_card_data(IdCard id_card)
     {
         TreeIter   iter;
         Gdk.Pixbuf pixbuf;
     {
         TreeIter   iter;
         Gdk.Pixbuf pixbuf;
-        this.listmodel->append (out iter);
+        this.listmodel->append(out iter);
         pixbuf = get_pixbuf(id_card);
         pixbuf = get_pixbuf(id_card);
-        listmodel->set (iter,
+        listmodel->set(iter,
                        Columns.IDCARD_COL, id_card,
                        Columns.LOGO_COL, pixbuf,
                        Columns.ISSUER_COL, id_card.issuer,
                        Columns.IDCARD_COL, id_card,
                        Columns.LOGO_COL, pixbuf,
                        Columns.ISSUER_COL, id_card.issuer,
@@ -340,162 +342,162 @@ public class IdentityManagerView : Window {
                        Columns.PASSWORD_COL, id_card.password);
     }
 
                        Columns.PASSWORD_COL, id_card.password);
     }
 
-    private void remove_id_card_data (IdCard id_card)
+    private void remove_id_card_data(IdCard id_card)
     {
         TreeIter iter;
         string issuer;
 
     {
         TreeIter iter;
         string issuer;
 
-        if (listmodel->get_iter_first (out iter))
+        if (listmodel->get_iter_first(out iter))
         {
             do
             {
         {
             do
             {
-                listmodel->get (iter,
+                listmodel->get(iter,
                                Columns.ISSUER_COL, out issuer);
 
                 if (id_card.issuer == issuer)
                 {
                                Columns.ISSUER_COL, out issuer);
 
                 if (id_card.issuer == issuer)
                 {
-                    listmodel->remove (iter);
+                    listmodel->remove(iter);
                     break;
                 }
             }
                     break;
                 }
             }
-            while (listmodel->iter_next (ref iter));
+            while (listmodel->iter_next(ref iter));
         }
     }
 
         }
     }
 
-    private IdCardWidget add_id_card_widget (IdCard id_card)
+    private IdCardWidget add_id_card_widget(IdCard id_card)
     {
     {
-        var id_card_widget = new IdCardWidget (id_card);
-        this.custom_vbox.add_id_card_widget (id_card_widget);
-        id_card_widget.details_id.connect (details_identity_cb);
-        id_card_widget.remove_id.connect (remove_identity_cb);
-        id_card_widget.send_id.connect ((w) => send_identity_cb (w.id_card));
-        id_card_widget.expanded.connect (this.custom_vbox.receive_expanded_event);
-        id_card_widget.expanded.connect (fill_details);
+        var id_card_widget = new IdCardWidget(id_card);
+        this.custom_vbox.add_id_card_widget(id_card_widget);
+        id_card_widget.details_id.connect(details_identity_cb);
+        id_card_widget.remove_id.connect(remove_identity_cb);
+        id_card_widget.send_id.connect((w) => send_identity_cb(w.id_card));
+        id_card_widget.expanded.connect(this.custom_vbox.receive_expanded_event);
+        id_card_widget.expanded.connect(fill_details);
         return id_card_widget;
     }
 
         return id_card_widget;
     }
 
-    public bool add_identity (IdCard id_card, bool force_flat_file_store)
+    public bool add_identity(IdCard id_card, bool force_flat_file_store)
     {
     {
-#if OS_MACOS
+        #if OS_MACOS
         /* 
          * TODO: We should have a confirmation dialog, but currently it will crash on Mac OS
          * so for now we will install silently
          */
         var ret = Gtk.ResponseType.YES;
         /* 
          * TODO: We should have a confirmation dialog, but currently it will crash on Mac OS
          * so for now we will install silently
          */
         var ret = Gtk.ResponseType.YES;
-#else
+        #else
         Gtk.MessageDialog dialog;
         IdCard? prev_id = identities_manager.find_id_card(id_card.nai, force_flat_file_store);
         if (prev_id!=null) {
             int flags = prev_id.Compare(id_card);
             if (flags == 0) {
                 return false; // no changes, no need to update
         Gtk.MessageDialog dialog;
         IdCard? prev_id = identities_manager.find_id_card(id_card.nai, force_flat_file_store);
         if (prev_id!=null) {
             int flags = prev_id.Compare(id_card);
             if (flags == 0) {
                 return false; // no changes, no need to update
-            } else if ((flags & (1<<IdCard.DiffFlags.DISPLAY_NAME)) != 0) {
-                dialog = new Gtk.MessageDialog (this,
-                                            Gtk.DialogFlags.DESTROY_WITH_PARENT,
-                                            Gtk.MessageType.QUESTION,
-                                            Gtk.ButtonsType.YES_NO,
-                                            _("Would you like to replace ID Card '%s' using nai '%s' with the new ID Card '%s'?"),
-                                            prev_id.display_name,
-                                            prev_id.nai,
-                                            id_card.display_name);
+            } else if ((flags & (1 << IdCard.DiffFlags.DISPLAY_NAME)) != 0) {
+                dialog = new Gtk.MessageDialog(this,
+                                               Gtk.DialogFlags.DESTROY_WITH_PARENT,
+                                               Gtk.MessageType.QUESTION,
+                                               Gtk.ButtonsType.YES_NO,
+                                               _("Would you like to replace ID Card '%s' using nai '%s' with the new ID Card '%s'?"),
+                                               prev_id.display_name,
+                                               prev_id.nai,
+                                               id_card.display_name);
             } else {
             } else {
-                dialog = new Gtk.MessageDialog (this,
-                                            Gtk.DialogFlags.DESTROY_WITH_PARENT,
-                                            Gtk.MessageType.QUESTION,
-                                            Gtk.ButtonsType.YES_NO,
-                                            _("Would you like to update ID Card '%s' using nai '%s'?"),
-                                            id_card.display_name,
-                                            id_card.nai);
+                dialog = new Gtk.MessageDialog(this,
+                                               Gtk.DialogFlags.DESTROY_WITH_PARENT,
+                                               Gtk.MessageType.QUESTION,
+                                               Gtk.ButtonsType.YES_NO,
+                                               _("Would you like to update ID Card '%s' using nai '%s'?"),
+                                               id_card.display_name,
+                                               id_card.nai);
             }
         } else {
             }
         } else {
-            dialog = new Gtk.MessageDialog (this,
-                                            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?"),
-                                            id_card.display_name);
+            dialog = new Gtk.MessageDialog(this,
+                                           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?"),
+                                           id_card.display_name);
         }
         }
-        var ret = dialog.run ();
-        dialog.destroy ();
-#endif
+        var ret = dialog.run();
+        dialog.destroy();
+        #endif
 
         if (ret == Gtk.ResponseType.YES) {
 
         if (ret == Gtk.ResponseType.YES) {
-            this.identities_manager.add_card (id_card, force_flat_file_store);
+            this.identities_manager.add_card(id_card, force_flat_file_store);
             return true;
         }
             return true;
         }
-
         return false;
     }
 
         return false;
     }
 
-    private void add_identity_manual_cb ()
+    private void add_identity_manual_cb()
     {
     {
-        var dialog = new AddIdentityDialog ();
+        var dialog = new AddIdentityDialog();
         int result = ResponseType.CANCEL;
         while (!dialog.complete)
         int result = ResponseType.CANCEL;
         while (!dialog.complete)
-            result = dialog.run ();
+            result = dialog.run();
 
         switch (result) {
         case ResponseType.OK:
 
         switch (result) {
         case ResponseType.OK:
-            this.identities_manager.add_card (get_id_card_data (dialog), false);
+            this.identities_manager.add_card(get_id_card_data(dialog), false);
             break;
         default:
             break;
         }
             break;
         default:
             break;
         }
-        dialog.destroy ();
+        dialog.destroy();
     }
 
     }
 
-    private void remove_id_card_widget (IdCardWidget id_card_widget) {
-       this.custom_vbox.remove_id_card_widget (id_card_widget);
+    private void remove_id_card_widget(IdCardWidget id_card_widget) {
+        this.custom_vbox.remove_id_card_widget(id_card_widget);
     }
 
     }
 
-    private void remove_identity (IdCardWidget id_card_widget)
+    private void remove_identity(IdCardWidget id_card_widget)
     {
         var id_card = id_card_widget.id_card;
     {
         var id_card = id_card_widget.id_card;
-        remove_id_card_widget (id_card_widget);
+        remove_id_card_widget(id_card_widget);
 
         this.identities_manager.remove_card(id_card);
     }
 
 
         this.identities_manager.remove_card(id_card);
     }
 
-    private void redraw_id_card_widgets ()
+    private void redraw_id_card_widgets()
     {
         TreeIter iter;
         IdCard id_card;
 
     {
         TreeIter iter;
         IdCard id_card;
 
-        var children = this.custom_vbox.get_children ();
-        foreach (var id_card_widget in children)
+        var children = this.custom_vbox.get_children();
+        foreach (var id_card_widget in children) {
             remove_id_card_widget((IdCardWidget )id_card_widget); //id_card_widget.destroy();
             remove_id_card_widget((IdCardWidget )id_card_widget); //id_card_widget.destroy();
+        }
 
 
-        if (filter.get_iter_first (out iter))
+        if (filter.get_iter_first(out iter))
         {
             do
             {
         {
             do
             {
-                filter.get (iter,
-                            Columns.IDCARD_COL, out id_card);
+                filter.get(iter,
+                           Columns.IDCARD_COL, out id_card);
 
 
-                add_id_card_widget (id_card);
+                add_id_card_widget(id_card);
             }
             }
-            while (filter.iter_next (ref iter));
+            while (filter.iter_next(ref iter));
         }
     }
 
         }
     }
 
-    private void remove_identity_cb (IdCardWidget id_card_widget)
+    private void remove_identity_cb(IdCardWidget id_card_widget)
     {
         var id_card = id_card_widget.id_card;
 
     {
         var id_card = id_card_widget.id_card;
 
-        var dialog = new MessageDialog (this,
-                                        DialogFlags.DESTROY_WITH_PARENT,
-                                        MessageType.QUESTION,
-                                        Gtk.ButtonsType.YES_NO,
-                                        _("Are you sure you want to delete %s ID Card?"), id_card.issuer);
-        var result = dialog.run ();
+        var dialog = new MessageDialog(this,
+                                       DialogFlags.DESTROY_WITH_PARENT,
+                                       MessageType.QUESTION,
+                                       Gtk.ButtonsType.YES_NO,
+                                       _("Are you sure you want to delete %s ID Card?"), id_card.issuer);
+        var result = dialog.run();
         switch (result) {
         case ResponseType.YES:
         switch (result) {
         case ResponseType.YES:
-            remove_identity (id_card_widget);
+            remove_identity(id_card_widget);
             break;
         default:
             break;
         }
             break;
         default:
             break;
         }
-        dialog.destroy ();
+        dialog.destroy();
     }
 
     public void set_prompting_service(string service)
     }
 
     public void set_prompting_service(string service)
@@ -509,22 +511,22 @@ public class IdentityManagerView : Window {
         { /* setup widgets */
             candidates = request.candidates;
             filter.refilter();
         { /* setup widgets */
             candidates = request.candidates;
             filter.refilter();
-            redraw_id_card_widgets ();
+            redraw_id_card_widgets();
             set_prompting_service(request.service);
             make_visible();
         }
             set_prompting_service(request.service);
             make_visible();
         }
-        this.request_queue.push_tail (request);
+        this.request_queue.push_tail(request);
     }
 
 
     /** Makes the window visible, or at least, notifies the user that the window
     }
 
 
     /** Makes the window visible, or at least, notifies the user that the window
-      * wants to be visible.
-      *
-      * This differs from show() in that show() does not guarantee that the 
-      * window will be moved to the foreground. Actually, neither does this
-      * method, because the user's settings and window manager may affect the
-      * behavior significantly.
-      */
+     * wants to be visible.
+     *
+     * This differs from show() in that show() does not guarantee that the 
+     * window will be moved to the foreground. Actually, neither does this
+     * method, because the user's settings and window manager may affect the
+     * behavior significantly.
+     */
     public void make_visible()
     {
         set_urgency_hint(true);
     public void make_visible()
     {
         set_urgency_hint(true);
@@ -541,8 +543,8 @@ public class IdentityManagerView : Window {
                 identity.password = request.password;
                 retval = model.update_card(identity);
             } else {
                 identity.password = request.password;
                 retval = model.update_card(identity);
             } else {
-                var dialog = new AddPasswordDialog (identity, request);
-                var result = dialog.run ();
+                var dialog = new AddPasswordDialog(identity, request);
+                var result = dialog.run();
 
                 switch (result) {
                 case ResponseType.OK:
 
                 switch (result) {
                 case ResponseType.OK:
@@ -556,19 +558,19 @@ public class IdentityManagerView : Window {
                     identity = null;
                     break;
                 }
                     identity = null;
                     break;
                 }
-                dialog.destroy ();
+                dialog.destroy();
             }
         }
         return retval;
     }
 
             }
         }
         return retval;
     }
 
-    public void send_identity_cb (IdCard id)
+    public void send_identity_cb(IdCard id)
     {
         IdCard identity = id;
         return_if_fail (request_queue.length > 0);
 
     {
         IdCard identity = id;
         return_if_fail (request_queue.length > 0);
 
-       candidates = null;
-        var request = this.request_queue.pop_head ();
+        candidates = null;
+        var request = this.request_queue.pop_head();
         identity = check_add_password(identity, request, identities_manager);
         if (this.request_queue.is_empty())
         {
         identity = check_add_password(identity, request, identities_manager);
         if (this.request_queue.is_empty())
         {
@@ -577,7 +579,7 @@ public class IdentityManagerView : Window {
             if (!parent_app.explicitly_launched) {
 // The following occasionally causes the app to exit without sending the dbus
 // reply, so for now we just don't exit
             if (!parent_app.explicitly_launched) {
 // The following occasionally causes the app to exit without sending the dbus
 // reply, so for now we just don't exit
-//                Gtk.main_quit ();
+//                Gtk.main_quit();
 // just hide instead
                 this.hide();
             }
 // just hide instead
                 this.hide();
             }
@@ -587,100 +589,100 @@ public class IdentityManagerView : Window {
             set_prompting_service(next.service);
         }
         filter.refilter();
             set_prompting_service(next.service);
         }
         filter.refilter();
-        redraw_id_card_widgets ();
+        redraw_id_card_widgets();
 
         if ((identity != null) && (!identity.IsNoIdentity()))
             parent_app.default_id_card = identity;
 
 
         if ((identity != null) && (!identity.IsNoIdentity()))
             parent_app.default_id_card = identity;
 
-        request.return_identity (identity);
+        request.return_identity(identity);
     }
 
     }
 
-    private void label_make_bold (Label label)
+    private void label_make_bold(Label label)
     {
     {
-        var font_desc = new Pango.FontDescription ();
+        var font_desc = new Pango.FontDescription();
 
 
-        font_desc.set_weight (Pango.Weight.BOLD);
+        font_desc.set_weight(Pango.Weight.BOLD);
 
         /* This will only affect the weight of the font, the rest is
          * from the current state of the widget, which comes from the
          * theme or user prefs, since the font desc only has the
          * weight flag turned on.
          */
 
         /* This will only affect the weight of the font, the rest is
          * from the current state of the widget, which comes from the
          * theme or user prefs, since the font desc only has the
          * weight flag turned on.
          */
-        label.modify_font (font_desc);
+        label.modify_font(font_desc);
     }
 
     }
 
-    private void fill_services_vbox (IdCard id_card)
+    private void fill_services_vbox(IdCard id_card)
     {
         int i = 0;
         var n_columns = id_card.services.length;
 
     {
         int i = 0;
         var n_columns = id_card.services.length;
 
-        var services_table = new Table (n_columns, 2, false);
-        services_table.set_col_spacings (10);
-        services_table.set_row_spacings (10);
-        this.services_internal_vbox.add (services_table);
+        var services_table = new Table(n_columns, 2, false);
+        services_table.set_col_spacings(10);
+        services_table.set_row_spacings(10);
+        this.services_internal_vbox.add(services_table);
         
         
-        service_button_map.remove_all ();
+        service_button_map.remove_all();
 
         foreach (string service in id_card.services)
         {
 
         foreach (string service in id_card.services)
         {
-            var label = new Label (service);
-            label.set_alignment (0, (float) 0.5);
-#if VALA_0_12
-            var remove_button = new Button.from_stock (Stock.REMOVE);
-#else
-            var remove_button = new Button.from_stock (STOCK_REMOVE);
-#endif
+            var label = new Label(service);
+            label.set_alignment(0, (float) 0.5);
+            #if VALA_0_12
+                var remove_button = new Button.from_stock(Stock.REMOVE);
+            #else
+                var remove_button = new Button.from_stock(STOCK_REMOVE);
+            #endif
 
 
 
 
-            service_button_map.insert (remove_button, service);
+            service_button_map.insert(remove_button, service);
             
             
-            remove_button.clicked.connect ((remove_button) =>
-            {
-              var candidate = service_button_map.lookup (remove_button);
-              if (candidate == null)
-                return;
-              var dialog = new Gtk.MessageDialog (this,
-                                      Gtk.DialogFlags.DESTROY_WITH_PARENT,
-                                      Gtk.MessageType.QUESTION,
-                                      Gtk.ButtonsType.YES_NO,
-                                      _("Are you sure you want to stop '%s' ID Card from being used with %s?"),
-                                      custom_vbox.current_idcard.id_card.display_name,
-                                      candidate);
-              var ret = dialog.run();
-              dialog.hide();
+            remove_button.clicked.connect((remove_button) =>
+                {
+                    var candidate = service_button_map.lookup(remove_button);
+                    if (candidate == null)
+                        return;
+                    var dialog = new Gtk.MessageDialog(this,
+                                                       Gtk.DialogFlags.DESTROY_WITH_PARENT,
+                                                       Gtk.MessageType.QUESTION,
+                                                       Gtk.ButtonsType.YES_NO,
+                                                       _("Are you sure you want to stop '%s' ID Card from being used with %s?"),
+                                                       custom_vbox.current_idcard.id_card.display_name,
+                                                       candidate);
+                    var ret = dialog.run();
+                    dialog.hide();
               
               
-              if (ret == Gtk.ResponseType.YES)
-              {
-                IdCard idcard = custom_vbox.current_idcard.id_card;
-                if (idcard != null) {
-                  SList<string> services = new SList<string>();
+                    if (ret == Gtk.ResponseType.YES)
+                    {
+                        IdCard idcard = custom_vbox.current_idcard.id_card;
+                        if (idcard != null) {
+                            SList<string> services = new SList<string>();
                 
                 
-                  foreach (string srv in idcard.services)
-                  {
-                    if (srv == candidate)
-                      continue;
-                    services.append (srv);
-                  }
+                            foreach (string srv in idcard.services)
+                            {
+                                if (srv == candidate)
+                                    continue;
+                                services.append(srv);
+                            }
                 
                 
-                  idcard.services = new string[services.length()];
-                  for (int j=0; j<idcard.services.length; j++)
-                  {
-                    idcard.services[j] = services.nth_data(j);
-                  }
+                            idcard.services = new string[services.length()];
+                            for (int j = 0; j < idcard.services.length; j++)
+                            {
+                                idcard.services[j] = services.nth_data(j);
+                            }
                 
                 
-                  identities_manager.update_card(idcard);
-                }
-              }
+                            identities_manager.update_card(idcard);
+                        }
+                    }
               
               
-            });
-            services_table.attach_defaults (label, 0, 1, i, i+1);
-            services_table.attach_defaults (remove_button, 1, 2, i, i+1);
+                });
+            services_table.attach_defaults(label, 0, 1, i, i+1);
+            services_table.attach_defaults(remove_button, 1, 2, i, i+1);
             i++;
         }
             i++;
         }
-        this.services_internal_vbox.show_all ();
+        this.services_internal_vbox.show_all();
     }
 
     }
 
-    private void on_about_action ()
+    private void on_about_action()
     {
         string[] authors = {
             "Javier Jardón <jjardon@codethink.co.uk>",
     {
         string[] authors = {
             "Javier Jardón <jjardon@codethink.co.uk>",
@@ -692,7 +694,7 @@ public class IdentityManagerView : Window {
         string copyright = "Copyright 2011 JANET";
 
         string license =
         string copyright = "Copyright 2011 JANET";
 
         string license =
-"""
+        """
 Copyright (c) 2011, JANET(UK)
 All rights reserved.
 
 Copyright (c) 2011, JANET(UK)
 All rights reserved.
 
@@ -724,17 +726,17 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.
 """;
 
 SUCH DAMAGE.
 """;
 
-        Gtk.show_about_dialog (this,
-            "comments", _("Moonshot project UI"),
-            "copyright", copyright,
-            "website", Config.PACKAGE_URL,
-            "version", Config.PACKAGE_VERSION,
-            "license", license,
-            "website-label", _("Visit the Moonshot project web site"),
-            "authors", authors,
-            "translator-credits", _("translator-credits"),
-            null
-        );
+        Gtk.show_about_dialog(this,
+                              "comments", _("Moonshot project UI"),
+                              "copyright", copyright,
+                              "website", Config.PACKAGE_URL,
+                              "version", Config.PACKAGE_VERSION,
+                              "license", license,
+                              "website-label", _("Visit the Moonshot project web site"),
+                              "authors", authors,
+                              "translator-credits", _("translator-credits"),
+                              null
+            );
     }
 
     private Gtk.ActionEntry[] create_actions() {
     }
 
     private Gtk.ActionEntry[] create_actions() {
@@ -746,22 +748,22 @@ SUCH DAMAGE.
                                      null, null, null };
         actions += filemenu;
         Gtk.ActionEntry add = { "AddIdCardAction",
                                      null, null, null };
         actions += filemenu;
         Gtk.ActionEntry add = { "AddIdCardAction",
-#if VALA_0_12
+                                #if VALA_0_12
                                 Stock.ADD,
                                 Stock.ADD,
-#else
+                                #else
                                 STOCK_ADD,
                                 STOCK_ADD,
-#endif
+                                #endif
                                 N_("Add ID Card"),
                                 null,
                                 N_("Add a new ID Card"),
                                 add_identity_manual_cb };
         actions += add;
         Gtk.ActionEntry quit = { "QuitAction",
                                 N_("Add ID Card"),
                                 null,
                                 N_("Add a new ID Card"),
                                 add_identity_manual_cb };
         actions += add;
         Gtk.ActionEntry quit = { "QuitAction",
-#if VALA_0_12
+                                 #if VALA_0_12
                                  Stock.QUIT,
                                  Stock.QUIT,
-#else
+                                 #else
                                  STOCK_QUIT,
                                  STOCK_QUIT,
-#endif
+                                 #endif
                                  N_("Quit"),
                                  "<control>Q",
                                  N_("Quit the application"),
                                  N_("Quit"),
                                  "<control>Q",
                                  N_("Quit the application"),
@@ -774,11 +776,11 @@ SUCH DAMAGE.
                                      null, null, null };
         actions += helpmenu;
         Gtk.ActionEntry about = { "AboutAction",
                                      null, null, null };
         actions += helpmenu;
         Gtk.ActionEntry about = { "AboutAction",
-#if VALA_0_12
+                                  #if VALA_0_12
                                   Stock.ABOUT,
                                   Stock.ABOUT,
-#else
+                                  #else
                                   STOCK_ABOUT,
                                   STOCK_ABOUT,
-#endif
+                                  #endif
                                   N_("About"),
                                   null,
                                   N_("About this application"),
                                   N_("About"),
                                   null,
                                   N_("About this application"),
@@ -789,179 +791,179 @@ SUCH DAMAGE.
     }
 
 
     }
 
 
-    private void create_ui_manager ()
+    private void create_ui_manager()
     {
     {
-        Gtk.ActionGroup action_group = new Gtk.ActionGroup ("GeneralActionGroup");
-        action_group.add_actions (create_actions (), this);
-        ui_manager.insert_action_group (action_group, 0);
+        Gtk.ActionGroup action_group = new Gtk.ActionGroup("GeneralActionGroup");
+        action_group.add_actions(create_actions(), this);
+        ui_manager.insert_action_group(action_group, 0);
         try
         {
         try
         {
-            ui_manager.add_ui_from_string (layout, -1);
+            ui_manager.add_ui_from_string(layout, -1);
         }
         catch (Error e)
         {
         }
         catch (Error e)
         {
-            stderr.printf ("%s\n", e.message);
+            stderr.printf("%s\n", e.message);
         }
         }
-        ui_manager.ensure_update ();
+        ui_manager.ensure_update();
     }
 
     private void build_ui()
     {
     }
 
     private void build_ui()
     {
-        create_ui_manager ();
+        create_ui_manager();
 
         this.search_entry = new Entry();
 
 
         this.search_entry = new Entry();
 
-        set_atk_name_description (search_entry, _("Search entry"), _("Search for a specific ID Card"));
-        this.search_entry.set_icon_from_pixbuf (EntryIconPosition.PRIMARY,
-                                                find_icon_sized ("edit-find", Gtk.IconSize.MENU));
-//                                                find_icon_sized ("edit-find-symbolic", Gtk.IconSize.MENU));
-        this.search_entry.set_icon_tooltip_text (EntryIconPosition.PRIMARY,
-                                                 _("Search identity or service"));
-        this.search_entry.set_icon_sensitive (EntryIconPosition.PRIMARY, false);
+        set_atk_name_description(search_entry, _("Search entry"), _("Search for a specific ID Card"));
+        this.search_entry.set_icon_from_pixbuf(EntryIconPosition.PRIMARY,
+                                               find_icon_sized("edit-find", Gtk.IconSize.MENU));
+//                                                find_icon_sized("edit-find-symbolic", Gtk.IconSize.MENU));
+        this.search_entry.set_icon_tooltip_text(EntryIconPosition.PRIMARY,
+                                                _("Search identity or service"));
+        this.search_entry.set_icon_sensitive(EntryIconPosition.PRIMARY, false);
 
 
-        this.search_entry.set_icon_from_pixbuf (EntryIconPosition.SECONDARY,
-                                                find_icon_sized ("process-stop", Gtk.IconSize.MENU));
-//                                                find_icon_sized ("edit-clear-symbolic", Gtk.IconSize.MENU));
-        this.search_entry.set_icon_tooltip_text (EntryIconPosition.SECONDARY,
-                                                 _("Clear the current search"));
-        this.search_entry.set_icon_sensitive (EntryIconPosition.SECONDARY, false);
+        this.search_entry.set_icon_from_pixbuf(EntryIconPosition.SECONDARY,
+                                               find_icon_sized("process-stop", Gtk.IconSize.MENU));
+//                                                find_icon_sized("edit-clear-symbolic", Gtk.IconSize.MENU));
+        this.search_entry.set_icon_tooltip_text(EntryIconPosition.SECONDARY,
+                                                _("Clear the current search"));
+        this.search_entry.set_icon_sensitive(EntryIconPosition.SECONDARY, false);
 
 
 
 
-        this.search_entry.icon_press.connect (search_entry_icon_press_cb);
-        this.search_entry.notify["text"].connect (search_entry_text_changed_cb);
+        this.search_entry.icon_press.connect(search_entry_icon_press_cb);
+        this.search_entry.notify["text"].connect(search_entry_text_changed_cb);
         this.search_entry.key_press_event.connect(search_entry_key_press_event_cb);
 
         this.search_entry.key_press_event.connect(search_entry_key_press_event_cb);
 
-        this.custom_vbox = new CustomVBox (this, false, 6);
-
-        var viewport = new Viewport (null, null);
-        viewport.set_border_width (6);
-        viewport.set_shadow_type (ShadowType.NONE);
-        viewport.add (custom_vbox);
-        var scroll = new ScrolledWindow (null, null);
-        scroll.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
-        scroll.set_shadow_type (ShadowType.IN);
-        scroll.add_with_viewport (viewport);
-        this.prompting_service = new Label (_(""));
+        this.custom_vbox = new CustomVBox(this, false, 6);
+
+        var viewport = new Viewport(null, null);
+        viewport.set_border_width(6);
+        viewport.set_shadow_type(ShadowType.NONE);
+        viewport.add(custom_vbox);
+        var scroll = new ScrolledWindow(null, null);
+        scroll.set_policy(PolicyType.NEVER, PolicyType.AUTOMATIC);
+        scroll.set_shadow_type(ShadowType.IN);
+        scroll.add_with_viewport(viewport);
+        this.prompting_service = new Label(_(""));
         // left-align
         prompting_service.set_alignment(0, (float )0.5);
 
         // left-align
         prompting_service.set_alignment(0, (float )0.5);
 
-        var vbox_left = new VBox (false, 0);
-        vbox_left.pack_start (search_entry, false, false, 6);
-        vbox_left.pack_start (scroll, true, true, 0);
-        vbox_left.pack_start (prompting_service, false, false, 6);
-        vbox_left.set_size_request (WINDOW_WIDTH, 0);
+        var vbox_left = new VBox(false, 0);
+        vbox_left.pack_start(search_entry, false, false, 6);
+        vbox_left.pack_start(scroll, true, true, 0);
+        vbox_left.pack_start(prompting_service, false, false, 6);
+        vbox_left.set_size_request(WINDOW_WIDTH, 0);
 
 
-        this.no_identity_title = new Label (_("No Identity: Send this identity to services which should not use Moonshot"));
+        this.no_identity_title = new Label(_("No Identity: Send this identity to services which should not use Moonshot"));
         no_identity_title.set_alignment(0, (float ) 0.5);
         no_identity_title.set_line_wrap(true);
         no_identity_title.show();
 
         no_identity_title.set_alignment(0, (float ) 0.5);
         no_identity_title.set_line_wrap(true);
         no_identity_title.show();
 
-        var login_vbox_title = new Label (_("Login: "));
-        label_make_bold (login_vbox_title);
-        login_vbox_title.set_alignment (0, (float) 0.5);
-        var issuer_label = new Label (_("Issuer:"));
-        issuer_label.set_alignment (1, (float) 0.5);
-        this.issuer_entry = new Entry ();
-        issuer_entry.set_can_focus (false);
-        var username_label = new Label (_("Username:"));
-        username_label.set_alignment (1, (float) 0.5);
-        this.username_entry = new Entry ();
-        username_entry.set_can_focus (false);
-        var password_label = new Label (_("Password:"));
-        password_label.set_alignment (1, (float) 0.5);
-        this.password_entry = new Entry ();
-        password_entry.set_invisible_char ('*');
-        password_entry.set_visibility (false);
-        password_entry.set_sensitive (false);
-        this.remember_checkbutton = new CheckButton.with_label (_("Remember password"));
+        var login_vbox_title = new Label(_("Login: "));
+        label_make_bold(login_vbox_title);
+        login_vbox_title.set_alignment(0, (float) 0.5);
+        var issuer_label = new Label(_("Issuer:"));
+        issuer_label.set_alignment(1, (float) 0.5);
+        this.issuer_entry = new Entry();
+        issuer_entry.set_can_focus(false);
+        var username_label = new Label(_("Username:"));
+        username_label.set_alignment(1, (float) 0.5);
+        this.username_entry = new Entry();
+        username_entry.set_can_focus(false);
+        var password_label = new Label(_("Password:"));
+        password_label.set_alignment(1, (float) 0.5);
+        this.password_entry = new Entry();
+        password_entry.set_invisible_char('*');
+        password_entry.set_visibility(false);
+        password_entry.set_sensitive(false);
+        this.remember_checkbutton = new CheckButton.with_label(_("Remember password"));
         remember_checkbutton.set_sensitive(false);
         remember_checkbutton.set_sensitive(false);
-        this.update_password_button = new Button.with_label (_("Update Password"));
+        this.update_password_button = new Button.with_label(_("Update Password"));
         this.update_password_button.clicked.connect(update_password_cb);
 
         this.update_password_button.clicked.connect(update_password_cb);
 
-        set_atk_relation (issuer_label, issuer_entry, Atk.RelationType.LABEL_FOR);
-        set_atk_relation (username_label, username_entry, Atk.RelationType.LABEL_FOR);
-        set_atk_relation (password_entry, password_entry, Atk.RelationType.LABEL_FOR);
-
-        var login_table = new Table (5, 2, false);
-        login_table.set_col_spacings (10);
-        login_table.set_row_spacings (10);
-        login_table.attach_defaults (issuer_label, 0, 1, 0, 1);
-        login_table.attach_defaults (issuer_entry, 1, 2, 0, 1);
-        login_table.attach_defaults (username_label, 0, 1, 1, 2);
-        login_table.attach_defaults (username_entry, 1, 2, 1, 2);
-        login_table.attach_defaults (password_label, 0, 1, 2, 3);
-        login_table.attach_defaults (password_entry, 1, 2, 2, 3);
-        login_table.attach_defaults (remember_checkbutton,  1, 2, 3, 4);
-        login_table.attach_defaults (update_password_button, 0, 1, 4, 5);
-        var login_vbox_alignment = new Alignment (0, 0, 0, 0);
-        login_vbox_alignment.set_padding (0, 0, 12, 0);
-        login_vbox_alignment.add (login_table);
-        this.login_vbox = new VBox (false, 6);
-        login_vbox.pack_start (login_vbox_title, false, true, 0);
-        login_vbox.pack_start (login_vbox_alignment, false, true, 0);
-
-        var services_vbox_title = new Label (_("Services:"));
-        label_make_bold (services_vbox_title);
-        services_vbox_title.set_alignment (0, (float) 0.5);
-        var services_vbox_alignment = new Alignment (0, 0, 0, 0);
-        services_vbox_alignment.set_padding (0, 0, 12, 0);
-        this.services_internal_vbox = new VBox (true, 6);
-        services_vbox_alignment.add (services_internal_vbox);
-        this.services_vbox = new VBox (false, 6);
-        services_vbox.pack_start (services_vbox_title, false, true, 0);
-        services_vbox.pack_start (services_vbox_alignment, false, true, 0);
-
-        this.vbox_right = new VBox (false, 18);
-        vbox_right.pack_start (login_vbox, false, true, 0);
-        vbox_right.pack_start (services_vbox, false, true, 0);
-
-        var hbox = new HBox (false, 12);
-        hbox.pack_start (vbox_left, false, false, 0);
-        hbox.pack_start (vbox_right, true, true, 0);
-
-        var main_vbox = new VBox (false, 0);
-        main_vbox.set_border_width (12);
+        set_atk_relation(issuer_label, issuer_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation(username_label, username_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation(password_entry, password_entry, Atk.RelationType.LABEL_FOR);
+
+        var login_table = new Table(5, 2, false);
+        login_table.set_col_spacings(10);
+        login_table.set_row_spacings(10);
+        login_table.attach_defaults(issuer_label, 0, 1, 0, 1);
+        login_table.attach_defaults(issuer_entry, 1, 2, 0, 1);
+        login_table.attach_defaults(username_label, 0, 1, 1, 2);
+        login_table.attach_defaults(username_entry, 1, 2, 1, 2);
+        login_table.attach_defaults(password_label, 0, 1, 2, 3);
+        login_table.attach_defaults(password_entry, 1, 2, 2, 3);
+        login_table.attach_defaults(remember_checkbutton,  1, 2, 3, 4);
+        login_table.attach_defaults(update_password_button, 0, 1, 4, 5);
+        var login_vbox_alignment = new Alignment(0, 0, 0, 0);
+        login_vbox_alignment.set_padding(0, 0, 12, 0);
+        login_vbox_alignment.add(login_table);
+        this.login_vbox = new VBox(false, 6);
+        login_vbox.pack_start(login_vbox_title, false, true, 0);
+        login_vbox.pack_start(login_vbox_alignment, false, true, 0);
+
+        var services_vbox_title = new Label(_("Services:"));
+        label_make_bold(services_vbox_title);
+        services_vbox_title.set_alignment(0, (float) 0.5);
+        var services_vbox_alignment = new Alignment(0, 0, 0, 0);
+        services_vbox_alignment.set_padding(0, 0, 12, 0);
+        this.services_internal_vbox = new VBox(true, 6);
+        services_vbox_alignment.add(services_internal_vbox);
+        this.services_vbox = new VBox(false, 6);
+        services_vbox.pack_start(services_vbox_title, false, true, 0);
+        services_vbox.pack_start(services_vbox_alignment, false, true, 0);
+
+        this.vbox_right = new VBox(false, 18);
+        vbox_right.pack_start(login_vbox, false, true, 0);
+        vbox_right.pack_start(services_vbox, false, true, 0);
+
+        var hbox = new HBox(false, 12);
+        hbox.pack_start(vbox_left, false, false, 0);
+        hbox.pack_start(vbox_right, true, true, 0);
+
+        var main_vbox = new VBox(false, 0);
+        main_vbox.set_border_width(12);
  
  
-#if OS_MACOS
+        #if OS_MACOS
         // hide the  File | Quit menu item which is now on the Mac Menu
         Gtk.Widget quit_item =  this.ui_manager.get_widget("/MenuBar/FileMenu/Quit");
         quit_item.hide();
         
         // hide the  File | Quit menu item which is now on the Mac Menu
         Gtk.Widget quit_item =  this.ui_manager.get_widget("/MenuBar/FileMenu/Quit");
         quit_item.hide();
         
-               Gtk.MenuShell menushell = this.ui_manager.get_widget("/MenuBar") as Gtk.MenuShell;
-               osxApp.set_menu_bar(menushell);
-               osxApp.set_use_quartz_accelerators(true);
-               osxApp.sync_menu_bar();
-               osxApp.ready(); 
-#else
-        var menubar = this.ui_manager.get_widget ("/MenuBar");
-        main_vbox.pack_start (menubar, false, false, 0);
-#endif
-        main_vbox.pack_start (hbox, true, true, 0);
-        add (main_vbox);
+        Gtk.MenuShell menushell = this.ui_manager.get_widget("/MenuBar") as Gtk.MenuShell;
+        osxApp.set_menu_bar(menushell);
+        osxApp.set_use_quartz_accelerators(true);
+        osxApp.sync_menu_bar();
+        osxApp.ready(); 
+        #else
+        var menubar = this.ui_manager.get_widget("/MenuBar");
+        main_vbox.pack_start(menubar, false, false, 0);
+        #endif
+        main_vbox.pack_start(hbox, true, true, 0);
+        add(main_vbox);
         main_vbox.show_all();
         main_vbox.show_all();
-        this.vbox_right.hide ();
-  } 
+        this.vbox_right.hide();
+    
 
 
-    private void set_atk_name_description (Widget widget, string name, string description)
+    private void set_atk_name_description(Widget widget, string name, string description)
     {
     {
-       var atk_widget = widget.get_accessible ();
+        var atk_widget = widget.get_accessible();
 
 
-       atk_widget.set_name (name);
-       atk_widget.set_description (description);
+        atk_widget.set_name(name);
+        atk_widget.set_description(description);
     }
 
     private void connect_signals()
     {
     }
 
     private void connect_signals()
     {
-        this.destroy.connect (Gtk.main_quit);
+        this.destroy.connect(Gtk.main_quit);
         this.identities_manager.card_list_changed.connect(this.on_card_list_changed);
     }
 
         this.identities_manager.card_list_changed.connect(this.on_card_list_changed);
     }
 
-    private static void set_atk_relation (Widget widget, Widget target_widget, Atk.RelationType relationship)
+    private static void set_atk_relation(Widget widget, Widget target_widget, Atk.RelationType relationship)
     {
     {
-        var atk_widget = widget.get_accessible ();
-        var atk_target_widget = target_widget.get_accessible ();
+        var atk_widget = widget.get_accessible();
+        var atk_target_widget = target_widget.get_accessible();
 
 
-        atk_widget.add_relationship (relationship, atk_target_widget);
+        atk_widget.add_relationship(relationship, atk_target_widget);
     }
 }
 
     }
 }
 
index 0838f66..028773f 100644 (file)
@@ -50,33 +50,35 @@ public class IdentityManagerApp {
     public IdentityManagerView view;
     private MoonshotServer ipc_server;
 
     public IdentityManagerView view;
     private MoonshotServer ipc_server;
 
-#if OS_MACOS
-       public OSXApplication osxApp;
+    #if OS_MACOS
+    public OSXApplication osxApp;
   
     // the signal handler function.
     // the current instance of our app class is passed in the 
     // id_manager_app_instanceparameter 
   
     // the signal handler function.
     // the current instance of our app class is passed in the 
     // id_manager_app_instanceparameter 
-       public static bool on_osx_open_files (OSXApplication osx_app_instance, 
-                                        string file_name, 
-                                        IdentityManagerApp id_manager_app_instance ) {
-    int added_cards = id_manager_app_instance.ipc_server.install_from_file(file_name);
-    return true;
-       }
-#endif
+    public static bool on_osx_open_files(OSXApplication osx_app_instance, 
+                                         string file_name, 
+                                         IdentityManagerApp id_manager_app_instance ) {
+        int added_cards = id_manager_app_instance.ipc_server.install_from_file(file_name);
+        return true;
+    }
+    #endif
 
     private const int WINDOW_WIDTH = 400;
     private const int WINDOW_HEIGHT = 500;
     public void show() {
         if (view != null) view.make_visible();
     }
 
     private const int WINDOW_WIDTH = 400;
     private const int WINDOW_HEIGHT = 500;
     public void show() {
         if (view != null) view.make_visible();
     }
-       
-    public IdentityManagerApp (bool headless, bool use_flat_file_store) {
+
+    public IdentityManagerApp(bool headless, bool use_flat_file_store) {
         use_flat_file_store |= UserForcesFlatFileStore();
         use_flat_file_store |= UserForcesFlatFileStore();
-#if GNOME_KEYRING
-        bool keyring_available = (!use_flat_file_store) && GnomeKeyring.is_available();
-#else
-        bool keyring_available = false;
-#endif
+
+        #if GNOME_KEYRING
+            bool keyring_available = (!use_flat_file_store) && GnomeKeyring.is_available();
+        #else
+            bool keyring_available = false;
+        #endif
+
         IIdentityCardStore.StoreType store_type;
         if (headless || use_flat_file_store || !keyring_available)
             store_type = IIdentityCardStore.StoreType.FLAT_FILE;
         IIdentityCardStore.StoreType store_type;
         if (headless || use_flat_file_store || !keyring_available)
             store_type = IIdentityCardStore.StoreType.FLAT_FILE;
@@ -91,30 +93,28 @@ public class IdentityManagerApp {
 
         if (!headless)
             view = new IdentityManagerView(this);
 
         if (!headless)
             view = new IdentityManagerView(this);
-        LinkedList<IdCard> card_list = model.get_card_list() ;
+        LinkedList<IdCard> card_list = model.get_card_list();
         if (card_list.size > 0)
             this.default_id_card = card_list.last();
 
         if (card_list.size > 0)
             this.default_id_card = card_list.last();
 
-        init_ipc_server ();
-
-#if OS_MACOS
+        init_ipc_server();
 
 
+        #if OS_MACOS
         osxApp = OSXApplication.get_instance();
         osxApp = OSXApplication.get_instance();
-        // The 'correct' way of connrcting wont work in Mac OS with Vala 0.12  e.g.    
-        //             osxApp.ns_application_open_file.connect(install_from_file);
+        // The 'correct' way of connecting won't work in Mac OS with Vala 0.12; e.g.
+        //     osxApp.ns_application_open_file.connect(install_from_file);
         // so we have to use this old way
         Signal.connect(osxApp, "NSApplicationOpenFile", (GLib.Callback)(on_osx_open_files), this);
         // so we have to use this old way
         Signal.connect(osxApp, "NSApplicationOpenFile", (GLib.Callback)(on_osx_open_files), this);
-
-#endif
+        #endif
     }
 
     }
 
-    public bool add_identity (IdCard id, bool force_flat_file_store) {
+    public bool add_identity(IdCard id, bool force_flat_file_store) {
         if (view != null) return view.add_identity(id, force_flat_file_store);
         model.add_card(id, force_flat_file_store);
         return true;
     }
 
         if (view != null) return view.add_identity(id, force_flat_file_store);
         model.add_card(id, force_flat_file_store);
         return true;
     }
 
-    public void select_identity (IdentityRequest request) {
+    public void select_identity(IdentityRequest request) {
         IdCard identity = null;
 
         if (request.select_default)
         IdCard identity = null;
 
         if (request.select_default)
@@ -144,7 +144,7 @@ public class IdentityManagerApp {
                     {
                         if (request.service == srv)
                         {
                     {
                         if (request.service == srv)
                         {
-                            request.candidates.append (id);
+                            request.candidates.append(id);
                             continue;
                         }
                     }
                             continue;
                         }
                     }
@@ -167,19 +167,19 @@ public class IdentityManagerApp {
                             has_service = true;
                             continue;
                         }
                             has_service = true;
                             continue;
                         }
-                        services_list.append (srv);
+                        services_list.append(srv);
                     }
                     
                     if (!has_service)
                         continue;
 
                     }
                     
                     if (!has_service)
                         continue;
 
-                    if (services_list.length () == 0)
+                    if (services_list.length() == 0)
                     {
                         id.services = {};
                         continue;
                     }
 
                     {
                         id.services = {};
                         continue;
                     }
 
-                    string[] services = new string[services_list.length ()];
+                    string[] services = new string[services_list.length()];
                     foreach (string srv in services_list)
                     {
                         services[i] = srv;
                     foreach (string srv in services_list)
                     {
                         services[i] = srv;
@@ -191,16 +191,16 @@ public class IdentityManagerApp {
             }
 
             /* If there are no candidates we use the service matching rules */
             }
 
             /* If there are no candidates we use the service matching rules */
-            if ((identity==null) && (request.candidates.length () == 0))
+            if ((identity == null) && (request.candidates.length() == 0))
             {
                 foreach (IdCard id in model.get_card_list())
                 {
                     foreach (Rule rule in id.rules)
                     {
             {
                 foreach (IdCard id in model.get_card_list())
                 {
                     foreach (Rule rule in id.rules)
                     {
-                        if (!match_service_pattern (request.service, rule.pattern))
+                        if (!match_service_pattern(request.service, rule.pattern))
                             continue;
 
                             continue;
 
-                        request.candidates.append (id);
+                        request.candidates.append(id);
 
                         if (rule.always_confirm == "true")
                             confirm = true;
 
                         if (rule.always_confirm == "true")
                             confirm = true;
@@ -220,10 +220,10 @@ public class IdentityManagerApp {
                 identity.temporary = true;
             }
             if (identity == null) {
                 identity.temporary = true;
             }
             if (identity == null) {
-                if (request.candidates.length () != 1) {
+                if (request.candidates.length() != 1) {
                     confirm = true;
                 } else {
                     confirm = true;
                 } else {
-                    identity = request.candidates.nth_data (0);                    
+                    identity = request.candidates.nth_data(0);                    
                 }
             }
 
                 }
             }
 
@@ -231,7 +231,7 @@ public class IdentityManagerApp {
             {
                 if (!explicitly_launched)
                     show();
             {
                 if (!explicitly_launched)
                     show();
-               view.queue_identity_request(request);
+                view.queue_identity_request(request);
                 return;
             }
         }
                 return;
             }
         }
@@ -242,58 +242,56 @@ public class IdentityManagerApp {
                 if (view != null) {
                     identity = view.check_add_password(identity, request, model);
                 }
                 if (view != null) {
                     identity = view.check_add_password(identity, request, model);
                 }
-                request.return_identity (identity);
+                request.return_identity(identity);
 // The following occasionally causes the app to exit without sending the dbus
 // reply, so for now we just don't exit
 //                if (!explicitly_launched)
 // The following occasionally causes the app to exit without sending the dbus
 // reply, so for now we just don't exit
 //                if (!explicitly_launched)
-//                    Idle.add( () => { Gtk.main_quit(); return false; } );
+//                    Idle.add(() => { Gtk.main_quit(); return false; } );
                 return false;
             }
                 return false;
             }
-        );
+            );
         return;
     }
 
         return;
     }
 
-    private bool match_service_pattern (string service, string pattern)
-    {
-        var pspec = new PatternSpec (pattern);
-        return pspec.match_string (service);
-    }   
+    private bool match_service_pattern(string service, string pattern)
+        {
+            var pspec = new PatternSpec(pattern);
+            return pspec.match_string(service);
+        }   
     
     
-#if IPC_MSRPC
-    private void init_ipc_server ()
-    {
+    #if IPC_MSRPC
+    private void init_ipc_server() {
         // Errors will currently be sent via g_log - ie. to an
         // obtrusive message box, on Windows
         //
         // Errors will currently be sent via g_log - ie. to an
         // obtrusive message box, on Windows
         //
-        this.ipc_server = MoonshotServer.get_instance ();
-        MoonshotServer.start (this);
+        this.ipc_server = MoonshotServer.get_instance();
+        MoonshotServer.start(this);
     }
     }
-#elif IPC_DBUS_GLIB
-    private void init_ipc_server ()
-    {
+    #elif IPC_DBUS_GLIB
+    private void init_ipc_server() {
         try {
         try {
-            var conn = DBus.Bus.get (DBus.BusType.SESSION);
-            dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus",
-                                                       "/org/freedesktop/DBus",
-                                                       "org.freedesktop.DBus");
+            var conn = DBus.Bus.get(DBus.BusType.SESSION);
+            dynamic DBus.Object bus = conn.get_object("org.freedesktop.DBus",
+                                                      "/org/freedesktop/DBus",
+                                                      "org.freedesktop.DBus");
 
             // try to register service in session bus
 
             // try to register service in session bus
-            uint reply = bus.request_name ("org.janet.Moonshot", (uint) 0);
+            uint reply = bus.request_name("org.janet.Moonshot", (uint) 0);
             if (reply == DBus.RequestNameReply.PRIMARY_OWNER)
             {
             if (reply == DBus.RequestNameReply.PRIMARY_OWNER)
             {
-                this.ipc_server = new MoonshotServer (this);
-                conn.register_object ("/org/janet/moonshot", ipc_server);
+                this.ipc_server = new MoonshotServer(this);
+                conn.register_object("/org/janet/moonshot", ipc_server);
             } else {
             } else {
-                bool shown=false;
+                bool shown = false;
                 GLib.Error e;
                 GLib.Error e;
-                DBus.Object manager_proxy = conn.get_object ("org.janet.Moonshot",
-                                                             "/org/janet/moonshot",
-                                                             "org.janet.Moonshot");
+                DBus.Object manager_proxy = conn.get_object("org.janet.Moonshot",
+                                                            "/org/janet/moonshot",
+                                                            "org.janet.Moonshot");
                 if (manager_proxy != null)
                     manager_proxy.call("ShowUi", out e, GLib.Type.INVALID, typeof(bool), out shown, GLib.Type.INVALID);
 
                 if (!shown) {
                 if (manager_proxy != null)
                     manager_proxy.call("ShowUi", out e, GLib.Type.INVALID, typeof(bool), out shown, GLib.Type.INVALID);
 
                 if (!shown) {
-                    GLib.error ("Couldn't own name org.janet.Moonshot on dbus or show previously launched identity manager.");
+                    GLib.error("Couldn't own name org.janet.Moonshot on dbus or show previously launched identity manager.");
                 } else {
                     stdout.printf("Showed previously launched identity manager.\n");
                     GLib.Process.exit(0);
                 } else {
                     stdout.printf("Showed previously launched identity manager.\n");
                     GLib.Process.exit(0);
@@ -302,119 +300,117 @@ public class IdentityManagerApp {
         }
         catch (DBus.Error e)
         {
         }
         catch (DBus.Error e)
         {
-            stderr.printf ("%s\n", e.message);
+            stderr.printf("%s\n", e.message);
         }
     }
         }
     }
-#else
-    private void bus_acquired_cb (DBusConnection conn)
-    {
+    #else
+    private void bus_acquired_cb(DBusConnection conn) {
         try {
         try {
-            conn.register_object ("/org/janet/moonshot", ipc_server);
+            conn.register_object("/org/janet/moonshot", ipc_server);
         }
         catch (Error e)
         {
         }
         catch (Error e)
         {
-            stderr.printf ("%s\n", e.message);
+            stderr.printf("%s\n", e.message);
         }
     }
 
         }
     }
 
-    private void init_ipc_server ()
-    {
-        this.ipc_server = new MoonshotServer (this);
-        GLib.Bus.own_name (GLib.BusType.SESSION,
-                           "org.janet.Moonshot",
-                           GLib.BusNameOwnerFlags.NONE,
-                           bus_acquired_cb,
-                           (conn, name) => {},
-                           (conn, name) => {
-                               bool shown=false;
-                               try {
-                                   IIdentityManager manager = Bus.get_proxy_sync (BusType.SESSION, name, "/org/janet/moonshot");
-                                   shown = manager.show_ui();
-                               } catch (IOError e) {
-                               }
-                               if (!shown) {
-                                   GLib.error ("Couldn't own name %s on dbus or show previously launched identity manager.", name);
-                               } else {
-                                   stdout.printf("Showed previously launched identity manager.\n");
-                                   GLib.Process.exit(0);
-                               }
-                           });
+    private void init_ipc_server() {
+        this.ipc_server = new MoonshotServer(this);
+        GLib.Bus.own_name(GLib.BusType.SESSION,
+                          "org.janet.Moonshot",
+                          GLib.BusNameOwnerFlags.NONE,
+                          bus_acquired_cb,
+                          (conn, name) => {},
+                          (conn, name) => {
+                              bool shown = false;
+                              try {
+                                  IIdentityManager manager = Bus.get_proxy_sync(BusType.SESSION, name, "/org/janet/moonshot");
+                                  shown = manager.show_ui();
+                              } catch (IOError e) {
+                              }
+                              if (!shown) {
+                                  GLib.error("Couldn't own name %s on dbus or show previously launched identity manager.", name);
+                              } else {
+                                  stdout.printf("Showed previously launched identity manager.\n");
+                                  GLib.Process.exit(0);
+                              }
+                          });
     }
     }
-#endif
+    #endif
 }
 
 static bool explicitly_launched = true;
 static bool use_flat_file_store = false;
 const GLib.OptionEntry[] options = {
 }
 
 static bool explicitly_launched = true;
 static bool use_flat_file_store = false;
 const GLib.OptionEntry[] options = {
-    {"dbus-launched",0,GLib.OptionFlags.REVERSE,GLib.OptionArg.NONE,
-     ref explicitly_launched,"launch for dbus rpc use",null},
-    {"flat-file-store",0,0,GLib.OptionArg.NONE,
-     ref use_flat_file_store,"force use of flat file identity store (used by default only for headless operation)",null},
+    {"dbus-launched", 0, GLib.OptionFlags.REVERSE, GLib.OptionArg.NONE,
+     ref explicitly_launched, "launch for dbus rpc use", null},
+    {"flat-file-store", 0, 0, GLib.OptionArg.NONE,
+     ref use_flat_file_store, "force use of flat file identity store (used by default only for headless operation)", null},
     {null}
 };
 
 
     {null}
 };
 
 
-public static int main(string[] args){
-#if IPC_MSRPC
-       bool headless = false;
-#else
-        bool headless = GLib.Environment.get_variable("DISPLAY") == null;
-#endif
+public static int main(string[] args) {
+    #if IPC_MSRPC
+        bool headless = false;
+    #else
+        bool headless = (GLib.Environment.get_variable("DISPLAY") == null);
+    #endif
 
 
-        if (headless) {
-            try {
-                var opt_context = new OptionContext(null);
-                opt_context.set_help_enabled (true);
-                opt_context.add_main_entries (options, null);
-                opt_context.parse(ref args);
-            } catch (OptionError e) {
-                stdout.printf(_("error: %s\n"),e.message);
-                stdout.printf(_("Run '%s --help' to see a full list of available options\n"), args[0]);
-                return -1;
-            }
-            explicitly_launched = false;
-        } else {
-            try {
-                if (!Gtk.init_with_args(ref args, _(""), options, null)) {
-                    stdout.printf(_("unable to initialize window\n"));
-                    return -1;
-                }
-            } catch (GLib.Error e) {
-                stdout.printf(_("error: %s\n"),e.message);
-                stdout.printf(_("Run '%s --help' to see a full list of available options\n"), args[0]);
+    if (headless) {
+        try {
+            var opt_context = new OptionContext(null);
+            opt_context.set_help_enabled(true);
+            opt_context.add_main_entries(options, null);
+            opt_context.parse(ref args);
+        } catch (OptionError e) {
+            stdout.printf(_("error: %s\n"),e.message);
+            stdout.printf(_("Run '%s --help' to see a full list of available options\n"), args[0]);
+            return -1;
+        }
+        explicitly_launched = false;
+    } else {
+        try {
+            if (!Gtk.init_with_args(ref args, _(""), options, null)) {
+                stdout.printf(_("unable to initialize window\n"));
                 return -1;
             }
                 return -1;
             }
-            gtk_available = true;
+        } catch (GLib.Error e) {
+            stdout.printf(_("error: %s\n"),e.message);
+            stdout.printf(_("Run '%s --help' to see a full list of available options\n"), args[0]);
+            return -1;
         }
         }
+        gtk_available = true;
+    }
 
 
-#if OS_WIN32
-        // Force specific theme settings on Windows without requiring a gtkrc file
-        Gtk.Settings settings = Gtk.Settings.get_default ();
-        settings.set_string_property ("gtk-theme-name", "ms-windows", "moonshot");
-        settings.set_long_property ("gtk-menu-images", 0, "moonshot");
-#endif
+    #if OS_WIN32
+    // Force specific theme settings on Windows without requiring a gtkrc file
+    Gtk.Settings settings = Gtk.Settings.get_default();
+    settings.set_string_property("gtk-theme-name", "ms-windows", "moonshot");
+    settings.set_long_property("gtk-menu-images", 0, "moonshot");
+    #endif
 
 
-        Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
-        Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
-        Intl.textdomain (Config.GETTEXT_PACKAGE);
+    Intl.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
+    Intl.bind_textdomain_codeset(Config.GETTEXT_PACKAGE, "UTF-8");
+    Intl.textdomain(Config.GETTEXT_PACKAGE);
        
        
-          
-        var app = new IdentityManagerApp(headless, use_flat_file_store);
-        app.explicitly_launched = explicitly_launched;
+    var app = new IdentityManagerApp(headless, use_flat_file_store);
+    app.explicitly_launched = explicitly_launched;
         
         
-       if (app.explicitly_launched) {
-            app.show();
-        }
-
-        if (headless) {
-#if !IPC_MSRPC
-            MainLoop loop = new MainLoop();
-            loop.run();
-#endif
-        } else {
-            Gtk.main();
-        }
+    if (app.explicitly_launched) {
+        app.show();
+    }
 
 
-        return 0;
+    if (headless) {
+        #if !IPC_MSRPC
+        MainLoop loop = new MainLoop();
+        loop.run();
+        #endif
+    }
+    else {
+        Gtk.main();
     }
 
     }
 
+    return 0;
+}
+
index 2137cce..8d0b24e 100644 (file)
@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
 */
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
 */
-public delegate void ReturnIdentityCallback (IdentityRequest request);
+public delegate void ReturnIdentityCallback(IdentityRequest request);
 
 public class IdentityRequest : Object {
     public IdCard? id_card = null;
 
 public class IdentityRequest : Object {
     public IdCard? id_card = null;
@@ -44,10 +44,10 @@ public class IdentityRequest : Object {
 
     ReturnIdentityCallback callback = null;
 
 
     ReturnIdentityCallback callback = null;
 
-    public IdentityRequest (IdentityManagerApp           app,
-                            string                       nai,
-                            string                       password,
-                            string                       service)
+    public IdentityRequest(IdentityManagerApp           app,
+                           string                       nai,
+                           string                       password,
+                           string                       service)
     {
         this.parent_app = app;
         this.nai = nai;
     {
         this.parent_app = app;
         this.nai = nai;
@@ -55,23 +55,23 @@ public class IdentityRequest : Object {
         this.service = service;
     }
 
         this.service = service;
     }
 
-    public IdentityRequest.default (IdentityManagerApp app)
+    public IdentityRequest.default(IdentityManagerApp app)
     {
         this.parent_app = app;
         this.select_default = true;
     }
 
     {
         this.parent_app = app;
         this.select_default = true;
     }
 
-    public void set_callback (owned ReturnIdentityCallback cb)
+    public void set_callback(owned ReturnIdentityCallback cb)
     {
     {
-#if VALA_0_12
-        this.callback = ((owned) cb);
-#else
-        this.callback = ((IdCard) => cb (IdCard));
-#endif
+        #if VALA_0_12
+            this.callback = ((owned) cb);
+        #else
+            this.callback = ((IdCard) => cb(IdCard));
+        #endif
     }
 
     }
 
-    public bool execute () {
-        parent_app.select_identity (this);
+    public bool execute() {
+        parent_app.select_identity(this);
 
         /* This function works as a GSourceFunc, so it can be passed to
          * the main loop from other threads
 
         /* This function works as a GSourceFunc, so it can be passed to
          * the main loop from other threads
@@ -79,7 +79,7 @@ public class IdentityRequest : Object {
         return false;
     }
 
         return false;
     }
 
-    public void return_identity (IdCard? id_card) {
+    public void return_identity(IdCard? id_card) {
         this.id_card = id_card;
         this.complete = true;
 
         this.id_card = id_card;
         this.complete = true;
 
@@ -103,12 +103,12 @@ public class IdentityRequest : Object {
                 services[id_card.services.length] = this.service;
                 id_card.services = services;
 
                 services[id_card.services.length] = this.service;
                 id_card.services = services;
 
-                this.id_card = this.parent_app.model.update_card (id_card);
+                this.id_card = this.parent_app.model.update_card(id_card);
             }
         }
 
         return_if_fail (callback != null);
             }
         }
 
         return_if_fail (callback != null);
-        callback (this);
+        callback(this);
     }
 
 #if OS_WIN32
     }
 
 #if OS_WIN32
index ab1ff1e..6b36022 100644 (file)
@@ -40,23 +40,25 @@ public class KeyringStore : Object, IIdentityCardStore {
 
     public void add_card(IdCard card) {
         id_card_list.add(card);
 
     public void add_card(IdCard card) {
         id_card_list.add(card);
-        store_id_cards ();
+        store_id_cards();
     }
 
     public IdCard? update_card(IdCard card) {
         id_card_list.remove(card);
         id_card_list.add(card);
     }
 
     public IdCard? update_card(IdCard card) {
         id_card_list.remove(card);
         id_card_list.add(card);
-        store_id_cards ();
-        foreach (IdCard idcard in id_card_list)
-            if (idcard.display_name == card.display_name)
+        store_id_cards();
+        foreach (IdCard idcard in id_card_list) {
+            if (idcard.display_name == card.display_name) {
                 return idcard;
                 return idcard;
+            }
+        }
         return null;
     }
 
     public bool remove_card(IdCard card) {
         bool retval = id_card_list.remove(card);
         if (retval)
         return null;
     }
 
     public bool remove_card(IdCard card) {
         bool retval = id_card_list.remove(card);
         if (retval)
-            store_id_cards ();
+            store_id_cards();
         return retval;
     }
 
         return retval;
     }
 
@@ -70,9 +72,9 @@ public class KeyringStore : Object, IIdentityCardStore {
 
     /* clear all keyring-stored ids (in preparation to store current list) */
     private void clear_keyring() {
 
     /* clear all keyring-stored ids (in preparation to store current list) */
     private void clear_keyring() {
-       GnomeKeyring.AttributeList match = new GnomeKeyring.AttributeList();
-       match.append_string(keyring_store_attribute, keyring_store_version);
-       GLib.List<GnomeKeyring.Found> items;
+        GnomeKeyring.AttributeList match = new GnomeKeyring.AttributeList();
+        match.append_string(keyring_store_attribute, keyring_store_version);
+        GLib.List<GnomeKeyring.Found> items;
         GnomeKeyring.find_items_sync(item_type, match, out items);
         foreach(unowned GnomeKeyring.Found entry in items) {
             GnomeKeyring.Result result = GnomeKeyring.item_delete_sync(null, entry.item_id);
         GnomeKeyring.find_items_sync(item_type, match, out items);
         foreach(unowned GnomeKeyring.Found entry in items) {
             GnomeKeyring.Result result = GnomeKeyring.item_delete_sync(null, entry.item_id);
@@ -85,26 +87,26 @@ public class KeyringStore : Object, IIdentityCardStore {
     private void load_id_cards() {
         id_card_list.clear();
 
     private void load_id_cards() {
         id_card_list.clear();
 
-       GnomeKeyring.AttributeList match = new GnomeKeyring.AttributeList();
-       match.append_string(keyring_store_attribute, keyring_store_version);
-       GLib.List<GnomeKeyring.Found> items;
+        GnomeKeyring.AttributeList match = new GnomeKeyring.AttributeList();
+        match.append_string(keyring_store_attribute, keyring_store_version);
+        GLib.List<GnomeKeyring.Found> items;
         GnomeKeyring.find_items_sync(item_type, match, out items);
         foreach(unowned GnomeKeyring.Found entry in items) {
         GnomeKeyring.find_items_sync(item_type, match, out items);
         foreach(unowned GnomeKeyring.Found entry in items) {
-            IdCard id_card = new IdCard ();
+            IdCard id_card = new IdCard();
             int i;
             int rules_patterns_index = -1;
             int rules_always_confirm_index = -1;
             string store_password = null;
             int i;
             int rules_patterns_index = -1;
             int rules_always_confirm_index = -1;
             string store_password = null;
-            for (i=0; i<entry.attributes.len; i++) {
+            for (i = 0; i < entry.attributes.len; i++) {
                 var attribute = ((GnomeKeyring.Attribute *) entry.attributes.data)[i];
                 var attribute = ((GnomeKeyring.Attribute *) entry.attributes.data)[i];
-               string value = attribute.string_value;
-               if (attribute.name == "Issuer") {
+                string value = attribute.string_value;
+                if (attribute.name == "Issuer") {
                     id_card.issuer = value;
                     id_card.issuer = value;
-               } else if (attribute.name == "Username") {
+                } else if (attribute.name == "Username") {
                     id_card.username = value;
                     id_card.username = value;
-               } else if (attribute.name == "DisplayName") {
+                } else if (attribute.name == "DisplayName") {
                     id_card.display_name = value;
                     id_card.display_name = value;
-               } else if (attribute.name == "Services") {
+                } else if (attribute.name == "Services") {
                     id_card.services = value.split(";");
                 } else if (attribute.name == "Rules-Pattern") {
                     rules_patterns_index = i;
                     id_card.services = value.split(";");
                 } else if (attribute.name == "Rules-Pattern") {
                     rules_patterns_index = i;
@@ -128,12 +130,12 @@ public class KeyringStore : Object, IIdentityCardStore {
                 string [] rules_always_confirm = rules_always_confirm_all.split(";");
                 string [] rules_patterns = rules_patterns_all.split(";");
                 if (rules_patterns.length == rules_always_confirm.length) {
                 string [] rules_always_confirm = rules_always_confirm_all.split(";");
                 string [] rules_patterns = rules_patterns_all.split(";");
                 if (rules_patterns.length == rules_always_confirm.length) {
-                   Rule[] rules = new Rule[rules_patterns.length];
-                   for (int j=0; j<rules_patterns.length; j++) {
-                       rules[j].pattern = rules_patterns[j];
-                       rules[j].always_confirm = rules_always_confirm[j];
-                   }
-                   id_card.rules = rules;
+                    Rule[] rules = new Rule[rules_patterns.length];
+                    for (int j = 0; j < rules_patterns.length; j++) {
+                        rules[j].pattern = rules_patterns[j];
+                        rules[j].always_confirm = rules_always_confirm[j];
+                    }
+                    id_card.rules = rules;
                 }
             }
 
                 }
             }
 
@@ -150,7 +152,7 @@ public class KeyringStore : Object, IIdentityCardStore {
         }
     }
 
         }
     }
 
-    public void store_id_cards () {
+    public void store_id_cards() {
         clear_keyring();
         foreach (IdCard id_card in this.id_card_list) {
             /* workaround for Centos vala array property bug: use temp array */
         clear_keyring();
         foreach (IdCard id_card in this.id_card_list) {
             /* workaround for Centos vala array property bug: use temp array */
@@ -159,7 +161,7 @@ public class KeyringStore : Object, IIdentityCardStore {
             string[] rules_patterns = new string[rules.length];
             string[] rules_always_conf = new string[rules.length];
             
             string[] rules_patterns = new string[rules.length];
             string[] rules_always_conf = new string[rules.length];
             
-            for (int i=0; i<rules.length; i++) {
+            for (int i = 0; i < rules.length; i++) {
                 rules_patterns[i] = rules[i].pattern;
                 rules_always_conf[i] = rules[i].always_confirm;
             }
                 rules_patterns[i] = rules[i].pattern;
                 rules_always_conf[i] = rules[i].always_confirm;
             }
@@ -182,9 +184,9 @@ public class KeyringStore : Object, IIdentityCardStore {
             attributes.append_string("StorePassword", id_card.store_password ? "yes" : "no");
 
             GnomeKeyring.Result result = GnomeKeyring.item_create_sync(null,
             attributes.append_string("StorePassword", id_card.store_password ? "yes" : "no");
 
             GnomeKeyring.Result result = GnomeKeyring.item_create_sync(null,
-                item_type, id_card.display_name, attributes,
-                id_card.store_password ? id_card.password : "",
-                true, out item_id);
+                                                                       item_type, id_card.display_name, attributes,
+                                                                       id_card.store_password ? id_card.password : "",
+                                                                       true, out item_id);
             if (result != GnomeKeyring.Result.OK) {
                 stdout.printf("GnomeKeyring.item_create_sync() failed. result: %d", result);
             }
             if (result != GnomeKeyring.Result.OK) {
                 stdout.printf("GnomeKeyring.item_create_sync() failed. result: %d", result);
             }
@@ -192,7 +194,7 @@ public class KeyringStore : Object, IIdentityCardStore {
         load_id_cards();
     }
 
         load_id_cards();
     }
 
-    public KeyringStore () {
+    public KeyringStore() {
         id_card_list = new LinkedList<IdCard>();
         load_id_cards();
     }
         id_card_list = new LinkedList<IdCard>();
         load_id_cards();
     }
index 8e4db0a..8281d9d 100644 (file)
@@ -28,7 +28,7 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
-*/
+ */
 using Gee; 
 
 public class LocalFlatFileStore : Object, IIdentityCardStore {
 using Gee; 
 
 public class LocalFlatFileStore : Object, IIdentityCardStore {
@@ -37,22 +37,22 @@ public class LocalFlatFileStore : Object, IIdentityCardStore {
 
     public void add_card(IdCard card) {
         id_card_list.add(card);
 
     public void add_card(IdCard card) {
         id_card_list.add(card);
-        store_id_cards ();
+        store_id_cards();
     }
 
     public IdCard? update_card(IdCard card) {
         id_card_list.remove(card);
         id_card_list.add(card);
     }
 
     public IdCard? update_card(IdCard card) {
         id_card_list.remove(card);
         id_card_list.add(card);
-        store_id_cards ();
+        store_id_cards();
         foreach(IdCard idcard in id_card_list)
         foreach(IdCard idcard in id_card_list)
-            if (idcard.display_name == card.display_name)
-                return idcard;
+        if (idcard.display_name == card.display_name)
+            return idcard;
         return null;
     }
 
     public bool remove_card(IdCard card) {
         if (id_card_list.remove(card)) {
         return null;
     }
 
     public bool remove_card(IdCard card) {
         if (id_card_list.remove(card)) {
-            store_id_cards ();
+            store_id_cards();
             return true;
         }
         return false;
             return true;
         }
         return false;
@@ -68,75 +68,75 @@ public class LocalFlatFileStore : Object, IIdentityCardStore {
      
     private void load_id_cards() {
         id_card_list.clear();
      
     private void load_id_cards() {
         id_card_list.clear();
-        var key_file = new KeyFile ();
-        var path = get_data_dir ();
-        var filename = Path.build_filename (path, FILE_NAME);
+        var key_file = new KeyFile();
+        var path = get_data_dir();
+        var filename = Path.build_filename(path, FILE_NAME);
         
         try {
         
         try {
-            key_file.load_from_file (filename, KeyFileFlags.NONE);
+            key_file.load_from_file(filename, KeyFileFlags.NONE);
         }
         catch (Error e) {
             stdout.printf("Error: %s\n", e.message);
             return;
         }
 
         }
         catch (Error e) {
             stdout.printf("Error: %s\n", e.message);
             return;
         }
 
-        var identities_uris = key_file.get_groups ();
+        var identities_uris = key_file.get_groups();
         foreach (string identity in identities_uris) {
             try {
         foreach (string identity in identities_uris) {
             try {
-                IdCard id_card = new IdCard ();
-
-                id_card.issuer = key_file.get_string (identity, "Issuer");
-                id_card.username = key_file.get_string (identity, "Username");
-                id_card.password = key_file.get_string (identity, "Password");
-                id_card.services = key_file.get_string_list (identity, "Services");
-                id_card.display_name = key_file.get_string (identity, "DisplayName");
-                if (key_file.has_key (identity, "StorePassword")) {
-                    id_card.store_password = (key_file.get_string (identity, "StorePassword") == "yes");
+                IdCard id_card = new IdCard();
+
+                id_card.issuer = key_file.get_string(identity, "Issuer");
+                id_card.username = key_file.get_string(identity, "Username");
+                id_card.password = key_file.get_string(identity, "Password");
+                id_card.services = key_file.get_string_list(identity, "Services");
+                id_card.display_name = key_file.get_string(identity, "DisplayName");
+                if (key_file.has_key(identity, "StorePassword")) {
+                    id_card.store_password = (key_file.get_string(identity, "StorePassword") == "yes");
                 } else {
                     id_card.store_password = (id_card.password != null) && (id_card.password != "");
                 }
                 
                 } else {
                     id_card.store_password = (id_card.password != null) && (id_card.password != "");
                 }
                 
-                if (key_file.has_key (identity, "Rules-Patterns") &&
-                    key_file.has_key (identity, "Rules-AlwaysConfirm")) {
-                    string [] rules_patterns =    key_file.get_string_list (identity, "Rules-Patterns");
-                    string [] rules_always_conf = key_file.get_string_list (identity, "Rules-AlwaysConfirm");
+                if (key_file.has_key(identity, "Rules-Patterns") &&
+                    key_file.has_key(identity, "Rules-AlwaysConfirm")) {
+                    string [] rules_patterns =    key_file.get_string_list(identity, "Rules-Patterns");
+                    string [] rules_always_conf = key_file.get_string_list(identity, "Rules-AlwaysConfirm");
                     
                     if (rules_patterns.length == rules_always_conf.length) {
                     
                     if (rules_patterns.length == rules_always_conf.length) {
-                      Rule[] rules = new Rule[rules_patterns.length];
-                      for (int i = 0; i < rules_patterns.length; i++) {
-                        rules[i] = {rules_patterns[i], rules_always_conf[i]};
-                      }
-                      id_card.rules = rules;
+                        Rule[] rules = new Rule[rules_patterns.length];
+                        for (int i = 0; i < rules_patterns.length; i++) {
+                            rules[i] = {rules_patterns[i], rules_always_conf[i]};
+                        }
+                        id_card.rules = rules;
                     }
                 }
                 
                 // Trust anchor 
                     }
                 }
                 
                 // Trust anchor 
-                id_card.trust_anchor.ca_cert = key_file.get_string (identity, "CA-Cert").strip();
-                id_card.trust_anchor.subject = key_file.get_string (identity, "Subject");
-                id_card.trust_anchor.subject_alt = key_file.get_string (identity, "SubjectAlt");
-                id_card.trust_anchor.server_cert = key_file.get_string (identity, "ServerCert");
+                id_card.trust_anchor.ca_cert = key_file.get_string(identity, "CA-Cert").strip();
+                id_card.trust_anchor.subject = key_file.get_string(identity, "Subject");
+                id_card.trust_anchor.subject_alt = key_file.get_string(identity, "SubjectAlt");
+                id_card.trust_anchor.server_cert = key_file.get_string(identity, "ServerCert");
 
 
-                id_card_list.add (id_card);
+                id_card_list.add(id_card);
             }
             catch (Error e) {
             }
             catch (Error e) {
-                stdout.printf ("Error:  %s\n", e.message);
+                stdout.printf("Error:  %s\n", e.message);
             }
         }
     }
 
     private string get_data_dir() {
         string path;
             }
         }
     }
 
     private string get_data_dir() {
         string path;
-        path = Path.build_filename (Environment.get_user_data_dir (),
-                                    Config.PACKAGE_TARNAME);
+        path = Path.build_filename(Environment.get_user_data_dir(),
+                                   Config.PACKAGE_TARNAME);
                                     
                                     
-        if (!FileUtils.test (path, FileTest.EXISTS)) {
-            DirUtils.create_with_parents (path, 0700);
+        if (!FileUtils.test(path, FileTest.EXISTS)) {
+            DirUtils.create_with_parents(path, 0700);
         }
         return path;
     }
     
         }
         return path;
     }
     
-    public void store_id_cards () {
-        var key_file = new KeyFile ();
+    public void store_id_cards() {
+        var key_file = new KeyFile();
         foreach (IdCard id_card in this.id_card_list) {
             /* workaround for Centos vala array property bug: use temp arrays */
             var rules = id_card.rules;
         foreach (IdCard id_card in this.id_card_list) {
             /* workaround for Centos vala array property bug: use temp arrays */
             var rules = id_card.rules;
@@ -145,57 +145,57 @@ public class LocalFlatFileStore : Object, IIdentityCardStore {
             string[] rules_patterns = new string[rules.length];
             string[] rules_always_conf = new string[rules.length];
             
             string[] rules_patterns = new string[rules.length];
             string[] rules_always_conf = new string[rules.length];
             
-            for (int i=0; i<rules.length; i++) {
-              rules_patterns[i] = rules[i].pattern;
-              rules_always_conf[i] = rules[i].always_confirm;
+            for (int i = 0; i < rules.length; i++) {
+                rules_patterns[i] = rules[i].pattern;
+                rules_always_conf[i] = rules[i].always_confirm;
             }
 
             }
 
-            key_file.set_string (id_card.display_name, "Issuer", id_card.issuer ?? "");
-            key_file.set_string (id_card.display_name, "DisplayName", id_card.display_name ?? "");
-            key_file.set_string (id_card.display_name, "Username", id_card.username ?? "");
+            key_file.set_string(id_card.display_name, "Issuer", id_card.issuer ?? "");
+            key_file.set_string(id_card.display_name, "DisplayName", id_card.display_name ?? "");
+            key_file.set_string(id_card.display_name, "Username", id_card.username ?? "");
             if (id_card.store_password && (id_card.password != null))
             if (id_card.store_password && (id_card.password != null))
-              key_file.set_string (id_card.display_name, "Password", id_card.password);
+                key_file.set_string(id_card.display_name, "Password", id_card.password);
             else
             else
-              key_file.set_string (id_card.display_name, "Password", "");
-            key_file.set_string_list (id_card.display_name, "Services", services ?? empty);
+                key_file.set_string(id_card.display_name, "Password", "");
+            key_file.set_string_list(id_card.display_name, "Services", services ?? empty);
 
             if (rules.length > 0) {
 
             if (rules.length > 0) {
-              key_file.set_string_list (id_card.display_name, "Rules-Patterns", rules_patterns);
-              key_file.set_string_list (id_card.display_name, "Rules-AlwaysConfirm", rules_always_conf);
+                key_file.set_string_list(id_card.display_name, "Rules-Patterns", rules_patterns);
+                key_file.set_string_list(id_card.display_name, "Rules-AlwaysConfirm", rules_always_conf);
             }
             }
-            key_file.set_string (id_card.display_name, "StorePassword", id_card.store_password ? "yes" : "no");
+            key_file.set_string(id_card.display_name, "StorePassword", id_card.store_password ? "yes" : "no");
             
             // Trust anchor 
             
             // Trust anchor 
-            key_file.set_string (id_card.display_name, "CA-Cert", id_card.trust_anchor.ca_cert ?? "");
-            key_file.set_string (id_card.display_name, "Subject", id_card.trust_anchor.subject ?? "");
-            key_file.set_string (id_card.display_name, "SubjectAlt", id_card.trust_anchor.subject_alt ?? "");
-            key_file.set_string (id_card.display_name, "ServerCert", id_card.trust_anchor.server_cert ?? "");
+            key_file.set_string(id_card.display_name, "CA-Cert", id_card.trust_anchor.ca_cert ?? "");
+            key_file.set_string(id_card.display_name, "Subject", id_card.trust_anchor.subject ?? "");
+            key_file.set_string(id_card.display_name, "SubjectAlt", id_card.trust_anchor.subject_alt ?? "");
+            key_file.set_string(id_card.display_name, "ServerCert", id_card.trust_anchor.server_cert ?? "");
         }
 
         }
 
-        var text = key_file.to_data (null);
+        var text = key_file.to_data(null);
 
         try {
 
         try {
-            var path = get_data_dir ();
-            var filename = Path.build_filename (path, FILE_NAME);
+            var path = get_data_dir();
+            var filename = Path.build_filename(path, FILE_NAME);
             var file  = File.new_for_path(filename);
             var stream = file.replace(null, false, FileCreateFlags.PRIVATE);
             var file  = File.new_for_path(filename);
             var stream = file.replace(null, false, FileCreateFlags.PRIVATE);
-#if GIO_VAPI_USES_ARRAYS
+            #if GIO_VAPI_USES_ARRAYS
             stream.write(text.data);
             stream.write(text.data);
-#else
+            #else
             var bits = text.data;
             stream.write(&bits[0], bits.length);
             var bits = text.data;
             stream.write(&bits[0], bits.length);
-#endif
-        }
+            #endif
+                }
         catch (Error e) {
         catch (Error e) {
-            stdout.printf ("Error:  %s\n", e.message);
+            stdout.printf("Error:  %s\n", e.message);
         }
 
         load_id_cards();
     }
 
         }
 
         load_id_cards();
     }
 
-     public LocalFlatFileStore () {
+    public LocalFlatFileStore() {
         id_card_list = new LinkedList<IdCard>();
         load_id_cards();
         id_card_list = new LinkedList<IdCard>();
         load_id_cards();
-     }
- }
+    }
+}
 
 
index 772d12c..e9b74f6 100644 (file)
@@ -37,86 +37,86 @@ class AddPasswordDialog : Dialog
     private CheckButton remember_checkbutton;
 
     public string password {
     private CheckButton remember_checkbutton;
 
     public string password {
-        get { return password_entry.get_text (); }
+        get { return password_entry.get_text(); }
     }
 
     public bool remember {
     }
 
     public bool remember {
-        get { return remember_checkbutton.get_active (); }
+        get { return remember_checkbutton.get_active(); }
     }
 
     }
 
-    public AddPasswordDialog (IdCard id_card, IdentityRequest? request)
+    public AddPasswordDialog(IdCard id_card, IdentityRequest? request)
     {
     {
-        this.set_title (_("Please enter password for ") + id_card.display_name);
-        this.set_modal (true);
+        this.set_title(_("Please enter password for ") + id_card.display_name);
+        this.set_modal(true);
 
 
-       if (request != null) {
-            this.add_buttons (_("Send"), ResponseType.OK,
-                              _("Return to application"), ResponseType.CANCEL);
+        if (request != null) {
+            this.add_buttons(_("Send"), ResponseType.OK,
+                             _("Return to application"), ResponseType.CANCEL);
         } else {
         } else {
-            this.add_buttons (_("Done"), ResponseType.OK,
-                              _("Cancel"), ResponseType.CANCEL);
+            this.add_buttons(_("Done"), ResponseType.OK,
+                             _("Cancel"), ResponseType.CANCEL);
         }
         }
-        this.set_default_response (ResponseType.OK);
+        this.set_default_response(ResponseType.OK);
 
 
-        var content_area = this.get_content_area ();
-        ((Box) content_area).set_spacing (12);
+        var content_area = this.get_content_area();
+        ((Box) content_area).set_spacing(12);
         Label service_label = null;
         Label service_value = null;
         Label service_label = null;
         Label service_value = null;
-       if (request != null) {
-            service_label = new Label (_("for use with:"));
-            service_label.set_alignment (1, (float) 0.5);
-            service_value = new Label (request.service);
-            service_value.set_alignment (0, (float) 0.5);
+        if (request != null) {
+            service_label = new Label(_("for use with:"));
+            service_label.set_alignment(1, (float) 0.5);
+            service_value = new Label(request.service);
+            service_value.set_alignment(0, (float) 0.5);
         }
 
         }
 
-        var nai_label = new Label (_("Network Access Identifier:"));
-        nai_label.set_alignment (1, (float) 0.5);
-        var nai_value = new Label (id_card.nai);
-        nai_value.set_alignment (0, (float) 0.5);
+        var nai_label = new Label(_("Network Access Identifier:"));
+        nai_label.set_alignment(1, (float) 0.5);
+        var nai_value = new Label(id_card.nai);
+        nai_value.set_alignment(0, (float) 0.5);
 
 
-        var password_label = new Label (_("Password:"));
-        password_label.set_alignment (1, (float) 0.5);
-        this.password_entry = new Entry ();
-        password_entry.set_invisible_char ('*');
-        password_entry.set_visibility (false);
+        var password_label = new Label(_("Password:"));
+        password_label.set_alignment(1, (float) 0.5);
+        this.password_entry = new Entry();
+        password_entry.set_invisible_char('*');
+        password_entry.set_visibility(false);
         password_entry.activates_default = true;
         password_entry.activates_default = true;
-        remember_checkbutton = new CheckButton.with_label (_("Remember password"));
+        remember_checkbutton = new CheckButton.with_label(_("Remember password"));
 
 
-        set_atk_relation (password_entry, password_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation(password_entry, password_entry, Atk.RelationType.LABEL_FOR);
 
 
-        var table = new Table (4, 2, false);
+        var table = new Table(4, 2, false);
         int row = 0;
         int row = 0;
-        table.set_col_spacings (10);
-        table.set_row_spacings (10);
+        table.set_col_spacings(10);
+        table.set_row_spacings(10);
         if (request != null) {
         if (request != null) {
-            table.attach_defaults (service_label, 0, 1, row, row + 1);
-            table.attach_defaults (service_value, 1, 2, row, row + 1);
+            table.attach_defaults(service_label, 0, 1, row, row + 1);
+            table.attach_defaults(service_value, 1, 2, row, row + 1);
             row++;
         }
             row++;
         }
-        table.attach_defaults (nai_label, 0, 1, row, row+1);
-        table.attach_defaults (nai_value, 1, 2, row, row+1);
+        table.attach_defaults(nai_label, 0, 1, row, row+1);
+        table.attach_defaults(nai_value, 1, 2, row, row+1);
         row++;
         row++;
-        table.attach_defaults (password_label, 0, 1, row, row+1);
-        table.attach_defaults (password_entry, 1, 2, row, row+1);
+        table.attach_defaults(password_label, 0, 1, row, row+1);
+        table.attach_defaults(password_entry, 1, 2, row, row+1);
         row++;
         row++;
-        table.attach_defaults (remember_checkbutton,  1, 2, row, row+1);
+        table.attach_defaults(remember_checkbutton,  1, 2, row, row+1);
 
 
-        var vbox = new VBox (false, 0);
-        vbox.set_border_width (6);
-        vbox.pack_start (table, false, false, 0);
+        var vbox = new VBox(false, 0);
+        vbox.set_border_width(6);
+        vbox.pack_start(table, false, false, 0);
 
 
-        ((Container) content_area).add (vbox);
+        ((Container) content_area).add(vbox);
 
 
-        this.set_border_width (6);
-        //this.set_resizable (false);
-        this.show_all ();
+        this.set_border_width(6);
+        //this.set_resizable(false);
+        this.show_all();
     }
 
     }
 
-    private void set_atk_relation (Widget widget, Widget target_widget, Atk.RelationType relationship)
+    private void set_atk_relation(Widget widget, Widget target_widget, Atk.RelationType relationship)
     {
     {
-        var atk_widget = widget.get_accessible ();
-        var atk_target_widget = target_widget.get_accessible ();
+        var atk_widget = widget.get_accessible();
+        var atk_target_widget = target_widget.get_accessible();
 
 
-        atk_widget.add_relationship (relationship, atk_target_widget);
+        atk_widget.add_relationship(relationship, atk_target_widget);
     }
 }
     }
 }
index de891cd..48a1fa6 100644 (file)
 
 namespace WebProvisioning
 { 
 
 namespace WebProvisioning
 { 
-  IdCard card;
-  IdCard[] cards;
+    IdCard card;
+    IdCard[] cards;
 
 
-  bool
-  check_stack (SList<string> stack, string[] reference)
-  {
-    if (stack.length () < reference.length)
-      return false;
+    bool check_stack(SList<string> stack, string[] reference) {
+
+        if (stack.length() < reference.length)
+            return false;
     
     
-    for (int i = 0; i<reference.length; i++)
-    {
-      if (stack.nth_data(i) != reference[i])
-        return false;
-    }
+        for (int i = 0; i < reference.length; i++)
+        {
+            if (stack.nth_data(i) != reference[i])
+                return false;
+        }
 
 
-    return true;
-  }
+        return true;
+    }
 
 
-  bool
-  always_confirm_handler (SList<string> stack)
-  {
-    string[] always_confirm_path = {"always-confirm", "rule", "selection-rules", "identity", "identities"};
+    bool always_confirm_handler(SList<string> stack)
+    {
+        string[] always_confirm_path = {"always-confirm", "rule", "selection-rules", "identity", "identities"};
     
     
-    return check_stack (stack, always_confirm_path);
-  }
+        return check_stack(stack, always_confirm_path);
+    }
   
   
-  bool
-  pattern_handler (SList<string> stack)
-  {
-    string[] pattern_path = {"pattern", "rule", "selection-rules", "identity", "identities"};
+    bool
+    pattern_handler(SList<string> stack)
+    {
+        string[] pattern_path = {"pattern", "rule", "selection-rules", "identity", "identities"};
     
     
-    return check_stack (stack, pattern_path);
-  }
+        return check_stack(stack, pattern_path);
+    }
 
 
-  bool
-  server_cert_handler (SList<string> stack)
-  {
-    string[] server_cert_path = {"server-cert", "trust-anchor", "identity", "identities"};
+    bool server_cert_handler(SList<string> stack)
+    {
+        string[] server_cert_path = {"server-cert", "trust-anchor", "identity", "identities"};
     
     
-    return check_stack (stack, server_cert_path);
-  }
+        return check_stack(stack, server_cert_path);
+    }
 
 
-  bool
-  subject_alt_handler (SList<string> stack)
-  {
-    string[] subject_alt_path = {"subject-alt", "trust-anchor", "identity", "identities"};
+    bool subject_alt_handler(SList<string> stack)
+    {
+        string[] subject_alt_path = {"subject-alt", "trust-anchor", "identity", "identities"};
     
     
-    return check_stack (stack, subject_alt_path);
-  }
+        return check_stack(stack, subject_alt_path);
+    }
 
 
-  bool
-  subject_handler (SList<string> stack)
-  {
-    string[] subject_path = {"subject", "trust-anchor", "identity", "identities"};
+    bool subject_handler(SList<string> stack)
+    {
+        string[] subject_path = {"subject", "trust-anchor", "identity", "identities"};
     
     
-    return check_stack (stack, subject_path);
-  }
+        return check_stack(stack, subject_path);
+    }
   
   
-  bool
-  ca_cert_handler (SList<string> stack)
-  {
-    string[] ca_path = {"ca-cert", "trust-anchor", "identity", "identities"};
+    bool ca_cert_handler(SList<string> stack)
+    {
+        string[] ca_path = {"ca-cert", "trust-anchor", "identity", "identities"};
     
     
-    return check_stack (stack, ca_path);
-  }
+        return check_stack(stack, ca_path);
+    }
 
 
-  bool
-  realm_handler (SList<string> stack)
-  {
-    string[] realm_path = {"realm", "identity", "identities"};
+    bool realm_handler(SList<string> stack)
+    {
+        string[] realm_path = {"realm", "identity", "identities"};
     
     
-    return check_stack (stack, realm_path);
-  }
+        return check_stack(stack, realm_path);
+    }
 
 
-  bool
-  password_handler (SList<string> stack)
-  {
-    string[] password_path = {"password", "identity", "identities"};
+    bool password_handler(SList<string> stack)
+    {
+        string[] password_path = {"password", "identity", "identities"};
     
     
-    return check_stack (stack, password_path);
-  }
+        return check_stack(stack, password_path);
+    }
 
 
-  bool
-  user_handler (SList<string> stack)
-  {
-    string[] user_path = {"user", "identity", "identities"};
+    bool user_handler(SList<string> stack)
+    {
+        string[] user_path = {"user", "identity", "identities"};
     
     
-    return check_stack (stack, user_path);
-  }
+        return check_stack(stack, user_path);
+    }
 
 
-  bool
-  display_name_handler (SList<string> stack)
-  {
-    string[] display_name_path = {"display-name", "identity", "identities"};
+    bool display_name_handler(SList<string> stack)
+    {
+        string[] display_name_path = {"display-name", "identity", "identities"};
     
     
-    return check_stack (stack, display_name_path);
-  }
+        return check_stack(stack, display_name_path);
+    }
   
   
-  public void
-  start_element_func (MarkupParseContext context,
-                      string element_name,
-                      string[] attribute_names,
-                      string[] attribute_values) throws MarkupError
-  {
-    if (element_name == "identity")
+    public void start_element_func(MarkupParseContext context,
+                                   string element_name,
+                                   string[] attribute_names,
+                                   string[] attribute_values) throws MarkupError
     {
     {
-      IdCard[] tmp_cards = cards;
+        if (element_name == "identity")
+        {
+            IdCard[] tmp_cards = cards;
 
 
-      cards = new IdCard[tmp_cards.length + 1];
-      for (int i=0; i<tmp_cards.length; i++)
-      {
-        cards[i] = tmp_cards[i];
-      }
-      card = new IdCard();
-      cards[tmp_cards.length] = card;
-    }
-    else if (element_name == "rule")
-    {
-      Rule[] tmp_rules = card.rules;
-      card.rules = new Rule[tmp_rules.length + 1];
-      for (int i=0; i<tmp_rules.length; i++)
-      {
-        card.rules[i] = tmp_rules[i];
-      }
+            cards = new IdCard[tmp_cards.length + 1];
+            for (int i = 0; i < tmp_cards.length; i++)
+            {
+                cards[i] = tmp_cards[i];
+            }
+            card = new IdCard();
+            cards[tmp_cards.length] = card;
+        }
+        else if (element_name == "rule")
+        {
+            Rule[] tmp_rules = card.rules;
+            card.rules = new Rule[tmp_rules.length + 1];
+            for (int i = 0; i < tmp_rules.length; i++)
+            {
+                card.rules[i] = tmp_rules[i];
+            }
       
       
-      card.rules[tmp_rules.length] = Rule();
+            card.rules[tmp_rules.length] = Rule();
+        }
     }
     }
-  }
 
 
-  public void
-  text_element_func (MarkupParseContext context,
-                     string             text,
-                     size_t             text_len) throws MarkupError
-  {
-    unowned SList<string> stack = context.get_element_stack ();
+    public void
+    text_element_func(MarkupParseContext context,
+                      string             text,
+                      size_t             text_len) throws MarkupError
+    {
+        unowned SList<string> stack = context.get_element_stack();
     
     
-    if (text_len < 1)
-      return;
+        if (text_len < 1)
+            return;
     
     
-    if (stack.nth_data(0) == "display-name" && display_name_handler (stack))
-    {
-      card.display_name = text;
-    }
-    else if (stack.nth_data(0) == "user" && user_handler (stack))
-    {
-      card.username = text;
-    }
-    else if (stack.nth_data(0) == "password" && password_handler (stack))
-    {
-      card.password = text;
-    }
-    else if (stack.nth_data(0) == "realm" && realm_handler (stack))
-    {
-      card.issuer = text;
-    }
-    else if (stack.nth_data(0) == "service")
-    {
-      string[] services = card.services;
-      card.services = new string[services.length + 1];
-      for (int i = 0; i<services.length; i++)
-      {
-        card.services[i] = services[i];
-      }
-      card.services[services.length] = text;
-    }
-    /* Rules */
-    else if (stack.nth_data(0) == "pattern" && pattern_handler (stack))
-    {
-      /* use temp array to workaround valac 0.10 bug accessing array property length */ 
-      var temp = card.rules;
-      card.rules[temp.length - 1].pattern = text;
+        if (stack.nth_data(0) == "display-name" && display_name_handler(stack))
+        {
+            card.display_name = text;
+        }
+        else if (stack.nth_data(0) == "user" && user_handler(stack))
+        {
+            card.username = text;
+        }
+        else if (stack.nth_data(0) == "password" && password_handler(stack))
+        {
+            card.password = text;
+        }
+        else if (stack.nth_data(0) == "realm" && realm_handler(stack))
+        {
+            card.issuer = text;
+        }
+        else if (stack.nth_data(0) == "service")
+        {
+            string[] services = card.services;
+            card.services = new string[services.length + 1];
+            for (int i = 0; i < services.length; i++)
+            {
+                card.services[i] = services[i];
+            }
+            card.services[services.length] = text;
+        }
+        /* Rules */
+        else if (stack.nth_data(0) == "pattern" && pattern_handler(stack))
+        {
+            /* use temp array to workaround valac 0.10 bug accessing array property length */ 
+            var temp = card.rules;
+            card.rules[temp.length - 1].pattern = text;
+        }
+        else if (stack.nth_data(0) == "always-confirm" && always_confirm_handler(stack))
+        {
+            if (text == "true" || text == "false") {
+                /* use temp array to workaround valac 0.10 bug accessing array property length*/
+                var temp = card.rules;
+                card.rules[temp.length - 1].always_confirm = text;
+            }
+        }
+        /*Trust anchor*/
+        else if (stack.nth_data(0) == "ca-cert" && ca_cert_handler(stack))
+        {
+            card.trust_anchor.ca_cert = text;
+        }
+        else if (stack.nth_data(0) == "subject" && subject_handler(stack))
+        {
+            card.trust_anchor.subject = text;
+        }
+        else if (stack.nth_data(0) == "subject-alt" && subject_alt_handler(stack))
+        {
+            card.trust_anchor.subject_alt = text;
+        }
+        else if (stack.nth_data(0) == "server-cert" && server_cert_handler(stack))
+        {
+            card.trust_anchor.server_cert = text;
+        }
     }
     }
-    else if (stack.nth_data(0) == "always-confirm" && always_confirm_handler (stack))
-    {
-      if (text == "true" || text == "false") {
-        /* use temp array to workaround valac 0.10 bug accessing array property length*/
-        var temp = card.rules;
-        card.rules[temp.length - 1].always_confirm = text;
-      }
-    }
-    /*Trust anchor*/
-    else if (stack.nth_data(0) == "ca-cert" && ca_cert_handler (stack))
-    {
-      card.trust_anchor.ca_cert = text;
-    }
-    else if (stack.nth_data(0) == "subject" && subject_handler (stack))
-    {
-      card.trust_anchor.subject = text;
-    }
-    else if (stack.nth_data(0) == "subject-alt" && subject_alt_handler (stack))
-    {
-      card.trust_anchor.subject_alt = text;
-    }
-    else if (stack.nth_data(0) == "server-cert" && server_cert_handler (stack))
-    {
-      card.trust_anchor.server_cert = text;
-    }
-  }
 
 
-  class Parser
-  {
-    private MarkupParser parser;
-    private string       text;
-    private string       path;
-    public Parser (string path)
+    class Parser
     {
     {
-      text = "";
-      this.path = path;
+        private MarkupParser parser;
+        private string       text;
+        private string       path;
+        public Parser(string path) {
+            text = "";
+            this.path = path;
 
 
-      var file = File.new_for_path (path);
+            var file = File.new_for_path(path);
     
     
-      try
-      {
-        var dis = new DataInputStream (file.read ());
-        string line;
-        while ((line = dis.read_line (null)) != null)
-          text += line;
-      }
-      catch (GLib.Error e)
-      {
-        error ("Could not retreive file size");
-      }
+            try
+            {
+                var dis = new DataInputStream(file.read());
+                string line;
+                while ((line = dis.read_line(null)) != null)
+                    text += line;
+            }
+            catch(GLib.Error e)
+            {
+                error("Could not retreive file size");
+            }
       
       
-      parser = {start_element_func, null, text_element_func, null, null};
-    }
+            parser = {start_element_func, null, text_element_func, null, null};
+        }
     
     
-    public void
-    parse ()
-    {
-      var ctx = new MarkupParseContext(parser, 0, null, null);
+        public void parse() {
+            var ctx = new MarkupParseContext(parser, 0, null, null);
       
       
-      try
-      {
-        ctx.parse (text, text.length);
-      }
-      catch (GLib.Error e)
-      {
-        error ("Could not parse %s, invalid content", path);
-      } 
+            try
+            {
+                ctx.parse(text, text.length);
+            }
+            catch(GLib.Error e)
+            {
+                error("Could not parse %s, invalid content", path);
+            } 
+        }
     }
     }
-  }
 }
 }
index 74288f7..67c22ab 100644 (file)
@@ -36,7 +36,7 @@ public class MoonshotServer : Object {
 
     private IdentityManagerApp parent_app;
 
 
     private IdentityManagerApp parent_app;
 
-    public MoonshotServer (IdentityManagerApp app)
+    public MoonshotServer(IdentityManagerApp app)
     {
         this.parent_app = app;
     }
     {
         this.parent_app = app;
     }
@@ -51,22 +51,22 @@ public class MoonshotServer : Object {
         return true;
     }
 
         return true;
     }
 
-    public async bool get_identity (string nai,
-                                    string password,
-                                    string service,
-                                    out string nai_out,
-                                    out string password_out,
-                                    out string server_certificate_hash,
-                                    out string ca_certificate,
-                                    out string subject_name_constraint,
-                                    out string subject_alt_name_constraint)
+    public async bool get_identity(string nai,
+                                   string password,
+                                   string service,
+                                   out string nai_out,
+                                   out string password_out,
+                                   out string server_certificate_hash,
+                                   out string ca_certificate,
+                                   out string subject_name_constraint,
+                                   out string subject_alt_name_constraint)
     {
     {
-        var request = new IdentityRequest (parent_app,
-                                           nai,
-                                           password,
-                                           service);
-        request.set_callback ((IdentityRequest) => get_identity.callback());
-        request.execute ();
+        var request = new IdentityRequest(parent_app,
+                                          nai,
+                                          password,
+                                          service);
+        request.set_callback((IdentityRequest) => get_identity.callback());
+        request.execute();
         yield;
 
         nai_out = "";
         yield;
 
         nai_out = "";
@@ -109,16 +109,16 @@ public class MoonshotServer : Object {
         return false;
     }
 
         return false;
     }
 
-    public async bool get_default_identity (out string nai_out,
-                                            out string password_out,
-                                            out string server_certificate_hash,
-                                            out string ca_certificate,
-                                            out string subject_name_constraint,
-                                            out string subject_alt_name_constraint)
+    public async bool get_default_identity(out string nai_out,
+                                           out string password_out,
+                                           out string server_certificate_hash,
+                                           out string ca_certificate,
+                                           out string subject_name_constraint,
+                                           out string subject_alt_name_constraint)
     {
     {
-        var request = new IdentityRequest.default (parent_app);
-        request.set_callback ((IdentityRequest) => get_default_identity.callback());
-        request.execute ();
+        var request = new IdentityRequest.default(parent_app);
+        request.set_callback((IdentityRequest) => get_default_identity.callback());
+        request.execute();
         yield;
 
         nai_out = "";
         yield;
 
         nai_out = "";
@@ -170,80 +170,80 @@ public class MoonshotServer : Object {
                                  string   ?server_cert,
                                  int      force_flat_file_store)
     {
                                  string   ?server_cert,
                                  int      force_flat_file_store)
     {
-      IdCard idcard = new IdCard ();
-
-      idcard.display_name = display_name;
-      idcard.username = user_name;
-      idcard.password = password;
-      if ((password != null) && (password != ""))
-        idcard.store_password = true;
-      idcard.issuer = realm;
-      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;
-
-      if (rules_patterns.length == rules_always_confirm.length)
-      {
-        /* workaround Centos vala array property bug: use temp array */
-        Rule[] rules = new Rule[rules_patterns.length];
+        IdCard idcard = new IdCard();
+
+        idcard.display_name = display_name;
+        idcard.username = user_name;
+        idcard.password = password;
+        if ((password != null) && (password != ""))
+            idcard.store_password = true;
+        idcard.issuer = realm;
+        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;
+
+        if (rules_patterns.length == rules_always_confirm.length)
+        {
+            /* workaround Centos vala array property bug: use temp array */
+            Rule[] rules = new Rule[rules_patterns.length];
          
          
-        for (int i=0; i<rules.length; i++)
-        { 
-          rules[i].pattern = rules_patterns[i];
-          rules[i].always_confirm = rules_always_confirm[i];
+            for (int i = 0; i < rules.length; i++)
+            { 
+                rules[i].pattern = rules_patterns[i];
+                rules[i].always_confirm = rules_always_confirm[i];
+            }
+            idcard.rules = rules;
         }
         }
-        idcard.rules = rules;
-      }
 
 
-      return parent_app.add_identity (idcard, force_flat_file_store!=0);
+        return parent_app.add_identity(idcard, force_flat_file_store!=0);
     }
 
 
     }
 
 
-    public int install_from_file (string file_name)
+    public int install_from_file(string file_name)
     {
     {
-    var webp = new WebProvisioning.Parser (file_name);
+        var webp = new WebProvisioning.Parser(file_name);
 
 
-    webp.parse();
-    bool result = false;
-    int installed_cards = 0;
-    foreach (IdCard card in WebProvisioning.cards)
-    {
-      string[] rules_patterns = {};
-      string[] rules_always_confirm = {};
-        
-      if (card.rules.length > 0)
-      {
-        int i = 0;
-        rules_patterns = new string[card.rules.length];
-        rules_always_confirm = new string[card.rules.length];
-        foreach (Rule r in card.rules)
+        webp.parse();
+        bool result = false;
+        int installed_cards = 0;
+        foreach (IdCard card in WebProvisioning.cards)
         {
         {
-          rules_patterns[i] = r.pattern;
-          rules_always_confirm[i] = r.always_confirm;
-          i++;
+            string[] rules_patterns = {};
+            string[] rules_always_confirm = {};
+        
+            if (card.rules.length > 0)
+            {
+                int i = 0;
+                rules_patterns = new string[card.rules.length];
+                rules_always_confirm = new string[card.rules.length];
+                foreach (Rule r in card.rules)
+                {
+                    rules_patterns[i] = r.pattern;
+                    rules_always_confirm[i] = r.always_confirm;
+                    i++;
+                }
+            } 
+
+            result = install_id_card(card.display_name,
+                                     card.username,
+                                     card.password,
+                                     card.issuer,
+                                     rules_patterns,
+                                     rules_always_confirm,
+                                     card.services,
+                                     card.trust_anchor.ca_cert,
+                                     card.trust_anchor.subject,
+                                     card.trust_anchor.subject_alt,
+                                     card.trust_anchor.server_cert,
+                                     0);
+            if (result) {
+                installed_cards++;
+            }
         }
         }
-      } 
-
-      result = install_id_card (card.display_name,
-                                card.username,
-                                card.password,
-                                card.issuer,
-                                rules_patterns,
-                                rules_always_confirm,
-                                card.services,
-                                card.trust_anchor.ca_cert,
-                                card.trust_anchor.subject,
-                                card.trust_anchor.subject_alt,
-                                card.trust_anchor.server_cert,
-                                0);
-      if (result) {
-        installed_cards++;
-      }
+        return installed_cards;
     }
     }
-    return installed_cards;
-  }
 }
 
 
 }
 
 
@@ -265,48 +265,48 @@ public class MoonshotServer : Object {
 
     private static MoonshotServer instance = null;
 
 
     private static MoonshotServer instance = null;
 
-    public static void start (IdentityManagerApp app)
+    public static void start(IdentityManagerApp app)
     {
         parent_app = app;
     {
         parent_app = app;
-        Rpc.server_start (MoonshotRpcInterface.spec, "/org/janet/Moonshot", Rpc.Flags.PER_USER);
+        Rpc.server_start(MoonshotRpcInterface.spec, "/org/janet/Moonshot", Rpc.Flags.PER_USER);
     }
 
     }
 
-    public static MoonshotServer get_instance ()
+    public static MoonshotServer get_instance()
     {
         if (instance == null)
     {
         if (instance == null)
-            instance = new MoonshotServer ();
+            instance = new MoonshotServer();
         return instance;
     }
 
     [CCode (cname = "moonshot_get_identity_rpc")]
         return instance;
     }
 
     [CCode (cname = "moonshot_get_identity_rpc")]
-    public static void get_identity (Rpc.AsyncCall call,
-                                     string nai,
-                                     string password,
-                                     string service,
-                                     ref string nai_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)
+    public static void get_identity(Rpc.AsyncCall call,
+                                    string nai,
+                                    string password,
+                                    string service,
+                                    ref string nai_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 = false;
 
     {
         bool result = false;
 
-        var request = new IdentityRequest (parent_app,
-                                           nai,
-                                           password,
-                                           service);
+        var request = new IdentityRequest(parent_app,
+                                          nai,
+                                          password,
+                                          service);
 
         // Pass execution to the main loop and block the RPC thread
 
         // Pass execution to the main loop and block the RPC thread
-        request.mutex = new Mutex ();
-        request.cond = new Cond ();
-        request.set_callback (return_identity_cb);
+        request.mutex = new Mutex();
+        request.cond = new Cond();
+        request.set_callback(return_identity_cb);
 
 
-        request.mutex.lock ();
-        Idle.add (request.execute);
+        request.mutex.lock();
+        Idle.add(request.execute);
 
         while (request.complete == false)
 
         while (request.complete == false)
-            request.cond.wait (request.mutex);
+            request.cond.wait(request.mutex);
 
         nai_out = "";
         password_out = "";
 
         nai_out = "";
         password_out = "";
@@ -326,12 +326,12 @@ public class MoonshotServer : Object {
             subject_name_constraint = id_card.trust_anchor.subject;
             subject_alt_name_constraint = id_card.trust_anchor.subject_alt;
 
             subject_name_constraint = id_card.trust_anchor.subject;
             subject_alt_name_constraint = id_card.trust_anchor.subject_alt;
 
-            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);
+            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;
         }
 
             result = true;
         }
@@ -340,33 +340,33 @@ public class MoonshotServer : Object {
         // reason they are 'ref' not 'out' parameters - Vala assigns to the
         // 'out' parameters only at the end of the function, which is too
         // late.
         // reason they are 'ref' not 'out' parameters - Vala assigns to the
         // 'out' parameters only at the end of the function, which is too
         // late.
-        call.return (&result);
+        call.return(&result);
 
 
-        request.cond.signal ();
-        request.mutex.unlock ();
+        request.cond.signal();
+        request.mutex.unlock();
     }
 
     [CCode (cname = "moonshot_get_default_identity_rpc")]
     }
 
     [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 server_certificate_hash,
-                                             ref string ca_certificate,
-                                             ref string subject_name_constraint,
-                                             ref string subject_alt_name_constraint)
+    public static void get_default_identity(Rpc.AsyncCall call,
+                                            ref string nai_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;
 
     {
         bool result;
 
-        var request = new IdentityRequest.default (parent_app);
-        request.mutex = new Mutex ();
-        request.cond = new Cond ();
-        request.set_callback (return_identity_cb);
+        var request = new IdentityRequest.default(parent_app);
+        request.mutex = new Mutex();
+        request.cond = new Cond();
+        request.set_callback(return_identity_cb);
 
 
-        request.mutex.lock ();
-        Idle.add (request.execute);
+        request.mutex.lock();
+        Idle.add(request.execute);
 
         while (request.complete == false)
 
         while (request.complete == false)
-            request.cond.wait (request.mutex);
+            request.cond.wait(request.mutex);
 
         nai_out = "";
         password_out = "";
 
         nai_out = "";
         password_out = "";
@@ -381,12 +381,12 @@ public class MoonshotServer : Object {
             password_out = request.id_card.password;
             server_certificate_hash = "certificate";
 
             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);
+            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;
         }
 
             result = true;
         }
@@ -395,40 +395,40 @@ public class MoonshotServer : Object {
             result = false;
         }
 
             result = false;
         }
 
-        call.return (&result);
+        call.return(&result);
 
 
-        request.cond.signal ();
-        request.mutex.unlock ();
+        request.cond.signal();
+        request.mutex.unlock();
     }
 
     // Called from the main loop thread when an identity has
     // been selected
     }
 
     // Called from the main loop thread when an identity has
     // been selected
-    static void return_identity_cb (IdentityRequest request) {
+    static void return_identity_cb(IdentityRequest request) {
         // Notify the RPC thread that the request is complete
         // Notify the RPC thread that the request is complete
-        request.mutex.lock ();
-        request.cond.signal ();
+        request.mutex.lock();
+        request.cond.signal();
 
         // Block the main loop until the RPC call has returned
         // to avoid any races
 
         // Block the main loop until the RPC call has returned
         // to avoid any races
-        request.cond.wait (request.mutex);
-        request.mutex.unlock ();
+        request.cond.wait(request.mutex);
+        request.mutex.unlock();
     }
 
     [CCode (cname = "moonshot_install_id_card_rpc")]
     }
 
     [CCode (cname = "moonshot_install_id_card_rpc")]
-    public static bool install_id_card (string     display_name,
-                                        string     user_name,
-                                        string     password,
-                                        string     realm,
-                                        string[]   rules_patterns,
-                                        string[]   rules_always_confirm,
-                                        string[]   services,
-                                        string     ca_cert,
-                                        string     subject,
-                                        string     subject_alt,
-                                        string     server_cert,
-                                        bool       force_flat_file_store)
+    public static bool install_id_card(string     display_name,
+                                       string     user_name,
+                                       string     password,
+                                       string     realm,
+                                       string[]   rules_patterns,
+                                       string[]   rules_always_confirm,
+                                       string[]   services,
+                                       string     ca_cert,
+                                       string     subject,
+                                       string     subject_alt,
+                                       string     server_cert,
+                                       bool       force_flat_file_store)
     {
     {
-        IdCard idcard = new IdCard ();
+        IdCard idcard = new IdCard();
         bool success = false;
         Mutex mutex = new Mutex();
         Cond cond = new Cond();
         bool success = false;
         Mutex mutex = new Mutex();
         Cond cond = new Cond();
@@ -447,26 +447,26 @@ public class MoonshotServer : Object {
         {
             idcard.rules = new Rule[rules_patterns.length];
          
         {
             idcard.rules = new Rule[rules_patterns.length];
          
-            for (int i=0; i<idcard.rules.length; i++)
+            for (int i = 0; i < idcard.rules.length; i++)
             { 
                 idcard.rules[i].pattern = rules_patterns[i];
                 idcard.rules[i].always_confirm = rules_always_confirm[i];
             }
         }
 
             { 
                 idcard.rules[i].pattern = rules_patterns[i];
                 idcard.rules[i].always_confirm = rules_always_confirm[i];
             }
         }
 
-        mutex.lock ();
+        mutex.lock();
 
         // Defer addition to the main loop thread.
 
         // Defer addition to the main loop thread.
-        Idle.add (() => {
-            mutex.lock ();
-            success = parent_app.add_identity (idcard, force_flat_file_store);
-            cond.signal ();
-            mutex.unlock ();
-            return false;
-        });
-
-        cond.wait (mutex);
-        mutex.unlock ();
+        Idle.add(() => {
+                mutex.lock();
+                success = parent_app.add_identity(idcard, force_flat_file_store);
+                cond.signal();
+                mutex.unlock();
+                return false;
+            });
+
+        cond.wait(mutex);
+        mutex.unlock();
 
         return success;
     }
 
         return success;
     }
index 72df968..8bc2a68 100644 (file)
  * SUCH DAMAGE.
 */
 #if OS_WIN32
  * SUCH DAMAGE.
 */
 #if OS_WIN32
-extern string? g_win32_get_package_installation_directory_of_module (void *module);
+extern string? g_win32_get_package_installation_directory_of_module(void *module);
 #endif
 
 #endif
 
-public Gdk.Pixbuf? find_icon_sized (string name, Gtk.IconSize icon_size)
+public Gdk.Pixbuf? find_icon_sized(string name, Gtk.IconSize icon_size)
 {
     int width, height;
 {
     int width, height;
-    Gtk.icon_size_lookup (icon_size, out width, out height);
-    return find_icon (name, width);
+    Gtk.icon_size_lookup(icon_size, out width, out height);
+    return find_icon(name, width);
 }
 
 /* Portability hack: making Gtk icon themes work on Windows is
 }
 
 /* Portability hack: making Gtk icon themes work on Windows is
@@ -52,27 +52,27 @@ public Gdk.Pixbuf? get_pixbuf(IdCard id)
     return find_icon("avatar-default", 48);
 }
 
     return find_icon("avatar-default", 48);
 }
 
-public Gdk.Pixbuf? find_icon (string name, int size)
+public Gdk.Pixbuf? find_icon(string name, int size)
 {
     if (!gtk_available)
         return null;
     try
     {
 {
     if (!gtk_available)
         return null;
     try
     {
-#if OS_WIN32
-        string? base_path = g_win32_get_package_installation_directory_of_module (null);
+        #if OS_WIN32
+        string? base_path = g_win32_get_package_installation_directory_of_module(null);
 
         // Hack to allow running within the source tree
 
         // Hack to allow running within the source tree
-        int last_dir_index = base_path.last_index_of_char ('\\');
-        if (base_path.substring (last_dir_index) == "\\.libs" || base_path.substring (last_dir_index) == "src")
+        int last_dir_index = base_path.last_index_of_char('\\');
+        if (base_path.substring(last_dir_index) == "\\.libs" || base_path.substring(last_dir_index) == "src")
             base_path = base_path.slice(0, last_dir_index);
 
             base_path = base_path.slice(0, last_dir_index);
 
-        string? filename = Path.build_filename (base_path, "share", "icons", "%s.png".printf (name));
-        return new Gdk.Pixbuf.from_file_at_size (filename, size, size);
+        string? filename = Path.build_filename(base_path, "share", "icons", "%s.png".printf(name));
+        return new Gdk.Pixbuf.from_file_at_size(filename, size, size);
 
 
-#else
-        var icon_theme = Gtk.IconTheme.get_default ();
-        return icon_theme.load_icon (name, size, Gtk.IconLookupFlags.FORCE_SIZE);
-#endif
+        #else
+        var icon_theme = Gtk.IconTheme.get_default();
+        return icon_theme.load_icon(name, size, Gtk.IconLookupFlags.FORCE_SIZE);
+        #endif
     }
     catch (Error e)
     {
     }
     catch (Error e)
     {
index 1fce688..efe53b5 100644 (file)
@@ -35,88 +35,88 @@ namespace WebProvisioning
 { 
 
 
 { 
 
 
-  public static int main (string[] args)
-  {
-    int arg_index = -1;
-    int force_flat_file_store = 0;
-    bool bad_switch = false;
-    for (arg_index = 1; arg_index < args.length; arg_index++) {
-      string arg = args[arg_index];
-      unichar c = arg.get_char();
-      if (c=='-') {
-          arg = arg.next_char();
-          c = arg.get_char();
-          switch (c) {
-            case 'f':
-              force_flat_file_store = 1;
-              break;
-            default:
-              bad_switch = true;
-              break;
-          }
-      } else {
-        break; // arg is not a switch; presume it's the file
-      }
-    }
-    if (bad_switch || (arg_index != args.length - 1))
+    public static int main(string[] args)
     {
     {
-      stdout.printf (_("Usage %s [-f] WEB_PROVISIONING_FILE\n -f: add identities to flat file store.\n"), args[0]);
-      return -1;
-    }
-    string webp_file = args[arg_index];
+        int arg_index = -1;
+        int force_flat_file_store = 0;
+        bool bad_switch = false;
+        for (arg_index = 1; arg_index < args.length; arg_index++) {
+            string arg = args[arg_index];
+            unichar c = arg.get_char();
+            if (c == '-') {
+                arg = arg.next_char();
+                c = arg.get_char();
+                switch (c) {
+                case 'f':
+                    force_flat_file_store = 1;
+                    break;
+                default:
+                    bad_switch = true;
+                    break;
+                }
+            } else {
+                break; // arg is not a switch; presume it's the file
+            }
+        }
+        if (bad_switch || (arg_index != args.length - 1))
+        {
+            stdout.printf(_("Usage %s [-f] WEB_PROVISIONING_FILE\n -f: add identities to flat file store.\n"), args[0]);
+            return -1;
+        }
+        string webp_file = args[arg_index];
     
     
-    if (!FileUtils.test (webp_file, FileTest.EXISTS | FileTest.IS_REGULAR))
-    {
-      stdout.printf (_("%s does not exist\n"), webp_file);
-      return -1;
-    }
+        if (!FileUtils.test(webp_file, FileTest.EXISTS | FileTest.IS_REGULAR))
+        {
+            stdout.printf(_("%s does not exist\n"), webp_file);
+            return -1;
+        }
     
     
-    var webp = new Parser (webp_file);
-    webp.parse();
+        var webp = new Parser(webp_file);
+        webp.parse();
     
     
-    foreach (IdCard card in cards)
-    {
-      Moonshot.Error error;
-      string[] rules_patterns = {};
-      string[] rules_always_confirm = {};
-        
-      /* use temp arrays to workaround centos array property bug */
-      var rules = card.rules;
-      var services = card.services;
-      if (rules.length > 0)
-      {
-        int i = 0;
-        rules_patterns = new string[rules.length];
-        rules_always_confirm = new string[rules.length];
-        foreach (Rule r in rules)
+        foreach (IdCard card in cards)
         {
         {
-          rules_patterns[i] = r.pattern;
-          rules_always_confirm[i] = r.always_confirm;
-          i++;
-        }
-      }
+            Moonshot.Error error;
+            string[] rules_patterns = {};
+            string[] rules_always_confirm = {};
+        
+            /* use temp arrays to workaround centos array property bug */
+            var rules = card.rules;
+            var services = card.services;
+            if (rules.length > 0)
+            {
+                int i = 0;
+                rules_patterns = new string[rules.length];
+                rules_always_confirm = new string[rules.length];
+                foreach (Rule r in rules)
+                {
+                    rules_patterns[i] = r.pattern;
+                    rules_always_confirm[i] = r.always_confirm;
+                    i++;
+                }
+            }
 
 
-      Moonshot.install_id_card (card.display_name,
-                                card.username,
-                                card.password,
-                                card.issuer,
-                                rules_patterns,
-                                rules_always_confirm,
-                                services,
-                                card.trust_anchor.ca_cert,
-                                card.trust_anchor.subject,
-                                card.trust_anchor.subject_alt,
-                                card.trust_anchor.server_cert,
-                                force_flat_file_store,
-                                out error);
+            Moonshot.install_id_card(card.display_name,
+                                     card.username,
+                                     card.password,
+                                     card.issuer,
+                                     rules_patterns,
+                                     rules_always_confirm,
+                                     services,
+                                     card.trust_anchor.ca_cert,
+                                     card.trust_anchor.subject,
+                                     card.trust_anchor.subject_alt,
+                                     card.trust_anchor.server_cert,
+                                     force_flat_file_store,
+                                     out error);
 
 
-      if (error != null)
-      {
-        stderr.printf ("Error: %s", error.message);
-        continue;
-      }
-    }
+            if (error != null)
+            {
+                stderr.printf("Error: %s", error.message);
+                continue;
+            }
+        }
     
     
-    return 0;
-  }
+        return 0;
+    }
 }
 }