summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakconnect
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/drakconnect')
-rwxr-xr-xperl-install/standalone/drakconnect1109
1 files changed, 486 insertions, 623 deletions
diff --git a/perl-install/standalone/drakconnect b/perl-install/standalone/drakconnect
index 98ef16cb3..d428bcae6 100755
--- a/perl-install/standalone/drakconnect
+++ b/perl-install/standalone/drakconnect
@@ -1,11 +1,8 @@
#!/usr/bin/perl
-# DrakConnect $Id$
+# DrakConnect
-# Copyright (C) 1999-2003 MandrakeSoft
-# Damien "Dam's" Krotkine
-# Damien "poulpy" Chaumette
-# Thierry Vignaud <tvignaud@mandrakesoft.com>
+# Copyright (C) 1999-2002 MandrakeSoft (damien@mandrakesoft.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,10 +18,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-use strict;
-use warnings;
-use diagnostics;
-
use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
@@ -34,28 +27,28 @@ use common;
use network::netconnect;
use network::ethernet;
use network::tools;
-use network::modem;
-use network::network;
+use network;
use c;
-use modules;
+use any;
use network::isdn;
use network::adsl;
-use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_prog $connect_file);
-use POSIX ":sys_wait_h";
+use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_prog $connect_file $disconnect_file);
my $xpm_path = "/usr/share/libDrakX/pixmaps";
+local $_ = join '', @ARGV;
+$::isWizard = /--wizard/;
-my ($netcnx, $netc, $intf) = ({}, {}, {});
+my $netcnx = {};
+my $netc = {};
+my $intf = {};
my @conx_type = ('modem', 'isdn_internal', 'isdn_external', 'adsl', 'cable', 'lan');
-my $in = 'interactive'->vnew('su');
-if ($in->isa('interactive::gtk')) {
- require ugtk2;
- ugtk2->import(qw(:create :dialogs :helpers :wrappers));
-}
-reread_net_conf();
-$::Wizard_title = N("Network & Internet Configuration");
+#$::wizard_xpm = "/usr/share/pixmaps/internet.xpm";
+
+my $in = 'interactive'->vnew('su', 'network');
+!$::isEmbedded && $in->isa('interactive::gtk') and $::isWizard = 1;
$::Wizard_pix_up = "wiz_drakconnect.png";
+$::Wizard_title = "Network & Internet Configuration";
MDK::Common::Globals::init(
in => $in,
@@ -65,448 +58,321 @@ MDK::Common::Globals::init(
connect_prog => "/etc/sysconfig/network-scripts/net_cnx_pg"
);
-local $_ = join '', @ARGV;
-/--skip-wizard/ and manage($netc, $netcnx, $intf);
-/--add/ and add_intf();
-/--del/ and del_intf();
-if (/--install/) {
- $::isInstall = 1;
- add_intf()
-}
-/--internet/ and configure_net($netcnx, $netc, $intf);
-
-# default is to run wizard
-add_intf();
-
-my @all_cards;
+$::isEmbedded && ref($in) =~ /gtk/ or goto dd;
+require ugtk2;
+import ugtk2 qw(:helpers :wrappers);
+my $expert_mode = 0;
+network::netconnect::read_net_conf('', $netcnx, $netc);
+any::load_category_no_message('net', undef);
+my @all_cards = network::ethernet::conf_network_card_backend($netc, $intf, undef, undef, undef, undef);
+network::netconnect::load_conf($netcnx, $netc, $intf);
my $window1 = ugtk2->new('drakconnect');
$window1->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
unless ($::isEmbedded) {
$window1->{rwindow}->set_position('center');
- $window1->{rwindow}->set_title(N("Network configuration (%d adapters)", scalar @all_cards));
- $window1->{rwindow}->set_size_request(-1, -1);
+ $window1->{rwindow}->set_title(N("Network configuration (%d adapters)", @all_cards));
+ $window1->{rwindow}->set_size_request(500, 400);
}
$window1->{rwindow}->set_border_width(10);
-
-my $warning_label1;
-
-my ($lan_button, $wiz_button, $int_button, $host_button, $button_apply);
-
-
+my $vbox1 = new Gtk2::VBox(0,10);
+$window1->{window}->add($vbox1);
+my $hbox1 = new Gtk2::HBox(0,0);
+$vbox1->pack_start($hbox1,0,0,0);
+$hbox1->pack_start(new Gtk2::Label(N("Profile: ")),0,0,0);
+
+my $combo1 = new Gtk2::Combo;
+$combo1->set_popdown_strings(network::netconnect::get_profiles());
+my $old_profile = $netcnx->{PROFILE};
+$combo1->entry->set_text($netcnx->{PROFILE} ? $netcnx->{PROFILE} : "default");
+$combo1->entry->set_editable(0);
+$hbox1->pack_start($combo1,0,0,0);
+my $button_del = new Gtk2::Button(N("Del profile..."));
+$button_del->signal_connect(clicked => sub {
+ my $dialog = new_dialog();
+ $dialog->vbox->pack_start(new Gtk2::Label(N("Profile to delete:")),1,1,0);
+ my $combo_dialog = new Gtk2::Combo;
+ $combo_dialog->set_popdown_strings(grep { ! /default/ } network::netconnect::get_profiles());
+ $combo_dialog->entry->set_editable(0);
+ $dialog->vbox->pack_start($combo_dialog,1,1,0);
+ my $bbox_dialog = new Gtk2::HButtonBox;
+ $dialog->action_area->add($bbox_dialog);
+ $bbox_dialog->set_layout('end');
+ my $button_ok = new Gtk2::Button(N("OK"));
+ $button_ok->signal_connect(clicked => sub {
+ network::netconnect::del_profile($netcnx, $combo_dialog->entry->get_text());
+ $netcnx->{PROFILE} eq $combo_dialog->entry->get_text() and $netcnx->{PROFILE} = "default";
+ Gtk2->main_quit();
+ });
+ $bbox_dialog->add($button_ok);
+ my $button_cancel = new Gtk2::Button(N("Cancel"));
+ $button_cancel->signal_connect(clicked => sub { Gtk2->main_quit() });
+ $bbox_dialog->add($button_cancel);
+ $dialog->show_all;
+ $dialog->set_modal(1);
+ Gtk2->main();
+ $dialog->destroy;
+ $combo1->entry->set_text(-e "/etc/sysconfig/network-scripts/drakconnect_conf." . $combo1->entry->get_text ? $combo1->entry->get_text : "default");
+ $combo1->set_popdown_strings(network::netconnect::get_profiles());
+ apply();
+ });
+$hbox1->pack_start($button_del,0,0,5);
+$button_del->set_sensitive(network::netconnect::get_profiles() > 1);
+my $button_new = new Gtk2::Button(N("New profile..."));
+$button_new->signal_connect(clicked => sub {
+ my $dialog = new_dialog();
+ $dialog->vbox->pack_start(new Gtk2::Label(N("Name of the profile to create (the new profile is created as a copy of the current one) :")),1,1,0);
+ my $entry_dialog = new Gtk2::Entry;
+ $dialog->vbox->pack_start($entry_dialog,1,1,0);
+ my $bbox_dialog = new Gtk2::HButtonBox;
+ $dialog->action_area->add($bbox_dialog);
+ $bbox_dialog->set_layout('end');
+ my $button_ok = new Gtk2::Button(N("OK"));
+ $button_ok->signal_connect(clicked => sub {
+ network::netconnect::add_profile($netcnx, $entry_dialog->get_text());
+ $netcnx->{PROFILE} = $entry_dialog->get_text();
+ Gtk2->main_quit();
+ });
+ $bbox_dialog->add($button_ok);
+ my $button_cancel = new Gtk2::Button(N("Cancel"));
+ $button_cancel->signal_connect(clicked => sub { Gtk2->main_quit() });
+ $bbox_dialog->add($button_cancel);
+ $dialog->show_all;
+ $dialog->set_modal(1);
+ Gtk2->main();
+ $dialog->destroy;
+ $combo1->entry->set_text(-e "/etc/sysconfig/network-scripts/drakconnect_conf." . $netcnx->{PROFILE} ? $netcnx->{PROFILE} : "default");
+ $combo1->set_popdown_strings(network::netconnect::get_profiles());
+});
+$hbox1->pack_start($button_new,0,0,5);
+my $hbox2 = new Gtk2::HBox(0,0);
+$vbox1->pack_start($hbox2,0,0,0);
+$hbox2->pack_start(new Gtk2::Label(N("Hostname: ")),0,0,0);
my $hostname = chomp_(`hostname`);
-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 $label_host = new Gtk2::Label($hostname);
+$hbox2->pack_start($label_host,0,0,0);
+
+#$vbox1->pack_start(new Gtk2::HSeparator,1,1,5);
+
+my $frame1 = new Gtk2::Frame(N("Internet access"));
+$vbox1->pack_start($frame1,1,1,0);
+my $vbox_frame1 = new Gtk2::VBox(0,0);
+$vbox_frame1->set_border_width(5);
+$frame1->add($vbox_frame1);
+my $table1 = new Gtk2::Table(3,3, 0);
+$table1->set_border_width(5);
+$table1->set_row_spacings(5);
+$table1->set_col_spacings(5);
+#$table1->set_border_width(10);
+$vbox_frame1->pack_start($table1,1,1,0);
+#attach(table, child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)
+#$table->attach($button[0], 0, 1, 0, 1, {expand=>1,fill=>1}, {expand=>1,fill=>1},0,0);
+$table1->attach(new Gtk2::Label(N("Type:")), 0, 1, 0, 1, 'fill', 'fill',0,0);
+my $label4 = new Gtk2::Label($netcnx->{type});
+$table1->attach($label4, 1, 2, 0, 1, 'fill', 'fill',0,0);
+my $label5 = new Gtk2::Label($netcnx->{type} eq 'lan' ? N("Gateway:") : N("Interface:"));
+$table1->attach($label5, 0, 1, 1, 2, 'fill', 'fill',0,0);
+my $label6 = new Gtk2::Label($netcnx->{type} eq 'lan' ? $netc->{GATEWAY} : $netcnx->{NET_INTERFACE});
+$table1->attach($label6, 1, 2, 1, 2, 'fill', 'fill',0,0);
my $isconnected = -1;
-
-my $int_connect = Gtk2::Button->new(N("Wait please"));
-$int_connect->set_sensitive(0);
-$int_connect->signal_connect(clicked => sub {
- if (!$isconnected) {
- if (cat_($connect_prog) =~ m|/usr/bin/kppp| && -e '/usr/bin/kppp') {
- run_program::rooted($prefix, "/usr/bin/kppp &");
- } else {
- connect_backend();
- }
- } else {
- disconnect_backend();
- }
-});
-
-my $tree_model = Gtk2::TreeStore->new("Gtk2::Gdk::Pixbuf", map { "Glib::String" } 2..6);
+#-sub connected_local {
+#- print "in connected local\n";
+#- my $w = $in->wait_message('', N("Testing your connection..."), 1);
+#- gtkflush();
+#- $isconnected = connected();
+#-}
+my $label7 = new Gtk2::Label(N("Status:"));
+$table1->attach($label7, 0, 1, 2, 3, 'fill', 'fill',0,0);
+my $label8 = new Gtk2::Label(N("Testing your connection..."));
+$table1->attach($label8, 1, 2, 2, 3, 'fill', 'fill',0,0);
+
+my $warning_label1 = new Gtk2::Label("");
+$vbox_frame1->pack_start($warning_label1,0,0,0);
+my $button2 = new Gtk2::Button(N("Wait please"));
+$button2->set_sensitive(0);
+$button2->signal_connect(clicked => sub {
+ if (!$isconnected && cat_($connect_prog) =~ m|/usr/bin/kppp| && -e '/usr/bin/kppp') {
+ run_program::rooted($prefix, "/usr/bin/kppp &");
+ } elsif (!$isconnected) {
+ connect_backend();
+ } else {
+ disconnect_backend();
+ }
+ update2();
+ });
+
+$table1->attach($button2, 2, 3, 2, 3, 'fill', 'fill',0,0);
+
+#$table1->attach($button1, 2, 3, 1, 2, 'fill', 'fill',0,0);
+
+my $hbox_frame1_button = new Gtk2::HBox(0,0);
+my $button1 = new Gtk2::Button(N("Configure Internet Access..."));
+$button1->signal_connect(clicked => [ \&configure_net, '', $netcnx, $netc, $intf ]);
+$hbox_frame1_button->pack_start($button1, 0, 0, 0);
+$vbox_frame1->pack_start($hbox_frame1_button,0,0,0);
+
+#$vbox1->pack_start(new Gtk2::HSeparator,1,1,5);
+
+my $frame2 = new Gtk2::Frame(N("LAN configuration"));
+$vbox1->pack_start($frame2,1,1,0);
+my $vbox2 = new Gtk2::VBox(0,0);
+$vbox2->set_border_width(5);
+$frame2->add($vbox2);
+
+my $tree_model = Gtk2::TreeStore->new(Gtk2::GType->OBJECT, map { Gtk2::GType->STRING } 2..6);
my $list = Gtk2::TreeView->new_with_model($tree_model);
$list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererPixbuf->new, 'pixbuf' => 0));
-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"));
-
-$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';
- });
-
-update_list();
-
-my ($label_host, $int_state, $button_expert);
-
-
-$window1->{window}->add(
- gtkpack_(Gtk2::VBox->new(0,10),
- 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 {
- local ($::isWizard, $::Wizard_finished) = (1, 1);
- eval { # For wizcancel
- configureNetworkNet($in, $netc, $intf, map { $_->[0] } @all_cards);
- $button_apply->set_sensitive(1);
- update();
- };
- if ($@ =~ /wizcancel/) {}
- $::WizardWindow->destroy;
- undef $::WizardWindow;
- }
- ),
- ),
- 1, gtkadd(Gtk2::Frame->new(N("LAN configuration")),
- gtkpack_(gtkset_border_width(Gtk2::VBox->new(0,0), 5),
- 0, $list,
- 0, Gtk2::HBox->new(0,0),
- 0, gtkpack_(Gtk2::HBox->new(0, 0),
- 0, $lan_button = gtksignal_connect(Gtk2::Button->new(N("Configure Local Area Network...")),
- clicked => \&configure_lan),
- ),
- )
- ),
- 0, gtkpack(Gtk2::HButtonBox->new,
- gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => sub {
- exec("drakhelp --id internet-connection") unless fork() }),
- $button_apply = gtksignal_connect(gtkset_sensitive(Gtk2::Button->new(N("Apply")), 0),
- clicked => \&apply),
- gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&quit_global),
- gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub {
- if ($button_apply->get('sensitive')) {
- my $dialog = _create_dialog(N("Please wait"));
- gtkpack($dialog->vbox,
- Gtk2::Label->new(N("Please Wait... Applying the configuration")));
- $dialog->show_all;
- gtkflush();
- apply();
- $dialog->destroy;
- }
- update();
- quit_global();
- }),
- ),
- ),
- );
-
-
-
-$window1->{rwindow}->show_all;
+each_index { $list->append_column(Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i + 1)) } (N("Interface"), N("IP address"), N("Protocol"), N("Driver"), N("State"));
+
+#TV $list->set_column_auto_resize($_,1) foreach (0..4);
+#TV $list->column_titles_passive();
+#TV $list->set_shadow_type('etched_out');
+$vbox2->pack_start($list, 0, 0, 5);
+#$scrolled1->add_with_viewport($table2);
+
+my $ip_regexp = qr/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+
+build_list();
+
+my $hbox3 = new Gtk2::HBox(0,0);
+my $button3 = new Gtk2::Button(N("Configure Local Area Network..."));
+$button3->signal_connect(clicked => [ \&configure_lan, '', $netcnx, $netc, $intf ]);
+$hbox3->pack_start($button3, 0, 0, 0);
+$vbox2->pack_start($hbox3, 0, 0, 0);
+
+#$vbox1->pack_start(new Gtk2::HSeparator,0,0,5);
+
+my $bbox0 = new Gtk2::HButtonBox;
+$vbox1->pack_start($bbox0,0,0,0);
+$bbox0->set_layout('end');
+
+
+$bbox0->add(new Gtk2::Label(N("Click here to launch the wizard ->")));
+my $button_wizard = new Gtk2::Button(N("Wizard..."));
+$button_wizard->signal_connect(clicked => sub {
+ $::isWizard = 1;
+ system("drakconnect --wizard");
+# netconnect::intro('', $netcnx, $in);
+ $combo1->entry->set_text(-e "/etc/sysconfig/network-scripts/drakconnect_conf." . $combo1->entry->get_text ? $combo1->entry->get_text : "default");
+ network::netconnect::load_conf($netcnx, $netc, $intf);
+ update();
+ });
+$bbox0->add($button_wizard);
+
+$vbox1->pack_start(new Gtk2::HSeparator,0,0,5);
+
+my $bbox1 = new Gtk2::HButtonBox;
+$vbox1->pack_start($bbox1,0,0,0);
+$bbox1->set_layout('end');
+#$bbox1->set_border_width(5);
+
+my $button_expert = new Gtk2::Button(N("Expert Mode"));
+$button_expert->signal_connect(clicked => sub {
+ foreach ($button1, $button3) { $expert_mode ? $_->hide() : $_->show() }
+ $button_expert->child->set($expert_mode ? N("Expert Mode") : N("Normal Mode"));
+ $expert_mode = !$expert_mode;
+ });
+$bbox1->add($button_expert);
+
+my $button_apply = new Gtk2::Button(N("Apply"));
+$button_apply->signal_connect(clicked => sub {
+ apply();
+ });
+$button_apply->set_sensitive(0);
+$bbox1->add($button_apply);
+
+my $button_cancel = new Gtk2::Button(N("Cancel"));
+$button_cancel->signal_connect(clicked => sub {
+ $combo1->entry->set_text($old_profile);
+ update();
+ quit_global();
+ });
+$bbox1->add($button_cancel);
+my $button_ok = new Gtk2::Button(N("OK"));
+$button_ok->signal_connect(clicked => sub {
+ my $dialog = new_dialog();
+ my $label = new Gtk2::Label(N("Please Wait... Applying the configuration"));
+ $dialog->vbox->pack_start($label,1,1,20);
+ $dialog->show_all;
+ gtkflush();
+ apply();
+ $dialog->destroy;
+ update();
+ quit_global();
+ });
+$bbox1->add($button_ok);
+$combo1->entry->signal_connect('changed', sub {
+# connected() and disconnect_backend();
+ network::netconnect::set_profile($netcnx, $combo1->entry->get_text());
+ network::netconnect::load_conf($netcnx, $netc, $intf);
+ $netcnx->{$_} = $netc->{$_} foreach qw(NET_DEVICE NET_INTERFACE);
+ network::netconnect::set_net_conf($netcnx, $netc);
+ update();
+ $button_apply->set_sensitive(1);
+ });
+
+$window1->{rwindow}->show_all();
+$_->hide foreach $button1, $button3;
gtkflush();
+$::isEmbedded and kill 'USR2', $::CCPID;
+my $tag = Gtk2->timeout_add(4000, \&update2);
$window1->main;
ugtk2->exit(0);
-
-
-sub manage {
- my ($netc, $netcnx, $intf) = @_;
-
- my $gui = {};
- my ($interface_menu, $selected);
- my $window = ugtk2->new('Manage Connection');
- my $notebook = Gtk2::Notebook->new;
- $notebook->set_property('show-tabs', 0);
- $notebook->set_property('show-border', 0);
-
- my $apply_button;
- $apply_button = gtksignal_connect(Gtk2::Button->new(N("Apply")),
- clicked => sub { save($netc, $netcnx, $intf, $gui, $apply_button) });
-
- each_index {
- my $interface = $_;
- $gui->{$interface}{index} = $::i;
- build_notebook($window, $netc, $intf->{$interface}, $gui->{$interface}, $interface, $apply_button);
- $notebook->append_page(gtkpack(Gtk2::VBox->new(0,0), $gui->{$interface}{notebook}));
- } (sort keys %$intf);
-
- $window->{rwindow}->add(gtkpack_(Gtk2::VBox->new,
- 0, $interface_menu = gtksignal_connect(Gtk2::OptionMenu->new,
- changed => sub {
- $selected = $interface_menu->get_text;
- $notebook->set_current_page($gui->{$selected}{index});
- },
- ),
- 1, $notebook,
- 0, gtkpack(Gtk2::HButtonBox->new,
- gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => sub { $window->destroy;
- Gtk2->main_quit }),
- gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => sub {}),
- $apply_button,
- gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub {
- if ($apply_button->get_property('sensitive')) {
- save($netc, $netcnx, $intf, $gui, $apply_button);
- $window->destroy;
- Gtk2->main_quit;
- }
- }),
- ),
- ));
- $interface_menu->set_popdown_strings(sort keys %$intf);
- $apply_button->set_sensitive(0);
-
- $window->{rwindow}->show_all;
- $window->main;
- ugtk2->exit(0);
-}
-
-sub build_notebook {
- my ($window, $netc, $intf, $gui, $interface, $apply_button) = @_;
-
- my $apply = sub { $apply_button->set_sensitive(1) };
-
- #- tcp/ip box
- gtkpack_($gui->{sheet}{'Tcp/ip'} = Gtk2::VBox->new(0,0),
- if_($interface =~ /eth/,
- 0, $gui->{intf}{BOOTPROTO} = gtksignal_connect(Gtk2::OptionMenu->new,
- changed => sub { $_->set_sensitive($gui->{intf}{BOOTPROTO}->get_text eq "static" ? 1 : 0) foreach $gui->{intf}{IPADDR}, $gui->{intf}{NETMASK} },
- ),
- ),
- 1, gtkpack(Gtk2::HBox->new(0,0),
- gtkpack_(Gtk2::VBox->new(0,0),
- 0, gtkpack_(Gtk2::VBox->new(0,0),
- 1, Gtk2::Label->new(N("IP address")),
- 0, gtksignal_connect($gui->{intf}{IPADDR} = Gtk2::Entry->new,
- key_press_event => $apply),
- ),
- 0, gtkpack_(Gtk2::VBox->new(0,0),
- 1, Gtk2::Label->new(N("Netmask")),
- 0, gtksignal_connect($gui->{intf}{NETMASK} = Gtk2::Entry->new,
- key_press_event => $apply),
- ),
- 0, gtkpack_(Gtk2::VBox->new(0,0),
- 1, Gtk2::Label->new(N("Gateway")),
- 0, gtksignal_connect($gui->{netc}{GATEWAY} = Gtk2::Entry->new,
- key_press_event => $apply),
- ),
- ),
- Gtk2::VSeparator->new,
- gtkpack_(Gtk2::VBox->new(0,0),
- 1, gtkadd(Gtk2::Frame->new(N("DNS servers")),
- gtkpack(Gtk2::VBox->new(0,0),
- Gtk2::Label->new($netc->{dnsServer}),
- Gtk2::Label->new($netc->{dnsServer2}),
- ),
- ),
- 1, gtkadd(Gtk2::Frame->new(N("Search Domain")),
- Gtk2::Label->new($netc->{DOMAINNAME} || 'none'),
- ),
- ),
- ),
- );
- $gui->{intf}{BOOTPROTO} and $gui->{intf}{BOOTPROTO}->set_popdown_strings(N_("static"), N_("dhcp"));
- $interface !~ /eth/ and $_->set_sensitive(0) foreach $gui->{intf}{IPADDR}, $gui->{intf}{NETMASK};
- $gui->{intf}{$_}->set_text($intf->{$_}) foreach keys %{$gui->{intf}};
- $gui->{netc}{$_}->set_text($netc->{$_}) foreach keys %{$gui->{netc}};
-
- if ($intf->{WIRELESS_MODE}) {
- gtkpack($gui->{sheet}{Wireless} = Gtk2::HBox->new(0,0),
- gtkpack_(Gtk2::VBox->new(0,0),
- map { (0, gtkpack_(Gtk2::VBox->new(0,0),
- 1, Gtk2::Label->new($_->[0]),
- 0, gtksignal_connect($gui->{intf}{$_->[1]} = Gtk2::Entry->new,
- key_press_event => $apply),
- ));
- } ([ N("Operating Mode"), "WIRELESS_MODE" ],
- [ N("Netwok name (ESSID)"), "WIRELESS_ESSID" ],
- [ N("Network ID"), "WIRELESS_NWID" ],
- [ N("Operating frequency"), "WIRELESS_FREQ" ],
- [ N("Sensitivity threshold"), "WIRELESS_SENS" ],
- [ N("Bitrate (in b/s)"), "WIRELESS_RATE" ]
- ),
- ),
- Gtk2::VSeparator->new,
- gtkpack_(Gtk2::VBox->new(0,0),
- map { (0, gtkpack_(Gtk2::VBox->new(0,0),
- 1, Gtk2::Label->new($_->[0]),
- 0, gtksignal_connect($gui->{intf}{$_->[1]} = Gtk2::Entry->new,
- key_press_event => $apply),
- ));
- } ([ N("Encryption key"), 'WIRELESS_ENC_KEY' ],
- [ N("RTS/CTS"), 'WIRELESS_RTS' ],
- [ N("Fragmentation"), 'WIRELESS_FRAG' ],
- [ N("Iwconfig command extra arguments"), 'WIRELESS_IWCONFIG' ],
- [ N("Iwspy command extra arguments"), 'WIRELESS_IWSPY' ],
- [ N("Iwpriv command extra arguments"), 'WIRELESS_IWPRIV' ],
- ),
- ),
- );
- $gui->{intf}{$_}->set_text($intf->{$_}) foreach keys %{$gui->{intf}};
- }
-
- #- options box
- gtkpack($gui->{sheet}{Options} = Gtk2::VBox->new(0,0),
- gtkpack__(Gtk2::VBox->new(0,0),
- map { ($gui->{intf_bool}{$_->[0]} = gtksignal_connect(Gtk2::CheckButton->new($_->[1]),
- toggled => $apply))
- } ([ "ONBOOT", N("Start at boot") ],
- [ "HWADDR", N("Track network card id (useful for laptops)") ],
- [ "MII_NOT_SUPPORTED", N("Network Hotplugging") ],
- ),
- ));
- $gui->{intf_bool}{$_}->set_active($intf->{$_} eq 'yes' ? 1 : 0) foreach keys %{$gui->{intf_bool}};
-
- #- informations box
- my $module = c::getNetDriver($interface) || modules::get_alias($interface);
- my $info = find { $_->{driver} eq $module } detect_devices::probeall();
- gtkpack($gui->{sheet}{Informations} = Gtk2::VBox->new(0,0),
- gtktext_insert(Gtk2::TextView->new,
- join('',
- map { $_->[0] . ": \x{200e}" . $_->[1] . "\n" } (
- [ N("Vendor"), split('\|', $info->{description}) ],
- [ N("Descripton"), reverse split('\|', $info->{description}) ],
- [ N("Media class"), $info->{media_type} ],
- [ N("Module name"), $module ],
- [ N("Mac Address"), c::get_hw_address($interface) ],
- [ N("Bus"), $info->{bus} ],
- [ N("Location on the bus"), $info->{pci_bus} ],
- )
- )
- ),
- );
-
- $gui->{notebook} = Gtk2::Notebook->new;
- populate_notebook($gui->{notebook}, $gui);
-}
-
-sub populate_notebook {
- my ($notebook, $gui) = @_;
- foreach ('Tcp/ip', 'Wireless', 'Options', 'Informations') {
- !$gui->{sheet}{$_} and next;
- $notebook->append_page($gui->{sheet}{$_}, Gtk2::Label->new($_));
- }
-}
-
-sub save {
- my ($netc, $netcnx, $intf, $gui, $apply_button) = @_;
-
- save_notebook($netc, $intf->{$_}, $gui->{$_}) foreach keys %$intf;
- apply($netc, $netcnx, $intf, $apply_button);
-}
-
-sub save_notebook {
- my ($netc, $intf, $gui) = @_;
-
- $intf->{$_} = $gui->{intf}{$_}->get_text foreach keys %{$gui->{intf}};
- $intf->{$_} = bool2yesno($gui->{intf_bool}{$_}->get_active) foreach keys %{$gui->{intf_bool}};
- $netc->{$_} = $gui->{netc}{$_}->get_text foreach keys %{$gui->{netc}};
-}
-
-sub add_intf() {
- $::isWizard = 1;
- network::netconnect::load_conf($netcnx, $netc, $intf);
- # network::netconnect::add_interface($in, $netcnx);
- eval { network::netconnect::main('', $netcnx, $in, $netc, undef, $intf) };
- my $err = $@;
- if ($err && $in->isa('interactive::gtk')) {
- err_dialog(N("Error"), N("An unexpected error has happened:\n%s", $err));
- }
- $in->exit(0);
-}
-
-sub del_intf() {
- my ($intf, $faillure);
- my $wiz =
- {
- defaultimage => "wiz_drakconnect.png",
- name => N("Remove a network interface"),
- pages => {
- welcome => {
- no_back => 1,
- name => N("Select the network interface to remove:"),
- data => [ { label => N("Net Device"), val => \$intf, list => [ detect_devices::getNet() ], allow_empty_list => 1 } ],
- post => sub {
- !$::testing and eval {
- modules::mergein_conf('/etc/modules.conf');
- modules::remove_alias($intf);
- modules::write_conf();
- rm_rf("/etc/sysconfig/network-scripts/ifcfg-$intf");
- };
- $faillure = $@;
- },
- next => "end",
- },
- end => {
- name => sub {
- ($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)
- )
- },
- },
- },
- };
- require wizards;
- wizards->new->safe_process($wiz, $in);
-}
-
-
-sub get_intf_ip {
- my ($interface) = @_;
- my ($ip, $state, $mask);
- if (-x "/sbin/ifconfig") {
- local $_ = `LC_ALL=C LANGUAGE=C /sbin/ifconfig $interface`;
- $ip = /inet addr:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/mso ? $1 : N("No Ip");
- $mask = /Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/mso ? $1 : N("No Mask");
- $state = /inet/ ? N("up") : N("down");
- } else {
- $ip = $intf->{$interface}{IPADDR};
- $state = "n/a";
- }
- ($ip, $state, $mask);
-}
-
-my %intf;
-
-sub update_list() {
- @all_cards = network::ethernet::conf_network_card_backend($netc, $intf);
- my %new_intf = map { @$_ } @all_cards;
- my @new_intf = sort keys %new_intf;
- foreach my $interface (difference2(\@new_intf, [ keys %intf ])) {
- $intf{$interface} = $tree_model->append(undef);
- }
- foreach my $interface (@new_intf) {
- my ($ip, $state) = get_intf_ip($interface);
- $tree_model->set($intf{$interface}, map_index { $::i => $_ } (gtkcreate_pixbuf("eth_card_mini2.png"), $interface, $ip , $intf->{$interface}{BOOTPROTO}, $new_intf{$interface}, $state));
- }
- foreach my $i (difference2([ keys %intf ], \@new_intf)) {
- $tree_model->remove($intf{$i});
- delete $intf{$i};
+dd:
+network::netconnect::intro('', $netcnx, $in);
+$in->exit(0);
+
+sub build_list {
+ foreach my $i (0..$#all_cards) {
+ my ($ip, $state);
+ if (-e "/sbin/ifconfig") {
+ local $_ = `LC_ALL=C LANG=C LANGUAGE=C LC_MESSAGES=C /sbin/ifconfig "eth$i"`;
+ /inet addr\:$ip_regexp/; $ip = if_($1 && $2 && $3, "$1.$2.$3.$4");
+ $_ = `LC_ALL=C LANG=C LANGUAGE=C LC_MESSAGES=C /sbin/ifconfig`;
+ $state = /eth$i/ ? "up" : "down";
+ } else { $ip = $intf->{"eth$_"}{IPADDR}; $state = "n/a" }
+ $tree_model->append_set(undef, [ map_index { $::i => $_ } (gtkcreate_pixbuf("eth_card_mini2.png"), "eth$i", $ip , $intf->{"eth$i"}{BOOTPROTO}, $all_cards[$i][1], $state) ])->free;
+#TV $list->set_selectable($i, 0);
}
}
sub apply {
- my ($netc, $netcnx, $intf, $button_apply) = @_;
-
- network::network::sethostname($netc) if is_dynamic_ip($intf);
-
- $netcnx->{type} eq 'modem' and network::modem::ppp_configure($in, $netcnx->{$netcnx->{type}});
- $netcnx->{type} eq 'isdn_internal' and network::isdn::isdn_write_config_backend($netcnx->{$netcnx->{type}}, $netc, $netcnx); #$light
- $netcnx->{type} eq 'isdn_external' and network::modem::ppp_configure($in, $netcnx->{$netcnx->{type}});
+ $old_profile = $netcnx->{PROFILE} ? $netcnx->{PROFILE} : "default";
+ network::netconnect::save_conf($netcnx, $netc, $intf);
+
+ $netcnx->{type} eq 'modem' and any::pppConfig($in, $netcnx->{$netcnx->{type}}, '');
+ $netcnx->{type} eq 'isdn_internal' and network::isdn::isdn_write_config_backend($netcnx->{$netcnx->{type}}, 1, $netc, $netcnx); #$light
+ $netcnx->{type} eq 'isdn_external' and any::pppConfig($in, $netcnx->{$netcnx->{type}}, '');
my $a = $netcnx->{type};
$a =~ s/adsl_//;
$netcnx->{type} =~ /adsl/ and network::adsl::adsl_conf_backend($netcnx->{$netcnx->{type}}, $netc, $a, $netcnx);
$netcnx->{dhcp_client} and $netc->{dhcp_client} = $netcnx->{dhcp_client};
- network::network::configureNetwork2($in, $prefix, $netc, $intf);
+ network::configureNetwork2($in, $prefix, $netc, $intf);
$netcnx->{type} =~ /adsl/ or system("/sbin/chkconfig --del adsl 2> /dev/null");
$netcnx->{type} !~ /adsl_p/ and system("$prefix/etc/rc.d/init.d/network restart");
-
$button_apply->set_sensitive(0);
}
-sub ethisup { `LC_ALL=C LANGUAGE=C /sbin/ifconfig $_[0]` =~ /inet/ }
-
-sub update_intbutt() {
- $int_state->set($isconnected ? N("Connected") : N("Not connected"));
- $int_connect->child->set($isconnected ? N("Disconnect...") : N("Connect..."));
- $int_connect->set_sensitive(1);
-}
+sub ethisup { `LC_ALL=C LANG=C LANGUAGE=C LC_MESSAGES=C /sbin/ifconfig` =~ /eth$_[0]/ }
my $to_update;
-sub update() {
+sub update {
my $h = chomp_(`hostname`);
- $label_host->set_label($h);
- $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();
- update_intbutt() if $isconnected != -1;
+ $label_host->set($h);
+ $label4->set($netcnx->{type});
+ $label5->set($netcnx->{type} eq 'lan' ? N("Gateway:") : N("Interface:"));
+ $label6->set($netcnx->{type} eq 'lan' ? $netc->{GATEWAY} : $netcnx->{NET_INTERFACE});
+#TV $list->window->freeze();
+ $tree_model->clear;
+ build_list();
+#TV $list->window->thaw();
+ $button_del->set_sensitive(network::netconnect::get_profiles() > 1);
+ return 1 if $isconnected == -1;
+ $label8->set($isconnected ? N("Connected") : N("Not connected"));
+ $button2->child->set($isconnected ? N("Disconnect...") : N("Connect..."));
+ $button2->set_sensitive(1);
1;
}
@@ -517,7 +383,7 @@ sub in_ifconfig {
`/sbin/ifconfig` =~ /$intf/;
}
-sub update2() {
+sub update2 {
undef $to_update;
connected_bg(\$to_update);
if (defined $to_update) {
@@ -527,195 +393,196 @@ sub update2() {
$warning_label1->set(N("Warning, another Internet connection has been detected, maybe using your network"));
$isconnected = 0;
} else { $warning_label1->set("") }
- update_intbutt();
+ $label8->set($isconnected ? N("Connected") : N("Not connected"));
+ $button2->child->set($isconnected ? N("Disconnect...") : N("Connect..."));
+ $button2->set_sensitive(1);
}
}
update();
1;
}
-sub quit_global() {
+sub quit_global {
ugtk2->exit(0);
}
-sub get_intf_status {
- my ($c) = @_;
- ethisup($c) ? N("Deactivate now") : N("Activate now")
-}
+sub configure_lan {
+ my (undef, $prefix, $netcnx, undef, $intf) = @_;
+ my $window = Gtk2::Window->new('toplevel');
-sub configure_lan() {
- my $window = _create_dialog(N("LAN configuration"));
my @card_tab;
if (@all_cards < 1) {
- $window->vbox->add(Gtk2::Label->new(N("You don't have any configured interface.
-Configure them first by clicking on 'Configure'")));
- gtkpack(gtkset_layout($window->action_area, 'end'),
- gtksignal_connect(Gtk2::Button->new(N("Ok")),
- clicked => sub { Gtk2->main_quit })
- );
- $window->show_all;
- $window->run;
- $window->destroy;
+ my $dialog = new_dialog();
+ $dialog->vbox->pack_start(new Gtk2::Label(N("You don't have any configured interface.
+Configure them first by clicking on 'Configure'")),1,1,0);
+ my $bbox_dialog = new Gtk2::HButtonBox;
+ $dialog->action_area->add($bbox_dialog);
+ $bbox_dialog->set_layout('end');
+ my $button_ok = new Gtk2::Button(N("OK"));
+ $button_ok->signal_connect(clicked => sub { Gtk2->main_quit() });
+ $bbox_dialog->add($button_ok);
+ $dialog->show_all;
+ $dialog->set_modal(1);
+ Gtk2->main();
+ $dialog->destroy;
return;
}
+ $window->signal_connect(delete_event => sub { Gtk2->main_quit });
+ $window->set_position('center');
+ $window->set_title(N("LAN configuration"));
$window->set_border_width(10);
- gtkpack($window->vbox,
- Gtk2::Label->new(N("LAN Configuration")),
- my $notebook = Gtk2::Notebook->new,
- );
-
+ my $vbox1 = new Gtk2::VBox(0,0);
+ $window->add($vbox1);
+ $vbox1->pack_start(new Gtk2::Label(N("LAN Configuration")),0,1,0);
+ my $notebook = new Gtk2::Notebook;
+ $vbox1->pack_start($notebook,0,1,0);
foreach (0..$#all_cards) {
my @infos;
my @conf_data;
$card_tab[2*$_] = \@infos;
$card_tab[2*$_+1] = \@conf_data;
-
- my $vbox_local = Gtk2::VBox->new(0,0);
+ my $vbox_local = new Gtk2::VBox(0,0);
$vbox_local->set_border_width(10);
- $vbox_local->pack_start(Gtk2::Label->new(N("Adapter %s: %s", $_+1 , $all_cards[$_][0])),1,1,0);
+ $vbox_local->pack_start(new Gtk2::Label(N("Adapter %s: %s", $_+1 , "eth$_")),1,1,0);
# Eth${_}Hostname = $netc->{HOSTNAME}
# Eth${_}HostAlias = " . do { $netc->{HOSTNAME} =~ /([^\.]*)\./; $1 } . "
# Eth${_}Driver = $all_cards[$_]->[1]
- my $interface = $all_cards[$_][0];
- my ($ip, undef, $mask) = get_intf_ip($interface);
- $mask ||= $intf->{$interface}{NETMASK};
- @conf_data = ([ N("IP address"), \$ip ],
- [ N("Netmask"), \$mask ],
- [ N("Boot Protocol"), \$intf->{$interface}{BOOTPROTO}, ["static", "dhcp", "bootp"] ],
- [ N("Started on boot"), \$intf->{$interface}{ONBOOT} , ["yes", "no"] ],
- [ N("DHCP client"), \$netcnx->{dhcp_client} ]
- );
+ @conf_data = ([N("IP address"), \$intf->{"eth$_"}{IPADDR}],
+ [N("Netmask"), \$intf->{"eth$_"}{NETMASK}],
+ [N("Boot Protocol"), \$intf->{"eth$_"}{BOOTPROTO}, ["static", "dhcp", "bootp"]],
+ [N("Started on boot"), \$intf->{"eth$_"}{ONBOOT} , ["yes", "no"]],
+ [N("DHCP client"), \$netcnx->{dhcp_client}]
+ );
my $i = 0;
- my $size_group = Gtk2::SizeGroup->new('horizontal');
-
foreach my $j (@conf_data) {
- my $l = Gtk2::Label->new($j->[0]);
+ $infos[2*$i] = new Gtk2::HBox(0,0);
+ my $l = new Gtk2::Label($j->[0]);
$l->set_justify('left');
- $infos[2*$i] = gtkpack_(Gtk2::HBox->new,
- 1, $l);
- $vbox_local->pack_start($infos[2*$i], 1, 1, 0);
- my $c;
+ $infos[2*$i]->pack_start($l,1,1,0);
+ $vbox_local->pack_start($infos[2*$i],0,0,0);
if (defined $j->[2]) {
- $c = Gtk2::OptionMenu->new;
+ my $c = new Gtk2::Combo();
$c->set_popdown_strings(@{$j->[2]});
$infos[2*$i+1] = $c->entry;
+ $infos[2*$i+1]->set_editable(0);
$infos[2*$i]->pack_start($c,0,0,0);
} else {
- $infos[2*$i+1] = ($c = Gtk2::Entry->new);
+ $infos[2*$i+1] = new Gtk2::Entry();
$infos[2*$i]->pack_start($infos[2*$i+1],0,0,0);
}
- $size_group->add_widget($c);
$infos[2*$i+1]->set_text(${$j->[1]});
$i++;
}
-
+ my $c = $_;
my $widget_temp;
- if (-e "$::prefix/etc/sysconfig/network-scripts/ifcfg-$interface") {
- $widget_temp = gtksignal_connect(Gtk2::Button->new(get_intf_status($interface)),
- clicked => sub {
- system("/sbin/if" . (ethisup($interface) ? N("down") : N("up")) . " $interface");
- $_[0]->set_label(get_intf_status($interface));
- update();
- });
+ if (-e "$prefix/etc/sysconfig/network-scripts/ifcfg-eth$c") {
+ $widget_temp = gtksignal_connect(new Gtk2::Button(ethisup($c) ? N("deactivate now") : N("activate now")),
+ clicked => sub {
+ system("/sbin/if" . (ethisup($c) ? "down" : "up") . " eth$c");
+ gtkbuttonset($_[0], ethisup($c) ? N("deactivate now") : N("activate now"));
+ });
} else {
- $widget_temp = N("This interface has not been configured yet.\nRun the \"Add an interface\" assistant from the Mandrake Control Center");
+ $widget_temp = N("This interface has not been configured yet.\nLaunch the configuration wizard in the main window");
}
- $vbox_local->pack_start(gtkpack__(Gtk2::HBox->new(0,0),
+ $vbox_local->pack_start(gtkpack__(new Gtk2::HBox(0,0),
$widget_temp
),0,0,0);
- # $list->append($_+1, $interface, $intf->{$interface}{IPADDR}, $intf->{$interface}{BOOTPROTO}, $all_cards[$_]->[1]);
+ # $list->append($_+1, "eth$_", $intf->{"eth$_"}{IPADDR}, $intf->{"eth$_"}{BOOTPROTO}, $all_cards[$_]->[1]);
# $list->set_selectable($_, 0);
- $notebook->append_page($vbox_local, Gtk2::Label->new($interface));
+# require Data::Dumper;
+# print "------------\n" . Data::Dumper->Dump([$b],['b']) . "\n";
+ my $hbox_local = new Gtk2::HBox(0,0);
+ my $pix = gtkpng("/usr/share/libDrakX/pixmaps/eth_card_mini.png");
+ $hbox_local->pack_start($pix,0,0,0);
+ $hbox_local->pack_start(new Gtk2::Label("eth$_"),0,0,0);
+ $hbox_local->show_all;
+ $notebook->append_page($vbox_local, $hbox_local);
}
-
- my $exit_dialogsub = sub {
- $window->destroy;
- Gtk2->main_quit;
- };
-
- gtkpack($window->action_area,
- gtksignal_connect(Gtk2::Button->new(N("Cancel")),
- clicked => $exit_dialogsub),
- gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub {
- foreach (0..$#all_cards) {
- my @infos = @{$card_tab[2*$_]};
- each_index { ${$_->[1]} = $infos[2*$::i+1]->get_text } @{$card_tab[2*$_+1]};
- my $interface = $all_cards[$_][0];
- if ($intf->{$interface}{BOOTPROTO} ne "static") {
- delete @{$intf->{$interface}}{qw(IPADDR NETWORK NETMASK BROADCAST)};
- } else {
- if ($infos[1]->get_text ne "No ip") {
- $intf->{$interface}{IPADDR} = $infos[1]->get_text;
- $intf->{$interface}{NETMASK} = $infos[3]->get_text;
- }
- }
- }
- update();
- $button_apply->set_sensitive(1);
- $exit_dialogsub->();
- }),
- );
-
- $window->show_all;
+ my $bbox1 = new Gtk2::HButtonBox;
+ $vbox1->pack_start($bbox1,0,0,10);
+ $bbox1->set_layout('end');
+ my $button_ok = new Gtk2::Button(N("OK"));
+ $button_ok->signal_connect(clicked => sub {
+ foreach (0..$#all_cards) {
+ my @infos = @{$card_tab[2*$_]};
+ each_index {
+ ${$_->[1]} = $infos[2*$::i+1]->get_text();
+ } @{$card_tab[2*$_+1]};
+ }
+ update();
+ $button_apply->set_sensitive(1);
+ $window->destroy(); Gtk2->main_quit;
+ });
+ $bbox1->add($button_ok);
+
+ my $button_cancel = new Gtk2::Button(N("Cancel"));
+ $button_cancel->signal_connect(clicked => sub { $window->destroy(); Gtk2->main_quit });
+ $bbox1->add($button_cancel);
+
+ $window->set_modal(1);
+ $window->show_all();
foreach (0..$#all_cards) {
my @infos = @{$card_tab[2*$_]};
- $intf->{$all_cards[$_][0]}{BOOTPROTO} eq "dhcp" or $infos[8]->hide;
+ $intf->{"eth$_"}{BOOTPROTO} eq "dhcp" or $infos[8]->hide;
}
- $window->run;
+ $window->set_position('center_always');
+ Gtk2->main;
}
sub configure_net {
- my ($netcnx, $netc, $_intf) = @_;
- my $dialog = ugtk2->new('drakconnect');
- my $exit_dialogsub = sub { Gtk2->main_quit };
+ my (undef, $_prefix, $netcnx, $netc, $_intf) = @_;
if (!$netcnx->{type}) {
- $in->ask_warn(
- N("Warning"),
- #-PO here "Internet access" should be translated the same was as in control-center
- N("You don't have any configured Internet connection.
-Please run \"Internet access\" in control center."));
- $in->exit;
+ my $dialog = new_dialog();
+ $dialog->vbox->pack_start(new Gtk2::Label(N("You don't have any internet connection.
+Create one first by clicking on 'Configure'")),1,1,0);
+ my $bbox_dialog = new Gtk2::HButtonBox;
+ $dialog->action_area->add($bbox_dialog);
+ $bbox_dialog->set_layout('end');
+ my $button_ok = new Gtk2::Button(N("OK"));
+ $button_ok->signal_connect(clicked => sub {
+ Gtk2->main_quit();
+ });
+ $bbox_dialog->add($button_ok);
+ $dialog->show_all;
+ $dialog->set_modal(1);
+ Gtk2->main();
+ $dialog->destroy;
+ return;
}
my $cnx = {};
+ my @infos;
$cnx = $netcnx->{$netcnx->{type}};
- 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 $window = Gtk2::Window->new('toplevel');
+ $window->signal_connect(delete_event => sub { Gtk2->main_quit });
+ $window->set_position('center');
+ $window->set_title(N("Internet connection configuration"));
+ $window->set_border_width(10);
+ my $vbox1 = new Gtk2::VBox(0,0);
+ $window->add($vbox1);
+ $vbox1->pack_start(new Gtk2::Label(N("Internet Connection Configuration")),0,1,0);
+
+ $vbox1->pack_start(new Gtk2::HSeparator,0,0,5);
+ my $table1 = new Gtk2::Table(2, 4, 0);
+ $table1->set_row_spacings(5);
+ $table1->set_col_spacings(5);
+ $vbox1->pack_start($table1,0,0,0);
+ $table1->attach(new Gtk2::Label(N("Profile: ")), 0, 1, 0, 1, 'fill', 'fill',0,0);
+ $table1->attach(new Gtk2::Label(translate($netcnx->{PROFILE})), 1, 2, 0, 1, 'fill', 'fill',0,0);
+ $table1->attach(new Gtk2::Label(N("Connection type: ")), 0, 1, 1, 2, 'fill', 'fill',0,0);
+ $table1->attach(new Gtk2::Label(translate($netcnx->{type})), 1, 2, 1, 2, 'fill', 'fill',0,0);
+# my $button1 = new Gtk2::Button(N("Reconfigure using wizard..."));
+# $table1->attach($button1, 2, 4, 0, 2, 'fill', 'fill',0,0);
+ $vbox1->pack_start(new Gtk2::HSeparator,0,0,5);
+
+ my $frame1 = new Gtk2::Frame(N("Parameters"));
+ $vbox1->pack_start($frame1,1,1,0);
+ my $vbox2 = new Gtk2::VBox(0,0);
+ $frame1->add($vbox2);
my $i = 0;
- my (@mask, $extra_netdevice);
- if ($netcnx->{type} eq 'lan') {
- @mask = (0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0);
- } elsif ($netcnx->{type} eq 'isdn_internal') {
- if (defined $cnx->{vendor} && defined $cnx->{id}) {
- @mask = (0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1);
- } else {
- @mask = (1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1)
- }
- $extra_netdevice = "ppp0";
- } elsif ($netcnx->{type} eq 'modem' || $netcnx->{type} eq 'isdn_external') {
- @mask = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0);
- $extra_netdevice = "ppp0" if $netcnx->{type} eq 'modem';
- } elsif ($netcnx->{type} =~ /adsl/) {
- @mask = (0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0);
- $extra_netdevice = "ppp0";
- } elsif ($netcnx->{type} eq 'cable') {
- @mask = (0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0);
- }
- $extra_netdevice = "ippp0" if $netcnx->{type} =~ /^isdn/;
- #- duplicated code (waiting for 9.1 to be out to merge everything correctly, avoid bug elsewhere).
- if ($netcnx->{type} =~ /adsl/) {
- require network::adsl;
- network::adsl::adsl_probe_info($cnx, $netc, $intf);
- }
my @conf_data = ([ N("Card IRQ"), \$cnx->{irq} ],
[ N("Card mem (DMA)"), \$cnx->{mem} ],
[ N("Card IO"), \$cnx->{io} ],
@@ -738,72 +605,68 @@ Please run \"Internet access\" in control center."));
[ N("Domain name"), \$cnx->{domain} ],
[ N("First DNS Server (optional)"), \$cnx->{dns1} ],
[ N("Second DNS Server (optional)"), \$cnx->{dns2} ],
- [ N("Ethernet Card"), \$netc->{NET_DEVICE}, [ detect_devices::getNet(), $extra_netdevice ] ],
+ [ N("Ethernet Card"), \$netc->{NET_DEVICE}, [ 'eth0', 'eth1', 'eth2', 'eth3', 'eth4', 'eth5', 'eth6', 'eth7', 'eth8', 'eth9' ] ],
[ N("DHCP Client"), \$netcnx->{dhcp_client}, ["dhcp-client", "dhcpcd", "dhcpxd"] ],
[ N("Connection speed"), \$cnx->{speed}, ["64 Kb/s", "128 Kb/s"] ],
[ N("Connection timeout (in sec)"), \$cnx->{huptimeout} ]
);
- my @infos;
foreach (@conf_data) {
- if (!$mask[$i]) {
- $i++;
- next;
- }
- $infos[2*$i] = Gtk2::HBox->new(0,0);
- gtkpack($infos[2*$i], gtkset_justify(Gtk2::Label->new($_->[0]), 'left'));
- gtkpack($param_vbox, $infos[2*$i]);
- if (defined $_->[2]) {
- my $c = Gtk2::Combo->new;
- $c->set_popdown_strings(@{$_->[2]});
- $infos[2*$i+1] = $c->entry;
- gtkpack($infos[2*$i], $c);
- } else {
- $infos[2*$i+1] = Gtk2::Entry->new;
- gtkpack($infos[2*$i], $infos[2*$i+1]);
- #hide password if Entry Password
- $infos[2*$i+1]->set_visibility(0) if $_->[0] eq N("Account Password") || $_->[0] eq N("Password");
- }
- $infos[2*$i+1]->set_text(${$_->[1]});
- $i++;
+ $infos[2*$i] = new Gtk2::HBox(0,0);
+ my $l = new Gtk2::Label($_->[0]);
+ $l->set_justify('left');
+ $infos[2*$i]->pack_start($l,1,1,0);
+ $vbox2->pack_start($infos[2*$i],0,0,0);
+ if (defined $_->[2]) {
+ my $c = new Gtk2::Combo();
+ $c->set_popdown_strings(@{$_->[2]});
+ $infos[2*$i+1] = $c->entry;
+ $infos[2*$i]->pack_start($c,0,0,0);
+ } else {
+ $infos[2*$i+1] = new Gtk2::Entry();
+ $infos[2*$i]->pack_start($infos[2*$i+1],0,0,0);
+ #hide password if Entry Password
+ if ($_->[0] eq N("Account Password") || $_->[0] eq N("Password")) { $infos[2*$i+1]->set_visibility(0) };
+ }
+ $infos[2*$i+1]->set_text(${$_->[1]});
+ $i++;
}
-
- $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,
- 0, 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->();
- }),
- 1, Gtk2::Label->new(""),
- 0, gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => $exit_dialogsub),
- ),
- ),
- );
-
- $dialog->{rwindow}->show_all;
- $dialog->main;
- ugtk2->exit(0);
+ my @mask;
+@mask = (0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0) if $netcnx->{type} eq 'lan';
+@mask = (0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1) if $netcnx->{type} eq 'isdn_internal' && defined $cnx->{vendor} && defined $cnx->{id};
+@mask = (1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1) if $netcnx->{type} eq 'isdn_internal' && (!defined $cnx->{vendor} || !defined $cnx->{id});
+@mask = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0) if $netcnx->{type} eq 'modem' || $netcnx->{type} eq 'isdn_external';
+@mask = (0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0) if $netcnx->{type} =~ /adsl/;
+@mask = (0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0) if $netcnx->{type} eq 'cable';
+ $vbox1->pack_start(new Gtk2::HSeparator,0,0,5);
+
+
+ my $bbox1 = new Gtk2::HButtonBox;
+ $vbox1->pack_start($bbox1,0,0,0);
+ $bbox1->set_layout('end');
+ my $button_ok = new Gtk2::Button(N("OK"));
+ $button_ok->signal_connect(clicked => sub {
+ each_index {
+ ${$conf_data[$::i][1]} = $infos[2*$::i+1]->get_text() if $_;
+ } @mask;
+ update();
+ $button_apply->set_sensitive(1);
+ $window->destroy(); Gtk2->main_quit;
+ });
+ $bbox1->add($button_ok);
+ my $button_cancel = new Gtk2::Button(N("Cancel"));
+ $button_cancel->signal_connect(clicked => sub { $window->destroy(); Gtk->main_quit });
+ $bbox1->add($button_cancel);
+
+ $window->set_modal(1);
+ $window->show_all();
+ each_index { $_ ? $infos[2*$::i]->show : $infos[2*$::i]->hide } @mask;
+ Gtk2->main;
}
-sub reread_net_conf() {
- network::netconnect::read_net_conf('', $netcnx, $netc);
- modules::load_category('net');
- @all_cards = network::ethernet::conf_network_card_backend($netc, $intf);
- network::netconnect::load_conf($netcnx, $netc, $intf);
- network::network::probe_netcnx_type('', $netc, $intf, $netcnx);
+sub new_dialog {
+ my $dialog = new Gtk2::Dialog();
+ $dialog->set_position('center-on-parent');
+ $dialog->vbox->set_border_width(10);
+ $dialog->signal_connect(delete_event => sub { Gtk2->main_quit() });
+ $dialog;
}