/**
 *  File:
 *    repair.ycp
 *
 *  Module:
 *    YaST2 system repair tool - automatic error detection and repair tool
 *
 *  Summary:
 *    This file provides the framework of the YaST2 system repair tool.
 *    It contains the main function that starts the scan and repair process.
 *
 *  Author:
 *    Johannes Buchhold <jbuch@suse.de>
 *
 * $Id: repair.ycp 20738 2005-01-12 17:47:48Z jsuchome $
 */
{

  import "CommandLine";
  import "Stage";
  import "Wizard";

  import "OSRRepairUI";
  import "OSRModuleLoading";
  import "OSRMode";

  textdomain "repair";

  //////////////////////////////////////////////////////////////////////////////
  //
  //  MAIN
  //
  //////////////////////////////////////////////////////////////////////////////
  define symbol OSRSequence ()
  {

    // check the special osr modes
    if( ! OSRMode::IsValid() ) return `error;

    // ===== Open UI ==================================================
    if( (! Stage::cont ()) && (! Stage::initial ()))
    {
	Wizard::CreateDialog();
    }
    Wizard::SetTitleIcon("misc");

    // ===== Init the Rescue System =================================
    symbol ret = OSRRepairUI::InitDialog();

    if ( ret != `next ) return ret;

    // ==== Open main dialog =========================================
    ret = OSRRepairUI::OsrMainDialog();

    // ==== Try to unload all loaded modules =========================
    OSRModuleLoading::UnloadAll();

    // ==== Close the dialog =========================================
    if( (! Stage::cont ()) && (! Stage::initial ()))
    {
	UI::CloseDialog();
    }
    return ret;
  }

  /* the command line description map */
  map cmdline = $[
    "id"		: "repair",
    // translators: command line help text for repair module
    "help"		: _("System repair module"),
    // help text
    "customhelp"	: _("Command line interface for the system repair module is not available"),
    "guihandler"	: OSRSequence,
  ];
  return OSRMode::Init () ? OSRSequence () : CommandLine::Run (cmdline);
}
