summaryrefslogtreecommitdiffstats
path: root/mdkapplet
diff options
context:
space:
mode:
Diffstat (limited to 'mdkapplet')
-rwxr-xr-xmdkapplet52
1 files changed, 39 insertions, 13 deletions
diff --git a/mdkapplet b/mdkapplet
index 8d93d2e6..c50ce271 100755
--- a/mdkapplet
+++ b/mdkapplet
@@ -33,11 +33,13 @@ if ($@) {
}
my ($eventbox, $img);
add_icon_path("/usr/share/mdkonline/pixmaps/");
-my ($menu, $url);
+my ($menu, $url, $timeout);
my $nowindow = 1;
my $arch = arch();
my $av_pkgs = $::testing ? 13 : 0;
-$conffile = '/etc/sysconfig/mdkonline';
+my $need_update = 0;
+
+my $conffile = '/etc/sysconfig/mdkonline';
my %state = (
okay => {
@@ -67,7 +69,7 @@ my %state = (
noconfig => {
colour => [ 'orange' ],
changes => [ 'okay' ],
- menu => [ 'update', 'weblink', 'register' ],
+ menu => [ 'weblink', 'register' ],
tt => [ N("Service not available. Click on \"configuration\"") ]
},
disconnected => {
@@ -75,7 +77,7 @@ my %state = (
changes => [ 'okay', 'busy', 'critical', 'error' ],
menu => [ 'confNetwork' ],
tt => [ N("Network is down. Click on \"configure Network\"") ]
- }
+ }
);
my %actions = (
'update' => { name => N("Launch Mandrake Update"), launch => sub { launchUpdate() } },
@@ -158,9 +160,10 @@ sub installUpdates {
$menu && $menu->destroy;
$menu = setState('error');
}
-sub checkUpdates {
+sub silentCheck {
my $link = "https://www.mandrakeonline.net/online3_RemoteAction.php/" . '?action=UpdateList';
- my %h = getVarsFromSh($conffile);
+ my %h = getVarsFromSh($conffile);
+ $need_update = 0;
my @r = sort( split /\n/, `rpm -qa` );
require LWP::UserAgent;
require HTTP::Request::Common;
@@ -180,13 +183,37 @@ sub checkUpdates {
}
$need_update
}
-sub firstUpdate {
-
+sub cronUpdate {
+ my ($to) = shift;
+ $timeout = Glib::Timeout->add(60*60*1000, sub {
+ checkUpdates
+ 1;
+ });
}
-sub configure {
- # system "/usr/sbin/mdkonline", "&";
+sub checkUpdates {
+ if (!isNetwork()) {
+ go2State('disconnected')
+ } elsif (!-e $conffile) {
+ go2State('noconfig')
+ } else {
+ my $update = silentCheck();
+ if ($update) {
+ go2State('critical')
+ } else { go2State('okay') }
+ }
+}
+sub go2State {
+ my $state = shift;
$menu && $menu->destroy;
- $menu = setState('okay');
+ $menu = setState($state);
+}
+sub isNetwork {
+ my $network;
+ $network = gethostbyname("mandrakeonline.net") ? 1 : 0;
+ $network;
+}
+sub configure {
+ system "/usr/sbin/mdkonline &";
}
sub getSite {
my $b = browser();
@@ -225,6 +252,5 @@ sub setState {
$menu
}
sub about {
- create_dialog(N("About Online Applet"),
- "\t" . "<span foreground=\"#21449C\"><u><b>" . N_("Mandrake Update Notification Applet") . "</b></u></span>\n\n<u>" . N_("Version:") . "</u> %s \n\n<u>" . N_("Team:"). "</u> " . N_("Mandrake Online Team"). " &lt;mot\@mandrakeonline.net&gt;\n\n<span foreground=\"#006666\"><i>" . N_("This Software is under GPL") . "</i></span>", ' 10.0 ' , { use_markup => 1 });
+
}