summaryrefslogtreecommitdiffstats
path: root/perl-install/network/activefw.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-02-16 13:44:30 +0000
committerOlivier Blin <oblin@mandriva.org>2005-02-16 13:44:30 +0000
commit936e9b839602eeafb3f41c161b2416c81489c79f (patch)
treee14430a2f11ca9d33fc2980e2012a3e6f4dc0aa8 /perl-install/network/activefw.pm
parent6d2d2c97967b66528d84b1400431d58cccc00a4b (diff)
downloaddrakx-936e9b839602eeafb3f41c161b2416c81489c79f.tar
drakx-936e9b839602eeafb3f41c161b2416c81489c79f.tar.gz
drakx-936e9b839602eeafb3f41c161b2416c81489c79f.tar.bz2
drakx-936e9b839602eeafb3f41c161b2416c81489c79f.tar.xz
drakx-936e9b839602eeafb3f41c161b2416c81489c79f.zip
add generic call_method sub to factorize
Diffstat (limited to 'perl-install/network/activefw.pm')
-rw-r--r--perl-install/network/activefw.pm87
1 files changed, 24 insertions, 63 deletions
diff --git a/perl-install/network/activefw.pm b/perl-install/network/activefw.pm
index f152c581f..4c1292845 100644
--- a/perl-install/network/activefw.pm
+++ b/perl-install/network/activefw.pm
@@ -55,103 +55,64 @@ sub dispatch {
$o->{bus}{connection}->dispatch;
}
-sub get_mode {
- my ($o) = @_;
- my $mode;
+sub call_method {
+ my ($o, $method, @args) = @_;
+ my @ret;
eval {
- $mode = $o->{daemon}->GetMode;
+ @ret = $o->{daemon}->$method(@args);
};
if ($@) {
- print "(GetMode) exception: $@\n";
+ print "($method) exception: $@\n";
$o->dispatch;
return;
}
- $mode;
+ @ret;
+}
+
+sub get_mode {
+ my ($o) = @_;
+ $o->call_method('GetMode');
}
sub blacklist {
my ($o, $seq, $blacklist) = @_;
- eval {
- $o->{daemon}->Blacklist(Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $seq),
- Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $blacklist));
- };
- if ($@) {
- print "(Blacklist) exception: $@\n";
- $o->dispatch;
- }
+ $o->call_method('Blacklist',
+ Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $seq),
+ Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $blacklist));
}
sub unblacklist {
my ($o, $addr) = @_;
- eval {
- $o->{daemon}->UnBlacklist(Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $addr));
- };
- if ($@) {
- print "(UnBlacklist) exception: $@\n";
- $o->dispatch;
- }
+ $o->call_method('UnBlacklist',
+ Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $addr));
}
sub whitelist {
my ($o, $addr) = @_;
- eval {
- $o->{daemon}->Whitelist(Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $addr));
- };
- if ($@) {
- print "(Whitelist) exception: $@\n";
- $o->dispatch;
- }
+ $o->call_method('Whitelist',
+ Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $addr));
}
sub unwhitelist {
my ($o, $addr) = @_;
- eval {
- $o->{daemon}->UnWhitelist(Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $addr));
- };
- if ($@) {
- print "(UnWhitelist) exception: $@\n";
- $o->dispatch;
- }
+ $o->call_method('UnWhitelist',
+ Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $addr));
}
sub set_interactive {
my ($o, $mode) = @_;
- print "setting new IDS mode: $mode\n";
- eval {
- $o->{daemon}->SetMode(Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $mode));
- };
- if ($@) {
- print "(SetMode) exception: $@\n";
- $o->dispatch;
- }
+ $o->call_method('SetMode',
+ Net::DBus::Binding::Value->new(&Net::DBus::Binding::Message::TYPE_UINT32, $mode));
}
sub get_blacklist {
my ($o) = @_;
- my @blacklist;
- eval {
- @blacklist = $o->{daemon}->GetBlacklist;
- };
- if ($@) {
- print "(GetBlacklist) exception: $@\n";
- $o->dispatch;
- return;
- }
- @blacklist;
+ $o->call_method('GetBlacklist');
}
sub get_whitelist {
my ($o) = @_;
- my @whitelist;
- eval {
- @whitelist = $o->{daemon}->GetWhitelist;
- };
- if ($@) {
- print "(GetWhitelist) exception: $@\n";
- $o->dispatch;
- return;
- }
- @whitelist;
+ $o->call_method('GetWhitelist');
}
sub format_date {