/** * File: include/CASA/complex.ycp * Package: Configuration of CASA * Summary: Dialogs definitions * Authors: casa * ********************************************************************* * Copyright (C) 2005-2007 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 "Label"; import "Popup"; import "Wizard"; //import "Wizard_hw"; import "NovellCasa"; include "CASA/helps.ycp"; /** * Return a modification status * @return true if data was modified */ boolean Modified() { return NovellCasa::Modified(); } boolean ReallyAbort() { return !NovellCasa::Modified() || Popup::ReallyAbort(true); } boolean PollAbort() { return UI::PollInput() == `abort; } /** * Read settings dialog * @return `abort if aborted and `next otherwise */ symbol ReadDialog() { Wizard::RestoreHelp(HELPS["read"]:""); // NovellCasa::AbortFunction = PollAbort; boolean ret = NovellCasa::Read(); return ret ? `next : `abort; } /** * Write settings dialog * @return `abort if aborted and `next otherwise */ symbol WriteDialog() { Wizard::RestoreHelp(HELPS["write"]:""); // NovellCasa::AbortFunction = PollAbort; boolean ret = NovellCasa::Write(); return ret ? `next : `abort; } /** * Summary dialog * @return dialog result */ any SummaryDialog() { /* CASA summary dialog caption */ string caption = _("CASA Configuration"); /* FIXME */ list summary = NovellCasa::Summary(); list unconfigured = summary[1]:[]; string configured = summary[0]:""; /* Frame label */ // term contents = Wizard_hw::DetectedContent(_("CASA to Configure"), // unconfigured, false, configured); term contents = `Frame(_(" CASA Configuration Wizard Pages "), `VBox( `VSpacing(), `VSpacing(), // `PushButton(`id(`install_casa_button),`opt(`default), _("&Configure CASA")), `PushButton(`id(`install_casa_button),`opt(`default), _("&Enable CASA")), `VSpacing(), `VSpacing(), // `PushButton(`id(`uninstall_casa_button),`opt(`default), _("&Unconfigure CASA")), `PushButton(`id(`uninstall_casa_button),`opt(`default), _("&Disable CASA")), `VSpacing(), `VSpacing() )); Wizard::SetContentsButtons(caption, contents, HELPS["summary"]:"", Label::BackButton(), Label::FinishButton()); UI::ChangeWidget(`id(`install_casa_button), `Enabled, false); UI::ChangeWidget(`id(`uninstall_casa_button), `Enabled, false); integer iConfig_CASAReturn = (integer)SCR::Execute(.target.bash, "/usr/sbin/iscasaconfiged"); if(iConfig_CASAReturn == 0) { UI::ChangeWidget(`id(`uninstall_casa_button), `Enabled, true); } else { UI::ChangeWidget(`id(`install_casa_button), `Enabled, true); } any ret = nil; while(true) { ret = UI::UserInput(); /* abort? */ if(ret == `abort || ret == `cancel || ret == `back) { if(ReallyAbort()) break; else continue; } /* overview dialog */ else if(ret == `edit_button) { ret = `overview; break; } /* configure the selected device */ else if(ret == `configure_button) { // TODO FIXME: check for change of the configuration any selected = UI::QueryWidget(`id(`detected_selbox), `CurrentItem); if(selected == `other) { ret = `other; } else { ret = `configure; } break; } else if(ret == `next) { break; } else if(ret == `install_casa_button) { if(iConfig_CASAReturn != 0) { // launch the install script here y2milestone ("SummaryDialog() launch the install script"); integer iInstall_CASAReturn = (integer)SCR::Execute(.target.bash, "/usr/sbin/installcasa"); if(iInstall_CASAReturn == 0) { y2milestone(sformat("SummaryDialog() SCR::Execute(.target.bash, /usr/sbin/installcasa) returned: %1",iInstall_CASAReturn)); // Popup::Message(sformat("YaST Configured CASA successfully.")); Popup::Message(sformat("YaST Enabled CASA successfully.")); } else if(iInstall_CASAReturn == 127) { Popup::Error(sformat("YaST was unable to find the installcasa script.")); } else if(iInstall_CASAReturn == 126) { Popup::Error(sformat("YaST requires root privleges to run the installcasa script.")); } else { Popup::Error(sformat("The install_casa script returned an unknown error: %1",iInstall_CASAReturn)); } UI::ChangeWidget(`id(`install_casa_button), `Enabled, false); UI::ChangeWidget(`id(`uninstall_casa_button), `Enabled, false); } continue; } else if(ret == `uninstall_casa_button) { if(iConfig_CASAReturn == 0) { // launch the uninstall script here y2milestone ("SummaryDialog() launch the uninstall script"); integer iUninstall_CASAReturn = (integer)SCR::Execute(.target.bash, "/usr/sbin/uninstallcasa"); if(iUninstall_CASAReturn == 0) { y2milestone(sformat("SummaryDialog() SCR::Execute(.target.bash, /usr/sbin/uninstallcasa) returned: %1",iUninstall_CASAReturn)); // Popup::Message(sformat("YaST Unconfigured CASA successfully.")); Popup::Message(sformat("YaST Disabled CASA successfully.")); } else if(iUninstall_CASAReturn == 127) { Popup::Error(sformat("YaST was unable to find the uninstallcasa script.")); } else if(iUninstall_CASAReturn == 126) { Popup::Error(sformat("YaST requires root privleges to run the uninstallcasa script.")); } else { Popup::Error(sformat("The uninstall_casa script returned an unknown error: %1",iUninstall_CASAReturn)); } UI::ChangeWidget(`id(`uninstall_casa_button), `Enabled, false); UI::ChangeWidget(`id(`install_casa_button), `Enabled, false); } continue; } else { y2error("unexpected retcode: %1", ret); continue; } } return ret; } /** * Overview dialog * @return dialog result */ any OverviewDialog() { /* CASA overview dialog caption */ string caption = _("CASA Overview"); list overview = NovellCasa::Overview(); /* FIXME table header */ // term contents = Wizard_hw::ConfiguredContent( // /* Table header */ // `header(_("Number"), _("CASA")), // overview, nil, nil, nil, nil ); // contents = Wizard_hw::SpacingAround(contents, 1.5, 1.5, 1.0, 1.0); term contents = `Frame(_("CASA Configuration Wizard Pages"), `VBox( `VSpacing(), `VSpacing(), `PushButton(`id(`start_wizard_button),`opt(`default), _("Re&start Wizard")), `VSpacing() )); Wizard::SetContentsButtons(caption, contents, HELPS["overview"]:"", Label::BackButton(), Label::FinishButton()); any ret = nil; while(true) { ret = UI::UserInput(); /* abort? */ if(ret == `abort || ret == `cancel) { if(ReallyAbort()) break; else continue; } /* add */ else if(ret == `add_button) { /* FIXME */ ret = `add; break; } /* edit */ else if(ret == `edit_button) { /* FIXME */ ret = `edit; break; } /* delete */ else if(ret == `delete_button) { /* FIXME */ continue; } else if(ret == `next || ret == `back) { break; } else { y2error("unexpected retcode: %1", ret); continue; } } return ret; } /* EOF */ }