author | wimpie <wimpie> | 2005-01-12 00:29:48 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-12 00:29:48 (UTC) |
commit | a846a0be197d3a6ff7f8c76a3ba322db0da7d058 (patch) (unidiff) | |
tree | 0db1eccb73b0756ff49029dcfa71ff1a3699cab0 | |
parent | 4b1d4fc9f4170ec22d196dd352cae5d9c1ecb232 (diff) | |
download | opie-a846a0be197d3a6ff7f8c76a3ba322db0da7d058.zip opie-a846a0be197d3a6ff7f8c76a3ba322db0da7d058.tar.gz opie-a846a0be197d3a6ff7f8c76a3ba322db0da7d058.tar.bz2 |
Fixed Crash in editing new profiles
-rw-r--r-- | noncore/settings/networksettings2/editconnection.cpp | 17 | ||||
-rw-r--r-- | noncore/settings/networksettings2/nsdata.cpp | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index 6ab2dd6..bda9d7e 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp | |||
@@ -60,129 +60,132 @@ class MyQListViewItem : public QListViewItem | |||
60 | public: | 60 | public: |
61 | MyQListViewItem( QListView *parent, const QString & S ) : | 61 | MyQListViewItem( QListView *parent, const QString & S ) : |
62 | QListViewItem( parent, S ) { } | 62 | QListViewItem( parent, S ) { } |
63 | MyQListViewItem( QListViewItem *parent, const QString & S ) : | 63 | MyQListViewItem( QListViewItem *parent, const QString & S ) : |
64 | QListViewItem( parent, S ) { } | 64 | QListViewItem( parent, S ) { } |
65 | 65 | ||
66 | virtual void paintCell( QPainter *p, const QColorGroup &cg, | 66 | virtual void paintCell( QPainter *p, const QColorGroup &cg, |
67 | int column, int width, int alignment ); | 67 | int column, int width, int alignment ); |
68 | 68 | ||
69 | }; | 69 | }; |
70 | 70 | ||
71 | void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg, | 71 | void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg, |
72 | int column, int width, int alignment ) | 72 | int column, int width, int alignment ) |
73 | { | 73 | { |
74 | QColorGroup _cg( cg ); | 74 | QColorGroup _cg( cg ); |
75 | QColor c = _cg.text(); | 75 | QColor c = _cg.text(); |
76 | if ( ! isSelectable() ) | 76 | if ( ! isSelectable() ) |
77 | _cg.setColor( QColorGroup::Text, Qt::lightGray ); | 77 | _cg.setColor( QColorGroup::Text, Qt::lightGray ); |
78 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 78 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
79 | _cg.setColor( QColorGroup::Text, c ); | 79 | _cg.setColor( QColorGroup::Text, c ); |
80 | } | 80 | } |
81 | 81 | ||
82 | // | 82 | // |
83 | // | 83 | // |
84 | // REAL GUI | 84 | // REAL GUI |
85 | // | 85 | // |
86 | // | 86 | // |
87 | 87 | ||
88 | bool EditNetworkSetup::AutoCollapse = 1; | 88 | bool EditNetworkSetup::AutoCollapse = 1; |
89 | 89 | ||
90 | EditNetworkSetup::EditNetworkSetup( QWidget* parent ) : | 90 | EditNetworkSetup::EditNetworkSetup( QWidget* parent ) : |
91 | EditNetworkSetupGUI( parent, 0, TRUE ), TmpCollection() { | 91 | EditNetworkSetupGUI( parent, 0, TRUE ), TmpCollection() { |
92 | 92 | ||
93 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); | 93 | Tab_TB->setTabEnabled( Setup_FRM, FALSE ); |
94 | Setup_FRM->setEnabled( FALSE ); | 94 | Setup_FRM->setEnabled( FALSE ); |
95 | 95 | ||
96 | TmpIsValid = 0; | 96 | TmpIsValid = 0; |
97 | SelectedNodes = 0; | 97 | SelectedNodes = 0; |
98 | 98 | ||
99 | AutoCollapse_CB->setChecked( AutoCollapse ); | 99 | AutoCollapse_CB->setChecked( AutoCollapse ); |
100 | 100 | ||
101 | Mapping = new QPtrDict<ANetNode>; | 101 | Mapping = new QPtrDict<ANetNode>; |
102 | Mapping->setAutoDelete( FALSE ); | 102 | Mapping->setAutoDelete( FALSE ); |
103 | Nodes_LV->header()->hide(); | 103 | Nodes_LV->header()->hide(); |
104 | // popluate tree with all NetNodes | 104 | // popluate tree with all NetNodes |
105 | buildFullTree(); | 105 | buildFullTree(); |
106 | } | 106 | } |
107 | 107 | ||
108 | NetworkSetup * EditNetworkSetup::getTmpCollection( void ) { | 108 | NetworkSetup * EditNetworkSetup::getTmpCollection( void ) { |
109 | 109 | ||
110 | if( TmpIsValid ) | 110 | if( TmpIsValid ) |
111 | // content is stil OK | 111 | // content is stil OK |
112 | return &(TmpCollection); | 112 | return &(TmpCollection); |
113 | 113 | ||
114 | // reset collection -> delete all NEW NetNodes | 114 | // reset collection -> delete all NEW NetNodes |
115 | for( QListIterator<ANetNodeInstance> it(TmpCollection); | 115 | for( QListIterator<ANetNodeInstance> it(TmpCollection); |
116 | it.current(); | 116 | it.current(); |
117 | ++it ) { | 117 | ++it ) { |
118 | if( it.current()->isNew() ) { | 118 | if( it.current()->isNew() ) { |
119 | delete it.current(); | 119 | delete it.current(); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | TmpCollection.clear(); | 123 | TmpCollection.clear(); |
124 | TmpCollection.copyFrom( *SelectedNodes ); | 124 | if( SelectedNodes ) { |
125 | // initialize like original | ||
126 | TmpCollection.copyFrom( *SelectedNodes ); | ||
127 | } | ||
125 | 128 | ||
126 | // update content | 129 | // update content |
127 | QListViewItem * it = Nodes_LV->firstChild(); | 130 | QListViewItem * it = Nodes_LV->firstChild(); |
128 | ANetNode * NN; | 131 | ANetNode * NN; |
129 | 132 | ||
130 | // start iter (if there is a collection) | 133 | // start iter (if there is a collection) |
131 | /* | 134 | /* |
132 | 135 | ||
133 | a node collection is sorted from the toplevel | 136 | a node collection is sorted from the toplevel |
134 | node to the deepest node | 137 | node to the deepest node |
135 | 138 | ||
136 | */ | 139 | */ |
137 | ANetNodeInstance * NNI = | 140 | ANetNodeInstance * NNI = |
138 | (SelectedNodes) ? SelectedNodes->first() : 0 ; | 141 | (SelectedNodes) ? SelectedNodes->first() : 0 ; |
139 | 142 | ||
140 | TmpCollection.setModified( 0 ); | 143 | TmpCollection.setModified( 0 ); |
141 | 144 | ||
142 | // the listview always starts with the toplevel | 145 | // the listview always starts with the toplevel |
143 | // hierarchy. This is always a controller item | 146 | // hierarchy. This is always a controller item |
144 | while ( it ) { | 147 | while ( it ) { |
145 | NN = (*Mapping)[it]; | 148 | NN = (*Mapping)[it]; |
146 | if( NN == 0 ) { | 149 | if( NN == 0 ) { |
147 | // this item is a controller -> | 150 | // this item is a controller -> |
148 | // has radio items as children -> | 151 | // has radio items as children -> |
149 | // find selected one | 152 | // find selected one |
150 | it = it->firstChild(); | 153 | it = it->firstChild(); |
151 | while( it ) { | 154 | while( it ) { |
152 | if( ((QCheckListItem *)it)->isOn() ) { | 155 | if( ((QCheckListItem *)it)->isOn() ) { |
153 | // this radio is selected -> go deeper | 156 | // this radio is selected -> go deeper |
154 | break; | 157 | break; |
155 | } | 158 | } |
156 | it = it->nextSibling(); | 159 | it = it->nextSibling(); |
157 | } | 160 | } |
158 | 161 | ||
159 | if( ! it ) { | 162 | if( ! it ) { |
160 | TmpIsValid = 0; | 163 | TmpIsValid = 0; |
161 | return 0; | 164 | return 0; |
162 | } | 165 | } |
163 | 166 | ||
164 | // it now contains selected radio | 167 | // it now contains selected radio |
165 | NN = (*Mapping)[it]; | 168 | NN = (*Mapping)[it]; |
166 | } | 169 | } |
167 | 170 | ||
168 | // NN here contains the netnode of the | 171 | // NN here contains the netnode of the |
169 | // current item -> this node needs to | 172 | // current item -> this node needs to |
170 | // be stored in the collection | 173 | // be stored in the collection |
171 | if( NNI == 0 || | 174 | if( NNI == 0 || |
172 | it->text(0) != NNI->nodeClass()->name() ) { | 175 | it->text(0) != NNI->nodeClass()->name() ) { |
173 | // new item not in previous collection | 176 | // new item not in previous collection |
174 | ANetNodeInstance * NNI = NN->createInstance(); | 177 | ANetNodeInstance * NNI = NN->createInstance(); |
175 | NNI->initialize(); | 178 | NNI->initialize(); |
176 | // this node type not in collection | 179 | // this node type not in collection |
177 | TmpCollection.append( NNI ); | 180 | TmpCollection.append( NNI ); |
178 | // master collection changed because new item in it | 181 | // master collection changed because new item in it |
179 | TmpCollection.setModified( 1 ); | 182 | TmpCollection.setModified( 1 ); |
180 | // no more valid items in old list | 183 | // no more valid items in old list |
181 | NNI = 0; | 184 | NNI = 0; |
182 | } else { | 185 | } else { |
183 | // already in list -> copy pointer | 186 | // already in list -> copy pointer |
184 | TmpCollection.append( NNI ); | 187 | TmpCollection.append( NNI ); |
185 | NNI = SelectedNodes->next(); | 188 | NNI = SelectedNodes->next(); |
186 | } | 189 | } |
187 | 190 | ||
188 | // go deeper to next level | 191 | // go deeper to next level |
@@ -395,131 +398,137 @@ void EditNetworkSetup::accept( void ) { | |||
395 | QString S; | 398 | QString S; |
396 | 399 | ||
397 | for( QListIterator<ANetNodeInstance> it(TmpCollection); | 400 | for( QListIterator<ANetNodeInstance> it(TmpCollection); |
398 | it.current(); | 401 | it.current(); |
399 | ++it ) { | 402 | ++it ) { |
400 | NNI = it.current(); | 403 | NNI = it.current(); |
401 | // widget must show its own problems | 404 | // widget must show its own problems |
402 | S = NNI->acceptable(); | 405 | S = NNI->acceptable(); |
403 | if( ! S.isEmpty() ) { | 406 | if( ! S.isEmpty() ) { |
404 | QMessageBox::warning( | 407 | QMessageBox::warning( |
405 | 0, | 408 | 0, |
406 | tr( "Cannot save" ), | 409 | tr( "Cannot save" ), |
407 | S ); | 410 | S ); |
408 | return; | 411 | return; |
409 | } | 412 | } |
410 | NNI->commit(); | 413 | NNI->commit(); |
411 | 414 | ||
412 | if( NNI->isModified() ) { | 415 | if( NNI->isModified() ) { |
413 | TmpCollection.setModified( 1 ); | 416 | TmpCollection.setModified( 1 ); |
414 | // commit the data | 417 | // commit the data |
415 | } | 418 | } |
416 | } | 419 | } |
417 | } | 420 | } |
418 | 421 | ||
419 | QDialog::accept(); | 422 | QDialog::accept(); |
420 | } | 423 | } |
421 | 424 | ||
422 | // triggered by CB | 425 | // triggered by CB |
423 | void EditNetworkSetup::SLOT_AutoCollapse( bool b ) { | 426 | void EditNetworkSetup::SLOT_AutoCollapse( bool b ) { |
424 | AutoCollapse = b; | 427 | AutoCollapse = b; |
425 | } | 428 | } |
426 | 429 | ||
427 | // clicked on node in tree -> update GUI | 430 | // clicked on node in tree -> update GUI |
428 | void EditNetworkSetup::SLOT_SelectNode( QListViewItem * it ) { | 431 | void EditNetworkSetup::SLOT_SelectNode( QListViewItem * it ) { |
429 | ANetNode * NN; | 432 | ANetNode * NN; |
430 | if( it == 0 || it->depth() == 0 ) { | 433 | if( it == 0 || it->depth() == 0 ) { |
431 | Description_LBL->setText( | 434 | Description_LBL->setText( |
432 | NSResources->netNode2Description( "fullsetup" ) ); | 435 | NSResources->netNode2Description( "fullsetup" ) ); |
433 | // topevel or no selection | 436 | // topevel or no selection |
434 | return; | 437 | return; |
435 | } | 438 | } |
436 | 439 | ||
437 | // store conversion from lvitem to node | 440 | // store conversion from lvitem to node |
438 | NN = (*Mapping)[ it ]; | 441 | NN = (*Mapping)[ it ]; |
439 | 442 | ||
440 | if( ! NN ) { | 443 | if( ! NN ) { |
441 | // intermediate node | 444 | // intermediate node |
442 | NN = (*Mapping)[ it->parent() ]; | 445 | NN = (*Mapping)[ it->parent() ]; |
443 | if( NN ) { | 446 | if( NN ) { |
444 | // figure out type of this node -> produce mesage | 447 | // figure out type of this node -> produce mesage |
445 | Description_LBL->setText( NSResources->netNode2Description( | 448 | Description_LBL->setText( NSResources->netNode2Description( |
446 | NN->needs()[0]) ); | 449 | NN->needs()[0]) ); |
447 | } else { | 450 | } else { |
448 | Description_LBL->setText( "" ); | 451 | Description_LBL->setText( "" ); |
449 | } | 452 | } |
450 | return; | 453 | return; |
451 | } | 454 | } |
452 | 455 | ||
453 | Description_LBL->setText( NN->nodeDescription() ); | 456 | Description_LBL->setText( NN->nodeDescription() ); |
454 | 457 | ||
455 | if( ! it->isSelectable() ) { | 458 | if( ! it->isSelectable() ) { |
456 | return; | 459 | return; |
457 | } | 460 | } |
458 | 461 | ||
459 | if( ! ((QCheckListItem *)it)->isOn() ) { | 462 | ANetNode::NetNodeList & NNL = NN->alternatives(); |
460 | // clicked on line but NOT on Check or Radio item | 463 | |
461 | return; | 464 | if( NNL.size() != 1 ) { |
465 | if( NNL.size() == 0 || | ||
466 | ! ((MyQCheckListItem *)it)->isOn() | ||
467 | ) { | ||
468 | // not clicked on Check or Radio item | ||
469 | return; | ||
470 | } | ||
462 | } | 471 | } |
463 | 472 | ||
464 | // item has really changed -> update | 473 | // item has really changed -> update |
465 | TmpIsValid = 0; | 474 | TmpIsValid = 0; |
466 | updateGUI( it, NN ); | 475 | updateGUI( it, NN ); |
467 | } | 476 | } |
468 | 477 | ||
469 | // cliecked on TAB to go to setup | 478 | // cliecked on TAB to go to setup |
470 | void EditNetworkSetup::SLOT_AlterTab( const QString & S ) { | 479 | void EditNetworkSetup::SLOT_AlterTab( const QString & S ) { |
471 | if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { | 480 | if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { |
472 | // switched to setup -> update CB and populate ws with | 481 | // switched to setup -> update CB and populate ws with |
473 | // forms for devices | 482 | // forms for devices |
474 | 483 | ||
475 | if( ! TmpIsValid ) { | 484 | if( ! TmpIsValid ) { |
476 | getTmpCollection(); | 485 | getTmpCollection(); |
477 | 486 | ||
478 | // clear CB and Ws | 487 | // clear CB and Ws |
479 | { QWidget * W; | 488 | { QWidget * W; |
480 | int i = 0; | 489 | int i = 0; |
481 | 490 | ||
482 | Devices_CB->clear(); | 491 | Devices_CB->clear(); |
483 | while( ( W = Setup_WS->widget( i ) ) ) { | 492 | while( ( W = Setup_WS->widget( i ) ) ) { |
484 | Setup_WS->removeWidget( W ); | 493 | Setup_WS->removeWidget( W ); |
485 | i ++; | 494 | i ++; |
486 | } | 495 | } |
487 | } | 496 | } |
488 | 497 | ||
489 | // update CB | 498 | // update CB |
490 | // and populate WidgetStack | 499 | // and populate WidgetStack |
491 | { ANetNodeInstance * NNI; | 500 | { ANetNodeInstance * NNI; |
492 | QListIterator<ANetNodeInstance> it(TmpCollection); | 501 | QListIterator<ANetNodeInstance> it(TmpCollection); |
493 | int i = 0; | 502 | int i = 0; |
494 | QWidget * W; | 503 | QWidget * W; |
495 | 504 | ||
496 | for ( ; it.current(); ++it ) { | 505 | for ( ; it.current(); ++it ) { |
497 | NNI = it.current(); | 506 | NNI = it.current(); |
498 | Devices_CB->insertItem( | 507 | Devices_CB->insertItem( |
499 | NSResources->getPixmap( NNI->nodeClass()->pixmapName() ), | 508 | NSResources->getPixmap( NNI->nodeClass()->pixmapName() ), |
500 | NNI->nodeClass()->name() | 509 | NNI->nodeClass()->name() |
501 | ); | 510 | ); |
502 | 511 | ||
503 | // add edit widget | 512 | // add edit widget |
504 | W = NNI->edit( Setup_WS ); | 513 | W = NNI->edit( Setup_WS ); |
505 | if( ! W) { | 514 | if( ! W) { |
506 | W = new QLabel( Setup_WS, | 515 | W = new QLabel( Setup_WS, |
507 | tr("No configuration required")); | 516 | tr("No configuration required")); |
508 | } | 517 | } |
509 | Setup_WS->addWidget( W , i ); | 518 | Setup_WS->addWidget( W , i ); |
510 | i ++; | 519 | i ++; |
511 | } | 520 | } |
512 | } | 521 | } |
513 | Setup_WS->raiseWidget( 0 ); | 522 | Setup_WS->raiseWidget( 0 ); |
514 | } // still valid | 523 | } // still valid |
515 | } | 524 | } |
516 | } | 525 | } |
517 | 526 | ||
518 | // update visual feedback of selection state | 527 | // update visual feedback of selection state |
519 | void EditNetworkSetup::updateGUI( QListViewItem * it, ANetNode * NN ) { | 528 | void EditNetworkSetup::updateGUI( QListViewItem * it, ANetNode * NN ) { |
520 | 529 | ||
521 | bool HCC = haveCompleteConfig( it ); | 530 | bool HCC = haveCompleteConfig( it ); |
522 | Tab_TB->setTabEnabled( Setup_FRM, HCC ); | 531 | Tab_TB->setTabEnabled( Setup_FRM, HCC ); |
523 | Setup_FRM->setEnabled( HCC ); | 532 | Setup_FRM->setEnabled( HCC ); |
524 | 533 | ||
525 | // disable children of all siblings at same level | 534 | // disable children of all siblings at same level |
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index b4622fc..835c7c3 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -660,128 +660,128 @@ QList<NetworkSetup> NetworkSettingsData::collectPossible( | |||
660 | // check if this profile handles the requested interface | 660 | // check if this profile handles the requested interface |
661 | if( NC->handlesInterface( Interface ) && // if different Intf. | 661 | if( NC->handlesInterface( Interface ) && // if different Intf. |
662 | NC->state() != Disabled && // if enabled | 662 | NC->state() != Disabled && // if enabled |
663 | NC->state() != IsUp // if already used | 663 | NC->state() != IsUp // if already used |
664 | ) { | 664 | ) { |
665 | Log( ( "Append %s for %s\n", | 665 | Log( ( "Append %s for %s\n", |
666 | NC->name().latin1(), Interface.latin1() )); | 666 | NC->name().latin1(), Interface.latin1() )); |
667 | PossibleNetworkSetups.append( NC ); | 667 | PossibleNetworkSetups.append( NC ); |
668 | } | 668 | } |
669 | } | 669 | } |
670 | return PossibleNetworkSetups; | 670 | return PossibleNetworkSetups; |
671 | } | 671 | } |
672 | 672 | ||
673 | 673 | ||
674 | /* | 674 | /* |
675 | Called by the system to see if interface can be brought UP | 675 | Called by the system to see if interface can be brought UP |
676 | 676 | ||
677 | if allowed, echo Interface-allowed else Interface-disallowed | 677 | if allowed, echo Interface-allowed else Interface-disallowed |
678 | */ | 678 | */ |
679 | 679 | ||
680 | bool NetworkSettingsData::canStart( const QString & Interface ) { | 680 | bool NetworkSettingsData::canStart( const QString & Interface ) { |
681 | // load situation | 681 | // load situation |
682 | NetworkSetup * NC = 0; | 682 | NetworkSetup * NC = 0; |
683 | QList<NetworkSetup> PossibleNetworkSetups; | 683 | QList<NetworkSetup> PossibleNetworkSetups; |
684 | 684 | ||
685 | PossibleNetworkSetups = collectPossible( Interface ); | 685 | PossibleNetworkSetups = collectPossible( Interface ); |
686 | 686 | ||
687 | Log( ( "for %s : Possiblilies %d\n", | 687 | Log( ( "for %s : Possiblilies %d\n", |
688 | Interface.latin1(), PossibleNetworkSetups.count() )); | 688 | Interface.latin1(), PossibleNetworkSetups.count() )); |
689 | switch( PossibleNetworkSetups.count() ) { | 689 | switch( PossibleNetworkSetups.count() ) { |
690 | case 0 : // no NetworkSetups | 690 | case 0 : // no NetworkSetups |
691 | break; | 691 | break; |
692 | case 1 : // one NetworkSetup | 692 | case 1 : // one NetworkSetup |
693 | NC = PossibleNetworkSetups.first(); | 693 | NC = PossibleNetworkSetups.first(); |
694 | break; | 694 | break; |
695 | default : // need to ask user ? | 695 | default : // need to ask user ? |
696 | return 1; | 696 | return 1; |
697 | } | 697 | } |
698 | 698 | ||
699 | if( NC ) { | 699 | if( NC ) { |
700 | switch( NC->state() ) { | 700 | switch( NC->state() ) { |
701 | case Unchecked : | 701 | case Unchecked : |
702 | case Unknown : | 702 | case Unknown : |
703 | case Unavailable : | 703 | case Unavailable : |
704 | case Disabled : | 704 | case Disabled : |
705 | // this profile does not allow interface to be UP | 705 | // this profile does not allow interface to be UP |
706 | // -> try others | 706 | // -> try others |
707 | break; | 707 | break; |
708 | case Off : | 708 | case Off : |
709 | // try to UP the device | 709 | // try to UP the device |
710 | { QString S= NC->setState( Activate ); | 710 | { QString S= NC->setState( Activate ); |
711 | if( ! S.isEmpty() ) { | 711 | if( ! S.isEmpty() ) { |
712 | // could not bring device Online -> try other alters | 712 | // could not bring device Online -> try other alters |
713 | Log(( "disallow %ld for %s : %s\n", | 713 | Log(( "disallow %ld for %s : %s\n", |
714 | NC->number(), Interface.latin1(), S.latin1() )); | 714 | NC->number(), Interface.latin1(), S.latin1() )); |
715 | break; | 715 | break; |
716 | } | 716 | } |
717 | // interface assigned | 717 | // interface assigned |
718 | } | 718 | } |
719 | // FT | 719 | // FT |
720 | case Available : | 720 | case Available : |
721 | case IsUp : // also called for 'ifdown' | 721 | case IsUp : // also called for 'ifdown' |
722 | // device is ready -> done | 722 | // device is ready -> done |
723 | Log(( "allow %ld for %s\n", NC->number(), Interface.latin1())); | 723 | Log(( "allow %ld for %s\n", NC->number(), Interface.latin1())); |
724 | printf( "A%ld%s\n", NC->number(), Interface.latin1() ); | 724 | printf( "A%d%s\n", NC->number(), Interface.latin1() ); |
725 | return 0; | 725 | return 0; |
726 | } | 726 | } |
727 | } | 727 | } |
728 | 728 | ||
729 | // if we come here no alternatives are possible | 729 | // if we come here no alternatives are possible |
730 | Log(( "disallow %s\n", Interface.latin1())); | 730 | Log(( "disallow %s\n", Interface.latin1())); |
731 | printf( "D-%s\n", Interface.latin1() ); | 731 | printf( "D-%s\n", Interface.latin1() ); |
732 | return 0; | 732 | return 0; |
733 | } | 733 | } |
734 | 734 | ||
735 | bool NetworkSettingsData::isModified( void ) { | 735 | bool NetworkSettingsData::isModified( void ) { |
736 | if( ForceModified ) | 736 | if( ForceModified ) |
737 | return 1; | 737 | return 1; |
738 | 738 | ||
739 | for( QDictIterator<NetworkSetup> it(NSResources->networkSetups()); | 739 | for( QDictIterator<NetworkSetup> it(NSResources->networkSetups()); |
740 | it.current(); | 740 | it.current(); |
741 | ++it ) { | 741 | ++it ) { |
742 | if( it.current()->isModified() ) { | 742 | if( it.current()->isModified() ) { |
743 | return 1; | 743 | return 1; |
744 | } | 744 | } |
745 | } | 745 | } |
746 | return 0; | 746 | return 0; |
747 | } | 747 | } |
748 | 748 | ||
749 | bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) { | 749 | bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) { |
750 | // load situation | 750 | // load situation |
751 | QList<NetworkSetup> PossibleTriggered; | 751 | QList<NetworkSetup> PossibleTriggered; |
752 | 752 | ||
753 | PossibleTriggered = collectTriggered( Interface ); | 753 | PossibleTriggered = collectTriggered( Interface ); |
754 | 754 | ||
755 | Log( ( "for %s : Possiblilies %d\n", | 755 | Log( ( "for %s : Possiblilies %d\n", |
756 | Interface.latin1(), PossibleTriggered.count() )); | 756 | Interface.latin1(), PossibleTriggered.count() )); |
757 | 757 | ||
758 | return ( PossibleTriggered.count() ) ? 1 : 0; | 758 | return ( PossibleTriggered.count() ) ? 1 : 0; |
759 | } | 759 | } |
760 | 760 | ||
761 | QList<NetworkSetup> NetworkSettingsData::collectTriggered( | 761 | QList<NetworkSetup> NetworkSettingsData::collectTriggered( |
762 | const QString & Interface ) { | 762 | const QString & Interface ) { |
763 | 763 | ||
764 | // collect NetworkSetups that could be triggered by this interface | 764 | // collect NetworkSetups that could be triggered by this interface |
765 | NetworkSetup * NC; | 765 | NetworkSetup * NC; |
766 | QList<NetworkSetup> PossibleTriggered; | 766 | QList<NetworkSetup> PossibleTriggered; |
767 | 767 | ||
768 | // for all NetworkSetups | 768 | // for all NetworkSetups |
769 | Name2NetworkSetup_t & M = NSResources->networkSetups(); | 769 | Name2NetworkSetup_t & M = NSResources->networkSetups(); |
770 | 770 | ||
771 | for( QDictIterator<NetworkSetup> it(M); | 771 | for( QDictIterator<NetworkSetup> it(M); |
772 | it.current(); | 772 | it.current(); |
773 | ++it ) { | 773 | ++it ) { |
774 | NC = it.current(); | 774 | NC = it.current(); |
775 | // check if this profile handles the requested interface | 775 | // check if this profile handles the requested interface |
776 | if( NC->triggeredBy( Interface ) && // if different Intf. | 776 | if( NC->triggeredBy( Interface ) && // if different Intf. |
777 | NC->state() != Disabled && // if enabled | 777 | NC->state() != Disabled && // if enabled |
778 | NC->state() != IsUp // if already used | 778 | NC->state() != IsUp // if already used |
779 | ) { | 779 | ) { |
780 | Log( ( "Append %s for %s\n", | 780 | Log( ( "Append %s for %s\n", |
781 | NC->name().latin1(), Interface.latin1() )); | 781 | NC->name().latin1(), Interface.latin1() )); |
782 | PossibleTriggered.append( NC ); | 782 | PossibleTriggered.append( NC ); |
783 | } | 783 | } |
784 | } | 784 | } |
785 | return PossibleTriggered; | 785 | return PossibleTriggered; |
786 | } | 786 | } |
787 | 787 | ||