summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rwxr-xr-xdraksnapshot-applet57
2 files changed, 33 insertions, 25 deletions
diff --git a/NEWS b/NEWS
index 044f480..0f43c5e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
- applet:
o delay first check by 30s so that notification goes at the right
place
+ o do not crash if DBus isn't reachable
Version 0.13 - 22 September 2008, Thierry Vignaud
diff --git a/draksnapshot-applet b/draksnapshot-applet
index d7050b0..41e6df0 100755
--- a/draksnapshot-applet
+++ b/draksnapshot-applet
@@ -91,31 +91,38 @@ my $hal_dn = 'org.freedesktop.Hal';
my $hal_manager = "$hal_dn.Manager";
my $manager_path = '/org/freedesktop/Hal/Manager';
-my $dbus = dbus_object::system_bus();
-
-my $do = dbus_object->new($dbus, $hal_dn, $manager_path, $hal_manager);
-
-my $con = $dbus->{connection};
-my $old_time;
-$con->add_filter(sub {
- my ($_bus, $msg) = @_;
- return 0 if $msg->get_member ne 'DeviceAdded';
- my $hal = $dbus->get_service($hal_dn);
- my $bool;
- eval {
- my $device = $hal->get_object(($msg->get_args_list)[0], "$hal_dn.Device");
- $bool =
- $device->QueryCapability('volume') && !$device->GetProperty('volume.is_disc') &&
- $device->GetProperty('volume.is_mounted');
- };
- if ($bool) {
- my $time = time();
- go2State('disk_found') if 5 < abs($time - $old_time);
+my $dbus = eval { dbus_object::system_bus() };
+my $dbus_error = $@;
+
+
+
+# initializing DBus/HAL:
+my ($do, $con);
+if ($dbus) {
+ $do = dbus_object->new($dbus, $hal_dn, $manager_path, $hal_manager);
+
+ $con = eval { $dbus->{connection} };
+ my $old_time;
+ $con->add_filter(sub {
+ my ($_bus, $msg) = @_; # perl_checker: Net::DBus::Binding::Message::Signal
+ return 0 if $msg->get_member ne 'DeviceAdded';
+ my $hal = $dbus->get_service($hal_dn);
+ my $bool;
+ eval {
+ my $device = $hal->get_object(($msg->get_args_list)[0], "$hal_dn.Device");
+ $bool =
+ $device->QueryCapability('volume') && !$device->GetProperty('volume.is_disc') &&
+ $device->GetProperty('volume.is_mounted');
+ };
+ if ($bool) {
+ my $time = time();
+ go2State('disk_found') if 5 < abs($time - $old_time);
$old_time = $time;
- }
- 0;
- });
-$con->add_match("type='signal',interface='$hal_manager'");
+ }
+ 0;
+ });
+ $con->add_match("type='signal',interface='$hal_manager'");
+}
my ($opt) = @ARGV;
@@ -134,7 +141,7 @@ $SIG{CHLD} = \&harvester;
run_program::raw({ detach => 1 }, 'ionice', '-p', $$, '-n7');
-$do->set_gtk2_watch;
+$do and $do->set_gtk2_watch;
Gtk2->main;
ugtk2::exit(0);