@ -27,16 +27,16 @@
# include <iostream>
# include <linux/version.h> //provides LINUX_VERSION* macros
# include < qregexp.h>
# include < qlabel.h>
# include < qprocess.h>
# include < qcursor.h>
# include < qeventloop.h>
# include < qtimer.h>
# include < qcheckbox.h>
# include < qspinbox.h>
# include < qwidgetstack.h>
# include < qtooltip.h>
# include < t qregexp.h>
# include < t qlabel.h>
# include < t qprocess.h>
# include < t qcursor.h>
# include < t qeventloop.h>
# include < t qtimer.h>
# include < t qcheckbox.h>
# include < t qspinbox.h>
# include < t qwidgetstack.h>
# include < t qtooltip.h>
# include <kpushbutton.h>
# include <kcombobox.h>
@ -48,8 +48,8 @@
# include <klocale.h>
# include <kstandarddirs.h>
WirelessAssistant : : WirelessAssistant ( QWidget* parent, const char * name , bool modal , WFlags fl )
: mainWindow ( parent, name , modal , fl )
WirelessAssistant : : WirelessAssistant ( T QWidget* tq parent, const char * name , bool modal , WFlags fl )
: mainWindow ( tq parent, name , modal , fl )
{
buttonScan - > setIconSet ( SmallIconSet ( " reload " ) ) ;
buttonConnect - > setIconSet ( SmallIconSet ( " connect_creating " ) ) ;
@ -61,35 +61,35 @@ WirelessAssistant::WirelessAssistant(QWidget* parent, const char* name, bool mod
frameDevice - > hide ( ) ;
/// Network List Widget
connect ( buttonScan , SIGNAL( clicked ( ) ) ,
this , SLOT( netScan ( ) ) ) ;
connect ( buttonScan , TQT_ SIGNAL( clicked ( ) ) ,
this , TQT_ SLOT( netScan ( ) ) ) ;
connect ( buttonConnect , SIGNAL( clicked ( ) ) ,
this , SLOT( itemAction ( ) ) ) ;
connect ( buttonConnect , TQT_ SIGNAL( clicked ( ) ) ,
this , TQT_ SLOT( itemAction ( ) ) ) ;
connect ( buttonClose , SIGNAL( clicked ( ) ) ,
this , SLOT( close ( ) ) ) ;
connect ( buttonClose , TQT_ SIGNAL( clicked ( ) ) ,
this , TQT_ SLOT( close ( ) ) ) ;
connect ( devCombo , SIGNAL( activated ( const QString & ) ) ,
this , SLOT( setDev ( const QString & ) ) ) ;
connect ( devCombo , TQT_ SIGNAL( activated ( const T QString & ) ) ,
this , TQT_ SLOT( setDev ( const T QString & ) ) ) ;
connect ( netList , SIGNAL( rightButtonPressed ( QListViewItem* , const QPoint& , int ) ) ,
SLOT( showItemContextMenu ( QListViewItem* , const QPoint& , int ) ) ) ;
connect ( netList , TQT_ SIGNAL( rightButtonPressed ( T QListViewItem* , const T QPoint& , int ) ) ,
TQT_ SLOT( showItemContextMenu ( T QListViewItem* , const T QPoint& , int ) ) ) ;
/// Settings Widget
connect ( buttonOptions , SIGNAL( toggled ( bool ) ) ,
this , SLOT( togglePage ( bool ) ) ) ;
connect ( buttonOptions , TQT_ SIGNAL( toggled ( bool ) ) ,
this , TQT_ SLOT( togglePage ( bool ) ) ) ;
connect ( buttonEnableAllMessages , SIGNAL( clicked ( ) ) ,
this , SLOT( enableAllMessages ( ) ) ) ;
connect ( buttonEnableAllMessages , TQT_ SIGNAL( clicked ( ) ) ,
this , TQT_ SLOT( enableAllMessages ( ) ) ) ;
/// Global KDE Options
connect ( KApplication : : kApplication ( ) , SIGNAL( settingsChanged ( int ) ) ,
this , SLOT( updateConfiguration ( int ) ) ) ;
connect ( KApplication : : kApplication ( ) , TQT_ SIGNAL( settingsChanged ( int ) ) ,
this , TQT_ SLOT( updateConfiguration ( int ) ) ) ;
setMouseBehaviour ( ) ;
QTimer: : singleShot ( 10 , this , SLOT( init ( ) ) ) ; //WAIT FOR THE UI TO BE READY BEFORE FURTHER SETUP (msec)
T QTimer: : singleShot ( 10 , this , TQT_ SLOT( init ( ) ) ) ; //WAIT FOR THE UI TO BE READY BEFORE FURTHER SETUP (msec)
}
WirelessAssistant : : ~ WirelessAssistant ( )
@ -101,11 +101,11 @@ WirelessAssistant::~WirelessAssistant()
void WirelessAssistant : : init ( )
{
statusLabel - > setText ( i18n ( " Initializing... " ) ) ;
statusLabel - > repaint( ) ;
statusLabel - > tq repaint( ) ;
////////////////////////////////////////
///// CHECK FOR SYSFS (KERNEL 2.6) /////
if ( ! QFile: : exists ( " /sys " ) ) {
if ( ! T QFile: : exists ( " /sys " ) ) {
std : : cout < < " Sysfs not present. Exiting. " < < std : : endl ;
KMessageBox : : error ( 0 , i18n ( " Kernel 2.6 or later not present. \n Wireless Assistant will now quit. " ) ) ;
close ( ) ;
@ -150,7 +150,7 @@ void WirelessAssistant::init()
///////////////////////////////////
///// DETECT WIRELESS DEVICES /////
QStringList devList = interfaceList ( ) ;
T QStringList devList = interfaceList ( ) ;
if ( devList . count ( ) = = 0 ) {
std : : cout < < " No wireless interfaces found. Exiting. " < < std : : endl ;
KMessageBox : : error ( 0 , i18n ( " No usable wireless devices found. \n Wireless Assistant will now quit. " ) ) ;
@ -174,7 +174,7 @@ void WirelessAssistant::init()
//////////////////////////////////
///// CHECK FILE PERMISSIONS /////
if ( ! QFileInfo( " /etc/resolv.conf " ) . isWritable ( ) ) {
if ( ! T QFileInfo( " /etc/resolv.conf " ) . isWritable ( ) ) {
std : : cout < < " warning: /etc/resolv.conf not writable " < < std : : endl ;
KMessageBox : : information ( 0 , i18n ( " <qt><p>You might have insufficient permissions for Wireless Assistant to function properly.</p><p>Did you run it using '<tt>sudo</tt>'?</p></qt> " ) ) ;
}
@ -188,16 +188,16 @@ void WirelessAssistant::init()
///// INITIALIZE GLOBAL VARIABLES /////
wpaAvailable = ( ! ( Commands . wpa_supplicant . isEmpty ( ) | | Commands . wpa_cli . isEmpty ( ) ) ) ;
connectedItem = 0 ;
timerGui = new QTimer( ) ;
timerConnectionCheck = new QTimer( ) ;
connect ( timerGui , SIGNAL( timeout ( ) ) , SLOT( updateConnectedItem ( ) ) ) ;
connect ( timerConnectionCheck , SIGNAL( timeout ( ) ) , SLOT( checkConnection Status( ) ) ) ;
timerGui = new T QTimer( ) ;
timerConnectionCheck = new T QTimer( ) ;
connect ( timerGui , TQT_ SIGNAL( timeout ( ) ) , TQT_ SLOT( updateConnectedItem ( ) ) ) ;
connect ( timerConnectionCheck , TQT_ SIGNAL( timeout ( ) ) , TQT_ SLOT( checkConnection tq Status( ) ) ) ;
////////////////////////
///// DETECT & SET PATHS /////
if ( ! Commands . allFound ) { //all ok or ONLY dhcpcd not found (i.e. dhclient present).
std : : cout < < " Missing executables ( " < < Commands . notFound . join ( " ', ' " ) < < " ). Exiting. " < < std : : endl ;
KMessageBox : : error ( 0 , i18n ( " Executable(s) '%1' could not be found. \n Wireless Assistant will now quit. " ) . arg( Commands . notFound . join ( " ', ' " ) ) ) ;
KMessageBox : : error ( 0 , i18n ( " Executable(s) '%1' could not be found. \n Wireless Assistant will now quit. " ) . tq arg( Commands . notFound . join ( " ', ' " ) ) ) ;
close ( ) ;
return ;
}
@ -208,14 +208,14 @@ void WirelessAssistant::init()
///////////////////////////////////////
///// SCAN FOR AVAILABLE NETWORKS /////
if ( autoConnect )
QTimer: : singleShot ( 0 , this , SLOT( netAutoConnect ( ) ) ) ;
T QTimer: : singleShot ( 0 , this , TQT_ SLOT( netAutoConnect ( ) ) ) ;
else
QTimer: : singleShot ( 0 , this , SLOT( netScan ( ) ) ) ;
T QTimer: : singleShot ( 0 , this , TQT_ SLOT( netScan ( ) ) ) ;
}
void WirelessAssistant : : checkConnection Status( )
void WirelessAssistant : : checkConnection tq Status( )
{
QListViewItem* lvi ;
T QListViewItem* lvi ;
if ( groupAPs ) lvi = getItemByEssid ( WATools : : essid ( NetParams . iface ) ) ;
else lvi = getItemByAp ( WATools : : ap ( NetParams . iface ) ) ;
bool needsKey ;
@ -235,7 +235,7 @@ void WirelessAssistant::checkConnectionStatus()
} else if ( connectedItem ) { //connection LOST
setConnectedItem ( 0 ) ;
timerConnectionCheck - > stop ( ) ;
if ( autoReconnect | | KMessageBox : : questionYesNo ( 0 , i18n ( " Connection to '%1' has been lost! \n Would you like to reconnect? " ) . arg( NetParams . essid ) , i18n ( " Connection Lost " ) , KStdGuiItem : : yes ( ) , KStdGuiItem : : no ( ) ) = = KMessageBox : : Yes ) {
if ( autoReconnect | | KMessageBox : : questionYesNo ( 0 , i18n ( " Connection to '%1' has been lost! \n Would you like to reconnect? " ) . tq arg( NetParams . essid ) , i18n ( " Connection Lost " ) , KStdGuiItem : : yes ( ) , KStdGuiItem : : no ( ) ) = = KMessageBox : : Yes ) {
netDisconnect ( true ) ;
netConnect ( ) ;
}
@ -246,10 +246,10 @@ void WirelessAssistant::checkConnectionStatus()
void WirelessAssistant : : removeNetParams ( )
{
NetListViewItem * nvi = static_cast < NetListViewItem * > ( netList - > selectedItem ( ) ) ;
QString ap = nvi - > ap ( ) ; QString essid = nvi - > essid ( ) ;
for ( QStringList: : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
T QString ap = nvi - > ap ( ) ; T QString essid = nvi - > essid ( ) ;
for ( T QStringList: : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
if ( ( * nps ) . section ( " , " , 2 , 2 ) = = ap & & ( * nps ) . section ( " , " , 1 , 1 ) = = essid ) {
if ( KMessageBox : : warningContinueCancel ( 0 , i18n ( " <qt><p>Settings for network '<b>%1</b>' are about to be deleted.</p><p>Would you like to continue?</p></qt> " ) . arg( essid ) ) = = KMessageBox : : Continue ) {
if ( KMessageBox : : warningContinueCancel ( 0 , i18n ( " <qt><p>Settings for network '<b>%1</b>' are about to be deleted.</p><p>Would you like to continue?</p></qt> " ) . tq arg( essid ) ) = = KMessageBox : : Continue ) {
if ( nvi - > hidden ( ) ) // hiddenEssid = 1
nvi - > setEssid ( " <hidden> " ) ;
NetParamsList . remove ( nps ) ;
@ -264,25 +264,25 @@ void WirelessAssistant::removeNetParams()
void WirelessAssistant : : setDNS ( const WANetParams & np )
{
QFile f ( " /etc/resolv.conf " ) ;
T QFile f ( " /etc/resolv.conf " ) ;
if ( f . open ( IO_WriteOnly | IO_Truncate ) ) {
QTextStream s ( & f ) ;
T QTextStream s ( & f ) ;
if ( ! np . domain . isEmpty ( ) ) {
s < < QString( " domain " + np . domain + " \n " ) ;
s < < T QString( " domain " + np . domain + " \n " ) ;
std : : cout < < " resolv.conf: domain " < < np . domain < < std : : endl ;
}
if ( ! np . dns1 . isEmpty ( ) ) {
s < < QString( " nameserver " + np . dns1 + " \n " ) ;
s < < T QString( " nameserver " + np . dns1 + " \n " ) ;
std : : cout < < " resolv.conf: nameserver " < < np . dns1 < < std : : endl ;
}
if ( ! np . dns2 . isEmpty ( ) ) {
s < < QString( " nameserver " + np . dns2 + " \n " ) ;
s < < T QString( " nameserver " + np . dns2 + " \n " ) ;
std : : cout < < " resolv.conf: nameserver " < < np . dns2 < < std : : endl ;
}
f . close ( ) ;
} else {
std : : cout < < " dns setup error: " < < f . name ( ) < < " is not writeable. " < < std : : endl ;
KMessageBox : : error ( 0 , i18n ( " <qt><p>File '<i>%1</i>' could not be opened for writing.</p><p>Nameserver(s) and/or domain are not set.</p></qt> " ) . arg( f . name ( ) ) ) ;
KMessageBox : : error ( 0 , i18n ( " <qt><p>File '<i>%1</i>' could not be opened for writing.</p><p>Nameserver(s) and/or domain are not set.</p></qt> " ) . tq arg( f . name ( ) ) ) ;
}
}
@ -291,7 +291,7 @@ void WirelessAssistant::netScan()
timerConnectionCheck - > stop ( ) ; //stop while scanning.
netScan ( NetParams ) ;
if ( netList - > childCount ( ) > 0 ) {
QTimer: : singleShot ( 0 , this , SLOT( checkConnection Status( ) ) ) ;
T QTimer: : singleShot ( 0 , this , TQT_ SLOT( checkConnection tq Status( ) ) ) ;
timerConnectionCheck - > start ( WA_CONNECTION_CHECK_INTERVAL ) ;
}
}
@ -314,30 +314,30 @@ void WirelessAssistant::netScan( const WANetParams & np )
}
if ( ! WATools : : isUp ( np . iface ) ) {
statusLabel - > setText ( i18n ( " Bringing interface %1 up... " ) . arg( np . iface ) ) ;
statusLabel - > setText ( i18n ( " Bringing interface %1 up... " ) . tq arg( np . iface ) ) ;
//runCommand( Commands.cmd("ifup",np) );
WATools : : setUp ( true , np . iface ) ;
if ( DelayBeforeScanning > 0 ) {
statusLabel - > setText ( i18n ( " Waiting before scanning... " ) ) ;
statusLabel - > repaint( ) ;
KApplication : : eventLoop ( ) - > processEvents ( QEventLoop: : ExcludeUserInput ) ;
statusLabel - > tq repaint( ) ;
KApplication : : eventLoop ( ) - > processEvents ( T QEventLoop: : ExcludeUserInput ) ;
usleep ( DelayBeforeScanning * 1000000 ) ; // delay * 1000ms
}
}
statusLabel - > setText ( i18n ( " Scanning... " ) ) ;
statusLabel - > repaint( ) ;
statusLabel - > tq repaint( ) ;
netList - > clear ( ) ;
QString result ;
T QString result ;
statusLabel - > setText ( i18n ( " Scanning... " ) ) ;
result = runCommand ( Commands . cmd ( " scan " , np ) ) ;
parseScan ( result ) ;
if ( netList - > childCount ( ) > 0 ) {
std : : cout < < " Networks found: " < < QString: : number ( netList - > childCount ( ) ) < < std : : endl ;
std : : cout < < " Networks found: " < < T QString: : number ( netList - > childCount ( ) ) < < std : : endl ;
if ( wasConnected )
groupAPs ? setConnectedItem ( WATools : : essid ( ) ) : setConnectedItem ( WATools : : ap ( ) ) ; //mark item as connected.
statusLabel - > setText ( i18n ( " Done. " ) ) ;
@ -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)
std : : cout < < " No networks found! " < < std : : endl ;
statusLabel - > setText ( i18n ( " No networks found. " ) ) ;
if ( result . find( " Resource temporarily unavailable " ) > - 1 ) {
if ( result . tq find( " Resource temporarily unavailable " ) > - 1 ) {
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. " ) ) ;
}
@ -354,25 +354,25 @@ void WirelessAssistant::netScan( const WANetParams & np )
setNetListColumns ( ) ;
}
void WirelessAssistant : : parseScan ( const QString & output )
void WirelessAssistant : : parseScan ( const T QString & output )
{
QString essid ;
QStringList essidList ;
QString channel ;
QString mode ;
T QString essid ;
T QStringList essidList ;
T QString channel ;
T QString mode ;
int qualInt ;
bool enc ; //default to false
bool hidden ; //default to false
QString ap ;
T QString ap ;
// security parameters
bool wpa ;
QStringList wpaSettings ;
// QString wpaVersion, wpaGroupCipher, wpaPairwiseCipher, wpaAuthenticationSuite;
T QStringList wpaSettings ;
// T QString wpaVersion, wpaGroupCipher, wpaPairwiseCipher, wpaAuthenticationSuite;
bool ok_channel = true ; //does iwlist return channel?
QString section ;
T QString section ;
netList - > setUpdatesEnabled ( false ) ; //do not redraw while adding items to avoid flicker.
@ -410,7 +410,7 @@ void WirelessAssistant::parseScan( const QString & output )
} else
hidden = false ;
// GET QUALITY
// GET T QUALITY
int wsignal ;
//check if driver reports quality directly
qualInt = getVal ( section , " Quality \\ D+( \\ d+) " ) . toInt ( ) ;
@ -429,8 +429,8 @@ void WirelessAssistant::parseScan( const QString & output )
enc = true ;
wpaSettings . clear ( ) ;
if ( section . contains( " WPA2 Version " ) ) wpaSettings < < " WPA2 " ; //prefer WPA2 over WPA
else if ( section . contains( " WPA Version " ) ) wpaSettings < < " WPA " ;
if ( section . tq contains( " WPA2 Version " ) ) wpaSettings < < " WPA2 " ; //prefer WPA2 over WPA
else if ( section . tq contains( " WPA Version " ) ) wpaSettings < < " WPA " ;
wpa = ( ! wpaSettings . isEmpty ( ) ) ;
if ( wpa ) {
@ -442,7 +442,7 @@ void WirelessAssistant::parseScan( const QString & output )
// CHECK IF SAME ESSID ALREADY FOUND, if necessary
if ( groupAPs ) {
if ( ! hidden & & essidList . contains( essid ) ) {
if ( ! hidden & & essidList . tq contains( essid ) ) {
NetListViewItem * sameEssid = static_cast < NetListViewItem * > ( getItemByEssid ( essid ) ) ;
sameEssid - > setAp ( " any " ) ;
if ( sameEssid - > quality ( ) < qualInt ) {
@ -485,7 +485,7 @@ bool WirelessAssistant::radioEnabled()
return r ;
}
void WirelessAssistant : : setNetParamsFromList ( QListViewItem* lvi )
void WirelessAssistant : : setNetParamsFromList ( T QListViewItem* lvi )
{
NetListViewItem * nvi = static_cast < NetListViewItem * > ( lvi ) ;
NetParams . essid = nvi - > essid ( ) ;
@ -498,12 +498,12 @@ void WirelessAssistant::setNetParamsFromList( QListViewItem* lvi )
NetParams . wpa = ( nvi - > enc ( ) & & ! NetParams . wpaSettings . isEmpty ( ) ) ;
}
bool WirelessAssistant : : setNetParamsFromConfig ( const QString & s )
bool WirelessAssistant : : setNetParamsFromConfig ( const T QString & s )
{
for ( QStringList: : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
for ( T QStringList: : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
if ( ( * nps ) . section ( " , " , 2 , 2 ) = = s | | ( ( * nps ) . section ( " , " , 1 , 1 ) = = s & & ( * nps ) . section ( " , " , 2 , 2 ) = = " any " ) ) {
NetParams . loadNetParamsString ( * nps ) ;
if ( ! s . contains( " : " ) ) NetParams . ap = " any " ; //if searched by essid
if ( ! s . tq contains( " : " ) ) NetParams . ap = " any " ; //if searched by essid
return 1 ;
}
}
@ -512,7 +512,7 @@ bool WirelessAssistant::setNetParamsFromConfig( const QString & s )
void WirelessAssistant : : itemAction ( )
{
QListViewItem* lvi = netList - > selectedItem ( ) ;
T QListViewItem* lvi = netList - > selectedItem ( ) ;
if ( ! lvi )
return ;
@ -539,7 +539,7 @@ void WirelessAssistant::netAutoConnect()
int bestQuality = 0 ;
for ( int i = 0 ; i < netList - > childCount ( ) ; i + + ) {
NetListViewItem * nvi = static_cast < NetListViewItem * > ( netList - > itemAtIndex ( i ) ) ;
QString search = nvi - > ap ( ) ;
T QString search = nvi - > ap ( ) ;
if ( search = = " any " ) search = nvi - > essid ( ) ;
if ( setNetParamsFromConfig ( search ) ) {
if ( nvi - > quality ( ) > bestQuality ) {
@ -552,7 +552,7 @@ void WirelessAssistant::netAutoConnect()
if ( bestItem ! = - 1 ) {
NetListViewItem * nvi = static_cast < NetListViewItem * > ( netList - > itemAtIndex ( bestItem ) ) ;
setNetParamsFromList ( nvi ) ;
QString search = nvi - > ap ( ) ;
T QString search = nvi - > ap ( ) ;
if ( search = = " any " ) search = nvi - > essid ( ) ;
setNetParamsFromConfig ( search ) ;
timerConnectionCheck - > stop ( ) ;
@ -570,21 +570,21 @@ void WirelessAssistant::netConnect()
setNetParamsFromList ( netList - > selectedItem ( ) ) ;
//can't connect if WPA needed, and wpa_supplicant and wpa_cli not available
if ( NetParams . wpa & & ! wpaAvailable ) {
KMessageBox : : error ( 0 , i18n ( " <qt><p><b>Can not connect to network '%1'.<b></p><p>The network you are trying to connect to requires WPA authentication. The necessary executables <i>wpa_supplicant</i> and <i>wpa_cli</i> could not be found. Install <i>wpa_supplicant</i> and restart Wireless Assistant to connect.</p></qt> " ) . arg( NetParams . essid ) ) ;
KMessageBox : : error ( 0 , i18n ( " <qt><p><b>Can not connect to network '%1'.<b></p><p>The network you are trying to connect to requires WPA authentication. The necessary executables <i>wpa_supplicant</i> and <i>wpa_cli</i> could not be found. Install <i>wpa_supplicant</i> and restart Wireless Assistant to connect.</p></qt> " ) . tq arg( NetParams . essid ) ) ;
timerConnectionCheck - > start ( WA_CONNECTION_CHECK_INTERVAL ) ; //resume connection checking
return ;
}
QString search = NetParams . ap ;
T QString search = NetParams . ap ;
if ( search = = " any " ) search = NetParams . essid ;
if ( ( NetParams . essid = = " <hidden> " ) | | ( ! setNetParamsFromConfig ( search ) ) ) {
ui_NetParamsWizard * netwiz = new ui_NetParamsWizard ;
if ( ! NetParams . hiddenEssid )
netwiz - > setCaption ( i18n ( " %1 - First Connection Wizard " ) . arg( NetParams . essid ) ) ;
netwiz - > setCaption ( i18n ( " %1 - First Connection Wizard " ) . tq arg( NetParams . essid ) ) ;
netwiz - > setEssidEnabled ( NetParams . hiddenEssid ) ;
netwiz - > setWepEnabled ( NetParams . wep ) ;
netwiz - > setWpaEnabled ( NetParams . wpa , NetParams . wpaSettings ) ;
netwiz - > exec ( ) ;
if ( netwiz - > result ( ) = = QDialog: : Rejected ) {
if ( netwiz - > result ( ) = = T QDialog: : Rejected ) {
delete netwiz ;
timerConnectionCheck - > start ( WA_CONNECTION_CHECK_INTERVAL ) ; //resume connection checking
return ;
@ -609,9 +609,9 @@ void WirelessAssistant::netConnect()
void WirelessAssistant : : updateNetParams ( )
{
for ( QStringList: : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
for ( T QStringList: : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
if ( ( * nps ) . section ( " , " , 2 , 2 ) = = NetParams . ap ) {
QString newNps = NetParams . netParamsString ( ) ;
T QString newNps = NetParams . netParamsString ( ) ;
if ( newNps ! = ( * nps ) ) {
( * nps ) = newNps ;
WAConfig : : self ( ) - > writeConfig ( ) ;
@ -623,9 +623,9 @@ void WirelessAssistant::updateNetParams()
}
}
QString WirelessAssistant : : matchEssidForAp ( const QString & ap )
T QString WirelessAssistant : : matchEssidForAp ( const T QString & ap )
{
for ( QStringList: : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
for ( T QStringList: : Iterator nps = NetParamsList . begin ( ) ; nps ! = NetParamsList . end ( ) ; nps + + ) {
if ( ( * nps ) . section ( " , " , 2 , 2 ) = = ap ) {
return ( * nps ) . section ( " , " , 1 , 1 ) ; //essid
}
@ -645,16 +645,16 @@ void WirelessAssistant::netConnect( const WANetParams & np )
if ( ! np . preConnectionCommand . isEmpty ( ) ) {
std : : cout < < " Running pre-connection command: " < < np . preConnectionCommand < < std : : endl ;
statusLabel - > setText ( i18n ( " Running pre-connection command... " ) ) ;
runCommand ( QStringList: : split ( " " , np . preConnectionCommand ) , np . preConnectionTimeout , np . preConnectionDetached ) ;
runCommand ( T QStringList: : split ( " " , np . preConnectionCommand ) , np . preConnectionTimeout , np . preConnectionDetached ) ;
} else
std : : cout < < " No pre-connection command specified. " < < std : : endl ;
statusLabel - > setText ( i18n ( " Connecting to '%1'... " ) . arg( np . essid ) ) ;
statusLabel - > repaint( ) ;
statusLabel - > setText ( i18n ( " Connecting to '%1'... " ) . tq arg( np . essid ) ) ;
statusLabel - > tq repaint( ) ;
if ( ! WATools : : isUp ( np . iface ) ) WATools : : setUp ( true , np . iface ) ;
//runCommand( Commands.cmd("ifup", np) );
if ( runCommand ( Commands . cmd ( " iwconfig_set " , np ) ) . find( " 8B04 " ) > - 1 ) { // error 8B04 - Request 'Set Frequency' not supported.
if ( runCommand ( Commands . cmd ( " iwconfig_set " , np ) ) . tq find( " 8B04 " ) > - 1 ) { // error 8B04 - Request 'Set Frequency' not supported.
WANetParams np2 = np ;
np2 . channel = " 0 " ;
runCommand ( Commands . cmd ( " iwconfig_set " , np2 ) ) ;
@ -679,8 +679,8 @@ void WirelessAssistant::netConnect( const WANetParams & np )
////////////////////////
///// CONFIGURE IP ADDRESS etc.
if ( np . dhcp ) { //DHCP config
QString dhcp_out = runCommand ( Commands . cmd ( " ifconfig_dhcp " , np ) , DhcpTimeout ) ;
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
T QString 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 ( dhcpClientRunning ( ) )
runCommand ( Commands . cmd ( " kill_dhcp " , np ) ) ; //kill any stale DHCP client running (seems it's dhclient only)
setUi ( 1 ) ;
@ -698,7 +698,7 @@ void WirelessAssistant::netConnect( const WANetParams & np )
if ( ! np . postConnectionCommand . isEmpty ( ) ) {
std : : cout < < " Running post-connection command: " < < np . postConnectionCommand < < std : : endl ;
statusLabel - > setText ( i18n ( " Running post-connection command... " ) ) ;
runCommand ( QStringList: : split ( " " , np . postConnectionCommand ) , np . postConnectionTimeout , np . postConnectionDetached ) ;
runCommand ( T QStringList: : split ( " " , np . postConnectionCommand ) , np . postConnectionTimeout , np . postConnectionDetached ) ;
} else
std : : cout < < " No post-connection command specified. " < < std : : endl ;
@ -710,7 +710,7 @@ void WirelessAssistant::netConnect( const WANetParams & np )
if ( autoQuit )
this - > close ( ) ;
groupAPs ? setConnectedItem ( np . essid ) : setConnectedItem ( np . ap ) ;
statusLabel - > setText ( i18n ( " Successfully connected to '%1'. " ) . arg( np . essid ) ) ;
statusLabel - > setText ( i18n ( " Successfully connected to '%1'. " ) . tq arg( np . essid ) ) ;
setUi ( 1 ) ;
} else {
std : : cout < < " CONNECTION FAILED. " < < std : : endl ;
@ -728,7 +728,7 @@ void WirelessAssistant::updateConnectedItem()
connectedItem - > setQuality ( WATools : : quality ( ) ) ;
}
void WirelessAssistant : : setConnectedItem ( const QString & netid )
void WirelessAssistant : : setConnectedItem ( const T QString & netid )
{
timerConnectionCheck - > stop ( ) ; //stop timer while changing currentItem
if ( connectedItem ) {
@ -737,8 +737,8 @@ void WirelessAssistant::setConnectedItem( const QString & netid )
connectedItem = 0 ;
}
if ( ! netid . isEmpty ( ) ) {
QListViewItem* lvi ;
if ( netid . contains( " : " ) ) lvi = getItemByAp ( netid ) ; //netid is an AP address
T QListViewItem* lvi ;
if ( netid . tq contains( " : " ) ) lvi = getItemByAp ( netid ) ; //netid is an AP address
else lvi = getItemByEssid ( netid ) ;
if ( lvi ) {
NetListViewItem * nvi = static_cast < NetListViewItem * > ( lvi ) ;
@ -757,29 +757,29 @@ void WirelessAssistant::setConnectedItem( const QString & netid )
void WirelessAssistant : : netDisconnect ( const bool & quiet )
{
if ( ( quiet ) | | ( KMessageBox : : warningContinueCancel ( 0 , i18n ( " <qt><p>You are about to disconnect from '<b>%1</b>'.</p><p>Would you like to continue?<p></qt> " ) . arg( connectedItem - > essid ( ) ) ) = = KMessageBox : : Continue ) ) {
if ( ( quiet ) | | ( KMessageBox : : warningContinueCancel ( 0 , i18n ( " <qt><p>You are about to disconnect from '<b>%1</b>'.</p><p>Would you like to continue?<p></qt> " ) . tq arg( connectedItem - > essid ( ) ) ) = = KMessageBox : : Continue ) ) {
timerConnectionCheck - > stop ( ) ; //stop while disconnecting.
if ( ! NetParams . preDisconnectionCommand . isEmpty ( ) ) {
std : : cout < < " Running pre-disconnection command: " < < NetParams . preDisconnectionCommand < < std : : endl ;
statusLabel - > setText ( i18n ( " Running pre-disconnection command... " ) ) ;
runCommand ( QStringList: : split ( " " , NetParams . preDisconnectionCommand ) , NetParams . preDisconnectionTimeout , NetParams . preDisconnectionDetached ) ;
runCommand ( T QStringList: : split ( " " , NetParams . preDisconnectionCommand ) , NetParams . preDisconnectionTimeout , NetParams . preDisconnectionDetached ) ;
} else
std : : cout < < " No pre-disconnection command specified. " < < std : : endl ;
statusLabel - > setText ( i18n ( " Disconnecting... " ) ) ;
statusLabel - > repaint( ) ;
statusLabel - > tq repaint( ) ;
setConnectedItem ( 0 ) ;
if ( NetParams . dhcp ) {
if ( dhcpClientRunning ( ) ) {
runCommand ( Commands . cmd ( " kill_dhcp " , NetParams ) ) ;
statusLabel - > setText ( i18n ( " Waiting for DHCP client to shut down... " ) ) ;
statusLabel - > repaint( ) ;
QTimer* tmr = new QTimer( ) ;
statusLabel - > tq repaint( ) ;
T QTimer* tmr = new T QTimer( ) ;
tmr - > start ( 1500 , true ) ; //wait 1.5sec for dhcp client to really shutdown, single shot.
while ( tmr - > isActive ( ) ) {
KApplication : : eventLoop ( ) - > processEvents ( QEventLoop: : AllEvents ) ;
KApplication : : eventLoop ( ) - > processEvents ( T QEventLoop: : AllEvents ) ;
usleep ( 75 * 1000 ) ; //75msec on Linux
}
delete tmr ;
@ -798,7 +798,7 @@ void WirelessAssistant::netDisconnect( const bool & quiet )
if ( ! NetParams . postDisconnectionCommand . isEmpty ( ) ) {
std : : cout < < " Running post-disconnection command: " < < NetParams . postDisconnectionCommand < < std : : endl ;
statusLabel - > setText ( i18n ( " Running post-disconnection command... " ) ) ;
runCommand ( QStringList: : split ( " " , NetParams . postDisconnectionCommand ) , NetParams . postDisconnectionTimeout , NetParams . postDisconnectionDetached ) ;
runCommand ( T QStringList: : split ( " " , NetParams . postDisconnectionCommand ) , NetParams . postDisconnectionTimeout , NetParams . postDisconnectionDetached ) ;
} else
std : : cout < < " No post-disconnection command specified. " < < std : : endl ;
@ -810,9 +810,9 @@ void WirelessAssistant::netDisconnect( const bool & quiet )
}
}
QListViewItem* WirelessAssistant : : getItemByAp ( const QString & ap )
T QListViewItem* WirelessAssistant : : getItemByAp ( const T QString & ap )
{
QListViewItem* lvi = netList - > firstChild ( ) ;
T QListViewItem* lvi = netList - > firstChild ( ) ;
while ( lvi ) {
if ( static_cast < NetListViewItem * > ( lvi ) - >
ap ( ) = = ap ) {
@ -823,9 +823,9 @@ QListViewItem* WirelessAssistant::getItemByAp( const QString & ap )
return lvi ;
}
QListViewItem* WirelessAssistant : : getItemByEssid ( const QString & essid )
T QListViewItem* WirelessAssistant : : getItemByEssid ( const T QString & essid )
{
QListViewItem* lvi = netList - > firstChild ( ) ;
T QListViewItem* lvi = netList - > firstChild ( ) ;
while ( lvi ) {
if ( static_cast < NetListViewItem * > ( lvi ) - >
essid ( ) = = essid ) {
@ -858,7 +858,7 @@ void WirelessAssistant::togglePage(bool options)
buttonScan - > setDisabled ( options ) ;
buttonConnect - > setDisabled ( options ) ;
if ( options ) {
if ( WAConfig : : self ( ) - > config ( ) - > groupList ( ) . contains( " Notification Messages " ) > 0 )
if ( WAConfig : : self ( ) - > config ( ) - > groupList ( ) . tq contains( " Notification Messages " ) > 0 )
buttonEnableAllMessages - > setEnabled ( true ) ;
else
buttonEnableAllMessages - > setEnabled ( false ) ;
@ -878,43 +878,43 @@ void WirelessAssistant::enableAllMessages()
void WirelessAssistant : : setMouseBehaviour ( )
{
if ( KGlobalSettings : : singleClick ( ) ) {
disconnect ( netList , SIGNAL( selectionChanged ( QListViewItem* ) ) ,
this , SLOT( updateConnectButton ( QListViewItem* ) ) ) ;
disconnect ( netList , SIGNAL( doubleClicked ( QListViewItem* , const QPoint & , int ) ) ,
this , SLOT( itemAction ( ) ) ) ;
connect ( netList , SIGNAL( clicked ( QListViewItem* , const QPoint & , int ) ) ,
this , SLOT( itemAction ( ) ) ) ;
disconnect ( netList , TQT_ SIGNAL( selectionChanged ( T QListViewItem* ) ) ,
this , TQT_ SLOT( updateConnectButton ( T QListViewItem* ) ) ) ;
disconnect ( netList , TQT_ SIGNAL( doubleClicked ( T QListViewItem* , const T QPoint & , int ) ) ,
this , TQT_ SLOT( itemAction ( ) ) ) ;
connect ( netList , TQT_ SIGNAL( clicked ( T QListViewItem* , const T QPoint & , int ) ) ,
this , TQT_ SLOT( itemAction ( ) ) ) ;
buttonConnect - > hide ( ) ;
} else {
disconnect ( netList , SIGNAL( clicked ( QListViewItem* , const QPoint & , int ) ) ,
this , SLOT( itemAction ( ) ) ) ;
disconnect ( netList , TQT_ SIGNAL( clicked ( T QListViewItem* , const T QPoint & , int ) ) ,
this , TQT_ SLOT( itemAction ( ) ) ) ;
connect ( netList , SIGNAL( selectionChanged ( QListViewItem* ) ) ,
this , SLOT( updateConnectButton ( QListViewItem* ) ) ) ;
connect ( netList , SIGNAL( doubleClicked ( QListViewItem* , const QPoint & , int ) ) ,
this , SLOT( itemAction ( ) ) ) ;
connect ( netList , TQT_ SIGNAL( selectionChanged ( T QListViewItem* ) ) ,
this , TQT_ SLOT( updateConnectButton ( T QListViewItem* ) ) ) ;
connect ( netList , TQT_ SIGNAL( doubleClicked ( T QListViewItem* , const T QPoint & , int ) ) ,
this , TQT_ SLOT( itemAction ( ) ) ) ;
buttonConnect - > show ( ) ;
}
}
void WirelessAssistant : : updateConnectButton ( QListViewItem* lvi )
void WirelessAssistant : : updateConnectButton ( T QListViewItem* lvi )
{
QToolTip: : remove
T QToolTip: : remove
( buttonConnect ) ;
if ( lvi = = connectedItem ) {
buttonConnect - > setText ( i18n ( " &Disconnect " ) ) ;
QToolTip: : add
T QToolTip: : add
( buttonConnect , i18n ( " Disconnect from the selected network " ) ) ;
} else {
buttonConnect - > setText ( i18n ( " &Connect " ) ) ;
QToolTip: : add
T QToolTip: : add
( buttonConnect , i18n ( " Connect to the selected network " ) ) ;
}
}
void WirelessAssistant : : setDev ( const QString & ifname )
void WirelessAssistant : : setDev ( const T QString & ifname )
{
NetParams . iface = ifname ;
WATools : : setInterface ( ifname ) ;
@ -922,67 +922,67 @@ void WirelessAssistant::setDev( const QString & ifname)
netScan ( ) ;
}
QString WirelessAssistant : : runCommand ( const QStringList & cmd , int timeout , bool detached )
T QString WirelessAssistant : : runCommand ( const T QStringList & cmd , int timeout , bool detached )
{
if ( cmd . isEmpty ( ) )
return QString : : null ;
return TQString ( ) ;
// a very basic and easy-to-workaround attepmt to restrict using dangerous commands via custom commands setting. This *REALLY* needs a working solution.
if ( cmd [ 0 ] = = " rm " | | cmd [ 0 ] = = " mv " | | cmd [ 0 ] = = " cp " | | cmd [ 0 ] = = " ln " ) return QString: : null ;
if ( cmd [ 0 ] = = " rm " | | cmd [ 0 ] = = " mv " | | cmd [ 0 ] = = " cp " | | cmd [ 0 ] = = " ln " ) return TQString( ) ;
QProcess* p = new QProcess( this ) ;
T QProcess* p = new T QProcess( TQT_TQOBJECT ( this ) ) ;
p - > setArguments ( cmd ) ;
p - > start ( ) ;
if ( detached ) {
p = 0 ;
return QString : : null ;
return TQString ( ) ;
}
QTimer* timerProc = new QTimer( ) ; //timeout timer
T QTimer* timerProc = new T QTimer( ) ; //timeout timer
if ( timeout > 0 & & ! detached ) {
connect ( timerProc , SIGNAL( timeout ( ) ) , p , SLOT( kill ( ) ) ) ;
connect ( timerProc , TQT_ SIGNAL( timeout ( ) ) , p , TQT_ SLOT( kill ( ) ) ) ;
timerProc - > start ( timeout * 1000 ) ; //convert sec to msec
}
connect ( buttonClose , SIGNAL( clicked ( ) ) ,
p , SLOT( kill ( ) ) ) ;
connect ( buttonClose , TQT_ SIGNAL( clicked ( ) ) ,
p , TQT_ SLOT( kill ( ) ) ) ;
int i = 0 ;
while ( p - > isRunning ( ) ) { // PROCESS USER EVENTS
KApplication : : eventLoop ( ) - > processEvents ( QEventLoop: : AllEvents ) ;
KApplication : : eventLoop ( ) - > processEvents ( T QEventLoop: : AllEvents ) ;
usleep ( 75 * 1000 ) ; //75msec on Linux (75000msec on Windows...)
if ( i = = 27 ) { // ca 2sec have passed and the process is still running. Replace the 'Close' button with 'Stop'.
disconnect ( buttonClose , SIGNAL( clicked ( ) ) ,
this , SLOT( close ( ) ) ) ;
disconnect ( buttonClose , TQT_ SIGNAL( clicked ( ) ) ,
this , TQT_ SLOT( close ( ) ) ) ;
buttonClose - > setIconSet ( SmallIconSet ( " stop " ) ) ;
buttonClose - > setText ( i18n ( " &Stop " ) ) ;
QToolTip: : remove
T QToolTip: : remove
( buttonClose ) ;
QToolTip: : add
( buttonClose , i18n ( " Terminate current process \n (%1) " ) . arg( p - > arguments ( ) . join ( " " ) ) ) ;
T QToolTip: : add
( buttonClose , i18n ( " Terminate current process \n (%1) " ) . tq arg( p - > arguments ( ) . join ( " " ) ) ) ;
}
i + + ;
}
disconnect ( buttonClose , SIGNAL( clicked ( ) ) ,
p , SLOT( kill ( ) ) ) ;
disconnect ( buttonClose , TQT_ SIGNAL( clicked ( ) ) ,
p , TQT_ SLOT( kill ( ) ) ) ;
if ( i > 27 ) { //set 'stop' back to 'close' if needed
connect ( buttonClose , SIGNAL( clicked ( ) ) ,
this , SLOT( close ( ) ) ) ;
connect ( buttonClose , TQT_ SIGNAL( clicked ( ) ) ,
this , TQT_ SLOT( close ( ) ) ) ;
buttonClose - > setIconSet ( SmallIconSet ( " fileclose " ) ) ;
buttonClose - > setText ( i18n ( " &Quit " ) ) ;
QToolTip: : remove
T QToolTip: : remove
( buttonClose ) ;
QToolTip: : add
T QToolTip: : add
( buttonClose , i18n ( " Quit the application " ) ) ;
}
if ( timerProc - > isActive ( ) )
timerProc - > stop ( ) ;
delete timerProc ;
QString e = QString( p - > readStderr ( ) ) ;
QString o = QString( p - > readStdout ( ) ) ;
T QString e = T QString( p - > readStderr ( ) ) ;
T QString o = T QString( p - > readStdout ( ) ) ;
if ( ! p - > normalExit ( ) ) {
o . append ( " ::ERR::killed " ) ;
//std::cout << "Process terminated (timed out)." << std::endl; //too much output when checking for internet when it's not available.
@ -1006,7 +1006,7 @@ void WirelessAssistant::setUi(int uiState)
buttonScan - > setEnabled ( false ) ;
buttonConnect - > setEnabled ( false ) ;
buttonOptions - > setEnabled ( false ) ;
KApplication : : setOverrideCursor ( QCursor( Qt: : BusyCursor ) ) ;
KApplication : : setOverrideCursor ( T QCursor( T Qt: : BusyCursor ) ) ;
} else {
if ( devCombo - > count ( ) > 0 ) {
devCombo - > setEnabled ( true ) ;
@ -1019,14 +1019,14 @@ void WirelessAssistant::setUi(int uiState)
}
}
void WirelessAssistant : : showItemContextMenu ( QListViewItem* i , const QPoint& p , int c )
void WirelessAssistant : : showItemContextMenu ( T QListViewItem* i , const T QPoint& p , int c )
{
if ( ! i )
return ;
NetListViewItem * nvi = static_cast < NetListViewItem * > ( i ) ;
QString search = nvi - > ap ( ) ;
T QString search = nvi - > ap ( ) ;
if ( search = = " any " ) search = nvi - > essid ( ) ;
bool isConfigured = setNetParamsFromConfig ( search ) ;
@ -1034,21 +1034,21 @@ void WirelessAssistant::showItemContextMenu( QListViewItem* i, const QPoint& p,
icm - > insertTitle ( nvi - > essid ( ) ) ;
if ( isConfigured ) {
if ( nvi - > isConnected ( ) ) {
icm - > insertItem ( SmallIcon ( " connect_no " ) , i18n ( " Disconnect... " ) , this , SLOT( netDisconnect ( ) ) ) ;
//icm->insertItem( SmallIcon("reload"), i18n("Reconnect"), this, SLOT(netConnect()) );
icm - > insertItem ( SmallIcon ( " connect_no " ) , i18n ( " Disconnect... " ) , this , TQT_ SLOT( netDisconnect ( ) ) ) ;
//icm->insertItem( SmallIcon("reload"), i18n("Reconnect"), this, TQT_ SLOT(netConnect()) );
} else
icm - > insertItem ( SmallIcon ( " connect_creating " ) , i18n ( " Connect " ) , this , SLOT( netConnect ( ) ) ) ;
icm - > insertItem ( SmallIcon ( " connect_creating " ) , i18n ( " Connect " ) , this , TQT_ SLOT( netConnect ( ) ) ) ;
icm - > insertSeparator ( ) ;
icm - > insertItem ( i18n ( " Forget Settings... " ) , this , SLOT( removeNetParams ( ) ) ) ;
icm - > insertItem ( i18n ( " Edit Settings... " ) , this , SLOT( editNetParams ( ) ) ) ;
icm - > insertItem ( i18n ( " Forget Settings... " ) , this , TQT_ SLOT( removeNetParams ( ) ) ) ;
icm - > insertItem ( i18n ( " Edit Settings... " ) , this , TQT_ SLOT( editNetParams ( ) ) ) ;
} else {
if ( nvi - > isConnected ( ) ) {
icm - > insertItem ( SmallIcon ( " connect_no " ) , i18n ( " Disconnect... " ) , this , SLOT( netDisconnect ( ) ) ) ;
//icm->insertItem( SmallIcon("reload"), i18n("Configure and Reconnect..."), this, SLOT(netConnect()) );
icm - > insertItem ( SmallIcon ( " connect_no " ) , i18n ( " Disconnect... " ) , this , TQT_ SLOT( netDisconnect ( ) ) ) ;
//icm->insertItem( SmallIcon("reload"), i18n("Configure and Reconnect..."), this, TQT_ SLOT(netConnect()) );
} else
icm - > insertItem ( SmallIcon ( " connect_creating " ) , i18n ( " Configure and Connect... " ) , this , SLOT( netConnect ( ) ) ) ;
icm - > insertItem ( SmallIcon ( " connect_creating " ) , i18n ( " Configure and Connect... " ) , this , TQT_ SLOT( netConnect ( ) ) ) ;
}
icm - > exec ( QCursor: : pos ( ) ) ;
icm - > exec ( T QCursor: : pos ( ) ) ;
}
void WirelessAssistant : : editNetParams ( )
@ -1059,9 +1059,9 @@ void WirelessAssistant::editNetParams()
ui_NetParamsEdit * netedit = new ui_NetParamsEdit ( ) ;
netedit - > setValues ( NetParams ) ;
netedit - > setCaption ( i18n ( " %1 Settings " ) . arg( NetParams . essid ) ) ;
netedit - > setCaption ( i18n ( " %1 Settings " ) . tq arg( NetParams . essid ) ) ;
netedit - > exec ( ) ;
if ( netedit - > result ( ) = = QDialog: : Rejected ) {
if ( netedit - > result ( ) = = T QDialog: : Rejected ) {
delete netedit ;
return ;
} else { //accepted
@ -1081,16 +1081,16 @@ void WirelessAssistant::setNetListColumns()
bool WirelessAssistant : : dhcpClientRunning ( )
{
QStringList pidPaths ;
QString pidFile ;
T QStringList pidPaths ;
T QString pidFile ;
pidPaths < < " /etc/ " < < " /etc/dhcpc/ " < < " /var/run/ " ;
if ( Commands . dhcpClient = = " dhcpcd " )
pidFile = QString( " dhcpcd-%1.pid " ) . arg( NetParams . iface ) ;
pidFile = T QString( " dhcpcd-%1.pid " ) . tq arg( NetParams . iface ) ;
else
pidFile = QString( " dhclient.pid " ) ;
pidFile = T QString( " dhclient.pid " ) ;
for ( QStringList: : Iterator it = pidPaths . begin ( ) ; it ! = pidPaths . end ( ) ; + + it ) {
if ( QFile( QString( * it ) . append ( pidFile ) ) . exists ( ) ) {
for ( T QStringList: : Iterator it = pidPaths . begin ( ) ; it ! = pidPaths . end ( ) ; + + it ) {
if ( T QFile( T QString( * it ) . append ( pidFile ) ) . exists ( ) ) {
std : : cout < < " Running DHCP client found. " < < std : : endl ;
return true ;
}
@ -1099,13 +1099,13 @@ bool WirelessAssistant::dhcpClientRunning()
return false ;
}
QStringList WirelessAssistant : : interfaceList ( )
T QStringList WirelessAssistant : : interfaceList ( )
{
QDir d ( " /sys/class/net " ) ;
QStringList ifList = d . entryList ( QDir: : Dirs ) ;
T QDir d ( " /sys/class/net " ) ;
T QStringList ifList = d . entryList ( T QDir: : Dirs ) ;
ifList . remove ( " . " ) ; ifList . remove ( " .. " ) ; ifList . remove ( " lo " ) ;
std : : cout < < " All interfaces: " < < ifList . join ( " , " ) < < std : : endl ;
for ( QStringList: : Iterator nps = ifList . begin ( ) ; nps ! = ifList . end ( ) ; nps + + ) {
for ( T QStringList: : Iterator nps = ifList . begin ( ) ; nps ! = ifList . end ( ) ; nps + + ) {
const char * i = * nps ;
bool w = WATools : : isWireless ( i ) ;
if ( ! WATools : : isWireless ( ( const char * ) * nps ) ) {
@ -1115,18 +1115,18 @@ QStringList WirelessAssistant::interfaceList()
return ifList ;
}
QString WirelessAssistant : : getVal ( const QString & str , const QString & rxs )
T QString WirelessAssistant : : getVal ( const T QString & str , const T QString & rxs )
{
QRegExp rx ( rxs ) ;
T QRegExp rx ( rxs ) ;
rx . search ( str ) ;
return rx . cap ( 1 ) . stripWhiteSpace ( ) ;
}
bool WirelessAssistant : : generateWpaConfigFile ( const QString& essid , const QStringList& wpaSettings , const QString& wpaKey )
bool WirelessAssistant : : generateWpaConfigFile ( const T QString& essid , const T QStringList& wpaSettings , const T QString& wpaKey )
{
// 0 WPA version (1 or 2), 1 group, 2 pairwise, 3 suite
if ( wpaSettings . isEmpty ( ) ) return QString( ) ;
QString c = " ctrl_interface=/var/run/wpa_supplicant \n network={ \n scan_ssid=0 \n ssid= \" " ; //fast_reauth=1\n
if ( wpaSettings . isEmpty ( ) ) return T QString( ) ;
T QString c = " ctrl_interface=/var/run/wpa_supplicant \n network={ \n scan_ssid=0 \n ssid= \" " ; //fast_reauth=1\n
c . append ( essid ) . append ( " \" \n " ) ;
// WPA version
@ -1134,8 +1134,8 @@ bool WirelessAssistant::generateWpaConfigFile( const QString& essid, const QStri
//WPA authentication suite
c . append ( " key_mgmt= " ) ;
if ( wpaSettings [ 3 ] . contains( " PSK " ) ) c . append ( " WPA-PSK \n " ) ;
else return QString( ) ; // not supported
if ( wpaSettings [ 3 ] . tq contains( " PSK " ) ) c . append ( " WPA-PSK \n " ) ;
else return T QString( ) ; // not supported
//WPA pairwise cipher
c . append ( " pairwise= " ) ;
@ -1146,7 +1146,7 @@ bool WirelessAssistant::generateWpaConfigFile( const QString& essid, const QStri
c . append ( wpaSettings [ 1 ] ) . append ( " \n " ) ;
//WPA key
QString k = QString( ) ;
T QString k = T QString( ) ;
if ( wpaKey . left ( 2 ) = = " s: " ) { // PASSPHRASE
k . append ( " \" " ) ;
k . append ( wpaKey . right ( wpaKey . length ( ) - 2 ) ) ;
@ -1170,10 +1170,10 @@ bool WirelessAssistant::generateWpaConfigFile( const QString& essid, const QStri
// psk=your_psk_here
// }
QFile file ( wpaConfigFile ) ;
T QFile file ( wpaConfigFile ) ;
if ( file . exists ( ) ) file . remove ( ) ;
if ( file . open ( IO_WriteOnly ) ) {
QTextStream stream ( & file ) ;
T QTextStream stream ( & file ) ;
stream < < c ;
file . close ( ) ;
//std::cout << "Wrote WPA config: " << wpaConfigFile << std::endl;
@ -1182,42 +1182,42 @@ bool WirelessAssistant::generateWpaConfigFile( const QString& essid, const QStri
return 0 ;
}
bool WirelessAssistant : : setWpaClientEnabled ( bool e , const QString& iface , QString driver )
bool WirelessAssistant : : setWpaClientEnabled ( bool e , const T QString& iface , T QString driver )
{
if ( ! e ) {
if ( runCommand ( QStringList( Commands . wpa_cli ) < < QString( " -i%1 " ) . arg( NetParams . iface ) < < " terminate " ) . contains( " OK " ) ) {
QFile( wpaConfigFile ) . remove ( ) ;
if ( runCommand ( T QStringList( Commands . wpa_cli ) < < T QString( " -i%1 " ) . tq arg( NetParams . iface ) < < " terminate " ) . tq contains( " OK " ) ) {
T QFile( wpaConfigFile ) . remove ( ) ;
return 1 ;
} else
return 0 ; // wpa client was not running.
}
if ( ! runCommand ( QStringList( Commands . wpa_cli ) < < QString( " -i%1 " ) . arg( NetParams . iface ) < < " status " ) . contains( " Failed to connect " ) ) {
if ( ! runCommand ( T QStringList( Commands . wpa_cli ) < < T QString( " -i%1 " ) . tq arg( NetParams . iface ) < < " status " ) . tq contains( " Failed to connect " ) ) {
std : : cout < < " WPA client already running. Reconfiguring... " < < std : : endl ;
runCommand ( QStringList( Commands . wpa_cli ) < < " reconfigure " ) ;
runCommand ( T QStringList( Commands . wpa_cli ) < < " reconfigure " ) ;
} else {
if ( driver . isEmpty ( ) ) { //detect needed driver
QString k = WATools : : kernelModule ( iface ) ;
if ( k . contains( " hermes " ) ) driver = " hermes " ;
else if ( k . contains( " atmel " ) ) driver = " atmel " ;
T QString k = WATools : : kernelModule ( iface ) ;
if ( k . tq contains( " hermes " ) ) driver = " hermes " ;
else if ( k . tq contains( " atmel " ) ) driver = " atmel " ;
# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 13)
else if ( k . contains( " ipw " ) ) driver = " ipw " ; //wext should be used for kernels newer than 2.6.12
else if ( k . tq contains( " ipw " ) ) driver = " ipw " ; //wext should be used for kernels newer than 2.6.12
# endif
//Commented out, because ndiswrapper newer than 1.13 works with wext driver.
//else if ( k. contains("ndiswrapper") ) driver = "ndiswrapper";
//else if ( k. tq contains("ndiswrapper") ) driver = "ndiswrapper";
//Commented out, because madwifi-ng works with wext driver.
//else if ( k. contains("ath") ) driver = "madwifi";
//else if ( k. tq contains("ath") ) driver = "madwifi";
else driver = " wext " ;
std : : cout < < " Using wpa_supplicant driver: " < < driver < < std : : endl ;
}
QProcess* wp = new QProcess( this ) ;
T QProcess* wp = new T QProcess( TQT_TQOBJECT ( this ) ) ;
wp - > clearArguments ( ) ;
wp - > addArgument ( Commands . wpa_supplicant ) ;
wp - > addArgument ( " -W " ) ; //wait for control interface
wp - > addArgument ( QString( " -D%1 " ) . arg( driver ) ) ;
wp - > addArgument ( QString( " -i%1 " ) . arg( iface ) ) ;
wp - > addArgument ( QString( " -c%1 " ) . arg( wpaConfigFile ) ) ;
wp - > addArgument ( T QString( " -D%1 " ) . tq arg( driver ) ) ;
wp - > addArgument ( T QString( " -i%1 " ) . tq arg( iface ) ) ;
wp - > addArgument ( T QString( " -c%1 " ) . tq arg( wpaConfigFile ) ) ;
//std::cout << "Starting WPA client: " << wp->arguments().join(" ") << std::endl;
if ( ! wp - > start ( ) ) {
std : : cout < < " Failed to start WPA client. " < < std : : endl ;
@ -1229,19 +1229,19 @@ bool WirelessAssistant::setWpaClientEnabled( bool e, const QString& iface, QStri
usleep ( 200 * 1000 ) ; //200msec for wpa_supplicant to initiate
QString o ;
T QString o ;
int i = 0 ;
while ( ! ( o = runCommand ( QStringList( Commands . wpa_cli ) < < QString( " -i%1 " ) . arg( NetParams . iface ) < < " status " ) ) . contains( " Failed to connect " ) ) {
while ( ! ( o = runCommand ( T QStringList( Commands . wpa_cli ) < < T QString( " -i%1 " ) . tq arg( NetParams . iface ) < < " status " ) ) . tq contains( " Failed to connect " ) ) {
for ( int c = 0 ; c < 15 ; c + + ) {
usleep ( 75 * 1000 ) ; //75msec
KApplication : : eventLoop ( ) - > processEvents ( QEventLoop: : AllEvents ) ;
KApplication : : eventLoop ( ) - > processEvents ( T QEventLoop: : AllEvents ) ;
i + + ;
}
if ( i > 400 ) { //more than 30sec have passed
runCommand ( QStringList( Commands . wpa_cli ) < < QString( " -i%1 " ) . arg( NetParams . iface ) < < " terminate " ) ;
runCommand ( T QStringList( Commands . wpa_cli ) < < T QString( " -i%1 " ) . tq arg( NetParams . iface ) < < " terminate " ) ;
return 0 ;
}
if ( o . contains( " wpa_state=COMPLETED " ) ) {
if ( o . tq contains( " wpa_state=COMPLETED " ) ) {
std : : cout < < " WPA Authorisation successful. " < < std : : endl ;
return 1 ;
}
@ -1257,7 +1257,7 @@ bool WirelessAssistant::close()
std : : cout < < " Application options saved. " < < std : : endl ;
WATools : : cleanup ( ) ;
std : : cout < < " Kernel socket closed. " < < std : : endl ;
return QWidget: : close ( ) ;
return T QWidget: : close ( ) ;
}