summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakpxe
Commit message (Expand)AuthorAgeFilesLines
* adapt to new directories layout:Pascal Rigaux2004-07-261-3/+3
* perl_checker compliancePascal Rigaux2004-07-211-1/+1
* MandrakeSoft -> MandrakesoftPascal Rigaux2004-07-201-1/+1
* do not abuse global namespaceThierry Vignaud2004-02-161-2/+2
* new banner iconsThierry Vignaud2004-02-131-1/+1
* update copyright noticesThierry Vignaud2004-01-221-1/+1
* fix bogus use of old netwok module instead of network::networkThierry Vignaud2003-11-121-2/+2
* misc perl_checker cleanupsThierry Vignaud2003-10-201-2/+2
* network::netconnect is unusedThierry Vignaud2003-10-171-1/+0
* "xxx or xxx" in list context is always bad!Pascal Rigaux2003-08-191-2/+2
* fixed to match new pxe dhcp.conf configuration file.Francois Pons2003-08-131-2/+2
* perl_checker fixesThierry Vignaud2003-05-231-3/+3
* fixed bad English stringPablo Saratxaga2003-02-281-1/+1
* reflect in standalone drakxtools the removal of DrakX iconsGuillaume Cottenceau2003-02-281-1/+1
* added code to handle more smootly if apache or apache-mod_perl is installed, orFrancois Pons2003-02-261-1/+1
* switched to apache2 instead of apache (avoid problem with apache-mod_perl).Francois Pons2003-02-261-1/+1
* fix translation of title by calling N() after interactive->vnewGuillaume Cottenceau2003-02-171-1/+1
* fix just stupid fpons sucksThierry Vignaud2003-02-121-1/+1
* updated to find an interface even when no profile are available.Francois Pons2003-02-121-6/+10
* fixed perl_checkerFrancois Pons2003-01-291-14/+16
* perl_checker fixThierry Vignaud2003-01-231-2/+2
* latest fixes for having default file correctly documented and make sure ifFrancois Pons2003-01-211-19/+22
* add daemons stop/start code.Francois Pons2003-01-211-0/+3
* update with something that look like running.Francois Pons2003-01-211-381/+289
* initial revision with translation message.Francois Pons2003-01-201-0/+596
nner} list => [] , # wizard layer variables: boolean_list => "", # provide default status for booleans list }, ], }, }, }; my $w => wizards->new $w->process($wiz, $in); =head1 DESCRIPTION wizards is a layer built on top of the interactive layer that do proper backward/forward stepping for us. A step is made up of a name/description, a list of interactive fields (see interactive documentation), a "complete", "pre" and "post" callbacks, an help id, ... The "pre" callback is run first. Its only argument is the actual step hash. Then, if the "name" fiels is a code reference, that callback is run and its actual result is used as the description of the step. At this stage, the interactive layer is used to display the actual step. The "post" callback is only run if the user has steped forward. Alternatively, you can call safe_process() rather than process(). safe_process() will handle for you the "wizcancel" exception while running the wizard. Actually, it should be used everywhere but where the wizard is not the main path (eg "mail alert wizard" in logdrake, ...), ie when you may need to do extra exception managment such as destroying the wizard window and the like. =cut sub new { bless {}, $_[0] } sub check_rpm { my ($in, $rpms) = @_; foreach my $rpm (@$rpms) { next if $in->do_pkgs->is_installed($rpm); if ($in->ask_okcancel(N("Error"), N("%s is not installed\nClick \"Next\" to install or \"Cancel\" to quit", c::from_utf8($rpm)))) { $::testing and next; if (!$in->do_pkgs->install($rpm)) { local $::Wizard_finished = 1; $in->ask_okcancel(N("Error"), N("Installation failed")); $in->exit; } } else { $in->exit } } } # sync me with interactive::ask_from_normalize() if needed: my %default_callback = (changed => sub {}, focus_out => sub {}, complete => sub { 0 }, canceled => sub { 0 }, advanced => sub {}); sub process { my ($_w, $o, $in) = @_; local $::isWizard = 1; local $::Wizard_title = $o->{name} || $::Wizard_title; local $::Wizard_pix_up = $o->{defaultimage} || $::Wizard_pix_up; #require_root_capability() if $> && !$o->{allow_user} && !$::testing; check_rpm($in, $o->{needed_rpm}) if ref($o->{needed_rpm}); if (defined $o->{init}) { my ($res, $msg) = &{$o->{init}}; if (!$res) { $in->ask_okcancel(N("Error"), $msg); die "wizard failled" if !$::testing; } } my @steps; # steps stack # initial step: my $next = 'welcome'; my $page = $o->{pages}{welcome}; while ($next) { local $::Wizard_no_previous = $page->{no_back}; local $::Wizard_no_cancel = $page->{no_cancel} || $page->{end}; local $::Wizard_finished = $page->{end}; defined $page->{pre} and $page->{pre}($page); die qq(inexistant "$next" wizard step) if is_empty_hash_ref($page); # FIXME or the displaying fails my $data = defined $page->{data} ? (ref($page->{data}) eq 'CODE' ? $page->{data}->() : $page->{data}) : []; my $data2; foreach my $d (@$data) { $d->{val} = ${$d->{val_ref}} if $d->{val_ref}; $d->{list} = $d->{list_ref} if $d->{list_ref}; #$d->{val} = ref($d->{val}) eq 'CODE' ? $d->{val}->() : $d->{val}; if ($d->{boolean_list}) { my $i; foreach (@{$d->{boolean_list}}) { push @$data2, { text => $_, type => 'bool', val => \${$d->{val}}->[$i], disabled => $d->{disabled} }; $i++; } } else { push @$data2, $d; } } my $name = ref($page->{name}) ? $page->{name}->() : $page->{name}; my %yesno = (yes => N("Yes"), no => N("No")); my $yes = ref($page->{default}) eq 'CODE' ? $page->{default}->() : $page->{default}; $data2 = [ { val => \$yes, type => 'list', list => [ keys %yesno ], format => sub { $yesno{$_[0]} }, gtk => { use_boxradio => 1 } } ] if $page->{type} eq "yesorno"; my $a; if (ref $data2 eq 'ARRAY' && @$data2) { $a = $in->ask_from_({ title => $o->{name}, messages => $name, callbacks => { map { $_ => $page->{$_} || $default_callback{$_} } qw(focus_out complete) }, if_($page->{interactive_help_id}, interactive_help_id => $page->{interactive_help_id}), }, $data2); } else { $a = $in->ask_okcancel($o->{name}, $name, $yes || 'ok'); } # interactive->ask_yesorno does not support stepping forward or backward: $a = $yes if $a && $page->{type} eq "yesorno"; if ($a) { # step forward: push @steps, $next if !$page->{ignore} && $steps[-1] ne $next; my $current = $next; $next = defined $page->{post} ? $page->{post}($page->{type} eq "yesorno" ? $yes eq 'yes' : $a) : 0; return if $page->{end}; if (!$next) { if (!defined $o->{pages}{$next}) { $next = $page->{next}; } else { die qq(the "$next" page (from previous wizard step) is undefined) if !$next; } } die qq(Step "$current": inexistant "$next" page) if !exists $o->{pages}{$next}; } else { # step back: $next = pop @steps; } $page = $o->{pages}{$next}; } } sub safe_process { my ($w, $wiz, $in) = @_; eval { $w->process($wiz, $in) }; my $err = $@; if ($err =~ /wizcancel/) { $in->exit(0); } else { die $err if $err; } } 1;