From 12fe3dab20c8ceb6a8ad207e17d041efae68dc80 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 19 May 2012 10:12:04 -0700 Subject: [PATCH] Some solaris ui-libification --- mount/solaris-lib.pl | 122 ++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 65 deletions(-) diff --git a/mount/solaris-lib.pl b/mount/solaris-lib.pl index b5a2f2c0d..8e7e74d90 100755 --- a/mount/solaris-lib.pl +++ b/mount/solaris-lib.pl @@ -414,56 +414,52 @@ return ($_[0] eq "nfs" || $_[0] eq "tmpfs" || $_[0] eq "cachefs" || # Output HTML for editing the mount location of some filesystem. sub generate_location { -if ($_[0] eq "nfs") { +local ($type, $loc) = @_; +if ($type eq "nfs") { # NFS mount from some host and directory - if ($_[1] =~ /^nfs:/) { $nfsmode = 2; } - elsif (!$_[1] || $_[1] =~ /^([A-z0-9\-\.]+):([^,]+)$/) { + local ($nfsmode, $nfshost, $nfspath); + if ($loc =~ /^nfs:/) { $nfsmode = 2; } + elsif (!$loc) { + $nfsmode = 0; + } + elsif ($loc =~ /^([A-z0-9\-\.]+):([^,]+)$/) { $nfsmode = 0; $nfshost = $1; $nfspath = $2; } else { $nfsmode = 1; } if ($gconfig{'os_version'} >= 2.6) { # Solaris 2.6 can list multiple NFS servers in mount - print " $text{'solaris_nsource'}\n"; - printf "\n", - $nfsmode == 0 ? "checked" : ""; - print "$text{'solaris_nhost'}\n"; - print "\n"; - print &nfs_server_chooser_button("nfs_host"); - print " $text{'solaris_ndir'}\n"; - print "\n"; - print &nfs_export_chooser_button("nfs_host", "nfs_dir"); - print " \n"; + local @opts; + push(@opts, [ 0, $text{'solaris_nhost'}, + &ui_textbox("nfs_host", $nfshost, 30). + &nfs_server_chooser_button("nfs_host"). + " ". + "".$text{'solaris_ndir'}." ". + &ui_textbox("nfs_dir", $nfspath, 30). + &nfs_export_chooser_button("nfs_host", "nfs_dir") ]); - print " \n"; - printf "\n", - $nfsmode == 1 ? "checked" : ""; - print "$text{'solaris_nmult'}\n"; - printf "\n", - $nfsmode == 1 ? $_[1] : ""; - print " \n"; + push(@opts, [ 1, $text{'solaris_nmult'}, + &ui_textbox("nfs_list", + $nfsmode == 1 ? $loc : "", 40) ]); if ($gconfig{'os_version'} >= 7) { - print " \n"; - printf "\n", - $nfsmode == 2 ? "checked" : ""; - print "$text{'solaris_webnfs'} \n"; - printf "\n", - $nfsmode == 2 ? $_[1] : ""; - print " \n"; + push(@opts, [ 2, $text{'solaris_webnfs'}, + &ui_textbox("nfs_url", + $nfsmode == 2 ? $loc : "", 40) ]); } + print &ui_table_row($text{'solaris_nsource'}, + &ui_radio_table("nfs_serv", $nfsmode, \@opts)); } else { - print " $text{'solaris_nhost'}\n"; - print "\n"; - print &nfs_server_chooser_button("nfs_host"); - print "\n"; - print "$text{'solaris_ndir'}\n"; - print "\n"; - print &nfs_export_chooser_button("nfs_host", "nfs_dir"); - print " \n"; + print &ui_table_row($text{'solaris_nhost'}, + &ui_textbox("nfs_host", $nfshost, 30). + &nfs_server_chooser_button("nfs_host"). + " ". + "".$text{'solaris_ndir'}." ". + &ui_textbox("nfs_dir", $nfspath, 30). + &nfs_export_chooser_button("nfs_host", "nfs_dir")); } } -elsif ($_[0] eq "tmpfs" || $_[0] eq "xmemfs") { +elsif ($type eq "tmpfs" || $type eq "xmemfs") { # Location is irrelevant for tmpfs and xmemfs filesystems } elsif ($_[0] eq "ufs") { @@ -598,42 +594,38 @@ elsif ($_[0] eq "pcfs") { } elsif ($_[0] eq "lofs") { # Mounting some directory to another location - print " $text{'solaris_orig'}\n"; - print "\n"; - print &file_chooser_button("lofs_src", 1); - print " \n"; + print &ui_table_row($text{'solaris_orig'}, + &ui_textbox("lofs_src", 40, $loc)." ". + &file_chooser_button("lofs_src", 1)); } -elsif ($_[0] eq "cachefs") { +elsif ($type eq "cachefs") { # Mounting a cached filesystem of some type.. need a location for # the source of the mount - print " $text{'solaris_cache'}\n"; - print " \n"; + print &ui_table_row($text{'solaris_cache'}, + &ui_textbox("cfs_src", 40, $loc)); } -elsif ($_[0] eq "autofs") { +elsif ($type eq "autofs") { # An automounter entry.. can be -hosts, -xfn or from some mapping - print " $text{'solaris_automap'}\n"; - printf "\n", - $_[1] eq "-hosts" || $_[1] eq "-xfn" ? "" : "checked"; - printf "Use map
\n", - $_[1] eq "-hosts" || $_[1] eq "-xfn" ? "" : $_[1]; - printf "\n", - $_[1] eq "-hosts" ? "checked" : ""; - print "$text{'solaris_autohosts'}
\n"; - printf "\n", - $_[1] eq "-xfn" ? "checked" : ""; - print "$text{'solaris_autoxfn'} \n"; + local $mode = $loc eq "-hosts" ? 1 : + $loc eq "-xfn" ? 2 : 0; + print &ui_table_row($text{'solaris_automap'}, + &ui_radio_table("autofs_type", $mode, + [ [ 0, $text{'linux_map'}, + &ui_textbox("autofs_map", 30, $mode == 0 ? $loc : "") ], + [ 1, $text{'solaris_autohosts'} ], + [ 2, $text{'solaris_autoxfn'} ] ])); } -elsif ($_[0] eq "rumba") { +elsif ($type eq "rumba") { # Windows filesystem - $_[1] =~ /^\\\\(.*)\\(.*)$/; - print " $text{'solaris_server'}\n"; - print "\n"; - print &smb_server_chooser_button("rumba_server"); - print "\n"; - print "$text{'solaris_share'}\n"; - print "\n"; - print &smb_share_chooser_button("rumba_server", "rumba_share"); - print " \n"; + local ($server, $share) = $loc =~ /^\\\\([^\\]*)\\(.*)$/ ? + ($1, $2) : ( ); + print &ui_table_row($text{'solaris_server'}, + &ui_textbox("rumba_server", $server, 30)." ". + &smb_server_chooser_button("rumba_server")." ". + " ". + "$text{'solaris_share'} ". + &ui_textbox("rumba_share", $share, 30)." ". + &smb_share_chooser_button("rumba_server", "rumba_share")); } }