summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2008-05-23 13:47:19 +0000
committerOlivier Blin <oblin@mandriva.com>2008-05-23 13:47:19 +0000
commitac1454746e6d312be5dfef85b09cf962b7582831 (patch)
tree9e3d49b59aebffc1aec00a297253c58bab7e0cba
parent5b77b46955f8b98a3e7d0b17119dda62f399d750 (diff)
downloaddrakx-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
-rw-r--r--lib/network/connection/cellular.pm18
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 || {};