summaryrefslogtreecommitdiffstats
path: root/bin/drakconnect
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-05-25 15:39:46 +0000
committerOlivier Blin <oblin@mandriva.com>2007-05-25 15:39:46 +0000
commit1d37bfdbbe874abd6dcb5563eea19f531de09e1c (patch)
tree74845e43ed8fa59c7aaafd1a87efaa6b0c83c228 /bin/drakconnect
parentc6ba983db7d5a82ee63599e775be0f8211447c72 (diff)
downloaddrakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.gz
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.bz2
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.xz
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.zip
sync with 2007.1 (because of SVN loss)2007.1
Diffstat (limited to 'bin/drakconnect')
-rwxr-xr-xbin/drakconnect155
1 files changed, 80 insertions, 75 deletions
diff --git a/bin/drakconnect b/bin/drakconnect
index 64b300e..ece74c5 100755
--- a/bin/drakconnect
+++ b/bin/drakconnect
@@ -2,7 +2,7 @@
# DrakConnect $Id$
-# Copyright (C) 1999-2005 Mandriva
+# Copyright (C) 1999-2006 Mandriva
# Damien "Dam's" Krotkine
# Damien "poulpy" Chaumette
# Thierry Vignaud <tvignaud@mandriva.com>
@@ -25,28 +25,33 @@ use strict;
use lib qw(/usr/lib/libDrakX);
+# i18n: IMPORTANT: to get correct namespace (drakx-net instead of libDrakX)
+BEGIN { unshift @::textdomains, 'drakx-net' }
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
use interactive;
use common;
+use run_program;
use network::netconnect;
-use network::ethernet;
+use network::connection::ethernet;
use network::tools;
use network::modem;
use network::network;
use detect_devices;
use c;
use modules;
-use network::isdn;
use network::adsl;
+use network::connection::isdn;
use network::test;
use POSIX ":sys_wait_h";
$ugtk2::wm_icon = "drakconnect";
my $in = 'interactive'->vnew('su');
if ($in->isa('interactive::gtk')) {
+ require mygtk2;
require ugtk2;
ugtk2->import(qw(:create :dialogs :helpers :wrappers));
+ mygtk2->import(qw(gtknew));
}
my $net = {};
@@ -73,11 +78,10 @@ add_intf();
old:
my @all_cards;
-my $window1 = ugtk2->new('drakconnect');
+my $window1 = ugtk2->new(N("Network configuration (%d adapters)", scalar @all_cards));
$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_border_width(10);
@@ -86,7 +90,7 @@ my $button_apply;
my $hostname = chomp_(`hostname`);
-my $int_label = Gtk2::Label->new($net->{type} eq 'lan' ? N("Gateway:") : N("Interface:"));
+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;
@@ -121,8 +125,8 @@ my ($label_host, $int_state);
$window1->{window}->add(
- gtkpack_(Gtk2::VBox->new(0,10),
- 0, gtkpack(Gtk2::HBox->new,
+ gtkpack__(Gtk2::VBox->new(0,10),
+ gtkpack(Gtk2::HBox->new,
Gtk2::Label->new(N("Hostname: ")),
$label_host = Gtk2::Label->new($hostname),
gtksignal_connect(Gtk2::Button->new(N("Configure hostname...")),
@@ -139,7 +143,7 @@ $window1->{window}->add(
}
),
),
- 1, gtkadd(gtkcreate_frame(N("LAN configuration")),
+ gtkadd(gtkcreate_frame(N("LAN configuration")),
gtkpack_(gtkset_border_width(Gtk2::VBox->new(0,0), 5),
0, $list,
0, Gtk2::HBox->new(0,0),
@@ -149,9 +153,9 @@ $window1->{window}->add(
),
)
),
- 0, gtkpack(Gtk2::HButtonBox->new,
+ gtkpack(Gtk2::HButtonBox->new,
gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => sub {
- exec("drakhelp --id internet-connection") unless fork() }),
+ run_program::raw({ detach => 1 }, 'drakhelp', '--id', 'internet-connection') }),
$button_apply = gtksignal_connect(gtkset_sensitive(Gtk2::Button->new(N("Apply")), 0),
clicked => \&apply),
gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&quit_global),
@@ -192,8 +196,8 @@ sub manage() {
$notebook->set_property('show-tabs', 0);
$notebook->set_property('show-border', 0);
- @all_cards = network::ethernet::get_eth_cards($modules_conf);
- my %names = network::ethernet::get_eth_cards_names(@all_cards);
+ @all_cards = network::connection::ethernet::get_eth_cards($modules_conf);
+ my %names = network::connection::ethernet::get_eth_cards_names(@all_cards);
foreach (keys %names) {
my $dev = detect_devices::is_lan_interface($_) ? $names{$_} : $_;
$p->{$dev} = {
@@ -212,7 +216,7 @@ sub manage() {
$window->{rwindow}->add(gtkpack_(Gtk2::VBox->new,
0, gtkpack__(Gtk2::HBox->new,
- Gtk2::Label->new(N("Device selected")),
+ gtknew('Label', text => N("Device: "), alignment => [ 0, 0 ]),
$interface_menu = gtksignal_connect(Gtk2::ComboBox->new_text,
changed => sub {
$selected = $interface_menu->get_text;
@@ -233,7 +237,7 @@ sub manage() {
},
},
undef, undef, '',
- [ N("Help"), sub { exec("drakhelp --id internet-connection") unless fork() } ],
+ [ N("Help"), sub { run_program::raw({ detach => 1 }, 'drakhelp', '--id', 'internet-connection') } ],
[ N("Apply"), sub { save($p, $apply_button) }, 0, 1 ],
),
),
@@ -266,7 +270,7 @@ sub build_tree {
network::adsl::adsl_probe_info($net);
$intf->{save} = sub {
$net->{type} = 'adsl';
- network::adsl::adsl_conf_backend($in, $modules_conf, $net);
+ network::adsl::adsl_conf_backend($in, $net);
};
}
elsif ($interface eq 'modem') {
@@ -276,8 +280,8 @@ sub build_tree {
}
elsif ($interface eq 'isdn') {
$intf->{pages} = { 'TCP/IP' => 1, 'Account' => 1, 'Modem' => 1, 'Options' => 1 };
- network::isdn::read_config($intf);
- $intf->{save} = sub { network::isdn::write_config($in, $intf) };
+ network::connection::isdn::read_config($intf);
+ $intf->{save} = sub { network::connection::isdn::apply_config($in, $intf) };
}
else {
#- ethernet is default
@@ -291,13 +295,14 @@ sub build_notebook {
my $apply = sub { $apply_button->set_sensitive(1) };
my $is_ethernet = detect_devices::is_lan_interface($interface);
+ my $size_group = Gtk2::SizeGroup->new('horizontal');
+
if ($intf->{pages}{'TCP/IP'}) {
- gtkpack($gui->{sheet}{'TCP/IP'} = Gtk2::HBox->new,
- gtkadd(gtkcreate_frame(N("IP configuration")),
- gtkpack_(gtkset_border_width(Gtk2::VBox->new(0,10), 5),
+ gtkpack__($gui->{sheet}{'TCP/IP'} = gtkset_border_width(Gtk2::VBox->new(0,10), 5),
+ gtknew('Title2', label => N("IP configuration")),
if_($is_ethernet,
- 0, gtkpack__(Gtk2::HBox->new,
- Gtk2::Label->new(N("Protocol")),
+ gtkpack(Gtk2::HBox->new(1,0),
+ gtknew('Label_Left', text => N("Protocol")),
$gui->{intf}{BOOTPROTO} = gtksignal_connect(Gtk2::ComboBox->new_text, changed => sub {
return if !$_[0]->realized;
my $proto = $gui->{intf}{BOOTPROTO};
@@ -312,39 +317,34 @@ sub build_notebook {
),
),
),
- 0, gtkpack(Gtk2::VBox->new(1,0),
- gtkpack__(Gtk2::HBox->new, Gtk2::Label->new(N("IP address"))),
- gtkpack__(Gtk2::HBox->new, gtksignal_connect($gui->{intf}{IPADDR} = Gtk2::Entry->new,
- key_press_event => $apply)),
+ gtkpack(Gtk2::HBox->new(1,0),
+ gtknew('Label_Left', text => N("IP address")),
+ gtksignal_connect($gui->{intf}{IPADDR} = Gtk2::Entry->new,
+ key_press_event => $apply),
),
- 0, gtkpack(Gtk2::VBox->new(1,0),
- gtkpack__(Gtk2::HBox->new, Gtk2::Label->new(N("Netmask"))),
- gtkpack__(Gtk2::HBox->new, gtksignal_connect($gui->{intf}{NETMASK} = Gtk2::Entry->new,
- key_press_event => $apply)),
+ gtkpack(Gtk2::HBox->new(1,0),
+ gtknew('Label_Left', text => N("Netmask")),
+ gtksignal_connect($gui->{intf}{NETMASK} = Gtk2::Entry->new,
+ key_press_event => $apply),
),
if_($is_ethernet,
- 0, gtkpack(Gtk2::VBox->new(1,0),
- gtkpack__(Gtk2::HBox->new, Gtk2::Label->new(N("Gateway"))),
- gtkpack__(Gtk2::HBox->new, gtksignal_connect($gui->{network}{GATEWAY} = Gtk2::Entry->new,
- key_press_event => $apply)),
+ gtkpack(Gtk2::HBox->new(1,0),
+ gtknew('Label_Left', text => N("Gateway")),
+ gtksignal_connect($gui->{network}{GATEWAY} = Gtk2::Entry->new,
+ key_press_event => $apply),
),
),
- ),
- ),
- gtkpack_(Gtk2::VBox->new,
- 1, gtkadd(gtkcreate_frame(N("DNS servers")),
- gtkpack(Gtk2::VBox->new(0,0),
- Gtk2::Label->new($intf->{dns1} || $net->{resolv}{dnsServer}),
- if_($intf->{dns2} || $net->{resolv}{dnsServer2},
- Gtk2::Label->new($intf->{dns2} || $net->{resolv}{dnsServer2})),
- if_($intf->{dns3} || $net->{resolv}{dnsServer3},
- Gtk2::Label->new($intf->{dns3} || $net->{resolv}{dnsServer3}))),
- ),
- 1, gtkadd(gtkcreate_frame(N("Search Domain")),
- Gtk2::Label->new($intf->{domain} || $net->{resolv}{DOMAINNAME} || 'none'),
- ),
+ gtknew('Title2', label => N("DNS servers")),
+ gtknew('Label_Left', text => join(', ', grep { $_ } $intf->{dns1} || $net->{resolv}{dnsServer},
+ $intf->{dns2} || $net->{resolv}{dnsServer2},
+ $intf->{dns3} || $net->{resolv}{dnsServer3}),
+ ),
+ gtkpack(Gtk2::HBox->new(1,0),
+ gtknew('Label_Left', text => N("Search Domain")),
+ my $w2 = gtknew('Label_Left', text => $intf->{domain} || $net->{resolv}{DOMAINNAME} || 'none'),
),
);
+ $size_group->add_widget($_) foreach $w2, $gui->{intf}{BOOTPROTO}, $gui->{intf}{IPADDR}, $gui->{intf}{NETMASK}, $gui->{network}{GATEWAY};
if ($is_ethernet) {
my $proto = $gui->{intf}{BOOTPROTO};
@@ -365,18 +365,18 @@ sub build_notebook {
if ($intf->{pages}{DHCP}) {
gtkpack(gtkset_border_width($gui->{sheet}{DHCP} = Gtk2::HBox->new(0,10), 5),
gtkpack__(gtkset_border_width(Gtk2::VBox->new(0,10), 5),
- gtkpack__(Gtk2::HBox->new,
- Gtk2::Label->new(N("DHCP client")),
- gtksignal_connect($gui->{intf}{DHCP_CLIENT} = Gtk2::ComboBox->new_with_strings(\@network::ethernet::dhcp_clients,
- $intf->{DHCP_CLIENT} || $network::ethernet::dhcp_clients[0]),
+ gtkpack__(Gtk2::HBox->new(1,0),
+ gtknew('Label_Left', text => N("DHCP client")),
+ gtksignal_connect($gui->{intf}{DHCP_CLIENT} = Gtk2::ComboBox->new_with_strings(\@network::connection::ethernet::dhcp_clients,
+ $intf->{DHCP_CLIENT} || $network::connection::ethernet::dhcp_clients[0]),
changed => $apply)),
gtksignal_connect($gui->{intf_bool}{NEEDHOSTNAME} = Gtk2::CheckButton->new(N("Assign host name from DHCP address")), toggled => $apply),
- gtkpack__(Gtk2::HBox->new,
- Gtk2::Label->new(N("DHCP host name")),
+ gtkpack__(Gtk2::HBox->new(1,0),
+ gtknew('Label_Left', text => N("DHCP host name")),
gtksignal_connect($gui->{intf}{DHCP_HOSTNAME} = Gtk2::Entry->new,
key_press_event => $apply)),
- gtkpack__(Gtk2::HBox->new,
- Gtk2::Label->new(N("DHCP timeout (in seconds)")),
+ gtkpack__(Gtk2::HBox->new(1,0),
+ gtknew('Label_Left', text => N("DHCP timeout (in seconds)")),
gtksignal_connect($gui->{intf}{DHCP_TIMEOUT} = Gtk2::Entry->new,
key_press_event => $apply)),
gtksignal_connect($gui->{intf_bool}{PEERDNS} = Gtk2::CheckButton->new(N("Get DNS servers from DHCP")), toggled => $apply),
@@ -392,6 +392,8 @@ sub build_notebook {
$gui->{intf}{DHCP_CLIENT}->set_text($intf->{DHCP_CLIENT});
$gui->{sheet}{DHCP}->set_sensitive($intf->{BOOTPROTO} eq 'dhcp');
}
+ my $size_group2 = Gtk2::SizeGroup->new('horizontal');
+ $size_group2->add_widget($_) foreach $gui->{intf}{DHCP_HOSTNAME}, $gui->{intf}{DHCP_TIMEOUT}, $gui->{intf}{DHCP_CLIENT};
if ($intf->{pages}{Wireless}) {
gtkpack(gtkset_border_width($gui->{sheet}{Wireless} = Gtk2::HBox->new(0,10), 5),
@@ -434,7 +436,7 @@ sub build_notebook {
if_($is_ethernet,
map { ($gui->{intf_bool}{$_->[0]} = gtksignal_connect(Gtk2::CheckButton->new($_->[1]),
toggled => $apply));
- } ([ "HWADDR", N("Track network card id (useful for laptops)") ],
+ } (
[ "MII_NOT_SUPPORTED", N("Network Hotplugging") ],
),
),
@@ -456,8 +458,8 @@ sub build_notebook {
key_press_event => $apply),
),
),
- gtkpack__(Gtk2::HBox->new(0,5),
- Gtk2::Label->new(N("Metric")),
+ gtkpack__(Gtk2::HBox->new(0,1),
+ gtknew('Label_Left', text => N("Metric")),
gtksignal_connect(gtkset_text($gui->{intf}{METRIC} = Gtk2::Entry->new, $intf->{METRIC}),
key_press_event => $apply)),
@@ -468,7 +470,6 @@ sub build_notebook {
$speed_radio[1]->signal_connect(toggled => sub { $gui->{intf_radio}{speed} = '128'; $apply->() });
$gui->{intf_bool}{ONBOOT}->set_active($intf->{ONBOOT} eq 'yes' ? 1 : 0);
$gui->{intf_bool}{MII_NOT_SUPPORTED}->set_active($intf->{MII_NOT_SUPPORTED} eq 'no' ? 1 : 0);
- $gui->{intf_bool}{HWADDR}->set_active($intf->{HWADDR});
}
if ($intf->{pages}{Account}) {
@@ -576,7 +577,7 @@ sub build_notebook {
if ($intf->{pages}{Information}) {
my ($info) = $gui->{description} ?
- find { $_->{description} eq $gui->{description} } detect_devices::probeall : network::ethernet::mapIntfToDevice($interface_name);
+ find { $_->{description} eq $gui->{description} } detect_devices::probeall : network::connection::ethernet::mapIntfToDevice($interface_name);
my @intfs = grep { $interface_name eq $_->[0] } @all_cards;
if (is_empty_hash_ref($info) && @intfs == 1) {
my $driver = $intfs[0][1];
@@ -666,7 +667,6 @@ sub save_notebook {
$gui->{intf_radio}{$_} and $intf->{$_} = $gui->{intf_radio}{$_} foreach keys %{$gui->{intf_radio}};
$intf->{$_} = bool2yesno($gui->{intf_bool}{$_}->get_active) foreach keys %{$gui->{intf_bool}};
$gui->{intf_bool}{MII_NOT_SUPPORTED} and $intf->{MII_NOT_SUPPORTED} = bool2yesno(!$gui->{intf_bool}{MII_NOT_SUPPORTED}->get_active);
- $gui->{intf_bool}{HWADDR} and (bool2yesno($gui->{intf_bool}{HWADDR}->get_active) eq 'yes' ? ($intf->{HWADDR} = 'yes') : delete $intf->{HWADDR});
if (my $proto = $gui->{intf}{BOOTPROTO}) {
$intf->{BOOTPROTO} = { reverse %{$proto->{protocols}} }->{$proto->get_text};
@@ -681,6 +681,10 @@ sub save_notebook {
return 0;
}
}
+
+ delete $intf->{IPADDR} if $intf->{IPADDR} eq N("No IP");
+ delete $intf->{NETMASK} if $intf->{NETMASK} eq N("No Mask");
+
if ($net->{network}{GATEWAY} && !is_ip($net->{network}{GATEWAY})) {
$in->ask_warn(N("Error"), N("Gateway address should be in format 1.2.3.4"));
return 0;
@@ -691,6 +695,7 @@ sub save_notebook {
sub add_intf() {
$::isWizard = 1;
network::netconnect::safe_main($net, $in, $modules_conf);
+ $modules_conf->write;
$in->exit(0);
}
@@ -700,8 +705,8 @@ sub del_intf() {
$in->ask_warn(N("Error"), N("No ethernet network adapter has been detected on your system. Please run the hardware configuration tool."));
$in->exit(0);
}
- @all_cards = network::ethernet::get_eth_cards($modules_conf);
- my %ethernet_names = network::ethernet::get_eth_cards_names(@all_cards);
+ @all_cards = network::connection::ethernet::get_eth_cards($modules_conf);
+ my %ethernet_names = network::connection::ethernet::get_eth_cards_names(@all_cards);
require wizards;
my $wiz = wizards->new(
{
@@ -736,6 +741,7 @@ sub del_intf() {
}
};
$failure = $@;
+ network::network::reload_net_applet();
return "end";
},
},
@@ -772,7 +778,7 @@ my %intf;
sub update_list {
my ($modules_conf) = @_;
- @all_cards = network::ethernet::get_eth_cards($modules_conf);
+ @all_cards = network::connection::ethernet::get_eth_cards($modules_conf);
my %new_intf = map { @$_ } @all_cards;
my @new_intf = sort keys %new_intf;
foreach my $interface (difference2(\@new_intf, [ keys %intf ])) {
@@ -913,7 +919,7 @@ Configure them first by clicking on 'Configure'")));
if (-e "/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");
+ system("/sbin/if" . (ethisup($interface) ? "down" : "up") . " $interface");
$_[0]->set_label(get_intf_status($interface));
update();
});
@@ -944,7 +950,7 @@ Configure them first by clicking on 'Configure'")));
if ($net->{ifcfg}{$interface}{BOOTPROTO} ne "static") {
delete @{$net->{ifcfg}{$interface}}{qw(IPADDR NETWORK NETMASK BROADCAST)};
} else {
- if ($infos[1]->get_text ne "No ip") {
+ if ($infos[1]->get_text ne N("No IP")) {
$net->{ifcfg}{$interface}{IPADDR} = $infos[1]->get_text;
$net->{ifcfg}{$interface}{NETMASK} = $infos[3]->get_text;
}
@@ -966,7 +972,7 @@ Configure them first by clicking on 'Configure'")));
sub configure_net() {
- my $dialog = ugtk2->new('drakconnect');
+ my $dialog = ugtk2->new(N("Internet connection configuration"));
my $exit_dialogsub = sub { Gtk2->main_quit };
if (!$net->{type}) {
$in->ask_warn(
@@ -978,7 +984,6 @@ Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a ne
}
unless ($::isEmbedded) {
$dialog->{rwindow}->set_position('center');
- $dialog->{rwindow}->set_title(N("Internet connection configuration"));
$dialog->{rwindow}->set_size_request(-1, -1);
$dialog->{rwindow}->set_icon(gtkcreate_pixbuf("drakconnect"));
}
@@ -1007,7 +1012,7 @@ Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a ne
}
$infos[2*$i+1]->set_text(${$_->[1]});
$i++;
- [ $_->[0], $c ];
+ [ Gtk2::WrappedLabel->new($_->[0]), $c ];
} @conf_data
)
);
@@ -1016,11 +1021,11 @@ Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a ne
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::Label->new(N("Connection type: ")),
- Gtk2::Label->new(translate($net->{type})) ],
+ [ Gtk2::WrappedLabel->new(N("Connection type: ")),
+ Gtk2::WrappedLabel->new(translate($net->{type})) ],
[ $int_label, $int_name ],
- [ Gtk2::Label->new(N("Status:")),
- $int_state = Gtk2::Label->new(N("Testing your connection...")) ]
+ [ Gtk2::WrappedLabel->new(N("Status:")),
+ $int_state = Gtk2::WrappedLabel->new(N("Testing your connection...")) ]
),
5),
),