summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/network/connection_manager.pm212
-rwxr-xr-xlib/network/netcenter.pm12
2 files changed, 112 insertions, 112 deletions
diff --git a/lib/network/connection_manager.pm b/lib/network/connection_manager.pm
index 526dc2f..462ae80 100644
--- a/lib/network/connection_manager.pm
+++ b/lib/network/connection_manager.pm
@@ -34,143 +34,143 @@ sub create {
}
sub prepare_connection {
- my ($droam) = @_;
+ my ($cmanager) = @_;
- my @packages = $droam->{connection}->can('get_packages') ? $droam->{connection}->get_packages : ();
- if (@packages && !$droam->{in}->do_pkgs->install(@packages)) {
- $droam->{in}->ask_warn(N("Error"), N("Could not install the packages (%s)!", join(', ', @packages)));
+ my @packages = $cmanager->{connection}->can('get_packages') ? $cmanager->{connection}->get_packages : ();
+ if (@packages && !$cmanager->{in}->do_pkgs->install(@packages)) {
+ $cmanager->{in}->ask_warn(N("Error"), N("Could not install the packages (%s)!", join(', ', @packages)));
return;
}
- $droam->{connection}->prepare_device;
- $droam->{connection}->setup_thirdparty($droam->{in}) or return;
- if ($droam->{connection}->can("check_device") && !$droam->{connection}->check_device) {
- $droam->{in}->ask_warn(N("Error"), $droam->{connection}{device}{error});
+ $cmanager->{connection}->prepare_device;
+ $cmanager->{connection}->setup_thirdparty($cmanager->{in}) or return;
+ if ($cmanager->{connection}->can("check_device") && !$cmanager->{connection}->check_device) {
+ $cmanager->{in}->ask_warn(N("Error"), $cmanager->{connection}{device}{error});
return;
}
- if ($droam->{connection}->can('get_hardware_settings')) {
- $droam->{connection}->guess_hardware_settings if $droam->{connection}->can('guess_hardware_settings');
- $droam->{in}->ask_from_({
+ if ($cmanager->{connection}->can('get_hardware_settings')) {
+ $cmanager->{connection}->guess_hardware_settings if $cmanager->{connection}->can('guess_hardware_settings');
+ $cmanager->{in}->ask_from_({
title => "Network settings",
messages => N("Please enter settings for network")
- }, $droam->{connection}->get_hardware_settings) or return;
+ }, $cmanager->{connection}->get_hardware_settings) or return;
}
- if ($droam->{connection}->can('check_hardware')) {
- my $_w = $droam->{in}->wait_message('', N("Configuring device..."));
- if (!$droam->{connection}->check_hardware) {
- $droam->{in}->ask_warn(N("Error"), $droam->{connection}{hardware}{error}) if $droam->{connection}{hardware}{error};
+ if ($cmanager->{connection}->can('check_hardware')) {
+ my $_w = $cmanager->{in}->wait_message('', N("Configuring device..."));
+ if (!$cmanager->{connection}->check_hardware) {
+ $cmanager->{in}->ask_warn(N("Error"), $cmanager->{connection}{hardware}{error}) if $cmanager->{connection}{hardware}{error};
return;
}
}
}
sub load_settings {
- my ($droam) = @_;
-
- $droam->{connection}->load_interface_settings;
- $droam->{connection}->guess_network_access_settings if $droam->{connection}->can('guess_network_access_settings');
- $droam->{connection}->guess_protocol($droam->{net}) if $droam->{connection}->can('guess_protocol');
- $droam->{connection}->guess_access_settings if $droam->{connection}->can('guess_access_settings');
- $droam->{connection}->guess_address_settings if $droam->{connection}->can('guess_address_settings');
- $droam->{connection}->guess_hostname_settings if $droam->{connection}->can('guess_hostname_settings');
- $droam->{connection}->guess_network_control_settings if $droam->{connection}->can('guess_network_control_settings');
- $droam->{connection}->guess_control_settings;
+ my ($cmanager) = @_;
+
+ $cmanager->{connection}->load_interface_settings;
+ $cmanager->{connection}->guess_network_access_settings if $cmanager->{connection}->can('guess_network_access_settings');
+ $cmanager->{connection}->guess_protocol($cmanager->{net}) if $cmanager->{connection}->can('guess_protocol');
+ $cmanager->{connection}->guess_access_settings if $cmanager->{connection}->can('guess_access_settings');
+ $cmanager->{connection}->guess_address_settings if $cmanager->{connection}->can('guess_address_settings');
+ $cmanager->{connection}->guess_hostname_settings if $cmanager->{connection}->can('guess_hostname_settings');
+ $cmanager->{connection}->guess_network_control_settings if $cmanager->{connection}->can('guess_network_control_settings');
+ $cmanager->{connection}->guess_control_settings;
}
sub configure_connection {
- my ($droam) = @_;
+ my ($cmanager) = @_;
- load_settings($droam);
+ load_settings($cmanager);
- $droam->{in}->ask_from_({
+ $cmanager->{in}->ask_from_({
title => "Network settings",
messages => N("Please enter settings for network")
},
[
- $droam->{connection}->can('get_network_access_settings') ? (
- { label => $droam->{connection}->get_network_access_settings_label, title => 1, advanced => 1 },
- @{$droam->{connection}->get_network_access_settings},
+ $cmanager->{connection}->can('get_network_access_settings') ? (
+ { label => $cmanager->{connection}->get_network_access_settings_label, title => 1, advanced => 1 },
+ @{$cmanager->{connection}->get_network_access_settings},
) : (),
- $droam->{connection}->can('get_protocols') ? (
- @{$droam->{connection}->get_protocol_settings},
+ $cmanager->{connection}->can('get_protocols') ? (
+ @{$cmanager->{connection}->get_protocol_settings},
) : (),
- $droam->{connection}->can('get_access_settings') ? (
- { label => $droam->{connection}->get_access_settings_label, title => 1, advanced => 1 },
- @{$droam->{connection}->get_access_settings}
+ $cmanager->{connection}->can('get_access_settings') ? (
+ { label => $cmanager->{connection}->get_access_settings_label, title => 1, advanced => 1 },
+ @{$cmanager->{connection}->get_access_settings}
) : (),
- $droam->{connection}->can('get_address_settings') ? (
- { label => $droam->{connection}->get_address_settings_label, title => 1, advanced => 1 },
- @{$droam->{connection}->get_address_settings('show_all')}
+ $cmanager->{connection}->can('get_address_settings') ? (
+ { label => $cmanager->{connection}->get_address_settings_label, title => 1, advanced => 1 },
+ @{$cmanager->{connection}->get_address_settings('show_all')}
) : (),
- $droam->{connection}->can('get_network_control_settings') ? (
- @{$droam->{connection}->get_network_control_settings}
+ $cmanager->{connection}->can('get_network_control_settings') ? (
+ @{$cmanager->{connection}->get_network_control_settings}
) : (),
],
) or return;
- $droam->{connection}->install_packages($droam->{in}) if $droam->{connection}->can('install_packages');
- $droam->{connection}->unload_connection if $droam->{connection}->can('unload_connection');
+ $cmanager->{connection}->install_packages($cmanager->{in}) if $cmanager->{connection}->can('install_packages');
+ $cmanager->{connection}->unload_connection if $cmanager->{connection}->can('unload_connection');
my $modules_conf = modules::any_conf->read;
- $droam->{connection}->write_settings($droam->{net}, $modules_conf);
+ $cmanager->{connection}->write_settings($cmanager->{net}, $modules_conf);
$modules_conf->write;
1;
}
sub start_connection {
- my ($droam) = @_;
+ my ($cmanager) = @_;
- $droam->{connection} && $droam->{connection}{network} or return;
- if ($droam->{connection}->selected_network_is_configured || configure_connection($droam)) {
- gtkset_mousecursor_wait($droam->{gui}{w}{window}->window);
- my $_wait = $droam->{in}->wait_message(N("Please wait"), N("Connecting..."));
+ $cmanager->{connection} && $cmanager->{connection}{network} or return;
+ if ($cmanager->{connection}->selected_network_is_configured || configure_connection($cmanager)) {
+ gtkset_mousecursor_wait($cmanager->{gui}{w}{window}->window);
+ my $_wait = $cmanager->{in}->wait_message(N("Please wait"), N("Connecting..."));
#- settings have to be rewritten only if they are impacted by choices from the main window
- if ($droam->{connection}->can('get_networks')) {
- load_settings($droam);
- $droam->{connection}->write_settings($droam->{net});
+ if ($cmanager->{connection}->can('get_networks')) {
+ load_settings($cmanager);
+ $cmanager->{connection}->write_settings($cmanager->{net});
}
- $droam->{connection}->prepare_connection if $droam->{connection}->can('prepare_connection');
- $droam->{connection}->disconnect;
- $droam->{connection}->connect($droam->{in}, $droam->{net});
- gtkset_mousecursor_normal($droam->{gui}{w}{window}->window);
+ $cmanager->{connection}->prepare_connection if $cmanager->{connection}->can('prepare_connection');
+ $cmanager->{connection}->disconnect;
+ $cmanager->{connection}->connect($cmanager->{in}, $cmanager->{net});
+ gtkset_mousecursor_normal($cmanager->{gui}{w}{window}->window);
}
- update_on_network_change($droam);
+ update_on_network_change($cmanager);
}
sub stop_connection {
- my ($droam) = @_;
+ my ($cmanager) = @_;
- gtkset_mousecursor_wait($droam->{gui}{w}{window}->window);
- my $_wait = $droam->{in}->wait_message(N("Please wait"), N("Disconnecting..."));
- $droam->{connection}->disconnect;
- gtkset_mousecursor_normal($droam->{gui}{w}{window}->window);
+ gtkset_mousecursor_wait($cmanager->{gui}{w}{window}->window);
+ my $_wait = $cmanager->{in}->wait_message(N("Please wait"), N("Disconnecting..."));
+ $cmanager->{connection}->disconnect;
+ gtkset_mousecursor_normal($cmanager->{gui}{w}{window}->window);
- update_on_network_change($droam);
+ update_on_network_change($cmanager);
}
sub toggle_would_disconnect {
- my ($droam) = @_;
+ my ($cmanager) = @_;
- my $network = $droam->{connection} && $droam->{connection}->get_selected_network;
- $droam->{connection} && $droam->{connection}->get_status &&
- (!$network || keys(%{$droam->{connection}{networks}}) <= 1 || $network->{current});
+ my $network = $cmanager->{connection} && $cmanager->{connection}->get_selected_network;
+ $cmanager->{connection} && $cmanager->{connection}->get_status &&
+ (!$network || keys(%{$cmanager->{connection}{networks}}) <= 1 || $network->{current});
}
sub toggle_connection {
- my ($droam) = @_;
+ my ($cmanager) = @_;
- if (toggle_would_disconnect($droam)) {
- stop_connection($droam);
+ if (toggle_would_disconnect($cmanager)) {
+ stop_connection($cmanager);
} else {
- start_connection($droam);
+ start_connection($cmanager);
}
}
sub create_networks_list {
- my ($droam) = @_;
+ my ($cmanager) = @_;
- $droam->{gui}{networks_list} = Gtk2::SimpleList->new(
+ $cmanager->{gui}{networks_list} = Gtk2::SimpleList->new(
"AP" => "hidden",
'' => "pixbuf",
N("SSID") => "text",
@@ -178,76 +178,76 @@ sub create_networks_list {
N("Encryption") => "pixbuf",
N("Operating Mode") => "text",
);
- $droam->{gui}{networks_list}->get_selection->set_mode('single');
- $droam->{gui}{networks_list}->get_selection->signal_connect('changed' => sub { select_network($droam) });
+ $cmanager->{gui}{networks_list}->get_selection->set_mode('single');
+ $cmanager->{gui}{networks_list}->get_selection->signal_connect('changed' => sub { select_network($cmanager) });
- $droam->{gui}{networks_list}->signal_connect('query-tooltip' => sub {
+ $cmanager->{gui}{networks_list}->signal_connect('query-tooltip' => sub {
my ($widget, $x, $y, $kbd_tip, $tooltip) = @_;
my ($x, $y, $model, $path, $iter) = $widget->get_tooltip_context($x, $y, $kbd_tip) or return;
my $ap = $model->get($iter, 0);
- my $network = $droam->{connection}{networks}{$ap};
+ my $network = $cmanager->{connection}{networks}{$ap};
$tooltip->set_text("$network->{signal_strength}% $network->{flags}");
$widget->set_tooltip_row($tooltip, $path);
1;
});
- $droam->{gui}{networks_list}->set_has_tooltip(1);
+ $cmanager->{gui}{networks_list}->set_has_tooltip(1);
}
sub update_networks {
- my ($droam) = @_;
- @{$droam->{gui}{networks_list}{data}} = ();
+ my ($cmanager) = @_;
+ @{$cmanager->{gui}{networks_list}{data}} = ();
- if ($droam->{connection}) {
- my $wait = $droam->{connection}->network_scan_is_slow && $droam->{in}->wait_message('', N("Scanning for networks..."));
- $droam->{connection}{networks} = $droam->{connection}->get_networks;
+ if ($cmanager->{connection}) {
+ my $wait = $cmanager->{connection}->network_scan_is_slow && $cmanager->{in}->wait_message('', N("Scanning for networks..."));
+ $cmanager->{connection}{networks} = $cmanager->{connection}->get_networks;
undef $wait;
- $droam->{connection}{network} ||= find { $droam->{connection}{networks}{$_}{current} } keys %{$droam->{connection}{networks}};
+ $cmanager->{connection}{network} ||= find { $cmanager->{connection}{networks}{$_}{current} } keys %{$cmanager->{connection}{networks}};
my $routes = network::tools::get_routes();
- my $interface = $droam->{connection}->get_interface;
+ my $interface = $cmanager->{connection}->get_interface;
my $connected = exists $routes->{$interface}{network};
- my @networks = values %{$droam->{connection}{networks}};
- $droam->{filter_networks} and @networks = $droam->{filter_networks}(@networks);
+ my @networks = values %{$cmanager->{connection}{networks}};
+ $cmanager->{filter_networks} and @networks = $cmanager->{filter_networks}(@networks);
foreach my $network (@networks) {
my $ap = $network->{ap};
- push @{$droam->{gui}{networks_list}{data}}, [
+ push @{$cmanager->{gui}{networks_list}{data}}, [
$ap || $network->{name},
- $network->{current} ? $connected ? $droam->{gui}{pixbufs}{state}{connected} : $droam->{gui}{pixbufs}{state}{refresh} : undef,
- !$network->{essid} && exists $droam->{net}{wireless}{$ap} && $droam->{net}{wireless}{$ap}{WIRELESS_ESSID} || $network->{name},
+ $network->{current} ? $connected ? $cmanager->{gui}{pixbufs}{state}{connected} : $cmanager->{gui}{pixbufs}{state}{refresh} : undef,
+ !$network->{essid} && exists $cmanager->{net}{wireless}{$ap} && $cmanager->{net}{wireless}{$ap}{WIRELESS_ESSID} || $network->{name},
network::signal_strength::get_strength_icon($network),
- $droam->{gui}{pixbufs}{encryption}{$network->{flags} =~ /WPA/i ? 'strong' : $network->{flags} =~ /WEP/i ? 'weak' : 'open'},
+ $cmanager->{gui}{pixbufs}{encryption}{$network->{flags} =~ /WPA/i ? 'strong' : $network->{flags} =~ /WEP/i ? 'weak' : 'open'},
$network->{mode},
];
}
- if ($droam->{connection}{network}) {
- my $index = eval { find_index { $_->[0] eq $droam->{connection}{network} } @{$droam->{gui}{networks_list}{data}} };
- $droam->{gui}{networks_list}->select($index) if defined $index;
+ if ($cmanager->{connection}{network}) {
+ my $index = eval { find_index { $_->[0] eq $cmanager->{connection}{network} } @{$cmanager->{gui}{networks_list}{data}} };
+ $cmanager->{gui}{networks_list}->select($index) if defined $index;
}
}
- update_on_network_change($droam);
+ update_on_network_change($cmanager);
}
sub update_on_network_change {
- my ($droam) = @_;
+ my ($cmanager) = @_;
- if ($droam->{gui}{buttons}{connect_toggle}) {
- $droam->{gui}{buttons}{connect_toggle}->set_label(toggle_would_disconnect($droam) ? N("Disconnect") : N("Connect"));
+ if ($cmanager->{gui}{buttons}{connect_toggle}) {
+ $cmanager->{gui}{buttons}{connect_toggle}->set_label(toggle_would_disconnect($cmanager) ? N("Disconnect") : N("Connect"));
#- always allow to disconnect if connected
- $droam->{gui}{buttons}{connect_toggle}->set_sensitive($droam->{connection} && ($droam->{connection}->get_status || $droam->{connection}{network}));
+ $cmanager->{gui}{buttons}{connect_toggle}->set_sensitive($cmanager->{connection} && ($cmanager->{connection}->get_status || $cmanager->{connection}{network}));
}
- $droam->{gui}{buttons}{connect_start}->set_sensitive($droam->{connection} && (!$droam->{connection}->get_status || $droam->{connection}{network}))
- if $droam->{gui}{buttons}{connect_start};
- $droam->{gui}{buttons}{connect_stop}->set_sensitive($droam->{connection} && $droam->{connection}->get_status)
- if $droam->{gui}{buttons}{connect_stop};
+ $cmanager->{gui}{buttons}{connect_start}->set_sensitive($cmanager->{connection} && (!$cmanager->{connection}->get_status || $cmanager->{connection}{network}))
+ if $cmanager->{gui}{buttons}{connect_start};
+ $cmanager->{gui}{buttons}{connect_stop}->set_sensitive($cmanager->{connection} && $cmanager->{connection}->get_status)
+ if $cmanager->{gui}{buttons}{connect_stop};
#- allow to configure only if a network is selected
- $droam->{gui}{buttons}{configure}->set_sensitive($droam->{connection} && $droam->{connection}{network})
- if $droam->{gui}{buttons}{configure};
+ $cmanager->{gui}{buttons}{configure}->set_sensitive($cmanager->{connection} && $cmanager->{connection}{network})
+ if $cmanager->{gui}{buttons}{configure};
}
1;
diff --git a/lib/network/netcenter.pm b/lib/network/netcenter.pm
index 846110b..a5910f6 100755
--- a/lib/network/netcenter.pm
+++ b/lib/network/netcenter.pm
@@ -33,13 +33,13 @@ sub filter_networks {
sub build_networks_list {
my ($in, $net, $w, $pixbufs, $connection) = @_;
- my $droam = network::connection_manager::create($in, $net, $w, $pixbufs);
- network::connection_manager::create_networks_list($droam);
- $droam->{connection} = $connection;
- $droam->{filter_networks} = sub { filter_networks($connection) };
- network::connection_manager::update_networks($droam);
+ my $cmanager = network::connection_manager::create($in, $net, $w, $pixbufs);
+ network::connection_manager::create_networks_list($cmanager);
+ $cmanager->{connection} = $connection;
+ $cmanager->{filter_networks} = sub { filter_networks($connection) };
+ network::connection_manager::update_networks($cmanager);
- $droam->{gui}{networks_list};
+ $cmanager->{gui}{networks_list};
}
sub gtkset_image {