diff options
author | Olivier Blin <oblin@mandriva.com> | 2008-05-23 13:47:19 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.com> | 2008-05-23 13:47:19 +0000 |
commit | ac1454746e6d312be5dfef85b09cf962b7582831 (patch) | |
tree | 9e3d49b59aebffc1aec00a297253c58bab7e0cba /lib/network/connection/cellular.pm | |
parent | 5b77b46955f8b98a3e7d0b17119dda62f399d750 (diff) | |
download | drakx-net-ac1454746e6d312be5dfef85b09cf962b7582831.tar drakx-net-ac1454746e6d312be5dfef85b09cf962b7582831.tar.gz drakx-net-ac1454746e6d312be5dfef85b09cf962b7582831.tar.bz2 drakx-net-ac1454746e6d312be5dfef85b09cf962b7582831.tar.xz drakx-net-ac1454746e6d312be5dfef85b09cf962b7582831.zip |
guess provider according to APN from chat file or from configuration of current network
Diffstat (limited to 'lib/network/connection/cellular.pm')
-rw-r--r-- | lib/network/connection/cellular.pm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/network/connection/cellular.pm b/lib/network/connection/cellular.pm index 51d9e3d..3b9c6e0 100644 --- a/lib/network/connection/cellular.pm +++ b/lib/network/connection/cellular.pm @@ -36,6 +36,24 @@ sub write_cellular_settings { setVarsInShMode($file, 0600, { map { (uc($_) => $self->{access}{$_}) } qw(login password apn) }); } +sub guess_apn_from_chat { + my ($self) = @_; + my $chat = cat_($::prefix . $self->get_chat_file); + my $chat_apn = $chat =~ /\bAT\+CGDCONT=\d+,"IP","([^"]+)"/ && $1; +} + +sub guess_provider_settings { + my ($self) = @_; + my $settings = $self->load_cellular_settings; + my $apn = $self->guess_apn_from_chat || $settings && $settings->{APN}; + if ($apn) { + my @providers_data = $self->get_providers; + $self->{provider_name} ||= find { $providers_data[0]{$_}{apn} eq $apn } keys %{$providers_data[0]}; + return; + } + $self->SUPER::guess_provider_settings; +} + sub guess_access_settings { my ($self) = @_; my $settings = $self->load_cellular_settings || {}; |