[PC-BSD Commits] r20116 - in pcbsd/branches/9.1/src-qt4: libpcbsd pc-netmanager/src/wificonfig

svn at pcbsd.org svn at pcbsd.org
Sat Nov 3 22:56:00 PDT 2012


Author: kris
Date: 2012-11-04 05:56:00 +0000 (Sun, 04 Nov 2012)
New Revision: 20116

Modified:
   pcbsd/branches/9.1/src-qt4/libpcbsd/netif.cpp
   pcbsd/branches/9.1/src-qt4/libpcbsd/utils.cpp
   pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp
   pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.h
   pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.ui
Log:

MFC the fixes to country-code support for the wifi utility

MFC the fixes also to libpcbsd to support this 



Modified: pcbsd/branches/9.1/src-qt4/libpcbsd/netif.cpp
===================================================================
--- pcbsd/branches/9.1/src-qt4/libpcbsd/netif.cpp	2012-11-04 05:54:40 UTC (rev 20115)
+++ pcbsd/branches/9.1/src-qt4/libpcbsd/netif.cpp	2012-11-04 05:56:00 UTC (rev 20116)
@@ -557,7 +557,7 @@
 void NetworkInterface::enableLagg(QString dev)
 {
   // Get the first wired device, we will enable lagg0 to use it
-  QString wiredDev, wifiParent, wifiConf, tmp;
+  QString wiredDev, wifiParent, wifiConf, tmp, newWifiConf;
   wiredDev = NetworkInterface::getFirstWiredDevice();
   wifiParent = NetworkInterface::getWifiParent(dev);
 
@@ -585,16 +585,36 @@
   Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + wifiParent, "ifconfig_" + wifiParent + "=\"ether ${ifconfig_" + wifiParent + "##*ether }\"", 2);
   Utils::setConfFileValue( "/etc/rc.conf", "wlans_" + wifiParent, "wlans_" + wifiParent + "=\"" + dev + "\"", -1);
 
+  wifiConf = wifiConf.simplified();
 
   // Check if we have a WPA setting, and put it in the right device slot
   if ( wifiConf.indexOf("WPA") != -1 )
   {
-    Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + dev, "ifconfig_" + dev + "=\"WPA\"", -1);
+    newWifiConf="WPA";
     wifiConf = wifiConf.replace("WPA", "");
-    wifiConf = wifiConf.simplified();
   }
 
+  // Check if we have a Country code setting, and put it in the right device slot
+  if ( wifiConf.indexOf("country ") != -1 )
+  {
+    tmp = wifiConf;
+    tmp.remove(0, tmp.lastIndexOf("country") + 8);
+    tmp = tmp.section(" ", 0,0);
+
+    newWifiConf+=" country " + tmp;
+    wifiConf = wifiConf.remove(wifiConf.indexOf("country"), wifiConf.indexOf("country") + 10 );
+  }
+
+
+  // Save the new wifi config line
+  newWifiConf = newWifiConf.simplified();
+  Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + dev, "ifconfig_" + dev + "=\"" + newWifiConf + "\"", -1);
+
+  // Set the wired device to UP
+  Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + wiredDev, "ifconfig_" + wiredDev + "=\"UP\"", -1);
+
   // Enable the lagg0 interface
+  wifiConf = wifiConf.simplified();
   Utils::setConfFileValue( "/etc/rc.conf", "cloned_interfaces", "cloned_interfaces=\"lagg0\"", -1);
   Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_lagg0", "ifconfig_lagg0=\"laggproto failover laggport " + wiredDev + " laggport " + dev + " " + wifiConf + "\"", -1);
 

Modified: pcbsd/branches/9.1/src-qt4/libpcbsd/utils.cpp
===================================================================
--- pcbsd/branches/9.1/src-qt4/libpcbsd/utils.cpp	2012-11-04 05:54:40 UTC (rev 20115)
+++ pcbsd/branches/9.1/src-qt4/libpcbsd/utils.cpp	2012-11-04 05:56:00 UTC (rev 20116)
@@ -645,7 +645,6 @@
        if (dev.indexOf("lo") == 0 
            || dev.indexOf("fwe") == 0 
            || dev.indexOf("ipfw") == 0
-           || dev.indexOf("lagg") == 0
            || dev.indexOf("plip") == 0
            || dev.indexOf("pfsync") == 0
            || dev.indexOf("pflog") == 0

Modified: pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp
===================================================================
--- pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp	2012-11-04 05:54:40 UTC (rev 20115)
+++ pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp	2012-11-04 05:56:00 UTC (rev 20116)
@@ -14,6 +14,7 @@
 #include <QTextStream>
 #include <QDebug>
 #include <QInputDialog>
+#include <QXmlStreamReader>
 
 #include <pcbsd-utils.h>
 #include <pcbsd-netif.h>
@@ -68,6 +69,14 @@
 	ifConfigLine="SYNCDHCP";
     } 
 
+    // See if we need to enable a country code
+    if ( groupCountryCode->isChecked() )
+    {
+       tmp = comboCountryCode->currentText().section("(", 1, 1);
+       tmp = tmp.section(")", 0, 0);
+       ifConfigLine+=" country " + tmp;
+    }
+
     // Now create the wpa_supplicant file based on saved configuration
     updateWPASupp();
 
@@ -240,6 +249,7 @@
   connect( pushRescan, SIGNAL( clicked() ), this, SLOT( slotRescan() ) );
   connect( pushAddHidden, SIGNAL( clicked() ), this, SLOT( slotAddHiddenProfile() ) );
   connect( checkDHCP, SIGNAL( clicked() ), this, SLOT( slotCheckDHCPBox() ) );
+  connect( groupCountryCode, SIGNAL( clicked() ), this, SLOT( slotCheckGlobalText() ) );
 
   // Save the device name for later
   DeviceName = Device;
@@ -257,10 +267,49 @@
  
   //Load the available wifi access points
   slotRescan();
-  
+
 }
 
+void wificonfigwidgetbase::loadCountryCodes()
+{
+  QFile file("/etc/regdomain.xml");
+  if (!file.open(QFile::ReadOnly | QFile::Text))
+  return;
 
+  QXmlStreamReader reader;
+  QString code, name;
+  int comboNum = 0;
+
+  reader.setDevice(&file);
+  reader.readNext();
+  while (!reader.atEnd()) {
+      if (reader.isStartElement()) {
+          if (reader.name() == "country") {
+	     name="";
+	     code = reader.attributes().value("id").toString();
+             while (!reader.atEnd()) {
+                 if (reader.isEndElement() && reader.name() == "country")
+		    break;
+                 if (reader.isStartElement() && reader.name() == "name") {
+	   	    name = reader.readElementText();
+	         }
+                 reader.readNext();
+             }
+	     if ( !name.isEmpty() && !code.isEmpty() && code != "DEBUG" )
+		comboCountryCode->addItem(name + " (" + code.toLower() + ")" );
+   	     if ( Country == code.toLower() )
+	        comboCountryCode->setCurrentIndex(comboNum);
+
+             comboNum++;
+	  }
+      }
+      reader.readNext();
+  }
+
+  // Now if we change index, enable Apply Button
+  connect( comboCountryCode, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotCheckGlobalText() ) );
+}
+
 void wificonfigwidgetbase::slotRescan()
 {
     QString strength, ssid, security, FileLoad;
@@ -1055,11 +1104,13 @@
    } else {
      // Look for an IP configuration
      tmp2 = tmp;
+     tmp2 = tmp2.simplified();
 
      if ( tmp.indexOf("laggport") != -1 )
        tmp2.remove(0, tmp2.lastIndexOf("laggport") + 9);
 
-     tmp2 = tmp2.simplified();
+     if ( tmp.indexOf("country") != -1 )
+       tmp2.remove(0, tmp2.lastIndexOf("country") + 10);
 
      if ( tmp.indexOf("WPA") == 0)
        tmp2.remove(0, tmp2.indexOf(" ") + 1);
@@ -1086,6 +1137,13 @@
       }
    }
    
+   // Look for a country code
+   tmp = Utils::getConfFileValue( "/etc/rc.conf", "ifconfig_" + DeviceName + "=", 1 );
+   if ( tmp.indexOf("country ") != -1 ) {
+       tmp.remove(0, tmp.lastIndexOf("country") + 8);
+       Country = tmp.section(" ", 0,0);
+       groupCountryCode->setChecked(true);
+   }
 
    // Look for the wpa_supplicant.conf file
    QFile file( "/etc/wpa_supplicant.conf" );
@@ -1253,6 +1311,10 @@
 
    // Refresh the ssid profile list
    slotRefreshSSIDList();  
+
+   // Load the list of country codes we can set
+   loadCountryCodes();
+
    
    // Start loading the info tab
    loadInfo();

Modified: pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.h
===================================================================
--- pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.h	2012-11-04 05:54:40 UTC (rev 20115)
+++ pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.h	2012-11-04 05:56:00 UTC (rev 20116)
@@ -10,7 +10,6 @@
 #include "wifiselectiondialog.h"
 #include "wepconfig.h"
 #include "dialogwpapersonal.h"
-#include "dialogwpaenterprise.h"
 #include "ui_wificonfigwidgetbase.h"
 #include <QProcess>
 
@@ -71,7 +70,6 @@
     void slotWPAPSave(QString newkey);
 
 private:
-    void runCommand( QString Command );
     QString getLineFromCommandOutput( QString command );
     QString getNetmaskForIdent( QString ident );
     QString getOutErrorsForIdent( QString ident );
@@ -86,8 +84,11 @@
     QString getGatewayForIdent( QString ident );
     QString getMediaForIdent( QString ident );
     QString getWifiParent( QString dev );
+    void loadCountryCodes();
+    void runCommand( QString Command );
     void updateWPASupp();
     QString DeviceName;
+    QString Country;
     
     dialogWPAPersonal *dialogWPA;
     wepConfig *dialogWEP;

Modified: pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.ui
===================================================================
--- pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.ui	2012-11-04 05:54:40 UTC (rev 20115)
+++ pcbsd/branches/9.1/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.ui	2012-11-04 05:56:00 UTC (rev 20116)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>382</width>
-    <height>427</height>
+    <width>397</width>
+    <height>457</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -407,6 +407,24 @@
         </layout>
        </item>
        <item>
+        <widget class="QGroupBox" name="groupCountryCode">
+         <property name="title">
+          <string>Set Country Code</string>
+         </property>
+         <property name="checkable">
+          <bool>true</bool>
+         </property>
+         <property name="checked">
+          <bool>false</bool>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_4">
+          <item row="0" column="0">
+           <widget class="QComboBox" name="comboCountryCode"/>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
         <spacer name="spacer7">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
@@ -828,7 +846,6 @@
   <include location="local">qmessagebox.h</include>
   <include location="local">wepconfig.h</include>
   <include location="local">dialogwpapersonal.h</include>
-  <include location="local">dialogwpaenterprise.h</include>
   <include location="local">qdesktopwidget.h</include>
   <include location="local">qapplication.h</include>
   <include location="global">pcbsd-netif.h</include>



More information about the Commits mailing list