From 4e04412c49cbf2d4fb541d7e9793eb1449f97de0 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Tue, 17 Aug 2004 15:40:16 +0000 Subject: use network::tools::get_internet_connection --- perl-install/standalone/net_applet | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'perl-install/standalone') diff --git a/perl-install/standalone/net_applet b/perl-install/standalone/net_applet index f07183694..58ef1e7d7 100644 --- a/perl-install/standalone/net_applet +++ b/perl-install/standalone/net_applet @@ -1,10 +1,12 @@ #!/usr/bin/perl use strict; -use lib qw(/usr/lib/libDrakX); +use lib qw(/home/blino/cvs/gi/perl-install /usr/lib/libDrakX); use c; use common; use Digest::MD5; +use network::netconnect; +use network::tools; use Gtk2::TrayIcon; @@ -34,7 +36,7 @@ my %appletstate = ( menu => [ 'confNetwork', 'refresh', 'help' ], tt => [ #-PO: keep the "Configure Network" substring synced with the "Configure Network" message below - N_("Network is down. Click on \"Configure Network\"") + N_("Network is down on interface %d. Click on \"Configure Network\"") ] } ); @@ -92,21 +94,16 @@ sub netMonitor() { checkNetwork() } sub checkNetwork() { - my $gatewayconf = '/etc/sysconfig/network'; - my %h = getVarsFromSh($gatewayconf); - my $new_md5 = md5file($prog_name); - # print "NEW($newmd5) = OLD($oldmd5)\n" - my ($gd, $addrgd); - if ($h{GATEWAYDEV}) { - $addrgd = getIP($gd = $h{GATEWAYDEV}); - } else { - ($addrgd, $gd) = `/sbin/ip route show` =~ /^default\s+via\s+(\S+).*\s+dev\s+(\S+)/m; - } - - if ($addrgd) { - go2State('connected', $gd) - } else { go2State('disconnected', '') } + my $netcnx = {}; + my $netc = {}; + my $intf = {}; + network::netconnect::read_net_conf($netcnx, $netc, $intf); + my ($gw_intf, $is_up, $gw_address, $dns_server) = network::tools::get_internet_connection($netc, $intf); + if ($gw_address) { + go2State('connected', $gw_intf) + } else { go2State('disconnected', $gw_intf) } + my $new_md5 = md5file($prog_name); if ($new_md5 ne $current_md5) { exec($prog_name) }; } sub getIP { -- cgit v1.2.1