diff options
-rw-r--r-- | lib/network/connection/cellular_card.pm | 9 | ||||
-rw-r--r-- | lib/network/connection_manager.pm | 4 | ||||
-rw-r--r-- | lib/network/netconnect.pm | 4 |
3 files changed, 17 insertions, 0 deletions
diff --git a/lib/network/connection/cellular_card.pm b/lib/network/connection/cellular_card.pm index eb0851e..fb6948f 100644 --- a/lib/network/connection/cellular_card.pm +++ b/lib/network/connection/cellular_card.pm @@ -68,6 +68,15 @@ sub get_hardware_settings { [ { label => N("PIN number"), val => \$self->{hardware}{pin}, hidden => 1 } ]; } +sub check_hardware_settings { + my ($self) = @_; + if ($self->{hardware}{pin} !~ /^[0-9]{4}$/) { + $self->{hardware}{error} = N("Wrong PIN number format: it should be 4 digits."); + return 0; + } + 1; +} + sub get_peer_default_options { my ($self) = @_; $self->SUPER::get_peer_default_options, diff --git a/lib/network/connection_manager.pm b/lib/network/connection_manager.pm index 4d4b12a..0ea65ee 100644 --- a/lib/network/connection_manager.pm +++ b/lib/network/connection_manager.pm @@ -73,6 +73,10 @@ sub setup_connection { title => N("Network settings"), messages => N("Please enter settings for network") }, $cmanager->{connection}->get_hardware_settings) or return; + if ($cmanager->{connection}->can("check_hardware_settings") && !$cmanager->{connection}->check_hardware_settings) { + $cmanager->{in}->ask_warn(N("Error"), $cmanager->{connection}->{hardware}{error}); + return; + } } if ($cmanager->{connection}->can('check_hardware')) { my $wait = $cmanager->{in}->wait_message(N("Please wait"), N("Configuring device...")); diff --git a/lib/network/netconnect.pm b/lib/network/netconnect.pm index 50c6174..a618f0f 100644 --- a/lib/network/netconnect.pm +++ b/lib/network/netconnect.pm @@ -173,6 +173,10 @@ sub real_main { name => sub { $net->{type}->get_type_name . "\n\n" . N("Hardware Configuration") }, data => sub { $hardware_settings }, complete => sub { + if ($connection->can("check_hardware_settings") && !$connection->check_hardware_settings) { + $in->ask_warn('', $connection->{hardware}{error}); + return 1; + } if ($connection->can('check_hardware')) { my $_w = $in->wait_message(N("Please wait"), N("Configuring device...")); if (!$connection->check_hardware) { |