#!/bin/sh
#rcrsn51 2014-06-22

eval_gettext () {
  local myMESSAGE=$(gettext "$1")
  eval echo -n \"$myMESSAGE\"
}
export -f eval_gettext

export TEXTDOMAIN=peasywifi
export OUTPUT_CHARSET=UTF-8

CHECKINTERFACE () {
  ifconfig $INTERFACE up
  if [ $? -eq 0 ]; then
    return 0
  else
   Xdialog --title " " --msgbox "$(eval_gettext 'Interface $INTERFACE is NOT active!')" 0 0
   return 1
  fi 
}
export -f CHECKINTERFACE

DOCONNECT () {
  CHECKINTERFACE
  [ $? -gt 0 ] && exit

  Xdialog --title " " --no-buttons --infobox "Connecting ..." 4 20 120000 &
  MSGPID=$!
  
  killall wpa_supplicant
  rm -f /var/run/wpa_supplicant/*
  wpa_supplicant -i $INTERFACE -D $DRIVER -c /tmp/wpa_supplicant.conf -d -B
  sleep $TIMEOUT
  killall dhcpcd
  rm -f /var/lib/dhcpcd/*.info
  rm -f /var/run/*.pid
  dhcpcd -t $((TIMEOUT+20)) -h $(hostname) $OPTION -d $INTERFACE
  RETVAL=$?

  kill $MSGPID
  if [ $RETVAL -eq 0 ]; then 
    Xdialog --title " " --rc-file /usr/local/peasywifi/green.rc --no-buttons --infobox "$(gettext 'WiFi connected.')" 4 25 3000
  else
    Xdialog --title " " --msgbox "$(gettext 'Connection failed!')" 0 0  
  fi

  rm /tmp/wpa_supplicant.conf 
}
export -f DOCONNECT

CONNECT () {

  if [ ! -f ${PROFILEPATH}/${PROFILE}.conf ]; then
    Xdialog --title " " --msgbox "$(gettext 'Profile not found!')" 0 0
    exit
  fi

  if [ -n "$PIN" -a ! -f ${PROFILEPATH}/${PROFILE}.conf.psk.bfe ]; then
    Xdialog --title " " --msgbox "$(gettext 'Encrypted passphrase not found!')" 0 0
    exit
  fi

  if [ -z "$PIN" -a -f ${PROFILEPATH}/${PROFILE}.conf.psk.bfe ]; then 
    Xdialog --title " " --msgbox "$(gettext 'Missing PIN!')" 0 0
    exit
  fi

  if [ -z "$PIN" ]; then
    cp ${PROFILEPATH}/${PROFILE}.conf /tmp/wpa_supplicant.conf
  else
    PASSPHRASE=$(echo $PIN$PIN | bcrypt -o ${PROFILEPATH}/${PROFILE}.conf.psk.bfe )
    if [ $? -gt 0 ]; then
      Xdialog --title " " --msgbox "$(gettext 'Wrong PIN!')" 0 0
      exit
    fi
    sed "s/secret/$PASSPHRASE/" ${PROFILEPATH}/${PROFILE}.conf  > /tmp/wpa_supplicant.conf
  fi

  DOCONNECT
}
export -f CONNECT

DISCONNECT () {
  CHECKINTERFACE
  [ $? -gt 0 ] && exit

  ifconfig $INTERFACE down
  killall -9 wpa_supplicant
  rm -f /var/run/wpa_supplicant/*
  killall -9 dhcpcd
  rm -f /var/lib/dhcpcd/*.info
  rm -f /var/run/*.pid
  rm -f /var/db/dhcpcd-${INTERFACE}.lease
  rm -f /var/lib/dhcpcd/dhcpcd-${INTERFACE}.lease
  Xdialog --title " " --no-buttons --infobox "$(gettext 'WiFi disconnected.')" 4 25 3000
}
export -f DISCONNECT

ENCRYPT () {
  if [ -z "$ENCPROFILE" -o -z "$ENCPASSPHRASE" -o -z "$ENCPIN" ]; then
    Xdialog --title " " --msgbox "$(gettext 'Missing data!')" 0 0
    exit
  fi

  grep -q "secret" ${PROFILEPATH}/${ENCPROFILE}.conf
  if [ $? -gt 0 ]; then 
    Xdialog --title "$(gettext 'Check the profile!')" --msgbox "$(gettext 'The psk value must be "secret"')" 0 0
    exit
  fi

  TESTPIN=$(echo -n $ENCPIN | tr -dc "[:alnum:]")
  if [ "$TESTPIN" != "$ENCPIN" ]; then 
    Xdialog --title " " --msgbox "$(gettext 'Not a valid PIN!')" 0 0
    exit
  fi

  if [ ${#ENCPIN} -lt 4 ]; then 
    Xdialog --title " " --msgbox "$(gettext 'The PIN is too short!')" 0 0
    exit
  fi
    
  echo -n "$ENCPASSPHRASE" > ${PROFILEPATH}/${ENCPROFILE}.conf.psk
  echo -e "$ENCPIN$ENCPIN\n$ENCPIN$ENCPIN" | bcrypt ${PROFILEPATH}/${ENCPROFILE}.conf.psk
  Xdialog --title " " --no-buttons --infobox "$(gettext 'Encryption completed.')" 4 30 3000
}
export -f ENCRYPT

HELP () {
  Xdialog --left --wrap --title "peasywifi" --msgbox "$(gettext 'Initial Configuration:\n  Click the Config button.\n  (this opens the hidden file /root/.peasywifi in a text editor)\n  Set the name of your WiFi INTERFACE. (Click I/F to find it)\n  Change the driver only if necessary.\n  Change the path to your WiFi profiles if necessary.\n\nIncrease the TIMEOUT if you have trouble connecting, or decrease it to speed up connection.\n\nIf your WiFi card requires drop waiting, insert an argument like "-j 15" into OPTION.\n\nTo build a WiFi connection profile, use Profile. Use Search to find a network SSID name. Click View to see the profiles folder.\n\nYou can hide your WiFi passphrase by storing it in an encrypted file. You unlock the file with a PIN. In each secure profile, change the PSK value to "secret".\n\nPeasyWifi can auto-connect to an access point at bootup. Click Auto and select a profile. Click On/Off to enable/disable the procedure. Look for the file /root/Startup/peasywifi_auto.\n\nHere is a hint for using public WiFi. If your browser`s home page is set to a secure site, like https://google.ca, you may have trouble connecting to the WiFi server. If so, select the address of an unencrypted site, like cbc.ca.\n')" 0 70 
}
export -f HELP

VIEW () {
  rox $PROFILEPATH
}
export -f VIEW

SCAN () {

CHECKINTERFACE
[ $? -gt 0 ] && exit

Xdialog --title " " --no-buttons --infobox "Scanning ..." 4 20 120000 &
MSGPID=$!

iwlist $INTERFACE scan | grep -E "ESSID|Encryption"> /tmp/iwlist.dat
kill $MSGPID

rm -f /tmp/openlist.dat
while read L1; do
  read L2
  echo $L1 $L2 >> /tmp/openlist.dat
done < /tmp/iwlist.dat

grep ":off" /tmp/openlist.dat | cut -d \" -f 2 | sort | uniq > /tmp/ssidlist.dat

COMBOLIST=""
while read L; do
  [ -n "$L" ] && COMBOLIST=$COMBOLIST"<item>"$L"</item>"
done < /tmp/ssidlist.dat

export DIALOG="
<window title=\"peasywifi\">
<vbox>
  <frame $(gettext 'Open networks')>
    <combobox>
      <variable>OPENSSID</variable>
        $COMBOLIST
    </combobox>
  </frame>
  <hbox>
    <button><label>$(gettext 'Connect')</label></button>
    <button><label>$(gettext 'Save')</label></button>
    <button><label>$(gettext 'Cancel')</label></button>
  </hbox>
</vbox>
</window>
"

I=$IFS; IFS=""
for STATEMENTS in  $(gtkdialog3 -c -p DIALOG); do
  eval $STATEMENTS
done
IFS=$I

[ "$EXIT" = "$(gettext 'Cancel')" -o "$EXIT" = "abort" -o -z "$OPENSSID" ] && exit

cat > /tmp/wpa_supplicant.conf  << EOF
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1
network={
ssid="$OPENSSID"
key_mgmt=NONE
}
EOF

if [ "$EXIT" = "$(gettext 'Save')" ]; then
  COPENSSID=$(echo -n $OPENSSID | tr -dc "[:alnum:]")
  cp /tmp/wpa_supplicant.conf ${PROFILEPATH}/${COPENSSID}.conf
  Xdialog --title " " --msgbox "$(eval_gettext 'A profile for $OPENSSID has been saved.\nYou must restart PeasyWiFi to select it.')" 0 0
fi

DOCONNECT
}
export -f SCAN

WRITEWPA () {
cat > /tmp/wpa_supplicant.conf  << EOF
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1
network={
ssid="new_ssid"
scan_ssid=1
psk="new_psk"
proto=WPA
key_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP
}
EOF
}
export -f WRITEWPA

WRITEWPA2 () {
cat > /tmp/wpa_supplicant.conf  << EOF
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1
network={
ssid="new_ssid"
scan_ssid=1
psk="new_psk"
proto=WPA2
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
}
EOF
}
export -f WRITEWPA2

WRITEOPEN () {
cat > /tmp/wpa_supplicant.conf  << EOF
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1
network={
ssid="new_ssid"
key_mgmt=NONE
}
EOF
}
export -f WRITEOPEN

WRITEWEP () {
cat > /tmp/wpa_supplicant.conf  << EOF
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1
network={
ssid="new_ssid"
key_mgmt=NONE
wep_key0=new_psk
wep_tx_keyidx=0
}
EOF
}
export -f WRITEWEP

WRITEPEAP () {
cat > /tmp/wpa_supplicant.conf  << EOF
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1 
network={
ssid="new_ssid"
identity="my_identity"
password="my_password"
key_mgmt=WPA-EAP
eap=PEAP
#ca_cert="/path/to/certificate"
#phase1="peaplabel=0"
phase2="auth=MSCHAPV2"
}
EOF
}
export -f WRITEPEAP

MAKE () {

if [ -z "$NEWPROFILE" ]; then
  Xdialog --title " " --msgbox "$(gettext 'Enter a profile name!')" 0 0
  exit
fi

NEWPROFILE=$(echo -n $NEWPROFILE | tr -dc "[:alnum:]")

if [ $WPA = "true" ]; then
  WRITEWPA
elif [ $WPA2 = "true" ]; then
  WRITEWPA2
elif [ $OPEN = "true" ]; then
  WRITEOPEN
elif [ $WEP = "true" ]; then
  WRITEWEP
elif [ $PEAP = "true" ]; then
  WRITEPEAP
fi

sed -i "s/new_ssid/$NEWSSID/" /tmp/wpa_supplicant.conf 
sed -i "s/new_psk/$NEWPSK/" /tmp/wpa_supplicant.conf
cp /tmp/wpa_supplicant.conf ${PROFILEPATH}/${NEWPROFILE}.conf
rm /tmp/wpa_supplicant.conf

Xdialog --title " " --msgbox "$(gettext 'New profile made.\nYou must restart PeasyWiFi to select it.')" 0 0

}
export -f MAKE

STATUS () {
  ifconfig | grep -q $INTERFACE
  if [ $? -gt 0 ]; then
    STATLINE=$(eval_gettext 'Interface $INTERFACE is NOT active.')
  else
    IP=$(ifconfig | awk "/$INTERFACE/{getline;print}" | grep inet | cut -d ":" -f 2 | cut -d " " -f 1)
    if [ -z "$IP" ]; then
      STATLINE=$(eval_gettext 'Interface $INTERFACE is NOT connected to a network.')
    else
      STATLINE="IP on "$INTERFACE": "$IP
    fi
  fi
  MODULE=$(basename $(readlink /sys/class/net/$INTERFACE/device/driver) 2>/dev/null)
  [ $? -gt 0 ] && MODULE="unknown"
  STATLINE=$STATLINE"\n\nKernel module: "$MODULE
  FIRMWARE=$(modinfo $MODULE | grep firmware | awk '{print $2}')
  [ -n "$FIRMWARE" ] && STATLINE=$STATLINE"\n\nFirmware:\n"$FIRMWARE
  RFKILL=$(rfkill list wlan | tail -n2)
  [ -n "$RFKILL" ] && STATLINE=$STATLINE"\n\nRFKill:\n"$RFKILL
  Xdialog --title " " --msgbox "$STATLINE" 0 0  
}
export -f STATUS

IFACE () {
  IFACES=$(iwconfig 2>/dev/null | grep "^[a-z]" | awk '{print $1}')
  Xdialog --title " " --msgbox "$(eval_gettext 'Your possible WiFi interface(s)\n$IFACES')" 0 0
}
export -f IFACE

DETAILS () {

[ ! -f /tmp/iwdata.dat ] && exit
grep -n -E "Cell|ESSID" /tmp/iwdata.dat > /tmp/celldata1.dat

rm -f /tmp/celldata2.dat
while read L1; do
  read L2
  echo $L1 $L2 >> /tmp/celldata2.dat
done < /tmp/celldata1.dat

LINEINFO=$(grep -A1 "$DETSSID" /tmp/celldata2.dat | cut -d ":" -f 1)
STARTLINE=$(echo -n $LINEINFO | awk '{print $1}')
ENDLINE=$(echo -n $LINEINFO | awk '{print $2}')

if [ -n "$ENDLINE" ]; then
  tail -n +$STARTLINE /tmp/iwdata.dat | head -n $((ENDLINE-STARTLINE-1)) | grep -v "Unknown" | Xdialog --title "$DETSSID" --no-cancel --textbox - 0 0
else
  tail -n +$STARTLINE /tmp/iwdata.dat | grep -v "Unknown" | Xdialog --title "$DETSSID" --no-cancel --textbox - 0 0
fi

}

export -f DETAILS

SCANALL () {

CHECKINTERFACE
[ $? -gt 0 ] && exit

Xdialog --title " " --no-buttons --infobox "Scanning ..." 4 20 120000 &
MSGPID=$!

iwlist $INTERFACE scan > /tmp/iwdata.dat
grep "ESSID" /tmp/iwdata.dat | grep -v -E "<|>" > /tmp/iwlist.dat
kill $MSGPID

cut -d \" -f 2  /tmp/iwlist.dat | sort | uniq > /tmp/ssidlist.dat

COMBOLIST=""
while read L; do
  [ -n "$L" ] && COMBOLIST=$COMBOLIST"<item>"$L"</item>"
done < /tmp/ssidlist.dat

export DIALOG="
<window title=\"peasywifi\">
<vbox>
  <frame $(gettext 'Networks')>
    <combobox>
      <variable>DETSSID</variable>
      $COMBOLIST
    </combobox>
  </frame>
  <hbox>
    <button>
      <label>$(gettext 'Details')</label>
      <action>DETAILS &</action>
    </button>
    <button><label>$(gettext 'Done')</label></button>
  </hbox>
</vbox>
</window>
"

gtkdialog3 -c -p DIALOG

}
export -f SCANALL

ETH0 () {

  Xdialog --title " " --yesno "$(gettext 'Reconnect your Ethernet port?')" 0 0
  [ $? -gt 0 ] && exit

  DISCONNECT

  Xdialog --title " " --no-buttons --infobox "Connecting ..." 4 20 120000 &
  MSGPID=$!
  dhcpcd -t $((TIMEOUT+20)) -h $(hostname) -d eth0
  RETVAL=$?

  kill $MSGPID
  if [ $RETVAL -eq 0 ]; then 
    Xdialog --title " " --rc-file /usr/local/peasywifi/green.rc --no-buttons --infobox "$(gettext 'eth0 connected.')" 4 25 3000
  else
    Xdialog --title " " --msgbox "$(gettext 'Connection failed!')" 0 0  
  fi 
}
export -f ETH0

SETAUTO () {
  case $1 in
    on) echo peasywifi $AUTOPROFILE > $STARTUPFILE
        chmod +x $STARTUPFILE
        Xdialog --title " " --no-buttons --infobox "$(eval_gettext 'Auto-connection set to $AUTOPROFILE.')" 4 45 3000        
        ;;
    off) rm -f $STARTUPFILE
         Xdialog --title " " --no-buttons --infobox "$(gettext 'Auto-connection turned off.')" 4 35 3000 
         ;;
    check) if [ -f $STARTUPFILE ]; then
             CHECKPROFILE=$(grep "^peasywifi" $STARTUPFILE | cut -d " " -f 2 )
             Xdialog --title " " --no-buttons --infobox "$(eval_gettext 'Auto-connection set to $CHECKPROFILE.')" 4 45 3000
           else
             Xdialog --title " " --no-buttons --infobox "$(gettext 'Auto-connection turned off.')" 4 35 3000
           fi
         ;;
   esac
}
export -f SETAUTO

DOCONFIG () {
  Xdialog --title " " --msgbox "$(gettext 'After changing the configuration\nyou must restart PeasyWiFi.')" 0 0
  defaulttexteditor $HOME/.peasywifi 
}
export -f DOCONFIG

NDISINSTALL () {

if [ ! -f "$INFFILE" ]; then
  Xdialog --title " " --msgbox "$(gettext 'Windows driver not found!')" 0 0
  exit
fi

CURRENTDRIVER=$(ndiswrapper -l | head -n1 | awk '{print $1}')
[ -n "$CURRENTDRIVER" ] && ndiswrapper -r $CURRENTDRIVER

ndiswrapper -i "$INFFILE"
ERR1=$?
ndiswrapper -l | grep -q "invalid"
ERR2=$?
if [ $ERR1 -gt 0 -o $ERR2 -eq 0 ]; then
  Xdialog --title " " --msgbox "$(gettext 'Windows driver NOT installed!')" 0 0
  exit
fi

ndiswrapper -m

cat > $STARTUPFILE << EOF
sleep 5 #change if needed
modprobe ndiswrapper
#peasywifi PROFILE #enable this line if auto-connecting
EOF

chmod +x $STARTUPFILE
Xdialog --title " " --msgbox "$(gettext 'Windows driver installed.\nCheck the setup file and reboot.')" 0 0
 
}
export -f NDISINSTALL

NDISHELP () {
  Xdialog --left --wrap --title "peasywifi" --msgbox "$(gettext 'Locate the two Windows driver files named xxx.inf and xxx.sys. Look on the setup CD for a folder named something like XP. Copy this folder into your Puppy filesystem.\n\n1. Click Status and check for installed kernel modules.\n2. If a module has been loaded, run System > BootManager and blacklist it.\n3. Power down.\n4. If your WiFi adapter is USB, unplug/replug it. This is important!\n5. Reboot.\n6. Click Status. If a different module has been loaded, repeat Steps 2-5.\n7. When no module is identified, install the Windows driver.\n8. Reboot.\n9. Click Status. The module should now be ndiswrapper.\n10. Scan your WiFi neighbourhood.')" 0 85
}
export -f NDISHELP

#####################

export STARTUPFILE=$HOME/Startup/peasywifi_auto

CONFIGFILE=$HOME/.peasywifi

if [ ! -f $CONFIGFILE ]; then 
  echo export INTERFACE=wlan0 > $CONFIGFILE
  echo export DRIVER=wext >> $CONFIGFILE    
  echo export PROFILEPATH=/etc/network-wizard/wireless/wpa_profiles >> $CONFIGFILE
  echo export TIMEOUT=10 >> $CONFIGFILE
  echo export OPTION=\"\" >> $CONFIGFILE 
fi

. $CONFIGFILE

if [ $# -gt 0 ]; then  # auto connect
  sleep $TIMEOUT		
  export PROFILE=$1
  [ $# -eq 2 ] && export PIN=$2
  CONNECT &
  exit
fi

PROFILELIST=""
for P in $PROFILEPATH/*.conf; do
  PP=$(basename $P ".conf")
  PROFILELIST=$PROFILELIST"<item>"$PP"</item>"
done

export DIALOG="
<window title=\"peasywifi v2.4\">
<vbox>
  <notebook labels=\"$(gettext 'Connect|Profile|Encrypt|Auto|Win')\">
    <vbox>
      <frame>
        <hbox>
          <text xalign=\"0\">
            <label>$(gettext 'Read the Help --------------> ')</label>
          </text>
          <button>
            <label>$(gettext 'Help')</label>
            <action>HELP &</action>
          </button>
         </hbox>
      </frame>
      <frame $(gettext 'Select a WiFi profile')>
        <combobox>
          <variable>PROFILE</variable>
	  $PROFILELIST
        </combobox>
      </frame>
      <frame $(gettext 'PIN (optional)')>
        <hbox>
          <entry>
            <variable>PIN</variable>
            <visible>password</visible>
          </entry>
          <button>
            <label>$(gettext 'Connect')</label>
            <action>CONNECT &</action>
            <action>Clear:PIN</action>
          </button>
          <button>
            <label>$(gettext 'Disconnect')</label>
            <action>DISCONNECT</action>
          </button>
        </hbox>
      </frame>
      <frame $(gettext 'Or connect to open networks')>
        <hbox>
          <button>
            <label>$(gettext 'Scan')</label>
            <action>SCAN &</action>
          </button>
        </hbox>
      </frame>
      <text><label>\"  \"</label></text>
    </vbox>
    <vbox>
      <frame $(gettext 'Search for networks')>
        <hbox>
          <button>
            <label>$(gettext 'Scan')</label>
            <action>SCANALL &</action>
          </button>
        </hbox>
      </frame>
      <frame $(gettext 'Make a WiFi connection profile')>
        <hbox>
          <radiobutton><label>WPA</label><variable>WPA</variable></radiobutton>
          <radiobutton><label>WPA2</label><variable>WPA2</variable></radiobutton>       
          <radiobutton><label>$(gettext 'Open')</label><variable>OPEN</variable></radiobutton>
          <radiobutton><label>WEP</label><variable>WEP</variable></radiobutton>
          <radiobutton><label>PEAP</label><variable>PEAP</variable></radiobutton>
        </hbox>
      </frame>
      <frame>
        <hbox>
          <text><label>$(gettext 'Profile Name')</label></text>
          <entry><variable>NEWPROFILE</variable></entry>
        </hbox>
        <hbox>
          <text><label>SSID             </label></text>
          <entry><variable>NEWSSID</variable></entry>
        </hbox>
        <hbox>
          <text><label>$(gettext 'Passphrase')   </label></text>
          <entry><variable>NEWPSK</variable></entry>
        </hbox>
        <hbox>
          <button>
            <label>$(gettext 'Make')</label>
            <action>MAKE</action>
          </button>
        </hbox>
      </frame>
    </vbox>
    <vbox>
      <frame $(gettext 'Select a WiFi profile')>
        <combobox>
          <variable>ENCPROFILE</variable>
	  $PROFILELIST
        </combobox>
      </frame>
      <frame $(gettext 'Passphrase (read the Help)')>
        <entry>
          <variable>ENCPASSPHRASE</variable>
        </entry>
      </frame>
      <frame $(gettext 'PIN for encryption (4 or more letters/digits)')>
        <hbox>
          <entry>
            <variable>ENCPIN</variable>
          </entry>
          <button>
            <label>$(gettext 'Encrypt')</label>
            <action>ENCRYPT</action>
          </button>
        </hbox>
      </frame>
      <text><label>\"  \"</label></text>
      <text><label>\"  \"</label></text>
      <text><label>\"  \"</label></text>
      <text><label>\"  \"</label></text>
    </vbox>
    <vbox>
      <frame>
        <text xalign=\"0\"><label>$(gettext 'PeasyWiFi can auto-connect to an access')</label></text>
        <text xalign=\"0\"><label>$(gettext 'point at bootup.')</label></text>
      </frame>
      <frame $(gettext 'Select a WiFi profile')>
        <combobox>
          <variable>AUTOPROFILE</variable>
	  $PROFILELIST
        </combobox>
      </frame>
      <hbox>
        <button>
          <label>$(gettext 'On')</label>
          <action>SETAUTO on</action>
        </button>
        <button>
          <label>$(gettext 'Off')</label>
          <action>SETAUTO off</action>
        </button>
        <button>
          <label>$(gettext 'Check')</label>
          <action>SETAUTO check</action>
        </button>
      </hbox>
      <text><label>\"  \"</label></text>
      <text><label>\"  \"</label></text>
      <text><label>\"  \"</label></text>
      <text><label>\"  \"</label></text>
      <text><label>\"  \"</label></text>
    </vbox>
   <vbox>
      <frame>
        <text xalign=\"0\"><label>$(gettext 'This tool installs the Windows driver for')</label></text>
        <text xalign=\"0\"><label>$(gettext 'your WiFi card. You must provide the folder')</label></text>
       <text xalign=\"0\"><label>$(gettext 'containing the .inf and .sys files. The setup')</label></text>
       <text xalign=\"0\"><label>$(gettext 'is saved in /root/Startup/peasywifi_auto.')</label></text>
      </frame>
      <frame $(gettext 'Select the .inf file')>
        <hbox>
          <entry accept=\"fileselect\"><variable>INFFILE</variable></entry>
          <button>
            <input file stock=\"gtk-open\"></input>
            <action type=\"fileselect\">INFFILE</action>
          </button>
        </hbox>
      </frame>
      <hbox>
        <button>
          <label>$(gettext 'Help')</label>
          <action>NDISHELP &</action>
        </button>
        <button>
          <label>$(gettext 'Check')</label>
          <action>defaulttexteditor $STARTUPFILE &</action>
        </button>
        <button>
          <label>$(gettext 'Install')</label>
          <action>NDISINSTALL &</action>
        </button>
      </hbox>
      <text><label>\"  \"</label></text>
      <text><label>\"  \"</label></text>
      <text><label>\"  \"</label></text>
    </vbox>
  </notebook>
  <hbox>
    <button>
      <label>eth0</label>
      <action>ETH0 &</action>
    </button>
    <button>
      <label>Config</label>
      <action>DOCONFIG &</action>
    </button>
    <button>
      <label>I/F</label>
      <action>IFACE &</action>
    </button>
    <button>
      <label>$(gettext 'Status')</label>
      <action>STATUS &</action>
    </button>
    <button>
      <label>$(gettext 'View')</label>
      <action>VIEW</action>
    </button>
    <button>
      <label>$(gettext 'Abort')</label>
      <action>killall -9 dhcpcd iwlist</action>
    </button>
    <button>
      <label>$(gettext 'Quit')</label>
    </button>
  </hbox>

</vbox>
</window>
"
gtkdialog3 -p DIALOG -G -1x-1+600+50

