summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/network/activefw.pm67
-rw-r--r--perl-install/standalone/drakids5
-rw-r--r--perl-install/standalone/net_applet4
3 files changed, 18 insertions, 58 deletions
diff --git a/perl-install/network/activefw.pm b/perl-install/network/activefw.pm
index 99a9d8db8..2a949379d 100644
--- a/perl-install/network/activefw.pm
+++ b/perl-install/network/activefw.pm
@@ -1,69 +1,26 @@
package network::activefw;
-use Gtk2::Helper;
+use dbus_object;
use Socket;
+our @ISA = qw(dbus_object);
+
sub new {
- my ($type, $filter) = @_;
+ my ($type, $bus, $filter) = @_;
- require Net::DBus;
- my $bus = Net::DBus->system;
my $con = $bus->{connection};
-
$con->add_filter($filter);
- $con->add_match("type='signal',interface='com.mandriva.activefirewall'");
-
- set_DBus_watch($con);
- $con->dispatch;
-
- my $o = bless { bus => $bus }, $type;
- $o->find_daemon;
-
+ $con->add_match("type='signal',interface='com.mandriva.monitoring.activefirewall'");
+
+ my $o = dbus_object::new($type,
+ $bus,
+ "com.mandriva.monitoring",
+ "/com/mandriva/monitoring/activefirewall",
+ "com.mandriva.monitoring.activefirewall");
+ dbus_object::set_gtk2_watch($o);
$o;
}
-sub find_daemon {
- my ($o) = @_;
- my $service = $o->{bus}->get_service("com.mandriva.activefirewall.daemon");
- $o->{daemon} = $service->get_object("/com/mandriva/activefirewall", "com.mandriva.activefirewall.daemon");
-}
-
-sub set_DBus_watch {
- my ($con) = @_;
- $con->set_watch_callbacks(sub {
- my ($con, $watch) = @_;
- my $flags = $watch->get_flags;
- require Net::DBus::Binding::Watch;
- if ($flags & &Net::DBus::Binding::Watch::READABLE) {
- Gtk2::Helper->add_watch($watch->get_fileno, 'in', sub {
- $watch->handle(&Net::DBus::Binding::Watch::READABLE);
- $con->dispatch;
- 1;
- });
- }
- #- do nothing for WRITABLE watch, we dispatch when needed
- }, undef, undef); #- do nothing when watch is disabled or toggled yet
-}
-
-sub dispatch {
- my ($o) = @_;
- $o->{bus}{connection}->dispatch;
-}
-
-sub call_method {
- my ($o, $method, @args) = @_;
- my @ret;
- eval {
- @ret = $o->{daemon}->$method(@args);
- };
- if ($@) {
- print "($method) exception: $@\n";
- $o->dispatch;
- return;
- }
- @ret;
-}
-
sub blacklist {
my ($o, $seq, $blacklist) = @_;
$o->call_method('Blacklist',
diff --git a/perl-install/standalone/drakids b/perl-install/standalone/drakids
index fd1e3cefd..b00bd9ec4 100644
--- a/perl-install/standalone/drakids
+++ b/perl-install/standalone/drakids
@@ -8,6 +8,7 @@ use standalone;
use Socket;
use mygtk2 qw(gtknew);
use POSIX qw(strftime);
+use dbus_object;
use network::activefw;
use Gtk2::SimpleList;
@@ -40,7 +41,7 @@ $whitelist->set_headers_clickable(1);
$whitelist->get_column(0)->signal_connect('clicked', \&sort_by_column, $whitelist->get_model);
$whitelist->get_column(0)->set_sort_column_id(0);
-my $activefw = network::activefw->new(sub {
+my $activefw = network::activefw->new(dbus_object::system_bus(), sub {
my ($_con, $msg) = @_;
my $member = $msg->get_member;
if ($member eq 'Blacklist') {
@@ -91,7 +92,7 @@ sub sort_by_column {
}
sub handle_init() {
- $activefw->attach_daemon;
+ $activefw->attach_object;
init_lists();
}
diff --git a/perl-install/standalone/net_applet b/perl-install/standalone/net_applet
index 37300d5a5..14ba43e6f 100644
--- a/perl-install/standalone/net_applet
+++ b/perl-install/standalone/net_applet
@@ -30,6 +30,8 @@ my $current_md5 = md5file($prog_name);
my $net = {};
my $watched_interface;
+my $dbus = dbus_object::system_bus();
+
$SIG{HUP} = sub {
print "received SIGHUP, reloading network configuration\n";
checkNetworkForce();
@@ -110,7 +112,7 @@ my $interactive_cb;
my @attacks_queue;
if ($enable_activefw) {
- $activefw = network::activefw->new(sub {
+ $activefw = network::activefw->new($dbus, sub {
my ($_con, $msg) = @_;
handle_attack($msg->get_args_list) if $msg->get_member eq "Attack";
});