| 1 | # -*- perl -*- | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | ▶ | use Wizard::State (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 0 | ▶ | use Wizard::SaveAble (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 7 | use Wizard::Examples::ISDN::Config (); | ||
| 8 | |||
| 9 | |||
| 10 | package Wizard::Examples::ISDN; | ||
| 11 | |||
| 12 | @Wizard::Examples::ISDN::ISA = qw(Wizard::Examples); | ||
| 13 | $Wizard::Examples::ISDN::VERSION = '0.01'; | ||
| 14 | |||
| 15 | |||
| 16 | sub GetKey { 'prefs'; }; | ||
| 17 | |||
| 18 | sub init { | ||
| 19 | my $self = shift; | ||
| 20 | my $prefs = $self->{'prefs'} || die "Missing preferences"; | ||
| 21 | return ($prefs) unless shift; | ||
| 22 | my $cfile = $prefs->{'isdn-prefs-cfile'} || die "Missing config file"; | ||
| 23 | wantarray ? ($prefs, $cfile) : $prefs; | ||
| 24 | } | ||
| 25 | |||
| 26 | |||
| 27 | sub Action_Reset { | ||
| 28 | my($self, $wiz) = @_; | ||
| 29 | |||
| 30 | # Load prefs, if required. | ||
| 31 | unless ($self->{'prefs'}) { | ||
| 32 | my $cfg = $Wizard::Examples::ISDN::Config::config; | ||
| 33 | my $file = $cfg->{'isdn-prefs-file'}; | ||
| 34 | $self->{'prefs'} = Wizard::SaveAble->new('file' => $file, 'load' => 1); | ||
| 35 | $self->Store($wiz); | ||
| 36 | } | ||
| 37 | |||
| 38 | # Return the initial menu. | ||
| 39 | (['Wizard::Elem::Title', 'value' => 'ISDN Wizard Menu'], | ||
| 40 | ['Wizard::Elem::Submit', 'value' => 'ISDN Wizard preferences', | ||
| 41 | 'name' => 'Wizard::Examples::ISDN::Action_Preferences', | ||
| 42 | 'id' => 1], | ||
| 43 | ['Wizard::Elem::Submit', 'value' => 'ISDN Settings Wizard', | ||
| 44 | 'name' => 'Wizard::Examples::ISDN::Settings::Action_Reset', | ||
| 45 | 'id' => 2], | ||
| 46 | ['Wizard::Elem::BR'], | ||
| 47 | ['Wizard::Elem::Submit', 'value' => 'Return to Wizard Examples', | ||
| 48 | 'name' => 'Wizard::Examples::Action_Reset', | ||
| 49 | 'id' => 98], | ||
| 50 | ['Wizard::Elem::Submit', 'value' => 'Exit ISDN Wizard', | ||
| 51 | 'id' => 99]); | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | sub Action_Preferences { | ||
| 56 | my($self, $wiz) = @_; | ||
| 57 | my $prefs = $self->init(); | ||
| 58 | |||
| 59 | # Return a list of input elements. | ||
| 60 | (['Wizard::Elem::Title', 'value' => 'ISDN Wizard Preferences'], | ||
| 61 | ['Wizard::Elem::Text', 'name' => 'isdn-prefs-cfile', | ||
| 62 | 'value' => $prefs->{'isdn-prefs-cfile'}, | ||
| 63 | 'descr' => 'ISDN Configfile'], | ||
| 64 | ['Wizard::Elem::Text', 'name' => 'isdn-prefs-updatecmd', | ||
| 65 | 'value' => $prefs->{'isdn-prefs-updatecmd'}, | ||
| 66 | 'descr' => 'Command that will be executed on update'], | ||
| 67 | ['Wizard::Elem::Submit', 'name' => 'Action_PreferencesSave', | ||
| 68 | 'value' => 'Save these settings', 'id' => 1], | ||
| 69 | ['Wizard::Elem::Submit', 'name' => 'Action_PreferencesReset', | ||
| 70 | 'value' => 'Reset this form', 'id' => 98], | ||
| 71 | ['Wizard::Elem::Submit', 'name' => 'Action_Reset', | ||
| 72 | 'value' => 'Return to top menu', 'id' => 99]); | ||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | sub Action_PreferencesSave { | ||
| 77 | my($self, $wiz) = @_; | ||
| 78 | my $prefs = $self->init(); | ||
| 79 | foreach my $opt (qw(isdn-prefs-cfile isdn-prefs-updatecmd)) { | ||
| 80 | $prefs->{$opt} = $wiz->param($opt) if defined($wiz->param($opt)); | ||
| 81 | } | ||
| 82 | $prefs->Modified(1); | ||
| 83 | $self->Store($wiz, 1); | ||
| 84 | $self->Action_Reset($wiz); | ||
| 85 | } | ||
| 86 | |||
| 87 | |||
| 88 | sub Action_PreferencesReset { | ||
| 89 | my($self, $wiz) = @_; | ||
| 90 | $self->Action_Reset($wiz); | ||
| 91 | $self->Action_Preferences($wiz); | ||
| 92 | } | ||
| 93 | |||
| 94 | |||
| 95 | 1; | ||
| 96 | |||