@ -346,7 +346,7 @@ void WirelessAssistant::netScan( const WANetParams & np )
//runCommand( Commands.cmd("ifdown", NetParams) ); //Commented out b/c it seems to cause more problems than it solves. (like no scan results)
//runCommand( Commands.cmd("ifdown", NetParams) ); //Commented out b/c it seems to cause more problems than it solves. (like no scan results)
std : : cout < < " No networks found! " < < std : : endl ;
std : : cout < < " No networks found! " < < std : : endl ;
statusLabel - > setText ( i18n ( " No networks found. " ) ) ;
statusLabel - > setText ( i18n ( " No networks found. " ) ) ;
if ( result . tq find( " Resource temporarily unavailable " ) > - 1 ) {
if ( result . find( " Resource temporarily unavailable " ) > - 1 ) {
std : : cout < < " Radio switch seems to be off. " < < std : : endl ;
std : : cout < < " Radio switch seems to be off. " < < std : : endl ;
KMessageBox : : information ( 0 , i18n ( " Radio of your wireless card seems to be turned off using an external switch on your computer. \n You need turn it on to be able to use wireless networks. " ) ) ;
KMessageBox : : information ( 0 , i18n ( " Radio of your wireless card seems to be turned off using an external switch on your computer. \n You need turn it on to be able to use wireless networks. " ) ) ;
}
}
@ -429,8 +429,8 @@ void WirelessAssistant::parseScan( const TQString & output )
enc = true ;
enc = true ;
wpaSettings . clear ( ) ;
wpaSettings . clear ( ) ;
if ( section . tq contains( " WPA2 Version " ) ) wpaSettings < < " WPA2 " ; //prefer WPA2 over WPA
if ( section . contains( " WPA2 Version " ) ) wpaSettings < < " WPA2 " ; //prefer WPA2 over WPA
else if ( section . tq contains( " WPA Version " ) ) wpaSettings < < " WPA " ;
else if ( section . contains( " WPA Version " ) ) wpaSettings < < " WPA " ;
wpa = ( ! wpaSettings . isEmpty ( ) ) ;
wpa = ( ! wpaSettings . isEmpty ( ) ) ;
if ( wpa ) {
if ( wpa ) {
@ -442,7 +442,7 @@ void WirelessAssistant::parseScan( const TQString & output )
// CHECK IF SAME ESSID ALREADY FOUND, if necessary
// CHECK IF SAME ESSID ALREADY FOUND, if necessary
if ( groupAPs ) {
if ( groupAPs ) {
if ( ! hidden & & essidList . tq contains( essid ) ) {
if ( ! hidden & & essidList . contains( essid ) ) {
NetListViewItem * sameEssid = static_cast < NetListViewItem * > ( getItemByEssid ( essid ) ) ;
NetListViewItem * sameEssid = static_cast < NetListViewItem * > ( getItemByEssid ( essid ) ) ;
sameEssid - > setAp ( " any " ) ;
sameEssid - > setAp ( " any " ) ;
if ( sameEssid - > quality ( ) < qualInt ) {
if ( sameEssid - > quality ( ) < qualInt ) {
@ -503,7 +503,7 @@ bool WirelessAssistant::setNetParamsFromConfig( const TQString & s )
for ( TQStringList : : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
for ( TQStringList : : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
if ( ( * nps ) . section ( " , " , 2 , 2 ) = = s | | ( ( * nps ) . section ( " , " , 1 , 1 ) = = s & & ( * nps ) . section ( " , " , 2 , 2 ) = = " any " ) ) {
if ( ( * nps ) . section ( " , " , 2 , 2 ) = = s | | ( ( * nps ) . section ( " , " , 1 , 1 ) = = s & & ( * nps ) . section ( " , " , 2 , 2 ) = = " any " ) ) {
NetParams . loadNetParamsString ( * nps ) ;
NetParams . loadNetParamsString ( * nps ) ;
if ( ! s . tq contains( " : " ) ) NetParams . ap = " any " ; //if searched by essid
if ( ! s . contains( " : " ) ) NetParams . ap = " any " ; //if searched by essid
return 1 ;
return 1 ;
}
}
}
}
@ -654,7 +654,7 @@ void WirelessAssistant::netConnect( const WANetParams & np )
statusLabel - > tqrepaint ( ) ;
statusLabel - > tqrepaint ( ) ;
if ( ! WATools : : isUp ( np . iface ) ) WATools : : setUp ( true , np . iface ) ;
if ( ! WATools : : isUp ( np . iface ) ) WATools : : setUp ( true , np . iface ) ;
//runCommand( Commands.cmd("ifup", np) );
//runCommand( Commands.cmd("ifup", np) );
if ( runCommand ( Commands . cmd ( " iwconfig_set " , np ) ) . tq find( " 8B04 " ) > - 1 ) { // error 8B04 - Request 'Set Frequency' not supported.
if ( runCommand ( Commands . cmd ( " iwconfig_set " , np ) ) . find( " 8B04 " ) > - 1 ) { // error 8B04 - Request 'Set Frequency' not supported.
WANetParams np2 = np ;
WANetParams np2 = np ;
np2 . channel = " 0 " ;
np2 . channel = " 0 " ;
runCommand ( Commands . cmd ( " iwconfig_set " , np2 ) ) ;
runCommand ( Commands . cmd ( " iwconfig_set " , np2 ) ) ;
@ -680,7 +680,7 @@ void WirelessAssistant::netConnect( const WANetParams & np )
///// CONFIGURE IP ADDRESS etc.
///// CONFIGURE IP ADDRESS etc.
if ( np . dhcp ) { //DHCP config
if ( np . dhcp ) { //DHCP config
TQString dhcp_out = runCommand ( Commands . cmd ( " ifconfig_dhcp " , np ) , DhcpTimeout ) ;
TQString dhcp_out = runCommand ( Commands . cmd ( " ifconfig_dhcp " , np ) , DhcpTimeout ) ;
if ( dhcp_out . tq contains( " ::ERR:: " ) & & ! dhcp_out . tq contains( " bound to " ) ) { // 'bound to' is a check for dhclient, which gives some output to stderr even when succeeded
if ( dhcp_out . contains( " ::ERR:: " ) & & ! dhcp_out . contains( " bound to " ) ) { // 'bound to' is a check for dhclient, which gives some output to stderr even when succeeded
if ( dhcpClientRunning ( ) )
if ( dhcpClientRunning ( ) )
runCommand ( Commands . cmd ( " kill_dhcp " , np ) ) ; //kill any stale DHCP client running (seems it's dhclient only)
runCommand ( Commands . cmd ( " kill_dhcp " , np ) ) ; //kill any stale DHCP client running (seems it's dhclient only)
setUi ( 1 ) ;
setUi ( 1 ) ;
@ -738,7 +738,7 @@ void WirelessAssistant::setConnectedItem( const TQString & netid )
}
}
if ( ! netid . isEmpty ( ) ) {
if ( ! netid . isEmpty ( ) ) {
TQListViewItem * lvi ;
TQListViewItem * lvi ;
if ( netid . tq contains( " : " ) ) lvi = getItemByAp ( netid ) ; //netid is an AP address
if ( netid . contains( " : " ) ) lvi = getItemByAp ( netid ) ; //netid is an AP address
else lvi = getItemByEssid ( netid ) ;
else lvi = getItemByEssid ( netid ) ;
if ( lvi ) {
if ( lvi ) {
NetListViewItem * nvi = static_cast < NetListViewItem * > ( lvi ) ;
NetListViewItem * nvi = static_cast < NetListViewItem * > ( lvi ) ;
@ -858,7 +858,7 @@ void WirelessAssistant::togglePage(bool options)
buttonScan - > setDisabled ( options ) ;
buttonScan - > setDisabled ( options ) ;
buttonConnect - > setDisabled ( options ) ;
buttonConnect - > setDisabled ( options ) ;
if ( options ) {
if ( options ) {
if ( WAConfig : : self ( ) - > config ( ) - > groupList ( ) . tq contains( " Notification Messages " ) > 0 )
if ( WAConfig : : self ( ) - > config ( ) - > groupList ( ) . contains( " Notification Messages " ) > 0 )
buttonEnableAllMessages - > setEnabled ( true ) ;
buttonEnableAllMessages - > setEnabled ( true ) ;
else
else
buttonEnableAllMessages - > setEnabled ( false ) ;
buttonEnableAllMessages - > setEnabled ( false ) ;
@ -1134,7 +1134,7 @@ bool WirelessAssistant::generateWpaConfigFile( const TQString& essid, const TQSt
//WPA authentication suite
//WPA authentication suite
c . append ( " key_mgmt= " ) ;
c . append ( " key_mgmt= " ) ;
if ( wpaSettings [ 3 ] . tq contains( " PSK " ) ) c . append ( " WPA-PSK \n " ) ;
if ( wpaSettings [ 3 ] . contains( " PSK " ) ) c . append ( " WPA-PSK \n " ) ;
else return TQString ( ) ; // not supported
else return TQString ( ) ; // not supported
//WPA pairwise cipher
//WPA pairwise cipher
@ -1185,28 +1185,28 @@ bool WirelessAssistant::generateWpaConfigFile( const TQString& essid, const TQSt
bool WirelessAssistant : : setWpaClientEnabled ( bool e , const TQString & iface , TQString driver )
bool WirelessAssistant : : setWpaClientEnabled ( bool e , const TQString & iface , TQString driver )
{
{
if ( ! e ) {
if ( ! e ) {
if ( runCommand ( TQStringList ( Commands . wpa_cli ) < < TQString ( " -i%1 " ) . tqarg ( NetParams . iface ) < < " terminate " ) . tq contains( " OK " ) ) {
if ( runCommand ( TQStringList ( Commands . wpa_cli ) < < TQString ( " -i%1 " ) . tqarg ( NetParams . iface ) < < " terminate " ) . contains( " OK " ) ) {
TQFile ( wpaConfigFile ) . remove ( ) ;
TQFile ( wpaConfigFile ) . remove ( ) ;
return 1 ;
return 1 ;
} else
} else
return 0 ; // wpa client was not running.
return 0 ; // wpa client was not running.
}
}
if ( ! runCommand ( TQStringList ( Commands . wpa_cli ) < < TQString ( " -i%1 " ) . tqarg ( NetParams . iface ) < < " status " ) . tq contains( " Failed to connect " ) ) {
if ( ! runCommand ( TQStringList ( Commands . wpa_cli ) < < TQString ( " -i%1 " ) . tqarg ( NetParams . iface ) < < " status " ) . contains( " Failed to connect " ) ) {
std : : cout < < " WPA client already running. Reconfiguring... " < < std : : endl ;
std : : cout < < " WPA client already running. Reconfiguring... " < < std : : endl ;
runCommand ( TQStringList ( Commands . wpa_cli ) < < " reconfigure " ) ;
runCommand ( TQStringList ( Commands . wpa_cli ) < < " reconfigure " ) ;
} else {
} else {
if ( driver . isEmpty ( ) ) { //detect needed driver
if ( driver . isEmpty ( ) ) { //detect needed driver
TQString k = WATools : : kernelModule ( iface ) ;
TQString k = WATools : : kernelModule ( iface ) ;
if ( k . tq contains( " hermes " ) ) driver = " hermes " ;
if ( k . contains( " hermes " ) ) driver = " hermes " ;
else if ( k . tq contains( " atmel " ) ) driver = " atmel " ;
else if ( k . contains( " atmel " ) ) driver = " atmel " ;
# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 13)
# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 13)
else if ( k . tq contains( " ipw " ) ) driver = " ipw " ; //wext should be used for kernels newer than 2.6.12
else if ( k . contains( " ipw " ) ) driver = " ipw " ; //wext should be used for kernels newer than 2.6.12
# endif
# endif
//Commented out, because ndiswrapper newer than 1.13 works with wext driver.
//Commented out, because ndiswrapper newer than 1.13 works with wext driver.
//else if ( k. tq contains("ndiswrapper") ) driver = "ndiswrapper";
//else if ( k. contains("ndiswrapper") ) driver = "ndiswrapper";
//Commented out, because madwifi-ng works with wext driver.
//Commented out, because madwifi-ng works with wext driver.
//else if ( k. tq contains("ath") ) driver = "madwifi";
//else if ( k. contains("ath") ) driver = "madwifi";
else driver = " wext " ;
else driver = " wext " ;
std : : cout < < " Using wpa_supplicant driver: " < < driver < < std : : endl ;
std : : cout < < " Using wpa_supplicant driver: " < < driver < < std : : endl ;
}
}
@ -1231,7 +1231,7 @@ bool WirelessAssistant::setWpaClientEnabled( bool e, const TQString& iface, TQSt
TQString o ;
TQString o ;
int i = 0 ;
int i = 0 ;
while ( ! ( o = runCommand ( TQStringList ( Commands . wpa_cli ) < < TQString ( " -i%1 " ) . tqarg ( NetParams . iface ) < < " status " ) ) . tq contains( " Failed to connect " ) ) {
while ( ! ( o = runCommand ( TQStringList ( Commands . wpa_cli ) < < TQString ( " -i%1 " ) . tqarg ( NetParams . iface ) < < " status " ) ) . contains( " Failed to connect " ) ) {
for ( int c = 0 ; c < 15 ; c + + ) {
for ( int c = 0 ; c < 15 ; c + + ) {
usleep ( 75 * 1000 ) ; //75msec
usleep ( 75 * 1000 ) ; //75msec
KApplication : : eventLoop ( ) - > processEvents ( TQEventLoop : : AllEvents ) ;
KApplication : : eventLoop ( ) - > processEvents ( TQEventLoop : : AllEvents ) ;
@ -1241,7 +1241,7 @@ bool WirelessAssistant::setWpaClientEnabled( bool e, const TQString& iface, TQSt
runCommand ( TQStringList ( Commands . wpa_cli ) < < TQString ( " -i%1 " ) . tqarg ( NetParams . iface ) < < " terminate " ) ;
runCommand ( TQStringList ( Commands . wpa_cli ) < < TQString ( " -i%1 " ) . tqarg ( NetParams . iface ) < < " terminate " ) ;
return 0 ;
return 0 ;
}
}
if ( o . tq contains( " wpa_state=COMPLETED " ) ) {
if ( o . contains( " wpa_state=COMPLETED " ) ) {
std : : cout < < " WPA Authorisation successful. " < < std : : endl ;
std : : cout < < " WPA Authorisation successful. " < < std : : endl ;
return 1 ;
return 1 ;
}
}