diff options
author | Eugeni Dodonov <eugeni@mandriva.org> | 2009-08-14 15:31:39 +0000 |
---|---|---|
committer | Eugeni Dodonov <eugeni@mandriva.org> | 2009-08-14 15:31:39 +0000 |
commit | cc65b8d0cc6c0ced59285cf34f6c3c8f8ef17fdd (patch) | |
tree | daeeeae2020dc5dad57024da41bc546dc554f59c | |
parent | 6626fd4c393477c4686a7823c03660a983c3accf (diff) | |
download | drakx-net-cc65b8d0cc6c0ced59285cf34f6c3c8f8ef17fdd.tar drakx-net-cc65b8d0cc6c0ced59285cf34f6c3c8f8ef17fdd.tar.gz drakx-net-cc65b8d0cc6c0ced59285cf34f6c3c8f8ef17fdd.tar.bz2 drakx-net-cc65b8d0cc6c0ced59285cf34f6c3c8f8ef17fdd.tar.xz drakx-net-cc65b8d0cc6c0ced59285cf34f6c3c8f8ef17fdd.zip |
Implemented netprofile module management.
-rwxr-xr-x | bin/draknetprofile | 33 | ||||
-rw-r--r-- | lib/network/network.pm | 28 |
2 files changed, 60 insertions, 1 deletions
diff --git a/bin/draknetprofile b/bin/draknetprofile index d226648..f938698 100755 --- a/bin/draknetprofile +++ b/bin/draknetprofile @@ -62,6 +62,23 @@ Gtk2::SimpleList->add_column_type( attr => 'active', ); +my $modules_list = Gtk2::SimpleList->new( + N("Module") => 'hidden', + N("Enabled") => 'bool', + N("Description") => 'text', +); + +my @r = $modules_list->get_column(0)->get_cell_renderers; +$r[0]->signal_connect('toggled' => sub { + my ($_renderer, $row, $_col) = @_; + if ($modules_list->{data}[$row][1]) { + network::network::netprofile_module_enable($modules_list->{data}[$row][0]); + } else { + network::network::netprofile_module_disable($modules_list->{data}[$row][0]); + } + }); + + my $profiles_list = Gtk2::SimpleList->new( "" => 'hidden', N("Profile") => 'text', @@ -74,6 +91,17 @@ $profiles_list->get_selection->signal_connect('changed' => sub { } }); +sub load_netprofile_modules() { + my @modules = network::network::netprofile_modules(); + foreach (@modules) { + push @{$modules_list->{data}}, [ + $_->{module}, + $_->{enabled}, + $_->{description}, + ]; + } +} + sub get_selected_profile() { my ($index) = $profiles_list->get_selected_indices; if (not $index ) { @@ -164,7 +192,9 @@ sub delete_selected_profile() { gtkadd($w->{window}, gtknew('VBox', spacing => 5, children => [ $::isEmbedded ? () : (0, Gtk2::Banner->new('draknetprofile', $title)), - 0, gtknew('WrappedLabel', text => N("This tool allows to activate an existing network profile, and to manage (clone, delete) profiles.") . "\n\n" . N("To modify a profile, you have to activate it first.")), + 0, gtknew('WrappedLabel', text => N("This tool allows to control network profiles.")), + 1, gtknew('ScrolledWindow', width => 300, height => 150, child => $modules_list), + 0, gtknew('WrappedLabel', text => N("Select a network profile:")), 1, gtknew('ScrolledWindow', width => 300, height => 150, child => $profiles_list), 0, gtknew('HButtonBox', children_loose => [ $buttons{activate} = gtknew('Button', text => N("Activate"), clicked => \&set_selected_profile, sensitive => 0), @@ -175,5 +205,6 @@ gtkadd($w->{window}, ]), ); +load_netprofile_modules(); update_profiles(); $w->main; diff --git a/lib/network/network.pm b/lib/network/network.pm index 8170d4a..ebcf9ca 100644 --- a/lib/network/network.pm +++ b/lib/network/network.pm @@ -395,6 +395,34 @@ sub gateway { join(".", @masked); } +sub netprofile_modules() { + my @m = split('\n', `/sbin/netprofile modules`); + my @modules = (); + + foreach my $module (@m) { + my @params = split('\t', $module); + my $vals = { + module => @params[0], + enabled => @params[1] == '+' ? 1 : 0, + name => @params[2], + description => @params[3], + }; + push(@modules, $vals); + } + @modules; +} + +sub netprofile_module_enable { + my ($module) = @_; + system('/sbin/netprofile', 'module_enable', $module); + log::explanations(qq(Enabling netprofile module $module)); +} + +sub netprofile_module_disable { + my ($module) = @_; + system('/sbin/netprofile', 'module_disable', $module); + log::explanations(qq(Disabling netprofile module $module)); +} sub netprofile_set { my ($net, $profile) = @_; |