6 files changed, 24 insertions, 20 deletions
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index 2714dd5..469cec5 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp @@ -1,510 +1,512 @@ #include <stdio.h> #include <unistd.h> #include <errno.h> #include <opie2/odebug.h> #include <opie2/oledbox.h> #include <qpe/qpeapplication.h> #include <qlistbox.h> #include <qlayout.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 <qevent.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" ) ); GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); Disable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); Up_TB->setPixmap( NSResources->getPixmap( "more" ) ); Down_TB->setPixmap( NSResources->getPixmap( "less" ) ); 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*)) ); { 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->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&)) ); } NetworkSettings::~NetworkSettings() { QString S; if( NSD.isModified() ) { S = NSD.saveSettings(); if( ! S.isEmpty() ) { 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 ) { NetworkSetup * NC; NSResources->system().probeInterfaces(); // update current selection only 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; NetworkSetup * NC; for( unsigned int i = 0; i < Profiles_LB->count() ; 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->removeNetworkSetup( LBI->text() ); delete LBI; NSD.setModified( 1 ); } } void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { QString OldName = ""; EditNetworkSetup EC( this ); if( LBI ) { NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); if( ! NC ) { return; } OldName = NC->name(); EC.setNetworkSetup( NC ); } EC.showMaximized(); // disable refresh timer UpdateTimer->stop(); // we need to retry while( 1 ) { if( EC.exec() == QDialog::Accepted ) { // toplevel item -> store NetworkSetup * NC = EC.networkSetup(); if( NC->isModified() ) { if( LBI ) { if( NC->name() != OldName ) { // find if new name is free 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->removeNetworkSetup( OldName ); NSResources->addNetworkSetup( NC, 0 ); } // else not changed - // must add it here since change will trigger event + // no update (will come later) + Profiles_LB->blockSignals( TRUE ); Profiles_LB->changeItem( NC->devicePixmap(), NC->name(), Profiles_LB->index( LBI ) ); + Profiles_LB->blockSignals( FALSE ); } else { // new item int ci = Profiles_LB->count(); NSResources->addNetworkSetup( NC, 0 ); NC->setNumber( NSResources->assignNetworkSetupNumber() ); Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); Profiles_LB->setSelected( ci, TRUE ); } SLOT_RefreshStates(); } } else { // cancelled : reset NetworkSetup if( LBI ) { NetworkSetup * NC = NSResources->findNetworkSetup( LBI->text() ); NC->reassign(); } } break; } // reenable UpdateTimer->start( 5000 ); } void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { if( LBI == 0 ) return; 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 : leds = 1; break; case Available : leds = 2; break; case IsUp : leds = 3; break; } Disable_TB->setOn( ! IsEnabled ); LED_Frm->setEnabled( FrmActive ); for( int i = 0 ; i < leds; i ++ ) { Leds[i]->setColor( red ); Leds[i]->setOn( true ); } for( int i = leds ; i < 3; i ++ ) { Leds[i]->setColor( red ); Leds[i]->setOn( false ); } Up_TB->setEnabled( leds < 3 && leds != 0 ); Down_TB->setEnabled( leds > 0 ); } void NetworkSettings::SLOT_CheckState( void ) { QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); if ( ! LBI ) return; updateProfileState( LBI ); } 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; 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; 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; } if( ! Msg.isEmpty() ) { Msg.insert( 0, "<p>" ); Msg.append( "</p>" ); QMessageBox::warning( 0, tr( "Increase availability" ), 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; 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; } if( ! Msg.isEmpty() ) { Msg.insert( 0, "<p>" ); Msg.append( "</p>" ); QMessageBox::warning( 0, tr( "Decrease availability" ), Msg ); return; } updateProfileState( LBI ); // set color of led we should change if( led >= 0 ) { Leds[led]->setColor( blue ); } } void NetworkSettings::SLOT_ToMessages( void ) { Profiles_LB->hide(); Profile_GB->hide(); Messages_GB->show(); } void NetworkSettings::SLOT_ToProfile( void ) { Profiles_LB->show(); Profile_GB->show(); Messages_GB->hide(); } 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/profile/profileGUI.ui b/noncore/settings/networksettings2/profile/profileGUI.ui index 8b421e8..eeb2e75 100644 --- a/noncore/settings/networksettings2/profile/profileGUI.ui +++ b/noncore/settings/networksettings2/profile/profileGUI.ui @@ -1,527 +1,527 @@ <!DOCTYPE UI><UI> <class>ProfileGUI</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>Profile_FRM</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>551</width> + <width>547</width> <height>547</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Profile</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> <number>1</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>TabWidget6</cstring> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Setup</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>1</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout8</cstring> </property> <grid> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="0" column="0" rowspan="2" colspan="1" > <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox1</cstring> </property> <property stdset="1"> <name>title</name> <string>Start</string> </property> <vbox> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>Automatic_CB</cstring> </property> <property stdset="1"> <name>text</name> <string>Automatically</string> </property> </widget> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>Confirm_CB</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>text</name> <string>Ask</string> </property> <property> <name>layoutMargin</name> </property> </widget> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>Disabled_CB</cstring> + <cstring>Enabled_CB</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>text</name> - <string>Disabled</string> + <string>Enabled</string> </property> <property> <name>layoutMargin</name> </property> </widget> </vbox> </widget> <widget row="0" column="1" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>TriggersVPN_CB</cstring> </property> <property stdset="1"> <name>text</name> <string>Trigger VPN</string> </property> </widget> <spacer row="1" column="1" > <property> <name>name</name> <cstring>Spacer8</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</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> </grid> </widget> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3</cstring> </property> <property stdset="1"> <name>text</name> <string>Description</string> </property> </widget> <widget> <class>QMultiLineEdit</class> <property stdset="1"> <name>name</name> <cstring>Description_LE</cstring> </property> </widget> </vbox> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>State</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget> <class>QFrame</class> <property stdset="1"> <name>name</name> <cstring>Frame73</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>5</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>NoFrame</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Plain</enum> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <hbox> <property stdset="1"> <name>margin</name> <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>InterfaceName_LBL</cstring> </property> <property stdset="1"> <name>font</name> <font> <underline>1</underline> </font> </property> <property stdset="1"> <name>text</name> <string>eth0</string> </property> </widget> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>InterfaceOptions_LBL</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>font</name> <font> <underline>1</underline> </font> </property> <property stdset="1"> <name>text</name> <string>(Multicast, Up)</string> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> </hbox> </widget> <widget> <class>QFrame</class> <property stdset="1"> <name>name</name> <cstring>Interface_GB</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>5</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> <grid> <property stdset="1"> <name>margin</name> <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>1</number> </property> <widget row="0" column="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel4_2_3</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>1</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>Subnet Mask</string> </property> </widget> <widget row="0" column="3" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_3_3</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>1</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>Broadcast</string> </property> </widget> <widget row="3" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_5</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>1</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>MAC</string> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_5_2</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>1</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>P-t-P</string> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> </widget> <widget row="0" column="0" rowspan="1" colspan="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3_2_3</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>IP Address</string> </property> </widget> <widget row="1" column="0" rowspan="1" colspan="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>IPAddress_LBL</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>frameShape</name> <enum>Panel</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>text</name> <string>0.0.0.0</string> </property> <property stdset="1"> <name>alignment</name> <set>AlignCenter</set> </property> <property stdset="1"> <name>indent</name> <number>0</number> </property> <property> <name>hAlign</name> </property> </widget> <widget row="1" column="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>SubnetMask_LBL</cstring> </property> diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp index fc2d809..0bc13d1 100644 --- a/noncore/settings/networksettings2/profile/profile_NNI.cpp +++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp @@ -1,81 +1,83 @@ #include <qpe/qpeapplication.h> #include <opie2/odebug.h> #include "profileedit.h" #include "profile_NNI.h" #include "profile_NN.h" AProfile::AProfile( ProfileNetNode * PNN ) : ANetNodeInstance( PNN ) { Data.Automatic = 1; Data.Confirm = 0; Data.Description = ""; - Data.Disabled = 0; + Data.Enabled = 1; Data.TriggerVPN = 0; GUI = 0; RT = 0; } void AProfile::setSpecificAttribute( QString & Attr, QString & Value ) { if ( Attr == "automatic" ) { Data.Automatic = (Value=="yes"); } else if ( Attr == "preconfirm" ) { Data.Confirm = (Value=="yes"); } else if ( Attr == "disabled" ) { - Data.Disabled = (Value=="yes"); + Data.Enabled = (Value=="no"); + } else if ( Attr == "enabled" ) { + Data.Enabled = (Value=="yes"); } else if ( Attr == "triggervpn" ) { Data.TriggerVPN = (Value=="yes"); } else if ( Attr == "description" ) { Data.Description = Value; } } void AProfile::saveSpecificAttribute( QTextStream & TS ) { TS << "automatic=" << ((Data.Automatic) ? "yes" : "no") << endl; TS << "preconfirm=" << ((Data.Confirm) ? "yes" : "no") << endl; - TS << "disabled=" << ((Data.Disabled) ? "yes" : "no") << endl; + TS << "enabled=" << ((Data.Enabled) ? "yes" : "no") << endl; TS << "triggervpn=" << ((Data.TriggerVPN) ? "yes" : "no") << endl; TS << "description=" << Data.Description << endl; } QWidget * AProfile::edit( QWidget * parent ) { GUI = new ProfileEdit( parent, this ); GUI->showData( Data ); return GUI; } QString AProfile::acceptable( void ) { return ( GUI ) ? GUI->acceptable( ) : QString(); } void AProfile::commit( void ) { if( GUI && GUI->commit( Data ) ) setModified( 1 ); } short AProfile::generateFileEmbedded( SystemFile & SF, long DevNr ) { short rvl, rvd; rvl = 1; if( SF.name() == "interfaces" ) { Log(("Generate Profile for %s\n", SF.name().latin1() )); if( Data.TriggerVPN ) { // this profile triggers VPN -> insert trigger SF << " up " << QPEApplication::qpeDir() << "bin/networksettings2 --triggervpn " << runtime()->device()->netNode()->nodeClass()->genNic( DevNr ) << " || true" << endl; rvl = 0; } } rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr ); return (rvd == 2 || rvl == 2 ) ? 2 : (rvd == 0 || rvl == 0 ) ? 0 : 1; } diff --git a/noncore/settings/networksettings2/profile/profiledata.h b/noncore/settings/networksettings2/profile/profiledata.h index 2f7060d..376b393 100644 --- a/noncore/settings/networksettings2/profile/profiledata.h +++ b/noncore/settings/networksettings2/profile/profiledata.h @@ -1,17 +1,17 @@ #ifndef PROFILE_DATA_H #define PROFILE_DATA_H #include <qstring.h> class ProfileData { public : QString Description; // start up automatically bool Automatic; // if started up automatically, ask user for confirmation bool Confirm; - // Do not bring this networkSetup up - bool Disabled; + // bring this networkSetup up + bool Enabled; bool TriggerVPN; } ; #endif diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp index 1713f0c..818bad6 100644 --- a/noncore/settings/networksettings2/profile/profileedit.cpp +++ b/noncore/settings/networksettings2/profile/profileedit.cpp @@ -1,125 +1,125 @@ #include <qlabel.h> #include <qgroupbox.h> #include <qpushbutton.h> #include <qframe.h> #include <qcheckbox.h> #include <qmultilineedit.h> #include <qcheckbox.h> #include <GUIUtils.h> #include <netnode.h> #include <resources.h> #include "profileedit.h" ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : ProfileGUI( Parent ), RefreshTimer(this) { InterfaceInfo * II; II = TNNI->networkSetup()->assignedInterface(); Log(( "Interface %p %p %p: %d\n", II, TNNI, TNNI->networkSetup(), (II) ? II->IsUp : 0 )); NNI = TNNI; Dev = NNI->runtime()->device(); if( ( II = NNI->networkSetup()->assignedInterface() ) ) { Refresh_CB->setEnabled( TRUE ); ResetODO_But->setEnabled( TRUE ); Sending_GB->setEnabled( TRUE ); Receiving_GB->setEnabled( TRUE ); Misc_GB->setEnabled( TRUE ); // show current content SLOT_Refresh(); // initialize ODO SLOT_ResetODO(); // fill in static data InterfaceName_LBL->setText( II->Name ); IPAddress_LBL->setText( II->Address ); SubnetMask_LBL->setText( II->Netmask ); Broadcast_LBL->setText( II->BCastAddress ); MACAddress_LBL->setText( II->MACAddress ); if( II->IsPointToPoint ) { PointToPoint_LBL->setText( II->DstAddress ); } QString S; InterfaceName_LBL->setText( II->Name ); if( II->HasMulticast ) { S += "Multicast"; } if( ! S.isEmpty() ) { S.prepend( " : " ); } InterfaceOptions_LBL->setText( S ); connect( &RefreshTimer, SIGNAL( timeout() ), this, SLOT( SLOT_Refresh() ) ); } } QString ProfileEdit::acceptable( void ) { return QString(); } void ProfileEdit::showData( ProfileData & Data ) { Description_LE->setText( Data.Description ); Automatic_CB->setChecked( Data.Automatic ); TriggersVPN_CB->setChecked( Data.TriggerVPN ); Confirm_CB->setChecked( Data.Confirm ); - Disabled_CB->setChecked( Data.Disabled ); + Enabled_CB->setChecked( Data.Enabled ); } bool ProfileEdit::commit( ProfileData & Data ) { bool SM = 0; TXTM( Data.Description, Description_LE, SM ); CBM( Data.Automatic, Automatic_CB, SM ); CBM( Data.TriggerVPN, TriggersVPN_CB, SM ); - CBM( Data.Disabled, Disabled_CB, SM ); + CBM( Data.Enabled, Enabled_CB, SM ); CBM( Data.Confirm, Confirm_CB, SM ); return SM; } void ProfileEdit::SLOT_Refresh( void ) { InterfaceInfo * II = NNI->networkSetup()->assignedInterface(); QString S; NSResources->system().refreshStatistics( *II ); RcvBytes_LBL->setText( II->RcvBytes ); RcvPackets_LBL->setText( II->RcvPackets ); RcvErrors_LBL->setText( II->RcvErrors ); RcvDropped_LBL->setText( II->RcvDropped ); S.setNum( II->RcvBytes.toLong() - RcvODO ); RcvODO_LBL->setText( S ); SndBytes_LBL->setText( II->SndBytes ); SndPackets_LBL->setText( II->SndPackets ); SndErrors_LBL->setText( II->SndErrors ); SndDropped_LBL->setText( II->SndDropped ); S.setNum( II->SndBytes.toLong() - SndODO ); SndODO_LBL->setText( S ); Collisions_LBL->setText( II->Collisions ); } void ProfileEdit::SLOT_AutoRefresh( bool ar ) { if( ar ) { RefreshTimer.start( 1000 ); SLOT_Refresh(); } else { RefreshTimer.stop(); } } void ProfileEdit::SLOT_ResetODO( void ) { InterfaceInfo * II = NNI->networkSetup()->assignedInterface(); RcvODO = II->RcvBytes.toLong(); SndODO = II->SndBytes.toLong(); SLOT_Refresh(); } diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp index 77bf9ac..faa7d66 100644 --- a/noncore/settings/networksettings2/profile/profilerun.cpp +++ b/noncore/settings/networksettings2/profile/profilerun.cpp @@ -1,30 +1,30 @@ #include <resources.h> #include "profilerun.h" State_t ProfileRun::detectState( void ) { - Log(( "Profile %sabled\n", (Data->Disabled) ? "dis" : "en" )); + Log(( "Profile %sabled\n", (Data->Enabled) ? "en" : "dis" )); - if( Data->Disabled ) { - return Disabled; + if( Data->Enabled ) { + return Unknown; } - return Unknown; + return Disabled; } QString ProfileRun::setMyState( NetworkSetup * NC, Action_t A, bool ) { - odebug << "Profile " << Data->Disabled << oendl; + odebug << "Profile " << Data->Enabled << oendl; if( A == Disable ) { - if( ! Data->Disabled ) { - Data->Disabled = 1; + if( Data->Enabled ) { + Data->Enabled = 0; NC->setModified( 1 ); } } else if( A == Enable ) { - if( Data->Disabled ) { - Data->Disabled = 0; + if( ! Data->Enabled ) { + Data->Enabled = 1; NC->setModified( 1 ); } } return QString(); } |