From 1fa34a312c4f561564d0ac9b659afebefb14ae96 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Fri, 14 Mar 2008 12:02:02 +0000 Subject: - split --internet part in network::drakconnect::global - move common function in network::drakconnect --- bin/drakconnect | 114 +++----------------------------------------------------- 1 file changed, 6 insertions(+), 108 deletions(-) (limited to 'bin/drakconnect') diff --git a/bin/drakconnect b/bin/drakconnect index ca5899e..8ce0420 100755 --- a/bin/drakconnect +++ b/bin/drakconnect @@ -32,6 +32,7 @@ use standalone; #- warning, standalone must be loaded very first, for 'expla use interactive; use common; use run_program; +use network::drakconnect; use network::netconnect; use network::connection::ethernet; use network::tools; @@ -42,7 +43,6 @@ use c; use modules; use network::adsl; use network::connection::isdn; -use network::test; use POSIX ":sys_wait_h"; $ugtk2::wm_icon = "drakconnect"; @@ -65,17 +65,16 @@ local $_ = join '', @ARGV; /--skip-wizard/ and manage(); /--add/ and add_intf(); /--del/ and del_intf(); -/--internet/ and configure_net(); +if (/--internet/) { + require network::drakconnect::global; + network::drakconnect::global::configure_net($in, $net); +} # default is to run wizard add_intf(); my @all_cards = network::connection::ethernet::get_eth_cards($modules_conf); my %names = network::connection::ethernet::get_eth_cards_names(@all_cards); -my $int_state; -my $int_label = Gtk2::WrappedLabel->new($net->{type} eq 'lan' ? N("Gateway:") : N("Interface:")); -my $int_name = Gtk2::Label->new($net->{type} eq 'lan' ? $net->{network}{GATEWAY} : $net->{net_interface}); -my $isconnected = -1; sub manage() { my $p = {}; @@ -538,7 +537,7 @@ sub save { save_notebook($p->{$_}{intf}, $p->{$_}{gui}) or return; $p->{$_}{intf}{save} and $p->{$_}{intf}{save}->(); } - apply(); + network::drakconnect::apply(); system("/etc/rc.d/init.d/network restart"); $dialog->response(0); }); @@ -663,104 +662,3 @@ sub get_intf_ip { } ($ip, $state, $mask); } - -sub apply() { - network::network::configure_network($net, $in, $modules_conf); -} - -sub update_intbutt() { - $int_state->set($isconnected ? N("Connected") : N("Not connected")); -} - -my $net_test; -sub update_network_status() { - unless ($net_test) { - $net_test = network::test->new; - $net_test->start; - } - if ($net_test->is_done) { - $isconnected = $net_test->is_connected; - update_intbutt(); - $net_test->start; - } - 1; -} - -sub configure_net() { - my $dialog = ugtk2->new(N("Internet connection configuration")); - my $exit_dialogsub = sub { Gtk2->main_quit }; - if (!$net->{type}) { - $in->ask_warn( - N("Warning"), - N("You do not have any configured Internet connection. -Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a new network interface (LAN, ISDN, ADSL, ...)"))); - $in->exit; - } - unless ($::isEmbedded) { - $dialog->{rwindow}->set_position('center'); - $dialog->{rwindow}->set_size_request(-1, -1); - $dialog->{rwindow}->set_icon(gtkcreate_pixbuf("drakconnect")); - } - $dialog->{rwindow}->signal_connect(delete_event => $exit_dialogsub); - - my $param_vbox = Gtk2::VBox->new(0,0); - my $i = 0; - - my @conf_data = ( - [ N("Host name (optional)"), \$net->{network}{HOSTNAME} ], - [ N("First DNS Server (optional)"), \$net->{resolv}{dnsServer} ], - [ N("Second DNS Server (optional)"), \$net->{resolv}{dnsServer2} ], - [ N("Third DNS server (optional)"), \$net->{resolv}{dnsServer3} ], - ); - my @infos; - gtkpack($param_vbox, - create_packtable({}, - map { - my $c; - if (defined $_->[2]) { - $c = Gtk2::Combo->new; - $c->set_popdown_strings(@{$_->[2]}); - $infos[2*$i+1] = $c->entry; - } else { - $c = $infos[2*$i+1] = Gtk2::Entry->new; - } - $infos[2*$i+1]->set_text(${$_->[1]}); - $i++; - [ Gtk2::WrappedLabel->new($_->[0]), $c ]; - } @conf_data - ) - ); - - $dialog->{rwindow}->add(gtkpack_(Gtk2::VBox->new, - 0, Gtk2::Label->new(N("Internet Connection Configuration")), - 1, gtkadd(gtkcreate_frame(N("Internet access")), - gtkset_border_width(create_packtable({ col_spacings => 5, row_spacings => 5, homogenous => 1 }, - [ Gtk2::WrappedLabel->new(N("Connection type: ")), - Gtk2::WrappedLabel->new(translate($net->{type})) ], - [ $int_label, $int_name ], - [ Gtk2::WrappedLabel->new(N("Status:")), - $int_state = Gtk2::WrappedLabel->new(N("Testing your connection...")) ] - ), - 5), - ), - 1, gtkadd(gtkcreate_frame(N("Parameters")), gtkset_border_width($param_vbox, 5)), - 0, gtkpack(create_hbox('edge'), - gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => $exit_dialogsub), - gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub { - foreach my $i (0..$#conf_data) { - ${$conf_data[$i][1]} = $infos[2*$i+1]->get_text; - } - apply(); - $exit_dialogsub->(); - }), - ), - ), - ); - - $dialog->{rwindow}->show_all; - update_network_status(); - Glib::Timeout->add(2000, \&update_network_status); - $dialog->main; - ugtk2->exit(0); -} - -- cgit v1.2.1