Esempio n. 1
0
        internal static string TakePwd(Window parentWindow, string challengePwd, string experimentPwd)
        {
            var    passwordPickerDialog = new InsertPassword();
            string passwordFromUser     = null;

            if (passwordPickerDialog.Run() == (int)Gtk.ResponseType.Ok)
            {
                //check pwds here
                passwordFromUser = passwordPickerDialog.userEnteredPassword;
                if (string.IsNullOrEmpty(passwordFromUser))
                {
                    //show alert dialog
                    Dialog dialog = new Dialog(
                        "Warning",
                        parentWindow,
                        DialogFlags.Modal,
                        "Close", ResponseType.Ok
                        );

                    dialog.VBox.Add(new Label("Please insert a valid password"));
                    dialog.ShowAll();
                    dialog.Run();
                    dialog.Destroy();

                    return(null);
                }
                else if (!checkPasswords(passwordFromUser, challengePwd, experimentPwd))
                {
                    //show alert
                    Dialog dialog = new Dialog(
                        "Warning",
                        parentWindow,
                        DialogFlags.Modal,
                        "Close", ResponseType.Ok
                        );

                    dialog.VBox.Add(new Label("Entered password is not valid"));
                    dialog.ShowAll();
                    dialog.Run();
                    dialog.Destroy();

                    return(null);
                }

                return(passwordFromUser);
            }

            passwordPickerDialog.Destroy();
            return(null);
        }
Esempio n. 2
0
        internal static string TakePwd (Window parentWindow, string challengePwd, string experimentPwd)
        {              
            var passwordPickerDialog = new InsertPassword ();       
            string passwordFromUser = null;
            if (passwordPickerDialog.Run () == (int)Gtk.ResponseType.Ok) {
                //check pwds here
                passwordFromUser = passwordPickerDialog.userEnteredPassword;
                if (string.IsNullOrEmpty (passwordFromUser)) {
                    //show alert dialog
                    Dialog dialog = new Dialog (
                        "Warning",
                        parentWindow,
                        DialogFlags.Modal,
                        "Close", ResponseType.Ok
                        );

                    dialog.VBox.Add (new Label ("Please insert a valid password")); 
                    dialog.ShowAll ();
                    dialog.Run ();
                    dialog.Destroy ();

                    return null;

                } else if (!checkPasswords (passwordFromUser, challengePwd, experimentPwd)) {
                    //show alert
                    Dialog dialog = new Dialog (
                        "Warning",
                        parentWindow,
                        DialogFlags.Modal,
                        "Close", ResponseType.Ok
                        );

                    dialog.VBox.Add (new Label ("Entered password is not valid")); 
                    dialog.ShowAll ();
                    dialog.Run ();
                    dialog.Destroy ();

                    return null;
                }

                return passwordFromUser;
            } 

            passwordPickerDialog.Destroy ();
            return null;  
        }