ACC SHELL

Path : /usr/share/YaST2/include/autoinstall/
File Upload :
Current File : //usr/share/YaST2/include/autoinstall/AdvancedPartitionDialog.ycp

/**
 * File:
 *	AdvancedPartitionDialog.ycp
 *
 * Module:
 *	Partitioning
 *
 * Summary:
 *	Display and handle advanced partition dialog.
 *
 * Authors:
 *	Sven Schober (sschober@suse.de)
 *
 * $Id: AdvancedPartitionDialog.ycp 2788 2008-05-13 10:00:17Z sschober $
 */
{
  textdomain "autoinst";

  include "autoinstall/common.ycp";
  include "partitioning/custom_part_dialogs.ycp";

  import "AutoinstPartPlan";
  import "AutoinstDrive";
  import "AutoinstPartition";
  import "Label";


  define boolean encryptionEnabled( PartitionT part ){
    return part["crypt_fs"]:false;
  }

  define boolean fstabOptionsEnabled( PartitionT part ){
    return false;
  }

  term mkRadioButton( PartitionT part, symbol name, string label ){
    /*
     * Constructs buttons like this
     *
     *	`Left(`RadioButton(`id(`rbMB_name),_("Device name"))),
     */
    return `Left(`RadioButton(`id(name), label, part["mountby"]:`Empty == name ));
  }

  define PartitionT AdvancedPartitionDisplay( PartitionT part,  boolean isPV ){
    /* is result copy of part? */
    PartitionT result = part;
    string helpText = _("<p><b>Mount in /etc/fstab By:</b>
	Normally, a file system to mount is identified in /etc/fstab
	by the device name. This identification can be changed so the file system to mount
	is found by searching for a UUID or a volume label. Not all file systems can be
	mounted by UUID or a volume label. If an option is disabled, it is not possible.
	");

	// help text, richtext format
    helpText = helpText + _("<p><b>Volume Label:</b>
	  The name entered in this field is used as the volume label. This usually makes sense only 
	  when you activate the option for mounting by volume label.
	  A volume label cannot contain the / character or spaces.
	  ");

    term cryptFrame = `CheckBoxFrame(`id(`cbfCrypt),_("Encryption"),encryptionEnabled( part ),
                       `TextEntry(`id(`crypt_key), _("Encryption key"), part["crypt_key"]:"No key set"));
    if( isPV ){
      cryptFrame = `Frame(_("Encryption"), `Label(_("Encryption is not available for physical volumes")));
    }
    term contents = `HBox(
		      //`HWeight(30, `RichText(`opt(`hstretch),helpText)),
		      `HSpacing(1),
		      `HWeight(70,
		       `HCenter(`VBox(
			`Heading( _("Advanced Partition Settings")  ),
			`VCenter(`VBox(
			cryptFrame,
			`VSpacing(1),
			`VSquash(`Frame(_("Fstab options"),
			  `VBox(
			    `Left(`Label(_("Mount by"))),
			    `RadioButtonGroup(`id(`rbgMountBy),
				`HBox(
				    `Top(`VBox(
				      mkRadioButton(part, `device, _("Device name")),
				      mkRadioButton(part, `id,     _("Device id")),
				      mkRadioButton(part, `label,  _("Volume label"))
				      )),
				    `Top(`VBox(
				      mkRadioButton(part, `path, _("Device path")),
				      mkRadioButton(part, `uuid, _("UUID"))
				    )))),
			    `Top(`TextEntry(`id(`volLabel), _("Volume label"), part["label"]:"No options set" ))
			  ))
			),
			`VSpacing(1),
			`HBox(
			  `PushButton(`id(`pbCancel), Label::CancelButton()),
			  `PushButton(`id(`pbOK),Label::OKButton())
			  ))),
			`VStretch()
			))),
			`HSpacing(1)
		      );
    /*
     * Setting the option `defaultsize here causes the main dialog (the one 
     * with the tree on the left) to be replaced by this one, which might be
     * a bit irritating... but otherwise the dialog is too small.
     */
    UI::OpenDialog( `opt( /*`decorated `defaultsize */ ), contents );
    UI::ChangeWidget(`id(`crypt_key), `ValidChars, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#* ,.;:._-+!$%&/|\?{[()]}@^\\<>" );

    /*
     * Disable all mount options if partition is a
     * physical volumen
     */
    if( isPV ){
    //TODO: disabling cbfCrypt doesn't work
      list<symbol> widgets = [ `device, `id, `label, `path, `uuid ];
      foreach( symbol widget, widgets, {
	UI::ChangeWidget(`id(widget), `Enabled, false );
      });
    }
    symbol widgetID = nil;
    widgetID = (symbol) UI::UserInput();

    while(  widgetID != `pbCancel &&
	    widgetID != `pbOK	    ){
      if( `pbFsOpts == widgetID ){
	/* segfaults */
	//FstabOptions( part, result );
	/* so for the time being */
	result["fstopt"] = UI::QueryWidget(`id(`fsOpts), `Value);
	UI::ChangeWidget(`id(`fsOpts), `Value, result["fstopt"]:"" );
      }
      widgetID = (symbol) UI::UserInput();
    }

    if( `pbCancel == widgetID ){
      /* discard changes and return part */
      UI::CloseDialog();
      return part;
    }
    /* store dialog changes in result */
    if( true == UI::QueryWidget(`id(`cbfCrypt), `Value)){
      result["crypt_fs"] = true;
      result["crypt_key"] = UI::QueryWidget(`id(`crypt_key),`Value);
      result["crypt"] = "twofish256";
    }
    result["label"] = UI::QueryWidget(`id(`volLabel), `Value);
    result["mountby"] = UI::QueryWidget(`id(`rbgMountBy), `Value);
    UI::CloseDialog();
    return result;
  }
}

ACC SHELL 2018