Author: jreidinger
Date: Thu Mar 19 12:56:24 2009
New Revision: 56235
URL: http://svn.opensuse.org/viewcvs/yast?rev=56235&view=rev
Log:
add password widget for grub
Modified:
branches/tmp/juhliarik/bootloader-UIrefactor/src/modules/Bootloader_API.pm
branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/dialogs_i386.ycp
branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/grub_options.ycp
branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/lib_iface.ycp
branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/widgets_i386.ycp
Modified: branches/tmp/juhliarik/bootloader-UIrefactor/src/modules/Bootloader_API.pm
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/juhliarik/bootloader-UIrefactor/src/modules/Bootloader_API.pm?rev=56235&r1=56234&r2=56235&view=diff
==============================================================================
--- branches/tmp/juhliarik/bootloader-UIrefactor/src/modules/Bootloader_API.pm (original)
+++ branches/tmp/juhliarik/bootloader-UIrefactor/src/modules/Bootloader_API.pm Thu Mar 19 12:56:24 2009
@@ -298,6 +298,15 @@
return $ret;
}
+BEGIN { $TYPEINFO{countGRUBPassword} = ["function", "string","string"]; }
+sub countGRUBPassword($) {
+ my ($pass) = @_;
+ my $ret = $lib_ref->CountGRUBPassword($pass);
+
+ DumpLog();
+ return $ret;
+}
+
# import fails if we cannot create the object
$lib_ref;
Modified: branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/dialogs_i386.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/dialogs_i386.ycp?rev=56235&r1=56234&r2=56235&view=diff
==============================================================================
--- branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/dialogs_i386.ycp (original)
+++ branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/dialogs_i386.ycp Thu Mar 19 12:56:24 2009
@@ -72,6 +72,7 @@
`Left("debug"),
`Left("generic_mbr"),
`Left("trusted_grub"),
+ `Left("password"),
`Left("hiddenmenu"),
`Left("gfxmenu"),
`Left(`HSquash("timeout"))
@@ -85,7 +86,7 @@
`HSpacing (2));
list<string> widget_names = ["activate","debug","generic_mbr",
- "trusted_grub","hiddenmenu","gfxmenu","timeout", "console"];
+ "trusted_grub","hiddenmenu","gfxmenu","timeout", "console","password"];
string caption = _("Boot Loader Options");
return CWM::ShowAndRun ($[
"widget_descr" : GrubOptions(),
Modified: branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/grub_options.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/grub_options.ycp?rev=56235&r1=56234&r2=56235&view=diff
==============================================================================
--- branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/grub_options.ycp (original)
+++ branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/grub_options.ycp Thu Mar 19 12:56:24 2009
@@ -19,6 +19,7 @@
textdomain "bootloader";
import "Label";
+import "System::Bootloader_API";
include "bootloader/routines/common_options.ycp";
@@ -82,6 +83,129 @@
return widget;
}
+/**
+ * Init function of widget
+ * @param widget string id of the widget
+ */
+void InitPasswdWidget (string widget) {
+ string passwd = BootCommon::globals["password"]:"";
+ if (passwd == nil || passwd == "")
+ {
+ UI::ChangeWidget (`id (`use_pas), `Value, false);
+ UI::ChangeWidget (`id (`pw1), `Enabled, false);
+ UI::ChangeWidget (`id (`pw1), `Value, "");
+ UI::ChangeWidget (`id (`pw2), `Enabled, false);
+ UI::ChangeWidget (`id (`pw2), `Value, "");
+ }
+ else
+ {
+ UI::ChangeWidget (`id (`use_pas), `Value, true);
+ UI::ChangeWidget (`id (`pw1), `Enabled, true);
+ UI::ChangeWidget (`id (`pw1), `Value, "**********");
+ UI::ChangeWidget (`id (`pw2), `Enabled, true);
+ UI::ChangeWidget (`id (`pw2), `Value, "**********");
+ }
+ if (Mode::installation()){
+ UI::ChangeWidget (`id (`use_pas), `Enable, false);
+ }
+}
+
+/**
+ * Handle function of a widget
+ * @param widget string id of the widget
+ * @param event map event description of event that occured
+ * @return symbol always nil
+ */
+symbol HandlePasswdWidget (string widget, map event) {
+ if (event["ID"]:nil == `use_pas)
+ {
+ boolean enabled = (boolean)UI::QueryWidget (`id (`use_pas), `Value);
+ UI::ChangeWidget (`id (`pw1), `Enabled, enabled);
+ UI::ChangeWidget (`id (`pw2), `Enabled, enabled);
+ }
+ return nil;
+}
+
+/**
+ * Store function of a popup
+ * @param key any widget key
+ * @param event map event that caused the operation
+ */
+void StorePasswdWidget (string key, map event) {
+ string password = nil;
+ boolean usepass = (boolean)UI::QueryWidget (`id (`use_pas), `Value);
+ y2milestone ("Usepass: %1", usepass);
+ if (usepass)
+ {
+ if (UI::QueryWidget (`id (`pw1), `Value) != "**********")
+ {
+ password = (string)UI::QueryWidget (`id (`pw1), `Value);
+ password = System::Bootloader_API::countGRUBPassword(password);
+ if (password != nil){
+ BootCommon::globals["password"] = password; //TODO popup for error
+ }
+ }
+ }
+ else if (haskey (BootCommon::globals, "password"))
+ {
+ BootCommon::globals = remove (BootCommon::globals, "password");
+ }
+ return nil;
+}
+
+
+/**
+ * Validate function of a popup
+ * @param key any widget key
+ * @param event map event that caused validation
+ * @return boolean true if widget settings ok
+ */
+boolean ValidatePasswdWidget (string key, map event) {
+ if (! (boolean)UI::QueryWidget (`id (`use_pas), `Value))
+ return true;
+ if (UI::QueryWidget (`id (`pw1), `Value) == "")
+ {
+ emptyPasswdErrorPopup ();
+ UI::SetFocus (`id (`pw1));
+ return false;
+ }
+ if (UI::QueryWidget (`id (`pw1), `Value)
+ == UI::QueryWidget (`id (`pw2), `Value)
+ )
+ return true;
+ passwdMissmatchPopup ();
+ UI::SetFocus (`id (`pw1));
+ return false;
+}
+
+
+
+/**
+ * Build a map describing a widget
+ * @return a map describing a widget
+ */
+map