author | wimpie <wimpie> | 2004-04-04 00:27:59 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-04 00:27:59 (UTC) |
commit | a416c6c9630d6d63ee63cf520953b86af8b7cddc (patch) (side-by-side diff) | |
tree | dbd0f5173728129f5a3faffdafd4f73d8cc72407 | |
parent | 152ffce2a4e8191d28738e3b40d8a726250a8767 (diff) | |
download | opie-a416c6c9630d6d63ee63cf520953b86af8b7cddc.zip opie-a416c6c9630d6d63ee63cf520953b86af8b7cddc.tar.gz opie-a416c6c9630d6d63ee63cf520953b86af8b7cddc.tar.bz2 |
*** empty log message ***
25 files changed, 130 insertions, 250 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h index 4dd508d..57ff95e 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h @@ -1,42 +1,42 @@ #ifndef BLUETOOTHRFCOMM_H #define BLUETOOTHRFCOMM_H #include <netnode.h> #include "bluetoothRFCOMMdata.h" #include "bluetoothRFCOMMrun.h" class BluetoothRFCOMMNetNode; class BluetoothRFCOMMEdit; class ABluetoothRFCOMM : public ANetNodeInstance { public : ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ); QWidget * edit( QWidget * parent ); QString acceptable( void ); void commit( void ); RuntimeInfo * runtime( void ) - { if( RT ) + { if( RT == 0 ) RT = new BluetoothRFCOMMRun( this, Data ); return RT; } virtual void * data( void ) { return (void *)&Data; } protected : virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); private : BluetoothRFCOMMEdit * GUI; BluetoothRFCOMMData Data; BluetoothRFCOMMRun * RT; }; #endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h index ee346f0..705201c 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h @@ -1,75 +1,75 @@ #ifndef BLUETOOTH_NETNODE_H #define BLUETOOTH_NETNODE_H #include "netnode.h" class ABluetoothBNEP; class BluetoothBNEPNetNode : public ANetNode { Q_OBJECT public: BluetoothBNEPNetNode(); virtual ~BluetoothBNEPNetNode(); virtual const QString pixmapName() - { return "bluetooth"; } + { return "Devices/bluetooth"; } virtual const QString nodeName() { return tr("Bluetooth PAN/NAP"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; class BluetoothRFCOMMNetNode : public ANetNode { Q_OBJECT public: BluetoothRFCOMMNetNode(); virtual ~BluetoothRFCOMMNetNode(); virtual const QString pixmapName() - { return "bluetooth"; } + { return "Devices/bluetooth"; } virtual const QString nodeName() { return tr("Bluetooth serial link"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h index 401317b..da99c1c 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.h +++ b/noncore/settings/networksettings2/cable/cable_NN.h @@ -1,44 +1,44 @@ #ifndef CABLE_NETNODE_H #define CABLE_NETNODE_H #include "netnode.h" class ACable; class CableNetNode : public ANetNode { Q_OBJECT public: CableNetNode(); virtual ~CableNetNode(); virtual const QString pixmapName() - { return "cable"; } + { return "Devices/cable"; } virtual const QString nodeName() { return tr("Cable Connection"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index d4b2bb3..ce13573 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp @@ -100,385 +100,385 @@ EditConnection::EditConnection( QWidget* parent ) : NodeCollection * EditConnection::getTmpCollection( void ) { if( TmpIsValid ) // content is stil OK return &(TmpCollection); // reset collection -> delete all NEW NetNodes { ANetNodeInstance * NNI; for( QListIterator<ANetNodeInstance> it(TmpCollection); it.current(); ++it ) { if( it.current()->isNew() ) { delete it.current(); } } TmpCollection.clear(); } // update content QListViewItem * it = Nodes_LV->firstChild(); ANetNode * NN; // start iter ANetNodeInstance * NNI = (SelectedNodes) ? SelectedNodes->first() : 0 ; TmpCollection.setModified( 0 ); while ( it ) { NN = (*Mapping)[it]; if( NN == 0 ) { // child is controller -> has sub radio // check if one radio is selected it = it->firstChild(); while( it ) { if( ((QCheckListItem *)it)->isOn() ) { // this radio is selected -> go deeper if( SelectedNodes == 0 || NNI == 0 || NNI->netNode()->nodeName() != it->text(0) ) { // new item not in previous collection ANetNodeInstance * NNI = (*Mapping)[it]->createInstance(); NNI->initialize(); // this node type not in collection TmpCollection.append( NNI ); // master collection changed because new item in it TmpCollection.setModified( 1 ); // no more valid items in old list NNI = 0; } else { // already in list -> copy pointer TmpCollection.append( NNI ); NNI = SelectedNodes->next(); } it = it->firstChild(); // do not bother to check other items break; } it = it->nextSibling(); } } else { // check children it = it->firstChild(); } } TmpIsValid = 1; return &(TmpCollection); } // pass a connection NodeCollection to be edited void EditConnection::setConnection( NodeCollection * NC ) { ANetNodeInstance * NNI; ANetNode * NN; SelectedNodes = NC; Name_LE->setText( NC->name() ); NNI = NC->first(); // show configure tabl Tab_TB->setCurrentPage( 1 ); // valid colledction Tab_TB->setTabEnabled( Setup_FRM, FALSE ); Setup_FRM->setEnabled( FALSE ); // select items in collection QListViewItem * it = Nodes_LV->firstChild(); bool Found; TmpIsValid = 0; while ( it ) { // listitem corresponds to netnode NN = (*Mapping)[it]; if( NN == 0 ) { // child is controller -> has sub radio QString Ctr = it->text(0); // check if one radio is selected it = it->firstChild(); Found = 0; while( it ) { if( NNI && NNI->netNode()->nodeName() == it->text(0) ) { // this radio is part of the collection ((QCheckListItem *)it)->setOn( 1 ); updateGUI( it, NNI->netNode() ); // check its children Found = 1; it = it->firstChild(); NNI = SelectedNodes->next(); // do not bother to check other items break; } it = it->nextSibling(); } if( ! Found ) { // this means that this level is NOT present in collection // probably INCOMPATIBEL collection OR Missing plugin QMessageBox::warning( 0, tr( "Error presentig Connection" ), tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). arg(Ctr) ); return; } } else { // automatic item -> check children it = it->firstChild(); } } } // get result of editing (either new OR updated collection NodeCollection * EditConnection::connection( void ) { if( SelectedNodes == 0 ) { // new collection SelectedNodes = new NodeCollection; } // clean out old entries SelectedNodes->clear(); // transfer { ANetNodeInstance * NNI; for( QListIterator<ANetNodeInstance> it(TmpCollection); it.current(); ++it ) { SelectedNodes->append( it.current() ); } } if( TmpCollection.isModified() ) SelectedNodes->setModified( 1 ); if( SelectedNodes->name() != Name_LE->text() ) { SelectedNodes->setName( Name_LE->text() ); SelectedNodes->setModified( 1 ); } return SelectedNodes; } // Build device tree -> start void EditConnection::buildFullTree( void ) { ANetNode * NN; // toplevel item MyQCheckListItem * TheTop = new MyQCheckListItem( Nodes_LV, NSResources->netNode2Name("fullsetup"), QCheckListItem::Controller ); TheTop->setOpen( TRUE ); Description_LBL->setText( NSResources->netNode2Description( "fullsetup" ) ); Nodes_LV->setSelected( TheTop, TRUE ); // find all Nodes that care toplevel nodes -> ie provide // TCP/IP Connection for( QDictIterator<NetNode_t> Iter(NSResources->netNodes()); Iter.current(); ++Iter ) { NN = Iter.current()->NetNode; if( ! NN->isToplevel() ) { continue; } MyQCheckListItem * it = new MyQCheckListItem( TheTop, NN->nodeName(), QCheckListItem::RadioButton ); - it->setPixmap( 0, NSResources->getPixmap( "commprofile" ) ); + it->setPixmap( 0, NSResources->getPixmap( "Devices/commprofile" ) ); // remember that this node maps to this listitem Mapping->insert( it, NN ); buildSubTree( it, NN ); } } // Build device tree -> help function void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { ANetNode::NetNodeList & NNL = NN->alternatives(); if( NNL.size() > 1 ) { // this node has alternatives -> needs radio buttons it = new MyQCheckListItem( it, NSResources->netNode2Name(NNL[0]->provides()), QCheckListItem::Controller ); it->setSelectable( FALSE ); } for ( unsigned int i=0; i < NNL.size(); i++ ) { QListViewItem * CI; if( NNL.size() > 1 ) { // generate radio buttons CI = new MyQCheckListItem( (QCheckListItem *)it, NNL[i]->nodeName(), QCheckListItem::RadioButton ); // remember that this node maps to this listitem CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); Mapping->insert( CI, NNL[i] ); CI->setSelectable( FALSE ); } else { // Single item CI = new MyQListViewItem( it, NNL[i]->nodeName() ); // remember that this node maps to this listitem Mapping->insert( CI, NNL[i] ); CI->setSelectable( FALSE ); CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); } buildSubTree( CI, NNL[i] ); } } // Clicked ok OK button void EditConnection::accept( void ) { if( ! haveCompleteConfig( 0 ) || Name_LE->text().isEmpty() ) { QMessageBox::warning( 0, tr( "Closing Connection Setup" ), tr( "Definition not complete or no name" ) ); return; } // check if all devices have acceptable input getTmpCollection(); { ANetNodeInstance * NNI; QString S; for( QListIterator<ANetNodeInstance> it(TmpCollection); it.current(); ++it ) { NNI = it.current(); // widget must show its own problems S = NNI->acceptable(); if( ! S.isEmpty() ) { QMessageBox::warning( 0, tr( "Cannot save" ), S ); return; } NNI->commit(); if( NNI->isModified() ) { TmpCollection.setModified( 1 ); // commit the data } } } QDialog::accept(); } // triggered by CB void EditConnection::SLOT_AutoCollapse( bool b ) { AutoCollapse = b; } // clicked on node in tree -> update GUI void EditConnection::SLOT_SelectNode( QListViewItem * it ) { ANetNode * NN; if( it == 0 || it->depth() == 0 ) { Description_LBL->setText( NSResources->netNode2Description( "fullsetup" ) ); // topevel or no selection return; } // store conversion from lvitem to node NN = (*Mapping)[ it ]; if( ! NN ) { // intermediate node NN = (*Mapping)[ it->firstChild() ]; if( NN ) { // figure out type of this node -> produce mesage Description_LBL->setText( NSResources->netNode2Description(NN->provides()) ); } else { Description_LBL->setText( "" ); } return; } Description_LBL->setText( NN->nodeDescription() ); if( ! it->isSelectable() ) { return; } if( ! ((QCheckListItem *)it)->isOn() ) { // clicked on line but NOT on Check or Radio item return; } // item has really changed -> update TmpIsValid = 0; updateGUI( it, NN ); } // cliecked on TAB to go to setup void EditConnection::SLOT_AlterTab( const QString & S ) { if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { // switched to setup -> update CB and populate ws with // forms for devices if( ! TmpIsValid ) { getTmpCollection(); // clear CB and Ws { QWidget * W; int i = 0; Devices_CB->clear(); while( ( W = Setup_WS->widget( i ) ) ) { Setup_WS->removeWidget( W ); i ++; } } // update CB // and populate WidgetStack { ANetNodeInstance * NNI; QListIterator<ANetNodeInstance> it(TmpCollection); int i = 0; QWidget * W; for ( ; it.current(); ++it ) { NNI = it.current(); Devices_CB->insertItem( NSResources->getPixmap( NNI->netNode()->pixmapName() ), NNI->netNode()->nodeName() ); // add edit widget W = NNI->edit( Setup_WS ); if( ! W) { W = new QLabel( Setup_WS, tr("No configuration required")); } Setup_WS->addWidget( W , i ); i ++; } } Setup_WS->raiseWidget( 0 ); } // still valid } } // update visual feedback of selection state void EditConnection::updateGUI( QListViewItem * it, ANetNode * NN ) { bool HCC = haveCompleteConfig( it ); Tab_TB->setTabEnabled( Setup_FRM, HCC ); Setup_FRM->setEnabled( HCC ); // disable children of all siblings at same level QListViewItem * Sbl = it->parent()->firstChild(); while( Sbl ) { if ( Sbl != it ) { disableTree( Sbl->firstChild(), FALSE ); Sbl->setSelectable( TRUE ); if( AutoCollapse ) Sbl->setOpen( FALSE ); diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h index 82811a4..6574c17 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.h +++ b/noncore/settings/networksettings2/irda/irda_NN.h @@ -1,44 +1,44 @@ #ifndef IRDA_NETNODE_H #define IRDA_NETNODE_H #include "netnode.h" class AIRDA; class IRDANetNode : public ANetNode { Q_OBJECT public: IRDANetNode(); virtual ~IRDANetNode(); virtual const QString pixmapName() - { return "irda"; } + { return "Devices/irda"; } virtual const QString nodeName() { return tr("Infrared link"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h index 576a6e0..71b49d0 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.h +++ b/noncore/settings/networksettings2/lancard/lancard_NN.h @@ -1,44 +1,44 @@ #ifndef LANCARD_NETNODE_H #define LANCARD_NETNODE_H #include "netnode.h" class ALanCard; class LanCardNetNode : public ANetNode{ Q_OBJECT public: LanCardNetNode(); virtual ~LanCardNetNode(); virtual const QString pixmapName() - { return "card"; } + { return "Devices/card"; } virtual const QString nodeName() { return tr("LAN card"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp index 1e1270e..7ec26a7 100644 --- a/noncore/settings/networksettings2/main.cpp +++ b/noncore/settings/networksettings2/main.cpp @@ -1,119 +1,119 @@ #include "nsdata.h" #include "activateprofile.h" #include "networksettings.h" #include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> #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 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; } 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; } // 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; NS.canStart( 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%d-allowed", AP.selectedProfile() ); + printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); } else { - printf( "%s-cNN-disallowed" ); + printf( "%s-cNN-disallowed", argv[1] ); } } 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; } return rv; } #endif // main.cpp diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h index 0f4c124..5eceed2 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.h +++ b/noncore/settings/networksettings2/modem/modem_NN.h @@ -1,44 +1,44 @@ #ifndef MODEM_NETNODE_H #define MODEM_NETNODE_H #include "netnode.h" class AModem; class ModemNetNode : public ANetNode{ Q_OBJECT public: ModemNetNode(); virtual ~ModemNetNode(); virtual const QString pixmapName() - { return "modem"; } + { return "Devices/modem"; } virtual const QString nodeName() { return tr("Dialup modem"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 3b0cd64..220e00f 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h @@ -1,44 +1,44 @@ #ifndef NETWORK_NETNODE_H #define NETWORK_NETNODE_H #include "netnode.h" class ANetwork; class NetworkNetNode : public ANetNode{ Q_OBJECT public: NetworkNetNode(); virtual ~NetworkNetNode(); virtual const QString pixmapName() - { return "tcpip"; } + { return "Devices/tcpip"; } virtual const QString nodeName() { return tr("IP Configuration"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index e732bfa..8deca14 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp @@ -1,63 +1,63 @@ #include <system.h> #include <asdevice.h> #include "networkrun.h" void NetworkRun::detectState( NodeCollection * NC ) { RuntimeInfo * RI = netNode()->nextNode()->runtime(); AsDevice * Next = RI->asDevice(); InterfaceInfo * II = Next->assignedInterface(); if( II ) { // device has assigned interface NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); } // has no interface -> delegate RI->detectState( NC ); } bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { // we handle UP and DOWN RuntimeInfo * RI = netNode()->nextNode()->runtime(); AsDevice * Next = RI->asDevice(); InterfaceInfo * II = Next->assignedInterface(); if( A == Up ) { // we can bring UP if lower level is available if( NC->currentState() == Available ) { QString S; - S.sprintf( "ifup %s=manual", II->Name.latin1() ); + S.sprintf( "ifup %s", II->Name.latin1() ); NSResources->system().execute( S ); NC->setCurrentState( IsUp ); } return 1; } else if( A == Down ) { if( NC->currentState() == IsUp ) { QString S; S.sprintf( "ifdown %s", II->Name.latin1() ); NSResources->system().execute( S ); NC->setCurrentState( Available ); } return 1; } // delegate return RI->setState( NC, A ); } bool NetworkRun::canSetState( State_t Curr, Action_t A ) { // we handle UP and DOWN RuntimeInfo * RI = netNode()->nextNode()->runtime(); if( A == Up ) { return ( Curr == Available ); } else if( A == Down ) { return ( Curr == IsUp ); } // delegate return RI->canSetState( Curr, A ); } bool NetworkRun::handlesInterface( const QString & S ) { // donno -> pass deeper return netNode()->nextNode()->runtime()->handlesInterface(S); } diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index f72fa8e..e1110e2 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp @@ -1,414 +1,411 @@ #include <stdio.h> #include <qpe/qpeapplication.h> -#include <qiconset.h> +#include <qlistbox.h> #include <qgroupbox.h> #include <qtimer.h> #include <qlistbox.h> #include <qmessagebox.h> #include <qlabel.h> #include <qiconview.h> #include <qtimer.h> #include <qpe/qpeapplication.h> #include <qtoolbutton.h> #include <asdevice.h> #include "networksettings.h" #include "netnode.h" #include "editconnection.h" NetworkSettings::NetworkSettings( QWidget *parent, const char *name, WFlags fl ) : NetworkSettingsGUI(parent,name,fl), NSD() { UpdateTimer = new QTimer( this ); // set pixmaps Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) ); CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) ); Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); On_TB->setPixmap( NSResources->getPixmap( "off" ) ); // populate main Listbox - Profiles_IV->clear(); + Profiles_LB->clear(); { Name2Connection_t & M = NSResources->connections(); NodeCollection * NC; - QIconViewItem * IVI; - // for all connections for( QDictIterator<NodeCollection> it(M); it.current(); ++it ) { NC = it.current(); - IVI = new QIconViewItem( Profiles_IV, - NC->name(), - NC->devicePixmap() ); + Profiles_LB->insertItem( NC->devicePixmap(), + NC->name() ); } } - if( Profiles_IV->count() ) { - Profiles_IV->setSelected( Profiles_IV->firstItem(), TRUE ); + if( Profiles_LB->count() ) { + Profiles_LB->setSelected( 0, TRUE ); } // if no profiles -> auto popup editing if( NSResources->connections().count() == 0 ) { QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); } UpdateTimer->start( 5000 ); connect( UpdateTimer, SIGNAL( timeout() ), this, SLOT( SLOT_RefreshStates() ) ); /* Add QCopChannel */ connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) ); } NetworkSettings::~NetworkSettings() { QString S; S = NSD.generateSettings(); if( ! S.isEmpty() ) { QMessageBox::warning( 0, tr( "Generating system configuration" ), S ); } S = NSD.saveSettings(); if( ! S.isEmpty() ) { // problem saving QMessageBox::warning( 0, tr( "Saving setup" ), S ); } } void NetworkSettings::SLOT_RefreshStates( void ) { - QIconViewItem * IVI = Profiles_IV->currentItem(); // remeber + QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember - if( IVI ) { + if( LBI ) { NodeCollection * NC; NSResources->system().probeInterfaces(); // update current selection only - NC = NSResources->findConnection( IVI->text() ); + NC = NSResources->findConnection( LBI->text() ); if( NC ) { State_t OldS = NC->state(); State_t NewS = NC->state(1); if( OldS != NewS ) { - updateProfileState( IVI ); + updateProfileState( LBI ); } } } /* -> LATER !! bool is; NodeCollection * NC; for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) { NC = NSResources->findConnection( Profiles_LB->text(i) ); if( NC ) { State_t OldS = NC->state(); State_t NewS = NC->state(1); if( OldS != NewS ) { is = Profiles_LB->isSelected(i); Profiles_LB->changeItem( NC->statePixmap(NewS), NC->name(), i ); if( is ) { Profiles_LB->setSelected( i, TRUE ); } } } } if( ci >= 0 ) Profiles_LB->setCurrentItem( ci ); */ } void NetworkSettings::SLOT_AddNode( void ) { SLOT_EditNode( 0 ); } void NetworkSettings::SLOT_DeleteNode( void ) { - QIconViewItem * IVI = Profiles_IV->currentItem(); + QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); - if ( ! IVI ) + if ( ! LBI ) return; if( QMessageBox::warning( 0, tr( "Removing profile" ), tr( "Remove selected profile ?" ), 1, 0 ) == 1 ) { - NSResources->removeConnection( IVI->text() ); - delete IVI; + NSResources->removeConnection( LBI->text() ); + delete LBI; setModified( 1 ); NSD.forceGeneration(1); } } -void NetworkSettings::SLOT_EditNode( QIconViewItem * IVI ) { +void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { QString OldName = ""; EditConnection EC( this ); - if( IVI ) { - NodeCollection * NC = NSResources->findConnection( IVI->text() ); + if( LBI ) { + NodeCollection * NC = NSResources->findConnection( LBI->text() ); if( ! NC ) { return; } OldName = NC->name(); EC.setConnection( NC ); } EC.showMaximized(); // disable refresh timer UpdateTimer->stop(); if( EC.exec() == QDialog::Accepted ) { // toplevel item -> store NodeCollection * NC = EC.connection(); if( NC->isModified() ) { setModified( 1 ); - if( IVI ) { + if( LBI ) { // new name -> remove item NSResources->removeConnection( OldName ); // must add it here since change will trigger event NSResources->addConnection( NC ); - IVI->setText( NC->name() ); - IVI->setPixmap( NC->devicePixmap() ); + Profiles_LB->changeItem( NC->devicePixmap(), + NC->name(), + Profiles_LB->index( LBI ) + ); } else { // new item + int ci = Profiles_LB->count(); NSResources->addConnection( NC ); NC->setNumber( NC->maxConnectionNumber()+1 ); - IVI = new QIconViewItem( Profiles_IV, - NC->name(), - NC->devicePixmap() - ); - Profiles_IV->setSelected( IVI, TRUE ); + Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); + Profiles_LB->setSelected( ci, TRUE ); } - updateProfileState( IVI ); + updateProfileState( LBI ); } } else { // cancelled : reset connection - if( IVI ) { - NodeCollection * NC = NSResources->findConnection( IVI->text() ); + if( LBI ) { + NodeCollection * NC = NSResources->findConnection( LBI->text() ); NC->reassign(); } } // reenable UpdateTimer->start( 5000 ); } -void NetworkSettings::SLOT_ShowNode( QIconViewItem * IVI ) { - if( IVI == 0 ) +void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { + if( LBI == 0 ) return; - NodeCollection * NC = NSResources->findConnection( IVI->text() ); + NodeCollection * NC = NSResources->findConnection( LBI->text() ); // is button possible bool EnabledPossible, OnPossible, ConnectPossible; // is button On or Off bool DisabledOn, OnOn, ConnectOn; EnabledPossible = OnPossible = ConnectPossible = 1; DisabledOn = 1; OnOn = ConnectOn = 0; switch( NC->state() ) { case Unknown : // cannot occur here break; case Unchecked : case Unavailable : // cannot do anything but recheck EnabledPossible = OnPossible = ConnectPossible = 0; break; case Disabled : OnPossible = ConnectPossible = 0; break; case Off : DisabledOn = 0; break; case Available : OnOn = 1; DisabledOn = 0; break; case IsUp : OnOn = ConnectOn = 1; DisabledOn = 0; break; } // set button state Enable_TB->setEnabled( EnabledPossible ); On_TB->setEnabled( OnPossible ); Connect_TB->setEnabled( ConnectPossible ); Enable_TB->setOn( DisabledOn ); On_TB->setOn( OnOn ); Connect_TB->setOn( ConnectOn ); if( NC->description().isEmpty() ) { Description_LBL->setText( tr( "No description" ) ); } else { Description_LBL->setText( NC->description() ); } - CurProfile_GB->setTitle( IVI->text() ); + CurProfile_GB->setTitle( LBI->text() ); State_LBL->setText( NC->stateName() ); } void NetworkSettings::SLOT_CheckState( void ) { - QIconViewItem * IVI = Profiles_IV->currentItem(); - if ( ! IVI ) + QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); + if ( ! LBI ) return; - updateProfileState( IVI ); + updateProfileState( LBI ); } -void NetworkSettings::updateProfileState( QIconViewItem * IVI ) { - if( IVI == Profiles_IV->currentItem() ) { - SLOT_ShowNode( IVI ); +void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { + if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { + SLOT_ShowNode( LBI ); } } void NetworkSettings::SLOT_GenerateConfig( void ) { QString S = NSD.generateSettings( TRUE ); if( ! S.isEmpty() ) { QMessageBox::warning( 0, tr( "Generating system configuration" ), S ); } } void NetworkSettings::SLOT_Enable( void ) { - QIconViewItem * IVI = Profiles_IV->currentItem(); + QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); QString Msg; - if ( ! IVI ) + if ( ! LBI ) return; NodeCollection * NC = - NSResources->findConnection( IVI->text() ); + NSResources->findConnection( LBI->text() ); bool rv; switch( NC->state() ) { case Disabled : Msg = tr( "Cannot enable profile" ); rv = NC->setState( Enable ); break; default : Msg = tr( "Cannot disable profile" ); rv = NC->setState( Disable ); break; } if( ! rv ) { QMessageBox::warning( 0, tr( "Activating profile" ), Msg ); return; } - updateProfileState( IVI ); + updateProfileState( LBI ); } void NetworkSettings::SLOT_On( void ) { - QIconViewItem * IVI = Profiles_IV->currentItem(); + QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); - if ( ! IVI ) + if ( ! LBI ) return; NodeCollection * NC = - NSResources->findConnection( IVI->text() ); + NSResources->findConnection( LBI->text() ); bool rv; switch( NC->state() ) { case Off : // activate interface rv = NC->setState( Activate ); break; case Available : // deactivate rv = NC->setState( Deactivate ); break; case IsUp : // bring down and deactivate rv = ( NC->setState( Down ) && NC->setState( Deactivate ) ); break; default : // others no change return; } if( ! rv ) { QMessageBox::warning( 0, tr( "Activating profile" ), tr( "Cannot enable profile" ) ); return; } - updateProfileState( IVI ); + updateProfileState( LBI ); } void NetworkSettings::SLOT_Connect( void ) { - QIconViewItem * IVI = Profiles_IV->currentItem(); + QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); - if ( ! IVI ) + if ( ! LBI ) return; NodeCollection * NC = - NSResources->findConnection( IVI->text() ); + NSResources->findConnection( LBI->text() ); bool rv; switch( NC->state() ) { case IsUp : // down interface rv = NC->setState( Down ); break; case Available : // up interface rv = NC->setState( Up ); break; case Off : // activate and bring up rv = ( NC->setState( Activate ) && NC->setState( Up ) ); break; default : // others no change return; } if( ! rv ) { QMessageBox::warning( 0, tr( "Activating profile" ), tr( "Cannot enable profile" ) ); return; } // we do not update the GUI but wait for the REAL upping of the device } void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if( msg == "raise" ) { raise(); return; } /* if ( msg == "someMessage(int,int,int)" ) { int a,b,c; stream >> a >> b >> c; ... } */ } diff --git a/noncore/settings/networksettings2/networksettings.h b/noncore/settings/networksettings2/networksettings.h index fadf81b..d9ea5d4 100644 --- a/noncore/settings/networksettings2/networksettings.h +++ b/noncore/settings/networksettings2/networksettings.h @@ -1,49 +1,49 @@ #include "nsdata.h" #include "networksettingsGUI.h" #include "resources.h" class ANetNode; class ANetNodeInstance; class QTimer; -class QIconViewItem; +class QListBoxItem; class NetworkSettings : public NetworkSettingsGUI { Q_OBJECT public : NetworkSettings( QWidget *parent=0, const char *name=0, WFlags fl = 0 ); ~NetworkSettings( void ); static QString appName( void ) { return QString::fromLatin1("networksettings"); } bool isModified( void ) { return NSD.isModified(); } void setModified( bool m ) { NSD.setModified( m ); } public slots : void SLOT_AddNode( void ); void SLOT_DeleteNode( void ); - void SLOT_ShowNode( QIconViewItem * ); - void SLOT_EditNode( QIconViewItem * ); + void SLOT_ShowNode( QListBoxItem * ); + void SLOT_EditNode( QListBoxItem * ); void SLOT_CheckState( void ); void SLOT_Enable( void ); void SLOT_On( void ); void SLOT_Connect( void ); void SLOT_GenerateConfig( void ); void SLOT_RefreshStates( void ); void SLOT_QCopMessage( const QCString&,const QByteArray& ); private : - void updateProfileState( QIconViewItem * it ); + void updateProfileState( QListBoxItem * it ); QTimer * UpdateTimer; NetworkSettingsData NSD; }; diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index d36a1e5..f040c99 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp @@ -43,260 +43,260 @@ QString quote( QString X ) { X = OutString; } return X; } // // // // // long ANetNodeInstance::InstanceCounter = -1; void ANetNodeInstance::initialize( void ) { if( InstanceCounter == -1 ) InstanceCounter = time(0); // set name QString N; N.sprintf( "-%ld", InstanceCounter++ ); N.prepend( NodeType->nodeName() ); setNodeName( N ); } void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ if( Attr == "name" ) { NodeName = Value; } else { setSpecificAttribute( Attr, Value ); } } void ANetNodeInstance::saveAttributes( QTextStream & TS ) { TS << "name=" << quote( NodeName ) << endl; saveSpecificAttribute( TS ); } ANetNodeInstance * ANetNodeInstance::nextNode( void ) { return connection()->findNext( this ); } // // // // // long NodeCollection::MaxNr = -1; NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { IsModified = 0; Index = -1; Name=""; IsNew = 1; CurrentState = Unchecked; } NodeCollection::NodeCollection( QTextStream & TS ) : QList<ANetNodeInstance>() { long idx; bool InError = 0; QString S, A, N; IsModified = 0; Index = -1; Name=""; IsNew = 0; CurrentState = Unchecked; do { S = TS.readLine(); if( S.isEmpty() ) { if( InError ) { // remove all nodes clear(); } // empty line break; } idx = S.find('='); S.stripWhiteSpace(); A = S.left( idx ); A.lower(); N = S.mid( idx+1, S.length() ); N.stripWhiteSpace(); N = deQuote( N ); if( A == "name" ) { Name = N; } else if( A == "number" ) { setNumber( N.toLong() ); } else if( A == "node" ) { ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); if( NNI && ! InError ) { append( NSResources->findNodeInstance( N ) ); } else { // could not find a node type -> collection invalid InError = 1; } } } while( 1 ); } NodeCollection::~NodeCollection( void ) { } const QString & NodeCollection::description( void ) { ANetNodeInstance * NNI = getToplevel(); return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; } void NodeCollection::append( ANetNodeInstance * NNI ) { NNI->setConnection( this ); QList<ANetNodeInstance>::append( NNI ); } void NodeCollection::save( QTextStream & TS ) { TS << "name=" << quote( Name ) << endl; TS << "number=" << number() << endl; ANetNodeInstance * NNI; for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { NNI = it.current(); TS << "node=" << quote( NNI->nodeName() ) << endl; } TS << endl; IsNew = 0; } ANetNodeInstance * NodeCollection::getToplevel( void ) { ANetNodeInstance * NNI = 0; for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { NNI = it.current(); if( NNI->netNode()->isToplevel() ) break; } return NNI; } ANetNodeInstance * NodeCollection::findByName( const QString & S ) { ANetNodeInstance * NNI = 0; for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { NNI = it.current(); if( NNI->name() == S ) break; } return NNI; } ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { ANetNodeInstance * NNNI; if( ! NNI ) getToplevel(); for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { NNNI = it.current(); if( NNNI == NNI ) { ++it; return it.current(); } } return 0; // no more next } int NodeCollection::compareItems( QCollection::Item I1, QCollection::Item I2 ) { ANetNodeInstance * NNI1, * NNI2; NNI1 = (ANetNodeInstance *)I1; NNI2 = (ANetNodeInstance *)I2; return NNI1->nodeName().compare( NNI2->nodeName() ); } static char * State2PixmapTbl[] = { "NULL", // Unchecked : no pixmap "check", // Unknown "delete", // unavailable "disabled", // disabled "off", // off "disconnected", // available "connected" // up }; QPixmap NodeCollection::devicePixmap( void ) { - return NSResources->getPixmap( - device()->netNode()->pixmapName()+"-large" ); + return NSResources->getPixmap( + device()->netNode()->pixmapName()+"-large" ); } QPixmap NodeCollection::statePixmap( State_t S) { return NSResources->getPixmap( State2PixmapTbl[S] ); } QString NodeCollection::stateName( State_t S) { switch( S ) { case Unknown : return qApp->translate( "networksettings2", "Unknown"); case Unavailable : return qApp->translate( "networksettings2", "Unavailable"); case Disabled : return qApp->translate( "networksettings2", "Disabled"); case Off : return qApp->translate( "networksettings2", "Off"); case Available : return qApp->translate( "networksettings2", "Available"); case IsUp : return qApp->translate( "networksettings2", "IsUp"); case Unchecked : /* FT */ default : break; } return QString(""); } void NodeCollection::reassign( void ) { for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { it.current()->setConnection( this ); } } InterfaceInfo * RuntimeInfo::assignedInterface( void ) { return netNode()->nextNode()->runtime()->assignedInterface(); } AsDevice * RuntimeInfo::device( void ) { return netNode()->nextNode()->runtime()->device(); } ANetNodeInstance * FakeNetNode::createInstance( void ) { return new FakeNetNodeInstance( this ); } void FakeNetNodeInstance::setSpecificAttribute( QString & A, QString & V ) { ValAttrPairs.insert( A, new QString(V) ); } void FakeNetNodeInstance::saveSpecificAttribute( QTextStream &TS ) { for( QDictIterator<QString> it( ValAttrPairs ); it.current(); ++ it ) { TS << it.currentKey().latin1() << "=" << quote( *(it.current())) << endl ; ++it; } } // collects all info that no plugin acceps FakeNetNode * FakeNode = 0; diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index 15e1b64..0301361 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp @@ -1,231 +1,234 @@ #include <qpixmap.h> #include <qpe/qlibrary.h> #include <qpe/qpeapplication.h> #include <qdir.h> #include <opie2/odebug.h> #include <qtopia/resource.h> #include "netnode.h" #include "resources.h" #define PLUGINDIR "plugins/networksettings2" #define ICONDIR "/pics/networksettings2/" // single resources instance TheNSResources * _NSResources = 0; TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), ConnectionsMap() { _NSResources = this; // load available netnodes findAvailableNetNodes(QPEApplication::qpeDir() + PLUGINDIR ); // compile provides and needs lists { const char ** NeedsRun; QDictIterator<NetNode_t> 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<NetNode_t> InnerIt( AllNodeTypes ); InnerIt.current(); ++InnerIt ) { if( InnerIt.current() == OuterIt.current() ) // avoid recursive continue; const char * Provides = InnerIt.current()->NetNode->provides(); NeedsRun = OuterIt.current()->NetNode->needs(); for( ; *NeedsRun; NeedsRun ++ ) { if( strcmp( Provides, *NeedsRun ) == 0 ) { // inner provides what outer needs NNL.resize( NNL.size() + 1 ); NNL[NNL.size()-1] = InnerIt.current()->NetNode; Done = 1; // break from 2 loops break; } } } OuterIt.current()->NetNode->setAlternatives( NNLP ); } } // define Node types to Description map NodeTypeNameMap.insert( "device", tr( "Network Device" ) ); NodeTypeNameMap.insert( "line", tr( "Character device" ) ); NodeTypeNameMap.insert( "connection", tr( "IP Connection" ) ); NodeTypeNameMap.insert( "fullsetup", tr( "Connection Profile" ) ); NodeTypeDescriptionMap.insert( "device", tr( "<p>Devices that can handle IP packets</p>" ) ); NodeTypeDescriptionMap.insert( "line", tr( "<p>Devices that can handle single bytes</p>" ) ); NodeTypeDescriptionMap.insert( "connection", tr( "<p>Nodes that provide working IP connections</p>" ) ); NodeTypeDescriptionMap.insert( "fullsetup", tr( "<p>Fully configured connection profile</p>" ) ); // define system files addSystemFile( new SystemFile( "interfaces", "./interfaces" ) ); // get access to the system TheSystem = new System(); } TheNSResources::~TheNSResources( void ) { delete TheSystem; } /** * Load all modules that are found in the path * @param path a directory that is scaned for any plugins that can be loaded * and attempts to load them */ void TheNSResources::findAvailableNetNodes(const QString &path){ QDir d(path); if(!d.exists()) return; QString lang = ::getenv("LANG"); // Don't want sym links d.setFilter( QDir::Files | QDir::NoSymLinks ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi=it.current()) ) { if( fi->fileName().contains(".so")){ /* if loaded install translation */ if( loadNetNode(path + "/" + fi->fileName()) ) { QTranslator *trans = new QTranslator(qApp); QString fn = QPEApplication::qpeDir()+ "/i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+ ".qm"; if( trans->load( fn ) ) qApp->installTranslator( trans ); else delete trans; } } ++it; } } /** * Attempt to load a function and resolve a function. * @param pluginFileName - the name of the file in which to attempt to load * @param resolveString - function pointer to resolve * @return true of loading is successful */ bool TheNSResources::loadNetNode( const QString &pluginFileName, const QString &resolveString){ QLibrary *lib = new QLibrary(pluginFileName); void * res = lib->resolve(resolveString); if( ! res ){ delete lib; return 0; } GetNetNodeListFt_t getNetNodeList = (GetNetNodeListFt_t)res; // Try to get an object. QList<ANetNode> PNN; getNetNodeList( PNN ); if( PNN.isEmpty() ) { delete lib; return 0; } ANetNode * NNP; for( QListIterator<ANetNode> it(PNN); it.current(); ++it ) { NetNode_t * NN; NNP = it.current(); NN = new NetNode_t; NN->NetNode = NNP; NN->TheLibrary = lib; NN->NodeCountInLib = PNN.count(); // store mapping AllNodeTypes.insert( NN->NetNode->nodeName(), NN ); } return 1; } QPixmap TheNSResources::getPixmap( const QString & QS ) { - return Resource::loadPixmap( QString("networksettings2")+QS ); + QString S("networksettings2/"); + S += QS; + printf( " pixmap %s\n", S.latin1() ); + return Resource::loadPixmap( QString("networksettings2/")+QS ); } 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::addConnection( NodeCollection * NC ) { ANetNodeInstance * NNI; ConnectionsMap.insert( NC->name(), NC ); // add (new) nodes to NodeList for( QListIterator<ANetNodeInstance> it(*NC); it.current(); ++it ) { NNI = it.current(); if( findNodeInstance( NNI->nodeName() ) == 0 ) { // new item addNodeInstance( NNI ); } } } void TheNSResources::removeConnection( const QString & N ) { NodeCollection * NC = findConnection( N ); if( ! NC ) return; // delete netnodes in this connection ANetNodeInstance * NNI; for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) { removeNodeInstance( NNI->nodeName() ); } ConnectionsMap.remove( N ); } NodeCollection * TheNSResources::findConnection( const QString & S ) { return ConnectionsMap[ S ]; } void TheNSResources::renumberConnections( void ) { Name2Connection_t & M = NSResources->connections(); NodeCollection * NC; // for all connections NodeCollection::resetMaxNr(); for( QDictIterator<NodeCollection> it(M); it.current(); ++it ) { NC = it.current(); NC->setNumber( NC->maxConnectionNumber()+1 ); NC->setModified( 1 ); } } diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp index 99f642e..85dcd7d 100644 --- a/noncore/settings/networksettings2/networksettings2/system.cpp +++ b/noncore/settings/networksettings2/networksettings2/system.cpp @@ -125,194 +125,195 @@ void System::refreshStatistics( InterfaceInfo & I ) { 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]; 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) return; // read interfaces from /proc/dev/net // SIOCGIFCONF does not return ALL interfaces ???!? ProcDevNet = new QFile(PROCNETDEV); if( ! ProcDevNet->open(IO_ReadOnly) ) { delete ProcDevNet; ProcDevNet =0; 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 fprintf( stderr, "NEWNIC %s\n", NicName.latin1()); IFI = new InterfaceInfo; IFI->Name = line.left(loc); IFI->NetNode = 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 ) { fprintf( stderr, "%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 fprintf( stderr, "OLDNIC %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 = ""; } + fprintf( stderr, "NIC %s UP %d\n", NicName.latin1(), IFI->IsUp ); } } diff --git a/noncore/settings/networksettings2/networksettingsGUI.ui b/noncore/settings/networksettings2/networksettingsGUI.ui index d457c35..1d79123 100644 --- a/noncore/settings/networksettings2/networksettingsGUI.ui +++ b/noncore/settings/networksettings2/networksettingsGUI.ui @@ -1,598 +1,457 @@ <!DOCTYPE UI><UI> <class>NetworkSettingsGUI</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>NetworkSettingsGUI</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>403</width> + <width>399</width> <height>502</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Network Settings</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>2</number> + <number>0</number> </property> <widget> <class>QFrame</class> <property stdset="1"> <name>name</name> <cstring>Frame4</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</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> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>1</number> </property> <widget> <class>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>Add_TB</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>...</string> </property> </widget> <widget> <class>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>Delete_TB</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>...</string> </property> </widget> <widget> <class>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>CheckState_TB</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>...</string> </property> </widget> <widget> <class>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>GenConfig_TB</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>...</string> </property> </widget> <spacer> <property> <name>name</name> <cstring>Spacer1</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>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>On_TB</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>...</string> </property> <property stdset="1"> <name>toggleButton</name> <bool>true</bool> </property> <property stdset="1"> <name>toggleButton</name> <bool>true</bool> </property> </widget> <widget> <class>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>Enable_TB</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>...</string> </property> <property stdset="1"> <name>toggleButton</name> <bool>true</bool> </property> <property stdset="1"> <name>toggleButton</name> <bool>true</bool> </property> </widget> <widget> <class>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>Connect_TB</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>...</string> </property> <property stdset="1"> <name>toggleButton</name> <bool>true</bool> </property> <property stdset="1"> <name>toggleButton</name> <bool>true</bool> </property> </widget> </hbox> </widget> <widget> - <class>QIconView</class> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> - <item> - <property> - <name>text</name> - <string>New Item</string> - </property> - <property> - <name>pixmap</name> - <pixmap>image0</pixmap> - </property> - </item> + <class>QListBox</class> <property stdset="1"> <name>name</name> - <cstring>Profiles_IV</cstring> - </property> - <property stdset="1"> - <name>spacing</name> - <number>5</number> - </property> - <property stdset="1"> - <name>itemsMovable</name> - <bool>false</bool> - </property> - <property stdset="1"> - <name>showToolTips</name> - <bool>false</bool> + <cstring>Profiles_LB</cstring> </property> </widget> <widget> <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>CurProfile_GB</cstring> </property> <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> <name>title</name> <string></string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> <number>4</number> </property> <property stdset="1"> <name>spacing</name> <number>1</number> </property> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout3</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> <property stdset="1"> <name>name</name> <cstring>TextLabel2</cstring> </property> <property stdset="1"> <name>text</name> <string>State</string> </property> </widget> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>State_LBL</cstring> </property> <property stdset="1"> <name>text</name> <string>State</string> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> <spacer> <property> <name>name</name> <cstring>Spacer6</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> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>Description_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>5</hsizetype> <vsizetype>7</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>NoFrame</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Raised</enum> </property> <property stdset="1"> <name>text</name> <string></string> </property> <property stdset="1"> <name>alignment</name> <set>AlignTop|AlignLeft</set> </property> <property> <name>vAlign</name> </property> </widget> </vbox> </widget> </vbox> </widget> -<images> - <image> - <name>image0</name> - <data format="XPM.GZ" length="1347">789c7dd3c14ac4301405d07dbf22f4ed8a743ace0882f8098a4b415ca4c92475310a3a2e44fc777393a64df2dabed7452e1c6eb368778d787e7a10cdaefabac8cb9b126a909fa2d1dfe7f3cfcbebfd6f551fae857bf69dd8d75755dd0a251e3fde4f38933b53e707b10f518df18478e8b08803e271c21af1e6168b681165e7f688681055874594211a13a242347efc95da9688dad58946ca75e58d6be9e5ba0a46e92d351a952aa2d3b2495459989849f949546632b5688c32c65aeadde428ed0132da23306e4c5863f1ba017042738f6fc138a5fdbd0a135b2203ec7bca7b723022e23d19628601cb0d6f59e8612dce0c2b2641658fb5650b375a0795a2c2b8afcaaba4859ba852c4cda4364da9964daed64caa60c2475d9a590503c54d54d1d0a2096abb67541bf79955fc0debbfbbea1f81b84f0e</data> - </image> -</images> <connections> <connection> <sender>Add_TB</sender> <signal>clicked()</signal> <receiver>NetworkSettingsGUI</receiver> <slot>SLOT_AddNode()</slot> </connection> <connection> <sender>Delete_TB</sender> <signal>clicked()</signal> <receiver>NetworkSettingsGUI</receiver> <slot>SLOT_DeleteNode()</slot> </connection> <connection> <sender>CheckState_TB</sender> <signal>clicked()</signal> <receiver>NetworkSettingsGUI</receiver> <slot>SLOT_CheckState()</slot> </connection> <connection> <sender>Enable_TB</sender> <signal>clicked()</signal> <receiver>NetworkSettingsGUI</receiver> <slot>SLOT_Enable()</slot> </connection> <connection> <sender>Connect_TB</sender> <signal>clicked()</signal> <receiver>NetworkSettingsGUI</receiver> <slot>SLOT_Connect()</slot> </connection> <connection> <sender>On_TB</sender> <signal>clicked()</signal> <receiver>NetworkSettingsGUI</receiver> <slot>SLOT_On()</slot> </connection> <connection> <sender>GenConfig_TB</sender> <signal>clicked()</signal> <receiver>NetworkSettingsGUI</receiver> <slot>SLOT_GenerateConfig()</slot> </connection> <connection> - <sender>Profiles_IV</sender> - <signal>selectionChanged(QIconViewItem*)</signal> + <sender>Profiles_LB</sender> + <signal>clicked(QListBoxItem*)</signal> <receiver>NetworkSettingsGUI</receiver> - <slot>SLOT_ShowNode( QIconViewItem*)</slot> + <slot>SLOT_ShowNode( QListBoxItem*)</slot> </connection> <connection> - <sender>Profiles_IV</sender> - <signal>doubleClicked(QIconViewItem*)</signal> + <sender>Profiles_LB</sender> + <signal>currentChanged(QListBoxItem*)</signal> <receiver>NetworkSettingsGUI</receiver> - <slot>SLOT_EditNode( QIconViewItem*)</slot> + <slot>SLOT_ShowNode( QListBoxItem*)</slot> </connection> <connection> - <sender>Profiles_IV</sender> - <signal>currentChanged(QIconViewItem*)</signal> + <sender>Profiles_LB</sender> + <signal>doubleClicked(QListBoxItem*)</signal> <receiver>NetworkSettingsGUI</receiver> - <slot>SLOT_ShowNode( QIconViewItem*)</slot> + <slot>SLOT_EditNode( QListBoxItem *)</slot> </connection> <slot access="public">SLOT_AddNode()</slot> <slot access="public">SLOT_CheckState()</slot> <slot access="public">SLOT_Connect()</slot> <slot access="public">SLOT_DeleteNode()</slot> - <slot access="public">SLOT_EditNode( QIconViewItem*)</slot> + <slot access="public">SLOT_EditNode( QListBoxItem *)</slot> <slot access="public">SLOT_Enable()</slot> <slot access="public">SLOT_GenerateConfig()</slot> <slot access="public">SLOT_On()</slot> - <slot access="public">SLOT_ShowNode( QIconViewItem*)</slot> + <slot access="public">SLOT_ShowNode( QListBoxItem*)</slot> </connections> </UI> diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index 9b2ad3a..3f5e958 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp @@ -1,213 +1,214 @@ #include <stdlib.h> #include <qpe/qpeapplication.h> #include <qtextstream.h> #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> #include "nsdata.h" #include <asdevice.h> #include <resources.h> static QString CfgFile; NetworkSettingsData::NetworkSettingsData( void ) { // init global resources structure new TheNSResources(); CfgFile.sprintf( "%s/NETCONFIG", getenv("HOME") ); // load settings Force = 0; + IsModified = 0; loadSettings(); } // saving is done by caller NetworkSettingsData::~NetworkSettingsData( void ) { delete NSResources; } void NetworkSettingsData::loadSettings( void ) { QString S; ANetNodeInstance* NNI; QString Attr, Value; long idx; QFile F( CfgFile ); QTextStream TS( &F ); do { if( ! F.open(IO_ReadOnly) ) break; /* load the file -> FORMAT : [NETNODETYPE] Entries ... <EMPTYLINE> [connection] Name=Name Node=Name <EMPTYLINE> */ while( ! TS.atEnd() ) { S = TS.readLine(); if ( S.isEmpty() || S[0] != '[' ) continue; S = S.mid( 1, S.length()-2 ); if( ! NSResources ) { continue; } if( S == "connection" ) { // load connections -> collections of nodes NodeCollection * NC = new NodeCollection( TS ); NSResources->addConnection( NC ); } else { // load nodes NNI = NSResources->createNodeInstance( S ); if( ! NNI ) { printf( "SKIPPING %s\n", S.latin1() ); } do { S = TS.readLine(); if( S.isEmpty() ) { // empty line break; } // node found ? if( NNI ) { idx = S.find( '=' ); if( idx > 0 ) { Attr = S.left( idx ); Value = S.mid( idx+1, S.length() ); } else { Value=""; Attr = S; } Value.stripWhiteSpace(); Attr.stripWhiteSpace(); Attr.lower(); // dequote Attr Value = deQuote(Value); // set the attribute NNI->setAttribute( Attr, Value ); } } while( 1 ); if( NNI ) { // loading from file -> exists NNI->setNew( FALSE ); NSResources->addNodeInstance( NNI ); } } } } while( 0 ); } QString NetworkSettingsData::saveSettings( void ) { QString ErrS = ""; if( ! isModified() ) return ErrS; QString S; QFile F( CfgFile + ".bup" ); printf( "Saving settings to %s\n", CfgFile.latin1() ); if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { ErrS = qApp->translate( "NetworkSettings", "<p>Could not save setup to %1 !</p>" ). arg(CfgFile); // problem return ErrS; } QTextStream TS( &F ); { Name2Connection_t & M = NSResources->connections(); ANetNodeInstance * NNI; // for all connections for( QDictIterator<NodeCollection> it(M); it.current(); ++it ) { // all nodes in those connections for( QListIterator<ANetNodeInstance> nit(*(it.current())); nit.current(); ++nit ) { // header NNI = nit.current(); TS << '[' <<NNI->netNode()->nodeName() << ']' << endl; NNI->saveAttributes( TS ); TS << endl; } TS << "[connection]" << endl; it.current()->save(TS); } } QDir D("."); D.rename( CfgFile + ".bup", CfgFile ); // // proper files AND system files regenerated // setModified( 0 ); return ErrS; } QString NetworkSettingsData::generateSettings( bool ForceReq ) { bool ForceIt; QString S = ""; // include own force flag ForceIt = (Force) ? 1 : ForceReq; if( ! ForceIt && ! isModified() ) return S; // regenerate system files printf( "Generating settings from %s\n", CfgFile.latin1() ); { Name2SystemFile_t & SFM = NSResources->systemFiles(); Name2Connection_t & M = NSResources->connections(); NodeCollection * NC; ANetNodeInstance * NNI; SystemFile * SF; bool needToRegenerate = ForceIt; // // check if we need to generate at least one of the system files // if( ! ForceIt ) { for( QDictIterator<SystemFile> sfit(SFM); sfit.current(); ++sfit ) { SF = sfit.current(); // check if there are nodes that are modified and require // data for this system file // for all connections for( QDictIterator<NodeCollection> ncit(M); ncit.current(); ++ncit ) { NC = ncit.current(); if( NC->isModified() ) { // does this connection 'touch' this system file ? for( QListIterator<ANetNodeInstance> cncit(*NC); cncit.current(); diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h index a933523..3f9a338 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.h +++ b/noncore/settings/networksettings2/ppp/ppp_NN.h @@ -1,44 +1,44 @@ #ifndef PPP_NETNODE_H #define PPP_NETNODE_H #include "netnode.h" class APPP; class PPPNetNode : public ANetNode{ Q_OBJECT public: PPPNetNode(); virtual ~PPPNetNode(); virtual const QString pixmapName() - { return "ppp"; } + { return "Devices/ppp"; } virtual const QString nodeName() { return tr("PPP Connection"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h index 08dca1d..a17721a 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.h +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h @@ -1,43 +1,43 @@ #ifndef PPP_H #define PPP_H #include <netnode.h> #include "pppdata.h" #include "ppprun.h" class PPPNetNode; class PPPEdit; class APPP : public ANetNodeInstance { public : APPP( PPPNetNode * PNN ); QWidget * edit( QWidget * parent ); QString acceptable( void ); void commit( void ); RuntimeInfo * runtime( void ) { if( RT == 0 ) RT = new PPPRun( this, Data ); - return RT; + return RT->runtimeInfo(); } virtual void * data( void ) { return (void *)&Data; } protected : virtual void setSpecificAttribute( QString & Attr, QString & Value ); virtual void saveSpecificAttribute( QTextStream & TS ); private : PPPEdit * GUI; PPPData Data; PPPRun * RT; }; #endif diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp index 8933f85..4ac0c5a 100644 --- a/noncore/settings/networksettings2/ppp/ppprun.cpp +++ b/noncore/settings/networksettings2/ppp/ppprun.cpp @@ -1,77 +1,90 @@ #include <resources.h> #include "ppprun.h" +PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) : + AsConnection( NNI ), AsDevice( NNI ), Pat( "eth[0-9]" ) { + D = &Data; +} + void PPPRun::detectState( NodeCollection * NC ) { if( isMyPPPDRunning( ) ) { if( isMyPPPUp() ) { NC->setCurrentState( IsUp ); } else { NC->setCurrentState( Available ); } } else { NC->setCurrentState( Off ); // at least this // but could also be unavailable - netNode()->nextNode()->runtime()->detectState( NC ); + ANetNodeInstance * NNI; + RuntimeInfo * RI; + NNI = AsDevice::netNode(); + printf( "%p\n", NNI ); + NNI = NNI->nextNode(); + printf( "%p\n", NNI ); + RI = NNI->runtime(); + printf( "%p\n", RI ); + RI->detectState( NC ); } } bool PPPRun::setState( NodeCollection * NC, Action_t A ) { switch( A ) { case Activate : NC->setCurrentState( Available ); // no break; case Deactivate : if( NC->currentState() == IsUp ) { NC->state( Down ); } // cannot really disable NC->setCurrentState( Available ); break; case Up : if( NC->currentState() != IsUp ) { // start my PPPD NC->setCurrentState( IsUp ); } break; case Down : if( NC->currentState() == IsUp ) { // stop my PPPD NC->setCurrentState( Available ); } break; default : // FT break; } return 1; } bool PPPRun::isMyPPPDRunning( void ) { return 0; } bool PPPRun::isMyPPPUp( void ) { System & S = NSResources->system(); - InterfaceInfo * best = 0, * Run; + InterfaceInfo * Run; QRegExp R( "ppp[0-9]" ); for( QDictIterator<InterfaceInfo> It(S.interfaces()); It.current(); ++It ) { Run = It.current(); if( R.match( Run->Name ) >= 0 && Run->IsPointToPoint ) { // this is a LAN card - if( Run->assignedNode() == netNode() ) { + if( Run->assignedNode() == AsDevice::netNode() ) { // assigned to us return 1; } } } return 0; } bool PPPRun::handlesInterface( const QString & S ) { return Pat.match( S ) >= 0; } diff --git a/noncore/settings/networksettings2/ppp/ppprun.h b/noncore/settings/networksettings2/ppp/ppprun.h index 76a05be..abb9176 100644 --- a/noncore/settings/networksettings2/ppp/ppprun.h +++ b/noncore/settings/networksettings2/ppp/ppprun.h @@ -1,37 +1,43 @@ #ifndef PPPRUN_H #define PPPRUN_H #include <qregexp.h> #include <asconnection.h> +#include <asdevice.h> #include "pppdata.h" -class PPPRun : public AsConnection { +class PPPRun : public AsConnection, public AsDevice { public : PPPRun( ANetNodeInstance * NNI, - PPPData & Data ) : - AsConnection( NNI ), - Pat( "eth[0-9]" ) - { D = &Data; } + PPPData & Data ); + virtual QString genNic( long NicNr ) + { QString S; return S.sprintf( "ppp%ld", NicNr ); } -protected : + virtual AsDevice * device( void ) + { return AsDevice::asDevice(); } + virtual RuntimeInfo * runtimeInfo( void ) + { return ( AsConnection *)this; } + + protected : void detectState( NodeCollection * NC ); bool setState( NodeCollection * NC, Action_t A ); bool canSetState( State_t S, Action_t A ) - { return connection()->findNext( netNode() )->runtime()->canSetState( S,A ); } + { return AsDevice::connection()->findNext( + AsDevice::netNode() )->runtime()->canSetState( S,A ); } bool handlesInterface( const QString & I ); private : bool isMyPPPDRunning( void ); bool isMyPPPUp( void ); PPPData_t * D; QRegExp Pat; }; #endif diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h index 2b469c7..3c06947 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.h +++ b/noncore/settings/networksettings2/profile/profile_NN.h @@ -1,44 +1,44 @@ #ifndef PROFILE_NETNODE_H #define PROFILE_NETNODE_H #include "netnode.h" class AProfile; class ProfileNetNode : public ANetNode{ Q_OBJECT public: ProfileNetNode(); virtual ~ProfileNetNode(); virtual const QString pixmapName() - { return "commprofile"; } + { return "Devices/commprofile"; } virtual const QString nodeName() { return tr("Regular profile"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h index 3871afc..8b97452 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.h +++ b/noncore/settings/networksettings2/usb/usb_NN.h @@ -1,44 +1,44 @@ #ifndef USB_NETNODE_H #define USB_NETNODE_H #include "netnode.h" class AUSB; class USBNetNode : public ANetNode{ Q_OBJECT public: USBNetNode(); virtual ~USBNetNode(); virtual const QString pixmapName() - { return "usb"; } + { return "Devices/usb"; } virtual const QString nodeName() { return tr("USB Cable Connect"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h index 5718961..a113ab9 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.h +++ b/noncore/settings/networksettings2/vpn/vpn_NN.h @@ -1,44 +1,44 @@ #ifndef VPN_NETNODE_H #define VPN_NETNODE_H #include "netnode.h" class AVPN; class VPNNetNode : public ANetNode{ Q_OBJECT public: VPNNetNode(); virtual ~VPNNetNode(); virtual const QString pixmapName() - { return "vpn"; } + { return "Devices/vpn"; } virtual const QString nodeName() { return tr("VPN Connection"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h index d1d6ded..0728a79 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.h +++ b/noncore/settings/networksettings2/wlan/wlan_NN.h @@ -1,44 +1,44 @@ #ifndef WLAN_NETNODE_H #define WLAN_NETNODE_H #include "netnode.h" class AWLan; class WLanNetNode : public ANetNode{ Q_OBJECT public: WLanNetNode(); virtual ~WLanNetNode(); virtual const QString pixmapName() - { return "wlan"; } + { return "Devices/wlan"; } virtual const QString nodeName() { return tr("WLan Device"); } virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); virtual const char * provides( void ); virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); virtual bool hasDataFor( const QString & S ); virtual bool generateDataForCommonFile( SystemFile & SF, long DevNr, ANetNodeInstance * NNI ); private: }; extern "C" { void create_plugin( QList<ANetNode> & PNN ); }; #endif |