/**
 * File:	include/dns-server/wizards.ycp
 * Package:	Configuration of dns-server
 * Summary:	Wizards definitions
 * Authors:	Jiri Srain <jsrain@suse.cz>
 *		Lukas Ocilka <locilka@suse.cz>
 *
 * $Id: wizards.ycp 18415 2004-08-06 08:53:34Z locilka $
 */

{

    textdomain "dns-server";

    import "Directory";
    import "Label";
    import "Popup";
    import "Sequencer";
    import "Wizard";

    global define symbol TabSequence () {
	map aliases = $[
	    "main"		: ``(runExpertDialog ()),
	    "zone_type_switch"	:[``(runZoneTypeSwitch ()), true],
	    "master_zone_tab"	: ``(runMasterZoneTabDialog ()),
	    "slave_zone_tab"	: ``(runSlaveZoneTabDialog ()),
	    "stub_zone_tab"	: ``(runStubZoneTabDialog ()),
	];

	map sequence = $[
	    "ws_start" : "main",
	    "main" : $[
		`abort : `abort,
		`next : `next,
		`edit_zone : "zone_type_switch",
	    ],
	    "zone_type_switch" : $[
		`abort : `abort,
		`master : "master_zone_tab",
		`slave : "slave_zone_tab",
		`stub : "stub_zone_tab",
	    ],
	    "master_zone_tab" : $[
		`abort : `abort,
		`next : "main",
	    ],
	    "slave_zone_tab" : $[
		`abort : `abort,
		`next : "main",
	    ],
	    "stub_zone_tab" : $[
		`abort : `abort,
		`next : "main",
	    ],
	];

	symbol ret = Sequencer::Run(aliases, sequence);

	return ret;

    }

    global define symbol InstallWizardSequence () {
	map aliases = $[
	    "forwarders"	: ``(runInstallWizardForwardersDialog ()),
	    "zones"		: ``(runInstallWizardZonesDialog ()),
	    "finish"		: ``(runInstallWizardFinishDialog ()),
	    "tab_seq"		: ``(TabSequence ()),
	    "zone_type_switch"	:[``(runZoneTypeSwitch ()), true],
	    "master_zone_tab"	: ``(runMasterZoneTabDialog ()),
	    "slave_zone_tab"	: ``(runSlaveZoneTabDialog ()),
	    "stub_zone_tab"	: ``(runStubZoneTabDialog ()),
	];

	map sequence = $[
	    "ws_start" : "forwarders",
	    "forwarders" : $[
		`next	: "zones",
		`abort	: `abort,
	    ],
	    "zones" : $[
		`next	: "finish",
		`abort	: `abort,
		`edit_zone : "zone_type_switch",
	    ],
	    "finish" : $[
		`next	: `next,
		`abort	: `abort,
		`expert : "tab_seq",
	    ],
	    "tab_seq" : $[
		`abort : `abort,
		`next : `next,
	    ],
	    "zone_type_switch" : $[
		`abort : `abort,
		`master : "master_zone_tab",
		`slave : "slave_zone_tab",
		`stub : "stub_zone_tab",
	    ],
	    "master_zone_tab" : $[
		`abort : `abort,
		`next : "zones",
	    ],
	    "slave_zone_tab" : $[
		`abort : `abort,
		`next : "zones",
	    ],
	    "stub_zone_tab" : $[
		`abort : `abort,
		`next : "zones",
	    ],
	];

	symbol ret = Sequencer::Run(aliases, sequence);

	return ret;

    }

    /**
      * Main workflow of the dns-server configuration
      * @return sequence result
      */
/**    global define symbol MainSequence() ``{

	map aliases = $[
	    "main"		: ``(runMainDialog ()),
	    "global_options"	: ``(runGlobalOptionsDialog ()),
	    "new_zone"		: ``(runNewZoneDialog ()),
	    "zone_type_switch"	:[``(runZoneTypeSwitch ()), true],
	    "master_zone"	: ``(runMasterZoneDialog ()),
	    "soa"		: ``(runSoaDialog ()),
	    "slave_zone"	: ``(runSlaveZoneDialog ()),
	    "stub_zone"		: ``(runStubZoneDialog ()),
	    "store_zone"	:[``(runZoneStore ()), true],
	    "firewall_settings" : ``(runFirewallDialog ()),
	    "ddns_settings"	: ``(runDDNSDialog ()),
	    "ddns_settings_2"	: ``(runDDNSDialog ()),
	];

	map sequence = $[
	    "ws_start" : "main",
	    "main" : $[
		`abort : `abort,
		`next : `next,
		`add : "new_zone",
		`edit : "zone_type_switch",
		`global_options : "global_options",
		`firewall : "firewall_settings",
		`ddns : "ddns_settings",
	    ],
	    "global_options" : $[
		`abort : `abort,
		`next : "main",
	    ],
	    "firewall_settings" : $[
		`abort : `abort,
		`next : "main",
	    ],
	    "ddns_settings" : $[
		`abort : `abort,
		`next : "main",
	    ],
	    "new_zone" : $[
		`abort : `abort,
		`next : "zone_type_switch",
	    ],
	    "zone_type_switch" : $[
		`abort : `abort,
		`master : "master_zone",
		`slave : "slave_zone",
		`stub : "stub_zone",
	    ],
	    "master_zone" : $[
		`abort : `abort,
		`next : "store_zone",
		`soa : "soa",
		`again : "master_zone",
		`ddns : "ddns_settings_2",
	    ],
	    "ddns_settings_2" : $[
		`abort : `abort,
		`next : "master_zone",
	    ],
	    "soa" : $[
		`abort : `abort,
		`next : "master_zone",
	    ],
	    "slave_zone" : $[
		`abort : `abort,
		`next : "store_zone",
		`again : "slave_zone",
	    ],
	    "stub_zone" : $[
		`abort : `abort,
		`next : "store_zone",
		`again : "stub_zone",
	    ],
	    "store_zone" : $[
		`abort : `abort,
		`next : "main",
	    ],
	];

	symbol ret = Sequencer::Run(aliases, sequence);

	return ret;
    }
*/

    /**
      * Whole configuration of dns-server
      * @return sequence result
      */
    global define symbol DnsSequence() ``{

	map aliases = $[
	    "read"	: [ ``( ReadDialog() ), true ],
//	    "main"	:   ``( MainSequence() ),
	    "main"	:   ``( TabSequence() ),
	    "wizard"	:   ``( InstallWizardSequence() ),
	    "write"	: [ ``( WriteDialog() ), true ]
	];

	map sequence = $[
	    "ws_start" : "read",
	    "read" : $[
		`abort	: `abort,
		`next	: "main"
	    ],
	    "main" : $[
		`abort	: `abort,
		`next	: "write"
	    ],
	    "wizard" : $[
		`abort	: `abort,
		`next	: "write"
	    ],
	    "write" : $[
		`abort	: `abort,
		`next	: `next
	    ]
	];

	Wizard::CreateDialog();
	Wizard::SetDesktopIcon("dns-server");

	if ($[] == SCR::Read (.target.stat, Directory::vardir + "/dns_server"))
	{
	    sequence["read", `next] = "wizard";
	}

	symbol ret = Sequencer::Run(aliases, sequence);

	UI::CloseDialog();
	return ret;
    }

    /**
      * Whole configuration of dns-server
      * @return sequence result
      */
    global define symbol DnsAutoSequence() ``{

	map aliases = $[
	    "main"	:   ``( TabSequence() ),
//	    "main"	:   ``( MainSequence() ),
	];

	map sequence = $[
	    "ws_start" : "main",
	    "main" : $[
		`abort	: `abort,
		`next	: `next
	    ]
	];

	Wizard::CreateDialog();
	Wizard::SetDesktopIcon("dns-server");

	symbol ret = Sequencer::Run(aliases, sequence);

	UI::CloseDialog();
	return ret;
    }

/* EOF */
}
