Wizard

 view release on metacpan or  search on metacpan

lib/Wizard/Examples/ISDN/Settings.pm  view on Meta::CPAN

     ['Wizard::Elem::Text', 'name' => 'isdn-settings-I4L_HARDWARE_PHONE',
      'value' => $sets->{'isdn-settings-I4L_HARDWARE_PHONE'},
      'descr' => 'Local MSN or EAZ; maybe empty'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-INTERNET_PHONE_OUT',
      'value' => $sets->{'isdn-settings-INTERNET_PHONE_OUT'},
      'descr' => 'Phone number of the Internet dailup line; may be empty'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-INTERNET_PHONE_IN',
      'value' => $sets->{'isdn-settings-INTERNET_PHONE_IN'},
      'descr' => 'Phone number of the Internet dailin line; may be empty'],
     ['Wizard::Elem::Select', 'name' => 'isdn-settings-INTERNET_ENABLED',
      'options' => ['yes', 'no'],
      'value' => $sets->{'isdn-settings-INTERNET_ENABLED'},
      'descr' => 'Use this ISDN card for Internet'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-INTERNET_USER',
      'value' => $sets->{'isdn-settings-INTERNET_USER'},
      'descr' => 'User name to login as'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-INTERNET_PASSWORD',
      'value' => $sets->{'isdn-settings-INTERNET_PASSWORD'},
      'descr' => 'Password to use'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-SERVICE_PHONE_OUT',
      'value' => $sets->{'isdn-settings-SERVICE_PHONE_OUT'},
      'descr' => 'Phone number of the service dialup line; may be empty'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-SERVICE_PHONE_IN',
      'value' => $sets->{'isdn-settings-SERVICE_PHONE_IN'},
      'descr' => 'Phone number of the service dialin line; may be empty'],
     ['Wizard::Elem::Select', 'name' => 'isdn-settings-SERVICE_ENABLED',
      'options' => ['yes', 'no'],
      'value' => $sets->{'isdn-settings-SERVICE_ENABLED'},
      'descr' => 'Use this ISDN card for Service dailup'],
     ['Wizard::Elem::Select', 'name' => 'isdn-settings-SERVICE_RAWIP',
      'options' => ['yes', 'no'],
      'value' => $sets->{'isdn-settings-SERVICE_RAWIP'},
      'descr' => 'Use RawIp on the Service line'],
     ['Wizard::Elem::Select', 'name' => 'isdn-settings-SERVICE_CALLBACK',
      'options' => ['yes', 'no'],
      'value' => $sets->{'isdn-settings-SERVICE_CALLBACK'},
      'descr' => 'Enable Callback on the service line'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-SERVICE_USER',
      'value' => $sets->{'isdn-settings-SERVICE_USER'},
      'descr' => 'Service user name (used only if RawIp is disabled; may be empty'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-SERVICE_PASSWORD',
      'value' => $sets->{'isdn-settings-SERVICE_PASSWORD'},
      'descr' => 'Password of the service user'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-SERVICE_IP_LOCAL',
      'value' => $sets->{'isdn-settings-SERVICE_IP_LOCAL'},
      'descr' => 'Local IP address of the service line'],
     ['Wizard::Elem::Text', 'name' => 'isdn-settings-SERVICE_IP_REMOTE',
      'value' => $sets->{'isdn-settings-SERVICE_IP_REMOTE'},
      'descr' => 'Rempote IP address of the service line'],
     ['Wizard::Elem::Submit', 'name' => 'Action_SettingsSave',
      'value' => 'Save these settings', 'id' => 1],
     ['Wizard::Elem::Submit', 'name' => 'Action_Reset',
      'value' => 'Return to ISDN menu', 'id' => 98],
     ['Wizard::Elem::Submit', 'name' => 'Wizard::Examples::ISDN::Action_Reset',
      'value' => 'Return to top menu', 'id' => 99]);
}


sub Action_SettingsSave {
    my($self, $wiz) = @_;
    my ($prefs, $basedir, $sets) = $self->init(1);
    
    foreach my $opt ($wiz->param()) {
	$sets->{$opt} = $wiz->param($opt) if (($opt =~ /^isdn-settings/) && defined($wiz->param($opt)));
    }
    
    $sets->{'isdn-settings-I4L_HARDWARE_PROTO'} = '1' if $sets->{'isdn-settings-I4L_HARDWARE_PROTO'} =~ /^1TR6/i;
    $sets->{'isdn-settings-I4L_HARDWARE_PROTO'} = '2' if $sets->{'isdn-settings-I4L_HARDWARE_PROTO'} =~ /^Euro/i;

    # Verify the new settings
    my $errors = '';
    my $ip_local = $sets->{'isdn-settings-SERVICE_IP_LOCAL'};
    my $ip_remote = $sets->{'isdn-settings-SERVICE_IP_REMOTE'};

    if ($ip_local) {
	$errors .= "Cannot resolve Service Local IP address $ip_local.\n"
	    unless Socket::inet_aton($ip_local);
    }
    if ($ip_remote) {
	$errors .= "Cannot resolve Service Remote IP address $ip_remote.\n"
	    unless Socket::inet_aton($ip_remote);
    }
    die $errors if $errors;

    $sets->Modified(1);
    $self->Store($wiz, 1);
    my $cmd = $prefs->{'isdn-prefs-upadatecmd'};
    my $cmdp = $cmd; $cmdp =~ s/\ .*$//g;
    system($cmd) if(-x $cmdp);

    $self->Wizard::Examples::ISDN::Action_Reset($wiz);
}

sub Action_Reset {
    my($self, $wiz) = @_;
    my ($prefs) = $self->init();

    my $cfile = $prefs->{'isdn-prefs-cfile'};
    $self->{'settings'} = Wizard::SaveAble::ShellVars->new('file' => $cfile, 'load' => 1, 'prefix' => 'isdn-settings-');
    $self->Store($wiz);

    return $self->ShowMe($wiz, $self->{'settings'});
}












( run in 0.606 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )