CASA/casa-yast/src/NovellCasa.pm

308 lines
6.9 KiB
Perl

#! /usr/bin/perl -w
# File: modules/NovellCasa.pm
# Package: Configuration of CASA
# Summary: NovellCasa settings, input and output functions
# Authors: casa <casa@novell.com>
#
# $Id: NovellCasa.pm,v 1.5 2004/02/11 10:31:12 mvidner Exp $
#------------------------------------------------------------------------------
# Comments to:
# support@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.
#
#
#------------------------------------------------------------------------------
#
# Representation of the configuration of CASA.
# Input and output routines.
package NovellCasa;
use strict;
use ycp;
use YaST::YCP qw(Boolean);
use Locale::gettext;
use POSIX (); # Needed for setlocale()
POSIX::setlocale(LC_MESSAGES, "");
textdomain("CASA");
sub _ {
return gettext($_[0]);
}
our %TYPEINFO;
YaST::YCP::Import ("Progress");
YaST::YCP::Import ("Report");
YaST::YCP::Import ("Summary");
##
# Data was modified?
#
my $modified = 0;
##
#
my $proposal_valid = 0;
##
# Write only, used during autoinstallation.
# Don't run services and SuSEconfig, it's all done at one place.
#
my $write_only = 0;
##
# Data was modified?
# @return true if modified
#
BEGIN { $TYPEINFO {Modified} = ["function", "boolean"]; }
sub Modified {
y2debug ("modified=$modified");
return Boolean($modified);
}
# Settings: Define all variables needed for configuration of CASA
# TODO FIXME: Define all the variables necessary to hold
# TODO FIXME: the configuration here (with the appropriate
# TODO FIXME: description)
# TODO FIXME: For example:
# ##
# # List of the configured cards.
# #
# my @cards = ();
#
# ##
# # Some additional parameter needed for the configuration.
# #
# my $additional_parameter = 1;
##
# Read all CASA settings
# @return true on success
#
BEGIN { $TYPEINFO{Read} = ["function", "boolean"]; }
sub Read {
# NovellCasa read dialog caption
my $caption = _("Initializing CASA Configuration");
# TODO FIXME Set the right number of stages
my $steps = 4;
my $sl = 0.5;
sleep($sl);
# TODO FIXME Names of real stages
# We do not set help text here, because it was set outside
Progress::New( $caption, " ", $steps, [
# Progress stage 1/3
_("Read the database"),
# Progress stage 2/3
_("Read the previous settings"),
# Progress stage 3/3
_("Detect the devices")
], [
# Progress step 1/3
_("Reading the database..."),
# Progress step 2/3
_("Reading the previous settings..."),
# Progress step 3/3
_("Detecting the devices..."),
# Progress finished
_("Finished")
],
""
);
# read database
Progress::NextStage();
# Error message
if(0)
{
Report::Error(_("Cannot read the database1."));
}
sleep($sl);
# read another database
Progress::NextStep();
# Error message
if(0)
{
Report::Error(_("Cannot read the database2."));
}
sleep($sl);
# read current settings
Progress::NextStage();
# Error message
if(0)
{
Report::Error(_("Cannot read current settings."));
}
sleep($sl);
# detect devices
Progress::NextStage();
# Error message
if(0)
{
Report::Warning(_("Cannot detect devices."));
}
sleep($sl);
# Progress finished
Progress::NextStage();
sleep($sl);
$modified = 0;
return Boolean(1);
}
##
# Write all CASA settings
# @return true on success
#
BEGIN { $TYPEINFO{Write} = ["function", "boolean"]; }
sub Write {
# NovellCasa read dialog caption
my $caption = _("Saving CASA Configuration");
# TODO FIXME And set the right number of stages
my $steps = 2;
my $sl = 0.5;
sleep($sl);
# TODO FIXME Names of real stages
# We do not set help text here, because it was set outside
Progress::New($caption, " ", $steps, [
# Progress stage 1/2
_("Write the settings"),
# Progress stage 2/2
_("Run SuSEconfig")
], [
# Progress step 1/2
_("Writing the settings..."),
# Progress step 2/2
_("Running SuSEconfig..."),
# Progress finished
_("Finished")
],
""
);
# write settings
Progress::NextStage();
# Error message
if(0)
{
Report::Error (_("Cannot write settings."));
}
sleep($sl);
# run SuSEconfig
Progress::NextStage ();
# Error message
if(0)
{
Report::Error (_("SuSEconfig script failed."));
}
sleep($sl);
# Progress finished
Progress::NextStage();
sleep($sl);
return Boolean(1);
}
##
# Get all CASA settings from the first parameter
# (For use by autoinstallation.)
# @param settings The YCP structure to be imported.
# @return boolean True on success
#
BEGIN { $TYPEINFO{Import} = ["function", "boolean", [ "map", "any", "any" ] ]; }
sub Import {
my %settings = %{$_[0]};
# TODO FIXME: your code here (fill the above mentioned variables)...
return Boolean(1);
}
##
# Dump the CASA settings to a single map
# (For use by autoinstallation.)
# @return map Dumped settings (later acceptable by Import ())
#
BEGIN { $TYPEINFO{Export} =["function", [ "map", "any", "any" ] ]; }
sub Export {
# TODO FIXME: your code here (return the above mentioned variables)...
return {};
}
##
# Create a textual summary and a list of unconfigured cards
# @return summary of the current configuration
#
BEGIN { $TYPEINFO{Summary} = ["function", [ "list", "string" ] ]; }
sub Summary {
# TODO FIXME: your code here...
# Configuration summary text for autoyast
return (
_("Configuration summary ...")
);
}
##
# Create an overview table with all configured cards
# @return table items
#
BEGIN { $TYPEINFO{Overview} = ["function", [ "list", "string" ] ]; }
sub Overview {
# TODO FIXME: your code here...
return ();
}
##
# Return packages needed to be installed and removed during
# Autoinstallation to insure module has all needed software
# installed.
# @return map with 2 lists.
#
BEGIN { $TYPEINFO{AutoPackages} = ["function", ["map", "string", ["list", "string"]]]; }
sub AutoPackages {
# TODO FIXME: your code here...
my %ret = (
"install" => (),
"remove" => (),
);
return \%ret;
}
1;
# EOF