[PC-BSD Commits] r2904 - in pcbsd: branches/7.0/wificonfig trunk/wificonfig
svn at pcbsd.org
svn at pcbsd.org
Tue Oct 14 14:54:19 PDT 2008
Author: kris
Date: 2008-10-14 14:54:18 -0700 (Tue, 14 Oct 2008)
New Revision: 2904
Added:
pcbsd/branches/7.0/wificonfig/arrow-down.png
pcbsd/branches/7.0/wificonfig/arrow-up.png
pcbsd/branches/7.0/wificonfig/edit-delete.png
pcbsd/branches/7.0/wificonfig/list-add.png
pcbsd/branches/7.0/wificonfig/object-locked.png
pcbsd/branches/7.0/wificonfig/object-unlocked.png
pcbsd/branches/7.0/wificonfig/wifiscanssid.cpp
pcbsd/branches/7.0/wificonfig/wifiscanssid.h
pcbsd/branches/7.0/wificonfig/wifiscanssid.ui
pcbsd/trunk/wificonfig/arrow-down.png
pcbsd/trunk/wificonfig/arrow-up.png
pcbsd/trunk/wificonfig/edit-delete.png
pcbsd/trunk/wificonfig/list-add.png
pcbsd/trunk/wificonfig/object-locked.png
pcbsd/trunk/wificonfig/object-unlocked.png
pcbsd/trunk/wificonfig/wifiscanssid.cpp
pcbsd/trunk/wificonfig/wifiscanssid.h
pcbsd/trunk/wificonfig/wifiscanssid.ui
Modified:
pcbsd/branches/7.0/wificonfig/dialogwpapersonal.cpp
pcbsd/branches/7.0/wificonfig/wificonfig.pro
pcbsd/branches/7.0/wificonfig/wificonfig.qrc
pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.cpp
pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.h
pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.ui
pcbsd/branches/7.0/wificonfig/wifiselectiondialog.cpp
pcbsd/branches/7.0/wificonfig/wifiselectiondialog.h
pcbsd/branches/7.0/wificonfig/wifiselectiondialog.ui
pcbsd/trunk/wificonfig/dialogwpapersonal.cpp
pcbsd/trunk/wificonfig/wificonfig.pro
pcbsd/trunk/wificonfig/wificonfig.qrc
pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp
pcbsd/trunk/wificonfig/wificonfigwidgetbase.h
pcbsd/trunk/wificonfig/wificonfigwidgetbase.ui
pcbsd/trunk/wificonfig/wifiselectiondialog.cpp
pcbsd/trunk/wificonfig/wifiselectiondialog.h
pcbsd/trunk/wificonfig/wifiselectiondialog.ui
Log:
Commit of a large update to the wifi configuration tool. Now you can save multiple ssid / wifi profiles to the wpa_supplicant.conf file, and the system will connect to what the best one available is. Very handy for travel now :)
Property changes on: pcbsd/branches/7.0/wificonfig/arrow-down.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: pcbsd/branches/7.0/wificonfig/arrow-up.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: pcbsd/branches/7.0/wificonfig/dialogwpapersonal.cpp
===================================================================
--- pcbsd/branches/7.0/wificonfig/dialogwpapersonal.cpp 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/branches/7.0/wificonfig/dialogwpapersonal.cpp 2008-10-14 21:54:18 UTC (rev 2904)
@@ -23,10 +23,17 @@
void dialogWPAPersonal::slotClose()
{
if ( lineKey->text() != lineKey2->text() )
- {
- QMessageBox::warning( this, "Network Key Error", "Error: The entered network keys do not match!\n" );
- } else {
- emit saved(lineKey->text());
- close();
- }
+ {
+ QMessageBox::warning( this, "Network Key Error", "Error: The entered network keys do not match!\n" );
+ return;
+ }
+
+ if ( lineKey->text().length() < 8 || lineKey->text().length() > 63 )
+ {
+ QMessageBox::warning( this, "Network Key Error", "Error: The network key must be between 8-63 characters in length!\n" );
+ return;
+ }
+
+ emit saved(lineKey->text());
+ close();
}
Property changes on: pcbsd/branches/7.0/wificonfig/edit-delete.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: pcbsd/branches/7.0/wificonfig/list-add.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: pcbsd/branches/7.0/wificonfig/object-locked.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: pcbsd/branches/7.0/wificonfig/object-unlocked.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: pcbsd/branches/7.0/wificonfig/wificonfig.pro
===================================================================
--- pcbsd/branches/7.0/wificonfig/wificonfig.pro 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/branches/7.0/wificonfig/wificonfig.pro 2008-10-14 21:54:18 UTC (rev 2904)
@@ -11,6 +11,7 @@
dialogwpapersonal.h \
wepconfig.h \
wificonfigwidgetbase.h \
+ wifiscanssid.h \
wifiselectiondialog.h
SOURCES += main.cpp \
@@ -18,12 +19,14 @@
dialogwpapersonal.cpp \
wepconfig.cpp \
wificonfigwidgetbase.cpp \
+ wifiscanssid.cpp \
wifiselectiondialog.cpp
FORMS = wificonfigwidgetbase.ui \
wifiselectiondialog.ui \
wepconfig.ui \
dialogwpapersonal.ui \
+ wifiscanssid.ui \
dialogwpaenterprise.ui
TRANSLATIONS = wificonfig_en.ts
Modified: pcbsd/branches/7.0/wificonfig/wificonfig.qrc
===================================================================
--- pcbsd/branches/7.0/wificonfig/wificonfig.qrc 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/branches/7.0/wificonfig/wificonfig.qrc 2008-10-14 21:54:18 UTC (rev 2904)
@@ -1,5 +1,11 @@
<RCC>
<qresource>
+ <file>object-locked.png</file>
+ <file>object-unlocked.png</file>
+ <file>edit-delete.png</file>
+ <file>list-add.png</file>
+ <file>arrow-up.png</file>
+ <file>arrow-down.png</file>
<file>folder_open.png</file>
<file>tray_wifi85.png</file>
</qresource>
Modified: pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.cpp
===================================================================
--- pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.cpp 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.cpp 2008-10-14 21:54:18 UTC (rev 2904)
@@ -73,177 +73,98 @@
ifConfigLine="DHCP";
}
+ saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
- // Check if we are not using security and write the entry
- if ( radioSecurityDisabled->isChecked() )
- {
- saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
+ // Now create the wpa_supplicant file based on saved configuration
+ QFile fileout( "/etc/wpa_supplicant.conf" );
+ if ( fileout.open( IO_WriteOnly ) ) {
+ QTextStream streamout( &fileout );
- // Now create the wpa_supplicant file based on saved configuration
- QFile fileout( "/etc/wpa_supplicant.conf" );
- if ( fileout.open( IO_WriteOnly ) ) {
+ // Loop through all the devices we have now
+ for(int curItem=0; curItem < 149; curItem++)
+ {
+ if ( ! SSIDList[curItem].isEmpty() )
+ {
- QTextStream streamout( &fileout );
- if ( checkBSSID->isChecked() ) {
- streamout << "network={\n bssid=\"" + lineBSSID->text() + "\"\n";
+
+
+
+ if ( BSSID[curItem]) {
+ streamout << "network={\n bssid=" + SSIDList[curItem] + "\n";
+ } else {
+ streamout << "network={\n ssid=\"" + SSIDList[curItem] + "\"\n";
+ }
+
+ streamout << " scan_ssid=1\n";
+
+ if ( SSIDEncType[curItem] == NO_ENCRYPTION )
+ {
+ streamout << " key_mgmt=NONE\n";
+ } else if (SSIDEncType[curItem] == WEP_ENCRYPTION ) {
+
+ streamout << " key_mgmt=NONE\n";
+ streamout << " wep_tx_keyidx=" + tmp.setNum(WEPIndex[curItem]) + "\n";
+ // Check if we are using a plaintext WEP or not
+ if ( WEPHex[curItem] ) {
+ streamout << " wep_key" + tmp.setNum(WEPIndex[curItem]) + "=" + WEPKey[curItem] + "\n";
} else {
- streamout << "network={\n ssid=\"" + lineSSID->text() + "\"\n";
+ streamout << " wep_key" + tmp.setNum(WEPIndex[curItem]) + "=\"" + WEPKey[curItem] + "\"\n";
}
- streamout << " scan_ssid=1\n";
- streamout << " key_mgmt=NONE\n";
- streamout << "}\n";
- fileout.close();
+ } else if (SSIDEncType[curItem] == WPA_ENCRYPTION ) {
- }
- } else if (radioSecurityWEP->isChecked() ) {
- // Write the settings with WEP enabled
-
- // Check that we even have a WEP Key yet
- if ( WEPKey.isEmpty() )
- {
- QMessageBox::warning( this, tr("Warning"),
- tr("WEP is selected, but not configured!\nPlease configure your WEP key before saving!") );
- return;
- }
-
- // Indicate that we are using WPA supplicant
- saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
+ streamout << " psk=\"" + WPAPersonalKey[curItem] + "\"\n";
- // Now create the wpa_supplicant file based on saved configuration
- QFile fileout( "/etc/wpa_supplicant.conf" );
- if ( fileout.open( IO_WriteOnly ) ) {
- QTextStream streamout( &fileout );
- if ( checkBSSID->isChecked() ) {
- streamout << "network={\n bssid=\"" + lineBSSID->text() + "\"\n";
- } else {
- streamout << "network={\n ssid=\"" + lineSSID->text() + "\"\n";
- }
+ } else if (SSIDEncType[curItem] == WPAE_ENCRYPTION ) {
- streamout << " scan_ssid=1\n";
- streamout << " key_mgmt=NONE\n";
- streamout << " wep_tx_keyidx=" + tmp.setNum(WEPIndex -1) + "\n";
- streamout << " wep_key" + tmp.setNum(WEPIndex -1) + "=" + WEPKey + "\n";
- streamout << "}\n";
- fileout.close();
- }
+ if ( WPAEType[curItem] == 1) {
+ streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=TLS\n";
+ streamout << " identity=\"" + WPAEIdent[curItem] + "\"\n";
+ streamout << " ca_cert=\"" + WPAECACert[curItem] + "\"\n";
+ streamout << " client_cert=\"" + WPAEClientCert[curItem] + "\"\n";
+ streamout << " private_key=\"" + WPAEPrivKeyFile[curItem] + "\"\n";
+ streamout << " private_key_password=\"" + WPAEPassword[curItem] + "\"\n";
-
- } else if (radioSecurityWPAPersonal->isChecked() ) {
- // Write the settings with WPA-Personal enabled
-
- // Check that we even have a WPA-Personal Key yet
- if ( WPAPersonalKey.isEmpty() )
- {
- QMessageBox::warning( this, tr("Warning"),
- tr("WPA-Personal is selected, but not configured!\nPlease configure your WPA key before saving!") );
- return;
- }
-
-
- // If we are using WPA security, write the ifconfig line, and wpa_supplicant line
- saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
- // Now create the wpa_supplicant file based on saved configuration
- QFile fileout( "/etc/wpa_supplicant.conf" );
- if ( fileout.open( IO_WriteOnly ) ) {
- QTextStream streamout( &fileout );
- if ( checkBSSID->isChecked() ) {
- streamout << "network={\n bssid=\"" + lineBSSID->text() + "\"\n ";
- } else {
- streamout << "network={\n ssid=\"" + lineSSID->text() + "\"\n ";
- }
-
- streamout << " scan_ssid=1\n";
- streamout << " psk=\"" + WPAPersonalKey + "\"\n}\n";
- fileout.close();
- }
-} else if (radioSecurityWPAEnt->isChecked() ) {
- // Write the settings with WPA-Enterprise enabled
-
- // Check if the key is setup for WPA EAP-TLS
- if ( WPAEType == 1 && ( WPAEIdent.isEmpty() || WPAECACert.isEmpty() || WPAEClientCert.isEmpty() || WPAEPrivKeyFile.isEmpty() || WPAEPassword.isEmpty() )) {
- QMessageBox::warning( this, tr("Warning"),
- tr("WPA-Enterprise is selected, but not configured!\nPlease configure your WPA settings before saving!") );
- return;
- }
-
- // Check if the key is setup for WPA EAP-TTLS && EAP-PEAP
- if ( (WPAEType == 2 || WPAEType == 3) && ( WPAEIdent.isEmpty() || WPAECACert.isEmpty() || WPAEPassword.isEmpty() ) ) {
- QMessageBox::warning( this, tr("Warning"),
- tr("WPA-Enterprise is selected, but not configured!\nPlease configure your WPA settings before saving!") );
- return;
- }
-
-
-
- // If we are using WPA security, write the ifconfig line, and wpa_supplicant line
- saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
- // Now create the wpa_supplicant file based on saved configuration
- QFile fileout( "/etc/wpa_supplicant.conf" );
- if ( fileout.open( IO_WriteOnly ) ) {
- QTextStream streamout( &fileout );
-
-
- streamout << "network={\n ssid=\"" + lineSSID->text() + "\"\n";
- if ( WPAEType == 1) {
- streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=TLS\n";
- streamout << " identity=\"" + WPAEIdent + "\"\n";
- streamout << " ca_cert=\"" + WPAECACert + "\"\n";
- streamout << " client_cert=\"" + WPAEClientCert + "\"\n";
- streamout << " private_key=\"" + WPAEPrivKeyFile + "\"\n";
- streamout << " private_key_password=\"" + WPAEPassword + "\"\n";
- streamout << " scan_ssid=1\n";
- } else if (WPAEType == 2) {
- streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=TTLS\n";
- streamout << " identity=\"" + WPAEIdent + "\"\n";
- streamout << " password=\"" + WPAEPassword + "\"\n";
- streamout << " ca_cert=\"" + WPAECACert + "\"\n";
- streamout << " phase2=\"auth=MD5\"\n";
- streamout << " scan_ssid=1\n";
-
- } else if (WPAEType == 3) {
- streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=PEAP\n";
- streamout << " identity=\"" + WPAEIdent + "\"\n";
- streamout << " password=\"" + WPAEPassword + "\"\n";
- streamout << " ca_cert=\"" + WPAECACert + "\"\n";
- streamout << " phase1=\"peaplabel=0\"\n";
- streamout << " phase2=\"auth=MSCHAPV2\"\n";
- streamout << " scan_ssid=1\n";
- }
-
- streamout << "}\n";
-
-
- fileout.close();
- }
-}
+ } else if (WPAEType[curItem] == 2) {
+ streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=TTLS\n";
+ streamout << " identity=\"" + WPAEIdent[curItem] + "\"\n";
+ streamout << " password=\"" + WPAEPassword[curItem] + "\"\n";
+ streamout << " ca_cert=\"" + WPAECACert[curItem] + "\"\n";
+ streamout << " phase2=\"auth=MD5\"\n";
-
-
- // Now restart the network for new settings to take effect
+ } else if (WPAEType[curItem] == 3) {
+ streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=PEAP\n";
+ streamout << " identity=\"" + WPAEIdent[curItem] + "\"\n";
+ streamout << " password=\"" + WPAEPassword[curItem] + "\"\n";
+ streamout << " ca_cert=\"" + WPAECACert[curItem] + "\"\n";
+ streamout << " phase1=\"peaplabel=0\"\n";
+ streamout << " phase2=\"auth=MSCHAPV2\"\n";
+ }
+ }
+ streamout << "}\n\n";
- QFile filerestart( "/tmp/.netrestart.sh" );
- if ( filerestart.open( IO_WriteOnly ) ) {
+ } // End of if check if SSIDList is empty
+ } // End of for loop
+
+ fileout.close();
+ }
+
+
+ // Now restart the network for new settings to take effect
+ QFile filerestart( "/tmp/.netrestart.sh" );
+ if ( filerestart.open( IO_WriteOnly ) ) {
QTextStream streamrestart( &filerestart );
streamrestart << "#!/bin/sh\n";
streamrestart << "/etc/rc.d/netif restart " << DeviceName << "\n";
- streamrestart << "/etc/rc.d/routing restart";
+ //streamrestart << "/etc/rc.d/routing restart";
filerestart.close();
- }
+ }
- runCommand("chmod 755 /tmp/.netrestart.sh ; sh /tmp/.netrestart.sh");
+ runCommand("chmod 755 /tmp/.netrestart.sh ; sh /tmp/.netrestart.sh");
- pushApply->setEnabled(FALSE);
-
- // netifProc = new Q3Process( this );
- // netifProc->addArgument( "/tmp/.netrestart.sh" );
-
- // if ( !netifProc->start() ) {
- // }
-
-
+ pushApply->setEnabled(FALSE);
}
@@ -259,24 +180,15 @@
}
+// Function which is called at the program init
void wificonfigwidgetbase::setDevice( QString Device )
{
+ // Connect our add / remove buttons for wifi
+ connect( pushAddWifi, SIGNAL( clicked() ), this, SLOT( slotAddNewProfile() ) );
+ connect( pushRemoveWifi, SIGNAL( clicked() ), this, SLOT( slotRemoveProfile() ) );
-// Make sure our variables are initialized properly
-WEPKey = "";
-WEPIndex = 1;
-WEPHex = true;
-WPAPersonalKey = "";
-WPAEType = 1;
-WPAEIdent="";
-WPAECACert="";
-WPAEClientCert="";
-WPAEPrivKeyFile="";
-WPAEPassword="";
-
-
// Save the device name for later
DeviceName = Device;
@@ -480,12 +392,41 @@
return "";
}
+void wificonfigwidgetbase::slotRemoveProfile()
+{
+ // Check if we have a selection to work with
+ if ( listWifi->currentRow() != -1 )
+ {
+ // Locate the SSID we want to remove
+ QString removeSSID = listWifi->item(listWifi->currentRow())->text();
+ for ( int curItem = 0; curItem < 149; curItem++)
+ {
+ if ( SSIDList[curItem] == removeSSID )
+ {
+ SSIDList[curItem] = "";
+ }
+ }
-void wificonfigwidgetbase::slotConfig()
+ // Refresh the SSID list and enable the apply button
+ slotRefreshSSIDList();
+ pushApply->setEnabled(TRUE);
+
+ }
+
+}
+
+void wificonfigwidgetbase::slotAddNewProfile()
{
wifiselect = new wifiselectiondialog();
- wifiselect->init(DeviceName, lineSSID->text());
- connect( wifiselect, SIGNAL( saved(QString) ), this, SLOT( slotSSIDChanged(QString) ) );
+ wifiselect->init(DeviceName);
+
+ connect( wifiselect, SIGNAL( signalSavedOpen(QString, bool) ), this, SLOT( slotAddNewProfileOpen(QString, bool) ) );
+
+ connect( wifiselect, SIGNAL( signalSavedWEP( QString, bool, QString, int, bool ) ), this, SLOT( slotAddNewProfileWEP( QString, bool, QString, int, bool) ) );
+ connect( wifiselect, SIGNAL( signalSavedWPA(QString, bool, QString) ), this, SLOT( slotAddNewProfileWPA(QString, bool, QString) ) );
+
+ connect( wifiselect, SIGNAL( signalSavedWPAE(QString, bool, int, QString, QString, QString, QString, QString) ), this, SLOT( slotAddNewProfileWPAE(QString, bool, int, QString, QString, QString, QString, QString) ) );
+
wifiselect->exec();
}
@@ -496,155 +437,139 @@
fclose(file);
}
-
-void wificonfigwidgetbase::slotSSIDChanged( QString newSSID )
+void wificonfigwidgetbase::slotAddNewProfileOpen(QString SSID, bool isBSSID)
{
- lineSSID->setText(newSSID);
-}
+ for (int dupItem = 0; dupItem < 149; dupItem++)
+ {
+ if ( SSID == SSIDList[dupItem] ) {
+ QMessageBox::warning( this, tr("Error"), tr("You already have a wireless network with this SSID! Please remove it first.\n") );
+ return;
+ }
+ }
-void wificonfigwidgetbase::slotConfigWEP()
-{
- dialogWEP = new wepConfig();
-
- if ( ! WEPKey.isEmpty() )
+
+ int curItem=0;
+
+ while( ! SSIDList[curItem].isEmpty() && curItem < 149 )
{
- dialogWEP->setKey(WEPKey, WEPIndex, WEPHex);
+ curItem++;
}
-
- connect( dialogWEP, SIGNAL( saved(QString, int, bool) ), this, SLOT( slotWEPChanged(QString, int, bool) ) );
- dialogWEP->exec();
-}
+ // Find which current item we are working on
-void wificonfigwidgetbase::slotWEPChanged( QString newKey, int newIndex, bool hexkey )
-{
- WEPKey = newKey;
- WEPIndex = newIndex;
- WEPHex = hexkey;
- // Check the status of the radio buttons
- slotCheckSecurityRadio();
+ SSIDList[curItem] = SSID;
+ BSSID[curItem] = isBSSID;
+ // Refresh the SSID listbox and enable the apply button
+ slotRefreshSSIDList();
+ slotCheckGlobalText();
}
-
-void wificonfigwidgetbase::slotCheckSecurityRadio()
+void wificonfigwidgetbase::slotAddNewProfileWEP( QString SSID, bool isBSSID, QString newKey, int newIndex, bool hexkey )
{
- // Check to see which radio button is checked and take approiate actions
-
- if ( radioSecurityDisabled->isChecked() )
- {
- pushSecurity->setEnabled(FALSE);
- } else if ( radioSecurityWEP->isChecked() ) {
- pushSecurity->setEnabled(TRUE);
- // Check if the key is setup
- if ( ! WEPKey.isEmpty() )
- {
- radioSecurityWEP->setText( tr("WEP (Configured)") );
- } else {
- radioSecurityWEP->setText( tr("WEP") );
- }
- } else if ( radioSecurityWPAPersonal->isChecked() ) {
- pushSecurity->setEnabled(TRUE);
- // Check if the key is setup
- if ( ! WPAPersonalKey.isEmpty() )
- {
- radioSecurityWPAPersonal->setText( tr("WPA Personal (Configured)") );
- } else {
- radioSecurityWPAPersonal->setText( tr("WPA Personal") );
- }
-
- } else if ( radioSecurityWPAEnt->isChecked() ) {
- pushSecurity->setEnabled(TRUE);
-
- // Check if the key is setup
- if ( ! WPAEIdent.isEmpty() && ! WPAECACert.isEmpty() && ! WPAEPassword.isEmpty() ) {
- radioSecurityWPAEnt->setText(tr("WPA Enterprise (Configured)") );
- } else {
- radioSecurityWPAEnt->setText(tr("WPA Enterprise") );
- }
+ for (int dupItem = 0; dupItem < 149; dupItem++)
+ {
+ if ( SSID == SSIDList[dupItem] ) {
+ QMessageBox::warning( this, tr("Error"), tr("You already have a wireless network with this SSID! Please remove it first.\n") );
+ return;
+ }
+ }
- }
- pushApply->setEnabled(TRUE);
-}
+ int curItem=0;
+ while( ! SSIDList[curItem].isEmpty() && curItem < 149 )
+ {
+ curItem++;
+ }
-void wificonfigwidgetbase::slotCheckWhichSecurity()
-{
- if ( radioSecurityDisabled->isChecked() )
- {
- return;
- } else if ( radioSecurityWEP->isChecked() ) {
- // Run the WEP config dialog
- slotConfigWEP();
- } else if ( radioSecurityWPAPersonal->isChecked() ) {
- slotConfigWPAP();
- } else if ( radioSecurityWPAEnt->isChecked() ) {
- slotConfigWPAE();
- }
+ // Find which current item we are working on
+
+ SSIDList[curItem] = SSID;
+ SSIDEncType[curItem] = WEP_ENCRYPTION;
+ BSSID[curItem] = isBSSID;
+ WEPKey[curItem] = newKey;
+ WEPIndex[curItem] = newIndex;
+ WEPIndex[curItem]--;
+ WEPHex[curItem] = hexkey;
+ // Refresh the SSID listbox and enable the apply button
+ slotRefreshSSIDList();
+ slotCheckGlobalText();
+
}
-void wificonfigwidgetbase::slotConfigWPAP()
+void wificonfigwidgetbase::slotAddNewProfileWPA( QString SSID, bool isBSSID, QString newKey )
{
- // Bring up the WPA-Personal config dialog
-
- dialogWPAP = new dialogWPAPersonal();
-
- if ( ! WPAPersonalKey.isEmpty() )
+ for (int dupItem = 0; dupItem < 149; dupItem++)
{
- dialogWPAP->setKey(WPAPersonalKey);
+ if ( SSID == SSIDList[dupItem] ) {
+ QMessageBox::warning( this, tr("Error"), tr("You already have a wireless network with this SSID! Please remove it first.\n") );
+ return;
+ }
}
-
- connect( dialogWPAP, SIGNAL( saved(QString) ), this, SLOT( slotWPAPChanged(QString) ) );
- dialogWPAP->exec();
-}
+ int curItem=0;
-
-void wificonfigwidgetbase::slotConfigWPAE()
-{
- // Bring up the WPA-Enterprise config dialog
-
- dialogWPAE = new dialogWPAEnterprise();
-
- if ( ! WPAEIdent.isEmpty() )
+ while( ! SSIDList[curItem].isEmpty() && curItem < 149 )
{
- dialogWPAE->setVariables(WPAEType, WPAEIdent, WPAECACert, WPAEClientCert, WPAEPrivKeyFile, WPAEPassword);
+ curItem++;
}
+
+
+ SSIDList[curItem] = SSID;
+ SSIDEncType[curItem] = WPA_ENCRYPTION;
+ BSSID[curItem] = isBSSID;
+ WPAPersonalKey[curItem] = newKey;
- connect( dialogWPAE, SIGNAL( saved(int, QString, QString, QString, QString, QString) ), this, SLOT( slotWPAEChanged(int, QString, QString, QString, QString, QString) ) );
- dialogWPAE->exec();
+ // Refresh the SSID listbox and enable the apply button
+ slotRefreshSSIDList();
+ slotCheckGlobalText();
}
-void wificonfigwidgetbase::slotWPAPChanged( QString newKey )
+void wificonfigwidgetbase::slotAddNewProfileWPAE( QString SSID, bool isBSSID, int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass )
{
- WPAPersonalKey = newKey;
- slotCheckSecurityRadio();
-}
+ for (int dupItem = 0; dupItem < 149; dupItem++)
+ {
+ if ( SSID == SSIDList[dupItem] ) {
+ QMessageBox::warning( this, tr("Error"), tr("You already have a wireless network with this SSID! Please remove it first.\n") );
+ return;
+ }
+ }
-void wificonfigwidgetbase::slotWPAEChanged( int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass )
-{
-WPAEType = type;
-WPAEIdent=EAPIdent;
-WPAECACert=CACert;
-WPAEClientCert=ClientCert;
-WPAEPrivKeyFile=PrivKeyFile;
-WPAEPassword=PrivKeyPass;
+ int curItem=0;
-slotCheckSecurityRadio();
+ while( ! SSIDList[curItem].isEmpty() && curItem < 149 )
+ {
+ curItem++;
+ }
+
+ SSIDList[curItem] = SSID;
+ SSIDEncType[curItem] = WPAE_ENCRYPTION;
+ BSSID[curItem] = isBSSID;
+ WPAEType[curItem] = type;
+ WPAEIdent[curItem] = EAPIdent;
+ WPAECACert[curItem] = CACert;
+ WPAEClientCert[curItem] = ClientCert;
+ WPAEPrivKeyFile[curItem] = PrivKeyFile;
+ WPAEPassword[curItem] = PrivKeyPass;
+
+ // Refresh the SSID listbox and enable the apply button
+ slotRefreshSSIDList();
+ slotCheckGlobalText();
+
}
void wificonfigwidgetbase::slotCheckDisabled()
{
- if ( checkDisableWireless->isChecked() )
- {
+ if ( checkDisableWireless->isChecked() )
+ {
tabMainWidget->setEnabled(FALSE);
} else {
tabMainWidget->setEnabled(TRUE);
@@ -790,7 +715,7 @@
void wificonfigwidgetbase::showInfo()
{
- tabMainWidget->showPage( tabMainWidget->page(3) );
+ tabMainWidget->showPage( tabMainWidget->page(2) );
}
@@ -826,327 +751,229 @@
}
- // Look for the SSID
- if ( tmp.find(" ssid") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find(" ssid") + 5 );
+ } else if ( tmp.find("inet") != -1 ) {
+ // Get the IP address first
+ tmp2 = tmp;
+ tmp2 = tmp2.remove(0, tmp.find("inet") + 5 );
+ tmp2.truncate(tmp.find("netmask") -1 );
+ lineIP->setText(tmp2);
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- if ( tmp2.find("\"") != -1)
- {
- tmp2 = tmp2.remove(0, tmp2.find("\"") +1 );
- tmp2.truncate(tmp2.findRev("\"") );
- }
- lineSSID->setText(tmp2);
- }
-
-
-
- // Look for the BSSID
- if ( tmp.find("bssid") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("bssid") + 5 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- lineBSSID->setText(tmp2);
- lineSSID->setText("");
- checkBSSID->setChecked(TRUE);
- slotBSSIDChecked();
- }
-
- // Look for the WEP Encryption
- if ( tmp.find("wepkey") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("wepkey") + 6 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
+ // Look for the netmask
+ if ( tmp.find("netmask") != -1 ) {
+ tmp2 = tmp;
+ tmp2 = tmp2.remove(0, tmp.find("netmask") + 8 );
+ if ( tmp.find("ether") != -1 ) {
+ tmp2.truncate(tmp.find("ether") );
+ }
- // Check if we are using the hex key, or plain text
- if ( tmp2.indexOf("0x") == 0)
- {
- WEPHex = true;
- // Remove the 0x
- tmp2.remove(0, 2);
- } else {
- WEPHex = false;
- }
+ lineNetmask->setText(tmp2);
- // Check if we need to remove the "0x"
- WEPKey = tmp2;
+ } else {
+ // No netmask specified, default it instead
+ lineNetmask->setText("255.255.255.0");
+ }
+ }
+
+ // Look for the wpa_supplicant.conf file
+ QFile file( "/etc/wpa_supplicant.conf" );
+ if ( file.open( IO_ReadOnly ) ) {
+ int curItem=0;
+ QTextStream stream( &file );
+ QString line;
+ while ( !stream.atEnd() ) {
- radioSecurityWEP->setChecked(TRUE);
- }
-
- // Look for the WEP transmit key
- if ( tmp.find("weptxkey") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("weptxkey") + 8 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
-
- ok = tmp2.toInt(&ok);
- if ( ok ) {
- WEPIndex = tmp2.toInt(&ok);
- }
- radioSecurityWEP->setChecked(TRUE);
- }
-
-
- } else {
-
- // Look for the SSID
- if ( tmp.find(" ssid") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find(" ssid") + 5 );
- tmp2.simplifyWhiteSpace();
+ line = stream.readLine(); // line of text excluding '\n'
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- if ( tmp2.find("\"") != -1)
- {
- tmp2 = tmp2.remove(0, tmp2.find("\"") +1 );
- tmp2.truncate(tmp2.findRev("\"") );
- }
+ // Check if we are at the end of a network profile block
+ if ( line.find("}") == 0)
+ {
+ curItem++;
+ }
- lineSSID->setText(tmp2);
- }
-
- // Look for the BSSID
- if ( tmp.find("bssid") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("bssid") + 5 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- lineBSSID->setText(tmp2);
- lineSSID->setText("");
- checkBSSID->setChecked(TRUE);
- slotBSSIDChecked();
- }
-
- // Get the IP address first
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("inet") + 5 );
- //tmp2 = tmp2.remove(0, tmp.find(" ") );
- tmp2.truncate(tmp.find("netmask") -1 );
- lineIP->setText(tmp2);
+ if ( line.find(" ssid=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") +1 );
+ tmp2.truncate(tmp2.find("\"") );
+ SSIDList[curItem] = tmp2;
+ BSSID[curItem] = false;
+ SSIDEncType[curItem]=NO_ENCRYPTION;
+ }
- // Look for the netmask
- if ( tmp.find("netmask") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("netmask") + 8 );
- if ( tmp.find("ether") != -1 ) {
- tmp2.truncate(tmp.find("ether") );
- }
- lineNetmask->setText(tmp2);
- } else {
- lineNetmask->setText("255.255.255.0");
- }
-
- // Look for the mac address change
- if ( tmp.find("ether") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("ether") + 6 );
- //if ( tmp.find(" ") != -1 ) {
- // tmp2.truncate(tmp.find(" ") );
- //}
- lineMAC->setText(tmp2);
- checkMAC->setChecked(FALSE);
- groupMAC->setEnabled(TRUE);
- }
+ if ( line.find(" bssid=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("=") +1 );
+ SSIDList[curItem] = tmp2;
+ BSSID[curItem] = true;
+ SSIDEncType[curItem]=NO_ENCRYPTION;
+ }
- // Look for the WEP Encryption
- if ( tmp.find("wepkey") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("wepkey") + 7 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- tmp2.remove(0, 2);
- WEPKey = tmp2;
- radioSecurityWEP->setChecked(TRUE);
- }
- // Look for the WEP transmit key
- if ( tmp.find("weptxkey") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("weptxkey") + 9 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
-
+ // Check if we are using a WEP key for this network
+ if ( line.find("wep_key") != -1 )
+ {
+ if (line.find("\"") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate(tmp2.find("\""));
+ WEPHex[curItem]=false;
+ } else {
+ tmp2 = line.remove(0, line.find("=") + 1 );
+ WEPHex[curItem]=true;
+ }
+ // Save the keycode
+ WEPKey[curItem] = tmp2;
+ SSIDEncType[curItem]=WEP_ENCRYPTION;
+ }
+
+ // Check for the WEP tx key id
+ if ( line.find("wep_tx_keyidx") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("wep_tx_keyidx") +1 );
+ // Save the keycode
+ tmp2.truncate(tmp2.find("=") );
ok = tmp2.toInt(&ok);
if ( ok ) {
- WEPIndex = tmp2.toInt(&ok);
+ WEPIndex[curItem] = tmp2.toInt(&ok);
+ WEPIndex[curItem]++;
}
- radioSecurityWEP->setChecked(TRUE);
- }
- }
-
-
- // Load the security information here
-
- // Start check for wpa_supplicant tag
- if ( tmp.find("WPA") != -1 )
- {
- // Look for the wpa_supplicant.conf file
- QFile file( "/etc/wpa_supplicant.conf" );
- if ( file.open( IO_ReadOnly ) ) {
- QTextStream stream( &file );
- QString line;
- while ( !stream.atEnd() ) {
- line = stream.readLine(); // line of text excluding '\n'
-
- if ( line.find(" ssid=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") +1 );
- tmp2.truncate(tmp2.find("\"") );
- lineSSID->setText(tmp2);
- }
-
- // Check if we are using a WEP key for this network
- if ( line.find("wep_key") != -1 )
- {
- tmp2 = line.remove(0, line.find("=") +1 );
- // Save the keycode
- WEPKey = tmp2;
- radioSecurityWEP->setChecked(TRUE);
- }
-
- // Check for the WEP tx key id
- if ( line.find("wep_tx_keyidx") != -1 )
- {
- tmp2 = line.remove(0, line.find("wep_tx_keyidx") +1 );
- // Save the keycode
- tmp2.truncate(tmp2.find("=") );
- ok = tmp2.toInt(&ok);
- if ( ok ) {
- WEPIndex = tmp2.toInt(&ok);
- WEPIndex++;
- }
- radioSecurityWEP->setChecked(TRUE);
- }
+ }
- // Check if we are using WPA-Personal
- if ( line.find("psk=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check if we are using WPA-Personal
+ if ( line.find("psk=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAPersonalKey = tmp2;
- radioSecurityWPAPersonal->setChecked(TRUE);
- }
+ // Save the keycode
+ WPAPersonalKey[curItem] = tmp2;
+ SSIDEncType[curItem]=WPA_ENCRYPTION;
+ }
- // Check if we are using WPA-Enterprise
- if ( line.find("eap=") != -1 )
- {
- tmp2 = line.remove(0, line.find("=") + 1 );
+ // Check if we are using WPA-Enterprise
+ if ( line.find("eap=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("=") + 1 );
- //Check to see whic type of WPA-Ent we are using
- if ( tmp2 == "TLS") {
- WPAEType = 1;
- } else if (tmp2 == "TTLS" ) {
- WPAEType = 2;
- } else if (tmp2 == "PEAP" ) {
- WPAEType = 3;
- }
+ //Check to see whic type of WPA-Ent we are using
+ if ( tmp2 == "TLS") {
+ WPAEType[curItem] = 1;
+ } else if (tmp2 == "TTLS" ) {
+ WPAEType[curItem] = 2;
+ } else if (tmp2 == "PEAP" ) {
+ WPAEType[curItem] = 3;
+ }
- radioSecurityWPAEnt->setChecked(TRUE);
- }
+ SSIDEncType[curItem]=WPAE_ENCRYPTION;
+ }
- // Check for a identity= line
- if ( line.find("identity=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check for a identity= line
+ if ( line.find("identity=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEIdent = tmp2;
- }
+ // Save the keycode
+ WPAEIdent[curItem] = tmp2;
+ }
- // Check for a ca_cert= line
- if ( line.find("ca_cert=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check for a ca_cert= line
+ if ( line.find("ca_cert=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAECACert = tmp2;
- }
+ // Save the keycode
+ WPAECACert[curItem] = tmp2;
+ }
- // Check for a client_cert= line
- if ( line.find("client_cert=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check for a client_cert= line
+ if ( line.find("client_cert=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEClientCert = tmp2;
- }
+ // Save the keycode
+ WPAEClientCert[curItem] = tmp2;
+ }
- // Check for a private_key= line
- if ( line.find("private_key=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check for a private_key= line
+ if ( line.find("private_key=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEPrivKeyFile = tmp2;
- }
-
- // Check for a private_key_passwd= line
- if ( line.find("private_key_passwd=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Save the keycode
+ WPAEPrivKeyFile[curItem] = tmp2;
+ }
+
+ // Check for a private_key_passwd= line
+ if ( line.find("private_key_passwd=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEPassword = tmp2;
- }
-
- // Check for a private_key_passwd= line
- if ( line.find("password=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Save the keycode
+ WPAEPassword[curItem] = tmp2;
+ }
+
+ // Check for a private_key_passwd= line
+ if ( line.find("password=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEPassword = tmp2;
- }
+ // Save the keycode
+ WPAEPassword[curItem] = tmp2;
+ }
- }
-
- }
}
- }
+ }
+
+
+ // Refresh the ssid profile list
+ slotRefreshSSIDList();
- slotCheckSecurityRadio();
-
-
// Start loading the info tab
loadInfo();
pushApply->setEnabled(FALSE);
+ }
}
+// Slot which reads the arrays and displays the list of WIFI profiles
+void wificonfigwidgetbase::slotRefreshSSIDList()
+{
+
+ listWifi->clear();
+
+ int curItem=0;
+
+ while( ! SSIDList[curItem].isEmpty() )
+ {
+ if ( SSIDEncType[curItem] == NO_ENCRYPTION )
+ {
+ listWifi->addItem(new QListWidgetItem(QIcon(":object-unlocked.png"), SSIDList[curItem] ) );
+ } else {
+
+ listWifi->addItem(new QListWidgetItem(QIcon(":object-locked.png"), SSIDList[curItem] ) );
+ }
+
+ curItem++;
+
+ // We only need 150 wireless networks
+ if ( curItem > 149 )
+ {
+ break;
+ }
+ }
+
+}
+
+
QString wificonfigwidgetbase::getIPv6ForIdent( QString ident )
{
QString command = "nice ifconfig " +ident + " | grep \"inet6 \"";
@@ -1202,18 +1029,3 @@
pushApply->setEnabled(TRUE);
}
-
-
-
-void wificonfigwidgetbase::slotBSSIDChecked()
-{
- if ( checkBSSID->isChecked() )
- {
- groupBSSID->setEnabled(TRUE);
- lineBSSID->setEnabled(TRUE);
- } else {
- groupBSSID->setEnabled(FALSE);
- lineBSSID->setEnabled(FALSE);
- }
- pushApply->setEnabled(TRUE);
-}
Modified: pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.h
===================================================================
--- pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.h 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.h 2008-10-14 21:54:18 UTC (rev 2904)
@@ -14,6 +14,13 @@
#include "ui_wificonfigwidgetbase.h"
#include <Q3Process>
+
+// Setup our encryption type defines
+#define NO_ENCRYPTION 0
+#define WEP_ENCRYPTION 1
+#define WPA_ENCRYPTION 2
+#define WPAE_ENCRYPTION 3
+
class wificonfigwidgetbase : public QWidget, private Ui::wificonfigwidgetbase
{
Q_OBJECT
@@ -33,23 +40,19 @@
void slotClose();
void slotApply();
void slotCheckDHCPBox();
- void slotConfig();
- void slotSSIDChanged( QString newSSID );
- void slotConfigWEP();
- void slotWEPChanged( QString newKey, int newIndex, bool hexkey );
- void slotCheckSecurityRadio();
- void slotCheckWhichSecurity();
- void slotConfigWPAP();
- void slotConfigWPAE();
- void slotWPAPChanged( QString newKey );
- void slotWPAEChanged( int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass );
+ void slotAddNewProfile();
+ void slotRemoveProfile();
+ void slotAddNewProfileOpen( QString SSID, bool isBSSID );
+ void slotAddNewProfileWEP( QString SSID, bool isBSSID, QString newKey, int newIndex, bool hexkey );
+ void slotAddNewProfileWPA( QString SSID, bool isBSSID, QString newKey );
+ void slotAddNewProfileWPAE( QString SSID, bool isBSSID, int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass );
void slotCheckDisabled();
void slotOK();
void slotMACClicked();
void loadInfo();
void slotFinishLoading();
void slotCheckGlobalText();
- void slotBSSIDChecked();
+ void slotRefreshSSIDList();
private:
@@ -72,23 +75,23 @@
QString getMediaForIdent( QString ident );
QString DeviceName;
wifiselectiondialog *wifiselect;
- wepConfig *dialogWEP;
- QString WEPKey;
- int WEPIndex;
- bool WEPHex;
- dialogWPAPersonal *dialogWPAP;
- QString WPAPersonalKey;
- dialogWPAEnterprise *dialogWPAE;
- int WPAEType;
- QString WPAEIdent;
- QString WPAECACert;
- QString WPAEClientCert;
- QString WPAEPrivKeyFile;
- QString WPAEPassword;
Q3Process *netifProc;
+ // Lets define our arrays for the SSID profiles
+ QString SSIDList[150];
+ int SSIDEncType[150];
+ bool BSSID[150];
+ QString WEPKey[150];
+ int WEPIndex[150];
+ bool WEPHex[150];
+ QString WPAPersonalKey[150];
+ QString WPAEIdent[150];
+ QString WPAECACert[150];
+ QString WPAEClientCert[150];
+ QString WPAEPrivKeyFile[150];
+ QString WPAEPassword[150];
+ int WPAEType[150];
-
signals:
} ;
Modified: pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.ui
===================================================================
--- pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.ui 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.ui 2008-10-14 21:54:18 UTC (rev 2904)
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>348</width>
- <height>463</height>
+ <height>450</height>
</rect>
</property>
<property name="windowTitle" >
@@ -17,25 +17,119 @@
<normaloff>:/tray_wifi85.png</normaloff>:/tray_wifi85.png</iconset>
</property>
<layout class="QGridLayout" >
+ <item row="2" column="3" >
+ <widget class="QPushButton" name="buttonCancel" >
+ <property name="text" >
+ <string>Close</string>
+ </property>
+ <property name="shortcut" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="4" >
+ <widget class="QCheckBox" name="checkDisableWireless" >
+ <property name="text" >
+ <string>Disable this wireless device</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" >
+ <widget class="QPushButton" name="pushApply" >
+ <property name="text" >
+ <string>&Apply</string>
+ </property>
+ <property name="shortcut" >
+ <string>Alt+A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <spacer name="spacer1" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>100</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QPushButton" name="pushOK" >
+ <property name="text" >
+ <string>&OK</string>
+ </property>
+ <property name="shortcut" >
+ <string>Alt+O</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="0" colspan="4" >
<widget class="QTabWidget" name="tabMainWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="tab" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>328</width>
- <height>356</height>
- </rect>
- </property>
<attribute name="title" >
<string>&General</string>
</attribute>
- <layout class="QGridLayout" >
- <item row="5" column="0" colspan="2" >
+ <layout class="QGridLayout" name="gridLayout_4" >
+ <item row="1" column="0" >
+ <layout class="QGridLayout" name="gridLayout_3" >
+ <item row="0" column="0" >
+ <widget class="QListWidget" name="listWifi" />
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QPushButton" name="pushAddWifi" >
+ <property name="text" >
+ <string>Add</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="wificonfig.qrc" >
+ <normaloff>:/list-add.png</normaloff>:/list-add.png</iconset>
+ </property>
+ <property name="shortcut" >
+ <string>Alt+S</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushRemoveWifi" >
+ <property name="text" >
+ <string>Remove</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="wificonfig.qrc" >
+ <normaloff>:/edit-delete.png</normaloff>:/edit-delete.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0" >
<widget class="QCheckBox" name="checkDHCP" >
<property name="text" >
<string>O&btain IP automatically (DHCP)</string>
@@ -45,23 +139,7 @@
</property>
</widget>
</item>
- <item row="4" column="0" colspan="2" >
- <widget class="QLabel" name="textLabel1" >
- <property name="frameShape" >
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow" >
- <enum>QFrame::Plain</enum>
- </property>
- <property name="text" >
- <string>Network address configuration</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2" >
+ <item row="3" column="0" >
<widget class="Line" name="line1" >
<property name="frameShape" >
<enum>QFrame::HLine</enum>
@@ -71,50 +149,17 @@
</property>
</widget>
</item>
- <item row="2" column="0" colspan="2" >
- <spacer name="spacer2" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>270</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="1" >
- <widget class="QPushButton" name="pushChangeWifi" >
- <property name="text" >
- <string>&Scan</string>
- </property>
- <property name="shortcut" >
- <string>Alt+S</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="2" >
+ <item row="0" column="0" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
- <string>Currently selected wireless network:</string>
+ <string>Wireless network profiles</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
- <item row="1" column="0" >
- <widget class="QLineEdit" name="lineSSID" >
- <property name="readOnly" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="6" column="0" colspan="2" >
+ <item row="5" column="0" >
<widget class="Q3GroupBox" name="groupBoxIP" >
<property name="title" >
<string>Assign static IP address</string>
@@ -169,169 +214,13 @@
</layout>
</widget>
</item>
- <item row="7" column="0" colspan="2" >
- <spacer name="spacer3_2" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Preferred</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>290</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
- <widget class="QWidget" name="tab" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>328</width>
- <height>356</height>
- </rect>
- </property>
- <attribute name="title" >
- <string>Securit&y</string>
- </attribute>
- <layout class="QGridLayout" >
- <item row="3" column="0" >
- <spacer name="spacer4" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>270</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="0" >
- <widget class="QLabel" name="textLabel4" >
- <property name="text" >
- <string>Wireless security setup</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <spacer name="spacer4_2" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>270</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0" >
- <widget class="Q3ButtonGroup" name="buttonGroupSecurity" >
- <property name="title" >
- <string>Security Mode</string>
- </property>
- <layout class="QGridLayout" >
- <item row="4" column="0" >
- <spacer name="spacer6" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>130</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="3" column="0" colspan="2" >
- <widget class="QRadioButton" name="radioSecurityWPAEnt" >
- <property name="text" >
- <string>WPA Enterprise</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2" >
- <widget class="QRadioButton" name="radioSecurityWEP" >
- <property name="text" >
- <string>WEP</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2" >
- <widget class="QRadioButton" name="radioSecurityWPAPersonal" >
- <property name="text" >
- <string>WPA Personal</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="4" column="1" >
- <widget class="QPushButton" name="pushSecurity" >
- <property name="text" >
- <string>Configure</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="2" >
- <widget class="QRadioButton" name="radioSecurityDisabled" >
- <property name="text" >
- <string>Disa&bled</string>
- </property>
- <property name="shortcut" >
- <string>Alt+B</string>
- </property>
- <property name="checked" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
<widget class="QWidget" name="TabPage" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>328</width>
- <height>356</height>
- </rect>
- </property>
<attribute name="title" >
<string>Advanced</string>
</attribute>
- <layout class="QGridLayout" >
+ <layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QCheckBox" name="checkMAC" >
<property name="text" >
@@ -361,34 +250,6 @@
</widget>
</item>
<item row="2" column="0" >
- <widget class="QCheckBox" name="checkBSSID" >
- <property name="text" >
- <string>Specify custom BSSID</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- <property name="checked" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="Q3GroupBox" name="groupBSSID" >
- <property name="enabled" >
- <bool>false</bool>
- </property>
- <property name="title" >
- <string>Custom wireless BSSID</string>
- </property>
- <layout class="QGridLayout" >
- <item row="0" column="0" >
- <widget class="QLineEdit" name="lineBSSID" />
- </item>
- </layout>
- </widget>
- </item>
- <item row="4" column="0" >
<spacer name="spacer7" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
@@ -407,14 +268,6 @@
</layout>
</widget>
<widget class="QWidget" name="TabPage" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>328</width>
- <height>356</height>
- </rect>
- </property>
<attribute name="title" >
<string>Info</string>
</attribute>
@@ -796,59 +649,6 @@
</widget>
</widget>
</item>
- <item row="2" column="3" >
- <widget class="QPushButton" name="buttonCancel" >
- <property name="text" >
- <string>Close</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="4" >
- <widget class="QCheckBox" name="checkDisableWireless" >
- <property name="text" >
- <string>Disable this wireless device</string>
- </property>
- </widget>
- </item>
- <item row="2" column="2" >
- <widget class="QPushButton" name="pushApply" >
- <property name="text" >
- <string>&Apply</string>
- </property>
- <property name="shortcut" >
- <string>Alt+A</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <spacer name="spacer1" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>100</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="1" >
- <widget class="QPushButton" name="pushOK" >
- <property name="text" >
- <string>&OK</string>
- </property>
- <property name="shortcut" >
- <string>Alt+O</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
@@ -859,25 +659,16 @@
<header>Qt3Support/Q3GroupBox</header>
<container>1</container>
</customwidget>
- <customwidget>
- <class>Q3ButtonGroup</class>
- <extends>Q3GroupBox</extends>
- <header>Qt3Support/Q3ButtonGroup</header>
- <container>1</container>
- </customwidget>
</customwidgets>
<tabstops>
<tabstop>tabMainWidget</tabstop>
- <tabstop>lineSSID</tabstop>
- <tabstop>pushChangeWifi</tabstop>
+ <tabstop>pushAddWifi</tabstop>
<tabstop>checkDHCP</tabstop>
<tabstop>lineIP</tabstop>
<tabstop>lineNetmask</tabstop>
<tabstop>pushOK</tabstop>
<tabstop>pushApply</tabstop>
<tabstop>buttonCancel</tabstop>
- <tabstop>radioSecurityDisabled</tabstop>
- <tabstop>pushSecurity</tabstop>
<tabstop>checkDisableWireless</tabstop>
<tabstop>checkMAC</tabstop>
<tabstop>lineMAC</tabstop>
@@ -917,22 +708,6 @@
</hints>
</connection>
<connection>
- <sender>checkDHCP</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckDHCPBox()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
<sender>pushApply</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
@@ -949,10 +724,10 @@
</hints>
</connection>
<connection>
- <sender>pushChangeWifi</sender>
+ <sender>checkDisableWireless</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
- <slot>slotConfig()</slot>
+ <slot>slotCheckDisabled()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
@@ -965,10 +740,10 @@
</hints>
</connection>
<connection>
- <sender>pushSecurity</sender>
+ <sender>pushOK</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckWhichSecurity()</slot>
+ <slot>slotOK()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
@@ -981,10 +756,10 @@
</hints>
</connection>
<connection>
- <sender>radioSecurityDisabled</sender>
+ <sender>checkDHCP</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckSecurityRadio()</slot>
+ <slot>slotCheckDHCPBox()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
@@ -997,86 +772,6 @@
</hints>
</connection>
<connection>
- <sender>radioSecurityWEP</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckSecurityRadio()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>radioSecurityWPAEnt</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckSecurityRadio()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>radioSecurityWPAPersonal</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckSecurityRadio()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>checkDisableWireless</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckDisabled()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>pushOK</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotOK()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
<sender>checkMAC</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
@@ -1140,53 +835,5 @@
</hint>
</hints>
</connection>
- <connection>
- <sender>lineSSID</sender>
- <signal>textChanged(QString)</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckGlobalText()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>checkBSSID</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotBSSIDChecked()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>lineBSSID</sender>
- <signal>textChanged(QString)</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckGlobalText()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
</connections>
</ui>
Modified: pcbsd/branches/7.0/wificonfig/wifiselectiondialog.cpp
===================================================================
--- pcbsd/branches/7.0/wificonfig/wifiselectiondialog.cpp 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/branches/7.0/wificonfig/wifiselectiondialog.cpp 2008-10-14 21:54:18 UTC (rev 2904)
@@ -1,209 +1,247 @@
-/****************************************************************************
-** ui.h extension file, included from the uic-generated form implementation.
-**
-** If you want to add, delete, or rename functions or slots, use
-** Qt Designer to update this file, preserving your code.
-**
-** You should not define a constructor or destructor in this file.
-** Instead, write your code in functions called init() and destroy().
-** These will automatically be called by the form's constructor and
-** destructor.
-*****************************************************************************/
#include "wifiselectiondialog.h"
#include "ui_wifiselectiondialog.h"
#include <qtextstream.h>
-
-
-
-void wifiselectiondialog::init( QString Device, QString oldSSID )
+void wifiselectiondialog::init(QString device)
{
- DeviceName = Device;
- SSID = oldSSID;
- pushConnect->setEnabled(FALSE);
+ DeviceName = device;
- QTimer::singleShot(500, this, SLOT(startScan()));
- //scanWifi();
+ connect( pushScan, SIGNAL( clicked() ), this, SLOT(slotOpenWifiScan()) );
+ connect( pushConnect, SIGNAL( clicked() ), this, SLOT(slotConnect()) );
+ connect( pushCancel, SIGNAL( clicked() ), this, SLOT(slotCancel()) );
+ connect( pushSecurity, SIGNAL( clicked() ), this, SLOT(slotCheckWhichSecurity()) );
}
-
-void wifiselectiondialog::scanWifi()
-{
- QString tmp;
- QString strength;
- QString ssid;
- int newStrength;
- bool ok;
- int foundItem = 0;
- QString FileLoad;
- QString line;
-
- // Clear the list box
- listWifi->clear();
- textTop->setText(tr("Scanning for wireless networks...") );
-
- // Take the interface down before starting the scan
- //runCommand("ifconfig " + DeviceName + " down");
-
- // Start the scan and get the output
- line = getLineFromCommandOutput("ifconfig -v " + DeviceName + " up list scan >/tmp/.wifilist 2>/tmp/.wifilist");
- // Now read the output file
- QFile file( "/tmp/.wifilist" );
- if ( file.open( IO_ReadOnly ) ) {
- QTextStream stream( &file );
- while ( !stream.atEnd() ) {
- line = stream.readLine(); // line of text excluding '\n'
- // exclude the header line
- if ( line.indexOf("BSSID") == -1) {
-
- // Get the ssid of the network
- tmp = line;
- tmp = tmp.simplified();
- tmp.remove(0, tmp.indexOf("SSID<") + 5);
- tmp.truncate(tmp.indexOf(">"));
- ssid = tmp;
- // Get the signal strength of this device
- tmp = line;
- tmp = tmp.simplified();
-
- // First remove the SSID which may have spaces in it
- tmp.remove(0, tmp.find(":"));
-
- // Now find the strength section
- tmp.truncate(tmp.findRev("SSID<"));
- tmp.truncate(tmp.findRev(":"));
- tmp.remove(0, tmp.findRev(" "));
- strength = tmp;
-
- //QMessageBox::warning( this, "Testing", "SSID:" + ssid + " STR:" + strength );
- // Add the device to the list box
- strength.toInt(&ok);
- if ( ok && !ssid.isEmpty() && ssid != " " ) {
- newStrength = tmp.toInt(&ok);
- if ( newStrength < 25 )
- {
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi.png";
- } else if ( newStrength < 50 ) {
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi30.png";
- } else if ( newStrength < 75 ) {
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi60.png";
- } else {;
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi85.png";
- }
-
-
- QImage *Icon = new QImage(FileLoad);
- QPixmap PixmapIcon;
- PixmapIcon.convertFromImage(Icon->scaled(22,22));
- listWifi->insertItem(PixmapIcon, ssid + " (signal strength: " +strength + "%)" );
-
- foundItem = 1;
-
- } else {
- if ( ! ssid.isEmpty() && ssid != " " ) {
- // If we didn't get the signal strength, still display the SSID
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi.png";
- QImage *Icon = new QImage(FileLoad);
- QPixmap PixmapIcon;
- PixmapIcon.convertFromImage(Icon->scaled(22,22));
- listWifi->insertItem(PixmapIcon, ssid + " (signal strength: unknown)" );
-
- foundItem = 1;
- }
- }
-
- }
-
- }
-
-
- if ( foundItem == 1 )
- {
- textTop->setText(tr("Select a wireless network to connect.") );
- listWifi->setSelected(0, TRUE);
- pushConnect->setEnabled(TRUE);
- } else {
- textTop->setText(tr("No wireless networks found!") );
- pushConnect->setEnabled(FALSE);
- }
- }
-
+void wifiselectiondialog::slotOpenWifiScan()
+{
+ dialogWifiscanssid = new wifiscanssid();
+ dialogWifiscanssid->init(DeviceName);
+ connect( dialogWifiscanssid, SIGNAL( saved(QString) ), this, SLOT( slotSSIDChanged(QString) ) );
+ dialogWifiscanssid->exec();
}
-QString wifiselectiondialog::getLineFromCommandOutput( QString command )
+void wifiselectiondialog::slotSSIDChanged( QString newSSID )
{
- FILE *file = popen(command,"r");
-
- char buffer[100];
-
- QString line = "";
- char firstChar;
-
- if ((firstChar = fgetc(file)) != -1){
- line += firstChar;
- line += fgets(buffer,100,file);
- }
-
-
- pclose(file);
-
-
- return line;
+ lineSSID->setText(newSSID);
}
-
+
void wifiselectiondialog::slotCancel()
{
close();
}
-
void wifiselectiondialog::slotConnect()
{
QString selectedSSID;
// Make sure a device was selected
- int sel = listWifi->currentItem();
- if ( sel == -1 )
+ if (lineSSID->text().isEmpty())
{
- QMessageBox::warning( this, tr("No selection"),
- tr("Error: You must select a network to connect!\n") );
+ QMessageBox::warning( this, tr("No SSID!"), tr("Error: You must select a wireless network to connect!\n") );
return;
}
+
+ if ( (checkBSSID->isChecked() && lineSSID->text().length() != 17) || (checkBSSID->isChecked() && lineSSID->text().count(":") != 5) )
+ {
+ QMessageBox::warning( this, tr("Invalid BSSID!"), tr("Error: The specified BSSID appears invalid. It must be in the format xx:xx:xx:xx:xx:xx\n") );
+ return;
+ }
+
+ // Check that we even have a WEP Key yet
+ if (radioSecurityWEP->isChecked() && WEPKey.isEmpty() ) {
+ QMessageBox::warning( this, tr("Warning"), tr("WEP is selected, but not configured!\nPlease configure your WEP key before saving!") );
+ return;
+ }
+
+ // Check that we even have a WPA-Personal Key yet
+ if (radioSecurityWPAPersonal->isChecked() && WPAPersonalKey.isEmpty() ) {
+ QMessageBox::warning( this, tr("Warning"), tr("WPA-Personal is selected, but not configured!\nPlease configure your WPA key before saving!") );
+ return;
+ }
+
+ // Check all the WPAEnt settings
+ if (radioSecurityWPAEnt->isChecked() ) {
+
+ // Check if the key is setup for WPA EAP-TLS
+ if ( WPAEType == 1 && ( WPAEIdent.isEmpty() || WPAECACert.isEmpty() || WPAEClientCert.isEmpty() || WPAEPrivKeyFile.isEmpty() || WPAEPassword.isEmpty() ))
+ {
+ QMessageBox::warning( this, tr("Warning"), tr("WPA-Enterprise is selected, but not configured!\nPlease configure your WPA settings before saving!") );
+ return;
+ }
+
+ // Check if the key is setup for WPA EAP-TTLS && EAP-PEAP
+ if ( (WPAEType == 2 || WPAEType == 3) && ( WPAEIdent.isEmpty() || WPAECACert.isEmpty() || WPAEPassword.isEmpty() ) )
+ {
+ QMessageBox::warning( this, tr("Warning"), tr("WPA-Enterprise is selected, but not configured!\nPlease configure your WPA settings before saving!") );
+ return;
+ }
+
+ } // End of WPAEnt setting check
- selectedSSID = listWifi->text(sel);
- selectedSSID.truncate( selectedSSID.find("(") - 1 );
+ selectedSSID = lineSSID->text();
+ bool usingBSSID = checkBSSID->isChecked() ;
// Emit the new network SSID the user selected
- emit saved(selectedSSID);
+ if ( radioSecurityDisabled->isChecked() )
+ {
+ emit signalSavedOpen(selectedSSID, usingBSSID);
+ }
+
+ if ( radioSecurityWEP->isChecked() )
+ {
+ emit signalSavedWEP(selectedSSID, usingBSSID, WEPKey, WEPIndex, WEPHex );
+ }
+
+ if ( radioSecurityWPAPersonal->isChecked() )
+ {
+ emit signalSavedWPA(selectedSSID, usingBSSID, WPAPersonalKey );
+ }
+
+ if ( radioSecurityWPAEnt->isChecked() )
+ {
+ emit signalSavedWPAE(selectedSSID, usingBSSID, WPAEType, WPAEIdent, WPAECACert, WPAEClientCert, WPAEPrivKeyFile, WPAEPassword );
+ }
+
close();
}
+void wifiselectiondialog::slotConfigWEP()
+{
+ dialogWEP = new wepConfig();
+
+ if ( ! WEPKey.isEmpty() )
+ {
+ dialogWEP->setKey(WEPKey, WEPIndex, WEPHex);
+ }
+
+ connect( dialogWEP, SIGNAL( saved(QString, int, bool) ), this, SLOT( slotWEPChanged(QString, int, bool) ) );
+ dialogWEP->exec();
+}
+void wifiselectiondialog::slotWEPChanged( QString newKey, int newIndex, bool hexkey )
+{
+ WEPKey = newKey;
+ WEPIndex = newIndex;
+ WEPHex = hexkey;
+ // Check the status of the radio buttons
+ slotCheckSecurityRadio();
+
+}
-void wifiselectiondialog::slotRescan()
+
+void wifiselectiondialog::slotCheckSecurityRadio()
{
- pushConnect->setEnabled(FALSE);
- scanWifi();
+ // Check to see which radio button is checked and take approiate actions
+
+ if ( radioSecurityDisabled->isChecked() )
+ {
+ pushSecurity->setEnabled(FALSE);
+ } else if ( radioSecurityWEP->isChecked() ) {
+ pushSecurity->setEnabled(TRUE);
+ // Check if the key is setup
+ if ( ! WEPKey.isEmpty() )
+ {
+ radioSecurityWEP->setText( tr("WEP (Configured)") );
+ } else {
+ radioSecurityWEP->setText( tr("WEP") );
+ }
+ } else if ( radioSecurityWPAPersonal->isChecked() ) {
+ pushSecurity->setEnabled(TRUE);
+ // Check if the key is setup
+ if ( ! WPAPersonalKey.isEmpty() )
+ {
+ radioSecurityWPAPersonal->setText( tr("WPA Personal (Configured)") );
+ } else {
+ radioSecurityWPAPersonal->setText( tr("WPA Personal") );
+ }
+
+ } else if ( radioSecurityWPAEnt->isChecked() ) {
+ pushSecurity->setEnabled(TRUE);
+
+ // Check if the key is setup
+ if ( ! WPAEIdent.isEmpty() && ! WPAECACert.isEmpty() && ! WPAEPassword.isEmpty() ) {
+ radioSecurityWPAEnt->setText(tr("WPA Enterprise (Configured)") );
+ } else {
+ radioSecurityWPAEnt->setText(tr("WPA Enterprise") );
+ }
+
+ }
+
}
-void wifiselectiondialog::runCommand( QString Command )
+void wifiselectiondialog::slotCheckWhichSecurity()
{
- FILE *file = popen(Command,"r");
- fclose(file);
+ if ( radioSecurityDisabled->isChecked() )
+ {
+ return;
+ } else if ( radioSecurityWEP->isChecked() ) {
+ // Run the WEP config dialog
+ slotConfigWEP();
+ } else if ( radioSecurityWPAPersonal->isChecked() ) {
+ slotConfigWPAP();
+ } else if ( radioSecurityWPAEnt->isChecked() ) {
+ slotConfigWPAE();
+ }
+
}
+void wifiselectiondialog::slotConfigWPAP()
+{
+ // Bring up the WPA-Personal config dialog
+
+ dialogWPAP = new dialogWPAPersonal();
+
+ if ( ! WPAPersonalKey.isEmpty() )
+ {
+ dialogWPAP->setKey(WPAPersonalKey);
+ }
+
+ connect( dialogWPAP, SIGNAL( saved(QString) ), this, SLOT( slotWPAPChanged(QString) ) );
+ dialogWPAP->exec();
+}
-void wifiselectiondialog::startScan()
+
+void wifiselectiondialog::slotConfigWPAE()
{
- scanWifi();
+ // Bring up the WPA-Enterprise config dialog
+
+ dialogWPAE = new dialogWPAEnterprise();
+
+ if ( ! WPAEIdent.isEmpty() )
+ {
+ dialogWPAE->setVariables(WPAEType, WPAEIdent, WPAECACert, WPAEClientCert, WPAEPrivKeyFile, WPAEPassword);
+ }
+
+ connect( dialogWPAE, SIGNAL( saved(int, QString, QString, QString, QString, QString) ), this, SLOT( slotWPAEChanged(int, QString, QString, QString, QString, QString) ) );
+ dialogWPAE->exec();
}
+void wifiselectiondialog::slotWPAPChanged( QString newKey )
+{
+ WPAPersonalKey = newKey;
+ slotCheckSecurityRadio();
+}
+
+
+void wifiselectiondialog::slotWPAEChanged( int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass )
+{
+WPAEType = type;
+WPAEIdent=EAPIdent;
+WPAECACert=CACert;
+WPAEClientCert=ClientCert;
+WPAEPrivKeyFile=PrivKeyFile;
+WPAEPassword=PrivKeyPass;
+
+slotCheckSecurityRadio();
+
+}
+
Modified: pcbsd/branches/7.0/wificonfig/wifiselectiondialog.h
===================================================================
--- pcbsd/branches/7.0/wificonfig/wifiselectiondialog.h 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/branches/7.0/wificonfig/wifiselectiondialog.h 2008-10-14 21:54:18 UTC (rev 2904)
@@ -4,6 +4,10 @@
#include <qfile.h>
#include <qmessagebox.h>
#include <qdialog.h>
+#include "wepconfig.h"
+#include "dialogwpapersonal.h"
+#include "dialogwpaenterprise.h"
+#include "wifiscanssid.h"
#include "ui_wifiselectiondialog.h"
class wifiselectiondialog : public QDialog, private Ui::wifiselectiondialog
@@ -16,7 +20,7 @@
setupUi(this);
}
- void init( QString Device, QString oldSSID );
+ void init(QString device);
void scanWifi();
@@ -25,19 +29,48 @@
private slots:
void slotCancel();
void slotConnect();
- void slotRescan();
- void startScan();
+ void slotOpenWifiScan();
+ void slotSSIDChanged(QString newSSID);
+ void slotConfigWEP();
+ void slotWEPChanged( QString newKey, int newIndex, bool hexkey );
+ void slotCheckSecurityRadio();
+ void slotCheckWhichSecurity();
+ void slotConfigWPAP();
+ void slotConfigWPAE();
+ void slotWPAPChanged( QString newKey );
+ void slotWPAEChanged( int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass );
private:
QString DeviceName;
QString SSID;
- QString getLineFromCommandOutput( QString command );
- void runCommand( QString Command );
+ // Setup our dialogs
+ wifiscanssid *dialogWifiscanssid;
+ wepConfig *dialogWEP;
+ dialogWPAPersonal *dialogWPAP;
+ dialogWPAEnterprise *dialogWPAE;
+ // WEP variables
+ QString WEPKey;
+ int WEPIndex;
+ bool WEPHex;
+ // WPA Personal Key variable
+ QString WPAPersonalKey;
+
+ // WPAE Variables
+ int WPAEType;
+ QString WPAEIdent;
+ QString WPAECACert;
+ QString WPAEClientCert;
+ QString WPAEPrivKeyFile;
+ QString WPAEPassword;
+
signals:
- void saved(QString);
+ void signalSavedOpen(QString, bool);
+ void signalSavedWEP(QString, bool, QString, int, bool );
+ void signalSavedWPA(QString, bool, QString);
+ void signalSavedWPAE(QString, bool, int, QString, QString, QString, QString, QString);
} ;
#endif // WIFISELECTIONDIALOG_H
Modified: pcbsd/branches/7.0/wificonfig/wifiselectiondialog.ui
===================================================================
--- pcbsd/branches/7.0/wificonfig/wifiselectiondialog.ui 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/branches/7.0/wificonfig/wifiselectiondialog.ui 2008-10-14 21:54:18 UTC (rev 2904)
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>420</width>
- <height>314</height>
+ <width>410</width>
+ <height>355</height>
</rect>
</property>
<property name="windowTitle" >
@@ -16,83 +16,104 @@
<iconset resource="wificonfig.qrc" >
<normaloff>:/tray_wifi85.png</normaloff>:/tray_wifi85.png</iconset>
</property>
- <layout class="QGridLayout" >
- <item row="0" column="0" colspan="3" >
- <widget class="QLabel" name="textTop" >
- <property name="frameShape" >
- <enum>QFrame::NoFrame</enum>
+ <layout class="QGridLayout" name="gridLayout_3" >
+ <item row="0" column="0" >
+ <widget class="Q3GroupBox" name="groupBSSID" >
+ <property name="enabled" >
+ <bool>true</bool>
</property>
- <property name="frameShadow" >
- <enum>QFrame::Plain</enum>
+ <property name="title" >
+ <string>Selected Wireless Network</string>
</property>
- <property name="text" >
- <string>Select a wireless network to connect.</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
+ <layout class="QGridLayout" name="gridLayout_2" >
+ <item row="0" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <widget class="QLineEdit" name="lineSSID" />
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushScan" >
+ <property name="text" >
+ <string>Scan</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QCheckBox" name="checkBSSID" >
+ <property name="enabled" >
+ <bool>true</bool>
+ </property>
+ <property name="text" >
+ <string>Using BSSID</string>
+ </property>
+ <property name="shortcut" >
+ <string/>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
- <item row="3" column="1" >
- <widget class="QPushButton" name="pushConnect" >
- <property name="text" >
- <string>&Connect</string>
- </property>
- <property name="shortcut" >
- <string>Alt+C</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <spacer name="spacer8" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>70</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="3" column="2" >
- <widget class="QPushButton" name="pushCancel" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="3" >
- <spacer name="spacer9" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>270</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="0" colspan="3" >
- <widget class="Q3GroupBox" name="groupBox2" >
+ <item row="1" column="0" >
+ <widget class="Q3ButtonGroup" name="buttonGroupSecurity" >
<property name="title" >
- <string>Available wireless networks</string>
+ <string>Security Mode</string>
</property>
- <layout class="QGridLayout" >
- <item row="0" column="0" colspan="2" >
- <widget class="Q3ListBox" name="listWifi" />
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QRadioButton" name="radioSecurityDisabled" >
+ <property name="text" >
+ <string>Disabled</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioSecurityWEP" >
+ <property name="enabled" >
+ <bool>true</bool>
+ </property>
+ <property name="text" >
+ <string>WEP</string>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioSecurityWPAPersonal" >
+ <property name="text" >
+ <string>WPA Personal</string>
+ </property>
+ <property name="shortcut" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioSecurityWPAEnt" >
+ <property name="text" >
+ <string>WPA Enterprise</string>
+ </property>
+ <property name="shortcut" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item row="1" column="0" >
- <spacer name="spacer10" >
+ <spacer name="spacer6" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
@@ -101,25 +122,78 @@
</property>
<property name="sizeHint" stdset="0" >
<size>
- <width>131</width>
+ <width>130</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" >
- <widget class="QPushButton" name="pushRescan" >
+ <widget class="QPushButton" name="pushSecurity" >
<property name="text" >
- <string>&Rescan</string>
+ <string>Configure</string>
</property>
<property name="shortcut" >
- <string>Alt+R</string>
+ <string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
+ <item row="2" column="0" >
+ <spacer name="spacer9" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>270</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="3" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <spacer name="spacer8" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>70</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushConnect" >
+ <property name="text" >
+ <string>Add</string>
+ </property>
+ <property name="shortcut" >
+ <string>Alt+C</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushCancel" >
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
@@ -132,9 +206,10 @@
<container>1</container>
</customwidget>
<customwidget>
- <class>Q3ListBox</class>
- <extends>Q3Frame</extends>
- <header>q3listbox.h</header>
+ <class>Q3ButtonGroup</class>
+ <extends>Q3GroupBox</extends>
+ <header>Qt3Support/Q3ButtonGroup</header>
+ <container>1</container>
</customwidget>
</customwidgets>
<includes>
@@ -146,54 +221,5 @@
<resources>
<include location="wificonfig.qrc" />
</resources>
- <connections>
- <connection>
- <sender>pushCancel</sender>
- <signal>clicked()</signal>
- <receiver>wifiselectiondialog</receiver>
- <slot>slotCancel()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>pushConnect</sender>
- <signal>clicked()</signal>
- <receiver>wifiselectiondialog</receiver>
- <slot>slotConnect()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>pushRescan</sender>
- <signal>clicked()</signal>
- <receiver>wifiselectiondialog</receiver>
- <slot>slotRescan()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>
Property changes on: pcbsd/trunk/wificonfig/arrow-down.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: pcbsd/trunk/wificonfig/arrow-up.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: pcbsd/trunk/wificonfig/dialogwpapersonal.cpp
===================================================================
--- pcbsd/trunk/wificonfig/dialogwpapersonal.cpp 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/trunk/wificonfig/dialogwpapersonal.cpp 2008-10-14 21:54:18 UTC (rev 2904)
@@ -23,10 +23,17 @@
void dialogWPAPersonal::slotClose()
{
if ( lineKey->text() != lineKey2->text() )
- {
- QMessageBox::warning( this, "Network Key Error", "Error: The entered network keys do not match!\n" );
- } else {
- emit saved(lineKey->text());
- close();
- }
+ {
+ QMessageBox::warning( this, "Network Key Error", "Error: The entered network keys do not match!\n" );
+ return;
+ }
+
+ if ( lineKey->text().length() < 8 || lineKey->text().length() > 63 )
+ {
+ QMessageBox::warning( this, "Network Key Error", "Error: The network key must be between 8-63 characters in length!\n" );
+ return;
+ }
+
+ emit saved(lineKey->text());
+ close();
}
Property changes on: pcbsd/trunk/wificonfig/edit-delete.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: pcbsd/trunk/wificonfig/list-add.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: pcbsd/trunk/wificonfig/object-locked.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: pcbsd/trunk/wificonfig/object-unlocked.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: pcbsd/trunk/wificonfig/wificonfig.pro
===================================================================
--- pcbsd/trunk/wificonfig/wificonfig.pro 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/trunk/wificonfig/wificonfig.pro 2008-10-14 21:54:18 UTC (rev 2904)
@@ -11,6 +11,7 @@
dialogwpapersonal.h \
wepconfig.h \
wificonfigwidgetbase.h \
+ wifiscanssid.h \
wifiselectiondialog.h
SOURCES += main.cpp \
@@ -18,12 +19,14 @@
dialogwpapersonal.cpp \
wepconfig.cpp \
wificonfigwidgetbase.cpp \
+ wifiscanssid.cpp \
wifiselectiondialog.cpp
FORMS = wificonfigwidgetbase.ui \
wifiselectiondialog.ui \
wepconfig.ui \
dialogwpapersonal.ui \
+ wifiscanssid.ui \
dialogwpaenterprise.ui
TRANSLATIONS = wificonfig_en.ts
Modified: pcbsd/trunk/wificonfig/wificonfig.qrc
===================================================================
--- pcbsd/trunk/wificonfig/wificonfig.qrc 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/trunk/wificonfig/wificonfig.qrc 2008-10-14 21:54:18 UTC (rev 2904)
@@ -1,5 +1,11 @@
<RCC>
<qresource>
+ <file>object-locked.png</file>
+ <file>object-unlocked.png</file>
+ <file>edit-delete.png</file>
+ <file>list-add.png</file>
+ <file>arrow-up.png</file>
+ <file>arrow-down.png</file>
<file>folder_open.png</file>
<file>tray_wifi85.png</file>
</qresource>
Modified: pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp
===================================================================
--- pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp 2008-10-14 21:54:18 UTC (rev 2904)
@@ -73,177 +73,98 @@
ifConfigLine="DHCP";
}
+ saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
- // Check if we are not using security and write the entry
- if ( radioSecurityDisabled->isChecked() )
- {
- saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
+ // Now create the wpa_supplicant file based on saved configuration
+ QFile fileout( "/etc/wpa_supplicant.conf" );
+ if ( fileout.open( IO_WriteOnly ) ) {
+ QTextStream streamout( &fileout );
- // Now create the wpa_supplicant file based on saved configuration
- QFile fileout( "/etc/wpa_supplicant.conf" );
- if ( fileout.open( IO_WriteOnly ) ) {
+ // Loop through all the devices we have now
+ for(int curItem=0; curItem < 149; curItem++)
+ {
+ if ( ! SSIDList[curItem].isEmpty() )
+ {
- QTextStream streamout( &fileout );
- if ( checkBSSID->isChecked() ) {
- streamout << "network={\n bssid=\"" + lineBSSID->text() + "\"\n";
+
+
+
+ if ( BSSID[curItem]) {
+ streamout << "network={\n bssid=" + SSIDList[curItem] + "\n";
+ } else {
+ streamout << "network={\n ssid=\"" + SSIDList[curItem] + "\"\n";
+ }
+
+ streamout << " scan_ssid=1\n";
+
+ if ( SSIDEncType[curItem] == NO_ENCRYPTION )
+ {
+ streamout << " key_mgmt=NONE\n";
+ } else if (SSIDEncType[curItem] == WEP_ENCRYPTION ) {
+
+ streamout << " key_mgmt=NONE\n";
+ streamout << " wep_tx_keyidx=" + tmp.setNum(WEPIndex[curItem]) + "\n";
+ // Check if we are using a plaintext WEP or not
+ if ( WEPHex[curItem] ) {
+ streamout << " wep_key" + tmp.setNum(WEPIndex[curItem]) + "=" + WEPKey[curItem] + "\n";
} else {
- streamout << "network={\n ssid=\"" + lineSSID->text() + "\"\n";
+ streamout << " wep_key" + tmp.setNum(WEPIndex[curItem]) + "=\"" + WEPKey[curItem] + "\"\n";
}
- streamout << " scan_ssid=1\n";
- streamout << " key_mgmt=NONE\n";
- streamout << "}\n";
- fileout.close();
+ } else if (SSIDEncType[curItem] == WPA_ENCRYPTION ) {
- }
- } else if (radioSecurityWEP->isChecked() ) {
- // Write the settings with WEP enabled
-
- // Check that we even have a WEP Key yet
- if ( WEPKey.isEmpty() )
- {
- QMessageBox::warning( this, tr("Warning"),
- tr("WEP is selected, but not configured!\nPlease configure your WEP key before saving!") );
- return;
- }
-
- // Indicate that we are using WPA supplicant
- saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
+ streamout << " psk=\"" + WPAPersonalKey[curItem] + "\"\n";
- // Now create the wpa_supplicant file based on saved configuration
- QFile fileout( "/etc/wpa_supplicant.conf" );
- if ( fileout.open( IO_WriteOnly ) ) {
- QTextStream streamout( &fileout );
- if ( checkBSSID->isChecked() ) {
- streamout << "network={\n bssid=\"" + lineBSSID->text() + "\"\n";
- } else {
- streamout << "network={\n ssid=\"" + lineSSID->text() + "\"\n";
- }
+ } else if (SSIDEncType[curItem] == WPAE_ENCRYPTION ) {
- streamout << " scan_ssid=1\n";
- streamout << " key_mgmt=NONE\n";
- streamout << " wep_tx_keyidx=" + tmp.setNum(WEPIndex -1) + "\n";
- streamout << " wep_key" + tmp.setNum(WEPIndex -1) + "=" + WEPKey + "\n";
- streamout << "}\n";
- fileout.close();
- }
+ if ( WPAEType[curItem] == 1) {
+ streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=TLS\n";
+ streamout << " identity=\"" + WPAEIdent[curItem] + "\"\n";
+ streamout << " ca_cert=\"" + WPAECACert[curItem] + "\"\n";
+ streamout << " client_cert=\"" + WPAEClientCert[curItem] + "\"\n";
+ streamout << " private_key=\"" + WPAEPrivKeyFile[curItem] + "\"\n";
+ streamout << " private_key_password=\"" + WPAEPassword[curItem] + "\"\n";
-
- } else if (radioSecurityWPAPersonal->isChecked() ) {
- // Write the settings with WPA-Personal enabled
-
- // Check that we even have a WPA-Personal Key yet
- if ( WPAPersonalKey.isEmpty() )
- {
- QMessageBox::warning( this, tr("Warning"),
- tr("WPA-Personal is selected, but not configured!\nPlease configure your WPA key before saving!") );
- return;
- }
-
-
- // If we are using WPA security, write the ifconfig line, and wpa_supplicant line
- saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
- // Now create the wpa_supplicant file based on saved configuration
- QFile fileout( "/etc/wpa_supplicant.conf" );
- if ( fileout.open( IO_WriteOnly ) ) {
- QTextStream streamout( &fileout );
- if ( checkBSSID->isChecked() ) {
- streamout << "network={\n bssid=\"" + lineBSSID->text() + "\"\n ";
- } else {
- streamout << "network={\n ssid=\"" + lineSSID->text() + "\"\n ";
- }
-
- streamout << " scan_ssid=1\n";
- streamout << " psk=\"" + WPAPersonalKey + "\"\n}\n";
- fileout.close();
- }
-} else if (radioSecurityWPAEnt->isChecked() ) {
- // Write the settings with WPA-Enterprise enabled
-
- // Check if the key is setup for WPA EAP-TLS
- if ( WPAEType == 1 && ( WPAEIdent.isEmpty() || WPAECACert.isEmpty() || WPAEClientCert.isEmpty() || WPAEPrivKeyFile.isEmpty() || WPAEPassword.isEmpty() )) {
- QMessageBox::warning( this, tr("Warning"),
- tr("WPA-Enterprise is selected, but not configured!\nPlease configure your WPA settings before saving!") );
- return;
- }
-
- // Check if the key is setup for WPA EAP-TTLS && EAP-PEAP
- if ( (WPAEType == 2 || WPAEType == 3) && ( WPAEIdent.isEmpty() || WPAECACert.isEmpty() || WPAEPassword.isEmpty() ) ) {
- QMessageBox::warning( this, tr("Warning"),
- tr("WPA-Enterprise is selected, but not configured!\nPlease configure your WPA settings before saving!") );
- return;
- }
-
-
-
- // If we are using WPA security, write the ifconfig line, and wpa_supplicant line
- saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1);
- // Now create the wpa_supplicant file based on saved configuration
- QFile fileout( "/etc/wpa_supplicant.conf" );
- if ( fileout.open( IO_WriteOnly ) ) {
- QTextStream streamout( &fileout );
-
-
- streamout << "network={\n ssid=\"" + lineSSID->text() + "\"\n";
- if ( WPAEType == 1) {
- streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=TLS\n";
- streamout << " identity=\"" + WPAEIdent + "\"\n";
- streamout << " ca_cert=\"" + WPAECACert + "\"\n";
- streamout << " client_cert=\"" + WPAEClientCert + "\"\n";
- streamout << " private_key=\"" + WPAEPrivKeyFile + "\"\n";
- streamout << " private_key_password=\"" + WPAEPassword + "\"\n";
- streamout << " scan_ssid=1\n";
- } else if (WPAEType == 2) {
- streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=TTLS\n";
- streamout << " identity=\"" + WPAEIdent + "\"\n";
- streamout << " password=\"" + WPAEPassword + "\"\n";
- streamout << " ca_cert=\"" + WPAECACert + "\"\n";
- streamout << " phase2=\"auth=MD5\"\n";
- streamout << " scan_ssid=1\n";
-
- } else if (WPAEType == 3) {
- streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=PEAP\n";
- streamout << " identity=\"" + WPAEIdent + "\"\n";
- streamout << " password=\"" + WPAEPassword + "\"\n";
- streamout << " ca_cert=\"" + WPAECACert + "\"\n";
- streamout << " phase1=\"peaplabel=0\"\n";
- streamout << " phase2=\"auth=MSCHAPV2\"\n";
- streamout << " scan_ssid=1\n";
- }
-
- streamout << "}\n";
-
-
- fileout.close();
- }
-}
+ } else if (WPAEType[curItem] == 2) {
+ streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=TTLS\n";
+ streamout << " identity=\"" + WPAEIdent[curItem] + "\"\n";
+ streamout << " password=\"" + WPAEPassword[curItem] + "\"\n";
+ streamout << " ca_cert=\"" + WPAECACert[curItem] + "\"\n";
+ streamout << " phase2=\"auth=MD5\"\n";
-
-
- // Now restart the network for new settings to take effect
+ } else if (WPAEType[curItem] == 3) {
+ streamout << " proto=RSN\n key_mgmt=WPA-EAP\n eap=PEAP\n";
+ streamout << " identity=\"" + WPAEIdent[curItem] + "\"\n";
+ streamout << " password=\"" + WPAEPassword[curItem] + "\"\n";
+ streamout << " ca_cert=\"" + WPAECACert[curItem] + "\"\n";
+ streamout << " phase1=\"peaplabel=0\"\n";
+ streamout << " phase2=\"auth=MSCHAPV2\"\n";
+ }
+ }
+ streamout << "}\n\n";
- QFile filerestart( "/tmp/.netrestart.sh" );
- if ( filerestart.open( IO_WriteOnly ) ) {
+ } // End of if check if SSIDList is empty
+ } // End of for loop
+
+ fileout.close();
+ }
+
+
+ // Now restart the network for new settings to take effect
+ QFile filerestart( "/tmp/.netrestart.sh" );
+ if ( filerestart.open( IO_WriteOnly ) ) {
QTextStream streamrestart( &filerestart );
streamrestart << "#!/bin/sh\n";
streamrestart << "/etc/rc.d/netif restart " << DeviceName << "\n";
- streamrestart << "/etc/rc.d/routing restart";
+ //streamrestart << "/etc/rc.d/routing restart";
filerestart.close();
- }
+ }
- runCommand("chmod 755 /tmp/.netrestart.sh ; sh /tmp/.netrestart.sh");
+ runCommand("chmod 755 /tmp/.netrestart.sh ; sh /tmp/.netrestart.sh");
- pushApply->setEnabled(FALSE);
-
- // netifProc = new Q3Process( this );
- // netifProc->addArgument( "/tmp/.netrestart.sh" );
-
- // if ( !netifProc->start() ) {
- // }
-
-
+ pushApply->setEnabled(FALSE);
}
@@ -259,24 +180,15 @@
}
+// Function which is called at the program init
void wificonfigwidgetbase::setDevice( QString Device )
{
+ // Connect our add / remove buttons for wifi
+ connect( pushAddWifi, SIGNAL( clicked() ), this, SLOT( slotAddNewProfile() ) );
+ connect( pushRemoveWifi, SIGNAL( clicked() ), this, SLOT( slotRemoveProfile() ) );
-// Make sure our variables are initialized properly
-WEPKey = "";
-WEPIndex = 1;
-WEPHex = true;
-WPAPersonalKey = "";
-WPAEType = 1;
-WPAEIdent="";
-WPAECACert="";
-WPAEClientCert="";
-WPAEPrivKeyFile="";
-WPAEPassword="";
-
-
// Save the device name for later
DeviceName = Device;
@@ -480,12 +392,41 @@
return "";
}
+void wificonfigwidgetbase::slotRemoveProfile()
+{
+ // Check if we have a selection to work with
+ if ( listWifi->currentRow() != -1 )
+ {
+ // Locate the SSID we want to remove
+ QString removeSSID = listWifi->item(listWifi->currentRow())->text();
+ for ( int curItem = 0; curItem < 149; curItem++)
+ {
+ if ( SSIDList[curItem] == removeSSID )
+ {
+ SSIDList[curItem] = "";
+ }
+ }
-void wificonfigwidgetbase::slotConfig()
+ // Refresh the SSID list and enable the apply button
+ slotRefreshSSIDList();
+ pushApply->setEnabled(TRUE);
+
+ }
+
+}
+
+void wificonfigwidgetbase::slotAddNewProfile()
{
wifiselect = new wifiselectiondialog();
- wifiselect->init(DeviceName, lineSSID->text());
- connect( wifiselect, SIGNAL( saved(QString) ), this, SLOT( slotSSIDChanged(QString) ) );
+ wifiselect->init(DeviceName);
+
+ connect( wifiselect, SIGNAL( signalSavedOpen(QString, bool) ), this, SLOT( slotAddNewProfileOpen(QString, bool) ) );
+
+ connect( wifiselect, SIGNAL( signalSavedWEP( QString, bool, QString, int, bool ) ), this, SLOT( slotAddNewProfileWEP( QString, bool, QString, int, bool) ) );
+ connect( wifiselect, SIGNAL( signalSavedWPA(QString, bool, QString) ), this, SLOT( slotAddNewProfileWPA(QString, bool, QString) ) );
+
+ connect( wifiselect, SIGNAL( signalSavedWPAE(QString, bool, int, QString, QString, QString, QString, QString) ), this, SLOT( slotAddNewProfileWPAE(QString, bool, int, QString, QString, QString, QString, QString) ) );
+
wifiselect->exec();
}
@@ -496,155 +437,139 @@
fclose(file);
}
-
-void wificonfigwidgetbase::slotSSIDChanged( QString newSSID )
+void wificonfigwidgetbase::slotAddNewProfileOpen(QString SSID, bool isBSSID)
{
- lineSSID->setText(newSSID);
-}
+ for (int dupItem = 0; dupItem < 149; dupItem++)
+ {
+ if ( SSID == SSIDList[dupItem] ) {
+ QMessageBox::warning( this, tr("Error"), tr("You already have a wireless network with this SSID! Please remove it first.\n") );
+ return;
+ }
+ }
-void wificonfigwidgetbase::slotConfigWEP()
-{
- dialogWEP = new wepConfig();
-
- if ( ! WEPKey.isEmpty() )
+
+ int curItem=0;
+
+ while( ! SSIDList[curItem].isEmpty() && curItem < 149 )
{
- dialogWEP->setKey(WEPKey, WEPIndex, WEPHex);
+ curItem++;
}
-
- connect( dialogWEP, SIGNAL( saved(QString, int, bool) ), this, SLOT( slotWEPChanged(QString, int, bool) ) );
- dialogWEP->exec();
-}
+ // Find which current item we are working on
-void wificonfigwidgetbase::slotWEPChanged( QString newKey, int newIndex, bool hexkey )
-{
- WEPKey = newKey;
- WEPIndex = newIndex;
- WEPHex = hexkey;
- // Check the status of the radio buttons
- slotCheckSecurityRadio();
+ SSIDList[curItem] = SSID;
+ BSSID[curItem] = isBSSID;
+ // Refresh the SSID listbox and enable the apply button
+ slotRefreshSSIDList();
+ slotCheckGlobalText();
}
-
-void wificonfigwidgetbase::slotCheckSecurityRadio()
+void wificonfigwidgetbase::slotAddNewProfileWEP( QString SSID, bool isBSSID, QString newKey, int newIndex, bool hexkey )
{
- // Check to see which radio button is checked and take approiate actions
-
- if ( radioSecurityDisabled->isChecked() )
- {
- pushSecurity->setEnabled(FALSE);
- } else if ( radioSecurityWEP->isChecked() ) {
- pushSecurity->setEnabled(TRUE);
- // Check if the key is setup
- if ( ! WEPKey.isEmpty() )
- {
- radioSecurityWEP->setText( tr("WEP (Configured)") );
- } else {
- radioSecurityWEP->setText( tr("WEP") );
- }
- } else if ( radioSecurityWPAPersonal->isChecked() ) {
- pushSecurity->setEnabled(TRUE);
- // Check if the key is setup
- if ( ! WPAPersonalKey.isEmpty() )
- {
- radioSecurityWPAPersonal->setText( tr("WPA Personal (Configured)") );
- } else {
- radioSecurityWPAPersonal->setText( tr("WPA Personal") );
- }
-
- } else if ( radioSecurityWPAEnt->isChecked() ) {
- pushSecurity->setEnabled(TRUE);
-
- // Check if the key is setup
- if ( ! WPAEIdent.isEmpty() && ! WPAECACert.isEmpty() && ! WPAEPassword.isEmpty() ) {
- radioSecurityWPAEnt->setText(tr("WPA Enterprise (Configured)") );
- } else {
- radioSecurityWPAEnt->setText(tr("WPA Enterprise") );
- }
+ for (int dupItem = 0; dupItem < 149; dupItem++)
+ {
+ if ( SSID == SSIDList[dupItem] ) {
+ QMessageBox::warning( this, tr("Error"), tr("You already have a wireless network with this SSID! Please remove it first.\n") );
+ return;
+ }
+ }
- }
- pushApply->setEnabled(TRUE);
-}
+ int curItem=0;
+ while( ! SSIDList[curItem].isEmpty() && curItem < 149 )
+ {
+ curItem++;
+ }
-void wificonfigwidgetbase::slotCheckWhichSecurity()
-{
- if ( radioSecurityDisabled->isChecked() )
- {
- return;
- } else if ( radioSecurityWEP->isChecked() ) {
- // Run the WEP config dialog
- slotConfigWEP();
- } else if ( radioSecurityWPAPersonal->isChecked() ) {
- slotConfigWPAP();
- } else if ( radioSecurityWPAEnt->isChecked() ) {
- slotConfigWPAE();
- }
+ // Find which current item we are working on
+
+ SSIDList[curItem] = SSID;
+ SSIDEncType[curItem] = WEP_ENCRYPTION;
+ BSSID[curItem] = isBSSID;
+ WEPKey[curItem] = newKey;
+ WEPIndex[curItem] = newIndex;
+ WEPIndex[curItem]--;
+ WEPHex[curItem] = hexkey;
+ // Refresh the SSID listbox and enable the apply button
+ slotRefreshSSIDList();
+ slotCheckGlobalText();
+
}
-void wificonfigwidgetbase::slotConfigWPAP()
+void wificonfigwidgetbase::slotAddNewProfileWPA( QString SSID, bool isBSSID, QString newKey )
{
- // Bring up the WPA-Personal config dialog
-
- dialogWPAP = new dialogWPAPersonal();
-
- if ( ! WPAPersonalKey.isEmpty() )
+ for (int dupItem = 0; dupItem < 149; dupItem++)
{
- dialogWPAP->setKey(WPAPersonalKey);
+ if ( SSID == SSIDList[dupItem] ) {
+ QMessageBox::warning( this, tr("Error"), tr("You already have a wireless network with this SSID! Please remove it first.\n") );
+ return;
+ }
}
-
- connect( dialogWPAP, SIGNAL( saved(QString) ), this, SLOT( slotWPAPChanged(QString) ) );
- dialogWPAP->exec();
-}
+ int curItem=0;
-
-void wificonfigwidgetbase::slotConfigWPAE()
-{
- // Bring up the WPA-Enterprise config dialog
-
- dialogWPAE = new dialogWPAEnterprise();
-
- if ( ! WPAEIdent.isEmpty() )
+ while( ! SSIDList[curItem].isEmpty() && curItem < 149 )
{
- dialogWPAE->setVariables(WPAEType, WPAEIdent, WPAECACert, WPAEClientCert, WPAEPrivKeyFile, WPAEPassword);
+ curItem++;
}
+
+
+ SSIDList[curItem] = SSID;
+ SSIDEncType[curItem] = WPA_ENCRYPTION;
+ BSSID[curItem] = isBSSID;
+ WPAPersonalKey[curItem] = newKey;
- connect( dialogWPAE, SIGNAL( saved(int, QString, QString, QString, QString, QString) ), this, SLOT( slotWPAEChanged(int, QString, QString, QString, QString, QString) ) );
- dialogWPAE->exec();
+ // Refresh the SSID listbox and enable the apply button
+ slotRefreshSSIDList();
+ slotCheckGlobalText();
}
-void wificonfigwidgetbase::slotWPAPChanged( QString newKey )
+void wificonfigwidgetbase::slotAddNewProfileWPAE( QString SSID, bool isBSSID, int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass )
{
- WPAPersonalKey = newKey;
- slotCheckSecurityRadio();
-}
+ for (int dupItem = 0; dupItem < 149; dupItem++)
+ {
+ if ( SSID == SSIDList[dupItem] ) {
+ QMessageBox::warning( this, tr("Error"), tr("You already have a wireless network with this SSID! Please remove it first.\n") );
+ return;
+ }
+ }
-void wificonfigwidgetbase::slotWPAEChanged( int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass )
-{
-WPAEType = type;
-WPAEIdent=EAPIdent;
-WPAECACert=CACert;
-WPAEClientCert=ClientCert;
-WPAEPrivKeyFile=PrivKeyFile;
-WPAEPassword=PrivKeyPass;
+ int curItem=0;
-slotCheckSecurityRadio();
+ while( ! SSIDList[curItem].isEmpty() && curItem < 149 )
+ {
+ curItem++;
+ }
+
+ SSIDList[curItem] = SSID;
+ SSIDEncType[curItem] = WPAE_ENCRYPTION;
+ BSSID[curItem] = isBSSID;
+ WPAEType[curItem] = type;
+ WPAEIdent[curItem] = EAPIdent;
+ WPAECACert[curItem] = CACert;
+ WPAEClientCert[curItem] = ClientCert;
+ WPAEPrivKeyFile[curItem] = PrivKeyFile;
+ WPAEPassword[curItem] = PrivKeyPass;
+
+ // Refresh the SSID listbox and enable the apply button
+ slotRefreshSSIDList();
+ slotCheckGlobalText();
+
}
void wificonfigwidgetbase::slotCheckDisabled()
{
- if ( checkDisableWireless->isChecked() )
- {
+ if ( checkDisableWireless->isChecked() )
+ {
tabMainWidget->setEnabled(FALSE);
} else {
tabMainWidget->setEnabled(TRUE);
@@ -790,7 +715,7 @@
void wificonfigwidgetbase::showInfo()
{
- tabMainWidget->showPage( tabMainWidget->page(3) );
+ tabMainWidget->showPage( tabMainWidget->page(2) );
}
@@ -826,327 +751,229 @@
}
- // Look for the SSID
- if ( tmp.find(" ssid") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find(" ssid") + 5 );
+ } else if ( tmp.find("inet") != -1 ) {
+ // Get the IP address first
+ tmp2 = tmp;
+ tmp2 = tmp2.remove(0, tmp.find("inet") + 5 );
+ tmp2.truncate(tmp.find("netmask") -1 );
+ lineIP->setText(tmp2);
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- if ( tmp2.find("\"") != -1)
- {
- tmp2 = tmp2.remove(0, tmp2.find("\"") +1 );
- tmp2.truncate(tmp2.findRev("\"") );
- }
- lineSSID->setText(tmp2);
- }
-
-
-
- // Look for the BSSID
- if ( tmp.find("bssid") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("bssid") + 5 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- lineBSSID->setText(tmp2);
- lineSSID->setText("");
- checkBSSID->setChecked(TRUE);
- slotBSSIDChecked();
- }
-
- // Look for the WEP Encryption
- if ( tmp.find("wepkey") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("wepkey") + 6 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
+ // Look for the netmask
+ if ( tmp.find("netmask") != -1 ) {
+ tmp2 = tmp;
+ tmp2 = tmp2.remove(0, tmp.find("netmask") + 8 );
+ if ( tmp.find("ether") != -1 ) {
+ tmp2.truncate(tmp.find("ether") );
+ }
- // Check if we are using the hex key, or plain text
- if ( tmp2.indexOf("0x") == 0)
- {
- WEPHex = true;
- // Remove the 0x
- tmp2.remove(0, 2);
- } else {
- WEPHex = false;
- }
+ lineNetmask->setText(tmp2);
- // Check if we need to remove the "0x"
- WEPKey = tmp2;
+ } else {
+ // No netmask specified, default it instead
+ lineNetmask->setText("255.255.255.0");
+ }
+ }
+
+ // Look for the wpa_supplicant.conf file
+ QFile file( "/etc/wpa_supplicant.conf" );
+ if ( file.open( IO_ReadOnly ) ) {
+ int curItem=0;
+ QTextStream stream( &file );
+ QString line;
+ while ( !stream.atEnd() ) {
- radioSecurityWEP->setChecked(TRUE);
- }
-
- // Look for the WEP transmit key
- if ( tmp.find("weptxkey") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("weptxkey") + 8 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
-
- ok = tmp2.toInt(&ok);
- if ( ok ) {
- WEPIndex = tmp2.toInt(&ok);
- }
- radioSecurityWEP->setChecked(TRUE);
- }
-
-
- } else {
-
- // Look for the SSID
- if ( tmp.find(" ssid") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find(" ssid") + 5 );
- tmp2.simplifyWhiteSpace();
+ line = stream.readLine(); // line of text excluding '\n'
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- if ( tmp2.find("\"") != -1)
- {
- tmp2 = tmp2.remove(0, tmp2.find("\"") +1 );
- tmp2.truncate(tmp2.findRev("\"") );
- }
+ // Check if we are at the end of a network profile block
+ if ( line.find("}") == 0)
+ {
+ curItem++;
+ }
- lineSSID->setText(tmp2);
- }
-
- // Look for the BSSID
- if ( tmp.find("bssid") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("bssid") + 5 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- lineBSSID->setText(tmp2);
- lineSSID->setText("");
- checkBSSID->setChecked(TRUE);
- slotBSSIDChecked();
- }
-
- // Get the IP address first
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("inet") + 5 );
- //tmp2 = tmp2.remove(0, tmp.find(" ") );
- tmp2.truncate(tmp.find("netmask") -1 );
- lineIP->setText(tmp2);
+ if ( line.find(" ssid=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") +1 );
+ tmp2.truncate(tmp2.find("\"") );
+ SSIDList[curItem] = tmp2;
+ BSSID[curItem] = false;
+ SSIDEncType[curItem]=NO_ENCRYPTION;
+ }
- // Look for the netmask
- if ( tmp.find("netmask") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("netmask") + 8 );
- if ( tmp.find("ether") != -1 ) {
- tmp2.truncate(tmp.find("ether") );
- }
- lineNetmask->setText(tmp2);
- } else {
- lineNetmask->setText("255.255.255.0");
- }
-
- // Look for the mac address change
- if ( tmp.find("ether") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("ether") + 6 );
- //if ( tmp.find(" ") != -1 ) {
- // tmp2.truncate(tmp.find(" ") );
- //}
- lineMAC->setText(tmp2);
- checkMAC->setChecked(FALSE);
- groupMAC->setEnabled(TRUE);
- }
+ if ( line.find(" bssid=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("=") +1 );
+ SSIDList[curItem] = tmp2;
+ BSSID[curItem] = true;
+ SSIDEncType[curItem]=NO_ENCRYPTION;
+ }
- // Look for the WEP Encryption
- if ( tmp.find("wepkey") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("wepkey") + 7 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
- tmp2.remove(0, 2);
- WEPKey = tmp2;
- radioSecurityWEP->setChecked(TRUE);
- }
- // Look for the WEP transmit key
- if ( tmp.find("weptxkey") != -1 ) {
- tmp2 = tmp;
- tmp2 = tmp2.remove(0, tmp.find("weptxkey") + 9 );
- tmp2.simplifyWhiteSpace();
- if ( tmp2.find(" ") != -1 ) {
- tmp2 = tmp2.section( " " , 1, 1 );
- }
-
+ // Check if we are using a WEP key for this network
+ if ( line.find("wep_key") != -1 )
+ {
+ if (line.find("\"") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate(tmp2.find("\""));
+ WEPHex[curItem]=false;
+ } else {
+ tmp2 = line.remove(0, line.find("=") + 1 );
+ WEPHex[curItem]=true;
+ }
+ // Save the keycode
+ WEPKey[curItem] = tmp2;
+ SSIDEncType[curItem]=WEP_ENCRYPTION;
+ }
+
+ // Check for the WEP tx key id
+ if ( line.find("wep_tx_keyidx") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("wep_tx_keyidx") +1 );
+ // Save the keycode
+ tmp2.truncate(tmp2.find("=") );
ok = tmp2.toInt(&ok);
if ( ok ) {
- WEPIndex = tmp2.toInt(&ok);
+ WEPIndex[curItem] = tmp2.toInt(&ok);
+ WEPIndex[curItem]++;
}
- radioSecurityWEP->setChecked(TRUE);
- }
- }
-
-
- // Load the security information here
-
- // Start check for wpa_supplicant tag
- if ( tmp.find("WPA") != -1 )
- {
- // Look for the wpa_supplicant.conf file
- QFile file( "/etc/wpa_supplicant.conf" );
- if ( file.open( IO_ReadOnly ) ) {
- QTextStream stream( &file );
- QString line;
- while ( !stream.atEnd() ) {
- line = stream.readLine(); // line of text excluding '\n'
-
- if ( line.find(" ssid=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") +1 );
- tmp2.truncate(tmp2.find("\"") );
- lineSSID->setText(tmp2);
- }
-
- // Check if we are using a WEP key for this network
- if ( line.find("wep_key") != -1 )
- {
- tmp2 = line.remove(0, line.find("=") +1 );
- // Save the keycode
- WEPKey = tmp2;
- radioSecurityWEP->setChecked(TRUE);
- }
-
- // Check for the WEP tx key id
- if ( line.find("wep_tx_keyidx") != -1 )
- {
- tmp2 = line.remove(0, line.find("wep_tx_keyidx") +1 );
- // Save the keycode
- tmp2.truncate(tmp2.find("=") );
- ok = tmp2.toInt(&ok);
- if ( ok ) {
- WEPIndex = tmp2.toInt(&ok);
- WEPIndex++;
- }
- radioSecurityWEP->setChecked(TRUE);
- }
+ }
- // Check if we are using WPA-Personal
- if ( line.find("psk=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check if we are using WPA-Personal
+ if ( line.find("psk=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAPersonalKey = tmp2;
- radioSecurityWPAPersonal->setChecked(TRUE);
- }
+ // Save the keycode
+ WPAPersonalKey[curItem] = tmp2;
+ SSIDEncType[curItem]=WPA_ENCRYPTION;
+ }
- // Check if we are using WPA-Enterprise
- if ( line.find("eap=") != -1 )
- {
- tmp2 = line.remove(0, line.find("=") + 1 );
+ // Check if we are using WPA-Enterprise
+ if ( line.find("eap=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("=") + 1 );
- //Check to see whic type of WPA-Ent we are using
- if ( tmp2 == "TLS") {
- WPAEType = 1;
- } else if (tmp2 == "TTLS" ) {
- WPAEType = 2;
- } else if (tmp2 == "PEAP" ) {
- WPAEType = 3;
- }
+ //Check to see whic type of WPA-Ent we are using
+ if ( tmp2 == "TLS") {
+ WPAEType[curItem] = 1;
+ } else if (tmp2 == "TTLS" ) {
+ WPAEType[curItem] = 2;
+ } else if (tmp2 == "PEAP" ) {
+ WPAEType[curItem] = 3;
+ }
- radioSecurityWPAEnt->setChecked(TRUE);
- }
+ SSIDEncType[curItem]=WPAE_ENCRYPTION;
+ }
- // Check for a identity= line
- if ( line.find("identity=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check for a identity= line
+ if ( line.find("identity=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEIdent = tmp2;
- }
+ // Save the keycode
+ WPAEIdent[curItem] = tmp2;
+ }
- // Check for a ca_cert= line
- if ( line.find("ca_cert=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check for a ca_cert= line
+ if ( line.find("ca_cert=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAECACert = tmp2;
- }
+ // Save the keycode
+ WPAECACert[curItem] = tmp2;
+ }
- // Check for a client_cert= line
- if ( line.find("client_cert=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check for a client_cert= line
+ if ( line.find("client_cert=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEClientCert = tmp2;
- }
+ // Save the keycode
+ WPAEClientCert[curItem] = tmp2;
+ }
- // Check for a private_key= line
- if ( line.find("private_key=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Check for a private_key= line
+ if ( line.find("private_key=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEPrivKeyFile = tmp2;
- }
-
- // Check for a private_key_passwd= line
- if ( line.find("private_key_passwd=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Save the keycode
+ WPAEPrivKeyFile[curItem] = tmp2;
+ }
+
+ // Check for a private_key_passwd= line
+ if ( line.find("private_key_passwd=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEPassword = tmp2;
- }
-
- // Check for a private_key_passwd= line
- if ( line.find("password=") != -1 )
- {
- tmp2 = line.remove(0, line.find("\"") + 1 );
- tmp2.truncate( tmp2.find("\"") );
+ // Save the keycode
+ WPAEPassword[curItem] = tmp2;
+ }
+
+ // Check for a private_key_passwd= line
+ if ( line.find("password=") != -1 )
+ {
+ tmp2 = line.remove(0, line.find("\"") + 1 );
+ tmp2.truncate( tmp2.find("\"") );
- // Save the keycode
- WPAEPassword = tmp2;
- }
+ // Save the keycode
+ WPAEPassword[curItem] = tmp2;
+ }
- }
-
- }
}
- }
+ }
+
+
+ // Refresh the ssid profile list
+ slotRefreshSSIDList();
- slotCheckSecurityRadio();
-
-
// Start loading the info tab
loadInfo();
pushApply->setEnabled(FALSE);
+ }
}
+// Slot which reads the arrays and displays the list of WIFI profiles
+void wificonfigwidgetbase::slotRefreshSSIDList()
+{
+
+ listWifi->clear();
+
+ int curItem=0;
+
+ while( ! SSIDList[curItem].isEmpty() )
+ {
+ if ( SSIDEncType[curItem] == NO_ENCRYPTION )
+ {
+ listWifi->addItem(new QListWidgetItem(QIcon(":object-unlocked.png"), SSIDList[curItem] ) );
+ } else {
+
+ listWifi->addItem(new QListWidgetItem(QIcon(":object-locked.png"), SSIDList[curItem] ) );
+ }
+
+ curItem++;
+
+ // We only need 150 wireless networks
+ if ( curItem > 149 )
+ {
+ break;
+ }
+ }
+
+}
+
+
QString wificonfigwidgetbase::getIPv6ForIdent( QString ident )
{
QString command = "nice ifconfig " +ident + " | grep \"inet6 \"";
@@ -1202,18 +1029,3 @@
pushApply->setEnabled(TRUE);
}
-
-
-
-void wificonfigwidgetbase::slotBSSIDChecked()
-{
- if ( checkBSSID->isChecked() )
- {
- groupBSSID->setEnabled(TRUE);
- lineBSSID->setEnabled(TRUE);
- } else {
- groupBSSID->setEnabled(FALSE);
- lineBSSID->setEnabled(FALSE);
- }
- pushApply->setEnabled(TRUE);
-}
Modified: pcbsd/trunk/wificonfig/wificonfigwidgetbase.h
===================================================================
--- pcbsd/trunk/wificonfig/wificonfigwidgetbase.h 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/trunk/wificonfig/wificonfigwidgetbase.h 2008-10-14 21:54:18 UTC (rev 2904)
@@ -14,6 +14,13 @@
#include "ui_wificonfigwidgetbase.h"
#include <Q3Process>
+
+// Setup our encryption type defines
+#define NO_ENCRYPTION 0
+#define WEP_ENCRYPTION 1
+#define WPA_ENCRYPTION 2
+#define WPAE_ENCRYPTION 3
+
class wificonfigwidgetbase : public QWidget, private Ui::wificonfigwidgetbase
{
Q_OBJECT
@@ -33,23 +40,19 @@
void slotClose();
void slotApply();
void slotCheckDHCPBox();
- void slotConfig();
- void slotSSIDChanged( QString newSSID );
- void slotConfigWEP();
- void slotWEPChanged( QString newKey, int newIndex, bool hexkey );
- void slotCheckSecurityRadio();
- void slotCheckWhichSecurity();
- void slotConfigWPAP();
- void slotConfigWPAE();
- void slotWPAPChanged( QString newKey );
- void slotWPAEChanged( int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass );
+ void slotAddNewProfile();
+ void slotRemoveProfile();
+ void slotAddNewProfileOpen( QString SSID, bool isBSSID );
+ void slotAddNewProfileWEP( QString SSID, bool isBSSID, QString newKey, int newIndex, bool hexkey );
+ void slotAddNewProfileWPA( QString SSID, bool isBSSID, QString newKey );
+ void slotAddNewProfileWPAE( QString SSID, bool isBSSID, int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass );
void slotCheckDisabled();
void slotOK();
void slotMACClicked();
void loadInfo();
void slotFinishLoading();
void slotCheckGlobalText();
- void slotBSSIDChecked();
+ void slotRefreshSSIDList();
private:
@@ -72,23 +75,23 @@
QString getMediaForIdent( QString ident );
QString DeviceName;
wifiselectiondialog *wifiselect;
- wepConfig *dialogWEP;
- QString WEPKey;
- int WEPIndex;
- bool WEPHex;
- dialogWPAPersonal *dialogWPAP;
- QString WPAPersonalKey;
- dialogWPAEnterprise *dialogWPAE;
- int WPAEType;
- QString WPAEIdent;
- QString WPAECACert;
- QString WPAEClientCert;
- QString WPAEPrivKeyFile;
- QString WPAEPassword;
Q3Process *netifProc;
+ // Lets define our arrays for the SSID profiles
+ QString SSIDList[150];
+ int SSIDEncType[150];
+ bool BSSID[150];
+ QString WEPKey[150];
+ int WEPIndex[150];
+ bool WEPHex[150];
+ QString WPAPersonalKey[150];
+ QString WPAEIdent[150];
+ QString WPAECACert[150];
+ QString WPAEClientCert[150];
+ QString WPAEPrivKeyFile[150];
+ QString WPAEPassword[150];
+ int WPAEType[150];
-
signals:
} ;
Modified: pcbsd/trunk/wificonfig/wificonfigwidgetbase.ui
===================================================================
--- pcbsd/trunk/wificonfig/wificonfigwidgetbase.ui 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/trunk/wificonfig/wificonfigwidgetbase.ui 2008-10-14 21:54:18 UTC (rev 2904)
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>348</width>
- <height>463</height>
+ <height>450</height>
</rect>
</property>
<property name="windowTitle" >
@@ -17,25 +17,119 @@
<normaloff>:/tray_wifi85.png</normaloff>:/tray_wifi85.png</iconset>
</property>
<layout class="QGridLayout" >
+ <item row="2" column="3" >
+ <widget class="QPushButton" name="buttonCancel" >
+ <property name="text" >
+ <string>Close</string>
+ </property>
+ <property name="shortcut" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="4" >
+ <widget class="QCheckBox" name="checkDisableWireless" >
+ <property name="text" >
+ <string>Disable this wireless device</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" >
+ <widget class="QPushButton" name="pushApply" >
+ <property name="text" >
+ <string>&Apply</string>
+ </property>
+ <property name="shortcut" >
+ <string>Alt+A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <spacer name="spacer1" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>100</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QPushButton" name="pushOK" >
+ <property name="text" >
+ <string>&OK</string>
+ </property>
+ <property name="shortcut" >
+ <string>Alt+O</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="0" colspan="4" >
<widget class="QTabWidget" name="tabMainWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="tab" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>328</width>
- <height>356</height>
- </rect>
- </property>
<attribute name="title" >
<string>&General</string>
</attribute>
- <layout class="QGridLayout" >
- <item row="5" column="0" colspan="2" >
+ <layout class="QGridLayout" name="gridLayout_4" >
+ <item row="1" column="0" >
+ <layout class="QGridLayout" name="gridLayout_3" >
+ <item row="0" column="0" >
+ <widget class="QListWidget" name="listWifi" />
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QPushButton" name="pushAddWifi" >
+ <property name="text" >
+ <string>Add</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="wificonfig.qrc" >
+ <normaloff>:/list-add.png</normaloff>:/list-add.png</iconset>
+ </property>
+ <property name="shortcut" >
+ <string>Alt+S</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushRemoveWifi" >
+ <property name="text" >
+ <string>Remove</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="wificonfig.qrc" >
+ <normaloff>:/edit-delete.png</normaloff>:/edit-delete.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0" >
<widget class="QCheckBox" name="checkDHCP" >
<property name="text" >
<string>O&btain IP automatically (DHCP)</string>
@@ -45,23 +139,7 @@
</property>
</widget>
</item>
- <item row="4" column="0" colspan="2" >
- <widget class="QLabel" name="textLabel1" >
- <property name="frameShape" >
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow" >
- <enum>QFrame::Plain</enum>
- </property>
- <property name="text" >
- <string>Network address configuration</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2" >
+ <item row="3" column="0" >
<widget class="Line" name="line1" >
<property name="frameShape" >
<enum>QFrame::HLine</enum>
@@ -71,50 +149,17 @@
</property>
</widget>
</item>
- <item row="2" column="0" colspan="2" >
- <spacer name="spacer2" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>270</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="1" >
- <widget class="QPushButton" name="pushChangeWifi" >
- <property name="text" >
- <string>&Scan</string>
- </property>
- <property name="shortcut" >
- <string>Alt+S</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="2" >
+ <item row="0" column="0" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
- <string>Currently selected wireless network:</string>
+ <string>Wireless network profiles</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
- <item row="1" column="0" >
- <widget class="QLineEdit" name="lineSSID" >
- <property name="readOnly" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="6" column="0" colspan="2" >
+ <item row="5" column="0" >
<widget class="Q3GroupBox" name="groupBoxIP" >
<property name="title" >
<string>Assign static IP address</string>
@@ -169,169 +214,13 @@
</layout>
</widget>
</item>
- <item row="7" column="0" colspan="2" >
- <spacer name="spacer3_2" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Preferred</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>290</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
- <widget class="QWidget" name="tab" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>328</width>
- <height>356</height>
- </rect>
- </property>
- <attribute name="title" >
- <string>Securit&y</string>
- </attribute>
- <layout class="QGridLayout" >
- <item row="3" column="0" >
- <spacer name="spacer4" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>270</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="0" >
- <widget class="QLabel" name="textLabel4" >
- <property name="text" >
- <string>Wireless security setup</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <spacer name="spacer4_2" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>270</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0" >
- <widget class="Q3ButtonGroup" name="buttonGroupSecurity" >
- <property name="title" >
- <string>Security Mode</string>
- </property>
- <layout class="QGridLayout" >
- <item row="4" column="0" >
- <spacer name="spacer6" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>130</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="3" column="0" colspan="2" >
- <widget class="QRadioButton" name="radioSecurityWPAEnt" >
- <property name="text" >
- <string>WPA Enterprise</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2" >
- <widget class="QRadioButton" name="radioSecurityWEP" >
- <property name="text" >
- <string>WEP</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2" >
- <widget class="QRadioButton" name="radioSecurityWPAPersonal" >
- <property name="text" >
- <string>WPA Personal</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="4" column="1" >
- <widget class="QPushButton" name="pushSecurity" >
- <property name="text" >
- <string>Configure</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="2" >
- <widget class="QRadioButton" name="radioSecurityDisabled" >
- <property name="text" >
- <string>Disa&bled</string>
- </property>
- <property name="shortcut" >
- <string>Alt+B</string>
- </property>
- <property name="checked" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
<widget class="QWidget" name="TabPage" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>328</width>
- <height>356</height>
- </rect>
- </property>
<attribute name="title" >
<string>Advanced</string>
</attribute>
- <layout class="QGridLayout" >
+ <layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QCheckBox" name="checkMAC" >
<property name="text" >
@@ -361,34 +250,6 @@
</widget>
</item>
<item row="2" column="0" >
- <widget class="QCheckBox" name="checkBSSID" >
- <property name="text" >
- <string>Specify custom BSSID</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- <property name="checked" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="Q3GroupBox" name="groupBSSID" >
- <property name="enabled" >
- <bool>false</bool>
- </property>
- <property name="title" >
- <string>Custom wireless BSSID</string>
- </property>
- <layout class="QGridLayout" >
- <item row="0" column="0" >
- <widget class="QLineEdit" name="lineBSSID" />
- </item>
- </layout>
- </widget>
- </item>
- <item row="4" column="0" >
<spacer name="spacer7" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
@@ -407,14 +268,6 @@
</layout>
</widget>
<widget class="QWidget" name="TabPage" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>328</width>
- <height>356</height>
- </rect>
- </property>
<attribute name="title" >
<string>Info</string>
</attribute>
@@ -796,59 +649,6 @@
</widget>
</widget>
</item>
- <item row="2" column="3" >
- <widget class="QPushButton" name="buttonCancel" >
- <property name="text" >
- <string>Close</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="4" >
- <widget class="QCheckBox" name="checkDisableWireless" >
- <property name="text" >
- <string>Disable this wireless device</string>
- </property>
- </widget>
- </item>
- <item row="2" column="2" >
- <widget class="QPushButton" name="pushApply" >
- <property name="text" >
- <string>&Apply</string>
- </property>
- <property name="shortcut" >
- <string>Alt+A</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <spacer name="spacer1" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>100</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="1" >
- <widget class="QPushButton" name="pushOK" >
- <property name="text" >
- <string>&OK</string>
- </property>
- <property name="shortcut" >
- <string>Alt+O</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
@@ -859,25 +659,16 @@
<header>Qt3Support/Q3GroupBox</header>
<container>1</container>
</customwidget>
- <customwidget>
- <class>Q3ButtonGroup</class>
- <extends>Q3GroupBox</extends>
- <header>Qt3Support/Q3ButtonGroup</header>
- <container>1</container>
- </customwidget>
</customwidgets>
<tabstops>
<tabstop>tabMainWidget</tabstop>
- <tabstop>lineSSID</tabstop>
- <tabstop>pushChangeWifi</tabstop>
+ <tabstop>pushAddWifi</tabstop>
<tabstop>checkDHCP</tabstop>
<tabstop>lineIP</tabstop>
<tabstop>lineNetmask</tabstop>
<tabstop>pushOK</tabstop>
<tabstop>pushApply</tabstop>
<tabstop>buttonCancel</tabstop>
- <tabstop>radioSecurityDisabled</tabstop>
- <tabstop>pushSecurity</tabstop>
<tabstop>checkDisableWireless</tabstop>
<tabstop>checkMAC</tabstop>
<tabstop>lineMAC</tabstop>
@@ -917,22 +708,6 @@
</hints>
</connection>
<connection>
- <sender>checkDHCP</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckDHCPBox()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
<sender>pushApply</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
@@ -949,10 +724,10 @@
</hints>
</connection>
<connection>
- <sender>pushChangeWifi</sender>
+ <sender>checkDisableWireless</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
- <slot>slotConfig()</slot>
+ <slot>slotCheckDisabled()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
@@ -965,10 +740,10 @@
</hints>
</connection>
<connection>
- <sender>pushSecurity</sender>
+ <sender>pushOK</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckWhichSecurity()</slot>
+ <slot>slotOK()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
@@ -981,10 +756,10 @@
</hints>
</connection>
<connection>
- <sender>radioSecurityDisabled</sender>
+ <sender>checkDHCP</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckSecurityRadio()</slot>
+ <slot>slotCheckDHCPBox()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
@@ -997,86 +772,6 @@
</hints>
</connection>
<connection>
- <sender>radioSecurityWEP</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckSecurityRadio()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>radioSecurityWPAEnt</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckSecurityRadio()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>radioSecurityWPAPersonal</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckSecurityRadio()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>checkDisableWireless</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckDisabled()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>pushOK</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotOK()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
<sender>checkMAC</sender>
<signal>clicked()</signal>
<receiver>wificonfigwidgetbase</receiver>
@@ -1140,53 +835,5 @@
</hint>
</hints>
</connection>
- <connection>
- <sender>lineSSID</sender>
- <signal>textChanged(QString)</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckGlobalText()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>checkBSSID</sender>
- <signal>clicked()</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotBSSIDChecked()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>lineBSSID</sender>
- <signal>textChanged(QString)</signal>
- <receiver>wificonfigwidgetbase</receiver>
- <slot>slotCheckGlobalText()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
</connections>
</ui>
Modified: pcbsd/trunk/wificonfig/wifiselectiondialog.cpp
===================================================================
--- pcbsd/trunk/wificonfig/wifiselectiondialog.cpp 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/trunk/wificonfig/wifiselectiondialog.cpp 2008-10-14 21:54:18 UTC (rev 2904)
@@ -1,209 +1,247 @@
-/****************************************************************************
-** ui.h extension file, included from the uic-generated form implementation.
-**
-** If you want to add, delete, or rename functions or slots, use
-** Qt Designer to update this file, preserving your code.
-**
-** You should not define a constructor or destructor in this file.
-** Instead, write your code in functions called init() and destroy().
-** These will automatically be called by the form's constructor and
-** destructor.
-*****************************************************************************/
#include "wifiselectiondialog.h"
#include "ui_wifiselectiondialog.h"
#include <qtextstream.h>
-
-
-
-void wifiselectiondialog::init( QString Device, QString oldSSID )
+void wifiselectiondialog::init(QString device)
{
- DeviceName = Device;
- SSID = oldSSID;
- pushConnect->setEnabled(FALSE);
+ DeviceName = device;
- QTimer::singleShot(500, this, SLOT(startScan()));
- //scanWifi();
+ connect( pushScan, SIGNAL( clicked() ), this, SLOT(slotOpenWifiScan()) );
+ connect( pushConnect, SIGNAL( clicked() ), this, SLOT(slotConnect()) );
+ connect( pushCancel, SIGNAL( clicked() ), this, SLOT(slotCancel()) );
+ connect( pushSecurity, SIGNAL( clicked() ), this, SLOT(slotCheckWhichSecurity()) );
}
-
-void wifiselectiondialog::scanWifi()
-{
- QString tmp;
- QString strength;
- QString ssid;
- int newStrength;
- bool ok;
- int foundItem = 0;
- QString FileLoad;
- QString line;
-
- // Clear the list box
- listWifi->clear();
- textTop->setText(tr("Scanning for wireless networks...") );
-
- // Take the interface down before starting the scan
- //runCommand("ifconfig " + DeviceName + " down");
-
- // Start the scan and get the output
- line = getLineFromCommandOutput("ifconfig -v " + DeviceName + " up list scan >/tmp/.wifilist 2>/tmp/.wifilist");
- // Now read the output file
- QFile file( "/tmp/.wifilist" );
- if ( file.open( IO_ReadOnly ) ) {
- QTextStream stream( &file );
- while ( !stream.atEnd() ) {
- line = stream.readLine(); // line of text excluding '\n'
- // exclude the header line
- if ( line.indexOf("BSSID") == -1) {
-
- // Get the ssid of the network
- tmp = line;
- tmp = tmp.simplified();
- tmp.remove(0, tmp.indexOf("SSID<") + 5);
- tmp.truncate(tmp.indexOf(">"));
- ssid = tmp;
- // Get the signal strength of this device
- tmp = line;
- tmp = tmp.simplified();
-
- // First remove the SSID which may have spaces in it
- tmp.remove(0, tmp.find(":"));
-
- // Now find the strength section
- tmp.truncate(tmp.findRev("SSID<"));
- tmp.truncate(tmp.findRev(":"));
- tmp.remove(0, tmp.findRev(" "));
- strength = tmp;
-
- //QMessageBox::warning( this, "Testing", "SSID:" + ssid + " STR:" + strength );
- // Add the device to the list box
- strength.toInt(&ok);
- if ( ok && !ssid.isEmpty() && ssid != " " ) {
- newStrength = tmp.toInt(&ok);
- if ( newStrength < 25 )
- {
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi.png";
- } else if ( newStrength < 50 ) {
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi30.png";
- } else if ( newStrength < 75 ) {
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi60.png";
- } else {;
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi85.png";
- }
-
-
- QImage *Icon = new QImage(FileLoad);
- QPixmap PixmapIcon;
- PixmapIcon.convertFromImage(Icon->scaled(22,22));
- listWifi->insertItem(PixmapIcon, ssid + " (signal strength: " +strength + "%)" );
-
- foundItem = 1;
-
- } else {
- if ( ! ssid.isEmpty() && ssid != " " ) {
- // If we didn't get the signal strength, still display the SSID
- FileLoad="/PCBSD/networkmanager/pics/tray_wifi.png";
- QImage *Icon = new QImage(FileLoad);
- QPixmap PixmapIcon;
- PixmapIcon.convertFromImage(Icon->scaled(22,22));
- listWifi->insertItem(PixmapIcon, ssid + " (signal strength: unknown)" );
-
- foundItem = 1;
- }
- }
-
- }
-
- }
-
-
- if ( foundItem == 1 )
- {
- textTop->setText(tr("Select a wireless network to connect.") );
- listWifi->setSelected(0, TRUE);
- pushConnect->setEnabled(TRUE);
- } else {
- textTop->setText(tr("No wireless networks found!") );
- pushConnect->setEnabled(FALSE);
- }
- }
-
+void wifiselectiondialog::slotOpenWifiScan()
+{
+ dialogWifiscanssid = new wifiscanssid();
+ dialogWifiscanssid->init(DeviceName);
+ connect( dialogWifiscanssid, SIGNAL( saved(QString) ), this, SLOT( slotSSIDChanged(QString) ) );
+ dialogWifiscanssid->exec();
}
-QString wifiselectiondialog::getLineFromCommandOutput( QString command )
+void wifiselectiondialog::slotSSIDChanged( QString newSSID )
{
- FILE *file = popen(command,"r");
-
- char buffer[100];
-
- QString line = "";
- char firstChar;
-
- if ((firstChar = fgetc(file)) != -1){
- line += firstChar;
- line += fgets(buffer,100,file);
- }
-
-
- pclose(file);
-
-
- return line;
+ lineSSID->setText(newSSID);
}
-
+
void wifiselectiondialog::slotCancel()
{
close();
}
-
void wifiselectiondialog::slotConnect()
{
QString selectedSSID;
// Make sure a device was selected
- int sel = listWifi->currentItem();
- if ( sel == -1 )
+ if (lineSSID->text().isEmpty())
{
- QMessageBox::warning( this, tr("No selection"),
- tr("Error: You must select a network to connect!\n") );
+ QMessageBox::warning( this, tr("No SSID!"), tr("Error: You must select a wireless network to connect!\n") );
return;
}
+
+ if ( (checkBSSID->isChecked() && lineSSID->text().length() != 17) || (checkBSSID->isChecked() && lineSSID->text().count(":") != 5) )
+ {
+ QMessageBox::warning( this, tr("Invalid BSSID!"), tr("Error: The specified BSSID appears invalid. It must be in the format xx:xx:xx:xx:xx:xx\n") );
+ return;
+ }
+
+ // Check that we even have a WEP Key yet
+ if (radioSecurityWEP->isChecked() && WEPKey.isEmpty() ) {
+ QMessageBox::warning( this, tr("Warning"), tr("WEP is selected, but not configured!\nPlease configure your WEP key before saving!") );
+ return;
+ }
+
+ // Check that we even have a WPA-Personal Key yet
+ if (radioSecurityWPAPersonal->isChecked() && WPAPersonalKey.isEmpty() ) {
+ QMessageBox::warning( this, tr("Warning"), tr("WPA-Personal is selected, but not configured!\nPlease configure your WPA key before saving!") );
+ return;
+ }
+
+ // Check all the WPAEnt settings
+ if (radioSecurityWPAEnt->isChecked() ) {
+
+ // Check if the key is setup for WPA EAP-TLS
+ if ( WPAEType == 1 && ( WPAEIdent.isEmpty() || WPAECACert.isEmpty() || WPAEClientCert.isEmpty() || WPAEPrivKeyFile.isEmpty() || WPAEPassword.isEmpty() ))
+ {
+ QMessageBox::warning( this, tr("Warning"), tr("WPA-Enterprise is selected, but not configured!\nPlease configure your WPA settings before saving!") );
+ return;
+ }
+
+ // Check if the key is setup for WPA EAP-TTLS && EAP-PEAP
+ if ( (WPAEType == 2 || WPAEType == 3) && ( WPAEIdent.isEmpty() || WPAECACert.isEmpty() || WPAEPassword.isEmpty() ) )
+ {
+ QMessageBox::warning( this, tr("Warning"), tr("WPA-Enterprise is selected, but not configured!\nPlease configure your WPA settings before saving!") );
+ return;
+ }
+
+ } // End of WPAEnt setting check
- selectedSSID = listWifi->text(sel);
- selectedSSID.truncate( selectedSSID.find("(") - 1 );
+ selectedSSID = lineSSID->text();
+ bool usingBSSID = checkBSSID->isChecked() ;
// Emit the new network SSID the user selected
- emit saved(selectedSSID);
+ if ( radioSecurityDisabled->isChecked() )
+ {
+ emit signalSavedOpen(selectedSSID, usingBSSID);
+ }
+
+ if ( radioSecurityWEP->isChecked() )
+ {
+ emit signalSavedWEP(selectedSSID, usingBSSID, WEPKey, WEPIndex, WEPHex );
+ }
+
+ if ( radioSecurityWPAPersonal->isChecked() )
+ {
+ emit signalSavedWPA(selectedSSID, usingBSSID, WPAPersonalKey );
+ }
+
+ if ( radioSecurityWPAEnt->isChecked() )
+ {
+ emit signalSavedWPAE(selectedSSID, usingBSSID, WPAEType, WPAEIdent, WPAECACert, WPAEClientCert, WPAEPrivKeyFile, WPAEPassword );
+ }
+
close();
}
+void wifiselectiondialog::slotConfigWEP()
+{
+ dialogWEP = new wepConfig();
+
+ if ( ! WEPKey.isEmpty() )
+ {
+ dialogWEP->setKey(WEPKey, WEPIndex, WEPHex);
+ }
+
+ connect( dialogWEP, SIGNAL( saved(QString, int, bool) ), this, SLOT( slotWEPChanged(QString, int, bool) ) );
+ dialogWEP->exec();
+}
+void wifiselectiondialog::slotWEPChanged( QString newKey, int newIndex, bool hexkey )
+{
+ WEPKey = newKey;
+ WEPIndex = newIndex;
+ WEPHex = hexkey;
+ // Check the status of the radio buttons
+ slotCheckSecurityRadio();
+
+}
-void wifiselectiondialog::slotRescan()
+
+void wifiselectiondialog::slotCheckSecurityRadio()
{
- pushConnect->setEnabled(FALSE);
- scanWifi();
+ // Check to see which radio button is checked and take approiate actions
+
+ if ( radioSecurityDisabled->isChecked() )
+ {
+ pushSecurity->setEnabled(FALSE);
+ } else if ( radioSecurityWEP->isChecked() ) {
+ pushSecurity->setEnabled(TRUE);
+ // Check if the key is setup
+ if ( ! WEPKey.isEmpty() )
+ {
+ radioSecurityWEP->setText( tr("WEP (Configured)") );
+ } else {
+ radioSecurityWEP->setText( tr("WEP") );
+ }
+ } else if ( radioSecurityWPAPersonal->isChecked() ) {
+ pushSecurity->setEnabled(TRUE);
+ // Check if the key is setup
+ if ( ! WPAPersonalKey.isEmpty() )
+ {
+ radioSecurityWPAPersonal->setText( tr("WPA Personal (Configured)") );
+ } else {
+ radioSecurityWPAPersonal->setText( tr("WPA Personal") );
+ }
+
+ } else if ( radioSecurityWPAEnt->isChecked() ) {
+ pushSecurity->setEnabled(TRUE);
+
+ // Check if the key is setup
+ if ( ! WPAEIdent.isEmpty() && ! WPAECACert.isEmpty() && ! WPAEPassword.isEmpty() ) {
+ radioSecurityWPAEnt->setText(tr("WPA Enterprise (Configured)") );
+ } else {
+ radioSecurityWPAEnt->setText(tr("WPA Enterprise") );
+ }
+
+ }
+
}
-void wifiselectiondialog::runCommand( QString Command )
+void wifiselectiondialog::slotCheckWhichSecurity()
{
- FILE *file = popen(Command,"r");
- fclose(file);
+ if ( radioSecurityDisabled->isChecked() )
+ {
+ return;
+ } else if ( radioSecurityWEP->isChecked() ) {
+ // Run the WEP config dialog
+ slotConfigWEP();
+ } else if ( radioSecurityWPAPersonal->isChecked() ) {
+ slotConfigWPAP();
+ } else if ( radioSecurityWPAEnt->isChecked() ) {
+ slotConfigWPAE();
+ }
+
}
+void wifiselectiondialog::slotConfigWPAP()
+{
+ // Bring up the WPA-Personal config dialog
+
+ dialogWPAP = new dialogWPAPersonal();
+
+ if ( ! WPAPersonalKey.isEmpty() )
+ {
+ dialogWPAP->setKey(WPAPersonalKey);
+ }
+
+ connect( dialogWPAP, SIGNAL( saved(QString) ), this, SLOT( slotWPAPChanged(QString) ) );
+ dialogWPAP->exec();
+}
-void wifiselectiondialog::startScan()
+
+void wifiselectiondialog::slotConfigWPAE()
{
- scanWifi();
+ // Bring up the WPA-Enterprise config dialog
+
+ dialogWPAE = new dialogWPAEnterprise();
+
+ if ( ! WPAEIdent.isEmpty() )
+ {
+ dialogWPAE->setVariables(WPAEType, WPAEIdent, WPAECACert, WPAEClientCert, WPAEPrivKeyFile, WPAEPassword);
+ }
+
+ connect( dialogWPAE, SIGNAL( saved(int, QString, QString, QString, QString, QString) ), this, SLOT( slotWPAEChanged(int, QString, QString, QString, QString, QString) ) );
+ dialogWPAE->exec();
}
+void wifiselectiondialog::slotWPAPChanged( QString newKey )
+{
+ WPAPersonalKey = newKey;
+ slotCheckSecurityRadio();
+}
+
+
+void wifiselectiondialog::slotWPAEChanged( int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass )
+{
+WPAEType = type;
+WPAEIdent=EAPIdent;
+WPAECACert=CACert;
+WPAEClientCert=ClientCert;
+WPAEPrivKeyFile=PrivKeyFile;
+WPAEPassword=PrivKeyPass;
+
+slotCheckSecurityRadio();
+
+}
+
Modified: pcbsd/trunk/wificonfig/wifiselectiondialog.h
===================================================================
--- pcbsd/trunk/wificonfig/wifiselectiondialog.h 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/trunk/wificonfig/wifiselectiondialog.h 2008-10-14 21:54:18 UTC (rev 2904)
@@ -4,6 +4,10 @@
#include <qfile.h>
#include <qmessagebox.h>
#include <qdialog.h>
+#include "wepconfig.h"
+#include "dialogwpapersonal.h"
+#include "dialogwpaenterprise.h"
+#include "wifiscanssid.h"
#include "ui_wifiselectiondialog.h"
class wifiselectiondialog : public QDialog, private Ui::wifiselectiondialog
@@ -16,7 +20,7 @@
setupUi(this);
}
- void init( QString Device, QString oldSSID );
+ void init(QString device);
void scanWifi();
@@ -25,19 +29,48 @@
private slots:
void slotCancel();
void slotConnect();
- void slotRescan();
- void startScan();
+ void slotOpenWifiScan();
+ void slotSSIDChanged(QString newSSID);
+ void slotConfigWEP();
+ void slotWEPChanged( QString newKey, int newIndex, bool hexkey );
+ void slotCheckSecurityRadio();
+ void slotCheckWhichSecurity();
+ void slotConfigWPAP();
+ void slotConfigWPAE();
+ void slotWPAPChanged( QString newKey );
+ void slotWPAEChanged( int type, QString EAPIdent, QString CACert, QString ClientCert, QString PrivKeyFile, QString PrivKeyPass );
private:
QString DeviceName;
QString SSID;
- QString getLineFromCommandOutput( QString command );
- void runCommand( QString Command );
+ // Setup our dialogs
+ wifiscanssid *dialogWifiscanssid;
+ wepConfig *dialogWEP;
+ dialogWPAPersonal *dialogWPAP;
+ dialogWPAEnterprise *dialogWPAE;
+ // WEP variables
+ QString WEPKey;
+ int WEPIndex;
+ bool WEPHex;
+ // WPA Personal Key variable
+ QString WPAPersonalKey;
+
+ // WPAE Variables
+ int WPAEType;
+ QString WPAEIdent;
+ QString WPAECACert;
+ QString WPAEClientCert;
+ QString WPAEPrivKeyFile;
+ QString WPAEPassword;
+
signals:
- void saved(QString);
+ void signalSavedOpen(QString, bool);
+ void signalSavedWEP(QString, bool, QString, int, bool );
+ void signalSavedWPA(QString, bool, QString);
+ void signalSavedWPAE(QString, bool, int, QString, QString, QString, QString, QString);
} ;
#endif // WIFISELECTIONDIALOG_H
Modified: pcbsd/trunk/wificonfig/wifiselectiondialog.ui
===================================================================
--- pcbsd/trunk/wificonfig/wifiselectiondialog.ui 2008-10-14 21:17:31 UTC (rev 2903)
+++ pcbsd/trunk/wificonfig/wifiselectiondialog.ui 2008-10-14 21:54:18 UTC (rev 2904)
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>420</width>
- <height>314</height>
+ <width>410</width>
+ <height>355</height>
</rect>
</property>
<property name="windowTitle" >
@@ -16,83 +16,104 @@
<iconset resource="wificonfig.qrc" >
<normaloff>:/tray_wifi85.png</normaloff>:/tray_wifi85.png</iconset>
</property>
- <layout class="QGridLayout" >
- <item row="0" column="0" colspan="3" >
- <widget class="QLabel" name="textTop" >
- <property name="frameShape" >
- <enum>QFrame::NoFrame</enum>
+ <layout class="QGridLayout" name="gridLayout_3" >
+ <item row="0" column="0" >
+ <widget class="Q3GroupBox" name="groupBSSID" >
+ <property name="enabled" >
+ <bool>true</bool>
</property>
- <property name="frameShadow" >
- <enum>QFrame::Plain</enum>
+ <property name="title" >
+ <string>Selected Wireless Network</string>
</property>
- <property name="text" >
- <string>Select a wireless network to connect.</string>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
+ <layout class="QGridLayout" name="gridLayout_2" >
+ <item row="0" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <widget class="QLineEdit" name="lineSSID" />
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushScan" >
+ <property name="text" >
+ <string>Scan</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QCheckBox" name="checkBSSID" >
+ <property name="enabled" >
+ <bool>true</bool>
+ </property>
+ <property name="text" >
+ <string>Using BSSID</string>
+ </property>
+ <property name="shortcut" >
+ <string/>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
- <item row="3" column="1" >
- <widget class="QPushButton" name="pushConnect" >
- <property name="text" >
- <string>&Connect</string>
- </property>
- <property name="shortcut" >
- <string>Alt+C</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <spacer name="spacer8" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>70</width>
- <height>21</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="3" column="2" >
- <widget class="QPushButton" name="pushCancel" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0" colspan="3" >
- <spacer name="spacer9" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>270</width>
- <height>16</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="0" colspan="3" >
- <widget class="Q3GroupBox" name="groupBox2" >
+ <item row="1" column="0" >
+ <widget class="Q3ButtonGroup" name="buttonGroupSecurity" >
<property name="title" >
- <string>Available wireless networks</string>
+ <string>Security Mode</string>
</property>
- <layout class="QGridLayout" >
- <item row="0" column="0" colspan="2" >
- <widget class="Q3ListBox" name="listWifi" />
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QRadioButton" name="radioSecurityDisabled" >
+ <property name="text" >
+ <string>Disabled</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioSecurityWEP" >
+ <property name="enabled" >
+ <bool>true</bool>
+ </property>
+ <property name="text" >
+ <string>WEP</string>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioSecurityWPAPersonal" >
+ <property name="text" >
+ <string>WPA Personal</string>
+ </property>
+ <property name="shortcut" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioSecurityWPAEnt" >
+ <property name="text" >
+ <string>WPA Enterprise</string>
+ </property>
+ <property name="shortcut" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item row="1" column="0" >
- <spacer name="spacer10" >
+ <spacer name="spacer6" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
@@ -101,25 +122,78 @@
</property>
<property name="sizeHint" stdset="0" >
<size>
- <width>131</width>
+ <width>130</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" >
- <widget class="QPushButton" name="pushRescan" >
+ <widget class="QPushButton" name="pushSecurity" >
<property name="text" >
- <string>&Rescan</string>
+ <string>Configure</string>
</property>
<property name="shortcut" >
- <string>Alt+R</string>
+ <string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
+ <item row="2" column="0" >
+ <spacer name="spacer9" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>270</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="3" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <spacer name="spacer8" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>70</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushConnect" >
+ <property name="text" >
+ <string>Add</string>
+ </property>
+ <property name="shortcut" >
+ <string>Alt+C</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushCancel" >
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
@@ -132,9 +206,10 @@
<container>1</container>
</customwidget>
<customwidget>
- <class>Q3ListBox</class>
- <extends>Q3Frame</extends>
- <header>q3listbox.h</header>
+ <class>Q3ButtonGroup</class>
+ <extends>Q3GroupBox</extends>
+ <header>Qt3Support/Q3ButtonGroup</header>
+ <container>1</container>
</customwidget>
</customwidgets>
<includes>
@@ -146,54 +221,5 @@
<resources>
<include location="wificonfig.qrc" />
</resources>
- <connections>
- <connection>
- <sender>pushCancel</sender>
- <signal>clicked()</signal>
- <receiver>wifiselectiondialog</receiver>
- <slot>slotCancel()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>pushConnect</sender>
- <signal>clicked()</signal>
- <receiver>wifiselectiondialog</receiver>
- <slot>slotConnect()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>pushRescan</sender>
- <signal>clicked()</signal>
- <receiver>wifiselectiondialog</receiver>
- <slot>slotRescan()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>
More information about the Commits
mailing list