summaryrefslogtreecommitdiffstats
path: root/lib/network/drakconnect
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2008-03-14 12:02:02 +0000
committerOlivier Blin <oblin@mandriva.com>2008-03-14 12:02:02 +0000
commit1fa34a312c4f561564d0ac9b659afebefb14ae96 (patch)
treeb7d1252ff82d2fc5bc097432ccaadd59d4bfbd7e /lib/network/drakconnect
parent4547391eb2c19474eb8960c9e2ad20508a9a400c (diff)
downloaddrakx-net-1fa34a312c4f561564d0ac9b659afebefb14ae96.tar
drakx-net-1fa34a312c4f561564d0ac9b659afebefb14ae96.tar.gz
drakx-net-1fa34a312c4f561564d0ac9b659afebefb14ae96.tar.bz2
drakx-net-1fa34a312c4f561564d0ac9b659afebefb14ae96.tar.xz
drakx-net-1fa34a312c4f561564d0ac9b659afebefb14ae96.zip
- split --internet part in network::drakconnect::global
- move common function in network::drakconnect
Diffstat (limited to 'lib/network/drakconnect')
-rw-r--r--lib/network/drakconnect/.perl_checker1
-rw-r--r--lib/network/drakconnect/global.pm108
2 files changed, 109 insertions, 0 deletions
diff --git a/lib/network/drakconnect/.perl_checker b/lib/network/drakconnect/.perl_checker
new file mode 100644
index 0000000..80deab8
--- /dev/null
+++ b/lib/network/drakconnect/.perl_checker
@@ -0,0 +1 @@
+Basedir ../../..
diff --git a/lib/network/drakconnect/global.pm b/lib/network/drakconnect/global.pm
new file mode 100644
index 0000000..746f717
--- /dev/null
+++ b/lib/network/drakconnect/global.pm
@@ -0,0 +1,108 @@
+package network::drakconnect::global;
+
+use ugtk2 qw(:create :dialogs :helpers :wrappers);
+use mygtk2 qw(gtknew);
+use common;
+use network::drakconnect;
+use network::test;
+
+my $net_test;
+sub update_network_status {
+ my ($int_state) = @_;
+ unless ($net_test) {
+ $net_test = network::test->new;
+ $net_test->start;
+ }
+ if ($net_test->is_done) {
+ my $isconnected = $net_test->is_connected;
+ $int_state->set($isconnected ? N("Connected") : N("Not connected"));
+ $net_test->start;
+ }
+ 1;
+}
+
+sub configure_net {
+ my ($in, $net) = @_;
+ 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 $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;
+ }
+ network::drakconnect::apply();
+ $exit_dialogsub->();
+ }),
+ ),
+ ),
+ );
+
+ $dialog->{rwindow}->show_all;
+ my $update = sub { update_network_status($int_state) };
+ $update->();
+ Glib::Timeout->add(2000, $update);
+ $dialog->main;
+ ugtk2->exit(0);
+}
+
+1;