15 files changed, 40 insertions, 34 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/config.in b/noncore/settings/networksettings2/bluetooth/config.in index e5155e8..b1a5a58 100644 --- a/noncore/settings/networksettings2/bluetooth/config.in +++ b/noncore/settings/networksettings2/bluetooth/config.in @@ -1,4 +1,4 @@ config NS2BT boolean "opie-networksettings2plugin-bluetooth (set up BLUETOOTH)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/cable/config.in b/noncore/settings/networksettings2/cable/config.in index 1cdcaa1..9007f14 100644 --- a/noncore/settings/networksettings2/cable/config.in +++ b/noncore/settings/networksettings2/cable/config.in @@ -1,4 +1,4 @@ config NS2CABLE boolean "opie-networksettings2plugin-cable (set up Cable)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/config.in b/noncore/settings/networksettings2/config.in index 1004ce4..ac38c2f 100644 --- a/noncore/settings/networksettings2/config.in +++ b/noncore/settings/networksettings2/config.in @@ -1,22 +1,23 @@ + source noncore/settings/networksettings2/networksettings2/config.in + config NS2 - boolean "opie-networksettings-2 (TCP/IP network settings)" - default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE + boolean + default "y" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN config NS2CORE boolean default "y" if NS2 depends ( LIBQPE || LIBQPE-X11 ) && NS2 source noncore/settings/networksettings2/profile/config.in source noncore/settings/networksettings2/network/config.in source noncore/settings/networksettings2/lancard/config.in source noncore/settings/networksettings2/ppp/config.in source noncore/settings/networksettings2/wlan/config.in source noncore/settings/networksettings2/usb/config.in source noncore/settings/networksettings2/irda/config.in source noncore/settings/networksettings2/vpn/config.in source noncore/settings/networksettings2/bluetooth/config.in source noncore/settings/networksettings2/cable/config.in source noncore/settings/networksettings2/modem/config.in - source noncore/settings/networksettings2/networksettings2/config.in diff --git a/noncore/settings/networksettings2/irda/config.in b/noncore/settings/networksettings2/irda/config.in index dd86b61..0da9a25 100644 --- a/noncore/settings/networksettings2/irda/config.in +++ b/noncore/settings/networksettings2/irda/config.in @@ -1,4 +1,4 @@ config NS2IRDA boolean "opie-networksettings2plugin-irda (set up IRDA)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/lancard/config.in b/noncore/settings/networksettings2/lancard/config.in index 71fb83e..c694908 100644 --- a/noncore/settings/networksettings2/lancard/config.in +++ b/noncore/settings/networksettings2/lancard/config.in @@ -1,4 +1,4 @@ config NS2LANCARD boolean "opie-networksettings2plugin-lancard (regular wired lan card)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp index b32b323..200e31b 100644 --- a/noncore/settings/networksettings2/main.cpp +++ b/noncore/settings/networksettings2/main.cpp @@ -1,146 +1,147 @@ #include "nsdata.h" #include "activateprofile.h" #include "activatevpn.h" #include "networksettings.h" #include <qpe/qpeapplication.h> #include <opie2/oapplicationfactory.h> using namespace Opie::Core; #ifdef GONE OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) #else // just standard GUI #define ACT_GUI 0 // used by interfaces to request for allow of up/down #define ACT_REQUEST 1 // regenerate config files #define ACT_REGEN 2 // used by interfaces to request user prompt #define ACT_PROMPT 3 // used by interfaces to trigger VPN #define ACT_VPN 4 int main( int argc, char * argv[] ) { int rv = 0; int Action = ACT_GUI; // could be overruled by -qws QApplication::Type GuiType = QApplication::GuiClient; #ifdef _WS_QWS_ QPEApplication * TheApp; #else QApplication * TheApp; #endif for ( int i = 1; i < argc; i ++ ) { int rmv; rmv = 0; if( strcmp( argv[i], "--regen" ) == 0 ) { Action = ACT_REGEN; GuiType = QApplication::Tty; rmv = 1; } else if( strcmp( argv[i], "--prompt" ) == 0 ) { Action = ACT_PROMPT; rmv = 1; } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { Action = ACT_VPN; rmv = 1; } if( rmv ) { memmove( argv+i, argv+i+rmv, sizeof( char * ) * (argc-i-rmv) ); i --; argc -= rmv; } } if( strstr( argv[0], "-request" ) ) { // called from system to request something GuiType = QApplication::Tty; Action = ACT_REQUEST; + Log(("Request : %s\n", argv[1] )); } // Start Qt #ifdef _WS_QWS_ // because QPEApplication does not handle GuiType well if( GuiType == QApplication::Tty ) { // this cast is NOT correct but we do not use // TheApp anymore ... TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType ); } else { TheApp = new QPEApplication( argc, argv, GuiType ); } #else TheApp = new QApplication( argc, argv, GuiType ); #endif // init qt with app widget switch( Action ) { case ACT_REQUEST : { NetworkSettingsData NS; if( NS.canStart( argv[1] ) ) { QString S; S.sprintf( QPEApplication::qpeDir()+ "/bin/networksettings2" ); char * MyArgv[4]; MyArgv[0] = "networksettings2"; MyArgv[1] = "--prompt"; MyArgv[2] = argv[1]; MyArgv[3] = NULL; NSResources->system().execAsUser( S, MyArgv ); // if we come here , failed printf( "%s-cNN-disallowed", argv[1] ); } } break; case ACT_REGEN : { NetworkSettingsData NS; // regen returns 0 if OK rv = (NS.regenerate()) ? 1 : 0; } break; case ACT_PROMPT : { ActivateProfile AP(argv[1]); if( AP.exec() == QDialog::Accepted ) { printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); } else { printf( "%s-cNN-disallowed", argv[1] ); } } break; case ACT_VPN : { ActivateVPN AVPN; AVPN.exec(); } break; case ACT_GUI : { QWidget * W = new NetworkSettings(0); TheApp->setMainWidget( W ); W->show(); #ifdef _WS_QWS_ W->showMaximized(); #else W->resize( W->sizeHint() ); #endif rv = TheApp->exec(); delete W; } break; } LogClose(); return rv; } #endif // main.cpp diff --git a/noncore/settings/networksettings2/modem/config.in b/noncore/settings/networksettings2/modem/config.in index 1a36636..a354da0 100644 --- a/noncore/settings/networksettings2/modem/config.in +++ b/noncore/settings/networksettings2/modem/config.in @@ -1,4 +1,4 @@ config NS2MODEM boolean "opie-networksettings2plugin-modem (set up DIALUP)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/network/config.in b/noncore/settings/networksettings2/network/config.in index 4c37974..725b7f0 100644 --- a/noncore/settings/networksettings2/network/config.in +++ b/noncore/settings/networksettings2/network/config.in @@ -1,4 +1,4 @@ config NS2NETWORK boolean "opie-networksettings2plugin-ipsetup (set up TCP/IP)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/networksettings2/config.in b/noncore/settings/networksettings2/networksettings2/config.in index 907f1a0..2b4e2f3 100644 --- a/noncore/settings/networksettings2/networksettings2/config.in +++ b/noncore/settings/networksettings2/networksettings2/config.in @@ -1,4 +1,4 @@ config NS2MAIN - boolean - default "y" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 + boolean "opie-networksettings2 (TCP/IP network settings)" + default "y" + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE diff --git a/noncore/settings/networksettings2/networksettings2/wextensions.cpp b/noncore/settings/networksettings2/networksettings2/wextensions.cpp index 778990c..c10bdc3 100644 --- a/noncore/settings/networksettings2/networksettings2/wextensions.cpp +++ b/noncore/settings/networksettings2/networksettings2/wextensions.cpp @@ -1,165 +1,169 @@ #include "wextensions.h" #include <qfile.h> #include <qtextstream.h> #include <arpa/inet.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <opie2/odebug.h> using namespace Opie::Core; #include <math.h> #define PROCNETWIRELESS "/proc/net/wireless" #define IW_LOWER 0 #define IW_UPPER 256 /** * Constructor. Sets hasWirelessExtensions */ WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) { fd = socket( AF_INET, SOCK_DGRAM, 0 ); if(fd == -1) return; const char* buffer[200]; memset( &iwr, 0, sizeof( iwr ) ); iwr.u.essid.pointer = (caddr_t) buffer; iwr.u.essid.length = IW_ESSID_MAX_SIZE; iwr.u.essid.flags = 0; // check if it is an IEEE 802.11 standard conform // wireless device by sending SIOCGIWESSID // which also gives back the Extended Service Set ID // (see IEEE 802.11 for more information) const char* iname = interface.latin1(); strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) hasWirelessExtensions = true; } /** * @return QString the station name of the access point. */ QString WExtensions::station(){ if(!hasWirelessExtensions) return QString(); const char* buffer[200]; iwr.u.data.pointer = (caddr_t) buffer; iwr.u.data.length = IW_ESSID_MAX_SIZE; iwr.u.data.flags = 0; if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ - iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; - return QString(iwr.u.data.pointer); + buffer[(unsigned int) iwr.u.data.length-1] = '\0'; + return (const char *)buffer; } - return QString(); + return QString::null; } /** * @return QString the essid of the host 802.11 access point. */ QString WExtensions::essid(){ if(!hasWirelessExtensions) return QString(); + const char* buffer[200]; + iwr.u.data.pointer = (caddr_t) buffer; + iwr.u.data.length = IW_ESSID_MAX_SIZE; + iwr.u.data.flags = 0; if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ - iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length] = '\0'; - return QString(iwr.u.essid.pointer); + buffer[(unsigned int) iwr.u.essid.length] = '\0'; + return (const char *)buffer; } return QString(); } /** * @return QString the mode of interface */ QString WExtensions::mode(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); return QString(); } /** * Get the frequency that the interface is running at. * @return int the frequency that the interfacae is running at. */ double WExtensions::frequency(){ if(!hasWirelessExtensions) return 0; if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); return 0; } /** * Get the channel that the interface is running at. * @return int the channel that the interfacae is running at. */ int WExtensions::channel(){ if(!hasWirelessExtensions) return 0; if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) return 0; // http://www.elanix.com/pdf/an137e.pdf double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); double left = 2.401; double right = 2.416; for(int channel = 1; channel<= 15; channel++){ if( num >= left && num <= right ) return channel; left += 0.005; right += 0.005; } odebug << QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1() << oendl; return -1; } /*** * Get the current rate that the card is transmiting at. * @return double the rate, 0 if error. */ double WExtensions::rate(){ if(!hasWirelessExtensions) return 0; if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ return ((double)iwr.u.bitrate.value)/1000000; } return 0; } /** * @return QString the AccessPoint that the interface is connected to. */ QString WExtensions::ap(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ QString ap; ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", iwr.u.ap_addr.sa_data[0]&0xff, iwr.u.ap_addr.sa_data[1]&0xff, iwr.u.ap_addr.sa_data[2]&0xff, iwr.u.ap_addr.sa_data[3]&0xff, iwr.u.ap_addr.sa_data[4]&0xff, iwr.u.ap_addr.sa_data[5]&0xff ); return ap; } else return QString(); } /** * Get the stats for interfaces * @param signal the signal strength of interface * @param noise the noise level of the interface * @param quality the quality level of the interface * @return bool true if successful */ bool WExtensions::stats(int &signal, int &noise, int &quality){ // gather link quality from /proc/net/wireless if(!QFile::exists(PROCNETWIRELESS)) diff --git a/noncore/settings/networksettings2/ppp/config.in b/noncore/settings/networksettings2/ppp/config.in index 9e3cd35..c722a10 100644 --- a/noncore/settings/networksettings2/ppp/config.in +++ b/noncore/settings/networksettings2/ppp/config.in @@ -1,4 +1,4 @@ config NS2PPP boolean "opie-networksettings2plugin-ppp (set up PPP)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/profile/config.in b/noncore/settings/networksettings2/profile/config.in index c5f2075..f99ef99 100644 --- a/noncore/settings/networksettings2/profile/config.in +++ b/noncore/settings/networksettings2/profile/config.in @@ -1,4 +1,4 @@ config NS2PROFILE boolean "opie-networksettings2plugin-profiles (User profiles)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/usb/config.in b/noncore/settings/networksettings2/usb/config.in index 136806d..d0c6cba 100644 --- a/noncore/settings/networksettings2/usb/config.in +++ b/noncore/settings/networksettings2/usb/config.in @@ -1,4 +1,4 @@ config NS2USB boolean "opie-networksettings2plugin-usb (set up USB)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/vpn/config.in b/noncore/settings/networksettings2/vpn/config.in index fff52c3..0d2cb3a 100644 --- a/noncore/settings/networksettings2/vpn/config.in +++ b/noncore/settings/networksettings2/vpn/config.in @@ -1,4 +1,4 @@ config NS2VPN boolean "opie-networksettings2plugin-vpn (set up VPN)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE diff --git a/noncore/settings/networksettings2/wlan/config.in b/noncore/settings/networksettings2/wlan/config.in index 328287b..13ef9da 100644 --- a/noncore/settings/networksettings2/wlan/config.in +++ b/noncore/settings/networksettings2/wlan/config.in @@ -1,4 +1,4 @@ config NS2WLAN boolean "opie-networksettings2plugin-wlan (set up Wireless LAN)" - default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2 && NS2CORE + default "n" if NS2MAIN + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2MAIN && NS2CORE |