home *** CD-ROM | disk | FTP | other *** search
- /**
- * File: modules/AutoinstGeneral.ycp
- * Package: Autoyast
- * Summary: Configuration of general settings for autoyast
- * Authors: Anas Nashif (nashif@suse.de)
- *
- * $Id: AutoinstGeneral.ycp 33295 2006-10-10 08:03:34Z ug $
- */
-
- {
- module "AutoinstGeneral";
- textdomain "autoinst";
-
- import "Stage";
- import "AutoInstall";
- import "AutoinstConfig";
- import "Summary";
- import "Keyboard";
- import "Mouse";
- import "Language";
- import "Keyboard";
- import "Timezone";
- import "Misc";
- import "Profile";
- import "Pkg";
-
- //
- // Show proposal and ask user for confirmation to go on with auto-installation
- // Similar to interactive mode, without letting use change settings
- // Interactive mode implies confirmation as well..
- //
- global boolean Confirm = true;
-
- //
- // Keyboard
- //
- //global map keyboard = $[];
-
- //
- // Language
- //
- //global string language = "";
-
- //
- // Mouse, if not autoprobed
- //
- global map mouse = $[];
-
- //
- // Clock Settings
- //
- //global map Clock = $[];
-
- //
- // Mode Settings
- //
- global map mode = $[];
-
- global map signature_handling = $[];
-
-
- /* default value of settings modified */
- global boolean modified = false;
-
-
- /**
- * Function sets internal variable, which indicates, that any
- * settings were modified, to "true"
- */
- global define void SetModified () {
- modified = true;
- }
-
- /**
- * Functions which returns if the settings were modified
- * @return boolean settings were modified
- */
- global define boolean GetModified () {
- return modified;
- }
-
- /**
- * Summary of configuration
- * @return string Formatted summary
- */
- global define string Summary()
- {
- //string language_name = "";
- //string keyboard_name = "";
- string mouse_name = "";
-
- if ( mouse["id"]:"" != "" && mouse["id"]:"" != "probe")
- {
- Mouse::Set(mouse["id"]:"");
- mouse_name = Mouse::MakeProposal(false, false);
- }
- else
- {
- mouse_name = "probe";
- }
- string summary = "";
-
- summary = Summary::AddHeader(summary, _("Mouse"));
- summary = Summary::AddLine(summary, (mouse_name != "") ?
- mouse_name : Summary::NotConfigured());
-
- summary = Summary::AddHeader(summary, _("Confirm installation?"));
- summary = Summary::AddLine(summary, (mode["confirm"]:true) ?
- _("Yes") : _("No"));
-
- summary = Summary::AddHeader(summary, _("Second Stage of AutoYaST"));
- summary = Summary::AddLine(summary, (mode["second_stage"]:true) ?
- _("Yes") : _("No"));
-
- summary = Summary::AddHeader(summary, _("Halting the machine after stage one"));
- summary = Summary::AddLine(summary, (mode["halt"]:false) ?
- _("Yes") : _("No"));
-
- summary = Summary::AddHeader(summary, _("Signature Handling"));
- summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["accept_unsigned_file"]:false) ?
- _("Accepting unsigned files") : _("Not accepting unsigned files"));
- summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["accept_file_without_checksum"]:false) ?
- _("Accepting files without a checksum") : _("Not accepting files without a checksum"));
- summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["accept_verification_failed"]:false) ?
- _("Accepting failed verifications") : _("Not accepting failed verifications"));
- summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["accept_unknown_gpg_key"]:false) ?
- _("Accepting unknown GPG keys") : _("Not accepting unknown GPG Keys"));
- summary = Summary::AddLine(summary, (AutoinstGeneral::signature_handling["import_gpg_key"]:false) ?
- _("Importing new GPG keys") : _("Not importing new GPG Keys"));
-
- return summary;
- }
-
- /**
- * Import Configuration
- * @param map settings
- * @return booelan
- */
- global define boolean Import (map settings)
- {
- SetModified ();
- y2milestone("General import: %1",settings);
- //language = settings["language"]:"";
- //keyboard = settings["keyboard"]:$[];;
- //Clock = settings["clock"]:$[];
- mouse = settings["mouse"]:$[];
- mode = settings["mode"]:$[];
- signature_handling = settings["signature-handling"]:$[];
- return true;
- }
-
-
- /**
- * Export Configuration
- * @return map
- */
- global define map Export ()
- {
- map general = $[];
-
- /*
- general["language"] = language ;
- if (haskey(keyboard, "keyboard_values") || Keyboard::ExpertSettingsChanged )
- {
- keyboard["keyboard_values"] = Keyboard::GetExpertValues();
- }
-
- general["keyboard"] = keyboard;
- general["clock"] = Clock;
- */
- general["mouse"] = mouse;
- general["mode"] = mode;
- general["signature-handling"] = signature_handling;
- return general;
- }
-
- /**
- * set the sigature handling
- * @return void
- */
- global define void SetSignatureHandling() {
- if( haskey(signature_handling, "accept_unsigned_file" ) )
- Pkg::CallbackAcceptUnsignedFile(
- signature_handling["accept_unsigned_file"]:false ? "AutoInstall::callbackTrue" : "AutoInstall::callbackFalse"
- );
- if( haskey(signature_handling, "accept_file_without_checksum" ) )
- Pkg::CallbackAcceptFileWithoutChecksum(
- signature_handling["accept_file_without_checksum"]:false ? "AutoInstall::callbackTrue" : "AutoInstall::callbackFalse"
- );
- if( haskey(signature_handling, "accept_verification_failed") )
- Pkg::CallbackAcceptVerificationFailed(
- signature_handling["accept_verification_failed"]:false ? "AutoInstall::callbackTrue" : "AutoInstall::callbackFalse"
- );
- if( haskey(signature_handling, "trusted_key_added") )
- Pkg::CallbackTrustedKeyAdded(
- signature_handling["trusted_key_added"]:false ? "AutoInstall::callbackTrue" : "AutoInstall::callbackFalse"
- );
- if( haskey(signature_handling, "trusted_key_removed") )
- Pkg::CallbackTrustedKeyRemoved(
- signature_handling["trusted_key_removed"]:false ? "AutoInstall::callbackTrue" : "AutoInstall::callbackFalse"
- );
- if( haskey(signature_handling, "accept_unknown_gpg_key") )
- Pkg::CallbackAcceptUnknownGpgKey(
- signature_handling["accept_unknown_gpg_key"]:false ? "AutoInstall::callbackTrue" : "AutoInstall::callbackFalse"
- );
- if( haskey(signature_handling, "import_gpg_key") )
- Pkg::CallbackImportGpgKey(
- signature_handling["import_gpg_key"]:false ? "AutoInstall::callbackTrue" : "AutoInstall::callbackFalse"
- );
-
- }
-
- /**
- * Write General Configuration
- * @return boolean true on success
- */
- global define boolean Write()
- {
- AutoinstConfig::Confirm = mode["confirm"]:true;
- AutoinstConfig::ForceBoot = mode["forceboot"]:false;
- AutoinstConfig::Halt = mode["halt"]:false;
- AutoinstConfig::RebootMsg = mode["rebootmsg"]:false;
-
- //
- // mouse
- //
-
- if ( mouse["id"]:"" != "probe" && mouse["id"]:"" != "")
- {
- Mouse::Set(mouse["id"]:"");
- }
- else if (haskey(mouse,"device"))
- {
- //
- // Otherwise, try to find the mouse id from the DB using data supplied by user,
- // at least the device is needed.
- //
- string device = mouse["device"]:"none";
- integer wheels = mouse["wheels"]:0;
-
- map<string, list> mice = (map<string, list>)Misc::ReadAlternateFile ("mouse_db.ycp", "mouse_raw.ycp");
-
- foreach(string f,list g, mice, ``{
- map data = g[1]:$[];
- if ( data["wheels"]:0 == wheels && data["device"]:"" == device)
- {
- mouse["id"] = f;
- }
- });
- Mouse::Set(mouse["id"]:"");
- }
- SetSignatureHandling();
- }
-
- /**
- * Constructor
- */
- global define void AutoinstGeneral ()
- {
- if( Stage::cont () ) {
- // FIXME: wrong position for this
- if (Profile::current["general"]:$[] != $[])
- Import(Profile::current["general"]:$[]);
- SetSignatureHandling();
- }
- return;
- }
-
- }
-
-