[PC-BSD Commits] r2446 - pcbsd/trunk/wificonfig

svn at pcbsd.org svn at pcbsd.org
Thu Jul 24 12:05:41 PDT 2008


Author: kris
Date: 2008-07-24 12:05:41 -0700 (Thu, 24 Jul 2008)
New Revision: 2446

Modified:
   pcbsd/trunk/wificonfig/wepconfig.cpp
   pcbsd/trunk/wificonfig/wepconfig.h
   pcbsd/trunk/wificonfig/wepconfig.ui
   pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp
   pcbsd/trunk/wificonfig/wificonfigwidgetbase.h
Log:

Added support for "plaintext" WEP keys to be entered into rc.conf



Modified: pcbsd/trunk/wificonfig/wepconfig.cpp
===================================================================
--- pcbsd/trunk/wificonfig/wepconfig.cpp	2008-07-24 16:22:14 UTC (rev 2445)
+++ pcbsd/trunk/wificonfig/wepconfig.cpp	2008-07-24 19:05:41 UTC (rev 2446)
@@ -14,13 +14,24 @@
 
 
 
-void wepConfig::setKey( QString Key, int index )
+void wepConfig::setKey( QString Key, int index, bool wephex )
 {
+    // Set the key on our line edits
     if ( ! Key.isEmpty() )
     {
 	lineKey->setText(Key);
 	lineKey2->setText(Key);
     }
+ 
+    // Set if we are using plaintext or a hex key
+    if ( wephex )
+    {
+      radioHex->setChecked(true);
+      radioPlaintext->setChecked(false);
+    } else {
+      radioHex->setChecked(false);
+      radioPlaintext->setChecked(true);
+    }
     
     if ( index == 1 || index == 2 || index == 3 || index == 4)
     {
@@ -36,7 +47,11 @@
     {
 	QMessageBox::warning( this, "Network Key Error", "Error: The entered network keys do not match!\n" );
     } else {
-	emit saved(lineKey->text(), spinIndex->value());
+	if ( radioHex->isChecked() ) {
+  	  emit saved(lineKey->text(), spinIndex->value(), true);
+        } else {
+          emit saved(lineKey->text(), spinIndex->value(), false);
+        }
 	close();
     }
 }

Modified: pcbsd/trunk/wificonfig/wepconfig.h
===================================================================
--- pcbsd/trunk/wificonfig/wepconfig.h	2008-07-24 16:22:14 UTC (rev 2445)
+++ pcbsd/trunk/wificonfig/wepconfig.h	2008-07-24 19:05:41 UTC (rev 2446)
@@ -16,7 +16,7 @@
           setupUi(this);
         }
 
-  void setKey( QString Key, int index );
+  void setKey( QString Key, int index, bool wephex );
 
 public slots:
 
@@ -26,7 +26,7 @@
 private:
 
 signals:
-    void saved(QString, int);
+    void saved(QString, int, bool);
 
 } ;
 #endif // WEPCONFIG_H

Modified: pcbsd/trunk/wificonfig/wepconfig.ui
===================================================================
--- pcbsd/trunk/wificonfig/wepconfig.ui	2008-07-24 16:22:14 UTC (rev 2445)
+++ pcbsd/trunk/wificonfig/wepconfig.ui	2008-07-24 19:05:41 UTC (rev 2446)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>301</width>
-    <height>182</height>
+    <width>324</width>
+    <height>222</height>
    </rect>
   </property>
   <property name="windowTitle" >
@@ -16,14 +16,35 @@
    <iconset resource="wificonfig.qrc" >
     <normaloff>:/tray_wifi85.png</normaloff>:/tray_wifi85.png</iconset>
   </property>
-  <layout class="QGridLayout" >
+  <layout class="QGridLayout" name="gridLayout" >
    <item row="0" column="0" colspan="2" >
     <widget class="Q3GroupBox" name="groupBox3" >
      <property name="title" >
       <string>Wireless network key</string>
      </property>
-     <layout class="QGridLayout" >
-      <item row="0" column="0" >
+     <layout class="QGridLayout" name="gridLayout_2" >
+      <item row="0" column="0" colspan="3" >
+       <layout class="QHBoxLayout" name="horizontalLayout" >
+        <item>
+         <widget class="QRadioButton" name="radioHex" >
+          <property name="text" >
+           <string>Hex Key</string>
+          </property>
+          <property name="checked" >
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="radioPlaintext" >
+          <property name="text" >
+           <string>Plaintext</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </item>
+      <item row="1" column="0" >
        <widget class="QLabel" name="textLabel1" >
         <property name="text" >
          <string>Network Key</string>
@@ -33,21 +54,14 @@
         </property>
        </widget>
       </item>
-      <item row="0" column="1" colspan="2" >
+      <item row="1" column="1" colspan="2" >
        <widget class="QLineEdit" name="lineKey" >
         <property name="echoMode" >
          <enum>QLineEdit::Password</enum>
         </property>
        </widget>
       </item>
-      <item row="1" column="1" colspan="2" >
-       <widget class="QLineEdit" name="lineKey2" >
-        <property name="echoMode" >
-         <enum>QLineEdit::Password</enum>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="0" >
+      <item row="2" column="0" >
        <widget class="QLabel" name="textLabel1_2" >
         <property name="text" >
          <string>Network Key (Repeat)</string>
@@ -57,7 +71,14 @@
         </property>
        </widget>
       </item>
-      <item row="2" column="0" >
+      <item row="2" column="1" colspan="2" >
+       <widget class="QLineEdit" name="lineKey2" >
+        <property name="echoMode" >
+         <enum>QLineEdit::Password</enum>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0" >
        <widget class="QLabel" name="textLabel1_2_2" >
         <property name="text" >
          <string>Key Index</string>
@@ -67,7 +88,7 @@
         </property>
        </widget>
       </item>
-      <item row="2" column="1" >
+      <item row="3" column="1" >
        <widget class="QSpinBox" name="spinIndex" >
         <property name="minimum" >
          <number>1</number>
@@ -77,7 +98,7 @@
         </property>
        </widget>
       </item>
-      <item row="2" column="2" >
+      <item row="3" column="2" >
        <spacer name="spacer11" >
         <property name="orientation" >
          <enum>Qt::Horizontal</enum>
@@ -96,16 +117,6 @@
      </layout>
     </widget>
    </item>
-   <item row="1" column="1" >
-    <widget class="QPushButton" name="pushClose" >
-     <property name="text" >
-      <string>&amp;Close</string>
-     </property>
-     <property name="shortcut" >
-      <string>Alt+C</string>
-     </property>
-    </widget>
-   </item>
    <item row="1" column="0" >
     <spacer name="spacer12" >
      <property name="orientation" >
@@ -122,6 +133,16 @@
      </property>
     </spacer>
    </item>
+   <item row="1" column="1" >
+    <widget class="QPushButton" name="pushClose" >
+     <property name="text" >
+      <string>&amp;Close</string>
+     </property>
+     <property name="shortcut" >
+      <string>Alt+C</string>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <layoutdefault spacing="6" margin="11" />

Modified: pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp
===================================================================
--- pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp	2008-07-24 16:22:14 UTC (rev 2445)
+++ pcbsd/trunk/wificonfig/wificonfigwidgetbase.cpp	2008-07-24 19:05:41 UTC (rev 2446)
@@ -102,7 +102,13 @@
       } else {
           confLine += " ssid \"" + lineSSID->text() + "\" wepmode on";
       }
+
+      if ( WEPHex ) {
       confLine += " wepkey 0x" + WEPKey + " weptxkey " + tmp.setNum(WEPIndex);
+      } else {
+      confLine += " wepkey \"" + WEPKey + "\" weptxkey " + tmp.setNum(WEPIndex);
+      }
+
       confLine += "\"";
      saveValue( "/etc/rc.conf", "ifconfig_" + DeviceName, confLine, -1);
 	    
@@ -244,6 +250,7 @@
 // Make sure our variables are initialized properly
 WEPKey = "";
 WEPIndex = 1;
+WEPHex = true;
 WPAPersonalKey = "";
 WPAEType = 1;
 WPAEIdent="";
@@ -485,18 +492,19 @@
    
    if ( ! WEPKey.isEmpty() )
    {
-       dialogWEP->setKey(WEPKey, WEPIndex);
+       dialogWEP->setKey(WEPKey, WEPIndex, WEPHex);
    }
    
-   connect( dialogWEP, SIGNAL( saved(QString, int) ), this, SLOT( slotWEPChanged(QString, int) ) ); 
+   connect( dialogWEP, SIGNAL( saved(QString, int, bool) ), this, SLOT( slotWEPChanged(QString, int, bool) ) ); 
    dialogWEP->exec();
 }
 
 
-void wificonfigwidgetbase::slotWEPChanged( QString newKey, int newIndex )
+void wificonfigwidgetbase::slotWEPChanged( QString newKey, int newIndex, bool hexkey )
 {
     WEPKey = newKey;
     WEPIndex = newIndex;
+    WEPHex = hexkey;
     // Check the status of the radio buttons
     slotCheckSecurityRadio();
     
@@ -842,8 +850,21 @@
 		if ( tmp2.find(" ") != -1 ) {
 		    tmp2 = tmp2.section( " " , 1, 1 );
 		}
-		tmp2.remove(0, 2);
+
+                // 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;
+                }
+
+                // Check if we need to remove the "0x"
 		WEPKey = tmp2;
+
+
 		radioSecurityWEP->setChecked(TRUE);	
 	}
 	

Modified: pcbsd/trunk/wificonfig/wificonfigwidgetbase.h
===================================================================
--- pcbsd/trunk/wificonfig/wificonfigwidgetbase.h	2008-07-24 16:22:14 UTC (rev 2445)
+++ pcbsd/trunk/wificonfig/wificonfigwidgetbase.h	2008-07-24 19:05:41 UTC (rev 2446)
@@ -36,7 +36,7 @@
     void slotConfig();
     void slotSSIDChanged( QString newSSID );
     void slotConfigWEP();
-    void slotWEPChanged( QString newKey, int newIndex );
+    void slotWEPChanged( QString newKey, int newIndex, bool hexkey );
     void slotCheckSecurityRadio();
     void slotCheckWhichSecurity();
     void slotConfigWPAP();
@@ -75,6 +75,7 @@
     wepConfig *dialogWEP;
     QString WEPKey;
     int WEPIndex;
+    bool WEPHex;
     dialogWPAPersonal *dialogWPAP;
     QString WPAPersonalKey;
     dialogWPAEnterprise *dialogWPAE;



More information about the Commits mailing list