author | wimpie <wimpie> | 2004-04-10 13:06:13 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-10 13:06:13 (UTC) |
commit | db9f0e2a7fd93157d95f421534fcc3015abe53e0 (patch) (side-by-side diff) | |
tree | 001918ca18d0d74f3e49597f766c070bea71e25c | |
parent | 6bcdc8cd41199dce849b800b4296011faf6281df (diff) | |
download | opie-db9f0e2a7fd93157d95f421534fcc3015abe53e0.zip opie-db9f0e2a7fd93157d95f421534fcc3015abe53e0.tar.gz opie-db9f0e2a7fd93157d95f421534fcc3015abe53e0.tar.bz2 |
*** empty log message ***
34 files changed, 957 insertions, 293 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h index 4a773cd..c168429 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h @@ -22,3 +22,3 @@ protected : - bool setState( NodeCollection * , Action_t ) + bool setState( NodeCollection * , Action_t, bool ) { return 0; } diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h index 6a7902a..aff1f59 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h @@ -19,3 +19,3 @@ protected : - bool setState( NodeCollection * , Action_t ) + bool setState( NodeCollection * , Action_t, bool ) { return 0; } diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp index edb4b01..5e99237 100644 --- a/noncore/settings/networksettings2/cable/cablerun.cpp +++ b/noncore/settings/networksettings2/cable/cablerun.cpp @@ -15,3 +15,3 @@ void CableRun::detectState( NodeCollection * NC ) { -bool CableRun::setState( NodeCollection * NC, Action_t A ) { +bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) { if( A == Activate ) { diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h index 7b341c4..c5b59d5 100644 --- a/noncore/settings/networksettings2/cable/cablerun.h +++ b/noncore/settings/networksettings2/cable/cablerun.h @@ -17,3 +17,3 @@ protected : void detectState( NodeCollection * NC ); - bool setState( NodeCollection * NC, Action_t A ); + bool setState( NodeCollection * NC, Action_t A, bool Force ); bool canSetState( State_t Curr, Action_t A ); diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h index d9fe5e8..4c903cc 100644 --- a/noncore/settings/networksettings2/irda/irdarun.h +++ b/noncore/settings/networksettings2/irda/irdarun.h @@ -19,3 +19,3 @@ protected : - bool setState( NodeCollection * , Action_t ) + bool setState( NodeCollection * , Action_t, bool ) { return 0; } diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp index 2e4fc43..1544ddc 100644 --- a/noncore/settings/networksettings2/lancard/lancardrun.cpp +++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp @@ -75,3 +75,3 @@ void LanCardRun::detectState( NodeCollection * NC ) { -bool LanCardRun::setState( NodeCollection * NC, Action_t A ) { +bool LanCardRun::setState( NodeCollection * NC, Action_t A, bool ) { diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h index e8a535a..b28dda7 100644 --- a/noncore/settings/networksettings2/lancard/lancardrun.h +++ b/noncore/settings/networksettings2/lancard/lancardrun.h @@ -25,3 +25,3 @@ protected : void detectState( NodeCollection * NC ); - bool setState( NodeCollection * NC, Action_t A ); + bool setState( NodeCollection * NC, Action_t A, bool Force ); bool canSetState( State_t Curr, Action_t A ); diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h index 6d1662b..336462e 100644 --- a/noncore/settings/networksettings2/modem/modemrun.h +++ b/noncore/settings/networksettings2/modem/modemrun.h @@ -19,3 +19,3 @@ protected : - bool setState( NodeCollection *, Action_t ) + bool setState( NodeCollection *, Action_t, bool ) { return 0; } diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index c19235a..41e1c53 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp @@ -19,3 +19,3 @@ void NetworkRun::detectState( NodeCollection * NC ) { -bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { +bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { // we handle UP and DOWN @@ -27,3 +27,3 @@ bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { // we can bring UP if lower level is available - if( NC->currentState() == Available ) { + if( NC->currentState() == Available || Force ) { QString S; @@ -36,3 +36,3 @@ bool NetworkRun::setState( NodeCollection * NC, Action_t A ) { } else if( A == Down ) { - if( NC->currentState() == IsUp ) { + if( NC->currentState() == IsUp || Force ) { QString S; diff --git a/noncore/settings/networksettings2/network/networkrun.h b/noncore/settings/networksettings2/network/networkrun.h index fa16365..522a912 100644 --- a/noncore/settings/networksettings2/network/networkrun.h +++ b/noncore/settings/networksettings2/network/networkrun.h @@ -17,3 +17,3 @@ protected : void detectState( NodeCollection * ); - bool setState( NodeCollection * ,Action_t A ); + bool setState( NodeCollection * ,Action_t A, bool ); bool canSetState( State_t , Action_t A ); diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index 3ddcbde..b36c7a0 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp @@ -25,2 +25,3 @@ NetworkSettings::NetworkSettings( QWidget *parent, UpdateTimer = new QTimer( this ); + // set pixmaps @@ -33,2 +34,3 @@ NetworkSettings::NetworkSettings( QWidget *parent, Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); + Disconnect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); @@ -36,2 +38,4 @@ NetworkSettings::NetworkSettings( QWidget *parent, + SLOT_ToProfile(); + // populate main Listbox @@ -278,3 +282,3 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { - CurProfile_GB->setTitle( LBI->text() ); + Profile_GB->setTitle( LBI->text() ); State_LBL->setText( NC->stateName() ); @@ -411,2 +415,24 @@ void NetworkSettings::SLOT_Connect( void ) { +void NetworkSettings::SLOT_Disconnect( void ) { + QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); + + if ( ! LBI ) + return; + + NodeCollection * NC = + NSResources->findConnection( LBI->text() ); + + NC->setState( Down, 1 ); +} + +void NetworkSettings::SLOT_ToMessages( void ) { + Profile_GB->hide(); + Messages_GB->show(); +} + +void NetworkSettings::SLOT_ToProfile( void ) { + Profile_GB->show(); + Messages_GB->hide(); +} + void NetworkSettings::SLOT_QCopMessage(const QCString &msg, const QByteArray &data) { diff --git a/noncore/settings/networksettings2/networksettings.h b/noncore/settings/networksettings2/networksettings.h index d9ea5d4..97852af 100644 --- a/noncore/settings/networksettings2/networksettings.h +++ b/noncore/settings/networksettings2/networksettings.h @@ -38,2 +38,3 @@ public slots : void SLOT_Connect( void ); + void SLOT_Disconnect( void ); void SLOT_GenerateConfig( void ); @@ -41,2 +42,4 @@ public slots : void SLOT_QCopMessage( const QCString&,const QByteArray& ); + void SLOT_ToProfile( void ); + void SLOT_ToMessages( void ); diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index dc66aff..1182543 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp @@ -1,3 +1,5 @@ -#include <qpe/qpeapplication.h> #include <time.h> +#include <qpe/qpeapplication.h> +#include <qpainter.h> +#include <qbitmap.h> #include <qtextstream.h> @@ -249,4 +251,13 @@ static char * State2PixmapTbl[] = { QPixmap NodeCollection::devicePixmap( void ) { - return NSResources->getPixmap( - device()->netNode()->pixmapName()+"-large" ); + QPixmap pm = NSResources->getPixmap( + getToplevel()->nextNode()->pixmapName()+"-large"); + + QPixmap Mini = NSResources->getPixmap( device()->netNode()->pixmapName() ); + + QPainter painter( &pm ); + painter.drawPixmap( pm.width()-Mini.width(), + pm.height()-Mini.height(), + Mini ); + pm.setMask( pm.createHeuristicMask( TRUE ) ); + return pm; } diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index 27d54f8..5e36062 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h @@ -260,3 +260,3 @@ public : virtual void detectState( NodeCollection * NC ) = 0; - virtual bool setState( NodeCollection * NC, Action_t A ) = 0; + virtual bool setState( NodeCollection * NC, Action_t A, bool Force = 0 ) = 0; virtual bool canSetState( State_t Curr, Action_t A ) = 0; @@ -324,4 +324,4 @@ public : - bool setState( Action_t A ) - { return getToplevel()->runtime()->setState( this, A ); } + bool setState( Action_t A, bool Force =0 ) + { return getToplevel()->runtime()->setState( this, A, Force ); } bool canSetState( Action_t A ) diff --git a/noncore/settings/networksettings2/networksettings2/networksettings2.pro b/noncore/settings/networksettings2/networksettings2/networksettings2.pro index 11b5f84..f97c93b 100644 --- a/noncore/settings/networksettings2/networksettings2/networksettings2.pro +++ b/noncore/settings/networksettings2/networksettings2/networksettings2.pro @@ -12,2 +12,3 @@ HEADERS = netnode.h \ systemfile.h \ + wextensions.h \ asdevice.h @@ -17,2 +18,3 @@ SOURCES = netnode.cpp \ systemfile.cpp \ + wextensions.cpp \ resources.cpp diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index 4b7a62f..c95ac7f 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp @@ -179,3 +179,4 @@ QPixmap TheNSResources::getPixmap( const QString & QS ) { S += QS; - return Resource::loadPixmap( QString("networksettings2/")+QS ); + fprintf( stderr, "%s\n", S.latin1() ); + return Resource::loadPixmap( S ); } diff --git a/noncore/settings/networksettings2/networksettingsGUI.ui b/noncore/settings/networksettings2/networksettingsGUI.ui index 1d79123..7ef2f64 100644 --- a/noncore/settings/networksettings2/networksettingsGUI.ui +++ b/noncore/settings/networksettings2/networksettingsGUI.ui @@ -13,4 +13,4 @@ <y>0</y> - <width>399</width> - <height>502</height> + <width>160</width> + <height>260</height> </rect> @@ -34,3 +34,3 @@ <name>spacing</name> - <number>0</number> + <number>2</number> </property> @@ -169,3 +169,3 @@ <name>name</name> - <cstring>On_TB</cstring> + <cstring>Enable_TB</cstring> </property> @@ -195,3 +195,3 @@ <name>name</name> - <cstring>Enable_TB</cstring> + <cstring>On_TB</cstring> </property> @@ -243,2 +243,28 @@ </widget> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Disconnect_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> @@ -256,10 +282,3 @@ <name>name</name> - <cstring>CurProfile_GB</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>1</vsizetype> - </sizepolicy> + <cstring>Profile_GB</cstring> </property> @@ -267,3 +286,3 @@ <name>title</name> - <string></string> + <string>Profile</string> </property> @@ -282,3 +301,3 @@ <name>spacing</name> - <number>1</number> + <number>2</number> </property> @@ -303,3 +322,3 @@ <name>name</name> - <cstring>TextLabel2</cstring> + <cstring>TextLabel2_2</cstring> </property> @@ -328,3 +347,3 @@ <name>name</name> - <cstring>Spacer6</cstring> + <cstring>Spacer6_2</cstring> </property> @@ -381,2 +400,141 @@ </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <spacer> + <property> + <name>name</name> + <cstring>Spacer4</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>ToMessages_BUT</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Messages ...</string> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + <widget> + <class>QGroupBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Messages_GB</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Messages</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>2</number> + </property> + <widget> + <class>QListBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Mesages_LB</cstring> + </property> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout2</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <spacer> + <property> + <name>name</name> + <cstring>Spacer3</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>ToProfile_BUT</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Profile ...</string> + </property> + </widget> + </hbox> + </widget> </vbox> @@ -446,2 +604,14 @@ </connection> + <connection> + <sender>ToProfile_BUT</sender> + <signal>clicked()</signal> + <receiver>NetworkSettingsGUI</receiver> + <slot>SLOT_ToProfile()</slot> + </connection> + <connection> + <sender>ToMessages_BUT</sender> + <signal>clicked()</signal> + <receiver>NetworkSettingsGUI</receiver> + <slot>SLOT_ToMessages()</slot> + </connection> <slot access="public">SLOT_AddNode()</slot> @@ -455,2 +625,5 @@ <slot access="public">SLOT_ShowNode( QListBoxItem*)</slot> + <slot access="public">SLOT_ToMessages()</slot> + <slot access="public">SLOT_ToProfile()</slot> + <slot access="public">SLOT_Disconnect()</slot> </connections> diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp index 8c75df3..a8abc50 100644 --- a/noncore/settings/networksettings2/ppp/ppprun.cpp +++ b/noncore/settings/networksettings2/ppp/ppprun.cpp @@ -22,3 +22,3 @@ void PPPRun::detectState( NodeCollection * NC ) { -bool PPPRun::setState( NodeCollection * NC, Action_t A ) { +bool PPPRun::setState( NodeCollection * NC, Action_t A, bool ) { switch( A ) { diff --git a/noncore/settings/networksettings2/ppp/ppprun.h b/noncore/settings/networksettings2/ppp/ppprun.h index af51fbe..90a3f25 100644 --- a/noncore/settings/networksettings2/ppp/ppprun.h +++ b/noncore/settings/networksettings2/ppp/ppprun.h @@ -29,3 +29,3 @@ public : void detectState( NodeCollection * NC ); - bool setState( NodeCollection * NC, Action_t A ); + bool setState( NodeCollection * NC, Action_t A, bool ); bool canSetState( State_t S, Action_t A ) diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp index 3f72c52..c9fb650 100644 --- a/noncore/settings/networksettings2/profile/profileedit.cpp +++ b/noncore/settings/networksettings2/profile/profileedit.cpp @@ -13,3 +13,3 @@ ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : - ProfileGUI( Parent ), TrafficRefresh(this) { + ProfileGUI( Parent ), RefreshTimer(this) { InterfaceInfo * II; @@ -19,2 +19,3 @@ ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : if( ( II = Dev->assignedInterface() ) ) { + Refresh_CB->setEnabled( TRUE ); @@ -23,2 +24,3 @@ ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : Collisions_FRM->setEnabled( TRUE ); + // show current content @@ -44,6 +46,7 @@ ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : InterfaceOptions_LBL->setText( S ); + + connect( &RefreshTimer, SIGNAL( timeout() ), + this, SLOT( SLOT_Refresh() ) ); } - connect( &TrafficRefresh, SIGNAL( timeout() ), - this, SLOT( SLOT_Refresh() ) ); } @@ -87,6 +90,6 @@ void ProfileEdit::SLOT_AutoRefresh( bool ar ) { if( ar ) { - TrafficRefresh.start( 1000 ); + RefreshTimer.start( 1000 ); SLOT_Refresh(); } else { - TrafficRefresh.stop(); + RefreshTimer.stop(); } diff --git a/noncore/settings/networksettings2/profile/profileedit.h b/noncore/settings/networksettings2/profile/profileedit.h index 8ca34be..b186b58 100644 --- a/noncore/settings/networksettings2/profile/profileedit.h +++ b/noncore/settings/networksettings2/profile/profileedit.h @@ -25,3 +25,3 @@ private : - QTimer TrafficRefresh; + QTimer RefreshTimer; ANetNodeInstance * NNI; diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp index feebf86..79bb93e 100644 --- a/noncore/settings/networksettings2/profile/profilerun.cpp +++ b/noncore/settings/networksettings2/profile/profilerun.cpp @@ -14,3 +14,3 @@ void ProfileRun::detectState( NodeCollection * NC ) { -bool ProfileRun::setState( NodeCollection * NC, Action_t A ) { +bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool ) { ANetNodeInstance * NNNI; diff --git a/noncore/settings/networksettings2/profile/profilerun.h b/noncore/settings/networksettings2/profile/profilerun.h index 6e8385c..c8ea063 100644 --- a/noncore/settings/networksettings2/profile/profilerun.h +++ b/noncore/settings/networksettings2/profile/profilerun.h @@ -15,3 +15,3 @@ public : void detectState( NodeCollection * NC ); - bool setState( NodeCollection * NC, Action_t A ); + bool setState( NodeCollection * NC, Action_t A, bool ); bool canSetState( State_t Curr, Action_t A ); diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index 4ce6721..beacd7b 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp @@ -77,3 +77,3 @@ void USBRun::detectState( NodeCollection * NC ) { -bool USBRun::setState( NodeCollection * NC, Action_t A ) { +bool USBRun::setState( NodeCollection * NC, Action_t A, bool ) { diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h index 6c6e4e4..03e21ab 100644 --- a/noncore/settings/networksettings2/usb/usbrun.h +++ b/noncore/settings/networksettings2/usb/usbrun.h @@ -25,3 +25,3 @@ protected : void detectState( NodeCollection * ); - bool setState( NodeCollection * , Action_t A ); + bool setState( NodeCollection * , Action_t A, bool ); bool canSetState( State_t , Action_t A ); diff --git a/noncore/settings/networksettings2/vpn/vpnrun.h b/noncore/settings/networksettings2/vpn/vpnrun.h index 4d26298..c19b609 100644 --- a/noncore/settings/networksettings2/vpn/vpnrun.h +++ b/noncore/settings/networksettings2/vpn/vpnrun.h @@ -21,3 +21,3 @@ protected : - bool setState( NodeCollection *, Action_t ) + bool setState( NodeCollection *, Action_t, bool ) { return 0; } diff --git a/noncore/settings/networksettings2/wlan/wlanGUI.ui b/noncore/settings/networksettings2/wlan/wlanGUI.ui index 9614369..1aec138 100644 --- a/noncore/settings/networksettings2/wlan/wlanGUI.ui +++ b/noncore/settings/networksettings2/wlan/wlanGUI.ui @@ -13,4 +13,4 @@ <y>0</y> - <width>192</width> - <height>329</height> + <width>209</width> + <height>307</height> </rect> @@ -34,3 +34,3 @@ <name>spacing</name> - <number>0</number> + <number>1</number> </property> @@ -75,6 +75,6 @@ <name>name</name> - <cstring>Layout6</cstring> + <cstring>Layout11</cstring> </property> <property> - <name>layoutMargin</name> + <name>layoutSpacing</name> </property> @@ -83,3 +83,3 @@ <name>margin</name> - <number>1</number> + <number>0</number> </property> @@ -87,9 +87,27 @@ <name>spacing</name> - <number>6</number> + <number>1</number> </property> - <widget row="1" column="0" > - <class>QLabel</class> + <widget row="0" column="1" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Auto</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Managed</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Ad-Hoc</string> + </property> + </item> <property stdset="1"> <name>name</name> - <cstring>essidLabel</cstring> + <cstring>Mode_CB</cstring> </property> @@ -103,31 +121,14 @@ <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> + <vsizetype>0</vsizetype> </sizepolicy> </property> - <property stdset="1"> - <name>text</name> - <string>ESS-ID</string> - </property> </widget> - <widget row="1" column="1" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>any</string> - </property> - </item> + <widget row="2" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>ESSID_CB</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>0</vsizetype> - </sizepolicy> + <cstring>essidLabel_2</cstring> </property> <property stdset="1"> - <name>editable</name> + <name>enabled</name> <bool>true</bool> @@ -135,16 +136,11 @@ <property stdset="1"> - <name>currentItem</name> - <number>0</number> - </property> - <property stdset="1"> - <name>sizeLimit</name> - <number>5</number> - </property> - <property stdset="1"> - <name>autoCompletion</name> - <bool>true</bool> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> </property> <property stdset="1"> - <name>duplicatesEnabled</name> - <bool>false</bool> + <name>text</name> + <string>Name</string> </property> @@ -173,31 +169,14 @@ </widget> - <widget row="0" column="1" > - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>Infrastructure</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Auto</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Managed</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Ad-Hoc</string> - </property> - </item> + <widget row="1" column="1" > + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>Mode_CB</cstring> + <cstring>ESSID_LE</cstring> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>essidLabel</cstring> </property> @@ -211,5 +190,20 @@ <hsizetype>1</hsizetype> - <vsizetype>0</vsizetype> + <vsizetype>1</vsizetype> </sizepolicy> </property> + <property stdset="1"> + <name>text</name> + <string>ESS-ID</string> + </property> + </widget> + <widget row="2" column="1" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>NodeName_LE</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string><UseHostName></string> + </property> </widget> @@ -246,3 +240,3 @@ <name>text</name> - <string>Specify &Access Point</string> + <string>Specify Access Point</string> </property> @@ -312,56 +306,2 @@ </widget> - <widget> - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout7</cstring> - </property> - <property> - <name>layoutMargin</name> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>1</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>SpecifyChannel_CB</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Specific &Channel</string> - </property> - </widget> - <widget> - <class>QSpinBox</class> - <property stdset="1"> - <name>name</name> - <cstring>ChannelNr_SB</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> - </property> - <property stdset="1"> - <name>maxValue</name> - <number>15</number> - </property> - <property stdset="1"> - <name>minValue</name> - <number>1</number> - </property> - <property stdset="1"> - <name>value</name> - <number>1</number> - </property> - </widget> - </hbox> - </widget> <spacer> @@ -412,3 +352,3 @@ <name>name</name> - <cstring>EnableWEB_CB</cstring> + <cstring>EnableWEP_CB</cstring> </property> @@ -513,2 +453,6 @@ </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> </widget> @@ -520,2 +464,6 @@ </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> </widget> @@ -527,2 +475,6 @@ </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> </widget> @@ -534,3 +486,3 @@ <name>name</name> - <cstring>CheckBox4</cstring> + <cstring>AcceptNonEncrypted_CB</cstring> </property> @@ -591,3 +543,3 @@ <name>name</name> - <cstring>Layout12</cstring> + <cstring>Layout13</cstring> </property> @@ -605,14 +557,3 @@ </property> - <widget row="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1_3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Station</string> - </property> - </widget> - <widget row="3" column="1" > + <widget row="4" column="1" > <class>QLabel</class> @@ -620,3 +561,3 @@ <name>name</name> - <cstring>Channel_LBL</cstring> + <cstring>Frequency_LBL</cstring> </property> @@ -624,3 +565,3 @@ <name>frameShape</name> - <enum>Panel</enum> + <enum>Box</enum> </property> @@ -635,13 +576,2 @@ </widget> - <widget row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel4_3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Channel</string> - </property> - </widget> <widget row="2" column="0" > @@ -650,3 +580,3 @@ <name>name</name> - <cstring>TextLabel3_3</cstring> + <cstring>TextLabel9_2</cstring> </property> @@ -654,6 +584,6 @@ <name>text</name> - <string>Mode</string> + <string>AP</string> </property> </widget> - <widget row="1" column="0" > + <widget row="5" column="1" > <class>QLabel</class> @@ -661,18 +591,15 @@ <name>name</name> - <cstring>TextLabel2_3</cstring> + <cstring>Channel_LBL</cstring> </property> <property stdset="1"> - <name>text</name> - <string>ESSID</string> + <name>frameShape</name> + <enum>Box</enum> </property> - </widget> - <widget row="4" column="0" > - <class>QLabel</class> <property stdset="1"> - <name>name</name> - <cstring>TextLabel9_2</cstring> + <name>frameShadow</name> + <enum>Plain</enum> </property> <property stdset="1"> - <name>text</name> - <string>AP</string> + <name>indent</name> + <number>0</number> </property> @@ -687,3 +614,3 @@ <name>frameShape</name> - <enum>Panel</enum> + <enum>Box</enum> </property> @@ -698,3 +625,14 @@ </widget> - <widget row="5" column="1" > + <widget row="6" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel4_2_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Rate</string> + </property> + </widget> + <widget row="6" column="1" > <class>QLabel</class> @@ -713,3 +651,3 @@ <name>frameShape</name> - <enum>Panel</enum> + <enum>Box</enum> </property> @@ -724,3 +662,3 @@ </widget> - <widget row="5" column="0" > + <widget row="2" column="1" > <class>QLabel</class> @@ -728,10 +666,18 @@ <name>name</name> - <cstring>TextLabel4_2_2</cstring> + <cstring>AP_LBL</cstring> </property> <property stdset="1"> - <name>text</name> - <string>Rate</string> + <name>frameShape</name> + <enum>Box</enum> + </property> + <property stdset="1"> + <name>frameShadow</name> + <enum>Plain</enum> + </property> + <property stdset="1"> + <name>indent</name> + <number>0</number> </property> </widget> - <widget row="4" column="1" > + <widget row="3" column="1" > <class>QLabel</class> @@ -739,3 +685,3 @@ <name>name</name> - <cstring>AP_LBL</cstring> + <cstring>Mode_LBL</cstring> </property> @@ -743,3 +689,3 @@ <name>frameShape</name> - <enum>Panel</enum> + <enum>Box</enum> </property> @@ -762,3 +708,3 @@ <name>frameShape</name> - <enum>Panel</enum> + <enum>Box</enum> </property> @@ -773,3 +719,3 @@ </widget> - <widget row="2" column="1" > + <widget row="3" column="0" > <class>QLabel</class> @@ -777,15 +723,51 @@ <name>name</name> - <cstring>Mode_LBL</cstring> + <cstring>TextLabel3_3</cstring> </property> <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> + <name>text</name> + <string>Mode</string> </property> + </widget> + <widget row="5" column="0" > + <class>QLabel</class> <property stdset="1"> - <name>frameShadow</name> - <enum>Plain</enum> + <name>name</name> + <cstring>TextLabel4_3</cstring> </property> <property stdset="1"> - <name>indent</name> - <number>0</number> + <name>text</name> + <string>Channel</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Station</string> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_3</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>ESSID</string> + </property> + </widget> + <widget row="4" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel4_3_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Frequency</string> </property> @@ -801,2 +783,6 @@ <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> <name>title</name> @@ -817,3 +803,3 @@ <name>spacing</name> - <number>2</number> + <number>0</number> </property> @@ -849,3 +835,3 @@ <name>progress</name> - <number>0</number> + <number>10</number> </property> @@ -860,3 +846,3 @@ <name>progress</name> - <number>0</number> + <number>10</number> </property> @@ -874,23 +860,2 @@ </widget> - <spacer row="0" column="1" > - <property> - <name>name</name> - <cstring>Spacer28</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Fixed</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>16</width> - <height>20</height> - </size> - </property> - </spacer> <widget row="0" column="2" > @@ -911,3 +876,3 @@ <name>progress</name> - <number>0</number> + <number>10</number> </property> @@ -937,2 +902,58 @@ </spacer> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout21</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>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>5</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>text</name> + <string>Live feed </string> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer16</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> </vbox> @@ -944,3 +965,3 @@ <connection> - <sender>EnableWEB_CB</sender> + <sender>EnableWEP_CB</sender> <signal>toggled(bool)</signal> @@ -962,5 +983,23 @@ <connection> - <sender>SpecifyChannel_CB</sender> + <sender>EnableWEP_CB</sender> + <signal>toggled(bool)</signal> + <receiver>AcceptNonEncrypted_CB</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Key1_RB</sender> + <signal>toggled(bool)</signal> + <receiver>Key1_LE</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Key2_RB</sender> + <signal>toggled(bool)</signal> + <receiver>Key2_LE</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Key3_RB</sender> <signal>toggled(bool)</signal> - <receiver>ChannelNr_SB</receiver> + <receiver>Key3_LE</receiver> <slot>setEnabled(bool)</slot> @@ -968,7 +1007,14 @@ <connection> - <sender>EnableWEB_CB</sender> + <sender>Key4_RB</sender> <signal>toggled(bool)</signal> - <receiver>CheckBox4</receiver> + <receiver>Key4_LE</receiver> <slot>setEnabled(bool)</slot> </connection> + <connection> + <sender>Refresh_CB</sender> + <signal>toggled(bool)</signal> + <receiver>WLanGUI</receiver> + <slot>SLOT_AutoRefresh(bool)</slot> + </connection> + <slot access="public">SLOT_AutoRefresh(bool)</slot> </connections> diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp index 78e756c..61969f2 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp @@ -1 +1,2 @@ +#include <unistd.h> #include "wlanedit.h" @@ -7,8 +8,58 @@ AWLan::AWLan( WLanNetNode * PNN ) : ANetNodeInstance( PNN ) { RT = 0; + Data.ESSID = ""; + Data.NodeName = tr("<UseHostName>"); + Data.Mode = 0; + Data.SpecificAP = 0; + Data.APMac = ""; + Data.Encrypted = 0; + Data.AcceptNonEncrypted = 0; + Data.Key[0] = ""; + Data.Key[1] = ""; + Data.Key[2] = ""; + Data.Key[3] = ""; } -void AWLan::setSpecificAttribute( QString & , QString & ) { +void AWLan::setSpecificAttribute( QString & A, QString & V ) { + if( A == "essid" ) { + Data.ESSID = V; + } else if( A == "nodename" ) { + Data.NodeName = V; + } else if( A == "mode" ) { + Data.Mode = V.toShort(); + } else if( A == "specificap" ) { + Data.SpecificAP = (V=="yes"); + } else if( A == "apmac" ) { + Data.APMac = V; + } else if( A == "encrypted" ) { + Data.Encrypted = (V=="yes"); + } else if( A == "acceptnonencrypted" ) { + Data.AcceptNonEncrypted = (V=="yes"); + } else if( A == "key0" ) { + Data.Key[0] = V; + } else if( A == "key1" ) { + Data.Key[1] = V; + } else if( A == "key2" ) { + Data.Key[2] = V; + } else if( A == "key3" ) { + Data.Key[3] = V; + } } -void AWLan::saveSpecificAttribute( QTextStream & ) { +void AWLan::saveSpecificAttribute( QTextStream & S ) { + S << "essid=" << quote( Data.ESSID ) << endl; + S << "nodename=" << quote( Data.NodeName ) << endl; + S << "mode=" << Data.Mode << endl; + S << "specificap=" + << ((Data.SpecificAP) ? "yes" : "no") + << endl; + S << "apmac=" << Data.APMac << endl; + S << "encrypted=" + << ((Data.Encrypted) ? "yes" : "no") + << endl; + S << "acceptnonencrypted=" + << ((Data.AcceptNonEncrypted) ? "yes" : "no") + << endl; + for( int i = 0 ;i < 4 ; i ++ ) { + S << "key" << i << "=" << Data.Key[i] << endl; + } } @@ -16,3 +67,3 @@ void AWLan::saveSpecificAttribute( QTextStream & ) { QWidget * AWLan::edit( QWidget * parent ) { - GUI = new WLanEdit( parent ); + GUI = new WLanEdit( parent, this ); GUI->showData( Data ); @@ -31,5 +82,58 @@ void AWLan::commit( void ) { bool AWLan::generateDataForCommonFile( - SystemFile &, + SystemFile & S, long ) { - return 1; + + S << " wireless_essid \"" + << Data.ESSID + << "\"" + << endl; + + if( ! Data.NodeName.isEmpty() ) { + if( Data.NodeName == tr("<UseHostName>") ) { + char Buf[100]; + if( gethostname(Buf, sizeof(Buf) ) == 0 ) { + Buf[99] = '\0'; // just to make sure + S << " wireless_nick " + << Buf + << endl; + } + } else { + S << " wireless_nick \"" + << Data.NodeName + << "\"" + << endl; + } + } + + char * M; + switch ( Data.Mode ) { + case 0 : + M = "Auto"; + break; + case 1 : + M = "Managed"; + break; + case 2 : + M = "Ad-Hoc"; + break; + } + + S << " wireless_mode " + << M + << endl; + if( Data.Encrypted ) { + for( int i = 0; i < 4; i ++ ) { + if( ! Data.Key[i].isEmpty() ) { + S << " wireless_key" + << i + << " " + << Data.Key[i] + << endl; + } + } + S << " wireless_keymode " + << ((Data.AcceptNonEncrypted) ? "open" : "restricted") + << endl; + } + return 0; } diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h index d861d13..2211c47 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.h +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h @@ -30,3 +30,3 @@ public : virtual bool hasDataFor( const QString & ) - { return 0; } + { return 1; } virtual bool generateDataForCommonFile( diff --git a/noncore/settings/networksettings2/wlan/wlandata.h b/noncore/settings/networksettings2/wlan/wlandata.h index ba1f2c2..36990a9 100644 --- a/noncore/settings/networksettings2/wlan/wlandata.h +++ b/noncore/settings/networksettings2/wlan/wlandata.h @@ -5,11 +5,10 @@ typedef struct WLanData { - QString Device; - QString LockFile; - long Speed; - short Parity; - short DataBits; - short StopBits; - bool HardwareControl; - bool SoftwareControl; - + QString ESSID; + QString NodeName; + short Mode; + bool SpecificAP; + QString APMac; + bool Encrypted; + QString Key[4]; + bool AcceptNonEncrypted; } WLanData_t; diff --git a/noncore/settings/networksettings2/wlan/wlanedit.cpp b/noncore/settings/networksettings2/wlan/wlanedit.cpp index c884886..8d3979e 100644 --- a/noncore/settings/networksettings2/wlan/wlanedit.cpp +++ b/noncore/settings/networksettings2/wlan/wlanedit.cpp @@ -1,5 +1,51 @@ +#include <qlineedit.h> +#include <qprogressbar.h> +#include <qcombobox.h> +#include <qlabel.h> +#include <qregexp.h> +#include <qcheckbox.h> #include <GUIUtils.h> +#include <resources.h> +#include <wextensions.h> + #include "wlanedit.h" +#include "wlan_NN.h" +#include "wlan_NNI.h" + +WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : + WLanGUI( Parent ), RefreshTimer(this){ + + InterfaceInfo * II; + + NNI = TNNI; + Dev = NNI->runtime()->device(); + WE = 0; + if( ( II = Dev->assignedInterface() ) ) { + // show data + WE = new WExtensions( II->Name ); + + if( WE->doesHaveWirelessExtensions() ) { + QString S; + Station_LBL->setText( WE->station() ); + ESSID_LBL->setText( WE->essid() ); + Mode_LBL->setText( WE->mode() ); + S.setNum( WE->frequency() ); + Frequency_LBL->setText( S ); + S.setNum( WE->channel() ); + Channel_LBL->setText( S ); + S.setNum( WE->rate() ); + Rate_LBL->setText( S ); + AP_LBL->setText( WE->ap() ); + + SLOT_Refresh(); + + connect( &RefreshTimer, SIGNAL( timeout() ), + this, SLOT( SLOT_Refresh() ) ); + } + } +} -WLanEdit::WLanEdit( QWidget * Parent ) : WLanGUI( Parent ){ +WLanEdit::~WLanEdit( void ) { + if( WE ) + delete WE; } @@ -7,2 +53,9 @@ WLanEdit::WLanEdit( QWidget * Parent ) : WLanGUI( Parent ){ QString WLanEdit::acceptable( void ) { + if( ESSID_LE->text().isEmpty() ) { + return QString("ESSID is mandatory"); + } + if( SpecifyAP_CB->isChecked() && + APMac_LE->text().isEmpty() ) { + return QString("APMac must have value"); + } return QString(); @@ -11,2 +64,14 @@ QString WLanEdit::acceptable( void ) { void WLanEdit::showData( WLanData_t & Data ) { + Mode_CB->setCurrentItem( Data.Mode ); + ESSID_LE->setText( Data.ESSID ); + NodeName_LE->setText( Data.NodeName ); + SpecifyAP_CB->setChecked( Data.SpecificAP ); + APMac_LE->setText( Data.APMac ); + + EnableWEP_CB->setChecked( Data.Encrypted ); + AcceptNonEncrypted_CB->setChecked( Data.AcceptNonEncrypted ); + Key1_LE->setText( Data.Key[0] ); + Key2_LE->setText( Data.Key[1] ); + Key3_LE->setText( Data.Key[2] ); + Key4_LE->setText( Data.Key[3] ); } @@ -14,3 +79,37 @@ void WLanEdit::showData( WLanData_t & Data ) { bool WLanEdit::commit( WLanData_t & Data ) { + bool SM = 0; + + TXTM( Data.ESSID, ESSID_LE, SM ); + TXTM( Data.NodeName, NodeName_LE, SM ); + TXTM( Data.APMac, APMac_LE, SM ); + TXTM( Data.Key[0], Key1_LE, SM ); + TXTM( Data.Key[1], Key2_LE, SM ); + TXTM( Data.Key[2], Key3_LE, SM ); + TXTM( Data.Key[3], Key4_LE, SM ); + CBM( Data.SpecificAP, SpecifyAP_CB, SM ); + CBM( Data.Encrypted, EnableWEP_CB, SM ); + CBM( Data.AcceptNonEncrypted, AcceptNonEncrypted_CB, SM ); + CIM( Data.Mode, Mode_CB, SM ); return 0; } + +void WLanEdit::SLOT_Refresh( void ) { + if( WE ) { + int signal, noise, quality; + WE->stats( signal, noise, quality); + + Signal_PB->setProgress( signal ); + Noise_PB->setProgress( noise ); + Quality_PB->setProgress( quality ); + } +} + +void WLanEdit::SLOT_AutoRefresh( bool ar ) { + if( ar ) { + RefreshTimer.start( 1000 ); + SLOT_Refresh(); + } else { + RefreshTimer.stop(); + } +} + diff --git a/noncore/settings/networksettings2/wlan/wlanedit.h b/noncore/settings/networksettings2/wlan/wlanedit.h index b7442d5..e550c14 100644 --- a/noncore/settings/networksettings2/wlan/wlanedit.h +++ b/noncore/settings/networksettings2/wlan/wlanedit.h @@ -1 +1,3 @@ +#include <qtimer.h> +#include <wextensions.h> #include "wlandata.h" @@ -3,2 +5,6 @@ +class ANetNodeInstance; +class AsDevice; +class WExtensions; + class WLanEdit : public WLanGUI { @@ -7,3 +13,4 @@ public : - WLanEdit( QWidget * parent ); + WLanEdit( QWidget * parent, ANetNodeInstance * NNI ); + ~WLanEdit( void ); QString acceptable( void ); @@ -11,2 +18,15 @@ public : bool commit( WLanData_t & Data ); + +public slots : + + void SLOT_AutoRefresh( bool ); + void SLOT_Refresh( void ); + +private : + + ANetNodeInstance * NNI; + AsDevice * Dev; + QTimer RefreshTimer; + WExtensions * WE; + }; diff --git a/noncore/settings/networksettings2/wlan/wlanrun.cpp b/noncore/settings/networksettings2/wlan/wlanrun.cpp index 79f11f7..3f1d4a9 100644 --- a/noncore/settings/networksettings2/wlan/wlanrun.cpp +++ b/noncore/settings/networksettings2/wlan/wlanrun.cpp @@ -1,5 +1,185 @@ + +#include <qfile.h> +#include <qtextstream.h> +#include <qstringlist.h> +#include <resources.h> #include "wlanrun.h" +void WLanRun::detectState( NodeCollection * NC ) { + + // unavailable : no card found + // available : card found and assigned to us or free + // up : card found and assigned to us and up + + QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); + System & Sys = NSResources->system(); + InterfaceInfo * Run; + + QFile F( S ); + + if( F.open( IO_ReadOnly ) ) { + // could open file -> read interface and assign + QString X; + QTextStream TS(&F); + X = TS.readLine(); + // find interface + if( handlesInterface( X ) ) { + for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); + It.current(); + ++It ) { + Run = It.current(); + if( X == Run->Name ) { + Run->assignNode( netNode() ); + assignInterface( Run ); + NC->setCurrentState( IsUp ); + return; + } + } + } + } + + if( ( Run = assignedInterface() ) ) { + // we already have an interface assigned -> still present ? + if( ! Run->IsUp ) { + // usb is still free -> keep assignment + NC->setCurrentState( Available ); + return; + } // else interface is up but NOT us -> some other profile + } + + // nothing (valid) assigned to us + assignInterface( 0 ); + + // find possible interface + for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); + It.current(); + ++It ) { + Run = It.current(); + if( handlesInterface( *Run ) && + ( Run->CardType == ARPHRD_ETHER +#ifdef ARPHRD_IEEE1394 + || Run->CardType == ARPHRD_IEEE1394 +#endif + ) && + ! Run->IsUp + ) { + // proper type, and Not UP -> free + NC->setCurrentState( Off ); + return; + } + } + // no free found + + NC->setCurrentState( Unavailable ); + +} + +bool WLanRun::setState( NodeCollection * NC, Action_t A, bool ) { + + // we only handle activate and deactivate + switch( A ) { + case Activate : + { + if( NC->currentState() != Off ) { + return 0; + } + InterfaceInfo * N = getInterface(); + if( ! N ) { + // no interface available + NC->setCurrentState( Unavailable ); + return 0; + } + // because we were OFF the interface + // we get back is NOT assigned + N->assignNode( netNode() ); + assignInterface( N ); + NC->setCurrentState( Available ); + return 1; + } + case Deactivate : + if( NC->currentState() == IsUp ) { + // bring down first + if( ! connection()->setState( Down ) ) + // could not ... + return 0; + } else if( NC->currentState() != Available ) { + return 1; + } + assignedInterface()->assignNode( 0 ); // release + assignInterface( 0 ); + NC->setCurrentState( Off ); + return 1; + default : + // FT + break; + } + return 0; +} + +bool WLanRun::canSetState( State_t Curr, Action_t A ) { + // we only handle up down activate and deactivate + switch( A ) { + case Activate : + { // at least available + if( Curr == Available ) { + return 1; + } + // or we can make one available + InterfaceInfo * N = getInterface(); + if( ! N || N->assignedNode() != 0 ) { + // non available or assigned + return 0; + } + return 1; + } + case Deactivate : + return ( Curr >= Available ); + default : + // FT + break; + } + return 0; +} + +// get interface that is free or assigned to us +InterfaceInfo * WLanRun::getInterface( void ) { + + System & S = NSResources->system(); + InterfaceInfo * best = 0, * Run; + + for( QDictIterator<InterfaceInfo> It(S.interfaces()); + It.current(); + ++It ) { + Run = It.current(); + if( handlesInterface( *Run ) && + ( Run->CardType == ARPHRD_ETHER +#ifdef ARPHRD_IEEE1394 + || Run->CardType == ARPHRD_IEEE1394 +#endif + ) + ) { + // this is a LAN card + if( Run->assignedNode() == netNode() ) { + // assigned to us + return Run; + } else if( Run->assignedNode() == 0 ) { + // free + best = Run; + } + } + } + return best; // can be 0 +} + bool WLanRun::handlesInterface( const QString & S ) { + InterfaceInfo * II; + II = NSResources->system().interface( S ); + if( ( II = NSResources->system().interface( S ) ) ) { + return handlesInterface( *II ); + } return Pat.match( S ) >= 0; } + +bool WLanRun::handlesInterface( const InterfaceInfo & II ) { + return ( Pat.match( II.Name ) < 0 ); +} diff --git a/noncore/settings/networksettings2/wlan/wlanrun.h b/noncore/settings/networksettings2/wlan/wlanrun.h index f46bcb7..25d5b96 100644 --- a/noncore/settings/networksettings2/wlan/wlanrun.h +++ b/noncore/settings/networksettings2/wlan/wlanrun.h @@ -23,12 +23,7 @@ protected : - void detectState( NodeCollection * ) - { } - - bool setState( NodeCollection *, Action_t ) - { return 0; } - - bool canSetState( State_t, Action_t ) - { return 0; } - + void detectState( NodeCollection * ); + bool setState( NodeCollection *, Action_t, bool ); + bool canSetState( State_t, Action_t ); bool handlesInterface( const QString & I ); + bool handlesInterface( const InterfaceInfo & II ); @@ -36,3 +31,5 @@ private : + InterfaceInfo * getInterface( void ); QRegExp Pat; + WLanData * Data; }; |