X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=src%2Fmoonshot-password-dialog.vala;h=5bf2e46f354e6975fc7f1c4f3f56a19db7d029fb;hb=fa8cc6553f0f8c40eda27408984e0631a989f133;hp=060959d77d0f6677fd3a92aefce480496b1925ae;hpb=5b77443c929b4ca49366c3ac66d61514c9d1fc89;p=moonshot-ui.git diff --git a/src/moonshot-password-dialog.vala b/src/moonshot-password-dialog.vala index 060959d..5bf2e46 100644 --- a/src/moonshot-password-dialog.vala +++ b/src/moonshot-password-dialog.vala @@ -1,77 +1,132 @@ +/* + * Copyright (c) 2011-2016, JANET(UK) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of JANET(UK) nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * 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 Gtk; class AddPasswordDialog : Dialog { + private static Gdk.Color white = make_color(65535, 65535, 65535); + private Entry password_entry; private CheckButton remember_checkbutton; public string password { - get { return password_entry.get_text (); } + get { return password_entry.get_text(); } } - public bool remember { - get { return remember_checkbutton.get_active (); } + /** + * Don't leave passwords in memory longer than necessary. + * This may not actually erase the password data bytes, but it seems to be the best we can do. + */ + public void clear_password() { + clear_password_entry(password_entry); } - public AddPasswordDialog (IdCard id_card, IdentityRequest request) - { - this.set_title (_("Please enter password for ") + id_card.display_name); - this.set_modal (true); - - this.add_buttons (_("Send"), ResponseType.OK, - _("Return to application"), ResponseType.CANCEL); - this.set_default_response (ResponseType.OK); - - var content_area = this.get_content_area (); - ((Box) content_area).set_spacing (12); - - var service_label = new Label (_("for use with:")); - service_label.set_alignment (1, (float) 0.5); - var 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 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; - remember_checkbutton = new CheckButton.with_label (_("Remember password")); - - set_atk_relation (password_entry, password_entry, Atk.RelationType.LABEL_FOR); - - var table = new Table (4, 2, false); - table.set_col_spacings (10); - table.set_row_spacings (10); - table.attach_defaults (service_label, 0, 1, 0, 1); - table.attach_defaults (service_value, 1, 2, 0, 1); - table.attach_defaults (nai_label, 0, 1, 1, 2); - table.attach_defaults (nai_value, 1, 2, 1, 2); - table.attach_defaults (password_label, 0, 1, 2, 3); - table.attach_defaults (password_entry, 1, 2, 2, 3); - table.attach_defaults (remember_checkbutton, 1, 2, 3, 4); - - var vbox = new VBox (false, 0); - vbox.set_border_width (6); - vbox.pack_start (table, false, false, 0); - - ((Container) content_area).add (vbox); - - this.set_border_width (6); - //this.set_resizable (false); - this.show_all (); + public bool remember { + get { return remember_checkbutton.get_active(); } } - private void set_atk_relation (Widget widget, Widget target_widget, Atk.RelationType relationship) + public AddPasswordDialog(IdCard id_card, IdentityRequest? request) { - var atk_widget = widget.get_accessible (); - var atk_target_widget = target_widget.get_accessible (); + this.set_title(_("Moonshot - Password")); + this.set_modal(true); + set_bg_color(this); + + this.add_buttons(_("Cancel"), ResponseType.CANCEL, + _("Connect"), ResponseType.OK); - atk_widget.add_relationship (relationship, atk_target_widget); + this.set_default_response(ResponseType.OK); + + var content_area = this.get_content_area(); + ((Box) content_area).set_spacing(12); + set_bg_color(content_area); + + Label dialog_label = new Label(_("Enter the password for ") + id_card.display_name); + dialog_label.set_alignment(0, 0); + + var nai_label = new Label(_("User (NAI):")); + nai_label.set_alignment(0, 1); + var nai_value = new Label(id_card.nai); + nai_value.set_alignment(0, 0); + + var password_label = new Label(_("Password:")); + password_label.set_alignment(0, (float) 1); + this.password_entry = new Entry(); + password_entry.set_invisible_char('*'); + password_entry.set_visibility(false); + password_entry.activates_default = true; + remember_checkbutton = new CheckButton.with_label(_("Remember password")); + + set_atk_relation(password_label, password_entry, Atk.RelationType.LABEL_FOR); + + var table = new Table(6, 1, false); + AttachOptions opts = AttachOptions.EXPAND | AttachOptions.FILL; + int row = 0; + table.set_col_spacings(6); + table.set_row_spacings(0); + table.attach(dialog_label, 0, 1, row, row + 1, opts, opts, 0, 2); +// table.attach_defaults(service_value, 1, 2, row, row + 1); + row++; + + VBox nai_vbox = new VBox(false, 0); + nai_vbox.pack_start(nai_label, false, false, 0); + nai_vbox.pack_start(nai_value, false, false, 0); + table.attach(nai_vbox, 0, 1, row, row + 1, opts, opts, 0, 12); + row++; + + VBox password_vbox = new VBox(false, 1); + var empty_box2 = new VBox(false, 0); + empty_box2.set_size_request(0, 0); + password_vbox.pack_start(empty_box2, false, false, 3); + password_vbox.pack_start(password_label, false, false, 0); + password_vbox.pack_start(password_entry, false, false, 0); + table.attach(password_vbox, 0, 1, row, row + 1, opts, opts, 0, 0); + row++; + + table.attach(remember_checkbutton, 0, 1, row, row + 1, opts, opts, 20, 2); + row++; + + var empty_box3 = new VBox(false, 0); + empty_box3.set_size_request(0, 0); + table.attach(empty_box3, 0, 1, row, row + 1, opts, opts, 0, 10); + row++; + + var vbox = new VBox(false, 0); + vbox.set_border_width(6); + vbox.pack_start(table, false, false, 0); + + ((Container) content_area).add(vbox); + + this.set_border_width(6); + //this.set_resizable(false); + this.show_all(); } }