summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index b36c7a0..6ee4106 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,4 +1,5 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <unistd.h>
2 3
3#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
4#include <qlistbox.h> 5#include <qlistbox.h>
@@ -61,6 +62,10 @@ NetworkSettings::NetworkSettings( QWidget *parent,
61 QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) ); 62 QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) );
62 } 63 }
63 64
65 connect( &(NSResources->system()),
66 SIGNAL( lineFromCommand(const QString &) ),
67 this, SLOT( SLOT_CmdMessage(const QString &) ) );
68
64 UpdateTimer->start( 5000 ); 69 UpdateTimer->start( 5000 );
65 connect( UpdateTimer, SIGNAL( timeout() ), 70 connect( UpdateTimer, SIGNAL( timeout() ),
66 this, SLOT( SLOT_RefreshStates() ) ); 71 this, SLOT( SLOT_RefreshStates() ) );
@@ -91,6 +96,12 @@ NetworkSettings::~NetworkSettings() {
91 } 96 }
92} 97}
93 98
99void NetworkSettings::SLOT_CmdMessage( const QString & S ) {
100 Messages_LB->insertItem( S );
101 Messages_LB->setCurrentItem( Messages_LB->count()-1 );
102 Messages_LB->ensureCurrentVisible();
103}
104
94void NetworkSettings::SLOT_RefreshStates( void ) { 105void NetworkSettings::SLOT_RefreshStates( void ) {
95 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember 106 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember
96 107
@@ -134,6 +145,9 @@ void NetworkSettings::SLOT_RefreshStates( void ) {
134 */ 145 */
135} 146}
136 147
148void NetworkSettings::SLOT_NoLongerBusy( void ) {
149 NSResources->busy( FALSE );
150}
137void NetworkSettings::SLOT_AddNode( void ) { 151void NetworkSettings::SLOT_AddNode( void ) {
138 SLOT_EditNode( 0 ); 152 SLOT_EditNode( 0 );
139} 153}
@@ -172,6 +186,8 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
172 EC.showMaximized(); 186 EC.showMaximized();
173 // disable refresh timer 187 // disable refresh timer
174 UpdateTimer->stop(); 188 UpdateTimer->stop();
189 NSResources->busy( TRUE );
190 QTimer::singleShot( 1000, this, SLOT( SLOT_NoLongerBusy() ));
175 // we need to retry 191 // we need to retry
176 while( 1 ) { 192 while( 1 ) {
177 if( EC.exec() == QDialog::Accepted ) { 193 if( EC.exec() == QDialog::Accepted ) {
@@ -206,7 +222,7 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
206 // new item 222 // new item
207 int ci = Profiles_LB->count(); 223 int ci = Profiles_LB->count();
208 NSResources->addConnection( NC ); 224 NSResources->addConnection( NC );
209 NC->setNumber( NC->maxConnectionNumber()+1 ); 225 NC->setNumber( NSResources->assignConnectionNumber() );
210 Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); 226 Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
211 Profiles_LB->setSelected( ci, TRUE ); 227 Profiles_LB->setSelected( ci, TRUE );
212 } 228 }
@@ -257,14 +273,20 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
257 break; 273 break;
258 case Available : 274 case Available :
259 OnOn = 1; 275 OnOn = 1;
276 Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) );
260 DisabledOn = 0; 277 DisabledOn = 0;
261 break; 278 break;
262 case IsUp : 279 case IsUp :
263 OnOn = ConnectOn = 1; 280 OnOn = ConnectOn = 1;
281 Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) );
264 DisabledOn = 0; 282 DisabledOn = 0;
265 break; 283 break;
266 } 284 }
267 285
286 if( ! OnOn ) {
287 Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) );
288 }
289
268 // set button state 290 // set button state
269 Enable_TB->setEnabled( EnabledPossible ); 291 Enable_TB->setEnabled( EnabledPossible );
270 On_TB->setEnabled( OnPossible ); 292 On_TB->setEnabled( OnPossible );
@@ -275,13 +297,12 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
275 Connect_TB->setOn( ConnectOn ); 297 Connect_TB->setOn( ConnectOn );
276 298
277 if( NC->description().isEmpty() ) { 299 if( NC->description().isEmpty() ) {
278 Description_LBL->setText( tr( "No description" ) ); 300 Description_LBL->setText( tr( "<<No description>>" ) );
279 } else { 301 } else {
280 Description_LBL->setText( NC->description() ); 302 Description_LBL->setText( NC->description() );
281 } 303 }
282 304
283 Profile_GB->setTitle( LBI->text() ); 305 Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() );
284 State_LBL->setText( NC->stateName() );
285} 306}
286 307
287void NetworkSettings::SLOT_CheckState( void ) { 308void NetworkSettings::SLOT_CheckState( void ) {
@@ -414,6 +435,7 @@ void NetworkSettings::SLOT_Connect( void ) {
414} 435}
415 436
416void NetworkSettings::SLOT_Disconnect( void ) { 437void NetworkSettings::SLOT_Disconnect( void ) {
438 QString S;
417 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 439 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
418 440
419 if ( ! LBI ) 441 if ( ! LBI )
@@ -422,7 +444,11 @@ void NetworkSettings::SLOT_Disconnect( void ) {
422 NodeCollection * NC = 444 NodeCollection * NC =
423 NSResources->findConnection( LBI->text() ); 445 NSResources->findConnection( LBI->text() );
424 446
447 Log(( "Force interface %s down\n", NC->name().latin1() ));
425 NC->setState( Down, 1 ); 448 NC->setState( Down, 1 );
449 // remove 'up' file to make sure
450 S.sprintf( "/tmp/Profile-%d.up", NC->number() );
451 unlink( S.latin1() );
426} 452}
427 453
428void NetworkSettings::SLOT_ToMessages( void ) { 454void NetworkSettings::SLOT_ToMessages( void ) {