// // OpenVPN Administrator // // Author(s): Everaldo Canuto // // (C) 2006 Everaldo Canuto // (C) 2006 The Gang // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // using System; using Gtk; using Glade; using Mono.Unix; namespace OpenVPN.Admin { public class ChangeForm { #region Fields [Widget] Dialog changeForm; [Widget] Image imageLogo; [Widget] Entry entryPassword; [Widget] Entry entryNewPassword; [Widget] Entry entryNewPasswordAgain; private string password; private string newpassword; #endregion #region Constructors and destructors public ChangeForm() { InitializeComponent(); } private void InitializeComponent() { // changeForm Glade.XML gxml = new Glade.XML (null, "openvpn-admin.glade", "changeForm", null); gxml.Autoconnect(this); this.changeForm.Icon = Gdk.Pixbuf.LoadFromResource("certificate.png"); this.imageLogo.Pixbuf = Gdk.Pixbuf.LoadFromResource("certificate.png"); } #endregion #region Public methods public Gtk.ResponseType ShowModal() { /*Gtk.ResponseType result = Gtk.ResponseType.None; while ((result != Gtk.ResponseType.Ok) && ((result != Gtk.ResponseType.Cancel))) { result = (Gtk.ResponseType) this.changeForm.Run(); } changeForm.Hide(); return result;*/ Gtk.ResponseType result = (Gtk.ResponseType) this.changeForm.Run(); changeForm.Hide(); return result; } public void ErrorBox(string message) { MessageDialog md = new MessageDialog(this.changeForm, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, message); md.Run(); md.Destroy(); } #endregion #region Public events public void on_ok_clicked(object o, EventArgs args) { try { if (entryNewPassword.Text != entryNewPasswordAgain.Text) throw new Exception(Catalog.GetString("New Passphrase and New Passphrase (Again) need to be the same.")); this.password = entryPassword.Text; this.newpassword = entryNewPassword.Text; this.changeForm.Respond(Gtk.ResponseType.Ok); } catch (Exception e) { ErrorBox(e.Message); } } #endregion #region Public properties public string Password { get { return this.password; } } public string NewPassword { get { return this.newpassword; } } #endregion } }