diff options
author | Thierry Vignaud <tv@mandriva.org> | 2008-02-01 18:00:17 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mandriva.org> | 2008-02-01 18:00:17 +0000 |
commit | 30a1302d7ebeb4dbdcd4976997552ac487823340 (patch) | |
tree | 4f2c1cd0cd918984713679ad2de578974dedcc4e | |
parent | 8e84ee04a68a2f2a29557971c9b6583231dd1fe3 (diff) | |
download | mgaonline-30a1302d7ebeb4dbdcd4976997552ac487823340.tar mgaonline-30a1302d7ebeb4dbdcd4976997552ac487823340.tar.gz mgaonline-30a1302d7ebeb4dbdcd4976997552ac487823340.tar.bz2 mgaonline-30a1302d7ebeb4dbdcd4976997552ac487823340.tar.xz mgaonline-30a1302d7ebeb4dbdcd4976997552ac487823340.zip |
(checkConfig,checkUpdates,isNetwork) readd them back as well as
disconnected state in order to make mdkapplet aware again of network
status (#35107) (thus reverting r232311 from 2007-12-05 13:22:53 [and
further cleanup r232726 on 2008-01-02 11:14:49])
now mdkapplet does not work w/o network
-rwxr-xr-x | mdkapplet | 51 |
1 files changed, 40 insertions, 11 deletions
@@ -80,7 +80,7 @@ mkdir_p($localdir) if !-d $localdir; my %state = ( delayed => { colour => [ 'busy' ], - changes => [ 'busy', 'critical' ], + changes => [ 'busy', 'critical', 'disconnected' ], menu => [ 'check' ], do_not_use_bubble => 1, tt => [ @@ -91,19 +91,19 @@ my %state = ( okay => { colour => [ 'okay' ], - changes => [ 'busy', 'critical' ], + changes => [ 'busy', 'critical', 'disconnected' ], menu => [ 'check' ], tt => [ N_("Your system is up-to-date") ] }, critical => { colour => [ 'noconf' ], - changes => [ 'okay', 'busy', 'critical' ], + changes => [ 'okay', 'busy', 'critical', 'disconnected' ], menu => [ 'check' ], tt => [ N_("Service configuration problem. Please check logs and send mail to support\@mandrivaonline.com") ] }, busy => { colour => [ 'busy' ], - changes => [ 'okay', 'critical', 'error' ], + changes => [ 'okay', 'critical', 'error', 'disconnected' ], menu => [], do_not_use_bubble => 1, tt => [ N_("Please wait, finding available packages...") ] @@ -120,6 +120,12 @@ my %state = ( menu => [ 'update', 'check' ], tt => [ N_("New bundles are available for your system") ] }, + disconnected => { + colour => [ 'disconnect' ], + changes => [ 'okay', 'busy', 'critical', 'error' ], + menu => [ 'confNetwork' ], + tt => [ N_("Network is down. Please configure your network") ] + }, disabled => { colour => [ 'disabled' ], changes => [ 'okay', 'busy', 'critical', 'error' ], @@ -128,7 +134,7 @@ my %state = ( }, locked => { colour => [ 'noconf' ], - changes => [ 'okay', 'busy', 'critical' ], + changes => [ 'okay', 'busy', 'critical', 'disconnected' ], menu => [ 'check' ], tt => [ N_("urpmi database locked") ], }, @@ -140,13 +146,13 @@ my %state = ( }, no_update_medium => { colour => [ 'noconf' ], - changes => [ 'okay', 'busy', 'critical' ], + changes => [ 'okay', 'busy', 'critical', 'disconnected' ], menu => [ 'check' ], tt => [ N_("No medium found. You must add some media through 'Software Media Manager'.") ], }, no_enabled_medium => { colour => [ 'noconf' ], - changes => [ 'okay', 'busy', 'critical' ], + changes => [ 'okay', 'busy', 'critical', 'disconnected' ], menu => [ 'check' ], tt => [ N("You already have at least one update medium configured, but all of them are currently disabled. You should run the Software @@ -197,7 +203,7 @@ my %comm_codes = ( my %actions = ( 'update' => { name => N("Install updates"), launch => sub { installUpdates() } }, - 'check' => { name => N("Check Updates"), launch => \&silentCheck }, + 'check' => { name => N("Check Updates"), launch => \&checkUpdates }, 'confNetwork' => { name => N("Configure Network"), launch => sub { configNetwork() } }, ); @@ -227,7 +233,8 @@ shouldStart() or die "$localfile should be set to TRUE: please use --force or -f $icon->show_all; go2State('delayed'); gtkflush(); -Glib::Timeout->add($config{FIRST_CHECK_DELAY}, sub { silentCheck(); 0 }); +checkConfig(); +Glib::Timeout->add($config{FIRST_CHECK_DELAY}, sub { checkUpdates(); 0 }); setup_cyclic_check(); @@ -388,8 +395,8 @@ sub setup_cyclic_check() { $first_run = 1; return 1; } - - silentCheck(); + checkConfig(); + checkUpdates(); 1; }); } @@ -405,6 +412,19 @@ sub setLastTime() { setVar($localfile, 'LASTCHECK', $date); } +sub checkConfig() { + if (!isNetwork()) { + logIt(N_("Checking Network: seems disabled\n")); + go2State('disconnected'); + } elsif (member($state_global, qw(disconnected))) { + silentCheck(); #- state has changed, update + } +} + +sub checkUpdates() { + member($state_global, qw(disconnected)) or silentCheck(); +} + sub go2State { my $state = shift; $menu->destroy if $menu; @@ -412,6 +432,15 @@ sub go2State { $state_global = $state; } +sub isNetwork() { + require network::network; + require network::tools; + my $net = {}; + network::network::read_net_conf($net); + my ($_gw_intf, $_is_up, $gw_address, $_dns_server) = network::tools::get_internet_connection($net); + to_bool($gw_address); +} + sub shouldStart() { my %p = getVarsFromSh($localfile); my $ret = $p{AUTOSTART} eq 'FALSE' ? 0 : 1; |