author | wimpie <wimpie> | 2005-01-12 00:09:13 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-12 00:09:13 (UTC) |
commit | 4b1d4fc9f4170ec22d196dd352cae5d9c1ecb232 (patch) (side-by-side diff) | |
tree | 90d4ac2f37ec43f69008b3cba67ff018e3af3ee1 | |
parent | b0afa096730ac7893fcd25873f6fd09fcef32a95 (diff) | |
download | opie-4b1d4fc9f4170ec22d196dd352cae5d9c1ecb232.zip opie-4b1d4fc9f4170ec22d196dd352cae5d9c1ecb232.tar.gz opie-4b1d4fc9f4170ec22d196dd352cae5d9c1ecb232.tar.bz2 |
GUI changes to profileedit
6 files changed, 335 insertions, 325 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index 2dd91f8..4d46778 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp @@ -1,344 +1,344 @@ #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <pwd.h> #include <qpixmap.h> #include <qdir.h> #include <qmessagebox.h> #include <qpe/qlibrary.h> #include <qpe/qpeapplication.h> #include <opie2/odebug.h> #include <opie2/opluginloader.h> #include <qtopia/resource.h> #include "netnode.h" #include "resources.h" #include "netnodeinterface.h" #define PLUGINDIR "plugins/networksettings2" #define ICONDIR "/pics/networksettings2/" // single resources instance TheNSResources * _NSResources = 0; TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), NetworkSetupsMap(), DanglingNetworkSetupsMap() { _NSResources = this; detectCurrentUser(); // load available netnodes Plugins = 0; findAvailableNetNodes(); // compile provides and needs lists { const char ** NeedsRun; QDictIterator<ANetNode> OuterIt( AllNodeTypes ); bool Done; for ( ; OuterIt.current(); ++OuterIt ) { // find needs list ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList; ANetNode::NetNodeList & NNL = *(NNLP); // must iterate this way to avoid duplication pointers for ( QDictIterator<ANetNode> InnerIt( AllNodeTypes ); InnerIt.current(); ++InnerIt ) { if( InnerIt.current() == OuterIt.current() ) // avoid recursive continue; const char ** Provides = InnerIt.current()->provides(); NeedsRun = OuterIt.current()->needs(); for( ; *NeedsRun; NeedsRun ++ ) { const char ** PRun; PRun = Provides; for( ; *PRun; PRun ++ ) { if( strcmp( *PRun, *NeedsRun ) == 0 ) { // inner provides what outer needs NNL.resize( NNL.size() + 1 ); NNL[NNL.size()-1] = InnerIt.current(); Done = 1; // break from 2 loops break; } } } } OuterIt.current()->setAlternatives( NNLP ); } } // define built in Node types to Description map addNodeType( "device", tr( "Network Device" ), tr( "<p>Devices that can handle IP packets</p>" ) ); addNodeType( "line", tr( "Character device" ), tr( "<p>Devices that can handle single bytes</p>" ) ); - addNodeType( "NetworkSetup", tr( "IP NetworkSetup" ), - tr( "<p>Nodes that provide working IP NetworkSetups</p>" ) ); - addNodeType( "fullsetup", tr( "NetworkSetup Profile" ), - tr( "<p>Fully configured NetworkSetup profile</p>" ) ); - addNodeType( "GPRS", tr( "NetworkSetup to GPRS device" ), - tr( "<p>NetworkSetup to a GPRS capable device</p>" ) ); + addNodeType( "connection", tr( "IP Connection" ), + tr( "<p>Nodes that provide working IP connection</p>" ) ); + addNodeType( "fullsetup", tr( "Connection Profile" ), + tr( "<p>Fully configured network profile</p>" ) ); + addNodeType( "GPRS", tr( "Connection to GPRS device" ), + tr( "<p>Connection to a GPRS capable device</p>" ) ); // get access to the system TheSystem = new System(); } TheNSResources::~TheNSResources( void ) { if( Plugins ) { delete Plugins; delete PluginManager; } delete TheSystem; } void TheNSResources::addNodeType( const QString & ID, const QString & Name, const QString & Descr ) { if( NodeTypeNameMap[ID].isEmpty() ) { NodeTypeNameMap.insert( ID, Name ); NodeTypeDescriptionMap.insert( ID, Descr ); } } void TheNSResources::addSystemFile( const QString & ID, const QString & P, bool KDI ) { if( ! SystemFiles.find( ID ) ) { // new system file SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) ); } // else existed } void TheNSResources::busy( bool ) { /* if( B ) { ShowWait->show(); qApp->process } else { ShowWait->hide(); } */ } void TheNSResources::findAvailableNetNodes( void ){ Plugins = new OPluginLoader( "networksettings2" ); Plugins->setAutoDelete( true ); PluginManager = new OPluginManager( Plugins ); PluginManager->load(); if( Plugins->isInSafeMode() ) { QMessageBox::information( 0, tr( "Today Error"), tr( "<qt>The plugin '%1' caused Today to crash." " It could be that the plugin is not properly" " installed.<br>Today tries to continue loading" " plugins.</qt>" ) .arg( PluginManager->crashedPlugin().name())); } // Get All Plugins OPluginLoader::List allplugins = Plugins->filtered(); QString lang = ::getenv("LANG"); for( OPluginLoader::List::Iterator it = allplugins.begin(); it != allplugins.end(); ++it ) { // check if this plugin supports the proper interface NetNodeInterface * interface = Plugins->load<NetNodeInterface>( *it, IID_NetworkSettings2 ); if( ! interface ) { Log(( "Plugin %s from %s does not support proper interface\n", (*it).name().latin1(), (*it).path().latin1() )); continue; } // add the nodes in this plugin to the dictionary { QList<ANetNode> PNN; interface->create_plugin( PNN ); if( PNN.isEmpty() ) { Log(( "Plugin %s from %s does offer any nodes\n", (*it).name().latin1(), (*it).path().latin1() )); delete interface; continue; } // merge this node with global node for( QListIterator<ANetNode> nnit(PNN); nnit.current(); ++nnit ) { Log(( "Found node type %s in plugin %s\n", nnit.current()->name(), (*it).name().latin1() )); AllNodeTypes.insert( nnit.current()->name(), nnit.current() ); } } // load the translation QTranslator *trans = new QTranslator(qApp); QString fn = QPEApplication::qpeDir()+ "/i18n/"+lang+"/"+ (*it).name() + ".qm"; if( trans->load( fn ) ) qApp->installTranslator( trans ); else delete trans; } } // used to find unique NetworkSetup number int TheNSResources::assignNetworkSetupNumber( void ) { bool found = 1; for( int trial = 0; ; trial ++ ) { found = 1; for( QDictIterator<NetworkSetup> it(NetworkSetupsMap); it.current(); ++it ) { if( it.current()->number() == trial ) { found = 0; break; } } if( found ) { Log(("Assign profile number %d\n", trial )); return trial; } } } QPixmap TheNSResources::getPixmap( const QString & QS ) { QPixmap P; QString S("networksettings2/"); S += QS; P = Resource::loadPixmap( S ); if( P.isNull() ) { Log(( "Cannot load %s\n", S.latin1() )); } return ( P.isNull() ) ? QPixmap() : P; } QString TheNSResources::tr( const char * s ) { return qApp->translate( "resource", s ); } const QString & TheNSResources::netNode2Name( const char * s ) { return NodeTypeNameMap[s]; } const QString & TheNSResources::netNode2Description( const char * s ) { return NodeTypeDescriptionMap[s]; } void TheNSResources::addNetworkSetup( NetworkSetup * NC, bool Dangling ) { ANetNodeInstance * NNI; Log(( "Add NetworkSetup %s, Dangling %d\n", NC->name().latin1(), Dangling )); if( Dangling ) { DanglingNetworkSetupsMap.insert( NC->name(), NC ); } else { NetworkSetupsMap.insert( NC->name(), NC ); } // add (new) nodes to NodeList for( QListIterator<ANetNodeInstance> it(*NC); it.current(); ++it ) { NNI = it.current(); if( findNodeInstance( NNI->name() ) == 0 ) { // new item addNodeInstance( NNI ); } } } void TheNSResources::removeNetworkSetup( const QString & N ) { NetworkSetup * NC = findNetworkSetup( N ); if( ! NC ) return; // delete netnodes in this NetworkSetup ANetNodeInstance * NNI; for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) { removeNodeInstance( NNI->name() ); } if( NetworkSetupsMap.find( N ) ) { NetworkSetupsMap.remove( N ); } else { DanglingNetworkSetupsMap.remove( N ); } } // dangling NetworkSetups are filtered out NetworkSetup * TheNSResources::findNetworkSetup( const QString & S ) { return NetworkSetupsMap[ S ]; } NetworkSetup * TheNSResources::getNetworkSetup( int nr ) { for( QDictIterator<NetworkSetup> it(NetworkSetupsMap); it.current(); ++it ) { if( it.current()->number() == nr ) { return it.current(); } } return 0; } /* void TheNSResources::renumberNetworkSetups( void ) { Name2NetworkSetup_t & M = NSResources->NetworkSetups(); NetworkSetup * NC; // for all NetworkSetups NetworkSetup::resetMaxNr(); for( QDictIterator<NetworkSetup> it(M); it.current(); ++it ) { NC = it.current(); NC->setNumber( NC->maxNetworkSetupNumber()+1 ); NC->setModified( 1 ); } } */ typedef struct EnvVars { char * Name; int Len; } EnvVar_t; #define AnEV(x) x, sizeof(x)-1 static EnvVar_t EV[] = { AnEV( "HOME" ), AnEV( "LOGNAME" ), AnEV( "USER" ), AnEV( "LD_LIBRARY_PATH" ), AnEV( "PATH" ), AnEV( "QTDIR" ), AnEV( "OPIEDIR" ), AnEV( "SHELL" ), { NULL, 0 } }; void TheNSResources::detectCurrentUser( void ) { // find current running qpe QString QPEEnvFile = ""; diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp index 33cc5bd..82f5c43 100644 --- a/noncore/settings/networksettings2/networksettings2/system.cpp +++ b/noncore/settings/networksettings2/networksettings2/system.cpp @@ -1,506 +1,518 @@ #include <sys/types.h> #include <sys/wait.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <errno.h> #include <unistd.h> #include <opie2/oprocess.h> #include <qdir.h> #include <qregexp.h> #include <qstringlist.h> #include <qfile.h> #include <qtextstream.h> #include <qapplication.h> #include "resources.h" #include "system.h" #define PROCNETDEV "/proc/net/dev" #ifndef ARPHRD_IEEE80211 #define ARPHRD_IEEE80211 801 #endif static char Dig2Hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; // get HIGH nibble of byte #define HN(x) Dig2Hex[(((x)&0xf0)>>4)] // get LOW nibble of byte #define LN(x) Dig2Hex[((x)&0x0f)] System::System( void ) : QObject(), ProbedInterfaces() { ProcDevNet = 0; } System::~System( void ) { if( ProcDevNet ) delete ProcDevNet; } QDict<InterfaceInfo> & System::interfaces( void ) { if( ProbedInterfaces.count() == 0 ) { probeInterfaces(); } return ProbedInterfaces; } int System::runAsRoot( QStringList & S, MyProcess * Prc ) { char * usr = getenv("USER"); if( S.count() == 0 ) { // close loophole to start shell return 8888; } if( usr == 0 || strcmp( usr, "root" ) ) { // unknown or non-root user -> use SUDO S.prepend( "sudo" ); } if( getenv( "NS2TESTMODE" ) ) { odebug << "TESTMODE !!! execute " << S.join( " ") << oendl; } else { MyProcess * P; if( Prc ) { P = Prc; } else { P = new MyProcess(); emit processEvent( tr("Command : ") + S.join( " " ) ); connect( P, SIGNAL( stdoutLine( const QString & ) ), this, SIGNAL( stdoutLine( const QString & ) ) ); connect( P, SIGNAL( stderrLine( const QString & ) ), this, SIGNAL( stderrLine( const QString & ) ) ); connect( P, SIGNAL(processExited(MyProcess*) ), this, SLOT (SLOT_ProcessExited(MyProcess*) ) ); } P->process() << S; Log(("Executing %s\n", S.join( " " ).latin1() )); if( ! P->process().start( OProcess::DontCare, OProcess::AllOutput ) ) { odebug << "Error starting " << S << oendl; if( ! Prc ) delete P; // error starting app return 0; } odebug << "Started " << S << oendl; } // all is fine return 1; } int System::execAsUser( QStringList & SL, bool Synchronous ) { MyProcess * P = new MyProcess(); CurrentQPEUser CU = NSResources->currentUser(); char * usr = getenv("USER"); if( usr == 0 || strcmp( usr, "root" ) == 0 ) { // find user running qpe if( CU.UserName.isEmpty() ) { // if we come here, the exec was not successfull Log(("User not known \n" )); return 0; } } // now we are ready to exec the requested command setuid( CU.Uid ); setgid( CU.Gid ); for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) { QString X; QStringList SL; X = CU.EnvList[i]; SL = QStringList::split( "=", X ); P->process().setEnvironment( SL[0], SL[1] ); } P->process() << SL; emit processEvent( tr("Command : ") + SL.join( " " ) ); Log(("Executing as user %s : %s\n", CU.UserName.latin1(), SL.join( " " ).latin1() )); P->setEchoMode( Synchronous ); bool rv = P->process().start( (Synchronous) ? OProcess::Block : OProcess::DontCare, (Synchronous) ? OProcess::AllOutput : OProcess::NoCommunication ); delete P; if( ! rv ) { // if we come here, the exec was not successfull Log(("Could not exec : %d\n", errno )); } return rv; } void System::SLOT_ProcessExited( MyProcess * P ) { QString R; for( QValueListConstIterator<QCString> it = P->process().args().begin(); it != P->process().args().end(); ++it ) { R += (*it); R += " "; } R += "Returned with " + QString().setNum( P->process().exitStatus() ); emit processEvent( R ); delete P; } void System::refreshStatistics( InterfaceInfo & I ) { if( ! ProcDevNet ) { return; } // cannot seek on dev ProcDevNet->close(); ProcDevNet->open( IO_ReadOnly ); QString line; QTextStream procTs(ProcDevNet); QStringList SL; int loc = -1; int version; procTs.readLine(); line = procTs.readLine(); // get version if( line.find("compressed") ) version = 3; else if( line.find( "bytes" ) ) version = 2; else version = 1; while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { if( (loc = line.find(":") ) == -1) { continue; } if( I.Name != line.left(loc) ) continue; // tokenize - SL = QStringList::split( ' ', line, FALSE ); + SL = QStringList::split( ' ', line.mid(loc+1), FALSE ); // update data switch( version ) { case 1 : - I.RcvBytes = SL[1]; - I.RcvErrors = SL[3]; - I.RcvDropped = SL[4]; + I.RcvBytes = ""; + I.RcvPackets = SL[0]; + I.RcvErrors = SL[1]; + I.RcvDropped = SL[2]; + + I.SndBytes = ""; + I.SndPackets = SL[5]; + I.SndErrors = SL[6]; + I.SndDropped = SL[7]; + + I.Collisions = SL[9]; + break; + case 2 : + I.RcvBytes = SL[0]; + I.RcvPackets = SL[1]; + I.RcvErrors = SL[2]; + I.RcvDropped = SL[3]; + I.SndBytes = SL[6]; + I.SndPackets = SL[7]; I.SndErrors = SL[8]; I.SndDropped = SL[9]; + I.Collisions = SL[11]; break; - case 2 : - I.RcvBytes = SL[1]; - I.RcvErrors = SL[3]; - I.RcvDropped = SL[4]; - I.SndBytes = SL[7]; - I.SndErrors = SL[9]; - I.SndDropped = SL[10]; - I.Collisions = SL[12]; - break; case 3 : - I.RcvBytes = SL[1]; - I.RcvErrors = SL[3]; - I.RcvDropped = SL[4]; - I.SndBytes = SL[9]; - I.SndErrors = SL[11]; - I.SndDropped = SL[12]; - I.Collisions = SL[14]; + I.RcvBytes = SL[0]; + I.RcvPackets = SL[1]; + I.RcvErrors = SL[2]; + I.RcvDropped = SL[3]; + + I.SndBytes = SL[8]; + I.SndPackets = SL[9]; + I.SndErrors = SL[10]; + I.SndDropped = SL[11]; + + I.Collisions = SL[13]; break; } break; } } // // THIS UPDATES THE LIST -> INTERFACES ARE NOT DELETED BUT // FLAGGED AS ! 'IsUp' IF NO LONGER PRESENT // void System::probeInterfaces( void ) { // probe interfaces int sockfd; // get list of all interfaces struct ifreq ifrs; InterfaceInfo * IFI; // flag all as 'down' for( QDictIterator<InterfaceInfo> it( ProbedInterfaces ); it.current(); ++it ) { it.current()->IsUp = 0; } sockfd = socket(PF_INET, SOCK_DGRAM, 0); if(sockfd == -1) { odebug << "Cannot open INET socket " << errno << " " << strerror( errno ) << oendl; return; } // read interfaces from /proc/dev/net // SIOCGIFCONF does not return ALL interfaces ???!? ProcDevNet = new QFile(PROCNETDEV); if( ! ProcDevNet->open(IO_ReadOnly) ) { odebug << "Cannot open " << PROCNETDEV << " " << errno << " " << strerror( errno ) << oendl; delete ProcDevNet; ProcDevNet =0; ::close( sockfd ); return; } QString line; QString NicName; QTextStream procTs(ProcDevNet); int loc = -1; procTs.readLine(); // eat a line procTs.readLine(); // eat a line while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { if((loc = line.find(":")) == -1) { continue; } NicName = line.left(loc); // set name for ioctl strcpy( ifrs.ifr_name, NicName.latin1() ); if ( ! ( IFI = ProbedInterfaces.find( NicName ) ) ) { // new nic Log(("New NIC found : %s\n", NicName.latin1())); IFI = new InterfaceInfo; IFI->Name = line.left(loc); IFI->Collection = 0; ProbedInterfaces.insert( IFI->Name, IFI ); // get dynamic info if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { IFI->IsPointToPoint = ((ifrs.ifr_flags & IFF_POINTOPOINT) == IFF_POINTOPOINT); } else { IFI->IsPointToPoint = 0; } // settings that never change IFI->DstAddress = ""; if( IFI->IsPointToPoint ) { if( ioctl(sockfd, SIOCGIFDSTADDR, &ifrs) >= 0 ) { IFI->DstAddress = inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_dstaddr)->sin_addr); } } IFI->CardType = 999999; IFI->MACAddress = ""; if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) { Log(("Family for NIC %s : %d\n", IFI->Name.latin1(), ifrs.ifr_hwaddr.sa_family )); IFI->CardType = ifrs.ifr_hwaddr.sa_family; switch( ifrs.ifr_hwaddr.sa_family ) { case ARPHRD_ETHER : // regular MAC address // valid address -> convert to regular ::: format // length = 6 bytes = 12 DIGITS -> 6 : IFI->MACAddress.sprintf( "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c", HN( ifrs.ifr_hwaddr.sa_data[0] ), LN( ifrs.ifr_hwaddr.sa_data[0] ), HN( ifrs.ifr_hwaddr.sa_data[1] ), LN( ifrs.ifr_hwaddr.sa_data[1] ), HN( ifrs.ifr_hwaddr.sa_data[2] ), LN( ifrs.ifr_hwaddr.sa_data[2] ), HN( ifrs.ifr_hwaddr.sa_data[3] ), LN( ifrs.ifr_hwaddr.sa_data[3] ), HN( ifrs.ifr_hwaddr.sa_data[4] ), LN( ifrs.ifr_hwaddr.sa_data[4] ), HN( ifrs.ifr_hwaddr.sa_data[5] ), LN( ifrs.ifr_hwaddr.sa_data[5] ) ); break; #ifdef ARPHRD_IEEE1394 case ARPHRD_IEEE1394 : // Firewire Eth address IFI->MACAddress.sprintf( "%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-00-00", HN( ifrs.ifr_hwaddr.sa_data[0] ), LN( ifrs.ifr_hwaddr.sa_data[0] ), HN( ifrs.ifr_hwaddr.sa_data[1] ), LN( ifrs.ifr_hwaddr.sa_data[1] ), HN( ifrs.ifr_hwaddr.sa_data[2] ), LN( ifrs.ifr_hwaddr.sa_data[2] ), HN( ifrs.ifr_hwaddr.sa_data[3] ), LN( ifrs.ifr_hwaddr.sa_data[3] ), HN( ifrs.ifr_hwaddr.sa_data[4] ), LN( ifrs.ifr_hwaddr.sa_data[4] ), HN( ifrs.ifr_hwaddr.sa_data[5] ), LN( ifrs.ifr_hwaddr.sa_data[5] ), HN( ifrs.ifr_hwaddr.sa_data[6] ), LN( ifrs.ifr_hwaddr.sa_data[6] ), HN( ifrs.ifr_hwaddr.sa_data[7] ), LN( ifrs.ifr_hwaddr.sa_data[7] ), HN( ifrs.ifr_hwaddr.sa_data[8] ), LN( ifrs.ifr_hwaddr.sa_data[8] ), HN( ifrs.ifr_hwaddr.sa_data[9] ), LN( ifrs.ifr_hwaddr.sa_data[9] ), HN( ifrs.ifr_hwaddr.sa_data[10] ), LN( ifrs.ifr_hwaddr.sa_data[10] ), HN( ifrs.ifr_hwaddr.sa_data[11] ), LN( ifrs.ifr_hwaddr.sa_data[11] ), HN( ifrs.ifr_hwaddr.sa_data[12] ), LN( ifrs.ifr_hwaddr.sa_data[12] ), HN( ifrs.ifr_hwaddr.sa_data[13] ), LN( ifrs.ifr_hwaddr.sa_data[13] ) ); break; #endif case ARPHRD_PPP : // PPP break; case ARPHRD_IEEE80211 : // WLAN break; case ARPHRD_IRDA : // IRDA break; } } } else // else already probed before -> just update Log(("Redetected NIC %s\n", NicName.latin1())); // get dynamic info if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { IFI->IsUp = ((ifrs.ifr_flags & IFF_UP) == IFF_UP); IFI->HasMulticast = ((ifrs.ifr_flags & IFF_MULTICAST) == IFF_MULTICAST); } else { IFI->IsUp = 0; IFI->HasMulticast = 0; } if( ioctl(sockfd, SIOCGIFADDR, &ifrs) >= 0 ) { IFI->Address = inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_addr)->sin_addr); } else { IFI->Address = ""; IFI->IsUp = 0; } if( ioctl(sockfd, SIOCGIFBRDADDR, &ifrs) >= 0 ) { IFI->BCastAddress = inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_broadaddr)->sin_addr); } else { IFI->BCastAddress = ""; } if( ioctl(sockfd, SIOCGIFNETMASK, &ifrs) >= 0 ) { IFI->Netmask = inet_ntoa(((struct sockaddr_in*)&ifrs.ifr_netmask)->sin_addr); } else { IFI->Netmask = ""; } Log(("NIC %s UP ? %d\n", NicName.latin1(), IFI->IsUp )); } ::close( sockfd ); } InterfaceInfo * System::findInterface( const QString & N ) { InterfaceInfo * Run; // has PAN NetworkSetup UP interface ? for( QDictIterator<InterfaceInfo> It(ProbedInterfaces); It.current(); ++It ) { Run = It.current(); if( N == Run->Name ) { // this PAN NetworkSetup is up return Run; } } return 0; } #include <stdarg.h> static FILE * logf = 0; void VLog( char * Format, ... ) { va_list l; va_start(l, Format ); if( logf == (FILE *)0 ) { QString S = getenv("NS2LOG"); if( S == "stderr" ) { logf = stderr; } else if( S.isEmpty() ) { logf = fopen( "/tmp/ns2log", "a" ); } else { logf = fopen( S, "a" ); } if( ! logf ) { fprintf( stderr, "Cannot open logfile %s : %d\n", S.latin1(), errno ); logf = (FILE *)1; } else { fprintf( logf, "____ OPEN LOGFILE ____\n"); } } if( (unsigned long)logf > 1 ) { vfprintf( logf, Format, l ); } va_end( l ); fflush( logf ); } void LogClose( void ) { if( (long)logf > 1 ) { fprintf( logf, "____ CLOSE LOGFILE ____\n"); diff --git a/noncore/settings/networksettings2/networksettings2/system.h b/noncore/settings/networksettings2/networksettings2/system.h index 794b868..52613d8 100644 --- a/noncore/settings/networksettings2/networksettings2/system.h +++ b/noncore/settings/networksettings2/networksettings2/system.h @@ -1,140 +1,143 @@ #ifndef __SYSTEM__H #define __SYSTEM__H #include <qstring.h> #include <opie2/oprocess.h> using namespace Opie::Core; // for hardware types #include <net/if_arp.h> #include <qdict.h> #include <qobject.h> #include <stdio.h> class NetworkSetup; class ANetNodeInstance; class QFile; class MyProcess : public QObject { Q_OBJECT public : MyProcess(); ~MyProcess(); inline OProcess & process() { return *P; } inline void setEchoMode( bool M ) { EchoMode = M; } public slots : void SLOT_Stdout( Opie::Core::OProcess * P, char *, int ); void SLOT_Stderr( Opie::Core::OProcess * P, char *, int ); void SLOT_ProcessExited( Opie::Core::OProcess * P); signals : void stdoutLine( const QString & ); void stderrLine( const QString & ); void processExited( MyProcess * ); private : QString StdoutBuffer; QString StderrBuffer; OProcess * P; // output all output to my output bool EchoMode; }; class InterfaceInfo { public : InterfaceInfo() : Name(), MACAddress(), BCastAddress(), Netmask(), DstAddress() { } NetworkSetup * assignedToNetworkSetup() { return Collection; } void assignToNetworkSetup( NetworkSetup * NNI ) { Collection = NNI; } NetworkSetup * Collection; // networkSetup taking care of me QString Name; // name of interface int CardType; // type of card QString MACAddress; // MAC address QString Address; // IP Address QString BCastAddress; // Broadcast Address QString Netmask; // Netmask QString DstAddress; // Peer address (if P-t-P) bool IsUp; // interface is UP bool HasMulticast; // Supports Multicast bool IsPointToPoint; // IsPointToPoint card QString RcvBytes; - QString SndBytes; QString RcvErrors; - QString SndErrors; + QString RcvPackets; QString RcvDropped; + + QString SndBytes; + QString SndErrors; + QString SndPackets; QString SndDropped; QString Collisions; }; class System : public QObject { Q_OBJECT public : System( void ); ~System( void ); QDict<InterfaceInfo> & interfaces( void ); InterfaceInfo * interface( const QString& N ) { return interfaces()[N]; } // exec command as root int runAsRoot( QStringList & S, MyProcess * Prc = 0 ); // exec command as user int execAsUser( QStringList & Cmd, bool Synchronous = 0 ); // refresh stats for this interface void refreshStatistics( InterfaceInfo & ); // reloads interfaces void probeInterfaces( void ); InterfaceInfo * findInterface( const QString & DevName ); private slots : void SLOT_ProcessExited( MyProcess * ); signals : void stdoutLine( const QString & ); void stderrLine( const QString & ); void processEvent( const QString & ); private : QDict<InterfaceInfo> ProbedInterfaces; FILE * OutputOfCmd; QFile * ProcDevNet; }; #endif diff --git a/noncore/settings/networksettings2/profile/profileGUI.ui b/noncore/settings/networksettings2/profile/profileGUI.ui index 5bf9a9c..8b421e8 100644 --- a/noncore/settings/networksettings2/profile/profileGUI.ui +++ b/noncore/settings/networksettings2/profile/profileGUI.ui @@ -1,291 +1,291 @@ <!DOCTYPE UI><UI> <class>ProfileGUI</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>Profile_FRM</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>276</width> - <height>231</height> + <width>551</width> + <height>547</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Profile</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> - <number>0</number> + <number>1</number> </property> <property stdset="1"> <name>spacing</name> - <number>0</number> + <number>3</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>TabWidget6</cstring> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Setup</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>1</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout8</cstring> </property> <grid> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="0" column="0" rowspan="2" colspan="1" > <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox1</cstring> </property> <property stdset="1"> <name>title</name> <string>Start</string> </property> <vbox> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>Automatic_CB</cstring> </property> <property stdset="1"> <name>text</name> <string>Automatically</string> </property> </widget> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>Confirm_CB</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>text</name> <string>Ask</string> </property> <property> <name>layoutMargin</name> </property> </widget> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>Disabled_CB</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>text</name> <string>Disabled</string> </property> <property> <name>layoutMargin</name> </property> </widget> </vbox> </widget> <widget row="0" column="1" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>TriggersVPN_CB</cstring> </property> <property stdset="1"> <name>text</name> <string>Trigger VPN</string> </property> </widget> <spacer row="1" column="1" > <property> <name>name</name> <cstring>Spacer8</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </grid> </widget> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3</cstring> </property> <property stdset="1"> <name>text</name> <string>Description</string> </property> </widget> <widget> <class>QMultiLineEdit</class> <property stdset="1"> <name>name</name> <cstring>Description_LE</cstring> </property> </widget> </vbox> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>State</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget> <class>QFrame</class> <property stdset="1"> <name>name</name> <cstring>Frame73</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>5</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>NoFrame</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Plain</enum> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <hbox> <property stdset="1"> <name>margin</name> <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>InterfaceName_LBL</cstring> </property> <property stdset="1"> <name>font</name> <font> <underline>1</underline> </font> </property> <property stdset="1"> <name>text</name> <string>eth0</string> </property> </widget> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>InterfaceOptions_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>font</name> @@ -695,1091 +695,1060 @@ <widget> <class>QFrame</class> <property stdset="1"> <name>name</name> <cstring>DHCP_GB</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>5</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>NoFrame</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Raised</enum> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>1</number> </property> <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel9_3</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>1</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>Lease Expires</string> </property> </widget> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel8_3</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>Lease Obtained</string> </property> </widget> <widget row="0" column="1" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>DHCPServer_LBL</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>5</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>text</name> <string></string> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> <widget row="1" column="1" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>LeaseObtained_LBL</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>5</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>minimumSize</name> <size> <width>94</width> <height>0</height> </size> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>text</name> <string></string> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> <widget row="2" column="1" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>LeaseExpires_LBL</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>5</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>text</name> <string></string> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel6_3</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>1</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>DHCP Server</string> </property> </widget> </grid> </widget> <spacer> <property> <name>name</name> <cstring>Spacer16</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </vbox> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Traffic</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget> - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout5</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QLabel</class> + <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1_2</cstring> + <cstring>Receiving_GB</cstring> </property> <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>1</vsizetype> - </sizepolicy> + <name>enabled</name> + <bool>false</bool> </property> <property stdset="1"> - <name>text</name> + <name>title</name> <string>Receiving</string> </property> - </widget> - <spacer> <property> - <name>name</name> - <cstring>Spacer17_2</cstring> + <name>layoutMargin</name> </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> + <property> + <name>layoutSpacing</name> </property> + <vbox> <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> + <name>margin</name> + <number>4</number> </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> + <property stdset="1"> + <name>spacing</name> + <number>2</number> </property> - </spacer> - </hbox> - </widget> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>Layout43</cstring> - </property> - <property> - <name>layoutMargin</name> + <cstring>Layout11</cstring> </property> <property> <name>layoutSpacing</name> </property> <hbox> <property stdset="1"> <name>margin</name> - <number>2</number> + <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>0</number> + <number>2</number> </property> <widget> - <class>QFrame</class> + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>Frame114</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>5</vsizetype> - </sizepolicy> - </property> - <property stdset="1"> - <name>minimumSize</name> - <size> - <width>5</width> - <height>0</height> - </size> - </property> - <property stdset="1"> - <name>maximumSize</name> - <size> - <width>5</width> - <height>32767</height> - </size> + <cstring>xxxxxxxxxxxxx</cstring> </property> <property stdset="1"> - <name>frameShape</name> - <enum>NoFrame</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Raised</enum> + <name>text</name> + <string>Pkt</string> </property> </widget> <widget> - <class>QFrame</class> + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>Rcv_GB</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> + <cstring>RcvPackets_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> - <vsizetype>5</vsizetype> + <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> - <enum>NoFrame</enum> + <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> - <enum>Raised</enum> - </property> - <property> - <name>layoutMargin</name> - </property> - <property> - <name>layoutSpacing</name> + <enum>Sunken</enum> </property> - <grid> <property stdset="1"> - <name>margin</name> + <name>indent</name> <number>0</number> </property> - <property stdset="1"> - <name>spacing</name> - <number>1</number> - </property> - <widget row="1" column="0" > + </widget> + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1_5_9</cstring> + <cstring>TextLabel1_5_3_4</cstring> </property> <property stdset="1"> <name>text</name> - <string>Errors</string> + <string>Bytes</string> </property> </widget> - <widget row="0" column="1" rowspan="1" colspan="3" > + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>RcvBytes_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> - <widget row="1" column="3" > + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>RcvDropped_LBL</cstring> + <cstring>TextLabel1_5_3_4_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>ODO</string> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>RcvODO_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> - <widget row="1" column="1" > + </hbox> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout12</cstring> + </property> + <property> + <name>layoutSpacing</name> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_5_9</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Errors</string> + </property> + </widget> + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>RcvErrors_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> - <widget row="1" column="2" > + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_5_4</cstring> </property> <property stdset="1"> <name>text</name> <string>Dropped</string> </property> </widget> - <widget row="0" column="0" > + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1_5_3</cstring> + <cstring>RcvDropped_LBL</cstring> </property> <property stdset="1"> - <name>text</name> - <string>Bytes</string> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> </property> - </widget> - </grid> - </widget> - </hbox> - </widget> - <widget> - <class>QLayoutWidget</class> <property stdset="1"> - <name>name</name> - <cstring>Layout6</cstring> + <name>frameShape</name> + <enum>Panel</enum> </property> - <hbox> <property stdset="1"> - <name>margin</name> - <number>0</number> + <name>frameShadow</name> + <enum>Sunken</enum> </property> <property stdset="1"> - <name>spacing</name> - <number>6</number> + <name>indent</name> + <number>0</number> </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> <widget> - <class>QLabel</class> + <class>QFrame</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1</cstring> + <cstring>Frame114</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> - <vsizetype>1</vsizetype> + <vsizetype>5</vsizetype> </sizepolicy> </property> <property stdset="1"> - <name>text</name> - <string>Transmitting</string> - </property> - </widget> - <spacer> - <property> - <name>name</name> - <cstring>Spacer18_2</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> + <name>minimumSize</name> <size> - <width>20</width> - <height>20</height> + <width>5</width> + <height>0</height> </size> </property> - </spacer> - </hbox> - </widget> - <widget> - <class>QLayoutWidget</class> <property stdset="1"> - <name>name</name> - <cstring>Layout44</cstring> - </property> - <property> - <name>layoutMargin</name> - </property> - <property> - <name>layoutSpacing</name> + <name>maximumSize</name> + <size> + <width>5</width> + <height>32767</height> + </size> </property> - <hbox> <property stdset="1"> - <name>margin</name> - <number>2</number> + <name>frameShape</name> + <enum>NoFrame</enum> </property> <property stdset="1"> - <name>spacing</name> - <number>0</number> + <name>frameShadow</name> + <enum>Raised</enum> </property> + </widget> <widget> <class>QFrame</class> <property stdset="1"> <name>name</name> <cstring>Frame115</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>5</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>minimumSize</name> <size> <width>5</width> <height>0</height> </size> </property> <property stdset="1"> <name>maximumSize</name> <size> <width>5</width> <height>32767</height> </size> </property> <property stdset="1"> <name>frameShape</name> <enum>NoFrame</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Plain</enum> </property> </widget> <widget> - <class>QFrame</class> + <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>Snd_GB</cstring> + <cstring>Sending_GB</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>5</vsizetype> - </sizepolicy> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>NoFrame</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Raised</enum> + <name>title</name> + <string>Sending</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> - <grid> + <vbox> <property stdset="1"> <name>margin</name> - <number>0</number> + <number>4</number> </property> <property stdset="1"> <name>spacing</name> - <number>1</number> + <number>2</number> </property> - <widget row="1" column="0" > - <class>QLabel</class> + <widget> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1_5_9_2</cstring> + <cstring>Layout13</cstring> </property> - <property stdset="1"> - <name>text</name> - <string>Errors</string> + <property> + <name>layoutSpacing</name> </property> - </widget> - <widget row="1" column="2" > - <class>QLabel</class> + <hbox> <property stdset="1"> - <name>name</name> - <cstring>TextLabel1_5_4_2</cstring> + <name>margin</name> + <number>0</number> </property> <property stdset="1"> - <name>text</name> - <string>Dropped</string> + <name>spacing</name> + <number>2</number> </property> - </widget> - <widget row="0" column="0" > + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1_5_3_2</cstring> + <cstring>dfsfadf</cstring> </property> <property stdset="1"> <name>text</name> - <string>Bytes</string> + <string>Pkt</string> </property> </widget> - <widget row="1" column="3" > + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>SndDropped_LBL</cstring> + <cstring>SndPackets_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> - <widget row="1" column="1" > + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>SndErrors_LBL</cstring> + <cstring>TextLabel1_5_3_4_4</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Bytes</string> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>SndBytes_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> - <widget row="0" column="1" rowspan="1" colspan="3" > + <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>SndBytes_LBL</cstring> + <cstring>TextLabel1_5_3_4_2_3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>ODO</string> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>SndODO_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> - </grid> - </widget> </hbox> </widget> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>Layout7</cstring> + <cstring>Layout14</cstring> + </property> + <property> + <name>layoutSpacing</name> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>6</number> + <number>2</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel1_3</cstring> + <cstring>TextLabel1_5_9_3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Errors</string> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>SndErrors_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> - <hsizetype>0</hsizetype> + <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> - <name>text</name> - <string>Others</string> - </property> - </widget> - <spacer> - <property> - <name>name</name> - <cstring>Spacer19</cstring> + <name>frameShape</name> + <enum>Panel</enum> </property> <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> + <name>frameShadow</name> + <enum>Sunken</enum> </property> <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> + <name>indent</name> + <number>0</number> </property> - </spacer> - </hbox> </widget> <widget> - <class>QLayoutWidget</class> + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>Layout45</cstring> + <cstring>TextLabel1_5_4_3</cstring> </property> - <property> - <name>layoutMargin</name> - </property> - <property> - <name>layoutSpacing</name> - </property> - <hbox> <property stdset="1"> - <name>margin</name> - <number>2</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>0</number> + <name>text</name> + <string>Dropped</string> </property> + </widget> <widget> - <class>QFrame</class> + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>Frame116</cstring> + <cstring>SndDropped_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>5</vsizetype> + <hsizetype>7</hsizetype> + <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> - <name>minimumSize</name> - <size> - <width>5</width> - <height>0</height> - </size> - </property> - <property stdset="1"> - <name>maximumSize</name> - <size> - <width>5</width> - <height>32767</height> - </size> - </property> - <property stdset="1"> <name>frameShape</name> - <enum>NoFrame</enum> + <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> - <enum>Raised</enum> + <enum>Sunken</enum> </property> + <property stdset="1"> + <name>indent</name> + <number>0</number> + </property> + </widget> + </hbox> + </widget> + </vbox> </widget> <widget> - <class>QFrame</class> + <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>Collisions_FRM</cstring> + <cstring>Misc_GB</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>5</vsizetype> - </sizepolicy> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>NoFrame</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Raised</enum> + <name>title</name> + <string>Miscellaneous</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <hbox> <property stdset="1"> <name>margin</name> - <number>0</number> + <number>4</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_5_3_3</cstring> </property> <property stdset="1"> <name>text</name> <string>Collisions</string> </property> </widget> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>Collisions_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> <spacer> <property> <name>name</name> - <cstring>Spacer18</cstring> + <cstring>Spacer10</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer> + <property> + <name>name</name> + <cstring>Spacer13</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> - </hbox> - </widget> </hbox> </widget> <spacer> <property> <name>name</name> <cstring>Spacer17</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>Layout17</cstring> + <cstring>Layout10</cstring> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>Refresh_CB</cstring> </property> <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>text</name> <string>Live feed </string> </property> </widget> <spacer> <property> <name>name</name> <cstring>Spacer57</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>ResetODO_But</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>text</name> + <string>Reset ODO</string> + </property> + </widget> </hbox> </widget> </vbox> </widget> </widget> </vbox> </widget> <connections> <connection> <sender>Refresh_CB</sender> <signal>toggled(bool)</signal> <receiver>Profile_FRM</receiver> <slot>SLOT_AutoRefresh(bool)</slot> </connection> + <connection> + <sender>ResetODO_But</sender> + <signal>clicked()</signal> + <receiver>Profile_FRM</receiver> + <slot>SLOT_ResetODO()</slot> + </connection> <slot access="public">SLOT_AutoRefresh(bool)</slot> + <slot access="public">SLOT_ResetODO()</slot> </connections> </UI> diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp index ad943fe..1713f0c 100644 --- a/noncore/settings/networksettings2/profile/profileedit.cpp +++ b/noncore/settings/networksettings2/profile/profileedit.cpp @@ -1,102 +1,125 @@ #include <qlabel.h> +#include <qgroupbox.h> +#include <qpushbutton.h> #include <qframe.h> #include <qcheckbox.h> #include <qmultilineedit.h> #include <qcheckbox.h> #include <GUIUtils.h> #include <netnode.h> #include <resources.h> #include "profileedit.h" ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : ProfileGUI( Parent ), RefreshTimer(this) { InterfaceInfo * II; II = TNNI->networkSetup()->assignedInterface(); Log(( "Interface %p %p %p: %d\n", II, TNNI, TNNI->networkSetup(), (II) ? II->IsUp : 0 )); NNI = TNNI; Dev = NNI->runtime()->device(); if( ( II = NNI->networkSetup()->assignedInterface() ) ) { Refresh_CB->setEnabled( TRUE ); - Snd_GB->setEnabled( TRUE ); - Rcv_GB->setEnabled( TRUE ); - Collisions_FRM->setEnabled( TRUE ); + ResetODO_But->setEnabled( TRUE ); + Sending_GB->setEnabled( TRUE ); + Receiving_GB->setEnabled( TRUE ); + Misc_GB->setEnabled( TRUE ); // show current content SLOT_Refresh(); + // initialize ODO + SLOT_ResetODO(); + // fill in static data InterfaceName_LBL->setText( II->Name ); IPAddress_LBL->setText( II->Address ); SubnetMask_LBL->setText( II->Netmask ); Broadcast_LBL->setText( II->BCastAddress ); MACAddress_LBL->setText( II->MACAddress ); if( II->IsPointToPoint ) { PointToPoint_LBL->setText( II->DstAddress ); } QString S; InterfaceName_LBL->setText( II->Name ); if( II->HasMulticast ) { S += "Multicast"; } if( ! S.isEmpty() ) { S.prepend( " : " ); } InterfaceOptions_LBL->setText( S ); connect( &RefreshTimer, SIGNAL( timeout() ), this, SLOT( SLOT_Refresh() ) ); } } QString ProfileEdit::acceptable( void ) { return QString(); } void ProfileEdit::showData( ProfileData & Data ) { Description_LE->setText( Data.Description ); Automatic_CB->setChecked( Data.Automatic ); TriggersVPN_CB->setChecked( Data.TriggerVPN ); Confirm_CB->setChecked( Data.Confirm ); Disabled_CB->setChecked( Data.Disabled ); } bool ProfileEdit::commit( ProfileData & Data ) { bool SM = 0; TXTM( Data.Description, Description_LE, SM ); CBM( Data.Automatic, Automatic_CB, SM ); CBM( Data.TriggerVPN, TriggersVPN_CB, SM ); CBM( Data.Disabled, Disabled_CB, SM ); CBM( Data.Confirm, Confirm_CB, SM ); return SM; } void ProfileEdit::SLOT_Refresh( void ) { InterfaceInfo * II = NNI->networkSetup()->assignedInterface(); + QString S; NSResources->system().refreshStatistics( *II ); + RcvBytes_LBL->setText( II->RcvBytes ); - SndBytes_LBL->setText( II->SndBytes ); + RcvPackets_LBL->setText( II->RcvPackets ); RcvErrors_LBL->setText( II->RcvErrors ); - SndErrors_LBL->setText( II->SndErrors ); RcvDropped_LBL->setText( II->RcvDropped ); + S.setNum( II->RcvBytes.toLong() - RcvODO ); + RcvODO_LBL->setText( S ); + + SndBytes_LBL->setText( II->SndBytes ); + SndPackets_LBL->setText( II->SndPackets ); + SndErrors_LBL->setText( II->SndErrors ); SndDropped_LBL->setText( II->SndDropped ); + S.setNum( II->SndBytes.toLong() - SndODO ); + SndODO_LBL->setText( S ); + Collisions_LBL->setText( II->Collisions ); } void ProfileEdit::SLOT_AutoRefresh( bool ar ) { if( ar ) { RefreshTimer.start( 1000 ); SLOT_Refresh(); } else { RefreshTimer.stop(); } } + +void ProfileEdit::SLOT_ResetODO( void ) { + InterfaceInfo * II = NNI->networkSetup()->assignedInterface(); + RcvODO = II->RcvBytes.toLong(); + SndODO = II->SndBytes.toLong(); + SLOT_Refresh(); +} diff --git a/noncore/settings/networksettings2/profile/profileedit.h b/noncore/settings/networksettings2/profile/profileedit.h index 9cde845..56bd15d 100644 --- a/noncore/settings/networksettings2/profile/profileedit.h +++ b/noncore/settings/networksettings2/profile/profileedit.h @@ -1,29 +1,32 @@ #include "profiledata.h" #include "profileGUI.h" #include <qtimer.h> class ANetNodeInstance; class RuntimeInfo; class ProfileEdit : public ProfileGUI { Q_OBJECT public : ProfileEdit( QWidget * parent, ANetNodeInstance * NNI ); QString acceptable( void ); bool commit( ProfileData & Data ); void showData( ProfileData & Data ); public slots : void SLOT_AutoRefresh( bool ); void SLOT_Refresh( void ); + void SLOT_ResetODO( void ); private : QTimer RefreshTimer; ANetNodeInstance * NNI; RuntimeInfo * Dev; + long RcvODO; + long SndODO; }; |