[PC-BSD Commits] r20115 - pcbsd/current/src-qt4/pc-netmanager/src/wificonfig
svn at pcbsd.org
svn at pcbsd.org
Sat Nov 3 22:54:40 PDT 2012
Author: kris
Date: 2012-11-04 05:54:40 +0000 (Sun, 04 Nov 2012)
New Revision: 20115
Modified:
pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp
pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.h
pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.ui
Log:
Add new "Country Codes" ability to wifi config, now user can select
from a list of country codes what they want their wifi adapter to run
as.
Modified: pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp 2012-11-04 05:53:35 UTC (rev 20114)
+++ pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp 2012-11-04 05:54:40 UTC (rev 20115)
@@ -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/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.h
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.h 2012-11-04 05:53:35 UTC (rev 20114)
+++ pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.h 2012-11-04 05:54:40 UTC (rev 20115)
@@ -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/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.ui
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.ui 2012-11-04 05:53:35 UTC (rev 20114)
+++ pcbsd/current/src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.ui 2012-11-04 05:54:40 UTC (rev 20115)
@@ -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