summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-08-03 12:30:20 +0000
committerOlivier Blin <oblin@mandriva.com>2007-08-03 12:30:20 +0000
commitfdb3520061c93916b1fed3963f2ab8ce256da790 (patch)
treea8d25317f4983d1e9ee0218f5c881ce2871da21d /bin
parent26b63d075087b69b7df25f33ab96ec8d1ec11053 (diff)
downloaddrakx-net-fdb3520061c93916b1fed3963f2ab8ce256da790.tar
drakx-net-fdb3520061c93916b1fed3963f2ab8ce256da790.tar.gz
drakx-net-fdb3520061c93916b1fed3963f2ab8ce256da790.tar.bz2
drakx-net-fdb3520061c93916b1fed3963f2ab8ce256da790.tar.xz
drakx-net-fdb3520061c93916b1fed3963f2ab8ce256da790.zip
move most initialization code in a main sub
Diffstat (limited to 'bin')
-rwxr-xr-xbin/drakroam43
1 files changed, 24 insertions, 19 deletions
diff --git a/bin/drakroam b/bin/drakroam
index fe35d80..df827af 100755
--- a/bin/drakroam
+++ b/bin/drakroam
@@ -333,28 +333,33 @@ sub build_drakroam_gui {
$droam->{gui}{networks_list}->get_selection->signal_connect('changed' => \&select_network);
}
-my %args = map { if_(/^--(\w+)=(.*)$/ && member($1, qw(ap interface)), $1 => $2) } @ARGV;
+sub main {
+ my ($in, $net, $dbus, $o_interface, $o_ap) = @_;
-my $droam = {};
-$droam->{in} = 'interactive'->vnew('su');
-$droam->{net} = {};
-network::network::read_net_conf($droam->{net});
-my $dbus;
-eval { $dbus = dbus_object::system_bus() };
+ my $droam = { in => $in, net => $net };
+ build_drakroam_gui($droam, $dbus);
-build_drakroam_gui($droam, $dbus);
+ my @connection_types = qw(network::connection::wireless network::connection::cellular_card);
+ @{$droam->{all_connections}} = map { $_->get_connections(automatic_only => 1) } @connection_types;
+ $droam->{connection} = $o_interface && find { $_->get_interface eq $o_interface } @{$droam->{all_connections}};
+ $droam->{connection} ||= find { !$_->network_scan_is_slow } @{$droam->{all_connections}};
+ update_connections_list($droam);
+ update_on_connection_change($droam);
-my @connection_types = qw(network::connection::wireless network::connection::cellular_card);
-@{$droam->{all_connections}} = map { $_->get_connections(automatic_only => 1) } @connection_types;
-$droam->{connection} = $args{interface} && find { $_->get_interface eq $args{interface} } @{$droam->{all_connections}};
-$droam->{connection} ||= find { !$_->network_scan_is_slow } @{$droam->{all_connections}};
-update_connections_list($droam);
-update_on_connection_change($droam);
+ if ($o_ap && $droam->{connection}) {
+ $droam->{connection}{network} = $o_ap;
+ $droam->{gui}{w}->show;
+ connect_to_network($droam);
+ }
-if ($args{ap} && $droam->{connection}) {
- $droam->{connection}{network} = $args{ap};
- $droam->{gui}{w}->show;
- connect_to_network($droam);
+ $droam->{gui}{w}->main;
}
-$droam->{gui}{w}->main;
+my %args = map { if_(/^--(\w+)=(.*)$/ && member($1, qw(ap interface)), $1 => $2) } @ARGV;
+
+my $in = 'interactive'->vnew('su');
+my $net = {};
+network::network::read_net_conf($net);
+my $dbus;
+eval { $dbus = dbus_object::system_bus() };
+main($in, $net, $dbus, $args{interface}, $args{ap});