[PC-BSD Commits] r2895 - in pcbsd: branches/7.0/wificonfig trunk/wificonfig

svn at pcbsd.org svn at pcbsd.org
Sat Oct 11 06:46:47 PDT 2008


Author: kris
Date: 2008-10-11 06:46:46 -0700 (Sat, 11 Oct 2008)
New Revision: 2895

Modified:
   pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.cpp
   pcbsd/branches/7.0/wificonfig/wifiselectiondialog.cpp
   pcbsd/branches/7.0/wificonfig/wifiselectiondialog.ui
   pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp
   pcbsd/trunk/wificonfig/wifiselectiondialog.cpp
   pcbsd/trunk/wificonfig/wifiselectiondialog.ui
Log:

Updated the wifi selection dialog to fix a few bugs.

1. Fixed issues with long SSIDs and SSID's with multiple spaces in the name
being detected and used properly.

2. Fixed an issue of connecting to non-WEP wlans, when using ssid with a space in the name. 

Needs a bit of testing still :)



Modified: pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.cpp
===================================================================
--- pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.cpp	2008-10-10 15:19:37 UTC (rev 2894)
+++ pcbsd/branches/7.0/wificonfig/wificonfigwidgetbase.cpp	2008-10-11 13:46:46 UTC (rev 2895)
@@ -77,11 +77,25 @@
      // Check if we are not using security and write the entry
      if ( radioSecurityDisabled->isChecked() )
     {
-	if ( checkBSSID->isChecked() ) {
-	     saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"" + ifConfigLine + " bssid " + lineBSSID->text() + "\"", -1);
-	} else {
-                    saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"" + ifConfigLine + " ssid " + lineSSID->text() + "\"", -1);
-              }
+        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 << " key_mgmt=NONE\n";
+          streamout << "}\n";
+          fileout.close();
+
+        }
      } else if (radioSecurityWEP->isChecked() ) {
         // Write the settings with WEP enabled
 	    
@@ -1004,14 +1018,7 @@
 			lineSSID->setText(tmp2);
 		   }
 	
-		   if ( line.find("key_mgmt=") != -1 )
-		   {
-			tmp2 = line.remove(0, line.find("=") +1 );
-			if ( tmp2 == "NONE" ) {
-				radioSecurityWEP->setChecked(TRUE);
-			}
-			
-		   }
+		   // Check if we are using a WEP key for this network
 		   if ( line.find("wep_key") != -1 )
 		   {		       
 			tmp2 = line.remove(0, line.find("=") +1 );
@@ -1019,7 +1026,9 @@
 			WEPKey = tmp2;
 			radioSecurityWEP->setChecked(TRUE);	
 		   }
-		    if ( line.find("wep_tx_keyidx") != -1 )
+
+		   // 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

Modified: pcbsd/branches/7.0/wificonfig/wifiselectiondialog.cpp
===================================================================
--- pcbsd/branches/7.0/wificonfig/wifiselectiondialog.cpp	2008-10-10 15:19:37 UTC (rev 2894)
+++ pcbsd/branches/7.0/wificonfig/wifiselectiondialog.cpp	2008-10-11 13:46:46 UTC (rev 2895)
@@ -45,7 +45,7 @@
     //runCommand("ifconfig " + DeviceName + " down");
     
     // Start the scan and get the output
-    line = getLineFromCommandOutput("ifconfig " + DeviceName + " up list scan >/tmp/.wifilist 2>/tmp/.wifilist");
+    line = getLineFromCommandOutput("ifconfig -v " + DeviceName + " up list scan >/tmp/.wifilist 2>/tmp/.wifilist");
 
     // Now read the output file
     QFile file( "/tmp/.wifilist" );
@@ -59,10 +59,10 @@
 		 // Get the ssid of the network
 		 tmp = line;
 		 tmp = tmp.simplified();
-		 tmp.truncate(tmp.find(":"));
-                 tmp.truncate(tmp.findRev(" "));
+		 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();
@@ -71,13 +71,15 @@
 		 tmp.remove(0, tmp.find(":"));
                   
                  // Now find the strength section
-                 tmp = tmp.section(" ", 3, 3);
-		 tmp.truncate(tmp.find(":"));
+		 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 ) {
+		 if ( ok && !ssid.isEmpty() && ssid != " " ) {
 		     newStrength = tmp.toInt(&ok);
 		     if ( newStrength < 25 )
 		     {	
@@ -99,6 +101,7 @@
 		       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);
@@ -107,6 +110,7 @@
 		       listWifi->insertItem(PixmapIcon, ssid + " (signal strength: unknown)" );
 		       
 		       foundItem = 1;
+                  }
 	     }
 	    
 	}

Modified: pcbsd/branches/7.0/wificonfig/wifiselectiondialog.ui
===================================================================
--- pcbsd/branches/7.0/wificonfig/wifiselectiondialog.ui	2008-10-10 15:19:37 UTC (rev 2894)
+++ pcbsd/branches/7.0/wificonfig/wifiselectiondialog.ui	2008-10-11 13:46:46 UTC (rev 2895)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>292</width>
-    <height>274</height>
+    <width>420</width>
+    <height>314</height>
    </rect>
   </property>
   <property name="windowTitle" >

Modified: pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp
===================================================================
--- pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp	2008-10-10 15:19:37 UTC (rev 2894)
+++ pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp	2008-10-11 13:46:46 UTC (rev 2895)
@@ -77,11 +77,25 @@
      // Check if we are not using security and write the entry
      if ( radioSecurityDisabled->isChecked() )
     {
-	if ( checkBSSID->isChecked() ) {
-	     saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"" + ifConfigLine + " bssid " + lineBSSID->text() + "\"", -1);
-	} else {
-                    saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, "ifconfig_" + DeviceName + "=\"" + ifConfigLine + " ssid " + lineSSID->text() + "\"", -1);
-              }
+        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 << " key_mgmt=NONE\n";
+          streamout << "}\n";
+          fileout.close();
+
+        }
      } else if (radioSecurityWEP->isChecked() ) {
         // Write the settings with WEP enabled
 	    
@@ -1004,14 +1018,7 @@
 			lineSSID->setText(tmp2);
 		   }
 	
-		   if ( line.find("key_mgmt=") != -1 )
-		   {
-			tmp2 = line.remove(0, line.find("=") +1 );
-			if ( tmp2 == "NONE" ) {
-				radioSecurityWEP->setChecked(TRUE);
-			}
-			
-		   }
+		   // Check if we are using a WEP key for this network
 		   if ( line.find("wep_key") != -1 )
 		   {		       
 			tmp2 = line.remove(0, line.find("=") +1 );
@@ -1019,7 +1026,9 @@
 			WEPKey = tmp2;
 			radioSecurityWEP->setChecked(TRUE);	
 		   }
-		    if ( line.find("wep_tx_keyidx") != -1 )
+
+		   // 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

Modified: pcbsd/trunk/wificonfig/wifiselectiondialog.cpp
===================================================================
--- pcbsd/trunk/wificonfig/wifiselectiondialog.cpp	2008-10-10 15:19:37 UTC (rev 2894)
+++ pcbsd/trunk/wificonfig/wifiselectiondialog.cpp	2008-10-11 13:46:46 UTC (rev 2895)
@@ -45,7 +45,7 @@
     //runCommand("ifconfig " + DeviceName + " down");
     
     // Start the scan and get the output
-    line = getLineFromCommandOutput("ifconfig " + DeviceName + " up list scan >/tmp/.wifilist 2>/tmp/.wifilist");
+    line = getLineFromCommandOutput("ifconfig -v " + DeviceName + " up list scan >/tmp/.wifilist 2>/tmp/.wifilist");
 
     // Now read the output file
     QFile file( "/tmp/.wifilist" );
@@ -59,10 +59,10 @@
 		 // Get the ssid of the network
 		 tmp = line;
 		 tmp = tmp.simplified();
-		 tmp.truncate(tmp.find(":"));
-                 tmp.truncate(tmp.findRev(" "));
+		 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();
@@ -71,13 +71,15 @@
 		 tmp.remove(0, tmp.find(":"));
                   
                  // Now find the strength section
-                 tmp = tmp.section(" ", 3, 3);
-		 tmp.truncate(tmp.find(":"));
+		 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 ) {
+		 if ( ok && !ssid.isEmpty() && ssid != " " ) {
 		     newStrength = tmp.toInt(&ok);
 		     if ( newStrength < 25 )
 		     {	
@@ -99,6 +101,7 @@
 		       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);
@@ -107,6 +110,7 @@
 		       listWifi->insertItem(PixmapIcon, ssid + " (signal strength: unknown)" );
 		       
 		       foundItem = 1;
+                  }
 	     }
 	    
 	}

Modified: pcbsd/trunk/wificonfig/wifiselectiondialog.ui
===================================================================
--- pcbsd/trunk/wificonfig/wifiselectiondialog.ui	2008-10-10 15:19:37 UTC (rev 2894)
+++ pcbsd/trunk/wificonfig/wifiselectiondialog.ui	2008-10-11 13:46:46 UTC (rev 2895)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>292</width>
-    <height>274</height>
+    <width>420</width>
+    <height>314</height>
    </rect>
   </property>
   <property name="windowTitle" >



More information about the Commits mailing list