summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index 78b6cce..80dcb3d 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -43,66 +43,66 @@ NetworkSettings::NetworkSettings( QWidget *parent,
QVBoxLayout* V = new QVBoxLayout( LED_Frm );
QHBoxLayout * H = new QHBoxLayout( 0 );
V->addStretch(1);
V->addLayout( H );
Leds[0] = new Opie::Ui::OLedBox( red, LED_Frm );
H->addWidget( Leds[0], 0, Qt::AlignVCenter );
Leds[1] = new Opie::Ui::OLedBox( red, LED_Frm );
H->addWidget( Leds[1], 0, Qt::AlignVCenter );
Leds[2] = new Opie::Ui::OLedBox( red, LED_Frm );
H->addWidget( Leds[2], 0, Qt::AlignVCenter );
V->addStretch(1);
SLOT_ToProfile();
// populate main Listbox
Profiles_LB->clear();
QPEApplication::setStylusOperation(
Profiles_LB->viewport(), QPEApplication::RightOnHold );
connect( Profiles_LB,
SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)),
this, SLOT(SLOT_EditNode(QListBoxItem*)) );
- { Name2Connection_t & M = NSResources->connections();
- NodeCollection * NC;
- // for all connections
- for( QDictIterator<NodeCollection> it(M);
+ { Name2NetworkSetup_t & M = NSResources->networkSetups();
+ NetworkSetup * NC;
+ // for all NetworkSetups
+ for( QDictIterator<NetworkSetup> it(M);
it.current();
++it ) {
NC = it.current();
Profiles_LB->insertItem( NC->devicePixmap(),
NC->name() );
}
}
if( Profiles_LB->count() ) {
Profiles_LB->setSelected( 0, TRUE );
}
// if no profiles -> auto popup editing
- if( NSResources->connections().count() == 0 ) {
+ if( NSResources->networkSetups().count() == 0 ) {
QTimer::singleShot( 100, this, SLOT(SLOT_AddNode() ) );
}
connect( &(NSResources->system()),
SIGNAL( stdoutLine(const QString &) ),
this, SLOT( SLOT_CmdMessage(const QString &) ) );
connect( &(NSResources->system()),
SIGNAL( stderrLine(const QString &) ),
this, SLOT( SLOT_CmdMessage(const QString &) ) );
connect( &(NSResources->system()),
SIGNAL( processEvent(const QString &) ),
this, SLOT( SLOT_CmdMessage(const QString &) ) );
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&)) );
}
@@ -115,183 +115,183 @@ NetworkSettings::~NetworkSettings() {
S.insert( 0, "<p>" );
S.append( "</p>" );
// problem saving
QMessageBox::warning(
0,
tr( "Saving setup" ), S );
}
SLOT_GenerateConfig();
NSD.setModified( 0 );
}
}
void NetworkSettings::SLOT_CmdMessage( const QString & S ) {
Messages_LB->insertItem( S );
Messages_LB->setCurrentItem( Messages_LB->count()-1 );
Messages_LB->ensureCurrentVisible();
}
void NetworkSettings::SLOT_RefreshStates( void ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember
if( LBI ) {
- NodeCollection * NC;
+ NetworkSetup * NC;
NSResources->system().probeInterfaces();
// update current selection only
- NC = NSResources->findConnection( LBI->text() );
+ NC = NSResources->findNetworkSetup( LBI->text() );
if( NC ) {
State_t OldS = NC->state();
State_t NewS = NC->state(1);
if( OldS != NewS ) {
updateProfileState( LBI );
}
}
}
/* -> LATER !!
bool is;
- NodeCollection * NC;
+ NetworkSetup * NC;
for( unsigned int i = 0; i < Profiles_LB->count() ; i ++ ) {
- NC = NSResources->findConnection( Profiles_LB->text(i) );
+ NC = NSResources->findNetworkSetup( 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 ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
if ( ! LBI )
return;
if( QMessageBox::warning(
0,
tr( "Removing profile" ),
tr( "Remove selected profile ?" ),
1, 0 ) == 1 ) {
- NSResources->removeConnection( LBI->text() );
+ NSResources->removeNetworkSetup( LBI->text() );
delete LBI;
NSD.setModified( 1 );
}
}
void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
QString OldName = "";
- EditConnection EC( this );
+ EditNetworkSetup EC( this );
if( LBI ) {
- NodeCollection * NC = NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
if( ! NC ) {
return;
}
OldName = NC->name();
- EC.setConnection( NC );
+ EC.setNetworkSetup( NC );
}
EC.showMaximized();
// disable refresh timer
UpdateTimer->stop();
// we need to retry
while( 1 ) {
if( EC.exec() == QDialog::Accepted ) {
// toplevel item -> store
- NodeCollection * NC = EC.connection();
+ NetworkSetup * NC = EC.networkSetup();
if( NC->isModified() ) {
if( LBI ) {
if( NC->name() != OldName ) {
// find if new name is free
- NodeCollection * LCN = NSResources->findConnection(
+ NetworkSetup * LCN = NSResources->findNetworkSetup(
NC->name() );
if( LCN ) {
QMessageBox::warning(
0,
tr( "In System Config" ),
tr( "Name %1 already exists" ).arg(NC->name())
);
continue; // restart exec
} // else new name
// new name -> remove item
- NSResources->removeConnection( OldName );
- NSResources->addConnection( NC, 0 );
+ NSResources->removeNetworkSetup( OldName );
+ NSResources->addNetworkSetup( NC, 0 );
} // else not changed
// must add it here since change will trigger event
Profiles_LB->changeItem( NC->devicePixmap(),
NC->name(),
Profiles_LB->index( LBI )
);
} else {
// new item
int ci = Profiles_LB->count();
- NSResources->addConnection( NC, 0 );
- NC->setNumber( NSResources->assignConnectionNumber() );
+ NSResources->addNetworkSetup( NC, 0 );
+ NC->setNumber( NSResources->assignNetworkSetupNumber() );
Profiles_LB->insertItem( NC->devicePixmap(), NC->name() );
Profiles_LB->setSelected( ci, TRUE );
}
updateProfileState( LBI );
}
} else {
- // cancelled : reset connection
+ // cancelled : reset NetworkSetup
if( LBI ) {
- NodeCollection * NC = NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
NC->reassign();
}
}
break;
}
// reenable
UpdateTimer->start( 5000 );
}
void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) {
if( LBI == 0 )
return;
- NodeCollection * NC = NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
if( NC->description().isEmpty() ) {
Description_LBL->setText( tr( "<<No description>>" ) );
} else {
Description_LBL->setText( NC->description() );
}
Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() );
bool FrmActive = 1;
bool IsEnabled = 1;
int leds = 0;
switch( NC->state() ) {
case Disabled : // no further work
IsEnabled = 0;
FrmActive = 0;
break;
case Unknown :
case Unchecked :
case Unavailable :
FrmActive = 0;
break;
case Off :
@@ -332,79 +332,79 @@ 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();
if( ! S.isEmpty() ) {
S.insert( 0, "<p>" );
S.append( "</p>" );
QMessageBox::warning(
0,
tr( "Generate config" ),
S);
}
}
void NetworkSettings::SLOT_Disable( bool T ) {
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
QString Msg;
if ( ! LBI )
return;
- NodeCollection * NC = NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() );
Log(( "Prepare to %sable\n", (T) ? "en" : "dis" ));
Msg = NC->setState( (T) ? Disable : Enable );
if( ! Msg.isEmpty() ) {
Msg.insert( 0, "<p>" );
Msg.append( "</p>" );
QMessageBox::warning(
0,
tr( "Activating profile" ),
Msg );
return;
}
// reload new state
NC->state( true );
updateProfileState( LBI );
}
void NetworkSettings::SLOT_Up( void ) {
// bring more up
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
QString Msg;
int led = -1;
if ( ! LBI )
return;
- NodeCollection * NC =
- NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC =
+ NSResources->findNetworkSetup( LBI->text() );
switch( NC->state() ) {
case Disabled : // cannot modify this state
case Unknown : // cannot modify this state
case Unchecked : // cannot modify this state
case Unavailable : // cannot modify this state
case IsUp : // highest UP state
return;
case Off : // -> activate
led = 1;
Down_TB->setEnabled( true );
Log(( "Activate interface %s\n", NC->name().latin1() ));
Msg = NC->setState( Activate );
break;
case Available : // -> up
led = 2;
Log(( "Bring up interface %s\n", NC->name().latin1() ));
Msg = NC->setState( Up );
if( Msg.isEmpty() ) {
Up_TB->setEnabled( false );
}
break;
}
@@ -417,50 +417,50 @@ void NetworkSettings::SLOT_Up( void ) {
Msg );
return;
}
updateProfileState( LBI );
// set color of led we should change
if( led > 0 ) {
Leds[led]->setColor( blue );
Leds[led]->setOn( true );
}
}
void NetworkSettings::SLOT_Down( void ) {
// bring more down
QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
int led = -1;
QString Msg;
if ( ! LBI )
return;
- NodeCollection * NC =
- NSResources->findConnection( LBI->text() );
+ NetworkSetup * NC =
+ NSResources->findNetworkSetup( LBI->text() );
switch( NC->state() ) {
case Disabled : // cannot modify this state
case Unknown : // cannot modify this state
case Unchecked : // cannot modify this state
case Unavailable : // cannot modify this state
case Off : // highest DOWN state
break;
case Available : // -> down
led = 0;
Log(( "Deactivate interface %s\n", NC->name().latin1() ));
Msg = NC->setState( Deactivate );
Down_TB->setEnabled( false );
break;
case IsUp : // highest UP state
led = 1;
Up_TB->setEnabled( true );
Log(( "Bring down interface %s\n", NC->name().latin1() ));
Msg = NC->setState( Down, 1 );
if( Msg.isEmpty() ) {
// remove 'up' file to make sure
unlink ( QString().sprintf( "/tmp/Profile-%d.up", NC->number() ).latin1() );;
}
break;