diff options
Diffstat (limited to 'perl-install')
-rwxr-xr-x | perl-install/standalone/drakconnect | 290 |
1 files changed, 104 insertions, 186 deletions
diff --git a/perl-install/standalone/drakconnect b/perl-install/standalone/drakconnect index 4e4590f5a..521c30b8e 100755 --- a/perl-install/standalone/drakconnect +++ b/perl-install/standalone/drakconnect @@ -51,7 +51,6 @@ my @conx_type = ('modem', 'isdn_internal', 'isdn_external', 'adsl', 'cable', 'la my $in = 'interactive'->vnew('su'); !$::isEmbedded and $in->isa('interactive::gtk'); $::Wizard_pix_up = "wiz_drakconnect.png"; -$::Wizard_title = N("Network & Internet Configuration"); MDK::Common::Globals::init( in => $in, @@ -61,13 +60,28 @@ MDK::Common::Globals::init( connect_prog => "/etc/sysconfig/network-scripts/net_cnx_pg" ); -($::isEmbedded || /--skip-wizard/) && ref($in) =~ /gtk/ or goto dd; -require ugtk2; -ugtk2->import(qw(:create :dialogs :helpers :wrappers)); +/--skip-wizard/ and goto manage; +/--add/ and add_intf(); +/--del/ and del_intf(); +/--internet/ and do { + init(); + configure_net($netcnx, $netc, $intf); +}; + +# default is to run wizard +add_intf(); + my @all_cards; -reread_net_conf(); +sub init { + require ugtk2; + ugtk2->import(qw(:create :dialogs :helpers :wrappers)); + reread_net_conf(); +} + +manage: +init(); my $window1 = ugtk2->new('drakconnect'); $window1->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) }); unless ($::isEmbedded) { @@ -77,64 +91,12 @@ unless ($::isEmbedded) { } $window1->{rwindow}->set_border_width(10); -my ($lan_button, $wiz_button, $int_button, $host_button, $button_apply); -my @profiles; - -my $button_del = Gtk2::Button->new(N("Del profile...")); -my $profile_combo = gtksignal_connect(Gtk2::OptionMenu->new, changed => sub { - my ($combo) = @_; - return if $::ignore_profile_change; - my $selected_profile = $combo->get_text; - return if $selected_profile eq $netcnx->{PROFILE}; - set_profiles($selected_profile) if $combo->window; # is realized?; - }); - -# update combo profiles -sub update_profiles() { - @profiles = network::netconnect::get_profiles(); - $button_del->set_sensitive(@profiles > 1); - local $::ignore_profile_change = 1; - $profile_combo->set_popdown_strings(@profiles); - $profile_combo->set_text($netcnx->{PROFILE}); -} +my $warning_label1; -# Change current profile -sub set_profiles { - my ($new_profile) = @_; - $netcnx->{PROFILE} = $new_profile; - network::netconnect::set_profile($netcnx); - network::netconnect::load_conf($netcnx, $netc, $intf); - update_profiles(); - update(); - $button_apply->set_sensitive(1); -} +my ($lan_button, $wiz_button, $int_button, $host_button, $button_apply); -@profiles = update_profiles(); - -$button_del->signal_connect(clicked => sub { - my $dialog = _create_dialog(N("Delete profile"), { stock => 'gtk-dialog-warning' }); - gtkpack($dialog->vbox, - Gtk2::Label->new(N("Profile to delete:")), - my $combo_dialog = Gtk2::OptionMenu->new, - ); - $combo_dialog->set_popdown_strings(grep { ! /default/ } network::netconnect::get_profiles()); - gtkpack($dialog->action_area, - gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => sub { $dialog->destroy }), - gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub { - my $profile2delete = $combo_dialog->entry->get_text; - $dialog->destroy; - Gtk2->main_quit; - network::netconnect::del_profile($profile2delete); - $profile2delete eq $netcnx->{PROFILE} ? set_profiles("default") : update_profiles(); - }), - ); - $dialog->show_all; - $dialog->run; - #apply(); ## BUG? - }); my $hostname = chomp_(`hostname`); -my $type_label = Gtk2::Label->new($netcnx->{type}); my $int_label = Gtk2::Label->new($netcnx->{type} eq 'lan' ? N("Gateway:") : N("Interface:")); my $interface_name = Gtk2::Label->new($netcnx->{type} eq 'lan' ? $netc->{GATEWAY} : $netcnx->{NET_INTERFACE}); my $isconnected = -1; @@ -151,7 +113,6 @@ $int_connect->signal_connect(clicked => sub { } else { disconnect_backend(); } - update2(); }); my $tree_model = Gtk2::TreeStore->new("Gtk2::Gdk::Pixbuf", map { "Glib::String" } 2..6); @@ -161,12 +122,12 @@ each_index { $list->append_column(my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i + 1)); $col->set_sort_column_id($::i); } (N("Interface"), N("IP address"), N("Protocol"), N("Driver"), N("State")); -my $wizard_pid; + $list->signal_connect(button_press_event => sub { my (undef, $event) = @_; my (undef, $iter) = $list->get_selection->get_selected; return unless $iter; - configure_lan() if $event->type eq '2button-press' && !$wizard_pid; + configure_lan() if $event->type eq '2button-press'; }); @@ -177,39 +138,11 @@ my ($label_host, $int_state, $button_expert); $window1->{window}->add( gtkpack_(Gtk2::VBox->new(0,10), - 0, gtkpack_(Gtk2::HBox->new(0,0), - 0, Gtk2::Label->new(N("Profile: ")), - 0, $profile_combo, - 0, $button_del, - 0, gtksignal_connect(Gtk2::Button->new(N("New profile...")), clicked => sub { - my $dialog = _create_dialog(N("New profile..."), { small => 1 }); - my $entry_dialog = Gtk2::Entry->new; - gtkpack($dialog->vbox, - Gtk2::Label->new(N("Name of the profile to create (the new profile is created as a copy of the current one) :")), - $entry_dialog, - ); - gtkpack($dialog->action_area, - gtksignal_connect(Gtk2::Button->new(N("Cancel")), - clicked => sub { $dialog->destroy }), - gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub { - #warn if already existing - my $prof = $entry_dialog->get_text; - $prof =~ s/ /_/g; - network::netconnect::add_profile($netcnx, $prof); - update_profiles(); - $dialog->destroy; - }), - ); - $dialog->show_all; - $dialog->run; - }), - ), 0, gtkpack(Gtk2::HBox->new, Gtk2::Label->new(N("Hostname: ")), $label_host = Gtk2::Label->new($hostname), $host_button = gtksignal_connect(Gtk2::Button->new(N("Configure hostname...")), clicked => sub { - sensitive_buttons(0); local ($::isWizard, $::Wizard_finished) = (1, 1); eval { # For wizcancel configureNetworkNet($in, $netc, $intf, map { $_->[0] } @all_cards); @@ -219,27 +152,9 @@ $window1->{window}->add( if ($@ =~ /wizcancel/) {} $::WizardWindow->destroy; undef $::WizardWindow; - sensitive_buttons(1); } ), ), - 0, gtkadd(Gtk2::Frame->new(N("Internet access")), - gtkpack_(gtkset_border_width(Gtk2::VBox->new(0,0), 5), - 1, gtkset_border_width(create_packtable({ col_spacings => 5, row_spacings => 5 }, - [ Gtk2::Label->new(N("Type:")), $type_label ], - [ $int_label, $interface_name ], - [ Gtk2::Label->new(N("Status:")), - $int_state = Gtk2::Label->new(N("Testing your connection...")) ] - ), - 5), - 0, my $warning_label1 = Gtk2::Label->new(""), - 0, gtkpack(Gtk2::HButtonBox->new, - $int_button = gtksignal_connect(Gtk2::Button->new(N("Configure Internet Access...")), - clicked => sub { configure_net('', $netcnx, $netc, $intf) }), - $int_connect, - ), - ) - ), 1, gtkadd(Gtk2::Frame->new(N("LAN configuration")), gtkpack_(gtkset_border_width(Gtk2::VBox->new(0,0), 5), 0, $list, @@ -250,19 +165,6 @@ $window1->{window}->add( ), ) ), - 0, gtkadd(Gtk2::HButtonBox->new, - $wiz_button = gtksignal_connect(Gtk2::Button->new(N("Launch the wizard")), - clicked => sub { - $wizard_pid = fork(); - if (defined $wizard_pid) { - # immediate exit, else forked gtk+ object destructors will badly catch up parent drakconnect - !$wizard_pid and do { exec("drakconnect") or POSIX::_exit(1) }; - sensitive_buttons(0); - } else { - err_dialog(N("Error"), N("Unable to fork: %s", "$!")); - } - }), - ), 0, Gtk2::HSeparator->new, 0, gtkpack(Gtk2::HButtonBox->new, gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => sub { @@ -289,36 +191,53 @@ $window1->{window}->add( -sub sensitive_buttons { - my ($state) = @_; - $_->set_sensitive($state) foreach $host_button, $lan_button, $wiz_button, $int_button; -} - - -$SIG{CHLD} = sub { - my $child = waitpid(-1, POSIX::WNOHANG); - # when the wizard has exiter, reload everything to catch its changes - return if !($wizard_pid && $child eq $wizard_pid); - undef $wizard_pid; - sensitive_buttons(1); - $netcnx = {}; $netc = {}; $intf = {}; - reread_net_conf(); - update_profiles(); - update(); -}; - - $window1->{rwindow}->show_all; gtkflush(); -my $tag = Glib::Timeout->add(4000, \&update2); $window1->main; ugtk2->exit(0); -dd: -$::isWizard = 1; -network::netconnect::load_conf($netcnx, $netc, $intf); -network::netconnect::main('', $netcnx, $in); -$in->exit(0); +sub add_intf { + $::Wizard_title = N("Network & Internet Configuration"); + $::isWizard = 1; + network::netconnect::load_conf($netcnx, $netc, $intf); + network::netconnect::main('', $netcnx, $in); + $in->exit(0); +} + +sub del_intf { + $::Wizard_title = N("Remove a network interface"); + $::isWizard = 1; + $::Wizard_no_previous = 1; + my $intf; + + $in->ask_from(N("Network Configuration"), + N("Select the network interface to remove:"), + [ { label => N("Net Device"), val => \$intf, list => [ detect_devices::getNet() ], allow_empty_list => 1 } ]); + + eval { + modules::mergein_conf('/etc/modules.conf'); + modules::remove_alias($intf); + modules::write_conf(); + rm_rf("/etc/sysconfig/network-scripts/ifcfg-$intf"); + }; + my $faillure = $@; + $::Wizard_finished = 1; + eval { + $in->ask_okcancel(N("Network Configuration"), ($faillure ? + N("An error occured while deleting the \"%s\" network interface:\n\n%s", + $intf, $faillure) : + N("Congratulations, the \"%s\" network interface has been succesfully deleted", $intf) + ), + 1); + }; + my $err = $@; + if ($err =~ /wizcancel/) { + $in->exit(0); + } else { + die $err; + } +} + sub get_intf_ip { my ($interface) = @_; @@ -385,7 +304,6 @@ my $to_update; sub update() { my $h = chomp_(`hostname`); $label_host->set_label($h); - $type_label->set($netcnx->{type}); $int_label->set($netcnx->{type} eq 'lan' ? N("Gateway:") : N("Interface:")); $interface_name->set($netcnx->{type} eq 'lan' ? $netc->{GATEWAY} : $netcnx->{NET_INTERFACE}); update_list(); @@ -427,7 +345,6 @@ sub get_intf_status { } sub configure_lan() { - sensitive_buttons(0); my $window = _create_dialog(N("LAN configuration")); my @card_tab; @@ -504,7 +421,7 @@ Configure them first by clicking on 'Configure'"))); update(); }); } else { - $widget_temp = N("This interface has not been configured yet.\nLaunch the configuration wizard in the main window"); + $widget_temp = N("This interface has not been configured yet.\nRun the \"Add an interface\" assistant from the Mandrake Control Center"); } $vbox_local->pack_start(gtkpack__(Gtk2::HBox->new(0,0), $widget_temp @@ -515,7 +432,6 @@ Configure them first by clicking on 'Configure'"))); } my $exit_dialogsub = sub { - sensitive_buttons(1); $window->destroy; Gtk2->main_quit; }; @@ -553,14 +469,9 @@ Configure them first by clicking on 'Configure'"))); sub configure_net { - my ($_prefix, $netcnx, $netc, $_intf) = @_; - sensitive_buttons(0); - my $dialog; - my $exit_dialogsub = sub { - sensitive_buttons(1); - $dialog->destroy; - Gtk2->main_quit; - }; + my ($netcnx, $netc, $_intf) = @_; + my $dialog = ugtk2->new('drakconnect'); + my $exit_dialogsub = sub { Gtk2->main_quit }; if (!$netcnx->{type}) { $dialog = _create_dialog(N("LAN configuration")); $dialog->vbox->add(Gtk2::Label->new(N("You don't have an Internet connection. @@ -574,9 +485,12 @@ Create one first by clicking on 'Configure'"))); } my $cnx = {}; $cnx = $netcnx->{$netcnx->{type}}; - $dialog = _create_dialog(N("Internet connection configuration")); - $dialog->signal_connect(delete_event => $exit_dialogsub); - $dialog->set_border_width(10); + unless ($::isEmbedded) { + $dialog->{rwindow}->set_position('center'); + $dialog->{rwindow}->set_title(N("Internet connection configuration")); + $dialog->{rwindow}->set_size_request(-1, -1); + } + $dialog->{rwindow}->signal_connect(delete_event => $exit_dialogsub); my $param_vbox = Gtk2::VBox->new(0,0); my $i = 0; @@ -657,32 +571,36 @@ Create one first by clicking on 'Configure'"))); $i++; } - gtkpack($dialog->vbox, - Gtk2::Label->new(N("Internet Connection Configuration")), - Gtk2::HSeparator->new, - create_packtable({ col_spacings => 5, row_spacings => 5, homogenous => 1 }, - [ Gtk2::Label->new(N("Profile: ")), - Gtk2::Label->new(translate($netcnx->{PROFILE})) ], - [ Gtk2::Label->new(N("Connection type: ")), - Gtk2::Label->new(translate($netcnx->{type})) ], - ), - Gtk2::HSeparator->new, - gtkadd(Gtk2::Frame->new(N("Parameters")), $param_vbox), - ); - gtkpack($dialog->action_area, - gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => $exit_dialogsub), - gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub { - each_index { - ${$conf_data[$::i][1]} = $infos[2*$::i+1]->get_text if $_; - } @mask; - update(); - $button_apply->set_sensitive(1); - $exit_dialogsub->(); - }), - ); + $dialog->{rwindow}->add(gtkpack_(Gtk2::VBox->new, + 0, Gtk2::Label->new(N("Internet Connection Configuration")), + 1, gtkadd(Gtk2::Frame->new(N("Internet access")), + gtkset_border_width(create_packtable({ col_spacings => 5, row_spacings => 5, homogenous => 1 }, + [ Gtk2::Label->new(N("Connection type: ")), + Gtk2::Label->new(translate($netcnx->{type})) ], + [ $int_label, $interface_name ], + [ Gtk2::Label->new(N("Status:")), + $int_state = Gtk2::Label->new(N("Testing your connection...")) ] + ), + 5), + ), + 1, gtkadd(Gtk2::Frame->new(N("Parameters")), $param_vbox), + 0, gtkpack(Gtk2::HBox->new, + gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => $exit_dialogsub), + gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub { + each_index { + ${$conf_data[$::i][1]} = $infos[2*$::i+1]->get_text if $_; + } @mask; + update(); + $button_apply->set_sensitive(1); + $exit_dialogsub->(); + }), + ), + ), + ); - $dialog->show_all; - $dialog->run; + $dialog->{rwindow}->show_all; + $dialog->main; + ugtk2->exit(0); } sub reread_net_conf() { |