/**
 * File:	include/CASA/wizards.ycp
 * Package:	Configuration of CASA
 * Summary:	Wizards definitions
 * Authors:	casa <casa@novell.com>
 *
 *********************************************************************
 * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; version 2.1
 * of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, Novell, Inc.
 *
 * To contact Novell about this file by physical or electronic mail, 
 * you may find current contact information at www.novell.com.
 *
 *********************************************************************
 *
 */

{

textdomain "CASA";

import "Sequencer";
import "Wizard";

include "CASA/complex.ycp";
include "CASA/dialogs.ycp";

/**
 * Add a configuration of CASA
 * @return sequence result
 */
any AddSequence() {

    /* FIXME: adapt to your needs */
    map aliases = $[
	"config1"	: ``(Configure1Dialog()),
	"config2"	: ``(Configure2Dialog()),
    ];

    /* FIXME: adapt to your needs */
    map sequence = $[
	"ws_start" : "config1",
	"config1" : $[
	    `abort	: `abort,
	    `next	: "config2"
	],
	"config2" : $[
	    `abort	: `abort,
	    `next	: `next
	]
    ];

    return Sequencer::Run(aliases, sequence);
}

/**
 * Main workflow of the CASA configuration
 * @return sequence result
 */
any MainSequence() {

    /* FIXME: adapt to your needs */
    map aliases = $[
	"summary"	:   ``( SummaryDialog() ),
	"overview"	:   ``( OverviewDialog() ),
	"configure"	: [ ``( AddSequence() ), true ],
	"add"		: [ ``( AddSequence() ), true ],
	"edit"		: [ ``( AddSequence() ), true ]
    ];

    /* FIXME: adapt to your needs */
    map sequence = $[
	"ws_start" : "summary",
	"summary" : $[
	    `abort	: `abort,
	    `next	: `next,
	    `overview	: "overview",
	    `configure	: "configure",
	    `other	: "configure",
	],
	"overview" : $[
	    `abort	: `abort,
	    `next	: `next,
	    `add	: "add",
	    `edit	: "edit",
	],
	"configure" : $[
	    `abort	: `abort,
	    `next	: "summary",
	],
	"add" : $[
	    `abort	: `abort,
	    `next	: "overview",
	],
	"edit" : $[
	    `abort	: `abort,
	    `next	: "overview",
	]
    ];

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

    return ret;
}

/**
 * Whole configuration of CASA
 * @return sequence result
 */
any NovellCasaSequence() {

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

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

    Wizard::CreateDialog();
    Wizard::SetDesktopIcon("CASA");

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

    UI::CloseDialog();
    return ret;
}

/**
 * Whole configuration of CASA but without reading and writing.
 * For use with autoinstallation.
 * @return sequence result
 */
any NovellCasaAutoSequence() {

    /* Initialization dialog caption */
    string caption = _("CASA Configuration");
    /* Initialization dialog contents */
    term contents = `Label(_("Initializing..."));

    Wizard::CreateDialog();
    Wizard::SetContentsButtons(caption, contents, "",
	    Label::BackButton(), Label::NextButton());

    any ret = MainSequence();

    UI::CloseDialog();
    return ret;
}

/* EOF */
}