author | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:35:26 (UTC) |
commit | a9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (side-by-side diff) | |
tree | 13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf | |
parent | 48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff) | |
download | opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2 |
CONTROL files : changed version string
NS2 many changes and first release of OT2
175 files changed, 2876 insertions, 2059 deletions
diff --git a/noncore/applets/zkbapplet/zkbapplet.control b/noncore/applets/zkbapplet/zkbapplet.control index 4e03c26..08b540f 100644 --- a/noncore/applets/zkbapplet/zkbapplet.control +++ b/noncore/applets/zkbapplet/zkbapplet.control @@ -8,3 +8,3 @@ Depends: task-opie-minimal Description: ZKB Applet and configuration program Obsoletes: keyz-cfg -Version: 0.6.0$EXTRAVERSION +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/confedit/opie-confeditor.control b/noncore/apps/confedit/opie-confeditor.control index 00a05da..b49aad3 100644 --- a/noncore/apps/confedit/opie-confeditor.control +++ b/noncore/apps/confedit/opie-confeditor.control @@ -5,5 +5,5 @@ Section: opie/settings Maintainer: Patrick S. Vogt <tille@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopiecore2 Description: An enditor for the ~/Settings/*.conf files diff --git a/noncore/apps/dagger/opie-dagger.control b/noncore/apps/dagger/opie-dagger.control index 4ded1f2..cfb45be 100644 --- a/noncore/apps/dagger/opie-dagger.control +++ b/noncore/apps/dagger/opie-dagger.control @@ -7,3 +7,3 @@ Architecture: arm Maintainer: Dan Williams (drw@handhelds.org) Description: A Bible study program utilizing the Sword library. -Version: 0.9.1$EXTRAVERSION +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/apps/opie-bartender/opie-bartender.control b/noncore/apps/opie-bartender/opie-bartender.control index 045c68e..29ad0ba 100644 --- a/noncore/apps/opie-bartender/opie-bartender.control +++ b/noncore/apps/opie-bartender/opie-bartender.control @@ -5,5 +5,5 @@ Section: opie/applications Maintainer: L.J. Potter <lpotter@trolltech.com> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal Description: Bartender drink receipe database lookup, and diff --git a/noncore/apps/opie-console/opie-console-embedix.control b/noncore/apps/opie-console/opie-console-embedix.control index cf27554..e902d0e 100644 --- a/noncore/apps/opie-console/opie-console-embedix.control +++ b/noncore/apps/opie-console/opie-console-embedix.control @@ -5,5 +5,5 @@ Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: 0.6-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: qpe-base, libopiecore2, libopieui2, opie-console-help-en, lrzsz, opie-keytabs License: GPL diff --git a/noncore/apps/opie-console/opie-console.control b/noncore/apps/opie-console/opie-console.control index e924b79..b64898b 100644 --- a/noncore/apps/opie-console/opie-console.control +++ b/noncore/apps/opie-console/opie-console.control @@ -5,5 +5,5 @@ Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: 0.6-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: qpe-base, libopiecore2, libopieui2, opie-console-help-en, lrzsz, opie-keytabs License: GPL diff --git a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control index 47fbcdf..bc0283e 100644 --- a/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control +++ b/noncore/apps/opie-gutenbrowser/opie-gutenbrowser.control @@ -6,5 +6,5 @@ Maintainer: ljp <lpotter@trolltech.com> Source: opie.handhelds.org Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: ftplib, libopiecore2, libopieui2 Description: Etext read for the Project Gutenberg. diff --git a/noncore/games/bounce/opie-bounce.control b/noncore/games/bounce/opie-bounce.control index dfd1bf0..0513958 100644 --- a/noncore/games/bounce/opie-bounce.control +++ b/noncore/games/bounce/opie-bounce.control @@ -1,5 +1,5 @@ Package: opie-bounce Files: plugins/application/libbounce.so* bin/bounce apps/Games/bounce.desktop pics/bounce/*.png -Version: 0.6-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopiecore2 Priority: optional diff --git a/noncore/games/buzzword/opie-buzzword.control b/noncore/games/buzzword/opie-buzzword.control index 3316445..f76a2c2 100644 --- a/noncore/games/buzzword/opie-buzzword.control +++ b/noncore/games/buzzword/opie-buzzword.control @@ -1,5 +1,5 @@ Package: opie-buzzword Files: plugins/application/libbuzzword.so* bin/buzzword apps/Games/buzzword.desktop pics/buzzword/buzzword.png share/buzzword/buzzwords -Version: 1.1-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal,libopiecore2 Priority: optional diff --git a/noncore/games/kbill/opie-kbill.control b/noncore/games/kbill/opie-kbill.control index 3299b93..cf12bca 100644 --- a/noncore/games/kbill/opie-kbill.control +++ b/noncore/games/kbill/opie-kbill.control @@ -5,5 +5,5 @@ Section: opie/games Maintainer: Mark Westcott <mark@houseoffish.org> Architecture: arm -Version: 0.8-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal License: GPL diff --git a/noncore/games/kcheckers/opie-kcheckers.control b/noncore/games/kcheckers/opie-kcheckers.control index 5bd03ae..e7c20d3 100644 --- a/noncore/games/kcheckers/opie-kcheckers.control +++ b/noncore/games/kcheckers/opie-kcheckers.control @@ -5,5 +5,5 @@ Section: opie/games Maintainer: leseb <prudhomme@laposte.net> Architecture: arm -Version: 0.3-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopiecore2 Description: The game of Checkers diff --git a/noncore/games/kpacman/opie-kpacman.control b/noncore/games/kpacman/opie-kpacman.control index 68487ec..97120aa 100644 --- a/noncore/games/kpacman/opie-kpacman.control +++ b/noncore/games/kpacman/opie-kpacman.control @@ -1,5 +1,5 @@ Package: opie-kpacman Files: plugins/applications/libkpacman.so* bin/kpacman apps/Games/kpacman.desktop pics/kpacman/kpacman.png share/kpacman -Version: 0.3.1-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal Priority: optional diff --git a/noncore/games/tetrix/ohighscoredlg.cpp b/noncore/games/tetrix/ohighscoredlg.cpp index 8d8079e..66f4917 100644 --- a/noncore/games/tetrix/ohighscoredlg.cpp +++ b/noncore/games/tetrix/ohighscoredlg.cpp @@ -20,4 +20,5 @@ #include <qstring.h> +#include <qlist.h> #include <qhbox.h> #include <qvbox.h> @@ -28,18 +29,14 @@ #include "ohighscoredlg.h" -OHighscore::OHighscore( int score , int playerLevel ) +OHighscore::OHighscore( int score , int playerLevel ) : playerData() { pLevel = playerLevel; getList(); checkIfItIsANewhighscore( score ); + playerData.setAutoDelete( TRUE ); } OHighscore::~OHighscore() { - std::list<t_playerData*>::iterator deleteIterator = playerData.begin(); - for ( ; deleteIterator != playerData.end() ; deleteIterator++ ) - { - delete ( *deleteIterator ); - } } @@ -65,5 +62,5 @@ void OHighscore::getList() pPlayerData->level = cfg.readNumEntry( "Level" ); - playerData.push_back( pPlayerData ); + playerData.append( pPlayerData ); if ( (temp < lowest) ) lowest = temp; @@ -84,5 +81,5 @@ void OHighscore::getList() pPlayerData->level = 0; - playerData.push_back( pPlayerData ); + playerData.append( pPlayerData ); } } @@ -101,9 +98,13 @@ void OHighscore::insertData( QString name , int punkte , int playerLevel ) { Config cfg ( "tetrix" ); + t_playerData * Run; + int index = 0; int entryNumber = 1; - std::list<t_playerData*>::iterator insertIterator = playerData.begin(); - while ( insertIterator != playerData.end() ) - { - if ( punkte > ( *insertIterator )->points ) + + for ( Run=playerData.first(); + Run != 0; + index ++, Run=playerData.next() ) { + + if ( punkte > Run->points ) { t_playerData* temp = new t_playerData; @@ -111,23 +112,20 @@ void OHighscore::insertData( QString name , int punkte , int playerLevel ) temp->points = punkte; temp->level = playerLevel; - playerData.insert( insertIterator , temp ); + + playerData.insert( index, temp ); //now we have to delete the last entry - insertIterator = playerData.end(); - insertIterator--; -//X delete *insertIterator; //memleak? - playerData.erase( insertIterator ); + playerData.remove( playerData.count() ); ///////////////////////////////////////// //this block just rewrites the highscore - insertIterator = playerData.begin(); - while ( insertIterator != playerData.end() ) - { + for ( t_playerData * Run2=playerData.first(); + Run2 != 0; + Run2=playerData.next() ) { cfg.setGroup( QString::number( entryNumber ) ); - cfg.writeEntry( "Name" , ( *insertIterator )->sName ); - cfg.writeEntry( "Points" , ( *insertIterator )->points ); - cfg.writeEntry( "Level" , ( *insertIterator )->level ); + cfg.writeEntry( "Name" , Run2->sName ); + cfg.writeEntry( "Points" , Run2->points ); + cfg.writeEntry( "Level" , Run2->level ); entryNumber++; - insertIterator++; } //////////////////////////////////////// @@ -135,5 +133,4 @@ void OHighscore::insertData( QString name , int punkte , int playerLevel ) return; } - insertIterator++; } } @@ -178,18 +175,28 @@ void OHighscoreDialog::createHighscoreListView() int points_ = 0; int level_ = 0; - - std::list<t_playerData*>::reverse_iterator iListe = hs_->playerData.rbegin(); - - for ( ; iListe != hs_->playerData.rend() ; ++iListe ) - { - QListViewItem *item = new QListViewItem( list ); + QListViewItem * Prev = 0; + + for ( t_playerData * Run = hs_->playerData.first(); + Run != 0; + Run=hs_->playerData.next() ) + { + QListViewItem *item; + + if( Prev ) { + // after previous + item = new QListViewItem( list, Prev ); + Prev = item; + } else { + item = new QListViewItem( list ); + + } item->setText( 0 , QString::number( pos ) ); //number - item->setText( 1 , ( *iListe )->sName ); //name - if ( ( *iListe )->points == -1 ) + item->setText( 1 , Run->sName ); //name + if ( Run->points == -1 ) points_ = 0; - else points_ = ( *iListe )->points; - if ( ( *iListe )->level == -1 ) - level_ = 0; - else level_ = ( *iListe )->level; + else points_ = Run->points; + if ( Run->level == -1 ) + level_ = 0; + else level_ = Run->level; item->setText( 2 , QString::number( points_ ) ); //points item->setText( 3 , QString::number( level_ ) ); //level diff --git a/noncore/games/tetrix/ohighscoredlg.h b/noncore/games/tetrix/ohighscoredlg.h index fdbe623..845e639 100644 --- a/noncore/games/tetrix/ohighscoredlg.h +++ b/noncore/games/tetrix/ohighscoredlg.h @@ -13,10 +13,11 @@ class QListView; #include <qdialog.h> -#include <list> +#include <qlist.h> -using namespace std; - -struct t_playerData +class t_playerData { + +public : + QString sName; int points; @@ -46,5 +47,5 @@ class OHighscore : public QWidget void insertData( QString , int , int ); - list<t_playerData*> playerData; + QList<t_playerData> playerData; /* @@ -54,6 +55,4 @@ class OHighscore : public QWidget private: - list<t_playerData*>::iterator iPlayerData; - /* * the lowest score in the highscorelist diff --git a/noncore/games/tetrix/tetrix.pro b/noncore/games/tetrix/tetrix.pro index 580a542..96f452f 100644 --- a/noncore/games/tetrix/tetrix.pro +++ b/noncore/games/tetrix/tetrix.pro @@ -13,5 +13,5 @@ SOURCES = main.cpp \ INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lopiecore2 -lstdc++ +LIBS += -lqpe -lopiecore2 INTERFACES = TARGET = tetrix diff --git a/noncore/multimedia/camera/opie-camera.control b/noncore/multimedia/camera/opie-camera.control index d9eaab8..5171050 100644 --- a/noncore/multimedia/camera/opie-camera.control +++ b/noncore/multimedia/camera/opie-camera.control @@ -5,5 +5,5 @@ Section: opie/multimedia Maintainer: Michael 'Mickey' Lauer <mickeyl@Vanille.de> Architecture: arm -Version: 1.0.1 +Version: $QPE_VERSION$EXTRAVERSION Depends: libqpe1, libopiecore2, libopieui2 Description: A Camera Application diff --git a/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control b/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control index 1d0fbfb..f4cbc41 100644 --- a/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control +++ b/noncore/multimedia/opieplayer2/opie-mediaplayer2-codecs.control @@ -4,5 +4,5 @@ Section: ;ibs Essential: no Priority: optional -Version: 0.7-$SUB_VERSION.3 +Version: $QPE_VERSION$EXTRAVERSION Architecture: arm Maintainer: Maximilian Reiss <harlekin@handhelds.org> diff --git a/noncore/multimedia/opieplayer2/opie-mediaplayer2.control b/noncore/multimedia/opieplayer2/opie-mediaplayer2.control index af6bb01..78cfa8b 100644 --- a/noncore/multimedia/opieplayer2/opie-mediaplayer2.control +++ b/noncore/multimedia/opieplayer2/opie-mediaplayer2.control @@ -5,5 +5,5 @@ Section: opie/multimedia Maintainer: L.J.Potter <ljp@llornkcor.com>, Maximilian Reiss <harlekin@handhelds.org> Architecture: arm -Depends: task-opie-minimal, libopie1, zlib1g, opie-mediaplayer2-skin-default | opie-mediaplayer2-skin-default-landscape , libxine1 | opie-mediaplayer2-codecs +Depends: task-opie-minimal, libopiecore2, libopieui2, libqtaux2, libz1, opie-mediaplayer2-skin-default | opie-mediaplayer2-skin-default-landscape , libxine1 | opie-mediaplayer2-codecs Description: The Opie media player The mediaplayer for Opie. It plays mp3, mpeg, wav, ogg, quicktime, divx and diff --git a/noncore/multimedia/powerchord/opie-powerchord.control b/noncore/multimedia/powerchord/opie-powerchord.control index 39d926b..4b5bc88 100644 --- a/noncore/multimedia/powerchord/opie-powerchord.control +++ b/noncore/multimedia/powerchord/opie-powerchord.control @@ -4,5 +4,5 @@ Section: opie/multimedia Maintainer: Camilo Mesias <camilo@mesias.co.uk>, ljp <lpotter@trolltech.com> Architecture: arm -Version: 0.0.8 +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal Description: Guitar Chord generator application diff --git a/noncore/net/mail/libetpanstuff/libetpan.control b/noncore/net/mail/libetpanstuff/libetpan.control index 2b5b354..b664157 100644 --- a/noncore/net/mail/libetpanstuff/libetpan.control +++ b/noncore/net/mail/libetpanstuff/libetpan.control @@ -5,5 +5,5 @@ Section: system Maintainer: Rajko Albrecht <alwin@handhelds.org> Architecture: arm -Version: 0.33pre-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: libssl0.9.7 Description: libetpan mail/news library - A version of libetpan patched for Opies mailing app diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.control b/noncore/net/mail/libmailwrapper/libmailwrapper.control index ec55bb3..3491d67 100644 --- a/noncore/net/mail/libmailwrapper/libmailwrapper.control +++ b/noncore/net/mail/libmailwrapper/libmailwrapper.control @@ -5,5 +5,5 @@ Section: libs Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> Architecture: arm -Version: 0.6-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopiecore2, libopieui2, libetpan (>= 0.33pre) Description: wrapper lib needed by Opie's mailer diff --git a/noncore/net/mail/opie-mail.control b/noncore/net/mail/opie-mail.control index 698aaa7..e3b18b3 100644 --- a/noncore/net/mail/opie-mail.control +++ b/noncore/net/mail/opie-mail.control @@ -5,5 +5,5 @@ Section: opie/pim Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> Architecture: arm -Version: 0.6-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopiecore2, libopieui2, libopiemm2, libopiedb2, libmailwrapper (>= 0.6), libssl Description: Opie's mail and news client (POP3, IMAP and NNTP) diff --git a/noncore/net/mail/taskbarapplet/opie-mailapplet.control b/noncore/net/mail/taskbarapplet/opie-mailapplet.control index f9822a5..c838e0b 100644 --- a/noncore/net/mail/taskbarapplet/opie-mailapplet.control +++ b/noncore/net/mail/taskbarapplet/opie-mailapplet.control @@ -5,5 +5,5 @@ Section: opie/applets Maintainer: Rajko Albrecht <alwin@handhelds.org>, Juergen Graf <jgf@handhelds.org>, Maximilian Reiß <harlekin@handhelds.org> Architecture: arm -Version: 0.5-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopiecore2, opie-mail Description: A Biff-like mailchecker diff --git a/noncore/net/opieirc/opie-irc.control b/noncore/net/opieirc/opie-irc.control index b9f20f0..195b5ff 100644 --- a/noncore/net/opieirc/opie-irc.control +++ b/noncore/net/opieirc/opie-irc.control @@ -5,5 +5,5 @@ Section: opie/applications Maintainer: Wenzel Jakob <root@wazlaf.de> Architecture: arm -Depends: task-opie-minimal, libopie1 +Depends: task-opie-minimal, libopiecore2, libopieui2, libqtaux2 Description: The Opie IRC client lets you chat on your favorite IRC server using your handheld computer Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/net/opierdesktop/opie-rdesktop.control b/noncore/net/opierdesktop/opie-rdesktop.control index a8726e0..2a9d415 100644 --- a/noncore/net/opierdesktop/opie-rdesktop.control +++ b/noncore/net/opierdesktop/opie-rdesktop.control @@ -5,5 +5,5 @@ Section: opie/applications Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org> Architecture: arm -Version: 1.2.0-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal Description: Remote Desktop Protocol (RDP) Client diff --git a/noncore/net/opietooth/blue-pin/main.cc b/noncore/net/opietooth/blue-pin/main.cc index 1ab1f2e..dbe5b41 100644 --- a/noncore/net/opietooth/blue-pin/main.cc +++ b/noncore/net/opietooth/blue-pin/main.cc @@ -10,3 +10,2 @@ using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<OpieTooth::PinDlg> ) - diff --git a/noncore/net/opietooth/blue-pin/opie-bluepin.control b/noncore/net/opietooth/blue-pin/opie-bluepin.control index 7147975..e9aa683 100644 --- a/noncore/net/opietooth/blue-pin/opie-bluepin.control +++ b/noncore/net/opietooth/blue-pin/opie-bluepin.control @@ -5,5 +5,5 @@ Section: opie/applications Maintainer: Holger Freyther <zecke@handhelds.org> Architecture: arm -Version: 0.3.4-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal License: GPL diff --git a/noncore/net/opietooth/blue-pin/pindlgbase.ui b/noncore/net/opietooth/blue-pin/pindlgbase.ui index 889a25e..6784de7 100644 --- a/noncore/net/opietooth/blue-pin/pindlgbase.ui +++ b/noncore/net/opietooth/blue-pin/pindlgbase.ui @@ -13,5 +13,5 @@ <x>0</x> <y>0</y> - <width>258</width> + <width>254</width> <height>245</height> </rect> @@ -30,19 +30,4 @@ <number>6</number> </property> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>txtStatus</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string></string> - </property> - <property stdset="1"> - <name>textFormat</name> - <enum>RichText</enum> - </property> - </widget> <spacer> <property> @@ -67,4 +52,19 @@ </spacer> <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>txtStatus</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string></string> + </property> + <property stdset="1"> + <name>textFormat</name> + <enum>RichText</enum> + </property> + </widget> + <widget> <class>QLayoutWidget</class> <property stdset="1"> diff --git a/noncore/net/opietooth/lib/libopietooth1.control b/noncore/net/opietooth/lib/libopietooth1.control index 20e4b76..9bc9572 100644 --- a/noncore/net/opietooth/lib/libopietooth1.control +++ b/noncore/net/opietooth/lib/libopietooth1.control @@ -6,5 +6,5 @@ Maintainer: Maximilian Reiß <max.reiss@gmx.de> Architecture: arm Replaces: libopietooth -Depends: libqte2 (>=2.3.4), libopie1, task-bluez +Depends: libqte2 (>=2.3.4), libopiecore2, task-bluez Description: Opie bluetooth library Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/net/opietooth/manager/opie-bluetoothmanager.control b/noncore/net/opietooth/manager/opie-bluetoothmanager.control index 4fe1e06..89ab698 100644 --- a/noncore/net/opietooth/manager/opie-bluetoothmanager.control +++ b/noncore/net/opietooth/manager/opie-bluetoothmanager.control @@ -5,5 +5,5 @@ Section: opie/settings Maintainer: Maximilian Reiß <max.reiss@gmx.de> Architecture: arm -Version: 0.5.4-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopietooth1, opie-bluepin License: GPL diff --git a/noncore/net/wellenreiter/opie-wellenreiter.control b/noncore/net/wellenreiter/opie-wellenreiter.control index e7bc25d..7dc9c22 100644 --- a/noncore/net/wellenreiter/opie-wellenreiter.control +++ b/noncore/net/wellenreiter/opie-wellenreiter.control @@ -5,6 +5,6 @@ Section: opie/applications Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org> Architecture: arm -Version: 1.0.3-cvs -Depends: libqpe1, libpcap0 (>=0.7.2), libopiecore2, libopienet2, libopieui2 +Version: $QPE_VERSION$EXTRAVERSION +Depends: libqpe1, libpcap0.8 (>=0.7.2), libopiecore2, libopienet2, libopieui2 Description: A WaveLAN Network Monitor A WaveLAN Network Monitor/Sniffer for the Opie Environment. diff --git a/noncore/securityplugins/blueping/bluepingplugin.control b/noncore/securityplugins/blueping/bluepingplugin.control index 0339996..62562f7 100644 --- a/noncore/securityplugins/blueping/bluepingplugin.control +++ b/noncore/securityplugins/blueping/bluepingplugin.control @@ -5,5 +5,5 @@ Section: opie/settings Maintainer: Clement Seveillac <clement@nist.gov> Architecture: arm -Version: 0.0.2.7 +Version: $QPE_VERSION$EXTRAVERSION Depends: libopiecore2, opie-security, bluez-utils (<= 2.3rel-hh5) Description: Blueping plugin for opie-security authentication. diff --git a/noncore/securityplugins/dummy/dummyplugin.control b/noncore/securityplugins/dummy/dummyplugin.control index 0ab2491..b4cc5e2 100644 --- a/noncore/securityplugins/dummy/dummyplugin.control +++ b/noncore/securityplugins/dummy/dummyplugin.control @@ -5,5 +5,5 @@ Section: opie/settings Maintainer: Clement Seveillac <clement@nist.gov> Architecture: arm -Version: 0.0.2.3 +Version: $QPE_VERSION$EXTRAVERSION Depends: libopiecore2, opie-security Description: Dummy plugin for opie-security authentication. diff --git a/noncore/securityplugins/notice/notice.control b/noncore/securityplugins/notice/notice.control index 8b8c7cd..091ce74 100644 --- a/noncore/securityplugins/notice/notice.control +++ b/noncore/securityplugins/notice/notice.control @@ -5,5 +5,5 @@ Section: opie/settings Maintainer: Clement Seveillac <clement@nist.gov> Architecture: arm -Version: 0.0.1.6 +Version: $QPE_VERSION$EXTRAVERSION Depends: libopiecore2, opie-security Description: Notice plugin for opie-security authentication. diff --git a/noncore/securityplugins/pin/pin.control b/noncore/securityplugins/pin/pin.control index 3709d08..51c3f08 100644 --- a/noncore/securityplugins/pin/pin.control +++ b/noncore/securityplugins/pin/pin.control @@ -5,5 +5,5 @@ Section: opie/settings Maintainer: Clement Seveillac <clement@nist.gov> Architecture: arm -Version: 0.0.2.6 +Version: $QPE_VERSION$EXTRAVERSION Depends: libopiecore2, opie-security Description: PIN plugin for opie-security authentication. diff --git a/noncore/settings/networksettings2/activatevpn.cpp b/noncore/settings/networksettings2/activatevpn.cpp index 2bdef0a..b75e623 100644 --- a/noncore/settings/networksettings2/activatevpn.cpp +++ b/noncore/settings/networksettings2/activatevpn.cpp @@ -23,19 +23,13 @@ ActivateVPN::ActivateVPN( void ) : QCheckListItem * CI; - printf( "%d\n", __LINE__ ); VPN_LV->clear(); VPN_LV->header()->hide(); - printf( "%d\n", __LINE__ ); for( QDictIterator<NodeCollection> it(NSResources->connections()); it.current(); ++it ) { - printf( "%d\n", __LINE__ ); if( it.current()->triggeredBy( "vpn" ) ) { - printf( "%d\n", __LINE__ ); CI = new MyCheckListItem( it.current(), VPN_LV ); - printf( "%d\n", __LINE__ ); } - printf( "%d\n", __LINE__ ); } } diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth.pro b/noncore/settings/networksettings2/bluetooth/bluetooth.pro index 8170d46..2e3b5bb 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth.pro +++ b/noncore/settings/networksettings2/bluetooth/bluetooth.pro @@ -2,18 +2,22 @@ TEMPLATE = lib CONFIG += qt warn_on release DESTDIR = $(OPIEDIR)/plugins/networksettings2 -HEADERS = bluetooth_NN.h \ +HEADERS = bluetoothBNEP_NN.h \ bluetoothBNEP_NNI.h \ + bluetoothRFCOMM_NN.h \ bluetoothRFCOMM_NNI.h \ bluetoothBNEPedit.h \ + bluetoothRFCOMMrun.h \ bluetoothRFCOMMedit.h -SOURCES = bluetooth_NN.cpp \ +SOURCES = bluetoothBNEP_NN.cpp \ bluetoothBNEP_NNI.cpp \ + bluetoothRFCOMM_NN.cpp \ bluetoothRFCOMM_NNI.cpp \ bluetoothBNEPedit.cpp \ bluetoothBNEPrun.cpp \ + bluetoothRFCOMMrun.cpp \ bluetoothRFCOMMedit.cpp -INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 -DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 -LIBS += -lqpe +INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 ../opietooth2 +DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 ../opietooth2 +LIBS += -lqpe -lopietooth2 INTERFACES = bluetoothBNEPGUI.ui bluetoothRFCOMMGUI.ui TARGET = bluetooth diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp index 398dcdc..42b2515 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp @@ -1,5 +1,5 @@ #include "bluetoothBNEPedit.h" #include "bluetoothBNEP_NNI.h" -#include "bluetooth_NN.h" +#include "bluetoothBNEP_NN.h" ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) : diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h index 03c6903..f52a2c5 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPdata.h @@ -4,8 +4,11 @@ #include <qstringlist.h> -typedef struct BluetoothBNEPData { +class BluetoothBNEPData { + +public : + bool AllowAll; QStringList BDAddress; -} BluetoothBNEPData_t; +}; #endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp index 24e4b7b..9d4ae97 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.cpp @@ -5,245 +5,157 @@ #include "bluetoothBNEPrun.h" -QDict<QString> * BluetoothBNEPRun::PANConnections = 0; +BluetoothBNEPRun::BluetoothBNEPRun( ANetNodeInstance * NNI, + BluetoothBNEPData & D ) : + RuntimeInfo( NNI ), + Data( D), + Pat( "bnep[0-6]" ) { + OT = 0; +} -void BluetoothBNEPRun::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 ); - - Log(("Detecting for %s\n", NC->name().latin1() )); - - if( F.open( IO_ReadOnly ) ) { - // could open file -> read interface and assign - QString X; - bool accepted = 0; - QTextStream TS(&F); - X = TS.readLine(); - Log(("%s exists : %s\n", S.latin1(), X.latin1() )); - // find interface - if( handlesInterface( X ) ) { - - Log(("Handles interface %s, PANC %p\n", X.latin1(), PANConnections )); - if( PANConnections == 0 ) { - // load connections that are active - // format : bnep0 00:60:57:02:71:A2 PANU - FILE * OutputOfCmd = popen( "pand --show", "r" ) ; - - PANConnections = new QDict<QString>; - - if( OutputOfCmd ) { - char ch; - // could fork - // read all data - QString Line = ""; - while( 1 ) { - if( fread( &ch, 1, 1, OutputOfCmd ) < 1 ) { - // eof - break; - } - if( ch == '\n' || ch == '\r' ) { - if( ! Line.isEmpty() ) { - if( Line.startsWith( "bnep" ) ) { - QStringList SL = QStringList::split( " ", Line ); - Log(("Detected PAN %s %s\n", - SL[0].latin1(), SL[1].latin1() )); - PANConnections->insert( SL[0], new QString(SL[1])); - } - Line=""; - } - } else { - Line += ch; - } - } - } +BluetoothBNEPRun::~BluetoothBNEPRun( void ) { + if( OT ) { + OTGateway::releaseOTGateway(); + } +} - pclose( OutputOfCmd ); - } +State_t BluetoothBNEPRun::detectState( void ) { - // check if this runtime allows connection to node - if( ! Data.AllowAll ) { - // has addresses - for ( QStringList::Iterator it = Data.BDAddress.begin(); - ! accepted && it != Data.BDAddress.end(); - ++ it ) { - for( QDictIterator<QString> it2( *(PANConnections) ); - it2.current(); - ++ it2 ) { - if( X == it2.currentKey() && - (*it) == *(it2.current()) - ) { - // found - Log(("%s accepts connections to %s\n", - NC->name().latin1(), - it2.current()->latin1() )); - accepted = 1; - break; - } - } - } - } else { - Log(("%s accepts any connection\n", NC->name().latin1() )); - // accept any - accepted = 1; - } + /* - if( accepted ) { - // matches and is allowed for this node - for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); - It.current(); - ++It ) { - Run = It.current(); - if( X == Run->Name ) { - Log(("%s Assigned %p\n", NC->name().latin1(), Run )); - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; - } - } - } - } - } - - Log(("Assigned %p\n", assignedInterface() )); - 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 + need to detect + + 1. for any PAN connection that is found if that + PAN is connected. + + if it is connected it is not available (since we do + not manage IP settings and we are called to detect + the state we knwo that we do not have an UP connection) + + 2. if it not connected and we allow any connection we + are available or if that PAN connection is to a device + with a correct address + + 3. if it is not connected and the address do not match or + we do not accept any address, we are Unavailable but + not DOWN. I.e a new connection could perhaps be created + + */ + + if( ! OT ) { + OT = OTGateway::getOTGateway(); } - // nothing (valid) assigned to us - assignInterface( 0 ); - - // find possible interface - for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); - It.current(); - ++It ) { - Run = It.current(); - - Log(("%s %d %d=%d %d\n", - Run->Name.latin1(), - handlesInterface( Run->Name ), - Run->CardType, ARPHRD_ETHER, - ! Run->IsUp )); - - if( handlesInterface( Run->Name ) && - Run->CardType == ARPHRD_ETHER && - ! Run->IsUp - ) { - Log(("Released(OFF)\n" )); - // proper type, and Not UP -> free - NC->setCurrentState( Off ); - return; - } + if( ! OT->isEnabled() ) { + return Unavailable; } - // no free found - Log(("None available\n" )); - NC->setCurrentState( Unavailable ); + // if there is a PAN connection that is UP but not + // yet configured (no ifup) the we are available + return ( hasFreePANConnection() ) ? Available : Unknown; } -bool BluetoothBNEPRun::setState( NodeCollection * NC, Action_t A, bool ) { +QString BluetoothBNEPRun::setMyState( 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 ); - Log(("Assing %p\n", 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; + if( A == Activate ) { + if( hasFreePANConnection( 1 ) ) { + // we have now an assignedinterface + } else { + return QString("TODO : Start PAND"); + } + + Log(( "Assigned interface" )); + NC->setCurrentState( Available ); + + return QString(); } - return 0; + + if( A == Deactivate ) { + // nothing to do + NC->setCurrentState( Off ); + return QString(); + } + return QString(); } -bool BluetoothBNEPRun::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; +bool BluetoothBNEPRun::handlesInterface( const QString & S ) { + return Pat.match( S ) >= 0; +} + +bool BluetoothBNEPRun::handlesInterface( InterfaceInfo * I ) { + return handlesInterface( I->Name ); +} + +bool BluetoothBNEPRun::hasFreePANConnection( bool Grab ) { + + if( ! OT ) { + OT = OTGateway::getOTGateway(); + } + + // load PAN connections + OTPANConnection * C; + InterfaceInfo * Run; + InterfaceInfo * Candidate = 0; // reuse this interface + PANConnectionVector Conns = OT->getPANConnections(); + System & Sys = NSResources->system(); + bool IsValid; + + for( unsigned int i = 0; + i < Conns.count(); + i ++ ) { + C = Conns[i]; + + if( Data.AllowAll ) { + // we allow all + IsValid = 1; + } else { + // is this PAN connection connecting to a Peer + // we allow ? + IsValid = 0; + for ( QStringList::Iterator it = Data.BDAddress.begin(); + it != Data.BDAddress.end(); + ++ it ) { + if( C->ConnectedTo == (*it) ) { + // this is a connection we could accept + IsValid = 1; + break; } - return 1; } - case Deactivate : - return ( Curr >= Available ); - default : - // FT - break; + } + + if( ! IsValid ) { + Log(("%s to %s not acceptable\n", + C->Device.latin1(), + C->ConnectedTo.latin1() )); + // don't bother checking this address + // it is not acceptable + continue; + } + + // is this PAN connection available to us ? + Run = Sys.findInterface( C->Device ); + + if( Run && Run->IsUp ) { + // this PAN connection is up + Log(("%s acceptable but unavailable\n", + C->Device.latin1() )); + // find others + continue; + } + + // we at least have a possible interface + if( ! Candidate ) { + Candidate = Run; + } } - return 0; -} -// get interface that is free or assigned to us -InterfaceInfo * BluetoothBNEPRun::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->Name ) && - Run->CardType == ARPHRD_ETHER - ) { - // this is a bluetooth card - if( Run->assignedNode() == netNode() ) { - // assigned to us - return Run; - } else if( Run->assignedNode() == 0 ) { - // free - best = Run; - } + if( Candidate ) { + if ( Grab ) { + netNode()->connection()->assignInterface( Candidate ); } + return 1; } - return best; // can be 0 -} -bool BluetoothBNEPRun::handlesInterface( const QString & S ) { - return Pat.match( S ) >= 0; + // no free PAN + return 0; } + diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h index ce03cbb..a05a7a2 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEPrun.h @@ -1,34 +1,35 @@ -#include <asdevice.h> +#include <netnode.h> #include "bluetoothBNEPdata.h" -class BluetoothBNEPRun : public AsDevice { +#include <OTGateway.h> +using namespace Opietooth2; + +class BluetoothBNEPRun : public RuntimeInfo { public : BluetoothBNEPRun( ANetNodeInstance * NNI, - BluetoothBNEPData & D ) : - AsDevice( NNI ), - Data( D), - Pat( "bnep[0-6]" ) - { } + BluetoothBNEPData & D ); + virtual ~BluetoothBNEPRun( void ); + + // i am a device + virtual RuntimeInfo * device( void ) + { return this; } - virtual AsDevice * asDevice( void ) - { return (AsDevice *)this; } + bool handlesInterface( const QString & ); + bool handlesInterface( InterfaceInfo * ); - virtual AsDevice * device( void ) - { return asDevice(); } + State_t detectState( void ); protected : - void detectState( NodeCollection * ); - bool setState( NodeCollection * , Action_t, bool ); - bool canSetState( State_t , Action_t ); - bool handlesInterface( const QString & ); + QString setMyState( NodeCollection * , Action_t, bool ); private : - InterfaceInfo * getInterface( void ); + bool hasFreePANConnection( bool Grab = 0 ); + BluetoothBNEPData & Data; - static QDict<QString> * PANConnections; + OTGateway * OT; QRegExp Pat; }; diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui index 2754a70..7f6565a 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMGUI.ui @@ -12,6 +12,6 @@ <x>0</x> <y>0</y> - <width>283</width> - <height>199</height> + <width>488</width> + <height>604</height> </rect> </property> @@ -29,15 +29,36 @@ <property stdset="1"> <name>margin</name> - <number>2</number> + <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>2</number> + <number>3</number> </property> <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel5_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Selected devices with gprs capability</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>WordBreak|AlignVCenter|AlignLeft</set> + </property> + <property> + <name>wordwrap</name> + </property> + </widget> + <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>Layout4</cstring> + <cstring>Layout8</cstring> + </property> + <property> + <name>layoutSpacing</name> </property> <hbox> @@ -48,5 +69,5 @@ <property stdset="1"> <name>spacing</name> - <number>6</number> + <number>3</number> </property> <widget> @@ -54,9 +75,9 @@ <property stdset="1"> <name>name</name> - <cstring>TextLabel4</cstring> + <cstring>TextLabel5</cstring> </property> <property stdset="1"> <name>text</name> - <string>Name</string> + <string>Address</string> </property> </widget> @@ -65,5 +86,16 @@ <property stdset="1"> <name>name</name> - <cstring>Name_LE</cstring> + <cstring>Address_LE</cstring> + </property> + </widget> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>FindDevice_TB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>...</string> </property> </widget> @@ -71,20 +103,84 @@ </widget> <widget> - <class>QLabel</class> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel3</cstring> + <cstring>Layout7</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> + <name>layoutSpacing</name> </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Channel</string> + </property> + </widget> + <widget> + <class>QSpinBox</class> + <property stdset="1"> + <name>name</name> + <cstring>Channel_SB</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>minValue</name> + <number>1</number> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel2_2</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Name</string> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>Name_LBL</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>frameShape</name> + <enum>Box</enum> + </property> + <property stdset="1"> + <name>indent</name> + <number>0</number> + </property> + </widget> + </hbox> </widget> <widget> @@ -94,4 +190,7 @@ <cstring>Layout5</cstring> </property> + <property> + <name>layoutSpacing</name> + </property> <hbox> <property stdset="1"> @@ -101,31 +200,132 @@ <property stdset="1"> <name>spacing</name> - <number>6</number> + <number>3</number> </property> <widget> - <class>QCheckBox</class> + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>Automatic_CB</cstring> + <cstring>TextLabel7</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> </property> <property stdset="1"> <name>text</name> - <string>Start automatically</string> + <string>Addresses</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignVCenter|AlignLeft</set> + </property> + <property> + <name>vAlign</name> + </property> + </widget> + <widget> + <class>QToolButton</class> + <property stdset="1"> + <name>name</name> + <cstring>Add_TB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>...</string> </property> </widget> <widget> - <class>QCheckBox</class> + <class>QToolButton</class> <property stdset="1"> <name>name</name> - <cstring>Confirm_CB</cstring> + <cstring>Remove_TB</cstring> </property> <property stdset="1"> <name>text</name> - <string>Confirm before start</string> + <string>...</string> </property> </widget> </hbox> </widget> + <widget> + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Name</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> + <string>Channel</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> + <string>Address</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <property stdset="1"> + <name>name</name> + <cstring>Addresses_LV</cstring> + </property> + <property stdset="1"> + <name>allColumnsShowFocus</name> + <bool>true</bool> + </property> + </widget> </vbox> </widget> +<connections> + <connection> + <sender>Add_TB</sender> + <signal>clicked()</signal> + <receiver>BluetoothRFCOMM_FRM</receiver> + <slot>SLOT_AddServer()</slot> + </connection> + <connection> + <sender>Remove_TB</sender> + <signal>clicked()</signal> + <receiver>BluetoothRFCOMM_FRM</receiver> + <slot>SLOT_RemoveServer()</slot> + </connection> + <connection> + <sender>FindDevice_TB</sender> + <signal>clicked()</signal> + <receiver>BluetoothRFCOMM_FRM</receiver> + <slot>SLOT_FindDevice()</slot> + </connection> + <slot access="public">SLOT_AddServer()</slot> + <slot access="public">SLOT_RemoveServer()</slot> + <slot access="public">SLOT_FindDevice()</slot> +</connections> </UI> diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp index 7ec8288..d19386e 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp @@ -1,15 +1,34 @@ #include "bluetoothRFCOMMedit.h" #include "bluetoothRFCOMM_NNI.h" -#include "bluetooth_NN.h" +#include "bluetoothRFCOMM_NN.h" -ABluetoothRFCOMM::ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ) : ANetNodeInstance( PNN ) { - GUI = 0; - RT = 0; +ABluetoothRFCOMM::ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ) : + ANetNodeInstance( PNN ), Data() { + Data.Devices.setAutoDelete( TRUE ); + GUI = 0; + RT = 0; } -void ABluetoothRFCOMM::setSpecificAttribute( QString & , QString & ) { +void ABluetoothRFCOMM::setSpecificAttribute( QString & A, QString & V) { + + if( A == "bdaddress" ) { + Data.Devices.resize( Data.Devices.size() + 1 ); + Data.Devices.insert( Data.Devices.size() - 1, new RFCOMMChannel); + Data.Devices[ Data.Devices.size() - 1 ]->BDAddress = V; + } else if ( A == "channel" ) { + Data.Devices[ Data.Devices.size() - 1 ]->Channel = V.toLong(); + } else if ( A == "name" ) { + Data.Devices[ Data.Devices.size() - 1 ]->Name = V; + } } -void ABluetoothRFCOMM::saveSpecificAttribute( QTextStream & ) { +void ABluetoothRFCOMM::saveSpecificAttribute( QTextStream & TS ) { + for( unsigned int i = 0 ; + i < Data.Devices.count(); + i ++ ) { + TS << "bdaddress=" << Data.Devices[i]->BDAddress << endl; + TS << "name=" << quote( Data.Devices[i]->Name ) << endl; + TS << "channel=" << Data.Devices[i]->Channel << endl; + } } diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h index 18f0d38..14cfeb0 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMdata.h @@ -3,16 +3,20 @@ #include <qstring.h> +#include <qvector.h> -typedef struct BluetoothRFCOMMData { - QString Device; - QString LockFile; - long Speed; - short Parity; - short DataBits; - short StopBits; - bool HardwareControl; - bool SoftwareControl; +class RFCOMMChannel { -} BluetoothRFCOMMData_t; +public : + QString BDAddress; + QString Name; + int Channel; +}; + +class BluetoothRFCOMMData { + +public : + + QVector<RFCOMMChannel> Devices; +}; #endif diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp index d3ddab4..7cac13f 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.cpp @@ -1,18 +1,156 @@ +#include <qlistview.h> +#include <qdialog.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qtoolbutton.h> +#include <qcheckbox.h> +#include <qspinbox.h> +#include <OTPeer.h> +#include <OTGateway.h> +#include <Opietooth.h> +#include <resources.h> #include <GUIUtils.h> #include "bluetoothRFCOMMedit.h" +using namespace Opietooth2; + +class PeerLBI : public QListViewItem { + +public : + + PeerLBI( OTPeer * P, int Ch, QListView * LV ) : QListViewItem( LV ) { + Peer = P; + Channel = Ch; + + setText( 0, (P->name().isEmpty()) ? + P->address().toString() : + P->name() ); + QString S; + S.setNum( Ch ); + setText( 1, S ); + setText( 2, P->address().toString() ); + } + ~PeerLBI( ) { + } + + inline int channel( void ) const + { return Channel; } + inline OTPeer * peer( void ) const + { return Peer; } + + int Channel; + OTPeer * Peer; +}; + BluetoothRFCOMMEdit::BluetoothRFCOMMEdit( QWidget * Parent ) : BluetoothRFCOMMGUI( Parent ){ + Modified = 0; + OT = OTGateway::getOTGateway(); + + Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); + Remove_TB->setPixmap( NSResources->getPixmap( "remove" ) ); + FindDevice_TB->setPixmap( NSResources->getPixmap( "Devices/bluetooth" ) ); + Addresses_LV->setColumnAlignment( 1, Qt::AlignRight ); +} +BluetoothRFCOMMEdit::~BluetoothRFCOMMEdit( void ) { + OTGateway::releaseOTGateway(); } QString BluetoothRFCOMMEdit::acceptable( void ) { - return QString(); + return QString(); +} + +bool BluetoothRFCOMMEdit::commit( BluetoothRFCOMMData & Data ) { + int ct = 0; + PeerLBI * I; + + if( Modified ) { + QListViewItem * it = Addresses_LV->firstChild(); + + Data.Devices.resize( 0 ); + while( it ) { + + ct ++; + Data.Devices.resize( ct ); + I = (PeerLBI * )it; + + Data.Devices.insert( ct-1, new RFCOMMChannel ); + + Data.Devices[ct-1]->BDAddress = I->peer()->address().toString(); + Data.Devices[ct-1]->Name = I->peer()->name(); + Data.Devices[ct-1]->Channel = I->channel(); + + it = it->nextSibling(); + } + } + + return Modified; } void BluetoothRFCOMMEdit::showData( BluetoothRFCOMMData & Data ) { + + OTPeer * P; + + for( unsigned int i = 0; + i < Data.Devices.count(); + i ++ ) { + P = new OTPeer( OT ); + P->setAddress( OTDeviceAddress( Data.Devices[i]->BDAddress ) ); + P->setName( Data.Devices[i]->Name ); + + new PeerLBI( P, Data.Devices[i]->Channel, Addresses_LV ); + } + Modified = 0; } -bool BluetoothRFCOMMEdit::commit( BluetoothRFCOMMData & Data ) { - return 0; +void BluetoothRFCOMMEdit::SLOT_AddServer( void ) { + QListViewItem * it = Addresses_LV->firstChild(); + + while( it ) { + // check address + if( it->text(2) == Address_LE->text() ) { + // already in table + return; + } + it = it->nextSibling(); + } + + // new server + Modified = 1; + OTPeer * P = new OTPeer( OT ); + P->setAddress( OTDeviceAddress( Address_LE->text() ) ); + P->setName( Name_LBL->text() ); + new PeerLBI( P, Channel_SB->value(), Addresses_LV ); + + Address_LE->setText(""); + Name_LBL->setText(""); + Channel_SB->setValue(1); +} + +void BluetoothRFCOMMEdit::SLOT_RemoveServer( void ) { + + QListViewItem * it = Addresses_LV->firstChild(); + + while( it ) { + // check address + if( it->isSelected() ) { + delete it; + Modified = 1; + return; + } + it = it->nextSibling(); + } +} + +void BluetoothRFCOMMEdit::SLOT_FindDevice( void ) { + OTPeer * Peer; + int Channel; + + // find device in Opietooth + if( OTScan::getDevice( Peer, Channel, OT ) == QDialog::Accepted ) { + Address_LE->setText( Peer->address().toString() ); + Name_LBL->setText( Peer->name() ); + Channel_SB->setValue( Channel ); + } } diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h index 14a6d64..9ad8f2a 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMedit.h @@ -2,4 +2,7 @@ #include "bluetoothRFCOMMGUI.h" +#include <Opietooth.h> +using namespace Opietooth2; + class BluetoothRFCOMMEdit : public BluetoothRFCOMMGUI { @@ -7,7 +10,18 @@ public : BluetoothRFCOMMEdit( QWidget * parent ); + virtual ~BluetoothRFCOMMEdit( void ); QString acceptable( void ); void showData( BluetoothRFCOMMData & Data ); bool commit( BluetoothRFCOMMData & Data ); + + bool Modified; + OTGateway * OT; + +public slots : + + void SLOT_AddServer( void ); + void SLOT_RemoveServer( void ); + void SLOT_FindDevice( void ); + }; diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h index 65fd686..24e3dae 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h +++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h @@ -1,28 +1,33 @@ -#include <asline.h> +#include <netnode.h> #include "bluetoothRFCOMMdata.h" -class BluetoothRFCOMMRun : public AsLine { +#include <OTGateway.h> +using namespace Opietooth2; + +class BluetoothRFCOMMRun : public RuntimeInfo { public : BluetoothRFCOMMRun( ANetNodeInstance * NNI, - BluetoothRFCOMMData & Data ) : AsLine( NNI ) - { } + BluetoothRFCOMMData & D ) : RuntimeInfo( NNI ) + { DeviceNr = -1; Data = &D; OT = 0; } + virtual ~BluetoothRFCOMMRun( void ); - virtual AsLine * asLine( void ) - { return (AsLine *)this; } + virtual RuntimeInfo * line( void ) + { return this; } + virtual QString deviceFile( void ); - virtual QString deviceFile( void ) - { return QString( "/dev/rfcomm..." ); } + State_t detectState( void ); protected : - void detectState( NodeCollection * ) - { } + QString setMyState( NodeCollection * , Action_t, bool ); - bool setState( NodeCollection * , Action_t, bool ) - { return 0; } +private : - bool canSetState( State_t , Action_t ) - { return 0; } + int deviceNrOfConnection( void ); + RFCOMMChannel * getChannel( void ); + BluetoothRFCOMMData * Data; + Opietooth2::OTGateway * OT; + int DeviceNr; // cached from detection }; diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp index 443a627..9be6b16 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp @@ -13,4 +13,9 @@ static const char * BluetoothBNEPNeeds[] = }; +static const char * BluetoothBNEPProvides[] = + { "device", + 0 + }; + /** * Constructor, find all of the possible interfaces @@ -43,6 +48,6 @@ const char ** BluetoothBNEPNetNode::needs( void ) { } -const char * BluetoothBNEPNetNode::provides( void ) { - return "device"; +const char ** BluetoothBNEPNetNode::provides( void ) { + return BluetoothBNEPProvides; } diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h index 4d6a3c1..b93342e 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h +++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h @@ -23,5 +23,5 @@ public: virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); virtual const char ** needs( void ); diff --git a/noncore/settings/networksettings2/bluetooth/config.in b/noncore/settings/networksettings2/bluetooth/config.in index 6968ac8..398cff1 100644 --- a/noncore/settings/networksettings2/bluetooth/config.in +++ b/noncore/settings/networksettings2/bluetooth/config.in @@ -2,3 +2,3 @@ boolean "opie-networksettings2plugin-bluetooth (set up BLUETOOTH)" default "n" if NS2 - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE && NS2OPIETOOTH diff --git a/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control b/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control index ea77bd7..c4d29f2 100644 --- a/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control +++ b/noncore/settings/networksettings2/bluetooth/opie-networksettings2plugin-bluetooth.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-bluetooth +Package: opie-networksettings2plugin-bluetooth Files: plugins/networksettings2/libbluetooth.so* Priority: optional @@ -5,5 +5,5 @@ Section: opie/settings Maintainer: Wim Delvaux <wimpie@handhelds.org> Architecture: arm -Depends: opie-networksettings2, libopiecore2, libopienet2 +Depends: opie-networksettings2, libopietooth2, libopiecore2, libopienet2 Description: Network settings bluetooth plugin. Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp index 38568df..dc4205c 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.cpp +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp @@ -6,4 +6,9 @@ static const char * CableNeeds[] = }; +static const char * CableProvides[] = + { "line", + 0 + }; + /** * Constructor, find all of the possible interfaces @@ -33,6 +38,6 @@ const char ** CableNetNode::needs( void ) { } -const char * CableNetNode::provides( void ) { - return "line"; +const char ** CableNetNode::provides( void ) { + return CableProvides; } diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h index 5cc2b2d..8d649cc 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.h +++ b/noncore/settings/networksettings2/cable/cable_NN.h @@ -21,5 +21,5 @@ public: virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); private: diff --git a/noncore/settings/networksettings2/cable/cable_NNI.cpp b/noncore/settings/networksettings2/cable/cable_NNI.cpp index 4bd9421..12a00a2 100644 --- a/noncore/settings/networksettings2/cable/cable_NNI.cpp +++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp @@ -50,17 +50,15 @@ void ACable::saveSpecificAttribute( QTextStream & TS ) { } -short ACable::generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, +short ACable::generateFileEmbedded( SystemFile & SF, long DevNr ) { short rvl, rvd; rvl = 1; - if( ID == "peers" ) { - TS << Data.Device + if( SF.name() == "peers" ) { + SF << Data.Device << endl; - TS << Data.Speed + SF << Data.Speed << endl; - TS << "lock " + SF << "lock " << Data.LockFile << endl; @@ -68,5 +66,5 @@ short ACable::generateFileEmbedded( const QString & ID, } - rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); + rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr ); return (rvd == 2 || rvl == 2 ) ? 2 : (rvd == 0 || rvl == 0 ) ? 0 : 1; diff --git a/noncore/settings/networksettings2/cable/cable_NNI.h b/noncore/settings/networksettings2/cable/cable_NNI.h index d06cbbe..18a52de 100644 --- a/noncore/settings/networksettings2/cable/cable_NNI.h +++ b/noncore/settings/networksettings2/cable/cable_NNI.h @@ -27,7 +27,5 @@ public : { return (void *)&Data; } - short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + short generateFileEmbedded( SystemFile & Sf, long DevNr ); protected : @@ -39,5 +37,5 @@ private : CableEdit * GUI; - CableData_t Data; + CableData Data; CableRun * RT; diff --git a/noncore/settings/networksettings2/cable/cabledata.h b/noncore/settings/networksettings2/cable/cabledata.h index c449d96..ea81f8d 100644 --- a/noncore/settings/networksettings2/cable/cabledata.h +++ b/noncore/settings/networksettings2/cable/cabledata.h @@ -4,5 +4,8 @@ #include <qstring.h> -typedef struct CableData { +class CableData { + +public : + QString Device; QString LockFile; @@ -14,5 +17,5 @@ typedef struct CableData { bool SoftwareControl; -} CableData_t; +}; #endif diff --git a/noncore/settings/networksettings2/cable/cableedit.cpp b/noncore/settings/networksettings2/cable/cableedit.cpp index 6e1a13b..4e57845 100644 --- a/noncore/settings/networksettings2/cable/cableedit.cpp +++ b/noncore/settings/networksettings2/cable/cableedit.cpp @@ -18,5 +18,5 @@ CableEdit::CableEdit( QWidget * Parent ) : CableGUI( Parent ) { } -void CableEdit::showData( CableData_t & D ) { +void CableEdit::showData( CableData & D ) { DeviceFile_LE->setText( D.Device ); LockFile_LE->setText( D.LockFile ); @@ -41,5 +41,5 @@ QString CableEdit::acceptable( void ) { } -bool CableEdit::commit( CableData_t & D ) { +bool CableEdit::commit( CableData & D ) { bool SM = 0; diff --git a/noncore/settings/networksettings2/cable/cableedit.h b/noncore/settings/networksettings2/cable/cableedit.h index ffacc61..ad1e832 100644 --- a/noncore/settings/networksettings2/cable/cableedit.h +++ b/noncore/settings/networksettings2/cable/cableedit.h @@ -8,5 +8,5 @@ public : CableEdit( QWidget * parent ); QString acceptable( void ); - bool commit( CableData_t & D ); - void showData( CableData_t & D ); + bool commit( CableData & D ); + void showData( CableData & D ); }; diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp index 85660f6..7a8deb9 100644 --- a/noncore/settings/networksettings2/cable/cablerun.cpp +++ b/noncore/settings/networksettings2/cable/cablerun.cpp @@ -3,25 +3,17 @@ #include "cablerun.h" -void CableRun::detectState( NodeCollection * NC ) { +State_t CableRun::detectState( void ) { int fd = open( Data->Device.latin1(), O_RDWR ); if( fd < 0 ) { - NC->setCurrentState( Unavailable ); + return Unavailable; } close( fd ); - NC->setCurrentState( Available ); + return Available; } -bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) { - if( A == Activate ) { - detectState(NC); - return (NC->currentState() == Available); - } - return 1; -} - -bool CableRun::canSetState( State_t , Action_t ) { - return 1; +QString CableRun::setMyState( NodeCollection *, Action_t , bool ) { + return QString(); } diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h index 20608f6..41aea01 100644 --- a/noncore/settings/networksettings2/cable/cablerun.h +++ b/noncore/settings/networksettings2/cable/cablerun.h @@ -1,26 +1,26 @@ -#include <asline.h> +#include <netnode.h> #include "cabledata.h" -class CableRun : public AsLine { +class CableRun : public RuntimeInfo { public : CableRun( ANetNodeInstance * NNI, - CableData_t & D ) : AsLine( NNI ) + CableData & D ) : RuntimeInfo( NNI ) { Data = &D; } - virtual AsLine * asLine( void ) - { return (AsLine *)this; } + virtual RuntimeInfo * line( void ) + { return this; } virtual QString deviceFile( void ); + State_t detectState( void ); + protected : - void detectState( NodeCollection * NC ); - bool setState( NodeCollection * NC, Action_t A, bool Force ); - bool canSetState( State_t Curr, Action_t A ); + QString setMyState( NodeCollection * , Action_t, bool ); private : - CableData_t * Data; + CableData * Data; }; diff --git a/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control b/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control index 79520e2..dd08279 100644 --- a/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control +++ b/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-bluetooth +Package: opie-networksettings2plugin-cable Files: plugins/networksettings2/libcable.so* Priority: optional diff --git a/noncore/settings/networksettings2/config.in b/noncore/settings/networksettings2/config.in index d0e5a32..d2b5f26 100644 --- a/noncore/settings/networksettings2/config.in +++ b/noncore/settings/networksettings2/config.in @@ -1,8 +1,10 @@ source noncore/settings/networksettings2/networksettings2/config.in + source noncore/settings/networksettings2/opietooth2/config.in + source noncore/settings/networksettings2/opietooth2_applet/config.in config NS2 boolean default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && NS2CORE && NS2OPIETOOTH source noncore/settings/networksettings2/profile/config.in @@ -17,2 +19,3 @@ config NS2 source noncore/settings/networksettings2/cable/config.in source noncore/settings/networksettings2/modem/config.in + source noncore/settings/networksettings2/gprs/config.in diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index 77826d1..3f8a53f 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp @@ -1,2 +1,3 @@ +#include <opie2/odebug.h> #include <qlistview.h> #include <qwidgetstack.h> @@ -32,4 +33,11 @@ public: QCheckListItem( parent, S, T ) { } + MyQCheckListItem( QListView *parent, const QString & S ) : + QCheckListItem( parent, S, QCheckListItem::Controller ) { } + MyQCheckListItem( QCheckListItem *parent, const QString & S ) : + QCheckListItem( parent, S, QCheckListItem::Controller ) { } + MyQCheckListItem( QListViewItem *parent, const QString & S ) : + QCheckListItem( parent, S, QCheckListItem::Controller ) { } + virtual void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); @@ -117,5 +125,12 @@ NodeCollection * EditConnection::getTmpCollection( void ) { QListViewItem * it = Nodes_LV->firstChild(); ANetNode * NN; - // start iter + + // start iter (if there is a collection) + /* + + a node collection is sorted from the toplevel + node to the deepest node + + */ ANetNodeInstance * NNI = (SelectedNodes) ? SelectedNodes->first() : 0 ; @@ -123,40 +138,55 @@ NodeCollection * EditConnection::getTmpCollection( void ) { TmpCollection.setModified( 0 ); + // the listview always starts with the toplevel + // hierarchy. This is always a controller item while ( it ) { NN = (*Mapping)[it]; if( NN == 0 ) { - // child is controller -> has sub radio - // check if one radio is selected + // this item is a controller -> + // has radio items as children -> + // find selected one it = it->firstChild(); while( it ) { if( ((QCheckListItem *)it)->isOn() ) { // this radio is selected -> go deeper - if( SelectedNodes == 0 || - NNI == 0 || - it->text(0) != NNI->nodeClass()->name() ) { - // new item not in previous collection - ANetNodeInstance * NNI = (*Mapping)[it]->createInstance(); - NNI->initialize(); - // this node type not in collection - TmpCollection.append( NNI ); - // master collection changed because new item in it - TmpCollection.setModified( 1 ); - // no more valid items in old list - NNI = 0; - } else { - // already in list -> copy pointer - TmpCollection.append( NNI ); - NNI = SelectedNodes->next(); - } - it = it->firstChild(); - // do not bother to check other items break; } it = it->nextSibling(); } + + if( ! it ) { + owarn << "Radio not selected" << oendl; + TmpIsValid = 0; + return 0; + } + + // it now contains selected radio + NN = (*Mapping)[it]; + } + + // NN here contains the netnode of the + // current item -> this node needs to + // be stored in the collection + if( NNI == 0 || + it->text(0) != NNI->nodeClass()->name() ) { + // new item not in previous collection + ANetNodeInstance * NNI = NN->createInstance(); + NNI->initialize(); + // this node type not in collection + TmpCollection.append( NNI ); + // master collection changed because new item in it + TmpCollection.setModified( 1 ); + // no more valid items in old list + NNI = 0; } else { - // check children - it = it->firstChild(); + // already in list -> copy pointer + TmpCollection.append( NNI ); + NNI = SelectedNodes->next(); } + + // go deeper to next level + // this level is can be a new controller + // or an item + it = it->firstChild(); } @@ -188,10 +218,9 @@ void EditConnection::setConnection( NodeCollection * NC ) { while ( it ) { - // listitem corresponds to netnode NN = (*Mapping)[it]; if( NN == 0 ) { - // child is controller -> has sub radio - QString Ctr = it->text(0); - // check if one radio is selected + // this item is a controller -> + // has radio items as children -> + // find selected one it = it->firstChild(); Found = 0; @@ -210,4 +239,5 @@ void EditConnection::setConnection( NodeCollection * NC ) { it = it->nextSibling(); } + if( ! Found ) { // this means that this level is NOT present in collection @@ -217,9 +247,29 @@ void EditConnection::setConnection( NodeCollection * NC ) { tr( "Error presentig Connection" ), tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). - arg(Ctr) ); + arg(NNI->nodeClass()->name()) ); return; } + + // it now contains selected radio + NN = (*Mapping)[it]; } else { - // automatic item -> check children + // automatic selection + if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { + // should exist and be the same + if( NNI ) { + QMessageBox::warning( + 0, + tr( "Error presentig Connection" ), + tr( "<p>Old connection or missing plugin \"<i>%1</i>\"</p>" ). + arg(NNI->nodeClass()->name()) ); + } else { + QMessageBox::warning( + 0, + tr( "Error presentig Connection" ), + tr( "<p>Missing connection\"<i>%1</i>\"</p>" ). + arg(it->text(0)) ); + } + return; + } it = it->firstChild(); } @@ -270,5 +320,5 @@ void EditConnection::buildFullTree( void ) { Nodes_LV->setSelected( TheTop, TRUE ); - // find all Nodes that care toplevel nodes -> ie provide + // find all Nodes that are toplevel nodes -> ie provide // TCP/IP Connection for( QDictIterator<NetNode_t> Iter(NSResources->netNodes()); @@ -285,5 +335,7 @@ void EditConnection::buildFullTree( void ) { NN->name(), QCheckListItem::RadioButton ); - it->setPixmap( 0, NSResources->getPixmap( "Devices/commprofile" ) ); + it->setPixmap( 0, + NSResources->getPixmap( NN->pixmapName() ) + ); // remember that this node maps to this listitem Mapping->insert( it, NN ); @@ -300,5 +352,5 @@ void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { it = new MyQCheckListItem( it, - NSResources->netNode2Name(NNL[0]->provides()), + NSResources->netNode2Name(NN->needs()[0]), QCheckListItem::Controller ); it->setSelectable( FALSE ); @@ -388,8 +440,9 @@ void EditConnection::SLOT_SelectNode( QListViewItem * it ) { if( ! NN ) { // intermediate node - NN = (*Mapping)[ it->firstChild() ]; + NN = (*Mapping)[ it->parent() ]; if( NN ) { // figure out type of this node -> produce mesage - Description_LBL->setText( NSResources->netNode2Description(NN->provides()) ); + Description_LBL->setText( NSResources->netNode2Description( + NN->needs()[0]) ); } else { Description_LBL->setText( "" ); @@ -540,38 +593,39 @@ void EditConnection::enablePath( QListViewItem * it, bool pha ) { // do we have a complete configuration (all needs are provided for ?) bool EditConnection::haveCompleteConfig( QListViewItem * it ) { - if( it == 0 || ((QCheckListItem *)it)->isOn() ) { - // check children - it = (it) ? it->firstChild() : Nodes_LV->firstChild() ; - while ( it ) { - if( ((QCheckListItem *)it)->type() == - QCheckListItem::Controller ) { - // child is controller -> has sub radio - // check if one radio is selected - it = it->firstChild(); - while( it ) { - if( ((QCheckListItem *)it)->isOn() ) { - // this radio is selected -> go deeper - it = it->firstChild(); - if( ! it ) { - // was deepest level - return 1; - } - // do not bother to check other items - break; - } - it = it->nextSibling(); - } - if( ! it ) { - // no radio selected - return 0; + + // check if all below this level is selected + it = ( it ) ?it : Nodes_LV->firstChild(); + ANetNode *NN; + bool Found; + + while ( it ) { + NN = (*Mapping)[it]; + if( NN == 0 ) { + // this item is a controller -> + // has radio items as children -> + // find selected one + it = it->firstChild(); + Found = 0; + while( it ) { + if( ((QCheckListItem *)it)->isOn() ) { + Found = 1; + // go deeper + it = it->firstChild(); + break; } - } else { - // check children - it = it->firstChild(); + it = it->nextSibling(); } + + if( ! Found ) { + return 0; // no not complete -> a radio should have been chkd + } + + // it now contains selected radio + NN = (*Mapping)[it]; + } else { + // automatic selection + it = it->firstChild(); } - // deepest level -> all is still OK - return 1; - } // was not ON - return 0; + } + return 1; } diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp index 9483e22..485cad3 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.cpp +++ b/noncore/settings/networksettings2/irda/irda_NN.cpp @@ -6,4 +6,9 @@ static const char * IRDANeeds[] = }; +static const char * IRDAProvides[] = + { "line", + 0 + }; + /** * Constructor, find all of the possible interfaces @@ -33,6 +38,6 @@ const char ** IRDANetNode::needs( void ) { } -const char * IRDANetNode::provides( void ) { - return "line"; +const char ** IRDANetNode::provides( void ) { + return IRDAProvides; } diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h index 900bbc6..9e5c5e6 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.h +++ b/noncore/settings/networksettings2/irda/irda_NN.h @@ -21,5 +21,5 @@ public: virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); private: diff --git a/noncore/settings/networksettings2/irda/irdadata.h b/noncore/settings/networksettings2/irda/irdadata.h index c3c683e..568f796 100644 --- a/noncore/settings/networksettings2/irda/irdadata.h +++ b/noncore/settings/networksettings2/irda/irdadata.h @@ -4,5 +4,6 @@ #include <qstring.h> -typedef struct IRDAData { +class IRDAData { +public : QString Device; QString LockFile; @@ -14,5 +15,5 @@ typedef struct IRDAData { bool SoftwareControl; -} IRDAData_t; +} ; #endif diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h index 4258aff..d3b714b 100644 --- a/noncore/settings/networksettings2/irda/irdarun.h +++ b/noncore/settings/networksettings2/irda/irdarun.h @@ -1,28 +1,25 @@ -#include <asline.h> +#include <netnode.h> #include "irdadata.h" -class IRDARun : public AsLine { +class IRDARun : public RuntimeInfo { public : IRDARun( ANetNodeInstance * NNI, - IRDAData & Data ) : AsLine( NNI ) + IRDAData & Data ) : RuntimeInfo( NNI ) { } - virtual AsLine * asLine( void ) - { return (AsLine *)this; } + virtual RuntimeInfo * line( void ) + { return this; } virtual QString deviceFile( void ) { return QString( "/dev/irda" ); } -protected : - - void detectState( NodeCollection * ) - { } + State_t detectState( void ) + { return Unknown; } - bool setState( NodeCollection * , Action_t, bool ) - { return 0; } +protected : - bool canSetState( State_t , Action_t ) - { return 0; } + QString setMyState( NodeCollection * , Action_t, bool ) + { return QString(); } }; diff --git a/noncore/settings/networksettings2/irda/opie-networksettings2plugin-irda.control b/noncore/settings/networksettings2/irda/opie-networksettings2plugin-irda.control index 938bee5..4afbbcf 100644 --- a/noncore/settings/networksettings2/irda/opie-networksettings2plugin-irda.control +++ b/noncore/settings/networksettings2/irda/opie-networksettings2plugin-irda.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-irda +Package: opie-networksettings2plugin-irda Files: plugins/networksettings2/libirda.so* Priority: optional diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index 20ae7f6..e36f757 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp @@ -3,5 +3,11 @@ static const char * LanCardNeeds[] = - { 0 }; + { 0 + }; + +static const char * LanCardProvides[] = + { "device", + 0 + }; /** @@ -35,6 +41,6 @@ const char ** LanCardNetNode::needs( void ) { } -const char * LanCardNetNode::provides( void ) { - return "device"; +const char ** LanCardNetNode::provides( void ) { + return LanCardProvides; } diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h index 6882af7..dc7566a 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.h +++ b/noncore/settings/networksettings2/lancard/lancard_NN.h @@ -26,5 +26,5 @@ public: virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); QStringList & addressesOfNIC( void ) diff --git a/noncore/settings/networksettings2/lancard/lancarddata.h b/noncore/settings/networksettings2/lancard/lancarddata.h index c76767f..8f5e2b5 100644 --- a/noncore/settings/networksettings2/lancard/lancarddata.h +++ b/noncore/settings/networksettings2/lancard/lancarddata.h @@ -5,9 +5,10 @@ #include <qstring.h> -typedef struct LanCardData { +class LanCardData { +public : bool AnyLanCard; QStringList HWAddresses; -} LanCardData_t; +} ; #endif diff --git a/noncore/settings/networksettings2/lancard/lancardrun.cpp b/noncore/settings/networksettings2/lancard/lancardrun.cpp index 1544ddc..470b797 100644 --- a/noncore/settings/networksettings2/lancard/lancardrun.cpp +++ b/noncore/settings/networksettings2/lancard/lancardrun.cpp @@ -5,5 +5,5 @@ #include "lancardrun.h" -void LanCardRun::detectState( NodeCollection * NC ) { +State_t LanCardRun::detectState( void ) { // unavailable : no card found @@ -11,5 +11,7 @@ void LanCardRun::detectState( NodeCollection * NC ) { // up : card found and assigned to us and up - QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); + NodeCollection * NC = nodeCollection(); + QString S = QString( "/tmp/profile-%1.up" ). + arg( NC->number()); System & Sys = NSResources->system(); InterfaceInfo * Run; @@ -29,8 +31,6 @@ void LanCardRun::detectState( NodeCollection * NC ) { Run = It.current(); if( X == Run->Name ) { - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; + NC->assignInterface( Run ); + return IsUp; } } @@ -38,15 +38,14 @@ void LanCardRun::detectState( NodeCollection * NC ) { } - if( ( Run = assignedInterface() ) ) { + if( ( Run = NC->assignedInterface() ) ) { // we already have an interface assigned -> still present ? if( ! Run->IsUp ) { // usb is still free -> keep assignment - NC->setCurrentState( Available ); - return; + return Available; } // else interface is up but NOT us -> some other profile } // nothing (valid) assigned to us - assignInterface( 0 ); + NC->assignInterface( 0 ); // find possible interface @@ -64,79 +63,36 @@ void LanCardRun::detectState( NodeCollection * NC ) { ) { // proper type, and Not UP -> free - NC->setCurrentState( Off ); - return; + return Off; } } // no free found - NC->setCurrentState( Unavailable ); - + return Unavailable; } -bool LanCardRun::setState( NodeCollection * NC, Action_t A, bool ) { +QString LanCardRun::setMyState( 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; + if( A == Activate ) { + InterfaceInfo * N = getInterface(); + + if( ! N ) { + // no interface available + NC->setCurrentState( Unavailable ); + return tr("No interface found"); + } + + // because we were OFF the interface + // we get back is NOT assigned + NC->assignInterface( N ); + NC->setCurrentState( Available ); + return QString(); } - return 0; -} -bool LanCardRun::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; + if( A == Deactivate ) { + NC->assignInterface( 0 ); + NC->setCurrentState( Off ); } - return 0; + + return QString(); } @@ -159,8 +115,8 @@ InterfaceInfo * LanCardRun::getInterface( void ) { ) { // this is a LAN card - if( Run->assignedNode() == netNode() ) { + if( Run->assignedConnection() == netNode()->connection() ) { // assigned to us return Run; - } else if( Run->assignedNode() == 0 ) { + } else if( Run->assignedConnection() == 0 ) { // free best = Run; diff --git a/noncore/settings/networksettings2/lancard/lancardrun.h b/noncore/settings/networksettings2/lancard/lancardrun.h index b28dda7..57ef3fb 100644 --- a/noncore/settings/networksettings2/lancard/lancardrun.h +++ b/noncore/settings/networksettings2/lancard/lancardrun.h @@ -2,31 +2,29 @@ #define LANCARDRUN_H -#include <asdevice.h> +#include <netnode.h> #include <qregexp.h> #include "lancarddata.h" -class LanCardRun : public AsDevice { +class LanCardRun : public RuntimeInfo { public : LanCardRun( ANetNodeInstance * NNI, - LanCardData & D ) : AsDevice( NNI ), - Pat( "eth[0-9]" ) - { Data = &D; } + LanCardData & D ) : RuntimeInfo( NNI ), + Pat( "eth[0-9]" ) { + Data = &D; + } - virtual AsDevice * device( void ) - { return (AsDevice *)this; } + virtual RuntimeInfo * device( void ) + { return this; } - virtual AsDevice * asDevice( void ) - { return (AsDevice *)this; } + bool handlesInterface( const QString & I ); + bool handlesInterface( const InterfaceInfo & II ); -protected : + State_t detectState( void ); - void detectState( NodeCollection * NC ); - bool setState( NodeCollection * NC, Action_t A, bool Force ); - bool canSetState( State_t Curr, Action_t A ); +protected : - bool handlesInterface( const QString & I ); - bool handlesInterface( const InterfaceInfo & II ); + QString setMyState( NodeCollection * , Action_t, bool ); private : diff --git a/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control b/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control index d5aca66..4f87d04 100644 --- a/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control +++ b/noncore/settings/networksettings2/lancard/opie-networksettings2plugin-lancard.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-lancard +Package: opie-networksettings2plugin-lancard Files: plugins/networksettings2/liblancard.so* Priority: optional diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp index 18bf652..8487e3e 100644 --- a/noncore/settings/networksettings2/main.cpp +++ b/noncore/settings/networksettings2/main.cpp @@ -4,4 +4,5 @@ #include "networksettings.h" +#include <opie2/odebug.h> #include <qpe/qpeapplication.h> @@ -25,4 +26,15 @@ OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) // used by interfaces to trigger VPN #define ACT_VPN 4 +// activate opietooth +#define ACT_OT 5 + +// include Opietooth GUI +#include <opietooth2/Opietooth.h> +using namespace Opietooth2; + +#include <qpushbutton.h> +#include <qlayout.h> +#include <qframe.h> +#include <qlabel.h> int main( int argc, char * argv[] ) { @@ -51,4 +63,7 @@ int main( int argc, char * argv[] ) { Action = ACT_VPN; rmv = 1; + } else if( strcmp( argv[i], "--opietooth" ) == 0 ) { + Action = ACT_OT; + rmv = 1; } if( rmv ) { @@ -65,4 +80,6 @@ int main( int argc, char * argv[] ) { Action = ACT_REQUEST; Log(("Request : %s\n", argv[1] )); + } else if( strstr( argv[0], "-opietooth" ) ) { + Action = ACT_OT; } @@ -87,13 +104,10 @@ int main( int argc, char * argv[] ) { { NetworkSettingsData NS; if( NS.canStart( argv[1] ) ) { - QString S; - S.sprintf( QPEApplication::qpeDir()+ - "bin/networksettings2" ); - char * MyArgv[4]; - MyArgv[0] = "networksettings2"; - MyArgv[1] = "--prompt"; - MyArgv[2] = argv[1]; - MyArgv[3] = NULL; - NSResources->system().execAsUser( S, MyArgv ); + QStringList S; + S << QPEApplication::qpeDir() + "/bin/networksettings2"; + S << "networksettings2"; + S << "--prompt"; + S << argv[1]; + NSResources->system().execAsUser( S ); Log(("FAILED %s-cNN-allowed\n", argv[1] )); // if we come here , failed @@ -104,6 +118,7 @@ int main( int argc, char * argv[] ) { case ACT_REGEN : { NetworkSettingsData NS; + QString S= NS.generateSettings(); // regen returns 0 if OK - rv = (NS.regenerate()) ? 1 : 0; + rv = ( S.isEmpty() ) ? 0 : 1; } break; @@ -126,6 +141,14 @@ int main( int argc, char * argv[] ) { break; case ACT_GUI : - { QWidget * W = new NetworkSettings(0); + case ACT_OT : + { QWidget * W; + + if( Action == ACT_OT ) { + W = new OTMain( 0 ); + } else { + W = new NetworkSettings(0); + } TheApp->setMainWidget( W ); + W->show(); #ifdef _WS_QWS_ @@ -135,4 +158,5 @@ int main( int argc, char * argv[] ) { #endif rv = TheApp->exec(); + delete W; } diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp index ee61b10..06f417c 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.cpp +++ b/noncore/settings/networksettings2/modem/modem_NN.cpp @@ -3,5 +3,10 @@ static const char * ModemNeeds[] = - { "line" + { "line", + 0 + }; +static const char * ModemProvides[] = + { "modem", + 0 }; @@ -34,6 +39,6 @@ const char ** ModemNetNode::needs( void ) { } -const char * ModemNetNode::provides( void ) { - return "line"; +const char ** ModemNetNode::provides( void ) { + return ModemProvides; } diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h index a76525f..5b3b573 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.h +++ b/noncore/settings/networksettings2/modem/modem_NN.h @@ -21,5 +21,5 @@ public: virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); private: diff --git a/noncore/settings/networksettings2/modem/modemdata.h b/noncore/settings/networksettings2/modem/modemdata.h index 773cb77..89656ed 100644 --- a/noncore/settings/networksettings2/modem/modemdata.h +++ b/noncore/settings/networksettings2/modem/modemdata.h @@ -3,5 +3,6 @@ #include <qstring.h> -typedef struct ModemData { +class ModemData { +public : QString Device; QString LockFile; @@ -13,5 +14,5 @@ typedef struct ModemData { bool SoftwareControl; -} ModemData_t; +} ; #endif diff --git a/noncore/settings/networksettings2/modem/modemedit.cpp b/noncore/settings/networksettings2/modem/modemedit.cpp index fd3d694..d97d895 100644 --- a/noncore/settings/networksettings2/modem/modemedit.cpp +++ b/noncore/settings/networksettings2/modem/modemedit.cpp @@ -10,9 +10,9 @@ QString ModemEdit::acceptable( void ) { } -bool ModemEdit::commit( ModemData_t & Data ) { +bool ModemEdit::commit( ModemData & Data ) { return 0; } -void ModemEdit::showData( ModemData_t & Data ) { +void ModemEdit::showData( ModemData & Data ) { } diff --git a/noncore/settings/networksettings2/modem/modemedit.h b/noncore/settings/networksettings2/modem/modemedit.h index 56e2a82..ed9cfc0 100644 --- a/noncore/settings/networksettings2/modem/modemedit.h +++ b/noncore/settings/networksettings2/modem/modemedit.h @@ -8,5 +8,5 @@ public : ModemEdit( QWidget * parent ); QString acceptable( void ); - bool commit( ModemData_t & Data ); - void showData( ModemData_t & Data ); + bool commit( ModemData & Data ); + void showData( ModemData & Data ); }; diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h index 491a677..eb3a193 100644 --- a/noncore/settings/networksettings2/modem/modemrun.h +++ b/noncore/settings/networksettings2/modem/modemrun.h @@ -1,28 +1,25 @@ -#include <asline.h> +#include <netnode.h> #include "modemdata.h" -class ModemRun : public AsLine { +class ModemRun : public RuntimeInfo { public : ModemRun( ANetNodeInstance * NNI, - ModemData & Data ) : AsLine ( NNI ) + ModemData & Data ) : RuntimeInfo ( NNI ) { } - virtual AsLine * asLine( void ) - { return (AsLine *)this; } + virtual RuntimeInfo * line( void ) + { return this; } virtual QString deviceFile( void ) { return QString("/dev/modem"); } -protected : - - void detectState( NodeCollection * ) - { } + State_t detectState( void ) + { return Unknown;} - bool setState( NodeCollection *, Action_t, bool ) - { return 0; } +protected : - bool canSetState( State_t, Action_t ) - { return 0; } + QString setMyState( NodeCollection * , Action_t, bool ) + { return QString(); } }; diff --git a/noncore/settings/networksettings2/modem/opie-networksettings2plugin-modem.control b/noncore/settings/networksettings2/modem/opie-networksettings2plugin-modem.control index eaa6ab0..a73249a 100644 --- a/noncore/settings/networksettings2/modem/opie-networksettings2plugin-modem.control +++ b/noncore/settings/networksettings2/modem/opie-networksettings2plugin-modem.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-modem +Package: opie-networksettings2plugin-modem Files: plugins/networksettings2/libmodem.so* Priority: optional diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index b5c41bf..23b3d44 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp @@ -1,4 +1,5 @@ #include <qpe/qpeapplication.h> -#include <asdevice.h> +#include <resources.h> +#include <netnode.h> #include "network_NN.h" #include "network_NNI.h" @@ -9,8 +10,16 @@ static const char * NetworkNeeds[] = }; +static const char * NetworkProvides[] = + { "connection", + 0 + }; + /** * Constructor, find all of the possible interfaces */ NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { + + NSResources->addSystemFile( + "interfaces", "/etc/network/interfaces", 1 ); } @@ -33,29 +42,32 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) { } -bool NetworkNetNode::hasDataForFile( const QString & S ) { - return S == "interfaces"; +bool NetworkNetNode::hasDataForFile( SystemFile & S ) { + return S.name() == "interfaces"; } -short NetworkNetNode::generateFile( const QString & ID, - const QString & , - QTextStream & TS, +short NetworkNetNode::generateFile( SystemFile & SF, ANetNodeInstance * NNI, long DevNr ) { + if( DevNr < 0 ) { + // generate device specific but common part + return 1; + } + QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); - if( ID == "interfaces" ) { - Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() )); + if( SF.name() == "interfaces" ) { + Log(("Generate entry for %s in %s\n", NIC.latin1(), SF.name().latin1() )); // generate mapping stanza for this interface - TS << "# check if " + SF << "# check if " << NIC << " can be brought UP" << endl; - TS << "mapping " + SF << "mapping " << NIC << endl; - TS << " script " + SF << " script " << QPEApplication::qpeDir() - << "/bin/networksettings2-request" + << "bin/networksettings2-request" << endl << endl; @@ -69,6 +81,6 @@ const char ** NetworkNetNode::needs( void ) { } -const char * NetworkNetNode::provides( void ) { - return "connection"; +const char ** NetworkNetNode::provides( void ) { + return NetworkProvides; } diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h index 745d1a7..b063d4c 100644 --- a/noncore/settings/networksettings2/network/network_NN.h +++ b/noncore/settings/networksettings2/network/network_NN.h @@ -15,9 +15,7 @@ public: virtual ~NetworkNetNode(); - virtual bool hasDataForFile( const QString & S ); + virtual bool hasDataForFile( SystemFile & S ); - virtual short generateFile( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFile( SystemFile & TS, ANetNodeInstance * NNI, long DevNr ); @@ -28,5 +26,5 @@ public: virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); private: diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp index 324c6e2..78e6545 100644 --- a/noncore/settings/networksettings2/network/network_NNI.cpp +++ b/noncore/settings/networksettings2/network/network_NNI.cpp @@ -1,4 +1,4 @@ #include <system.h> -#include <asdevice.h> +#include <netnode.h> #include "networkedit.h" #include "network_NNI.h" @@ -100,13 +100,11 @@ void ANetwork::commit( void ) { } -bool ANetwork::hasDataForFile( const QString & S ) { - return S == "interfaces"; +bool ANetwork::hasDataForFile( SystemFile & S ) { + return S.name() == "interfaces"; } -short ANetwork::generateFile( const QString & ID, - const QString & Path, - QTextStream &TS, - long DevNr - ) { +short ANetwork::generateFile( SystemFile &SF, + long DevNr + ) { short rvl, rvd ; @@ -114,9 +112,9 @@ short ANetwork::generateFile( const QString & ID, rvl = 1; - if( ID == "interfaces" ) { - Log(("Generate Network for %s\n", ID.latin1() )); + if( SF.name() == "interfaces" ) { + Log(("Generate Network for %s\n", SF.name().latin1() )); // we can safely call from here since device item is deeper if( Data.UseDHCP ) { - TS << "iface " + SF << "iface " << NIC << "-c" @@ -124,5 +122,5 @@ short ANetwork::generateFile( const QString & ID, << "-allowed inet dhcp" << endl; - TS << " up echo \"" + SF << " up echo \"" << NIC << "\" > /tmp/profile-" @@ -131,20 +129,20 @@ short ANetwork::generateFile( const QString & ID, << endl; if( Data.SendHostname ) { - TS << " hostname " + SF << " hostname " << Data.Hostname << endl; } - TS << " down rm -f /tmp/profile-" + SF << " down rm -f /tmp/profile-" << connection()->number() << ".up" << endl; } else { - TS << "iface " + SF << "iface " << NIC << "-c" << connection()->number() << "-allowed inet static" << endl; - TS << " up echo \"" + SF << " up echo \"" << NIC << "\" > /tmp/profile-" @@ -152,15 +150,15 @@ short ANetwork::generateFile( const QString & ID, << ".up" << endl; - TS << " down rm -f /tmp/profile-" + SF << " down rm -f /tmp/profile-" << connection()->number() << ".up" << endl; - TS << " address " + SF << " address " << Data.IPAddress << endl; - TS << " broadcast " + SF << " broadcast " << Data.Broadcast << endl; - TS << " netmask " + SF << " netmask " << Data.NetMask << endl; @@ -176,5 +174,5 @@ short ANetwork::generateFile( const QString & ID, arg( ipal[2].toShort() & nmal[2].toShort() ). arg( ipal[3].toShort() & nmal[3].toShort() ); - TS << " network " + SF << " network " << NW << endl; @@ -184,5 +182,5 @@ short ANetwork::generateFile( const QString & ID, it != Data.PreUp_SL.end(); ++it ) { - TS << " pre-up " + SF << " pre-up " << (*it) << endl; @@ -191,5 +189,5 @@ short ANetwork::generateFile( const QString & ID, it != Data.PostUp_SL.end(); ++it ) { - TS << " up " + SF << " up " << (*it) << endl; @@ -198,5 +196,5 @@ short ANetwork::generateFile( const QString & ID, it != Data.PreDown_SL.end(); ++it ) { - TS << " down " + SF << " down " << (*it) << endl; @@ -205,5 +203,5 @@ short ANetwork::generateFile( const QString & ID, it != Data.PostDown_SL.end(); ++it ) { - TS << " post-down " + SF << " post-down " << (*it) << endl; @@ -213,5 +211,5 @@ short ANetwork::generateFile( const QString & ID, // embed other info in it - rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr ); + rvd = connection()->getToplevel()->generateFileEmbedded( SF, DevNr ); return (rvd == 2 || rvl == 2 ) ? 2 : diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h index 5e42503..71c276a 100644 --- a/noncore/settings/networksettings2/network/network_NNI.h +++ b/noncore/settings/networksettings2/network/network_NNI.h @@ -28,9 +28,7 @@ public : { return (void *)&Data; } - virtual bool hasDataForFile( const QString & S ); - virtual short generateFile( const QString & ID, - const QString & Path, - QTextStream &TS, - long DevNr ); + virtual bool hasDataForFile( SystemFile & SF ); + virtual short generateFile( SystemFile &TS, + long DevNr ); protected : @@ -42,5 +40,5 @@ private : NetworkEdit * GUI; - NetworkData_t Data; + NetworkData Data; NetworkRun * RT; }; diff --git a/noncore/settings/networksettings2/network/networkdata.h b/noncore/settings/networksettings2/network/networkdata.h index 2c5da37..1df9dc4 100644 --- a/noncore/settings/networksettings2/network/networkdata.h +++ b/noncore/settings/networksettings2/network/networkdata.h @@ -4,5 +4,6 @@ #include <qstring.h> #include <qstringlist.h> -typedef struct NetworkData { +class NetworkData { +public : bool UseDHCP; QString Hostname; @@ -18,5 +19,5 @@ typedef struct NetworkData { QStringList PreDown_SL; QStringList PostDown_SL; -} NetworkData_t; +} ; #endif diff --git a/noncore/settings/networksettings2/network/networkedit.cpp b/noncore/settings/networksettings2/network/networkedit.cpp index 05110d9..d13cb66 100644 --- a/noncore/settings/networksettings2/network/networkedit.cpp +++ b/noncore/settings/networksettings2/network/networkedit.cpp @@ -66,5 +66,5 @@ QString NetworkEdit::acceptable( void ) { } -bool NetworkEdit::commit( NetworkData_t & Data ) { +bool NetworkEdit::commit( NetworkData & Data ) { bool SM = 0; CBM( Data.UseDHCP, DHCP_CB, SM ); @@ -86,5 +86,5 @@ bool NetworkEdit::commit( NetworkData_t & Data ) { } -void NetworkEdit::showData( NetworkData_t & Data ) { +void NetworkEdit::showData( NetworkData & Data ) { DHCP_CB->setChecked( Data.UseDHCP ); SendHostname_CB->setChecked( Data.SendHostname ); diff --git a/noncore/settings/networksettings2/network/networkedit.h b/noncore/settings/networksettings2/network/networkedit.h index adc20e0..45635c8 100644 --- a/noncore/settings/networksettings2/network/networkedit.h +++ b/noncore/settings/networksettings2/network/networkedit.h @@ -10,6 +10,6 @@ public : NetworkEdit( QWidget * parent ); QString acceptable( void ); - bool commit( NetworkData_t & Data ); - void showData( NetworkData_t & Data ); + bool commit( NetworkData & Data ); + void showData( NetworkData & Data ); public slots : diff --git a/noncore/settings/networksettings2/network/networkrun.cpp b/noncore/settings/networksettings2/network/networkrun.cpp index 3e24c5f..c17aa7f 100644 --- a/noncore/settings/networksettings2/network/networkrun.cpp +++ b/noncore/settings/networksettings2/network/networkrun.cpp @@ -1,78 +1,51 @@ #include <system.h> -#include <asdevice.h> +#include <netnode.h> +#include <resources.h> #include "networkrun.h" -void NetworkRun::detectState( NodeCollection * NC ) { - RuntimeInfo * RI = netNode()->nextNode()->runtime(); - AsDevice * Next = RI->asDevice(); - InterfaceInfo * II = Next->assignedInterface(); +State_t NetworkRun::detectState( void ) { + InterfaceInfo * II = nodeCollection()->assignedInterface(); - if( II ) { + Log(( "Interface %p : %d\n", II, (II) ? II->IsUp : 0 )); + if( II && II->IsUp ) { // device has assigned interface - NC->setCurrentState( (( II->IsUp ) ? IsUp : Available) ); - return; + return IsUp; } - Log(( "%s not ! UP or ava\n", NC->name().latin1() )); - // has no interface -> delegate - RI->detectState( NC ); + // had no interface or interface is no longer up -> release + nodeCollection()->assignInterface( 0 ); + + return Unknown; } -bool NetworkRun::setState( NodeCollection * NC, Action_t A, bool Force ) { +QString NetworkRun::setMyState( NodeCollection * NC, Action_t A, bool ) { // we handle UP and DOWN - RuntimeInfo * RI = netNode()->nextNode()->runtime(); - AsDevice * Next = RI->asDevice(); - InterfaceInfo * II = Next->assignedInterface(); + InterfaceInfo * II = NC->assignedInterface(); if( A == Up ) { // we can bring UP if lower level is available - if( NC->currentState() == Available || Force ) { - QString S; - S.sprintf( "ifup %s=%s-c%d-allowed", - II->Name.latin1(), II->Name.latin1(), - connection()->number() ); - NSResources->system().runAsRoot( S ); + QStringList SL; + SL << "ifup" + << QString().sprintf( "%s=%s-c%d-allowed", + II->Name.latin1(), II->Name.latin1(), + nodeCollection()->number() ); + if( ! NSResources->system().runAsRoot( SL ) ) { + return QString("Cannot call %1").arg(SL.join(" ")); } - return 1; - } else if( A == Down ) { - QString S; - if( Force ) { - Log(("Force mode %d\n", Force )); - for( int i = 0; - i < RI->netNode()->nodeClass()->instanceCount(); - i ++ ) { - S.sprintf( "ifdown %s", - RI->netNode()->nodeClass()->genNic( i ).latin1() ); - NSResources->system().runAsRoot( S ); + return QString(); + } + + if( A == Down ) { + QStringList SL; + if( II ) { + SL << "ifdown" + << II->Name.latin1(); + if( ! NSResources->system().runAsRoot( SL ) ) { + return QString( "Cannot call %1" ).arg( SL.join( " " )); } } else { - if( NC->currentState() == IsUp ) { - S.sprintf( "ifdown %s=%s-c%d-allowed", - II->Name.latin1(), II->Name.latin1(), - connection()->number() ); - NSResources->system().runAsRoot( S ); - } + Log(( "no interface assigned." )); } - return 1; - } - // delegate - return RI->setState( NC, A, Force ); -} - -bool NetworkRun::canSetState( State_t Curr, Action_t A ) { - // we handle UP and DOWN - RuntimeInfo * RI = netNode()->nextNode()->runtime(); - - if( A == Up ) { - return ( Curr == Available ); - } else if( A == Down ) { - return ( Curr == IsUp ); } - // delegate - return RI->canSetState( Curr, A ); -} - -bool NetworkRun::handlesInterface( const QString & S ) { - // donno -> pass deeper - return netNode()->nextNode()->runtime()->handlesInterface(S); + return QString(); } diff --git a/noncore/settings/networksettings2/network/networkrun.h b/noncore/settings/networksettings2/network/networkrun.h index 522a912..78a1694 100644 --- a/noncore/settings/networksettings2/network/networkrun.h +++ b/noncore/settings/networksettings2/network/networkrun.h @@ -1,23 +1,20 @@ -#include <asconnection.h> +#include <netnode.h> #include "networkdata.h" -class NetworkRun : public AsConnection { +class NetworkRun : public RuntimeInfo { public : NetworkRun( ANetNodeInstance * NNI, - NetworkData & Data ) : AsConnection( NNI ) + NetworkData & Data ) : RuntimeInfo( NNI ) { } - virtual AsConnection * asConnection( void ) - { return (AsConnection *)this; } + virtual RuntimeInfo * connection( void ) + { return this; } -protected : - - void detectState( NodeCollection * ); - bool setState( NodeCollection * ,Action_t A, bool ); - bool canSetState( State_t , Action_t A ); + State_t detectState( void ); - bool handlesInterface( const QString & I ); +protected : + QString setMyState( NodeCollection * , Action_t, bool ); }; diff --git a/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control b/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control index 3dbb808..7b1056b 100644 --- a/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control +++ b/noncore/settings/networksettings2/network/opie-networksettings2plugin-network.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-network +Package: opie-networksettings2plugin-network Files: plugins/networksettings2/libnetwork.so* Priority: optional diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index ce0eabc..a0d4c7c 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp @@ -3,6 +3,10 @@ #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> @@ -16,5 +20,4 @@ #include <qevent.h> -#include <asdevice.h> #include "networksettings.h" #include "netnode.h" @@ -32,11 +35,22 @@ NetworkSettings::NetworkSettings( QWidget *parent, Delete_TB->setPixmap( NSResources->getPixmap( "remove" ) ); CheckState_TB->setPixmap( NSResources->getPixmap( "check" ) ); - Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); - Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); - Disconnect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); + 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 OLedBox( red, LED_Frm ); + H->addWidget( Leds[0], 0, Qt::AlignVCenter ); + Leds[1] = new OLedBox( red, LED_Frm ); + H->addWidget( Leds[1], 0, Qt::AlignVCenter ); + Leds[2] = new OLedBox( red, LED_Frm ); + H->addWidget( Leds[2], 0, Qt::AlignVCenter ); + V->addStretch(1); - On_TB->setPixmap( NSResources->getPixmap( "off" ) ); SLOT_ToProfile(); @@ -73,5 +87,13 @@ NetworkSettings::NetworkSettings( QWidget *parent, connect( &(NSResources->system()), - SIGNAL( lineFromCommand(const QString &) ), + 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 &) ) ); @@ -88,7 +110,11 @@ NetworkSettings::~NetworkSettings() { QString S; - if( isModified() ) { + owarn << "Dispose NS" << oendl; + if( NSD.isModified() ) { + owarn << "Modified" << oendl; S = NSD.saveSettings(); if( ! S.isEmpty() ) { + S.insert( 0, "<p>" ); + S.append( "</p>" ); // problem saving QMessageBox::warning( @@ -98,4 +124,5 @@ NetworkSettings::~NetworkSettings() { SLOT_GenerateConfig(); + NSD.setModified( 0 ); } @@ -168,5 +195,5 @@ void NetworkSettings::SLOT_DeleteNode( void ) { NSResources->removeConnection( LBI->text() ); delete LBI; - setModified( 1 ); + NSD.setModified( 1 ); } } @@ -175,5 +202,4 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { QString OldName = ""; - printf( "------------------ Edit NOde\n" ); EditConnection EC( this ); @@ -197,5 +223,4 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { NodeCollection * NC = EC.connection(); if( NC->isModified() ) { - setModified( 1 ); if( LBI ) { if( NC->name() != OldName ) { @@ -250,60 +275,53 @@ void NetworkSettings::SLOT_ShowNode( QListBoxItem * LBI ) { NodeCollection * NC = NSResources->findConnection( LBI->text() ); - // is button possible - bool EnabledPossible, OnPossible, ConnectPossible; - // is button On or Off - bool DisabledOn, OnOn, ConnectOn; + if( NC->description().isEmpty() ) { + Description_LBL->setText( tr( "<<No description>>" ) ); + } else { + Description_LBL->setText( NC->description() ); + } + + Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() ); - EnabledPossible = OnPossible = ConnectPossible = 1; - DisabledOn = 1; - OnOn = ConnectOn = 0; + bool FrmActive = 1; + bool IsEnabled = 1; + int leds = 0; + owarn << "State " << NC->state() << oendl; switch( NC->state() ) { - case Unknown : - // cannot occur here + case Disabled : // no further work + IsEnabled = 0; + FrmActive = 0; + owarn << "LEds " << leds << oendl; break; + case Unknown : case Unchecked : case Unavailable : - // cannot do anything but recheck - EnabledPossible = OnPossible = ConnectPossible = 0; - break; - case Disabled : - OnPossible = ConnectPossible = 0; + FrmActive = 0; break; case Off : - DisabledOn = 0; + leds = 1; break; case Available : - OnOn = 1; - Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); - DisabledOn = 0; + leds = 2; break; case IsUp : - OnOn = ConnectOn = 1; - Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); - DisabledOn = 0; + leds = 3; break; } - if( ! OnOn ) { - Connect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); - } - - // set button state - Enable_TB->setEnabled( EnabledPossible ); - On_TB->setEnabled( OnPossible ); - Connect_TB->setEnabled( ConnectPossible ); - - Enable_TB->setOn( DisabledOn ); - On_TB->setOn( OnOn ); - Connect_TB->setOn( ConnectOn ); + Disable_TB->setOn( ! IsEnabled ); + LED_Frm->setEnabled( FrmActive ); - if( NC->description().isEmpty() ) { - Description_LBL->setText( tr( "<<No description>>" ) ); - } else { - Description_LBL->setText( NC->description() ); + 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 ); } - Profile_GB->setTitle( LBI->text() + " : " + NC->stateName() ); + Up_TB->setEnabled( leds < 3 && leds != 0 ); + Down_TB->setEnabled( leds > 0 ); } @@ -322,29 +340,29 @@ void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { void NetworkSettings::SLOT_GenerateConfig( void ) { - NSD.regenerate(); + QString S = NSD.generateSettings(); + if( ! S.isEmpty() ) { + S.insert( 0, "<p>" ); + S.append( "</p>" ); + QMessageBox::warning( + 0, + tr( "Generate config" ), + S); + } } -void NetworkSettings::SLOT_Enable( void ) { +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() ); - - bool rv; - switch( NC->state() ) { - case Disabled : - Msg = tr( "Cannot enable profile" ); - rv = NC->setState( Enable ); - break; - default : - Msg = tr( "Cannot disable profile" ); - rv = NC->setState( Disable ); - break; - } + NodeCollection * NC = NSResources->findConnection( LBI->text() ); - if( ! rv ) { + owarn << "Prepare to disable" << oendl; + Msg = NC->setState( (T) ? Disable : Enable ); + if( ! Msg.isEmpty() ) { + Msg.insert( 0, "<p>" ); + Msg.append( "</p>" ); QMessageBox::warning( 0, @@ -353,9 +371,16 @@ void NetworkSettings::SLOT_Enable( void ) { return; } + + // reload new state + NC->state( true ); updateProfileState( LBI ); } -void NetworkSettings::SLOT_On( void ) { +void NetworkSettings::SLOT_Up( void ) { + // bring more up + QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); + QString Msg; + int led = -1; if ( ! LBI ) @@ -365,31 +390,53 @@ void NetworkSettings::SLOT_On( void ) { NSResources->findConnection( LBI->text() ); - bool rv; switch( NC->state() ) { - case Off : - // activate interface - rv = NC->setState( Activate ); + 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 : // deactivate - case IsUp : // deactivate (will also bring down if needed) - rv = NC->setState( Deactivate ); + 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; - default : - // others no change - return; - } + } - if( ! rv ) { + if( ! Msg.isEmpty() ) { + Msg.insert( 0, "<p>" ); + Msg.append( "</p>" ); QMessageBox::warning( 0, - tr( "Activating profile" ), - tr( "Cannot enable profile" ) ); + 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_Connect( void ) { +void NetworkSettings::SLOT_Down( void ) { + // bring more down + QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); + int led = -1; + QString Msg; if ( ! LBI ) @@ -399,52 +446,49 @@ void NetworkSettings::SLOT_Connect( void ) { NSResources->findConnection( LBI->text() ); - bool rv = 1 ; switch( NC->state() ) { - case IsUp : - // down interface - rv = NC->setState( Down ); - break; - case Available : - // up interface - rv = NC->setState( Up ); + 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 Off : - // activate and bring up - rv = ( NC->setState( Activate ) && - NC->setState( Up ) ); + case Available : // -> down + led = 0; + Log(( "Deactivate interface %s\n", NC->name().latin1() )); + Msg = NC->setState( Deactivate ); + Down_TB->setEnabled( false ); break; - default : - // others no change + 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( ! rv ) { + if( ! Msg.isEmpty() ) { + Msg.insert( 0, "<p>" ); + Msg.append( "</p>" ); QMessageBox::warning( 0, - tr( "Activating profile" ), - tr( "Cannot enable profile" ) ); - } - - // we do not update the GUI but wait for the REAL upping of the device -} - -void NetworkSettings::SLOT_Disconnect( void ) { - QString S; - QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); - - if ( ! LBI ) + tr( "Decrease availability" ), + Msg ); return; + } - NodeCollection * NC = - NSResources->findConnection( LBI->text() ); + updateProfileState( LBI ); - Log(( "Force interface %s down\n", NC->name().latin1() )); - NC->setState( Down, 1 ); - // remove 'up' file to make sure - S.sprintf( "/tmp/Profile-%d.up", NC->number() ); - unlink( S.latin1() ); + // 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(); @@ -452,4 +496,5 @@ void NetworkSettings::SLOT_ToMessages( void ) { void NetworkSettings::SLOT_ToProfile( void ) { + Profiles_LB->show(); Profile_GB->show(); Messages_GB->hide(); diff --git a/noncore/settings/networksettings2/networksettings.h b/noncore/settings/networksettings2/networksettings.h index 8ec5d08..987e311 100644 --- a/noncore/settings/networksettings2/networksettings.h +++ b/noncore/settings/networksettings2/networksettings.h @@ -8,4 +8,5 @@ class QTimer; class QListBoxItem; class QEvent; +class OLedBox; class NetworkSettings : public NetworkSettingsGUI { @@ -18,14 +19,9 @@ public : const char *name=0, WFlags fl = 0 ); - ~NetworkSettings( void ); + virtual ~NetworkSettings( void ); static QString appName( void ) { return QString::fromLatin1("networksettings"); } - bool isModified( void ) - { return NSD.isModified(); } - void setModified( bool m ) - { NSD.setModified( m ); } - public slots : @@ -35,8 +31,9 @@ public slots : void SLOT_EditNode( QListBoxItem * ); void SLOT_CheckState( void ); - void SLOT_Enable( void ); - void SLOT_On( void ); - void SLOT_Connect( void ); - void SLOT_Disconnect( void ); + + void SLOT_Up( void ); + void SLOT_Down( void ); + void SLOT_Disable( bool ); + void SLOT_GenerateConfig( void ); void SLOT_RefreshStates( void ); @@ -51,3 +48,12 @@ private : QTimer * UpdateTimer; NetworkSettingsData NSD; + /* + + no leds : not present, unknown, unchecked or disabled + (1) down : hardware present but inactive + (2) available : hardware present and active + (3) up : present active and connected + + */ + OLedBox * Leds[3]; }; diff --git a/noncore/settings/networksettings2/networksettings.pro b/noncore/settings/networksettings2/networksettings.pro index 5d9efbb..d201db1 100644 --- a/noncore/settings/networksettings2/networksettings.pro +++ b/noncore/settings/networksettings2/networksettings.pro @@ -12,7 +12,7 @@ SOURCES = main.cpp \ activatevpn.cpp \ editconnection.cpp -INCLUDEPATH += $(OPIEDIR)/include networksettings2/ -DEPENDPATH += $(OPIEDIR)/include networksettings2/ -LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -lopiecore2 +INCLUDEPATH += $(OPIEDIR)/include networksettings2/ opietooth2/ +DEPENDPATH += $(OPIEDIR)/include networksettings2/ opietooth2/ +LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -lopietooth2 -lopiecore2 INTERFACES = networksettingsGUI.ui \ editconnectionGUI.ui \ diff --git a/noncore/settings/networksettings2/networksettings2/GUIUtils.h b/noncore/settings/networksettings2/networksettings2/GUIUtils.h index 23290a9..baf6f0c 100644 --- a/noncore/settings/networksettings2/networksettings2/GUIUtils.h +++ b/noncore/settings/networksettings2/networksettings2/GUIUtils.h @@ -32,4 +32,13 @@ } +#define STXT(a, b) \ + b->setText( a ); + +#define SCB(a, b) \ + b->setChecked( a ); + +#define SSB( Data,Wdg) \ + Wdg->setValue( Data ) + extern bool validIP( const QString & S ); diff --git a/noncore/settings/networksettings2/networksettings2/Utils.h b/noncore/settings/networksettings2/networksettings2/Utils.h index 739476e..301aac1 100644 --- a/noncore/settings/networksettings2/networksettings2/Utils.h +++ b/noncore/settings/networksettings2/networksettings2/Utils.h @@ -2,4 +2,6 @@ #define __UTILS_H +#include <opie2/odebug.h> + #define Log(x) VLog x extern void VLog( char * Format, ... ); diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index 110786a..17653bd 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp @@ -3,5 +3,4 @@ #include <qpe/resource.h> - #include <qpainter.h> #include <qbitmap.h> @@ -12,8 +11,22 @@ #include "netnode.h" -#include "asdevice.h" -#include "asline.h" -#include "asconnection.h" -#include "asfullsetup.h" +static char * ActionName[] = { + "Disable", + "Enable", + "Activate", + "Deactivate", + "Up", + "Down" +}; + +static char * StateName[] = { + "Unchecked", + "Unknown", + "Unavailable", + "Disabled", + "Off", + "Available", + "IsUp" +}; QString & deQuote( QString & X ) { @@ -66,4 +79,19 @@ void ANetNode::setAttribute( QString & Attr, QString & Value ){ } +bool ANetNode::isToplevel( void ) { + const char ** P = provides(); + while( *P ) { + if( strcmp( *P, "fullsetup") == 0 ) + return 1; + P ++; + } + return 0; +} + +bool ANetNode::openFile( SystemFile & SF, + ANetNodeInstance * NNI ) { + return (NNI ) ? NNI->openFile( SF ) : 0 ; +} + // // @@ -85,5 +113,5 @@ void ANetNodeInstance::initialize( void ) { void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ - if( Attr == "name" ) { + if( Attr == "__name" ) { setName( Value.latin1() ); } else { @@ -93,5 +121,5 @@ void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ void ANetNodeInstance::saveAttributes( QTextStream & TS ) { - TS << "name=" << name() << endl; + TS << "__name=" << name() << endl; saveSpecificAttribute( TS ); } @@ -113,4 +141,5 @@ NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { IsNew = 1; CurrentState = Unchecked; + AssignedInterface = 0; } @@ -124,4 +153,5 @@ NodeCollection::NodeCollection( QTextStream & TS ) : Name=""; IsNew = 0; + AssignedInterface = 0; CurrentState = Unchecked; @@ -148,5 +178,4 @@ NodeCollection::NodeCollection( QTextStream & TS ) : Name = N; } else if( A == "number" ) { - Log(( "Profile number %s\n", N.latin1() )); setNumber( N.toLong() ); } else if( A == "node" ) { @@ -160,4 +189,7 @@ NodeCollection::NodeCollection( QTextStream & TS ) : } } while( 1 ); + + Log(( "Profile number %s : %d nodes\n", + N.latin1(), count() )); } @@ -168,5 +200,5 @@ NodeCollection::~NodeCollection( void ) { const QString & NodeCollection::description( void ) { ANetNodeInstance * NNI = getToplevel(); - return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; + return (NNI) ? NNI->runtime()->description() : Name; } @@ -255,5 +287,6 @@ QPixmap NodeCollection::devicePixmap( void ) { getToplevel()->nextNode()->pixmapName()+"-large"); - QPixmap Mini = NSResources->getPixmap( device()->netNode()->pixmapName() ); + QPixmap Mini = NSResources->getPixmap( + device()->netNode()->pixmapName() ); if( pm.isNull() || Mini.isNull() ) @@ -281,9 +314,9 @@ QString NodeCollection::stateName( State_t S) { return qApp->translate( "networksettings2", "Disabled"); case Off : - return qApp->translate( "networksettings2", "Off"); + return qApp->translate( "networksettings2", "Inactive"); case Available : return qApp->translate( "networksettings2", "Available"); case IsUp : - return qApp->translate( "networksettings2", "IsUp"); + return qApp->translate( "networksettings2", "Up"); case Unchecked : /* FT */ default : @@ -301,20 +334,17 @@ void NodeCollection::reassign( void ) { } -bool NodeCollection::triggersVPN() { - return getToplevel()->runtime()->asFullSetup()->triggersVPN(); +const QStringList & NodeCollection::triggers() { + return getToplevel()->runtime()->triggers(); } -bool NodeCollection::hasDataForFile( const QString & S ) { +bool NodeCollection::hasDataForFile( SystemFile & S ) { return ( firstWithDataForFile( S ) != 0 ); } -ANetNodeInstance * NodeCollection::firstWithDataForFile( const QString & S ) { +ANetNodeInstance * NodeCollection::firstWithDataForFile( SystemFile & S ) { for( QListIterator<ANetNodeInstance> it(*this); it.current(); ++it ) { if( it.current()->hasDataForFile( S ) ) { - Log(( "Node %s has data for %s\n", - it.current()->nodeClass()->name(), - S.latin1() )); return it.current(); } @@ -323,15 +353,159 @@ ANetNodeInstance * NodeCollection::firstWithDataForFile( const QString & S ) { } +State_t NodeCollection::state( bool Update ) { + State_t NodeState; + + if( CurrentState == Unchecked || Update ) { + // collect states of all nodes until with get the 'higest' + // state possible + + Log(( "Connection %s state %s\n", + Name.latin1(), StateName[CurrentState] )); + + CurrentState = Unknown; + for( QListIterator<ANetNodeInstance> it(*this); + it.current(); + ++it ) { + Log(( "-> Detect %s\n", it.current()->name() )); + NodeState = it.current()->runtime()->detectState(); + Log(( " state %s\n", StateName[NodeState] )); + + if( NodeState == Disabled || + NodeState == IsUp ) { + // max + CurrentState = NodeState; + break; + } + + if( NodeState > CurrentState ) { + // higher + CurrentState = NodeState; + } + } + } + + return CurrentState; +} + +QString NodeCollection::setState( Action_t A, bool Force ) { + + QString msg; + Action_t Actions[10]; + int NoOfActions = 0; + + // get current state + state( Force ); + + switch( A ) { + case Disable : + if( CurrentState < Disabled ) { + // disabled + CurrentState = Disabled; + return QString(); + } + + if( CurrentState == IsUp ) { + Actions[NoOfActions++] = Down; + Actions[NoOfActions++] = Deactivate; + } else if( CurrentState == Available ) { + Actions[NoOfActions++] = Deactivate; + } + Actions[NoOfActions++] = Disable; + break; + case Enable : + // always possible -> detected state is new state + Actions[NoOfActions++] = Enable; + break; + case Activate : + if( ! Force ) { + if( CurrentState >= Available ) { + // already available + return QString(); + } + + if( CurrentState != Off ) { + return qApp->translate( "System", + "State should be off" ); + } + } + + Actions[NoOfActions++] = Activate; + break; + case Deactivate : + if( ! Force ) { + if( CurrentState < Off ) { + // already inactive + return QString(); + } + } + + if( CurrentState == IsUp ) { + Actions[NoOfActions++] = Down; + } + Actions[NoOfActions++] = Deactivate; + break; + case Up : + if( ! Force ) { + if( CurrentState == IsUp ) { + return QString(); + } + if( CurrentState < Off ) { + return qApp->translate( "System", + "State should at least be off" ); + } + } + if( CurrentState == Off ) { + Actions[NoOfActions++] = Activate; + } + Actions[NoOfActions++] = Up; + break; + case Down : + if( ! Force ) { + if( CurrentState < Available ) { + // OK + return QString(); + } + } + Actions[NoOfActions++] = Down; + break; + } + + // send actions to all nodes + Log(( "Action %s requires %d steps\n", + ActionName[A], NoOfActions )); + + for( int i = 0 ; i < NoOfActions; i ++ ) { + // setState recurses through the tree depth first + msg = getToplevel()->runtime()->setState( this, Actions[i], Force ); + if( ! msg.isEmpty() ) { + return msg; + } + } + return QString(); +} + // // -// RUNTIMEINFO +// RuntimeInfo // // -InterfaceInfo * RuntimeInfo::assignedInterface( void ) { - return netNode()->nextNode()->runtime()->assignedInterface(); -} +QString RuntimeInfo::setState( NodeCollection * NC, + Action_t A, + bool Force ) { + QString M; + RuntimeInfo * Deeper = nextNode(); + + if( Deeper ) { + // first go deeper + M = Deeper->setState( NC, A, Force ); + if( ! M.isEmpty() ) + return M; + } -AsDevice * RuntimeInfo::device( void ) { - return netNode()->nextNode()->runtime()->device(); + // set my own state + Log (( "-> Act upon %s\n", netNode()->name() )); + M = setMyState( NC, A, Force ); + Log (( " result %s\n", M.latin1() )); + return M; } diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index d3d7b34..4626381 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h @@ -11,4 +11,5 @@ #include <Utils.h> +#include <system.h> // difference feature interfaces @@ -27,4 +28,5 @@ class QTextStream; class RuntimeInfo; class InterfaceInfo; +class NSResources; extern QString & deQuote( QString & X ); @@ -56,19 +58,19 @@ typedef enum State { typedef enum Action { - // to make the device unavailable functionally + // to make the device unavailable functionally -> to disabled Disable = 0, - // to make the device available functionally + // to make the device available functionally -> to off Enable = 1, - // bring the hardware up + // bring the hardware up -> to Available Activate = 2, - // bring the hardware down + // bring the hardware down -> to off Deactivate = 3, - // bring the connection up + // bring the connection up -> to IsUp Up = 4, - // bring the connection down + // bring the connection down -> to Available Down = 5 } Action_t; -class ANetNode : public QObject{ +class ANetNode : public QObject { public: @@ -91,6 +93,5 @@ public: // does this Node provide a Connection - inline bool isToplevel( void ) - { return strcmp( provides(), "fullsetup") == 0 ; } + bool isToplevel( void ); // set the value of an attribute @@ -111,25 +112,36 @@ public: // do instances of this noce class have data for this file - virtual bool hasDataForFile( const QString & ) + virtual bool hasDataForFile( SystemFile & ) { return 0; } + // open proper file SF identified by S + // this method is called by NS2. + // + // overrule this ONLY if this proper file is a common file + // for all NNI of this node class and the data generated + // by each of the NNI needs to be put in one file + // + // if this is the case the file should be (re)opened in append + // return 0 if file cannot be opened + virtual bool openFile( SystemFile &SF, + ANetNodeInstance * NNI ); + // generate instance independent stuff // 0 : data output, 1 no data, 2 error - virtual short generateFile( const QString & , - const QString & , - QTextStream & , - long ) + virtual short generatePreamble( SystemFile & ) + { return 1; } + + // generate instance independent stuff + // 0 : data output, 1 no data, 2 error + virtual short generatePostamble( SystemFile & ) { return 1; } - // generate instance dependent but profile common stuff + // generate instance dependent but instance common stuff // 0 : data output, 1 no data, 2 error - virtual short generateFile( const QString & , - const QString & , - QTextStream & , + virtual short generateFile( SystemFile &, ANetNodeInstance * , long ) { return 1; } - // generate NIC name based on instance nr // only relevant if node instances are devices @@ -142,7 +154,8 @@ public: { return 1; } - // return list of files that are specific for this node class - virtual QStringList * properFiles( void ) - { return 0; } + // return ID list for each file generated specially for + // this node type + virtual QStringList properFiles( void ) + { return QStringList(); } // @@ -161,6 +174,8 @@ public: virtual ANetNodeInstance * createInstance( void ) = 0; - // return feature this NetNode provides - virtual const char * provides( void ) = 0; + // return features this NetNode provides + virtual const char ** provides( void ) = 0; + + // return features this NetNode needs virtual const char ** needs( void ) = 0; @@ -225,5 +240,5 @@ public: { return NodeType->pixmapName(); } - inline const char * provides( void ) + inline const char ** provides( void ) { return NodeType->provides(); } @@ -245,9 +260,9 @@ public: // open proper file identified by S - virtual QFile * openFile( const QString & ) + virtual bool openFile( SystemFile & ) { return 0; } // check if this node (or sub nodes) have data for this file - virtual bool hasDataForFile( const QString & S ) + virtual bool hasDataForFile( SystemFile & S ) { return nodeClass()->hasDataForFile( S ); } @@ -255,20 +270,16 @@ public: // in the section of the parent // this is called within the code of the parent - virtual short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFileEmbedded( SystemFile & SF, long DevNr ) { ANetNodeInstance * NNI = nextNode(); - return (NNI) ? NNI->generateFileEmbedded( ID, Path, TS, DevNr ) : 1; + return (NNI) ? NNI->generateFileEmbedded( SF, DevNr ) : 1; } // generate code specific for this node // (or find the first node that does) - virtual short generateFile( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFile( SystemFile & SF, long DevNr ) { ANetNodeInstance * NNI = nextNode(); - return (NNI) ? NNI->generateFile( ID, Path, TS, DevNr ) : 1; + return (NNI) ? NNI->generateFile( SF, DevNr ) : 1; } @@ -324,31 +335,116 @@ public : { NNI = TheNNI; } - // downcast implemented by specify runtime classes - virtual AsDevice * asDevice( void ) - { return 0; } - virtual AsConnection * asConnection( void ) - { return 0; } - virtual AsLine * asLine( void ) - { return 0; } - virtual AsFullSetup * asFullSetup( void ) - { return 0; } + // + // + // methods to be overloaded by connection capable + // runtimes + // + // + + + // + // + // methods to be overloaded by device capable + // runtimes + // + // // does this node handles this interface e.g.eth0 // recurse deeper if this node cannot answer that question - virtual bool handlesInterface( const QString & ) - { return 0; } - virtual bool handlesInterface( const InterfaceInfo & ) - { return 0; } - virtual InterfaceInfo * assignedInterface( void ); - virtual AsDevice * device( void ); - - ANetNodeInstance * netNode() + virtual bool handlesInterface( const QString & S ) { + RuntimeInfo * RI = device(); + if( RI ) { + return RI->handlesInterface( S ); + } + return 0; + } + bool handlesInterface( const InterfaceInfo & I ) { + RuntimeInfo * RI = device(); + if( RI ) { + return RI->handlesInterface( I ); + } + return 0; + } + + // + // + // methods to be overloaded by full setup capable + // runtimes + // + // + + // return description for this full setup + virtual const QString & description( void ) { + return fullSetup()->description( ); + } + // return triggers that should fire when this + // setup is brought up + virtual const QStringList & triggers( void ) { + return fullSetup()->triggers( ); + } + + // + // + // methods to be overloaded by line capable + // runtimes + // + // + + // return the device file ('/dev/xxx') created + // by this line capable runtime + virtual QString deviceFile( void ) { + RuntimeInfo * RI = line(); + if( RI ) { + return RI->deviceFile(); + } + return QString(); + } + + // + // + // runtime interface + // + // + + // return the node that offers device capability + virtual RuntimeInfo * device( void ) + { RuntimeInfo * RI = nextNode(); + return (RI) ? RI->device() : 0; + } + + // return the node that offers connection capability + virtual RuntimeInfo * connection( void ) + { RuntimeInfo * RI = nextNode(); + return (RI) ? RI->connection() : 0; + } + + // return the node that offers line capability + virtual RuntimeInfo * line( void ) + { RuntimeInfo * RI = nextNode(); + return (RI) ? RI->line() : 0; + } + + // return the node that offers full setup capability + virtual RuntimeInfo * fullSetup( void ) + { RuntimeInfo * RI = nextNode(); + return (RI) ? RI->fullSetup() : 0; + } + + inline ANetNodeInstance * netNode() { return NNI; } - NodeCollection * connection() + + inline NodeCollection * nodeCollection() { return NNI->connection(); } - virtual void detectState( NodeCollection * NC ) = 0; - virtual bool setState( NodeCollection * NC, Action_t A, bool Force = 0 ) = 0; - virtual bool canSetState( State_t Curr, Action_t A ) = 0; + virtual State_t detectState( void ) = 0; + // public API to set the state + virtual QString setState( NodeCollection * NC, + Action_t A, + bool Force = 0 ); + + inline RuntimeInfo * nextNode( void ) { + ANetNodeInstance * NNI = netNode()->nextNode(); + return (NNI) ? NNI->runtime() : 0; + } signals : @@ -359,4 +455,9 @@ signals : protected : + // set state of this node (private API) + virtual QString setMyState( NodeCollection * NC, + Action_t A, + bool Force = 0 ) = 0; + // connection this runtime info belongs to ANetNodeInstance * NNI; @@ -393,26 +494,30 @@ public : } + // return the interface in the OS that is assigned to + // this device inline InterfaceInfo * assignedInterface( void ) { - return getToplevel()->runtime()->assignedInterface(); + return AssignedInterface; } - inline AsDevice * device() { + // assign the interface to this device + inline void assignInterface( InterfaceInfo * NI ) { + if( NI == 0 ) { + if( AssignedInterface ) { + AssignedInterface->assignConnection( 0 ); + } + } + AssignedInterface = NI; + if( AssignedInterface ) { + AssignedInterface->assignConnection( this ); + } + } + + inline RuntimeInfo * device() { return getToplevel()->runtime()->device(); } - bool triggersVPN(); - - inline State_t state( bool Update = 0 ) - { Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState, - Unchecked )); - if( CurrentState == Unchecked || Update ) { - Log(( "TL %p TLR %p\n", - getToplevel(), - getToplevel()->runtime() )); - // need to get current state - getToplevel()->runtime()->detectState( this ); - } - return CurrentState; - } + const QStringList & triggers(); + + State_t state( bool Update = 0 ); // get the ixmap for this device @@ -425,8 +530,5 @@ public : { return stateName( state(Update) ); } - inline bool setState( Action_t A, bool Force =0 ) - { return getToplevel()->runtime()->setState( this, A, Force ); } - inline bool canSetState( Action_t A ) - { return getToplevel()->runtime()->canSetState( CurrentState, A ); } + QString setState( Action_t A, bool Force = 0 ); void save( QTextStream & TS ); @@ -457,14 +559,12 @@ public : // return TRUE if this node can have data to be inserted in // file identified by S - bool hasDataForFile( const QString & S ); - ANetNodeInstance * firstWithDataForFile( const QString & S ); + bool hasDataForFile( SystemFile & S ); + ANetNodeInstance * firstWithDataForFile( SystemFile & ); // generate items for this file -> toplevel call - short generateFile( const QString & FID, // identification of file - const QString & FName, // effective filename of file - QTextStream & TS, // stream to file + short generateFile( SystemFile & SF, long DN // device number ) - { return getToplevel()->generateFile( FID, FName, TS, DN ); } + { return getToplevel()->generateFile( SF, DN ); } bool triggeredBy( const QString & Trigger ) @@ -490,4 +590,6 @@ private : int Done; + InterfaceInfo * AssignedInterface; + }; diff --git a/noncore/settings/networksettings2/networksettings2/networksettings2.pro b/noncore/settings/networksettings2/networksettings2/networksettings2.pro index d1e42b7..f2ba9df 100644 --- a/noncore/settings/networksettings2/networksettings2/networksettings2.pro +++ b/noncore/settings/networksettings2/networksettings2/networksettings2.pro @@ -6,11 +6,7 @@ HEADERS = netnode.h \ resources.h \ system.h \ - asline.h \ GUIUtils.h \ - asconnection.h \ - asfullsetup.h \ systemfile.h \ - wextensions.h \ - asdevice.h + wextensions.h SOURCES = netnode.cpp \ GUIUtils.cpp \ diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index 2f17693..8b3b4fe 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp @@ -46,13 +46,18 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), continue; - const char * Provides = InnerIt.current()->NetNode->provides(); + const char ** Provides = InnerIt.current()->NetNode->provides(); NeedsRun = OuterIt.current()->NetNode->needs(); + for( ; *NeedsRun; NeedsRun ++ ) { - if( strcmp( Provides, *NeedsRun ) == 0 ) { - // inner provides what outer needs - NNL.resize( NNL.size() + 1 ); - NNL[NNL.size()-1] = InnerIt.current()->NetNode; - Done = 1; // break from 2 loops - break; + const char ** PRun; + PRun = Provides; + for( ; *PRun; PRun ++ ) { + if( strcmp( *PRun, *NeedsRun ) == 0 ) { + // inner provides what outer needs + NNL.resize( NNL.size() + 1 ); + NNL[NNL.size()-1] = InnerIt.current()->NetNode; + Done = 1; // break from 2 loops + break; + } } } @@ -62,21 +67,15 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), } - // define Node types to Description map - NodeTypeNameMap.insert( "device", tr( "Network Device" ) ); - NodeTypeNameMap.insert( "line", tr( "Character device" ) ); - NodeTypeNameMap.insert( "connection", tr( "IP Connection" ) ); - NodeTypeNameMap.insert( "fullsetup", tr( "Connection Profile" ) ); - - NodeTypeDescriptionMap.insert( "device", - tr( "<p>Devices that can handle IP packets</p>" ) ); - NodeTypeDescriptionMap.insert( "line", - tr( "<p>Devices that can handle single bytes</p>" ) ); - NodeTypeDescriptionMap.insert( "connection", - tr( "<p>Nodes that provide working IP connections</p>" ) ); - NodeTypeDescriptionMap.insert( "fullsetup", - tr( "<p>Fully configured connection profile</p>" ) ); - - // define system files - addSystemFile( "interfaces", "/tmp/interfaces", 1 ); + // define built in Node types to Description map + addNodeType( "device", tr( "Network Device" ), + tr( "<p>Devices that can handle IP packets</p>" ) ); + addNodeType( "line", tr( "Character device" ), + tr( "<p>Devices that can handle single bytes</p>" ) ); + addNodeType( "connection", tr( "IP Connection" ), + tr( "<p>Nodes that provide working IP connections</p>" ) ); + addNodeType( "fullsetup", tr( "Connection Profile" ), + tr( "<p>Fully configured connection profile</p>" ) ); + addNodeType( "GPRS", tr( "Connection to GPRS device" ), + tr( "<p>Connection to a GPRS capable device</p>" ) ); // get access to the system @@ -89,4 +88,13 @@ TheNSResources::~TheNSResources( void ) { } +void TheNSResources::addNodeType( const QString & ID, + const QString & Name, + const QString & Descr ) { + if( NodeTypeNameMap[ID].isEmpty() ) { + NodeTypeNameMap.insert( ID, Name ); + NodeTypeDescriptionMap.insert( ID, Descr ); + } +} + void TheNSResources::addSystemFile( const QString & ID, const QString & P, @@ -221,6 +229,8 @@ QPixmap TheNSResources::getPixmap( const QString & QS ) { QString S("networksettings2/"); S += QS; - Log(("%s\n", S.latin1() )); P = Resource::loadPixmap( S ); + if( P.isNull() ) { + Log(( "Cannot load %s\n", S.latin1() )); + } return ( P.isNull() ) ? QPixmap() : P; } @@ -270,4 +280,14 @@ NodeCollection * TheNSResources::findConnection( const QString & S ) { } +NodeCollection * TheNSResources::getConnection( int nr ) { + for( QDictIterator<NodeCollection> it(ConnectionsMap); + it.current(); + ++it ) { + if( it.current()->number() == nr ) { + return it.current(); + } + } + return 0; +} /* void TheNSResources::renumberConnections( void ) { diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h index 23b120e..634cd39 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.h +++ b/noncore/settings/networksettings2/networksettings2/resources.h @@ -68,4 +68,9 @@ public : } + // define new plugin (=node) + void addNodeType( const QString & ID, + const QString & LongName, + const QString & Description ); + Name2SystemFile_t & systemFiles( void ) { return SystemFiles; } @@ -100,4 +105,5 @@ public : void removeConnection( const QString & N ); NodeCollection * findConnection( const QString & N ); + NodeCollection * getConnection( int nr ); Name2Connection_t & connections( void ) { return ConnectionsMap; } diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp index 298bdc9..141484c 100644 --- a/noncore/settings/networksettings2/networksettings2/system.cpp +++ b/noncore/settings/networksettings2/networksettings2/system.cpp @@ -14,4 +14,6 @@ #include <unistd.h> +#include <opie2/oprocess.h> + #include <qdir.h> #include <qregexp.h> @@ -51,10 +53,8 @@ System::~System( void ) { } -int System::runAsRoot( const QString & S ) { - QString MyS = S; +int System::runAsRoot( QStringList & S ) { char * usr = getenv("USER"); - char ch; - if( S.isEmpty() ) { + if( S.count() == 0 ) { // loophole to start shell return 8888; @@ -62,50 +62,107 @@ int System::runAsRoot( const QString & S ) { if( usr == 0 || strcmp( usr, "root" ) ) { // unknown or non-root user -> use SUDO - MyS.prepend( "sudo " ); + S.prepend( "sudo" ); } - Log(("Executing %s\n", MyS.latin1() )); - - emit lineFromCommand( tr("Command : ") + MyS ); - emit lineFromCommand( "---------------" ); - Log(( "Command : %s\n", MyS.latin1() ) ); - MyS += " 2>&1 "; - OutputOfCmd = popen( MyS.latin1(), "r" ) ; - if( ! OutputOfCmd ) { - // cannot fork - return 1; + if( getenv( "NS2TESTMODE" ) ) { + owarn << "TESTMODE !!! execute " + << S.join( " ") + << oendl; + } else { + MyProcess * P = new MyProcess(); + emit processEvent( tr("Command : ") + S.join( " " ) ); + + P->process() << S; + + connect( P, + SIGNAL( stdoutLine( const QString & ) ), + this, + SIGNAL( stdoutLine( const QString & ) ) ); + + connect( P, + SIGNAL( stderrLine( const QString & ) ), + this, + SIGNAL( stderrLine( const QString & ) ) ); + + connect( P, + SIGNAL(processExited(MyProcess*) ), + this, SLOT + (SLOT_ProcessExited(MyProcess*) ) ); + + Log(("Executing %s\n", S.join( " " ).latin1() )); + + if( ! P->process().start( OProcess::DontCare, + OProcess::AllOutput ) ) { + owarn << "Error starting " << S << oendl; + delete P; + // error starting app + return 1; + } + owarn << "Started " << S << oendl; } - // read all data - QString Line = ""; - while( 1 ) { - if( fread( &ch, 1, 1, OutputOfCmd ) < 1 ) - // eof - break; - if( ch == '\n' || ch == '\r' ) { - if( ! Line.isEmpty() ) { - Log(( "read cmd output : **%s**\n", Line.latin1() ) ); - emit lineFromCommand( Line ); - Line = ""; - qApp->processEvents(); + // all is fine + return 0; +} + +int System::execAsUser( QStringList & SL ) { + MyProcess * P = new MyProcess(); + CurrentQPEUser CU = NSResources->currentUser(); + char * usr = getenv("USER"); + + if( strcmp( usr, "root" ) == 0 ) { + // find user running qpe + if( CU.UserName.isEmpty() ) { + // if we come here, the exec was not successfull + Log(("User not known \n" )); + return 0; } - } else { - Line += ch; } - } - if( ! Line.isEmpty() ) { - emit lineFromCommand( Line ); - Log(( "read cmd output : **%s**\n", Line.latin1() ) ); - } - Log(( "End of command\n", Line.latin1() ) ); + // now we are ready to exec the requested command + setuid( CU.Uid ); + setgid( CU.Gid ); - if( pclose( OutputOfCmd ) < 0 ) { - // error in command - return 3; - } + for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) { + QString X; + QStringList SL; + X = CU.EnvList[i]; + SL = QStringList::split( "=", X ); + P->process().setEnvironment( SL[0], SL[1] ); + } - // all is fine - return 0; + P->process() << SL; + + emit processEvent( tr("Command : ") + SL.join( " " ) ); + + Log(("Executing as user %s : %s\n", + CU.UserName.latin1(), + SL.join( " " ).latin1() )); + + int rv = ( P->process().start( OProcess::DontCare, + OProcess::NoCommunication ) ); + delete P; + + if( rv ) { + // if we come here, the exec was not successfull + Log(("Could not exec : %d\n", errno )); + } + + return rv; +} + +void System::SLOT_ProcessExited( MyProcess * P ) { + QString R; + + for( QValueListConstIterator<QCString> it = P->process().args().begin(); + it != P->process().args().end(); + ++it ) { + R += (*it); + R += " "; + } + + R += "Returned with " + QString().setNum( P->process().exitStatus() ); + emit processEvent( R ); + delete P; } @@ -199,6 +256,12 @@ void System::probeInterfaces( void ) { sockfd = socket(PF_INET, SOCK_DGRAM, 0); - if(sockfd == -1) + if(sockfd == -1) { + owarn << "Cannot open INET socket " + << errno + << " " + << strerror( errno ) + << oendl; return; + } // read interfaces from /proc/dev/net @@ -206,6 +269,14 @@ void System::probeInterfaces( void ) { ProcDevNet = new QFile(PROCNETDEV); if( ! ProcDevNet->open(IO_ReadOnly) ) { + owarn << "Cannot open " + << PROCNETDEV + << " " + << errno + << " " + << strerror( errno ) + << oendl; delete ProcDevNet; ProcDevNet =0; + ::close( sockfd ); return; } @@ -230,8 +301,8 @@ void System::probeInterfaces( void ) { if ( ! ( IFI = ProbedInterfaces.find( NicName ) ) ) { // new nic - Log(("NEWNIC %s\n", NicName.latin1())); + Log(("New NIC found : %s\n", NicName.latin1())); IFI = new InterfaceInfo; IFI->Name = line.left(loc); - IFI->NetNode = 0; + IFI->Collection = 0; ProbedInterfaces.insert( IFI->Name, IFI ); @@ -257,5 +328,5 @@ void System::probeInterfaces( void ) { if( ioctl(sockfd, SIOCGIFHWADDR, &ifrs) >= 0 ) { - Log(("%s = %d\n", IFI->Name.latin1(), + Log(("Family for NIC %s : %d\n", IFI->Name.latin1(), ifrs.ifr_hwaddr.sa_family )); @@ -325,5 +396,5 @@ void System::probeInterfaces( void ) { } } else // else already probed before -> just update - Log(("OLDNIC %s\n", NicName.latin1())); + Log(("Redetected NIC %s\n", NicName.latin1())); // get dynamic info @@ -355,33 +426,23 @@ void System::probeInterfaces( void ) { IFI->Netmask = ""; } - Log(("NIC %s UP %d\n", NicName.latin1(), IFI->IsUp )); + Log(("NIC %s UP ? %d\n", NicName.latin1(), IFI->IsUp )); } -} - -void System::execAsUser( QString & Cmd, char * argv[] ) { - CurrentQPEUser CU = NSResources->currentUser(); - - if( CU.UserName.isEmpty() ) { - // if we come here, the exec was not successfull - Log(("User not known \n" )); - return; - } - // now we are ready to exec the requested command - setuid( CU.Uid ); - setgid( CU.Gid ); - - char ** envp = (char **)alloca( sizeof( char *) * - (CU.EnvList.count()+1) ); + ::close( sockfd ); +} - for( unsigned int i = 0 ; i < CU.EnvList.count() ; i ++ ) { - *(envp+i) = CU.EnvList[i]; +InterfaceInfo * System::findInterface( const QString & N ) { + InterfaceInfo * Run; + // has PAN connection UP interface ? + for( QDictIterator<InterfaceInfo> It(ProbedInterfaces); + It.current(); + ++It ) { + Run = It.current(); + if( N == Run->Name ) { + // this PAN connection is up + return Run; + } } - envp[CU.EnvList.count()]=NULL; - - execve( Cmd.latin1(), argv, envp ); - - // if we come here, the exec was not successfull - Log(("Could not exec : %d\n", errno )); + return 0; } @@ -395,12 +456,16 @@ void VLog( char * Format, ... ) { if( logf == (FILE *)0 ) { - if( getenv("NS2STDERR") ) { + QString S = getenv("NS2LOG"); + if( S == "stderr" ) { logf = stderr; - } else { + } else if( S.isEmpty() ) { logf = fopen( "/tmp/ns2log", "a" ); + } else { + logf = fopen( S, "a" ); } + if( ! logf ) { - fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n", - errno ); + fprintf( stderr, "Cannot open logfile %s : %d\n", + S.latin1(), errno ); logf = (FILE *)1; } else { @@ -409,8 +474,9 @@ void VLog( char * Format, ... ) { } - if( (long)logf > 1 ) { + if( (unsigned long)logf > 1 ) { vfprintf( logf, Format, l ); } va_end( l ); + fflush( logf ); } @@ -427,7 +493,81 @@ void LogClose( void ) { QString removeSpaces( const QString & X ) { - QStringList SL; + QString Y; + Y = X.simplifyWhiteSpace(); + Y.replace( QRegExp(" "), "_" ); + owarn << X << " **" << Y << "**" << oendl; + return Y; +} + +// +// +// +// +// + +MyProcess::MyProcess() : QObject(), StdoutBuffer(), StderrBuffer() { + P = new OProcess(); + connect( P, + SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int ) ), + this, + SLOT( SLOT_Stdout(Opie::Core::OProcess*,char*,int) ) ); + + connect( P, + SIGNAL( receivedStderr(Opie::Core::OProcess*, char*, int ) ), + this, + SLOT( SLOT_Stderr(Opie::Core::OProcess*,char*,int) ) ); + connect( P, + SIGNAL( processExited(Opie::Core::OProcess*) ), + this, + SLOT( SLOT_ProcessExited(Opie::Core::OProcess*) ) ); +} + +MyProcess::~MyProcess() { + delete P; +} + +void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { + char * LB = (char *)alloca( len + 1 ); + memcpy( LB, Buf, len ); + LB[len] = '\0'; + + // now input is zero terminated + StdoutBuffer += LB; + + owarn << "Received " << len << " bytes on stdout" << oendl; + // see if we have some lines (allow empty lines) + QStringList SL = QStringList::split( "\n", StdoutBuffer, TRUE ); + + for( unsigned int i = 0; i < SL.count()-1; i ++ ) { + Log(( "Stdout : \"%s\"\n", SL[i].latin1() ) ); + emit stdoutLine( SL[i] ); + } + + // last line is rest + StdoutBuffer = SL[ SL.count()-1 ]; +} + +void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) { + char * LB = (char *)alloca( len + 1 ); + memcpy( LB, Buf, len ); + LB[len] = '\0'; + + // now input is zero terminated + StderrBuffer += LB; + + owarn << "Received " << len << " bytes on stderr" << oendl; + // see if we have some lines (allow empty lines) + QStringList SL = QStringList::split( "\n", StderrBuffer, TRUE ); + + for( unsigned int i = 0; i < SL.count()-1; i ++ ) { + Log(( "Stderr : \"%s\"\n", SL[i].latin1() ) ); + emit stderrLine( SL[i] ); + } + + // last line is rest + StderrBuffer = SL[ SL.count()-1 ]; +} - SL = QStringList::split( " ", X ); - return SL.join( "_" ); +void MyProcess::SLOT_ProcessExited( Opie::Core::OProcess * ) { + emit processExited( this ); } diff --git a/noncore/settings/networksettings2/networksettings2/system.h b/noncore/settings/networksettings2/networksettings2/system.h index 33af391..e67d695 100644 --- a/noncore/settings/networksettings2/networksettings2/system.h +++ b/noncore/settings/networksettings2/networksettings2/system.h @@ -2,4 +2,10 @@ #define __SYSTEM__H +#include <qstring.h> + +#include <opie2/oprocess.h> + +using namespace Opie::Core; + // for hardware types #include <net/if_arp.h> @@ -8,7 +14,39 @@ #include <stdio.h> +class NodeCollection; class ANetNodeInstance; class QFile; +class MyProcess : public QObject { + + Q_OBJECT + +public : + + MyProcess(); + ~MyProcess(); + + inline OProcess & process() + { return *P; } + +public slots : + + void SLOT_Stdout( Opie::Core::OProcess * P, char *, int ); + void SLOT_Stderr( Opie::Core::OProcess * P, char *, int ); + void SLOT_ProcessExited( Opie::Core::OProcess * P); + +signals : + + void stdoutLine( const QString & ); + void stderrLine( const QString & ); + void processExited( MyProcess * ); + +private : + + QString StdoutBuffer; + QString StderrBuffer; + OProcess * P; +}; + class InterfaceInfo { @@ -23,11 +61,11 @@ public : } - ANetNodeInstance * assignedNode() - { return NetNode; } + NodeCollection * assignedConnection() + { return Collection; } - void assignNode( ANetNodeInstance * NNI ) - { NetNode = NNI; } + void assignConnection( NodeCollection * NNI ) + { Collection = NNI; } - ANetNodeInstance * NetNode; // netnode taking care of me + NodeCollection * Collection; // connection taking care of me QString Name; // name of interface int CardType; // type of card @@ -65,8 +103,8 @@ public : // exec command as root - int runAsRoot( const QString & S ); + int runAsRoot( QStringList & S ); // exec command as user - void execAsUser( QString & Cmd, char * argv[] ); + int execAsUser( QStringList & Cmd ); // refresh stats for this interface @@ -76,7 +114,15 @@ public : void probeInterfaces( void ); + InterfaceInfo * findInterface( const QString & DevName ); + +private slots : + + void SLOT_ProcessExited( MyProcess * ); + signals : - void lineFromCommand( const QString & S ); + void stdoutLine( const QString & ); + void stderrLine( const QString & ); + void processEvent( const QString & ); private : @@ -85,5 +131,4 @@ private : FILE * OutputOfCmd; QFile * ProcDevNet; - }; diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp index 2b40834..82fd43a 100644 --- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp +++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp @@ -17,4 +17,5 @@ SystemFile::SystemFile( const QString & N, Name = N; Path = P; + InAppend = 0; F = 0; // get template info @@ -64,18 +65,53 @@ SystemFile::SystemFile( const QString & N, } +SystemFile::SystemFile( const QString & N, bool KDI ){ + Name = N; + Path = ""; + InAppend = 0; + F =0; + KnowsDeviceInstances = KDI; + hasPreSection = + hasPostSection = + hasPreNodeSection = + hasPostNodeSection = + hasPreDeviceSection = + hasPostDeviceSection = 0; +} + SystemFile::~SystemFile( void ) { - if( F ) - delete F; + close(); } bool SystemFile::open( void ) { - if( F ) { - F->close(); - delete F; - } + QString Prefix = getenv( "NS2OUTPUTTO" ); + + if( Prefix != "stderr" /* && Name != "interfaces" */ ) { + // generate files where the need to be + if( F ) { + F->close(); + delete F; + } - F = new QFile( Path + "bup" ); - if( ! F->open( IO_WriteOnly ) ) { - return 0; + F = new QFile( Prefix + Path + ((InAppend)?"":"bup") ); + Log(( "Open systemfile %s\n", F->name().latin1() )); + if( ! F->open( ((InAppend)?IO_Append : 0 ) | IO_WriteOnly ) ) { + return 0; + } + } else { + if( ! F ) { + owarn << "!!!!!!!!!!!!!!!!!! " << oendl; + owarn << "!!!! TESTMODE !!!!" << oendl; + owarn << "!!!!!!!!!!!!!!!!!! " << oendl; + owarn << "!!!!" << oendl; + owarn << "!!!! GENERATE " << Path << oendl; + if( InAppend ) { + owarn << "!!!! In APPEND mode" << oendl; + } + owarn << "!!!!" << oendl; + owarn << "!!!!!!!!!!!!!!!!!!" << oendl; + + F = new QFile(); + F->open( IO_WriteOnly, stderr ); + } } setDevice( F ); @@ -84,9 +120,15 @@ bool SystemFile::open( void ) { bool SystemFile::close( void ) { - if( ! F ) { + if( ! F || ! F->isOpen() ) { return 1 ; } - QString OldP = Path + "bup"; + QString Prefix = getenv( "NS2OUTPUTTO" ); + + if( Prefix == "stderr" ) { + return 1; + } + + QString OldP = Prefix + Path + "bup"; F->close(); @@ -94,5 +136,9 @@ bool SystemFile::close( void ) { F = 0; - return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); + if( ! InAppend ) { + owarn << "Rename " << OldP << " to " << Path << oendl; + return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); + } + return 1; } diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.h b/noncore/settings/networksettings2/networksettings2/systemfile.h index ceed605..a950c4d 100644 --- a/noncore/settings/networksettings2/networksettings2/systemfile.h +++ b/noncore/settings/networksettings2/networksettings2/systemfile.h @@ -15,13 +15,23 @@ public : const QString & Path, bool KnowsDevicesInstances ); + SystemFile( const QString & Name, + bool KnowsDevicesInstances = 0 ); ~SystemFile( void ); + void setName( const QString & S ) + { Name = S; } const QString & name( void ) const { return Name; } + + void setPath( const QString & S ) + { Path = S; } const QString & path( void ) const { return Path; } + bool knowsDeviceInstances( void ) const { return KnowsDeviceInstances; } + void setAppendMode( bool A) + { InAppend = A; }; bool open( void ); bool close( void ); @@ -46,4 +56,5 @@ private : bool hasPostDeviceSection; bool KnowsDeviceInstances; + bool InAppend; }; diff --git a/noncore/settings/networksettings2/networksettingsGUI.ui b/noncore/settings/networksettings2/networksettingsGUI.ui index 6ed29f3..1085e08 100644 --- a/noncore/settings/networksettings2/networksettingsGUI.ui +++ b/noncore/settings/networksettings2/networksettingsGUI.ui @@ -12,6 +12,6 @@ <x>0</x> <y>0</y> - <width>144</width> - <height>260</height> + <width>383</width> + <height>359</height> </rect> </property> @@ -69,5 +69,5 @@ <property stdset="1"> <name>spacing</name> - <number>1</number> + <number>0</number> </property> <widget> @@ -168,12 +168,5 @@ <property stdset="1"> <name>name</name> - <cstring>Enable_TB</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - </sizepolicy> + <cstring>Disable_TB</cstring> </property> <property stdset="1"> @@ -194,12 +187,5 @@ <property stdset="1"> <name>name</name> - <cstring>On_TB</cstring> - </property> - <property stdset="1"> - <name>sizePolicy</name> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - </sizepolicy> + <cstring>Down_TB</cstring> </property> <property stdset="1"> @@ -209,35 +195,24 @@ <property stdset="1"> <name>toggleButton</name> - <bool>true</bool> + <bool>false</bool> </property> <property stdset="1"> <name>toggleButton</name> - <bool>true</bool> + <bool>false</bool> </property> </widget> <widget> - <class>QToolButton</class> + <class>QFrame</class> <property stdset="1"> <name>name</name> - <cstring>Connect_TB</cstring> + <cstring>LED_Frm</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> + <name>frameShape</name> + <enum>NoFrame</enum> </property> <property stdset="1"> - <name>toggleButton</name> - <bool>true</bool> + <name>frameShadow</name> + <enum>Raised</enum> </property> </widget> @@ -246,12 +221,5 @@ <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> + <cstring>Up_TB</cstring> </property> <property stdset="1"> @@ -261,9 +229,9 @@ <property stdset="1"> <name>toggleButton</name> - <bool>true</bool> + <bool>false</bool> </property> <property stdset="1"> <name>toggleButton</name> - <bool>true</bool> + <bool>false</bool> </property> </widget> @@ -480,10 +448,4 @@ <connections> <connection> - <sender>Add_TB</sender> - <signal>clicked()</signal> - <receiver>NetworkSettingsGUI</receiver> - <slot>SLOT_AddNode()</slot> - </connection> - <connection> <sender>Delete_TB</sender> <signal>clicked()</signal> @@ -498,22 +460,4 @@ </connection> <connection> - <sender>Enable_TB</sender> - <signal>clicked()</signal> - <receiver>NetworkSettingsGUI</receiver> - <slot>SLOT_Enable()</slot> - </connection> - <connection> - <sender>Connect_TB</sender> - <signal>clicked()</signal> - <receiver>NetworkSettingsGUI</receiver> - <slot>SLOT_Connect()</slot> - </connection> - <connection> - <sender>On_TB</sender> - <signal>clicked()</signal> - <receiver>NetworkSettingsGUI</receiver> - <slot>SLOT_On()</slot> - </connection> - <connection> <sender>GenConfig_TB</sender> <signal>clicked()</signal> @@ -552,21 +496,39 @@ </connection> <connection> - <sender>Disconnect_TB</sender> + <sender>Add_TB</sender> + <signal>clicked()</signal> + <receiver>NetworkSettingsGUI</receiver> + <slot>SLOT_AddNode()</slot> + </connection> + <connection> + <sender>Disable_TB</sender> + <signal>toggled(bool)</signal> + <receiver>NetworkSettingsGUI</receiver> + <slot>SLOT_Disable(bool)</slot> + </connection> + <connection> + <sender>Down_TB</sender> + <signal>clicked()</signal> + <receiver>NetworkSettingsGUI</receiver> + <slot>SLOT_Down()</slot> + </connection> + <connection> + <sender>Up_TB</sender> <signal>clicked()</signal> <receiver>NetworkSettingsGUI</receiver> - <slot>SLOT_Disconnect()</slot> + <slot>SLOT_Up()</slot> </connection> <slot access="public">SLOT_AddNode()</slot> <slot access="public">SLOT_CheckState()</slot> - <slot access="public">SLOT_Connect()</slot> <slot access="public">SLOT_DeleteNode()</slot> + <slot access="public">SLOT_Disable(bool)</slot> <slot access="public">SLOT_EditNode( QListBoxItem *)</slot> - <slot access="public">SLOT_Enable()</slot> <slot access="public">SLOT_GenerateConfig()</slot> - <slot access="public">SLOT_On()</slot> + <slot access="public">SLOT_SetState(int)</slot> <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> + <slot access="public">SLOT_Up()</slot> + <slot access="public">SLOT_Down()</slot> </connections> </UI> diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index e2dd5b5..698a941 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp @@ -1,3 +1,4 @@ #include <stdlib.h> +#include <opie2/odebug.h> #include <qpe/qpeapplication.h> #include <qtextstream.h> @@ -7,5 +8,5 @@ #include "nsdata.h" -#include <asdevice.h> +#include <netnode.h> #include <resources.h> @@ -28,6 +29,44 @@ NetworkSettingsData::NetworkSettingsData( void ) { // load settings - IsModified = 0; loadSettings(); + + // assign interfaces by scanning /tmp/profile-%s.Up files + { QDir D( "/tmp" ); + QFile * F = new QFile; + int profilenr; + QString interfacename; + QTextStream TS ( F ); + + QStringList SL = D.entryList( "profile-*.up"); + + Log(( "System reports %d interfaces. Found %d up\n", + NSResources->system().interfaces().count(), + SL.count() )); + + for ( QStringList::Iterator it = SL.begin(); + it != SL.end(); + ++it ) { + profilenr = atol( (*it).mid( 8 ).latin1() ); + // read the interface store int 'up' + F->setName( D.path() + "/" + (*it) ); + if( F->open( IO_ReadOnly ) ) { + NodeCollection * NC; + interfacename = TS.readLine(); + F->close(); + + Log(( "Assign interface %s to Profile nr %d\n", + interfacename.latin1(), profilenr )); + + NC = NSResources->getConnection( profilenr ); + if( NC ) { + NC->assignInterface( + NSResources->system().findInterface( interfacename ) ); + } else { + Log(( "Profile nr %d no longer defined\n", + profilenr )); + } + } + } + } } @@ -45,4 +84,6 @@ void NetworkSettingsData::loadSettings( void ) { QTextStream TS( &F ); + ForceModified = 0; + do { @@ -86,9 +127,7 @@ void NetworkSettingsData::loadSettings( void ) { // try to find netnode NN = NSResources->findNetNode( S ); - Log( ( "Node %s : %p\n", S.latin1(), NN ) ); } else { // try to find instance NNI = NSResources->createNodeInstance( S ); - Log( ( "NodeInstance %s : %p\n", S.latin1(), NNI )); } @@ -139,7 +178,11 @@ void NetworkSettingsData::loadSettings( void ) { if( NNI ) { // loading from file -> exists + Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI )); NNI->setNew( FALSE ); NSResources->addNodeInstance( NNI ); } + if( NN ) { + Log( ( "Node %s : %p\n", NN->name(), NN ) ); + } } } @@ -221,5 +264,11 @@ QString NetworkSettingsData::saveSettings( void ) { // - setModified( 0 ); + + for( QDictIterator<NodeCollection> it(NSResources->connections()); + it.current(); + ++it ) { + it.current()->setModified( 0 ); + } + return ErrS; } @@ -232,6 +281,5 @@ QString NetworkSettingsData::generateSettings( void ) { ANetNodeInstance * NNI; ANetNodeInstance * FirstWithData; - SystemFile * SF; - AsDevice * CurDev; + RuntimeInfo * CurDev; ANetNode * NN, * CurDevNN = 0; long NoOfDevs; @@ -242,37 +290,95 @@ QString NetworkSettingsData::generateSettings( void ) { Log( ( "Generating settings from %s\n", CfgFile.latin1() )); - // - // generate files proper to each netnodeinstance - // - { Name2Instance_t & NNIs = NSResources->netNodeInstances(); - - for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); - NNIIt.current(); - ++NNIIt ) { - // for all nodes find those that are modified - NNI = NNIIt.current(); - - { // get list of proper files for this nodeclass (if any) - QStringList * PF = NNI->nodeClass()->properFiles(); - - if( PF ) { - for ( QStringList::Iterator it = PF->begin(); - it != PF->end(); - ++it ) { - QFile * F = NNI->openFile( (*it) ); - if( F ) { - QTextStream TS( F ); - if( NNI->generateFile( (*it), F->name(), TS, -1 ) == 2 ) { - // problem generating + for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); + nnit.current(); + ++nnit ) { + { QStringList SL; + bool FirstItem = 1; + bool Generated = 0; + + CurDevNN = nnit.current()->NetNode; + SL = CurDevNN->properFiles(); + + for ( QStringList::Iterator it = SL.begin(); + it != SL.end(); + ++it ) { + + Generated = 0; + FirstItem = 1; + // iterate over NNI's of this class + for( QDictIterator<ANetNodeInstance> nniit( + NSResources->netNodeInstances() ); + nniit.current(); + ++nniit ) { + if( nniit.current()->nodeClass() != CurDevNN ) + // different class + continue; + + // open proper file + { SystemFile SF( (*it) ); + + if( ! CurDevNN->openFile( SF, nniit.current()) ) { + // cannot open + S = qApp->translate( "NetworkSettings", + "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). + arg( (*it) ).arg( CurDevNN->name() ); + return S; + } + + if( ! SF.open() ) { + S = qApp->translate( "NetworkSettings", + "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). + arg( (*it) ).arg( CurDevNN->name() ); + return S; + } + + // preamble on first + if( FirstItem ) { + if( CurDevNN->generatePreamble( SF ) == 2 ) { S = qApp->translate( "NetworkSettings", - "<p>Cannot generate files proper to \"%1\"</p>" ). - arg(NNI->nodeClass()->name()) ; - delete F; + "<p>Error in section \"preamble\" for proper file \"%1\" and node \"%2\"</p>" ). + arg( (*it) ). + arg( CurDevNN->name() ); return S; } - delete F; + } + FirstItem = 0; + Generated = 1; + + // item specific + if( nniit.current()->generateFile( SF, -1 ) == 2 ) { + S = qApp->translate( "NetworkSettings", + "<p>Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"</p>" ). + arg( nniit.current()->name() ). + arg( (*it) ). + arg( CurDevNN->name() ); + return S; } } } + + if( Generated ) { + SystemFile SF( (*it) ); + + if( CurDevNN->openFile( SF, 0 ) && + ! SF.path().isEmpty() + ) { + + if( ! SF.open() ) { + S = qApp->translate( "NetworkSettings", + "<p>Cannot open proper file \"%1\" for node \"%2\"</p>" ). + arg( (*it) ).arg( CurDevNN->name() ); + return S; + } + + if( CurDevNN->generatePostamble( SF ) == 2 ) { + S = qApp->translate( "NetworkSettings", + "<p>Error in section \"postamble\" for proper file \"%1\" and node \"%2\"</p>" ). + arg( (*it) ). + arg( CurDevNN->name() ); + return S; + } + } // no postamble + } } } @@ -280,9 +386,11 @@ QString NetworkSettingsData::generateSettings( void ) { // - // generate all system files + // generate all registered files // for( QDictIterator<SystemFile> sfit(SFM); sfit.current(); ++sfit ) { + SystemFile * SF; + SF = sfit.current(); @@ -307,5 +415,5 @@ QString NetworkSettingsData::generateSettings( void ) { } - Log( ( "Generating %s\n", SF->name().latin1() )); + Log( ( "Generating system file %s\n", SF->name().latin1() )); needToGenerate = 0; @@ -319,5 +427,5 @@ QString NetworkSettingsData::generateSettings( void ) { NN = nnit.current()->NetNode; - if( NN->hasDataForFile( SF->name() ) ) { + if( NN->hasDataForFile( *SF ) ) { // netnode can have data @@ -346,5 +454,10 @@ QString NetworkSettingsData::generateSettings( void ) { // ok generate this system file - SF->open(); + if( ! SF->open() ) { + S = qApp->translate( "NetworkSettings", + "<p>Cannot open system file \"%1\"</p>" ). + arg( SF->name() ); + return S; + } // global presection for this system file @@ -368,5 +481,5 @@ QString NetworkSettingsData::generateSettings( void ) { } - if( ! NC->hasDataForFile( SF->name() ) ) { + if( ! NC->hasDataForFile( *SF ) ) { // no data continue; @@ -376,5 +489,5 @@ QString NetworkSettingsData::generateSettings( void ) { SF->name().latin1(), NC->name().latin1() )); // find highest item that wants to write data to this file - FirstWithData = NC->firstWithDataForFile( SF->name() ); + FirstWithData = NC->firstWithDataForFile( *SF ); // find device on which this connection works @@ -383,8 +496,4 @@ QString NetworkSettingsData::generateSettings( void ) { CurDevNN = CurDev->netNode()->nodeClass(); - Log(( "%s is done %d\n", - FirstWithData->nodeClass()->name(), - FirstWithData->nodeClass()->done() )); - if( ! FirstWithData->nodeClass()->done() ) { // generate fixed part @@ -397,5 +506,7 @@ QString NetworkSettingsData::generateSettings( void ) { if( FirstWithData->nodeClass()->generateFile( - SF->name(), SF->path(), *SF, -1 ) == 2 ) { + *SF, + FirstWithData, + -2 ) == 2 ) { S = qApp->translate( "NetworkSettings", "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ). @@ -405,4 +516,7 @@ QString NetworkSettingsData::generateSettings( void ) { } FirstWithData->nodeClass()->setDone( 1 ); + Log(( "Systemfile %s for node instance %s is done\n", + SF->name().latin1(), + FirstWithData->name() )); } @@ -415,8 +529,4 @@ QString NetworkSettingsData::generateSettings( void ) { } - Log(( "Node %s is done %d\n", - CurDev->netNode()->nodeClass()->name(), - CurDev->netNode()->nodeClass()->done() )); - if( ! CurDev->netNode()->nodeClass()->done() ) { // first time this device is handled @@ -425,5 +535,5 @@ QString NetworkSettingsData::generateSettings( void ) { if( FirstWithData->nodeClass()->generateFile( - SF->name(), SF->path(), *SF, CurDev->netNode(), i ) == 2 ) { + *SF, CurDev->netNode(), i ) == 2 ) { S = qApp->translate( "NetworkSettings", "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ). @@ -434,4 +544,9 @@ QString NetworkSettingsData::generateSettings( void ) { } CurDev->netNode()->nodeClass()->setDone( 1 ); + + Log(( "Systemfile %s for Nodeclass %s is done\n", + SF->name().latin1(), + CurDev->netNode()->nodeClass()->name() + )); } @@ -447,7 +562,9 @@ QString NetworkSettingsData::generateSettings( void ) { } - Log(("Connection %s of same family\n", ncit2.current()->name().latin1() )); + Log(("Connection %s of family %s\n", + ncit2.current()->name().latin1(), + CurDev->name() )); // generate - NNI = ncit2.current()->firstWithDataForFile( SF->name() ); + NNI = ncit2.current()->firstWithDataForFile( *SF ); for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { if( ! SF->preNodeSection( NNI, i ) ) { @@ -459,6 +576,5 @@ QString NetworkSettingsData::generateSettings( void ) { } - switch( NNI->generateFile( - SF->name(), SF->path(), *SF, i ) ) { + switch( NNI->generateFile( *SF, i ) ) { case 0 : (*SF) << endl; @@ -570,7 +686,12 @@ bool NetworkSettingsData::canStart( const char * Interface ) { case Off : // try to UP the device - if( ! NC->setState( Activate ) ) { - // cannot bring device Online -> try other alters - break; + { QString S= NC->setState( Activate ); + if( ! S.isEmpty() ) { + // could not bring device Online -> try other alters + Log(( "%s-c%d-disallowed : %s\n", + Interface, NC->number(), S.latin1() )); + break; + } + // interface assigned } // FT @@ -590,13 +711,14 @@ bool NetworkSettingsData::canStart( const char * Interface ) { } -/* - Called by the system to regenerate config files -*/ - -bool NetworkSettingsData::regenerate( void ) { - QString S = generateSettings(); - if( ! S.isEmpty() ) { - fprintf( stdout, "%s\n", S.latin1() ); +bool NetworkSettingsData::isModified( void ) { + if( ForceModified ) return 1; + + for( QDictIterator<NodeCollection> it(NSResources->connections()); + it.current(); + ++it ) { + if( it.current()->isModified() ) { + return 1; + } } return 0; diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h index 507185e..a0ae7d1 100644 --- a/noncore/settings/networksettings2/nsdata.h +++ b/noncore/settings/networksettings2/nsdata.h @@ -2,5 +2,5 @@ #define __NSDATA_H -#include "netnode.h" +#include <netnode.h> class NetworkSettingsData { @@ -16,21 +16,18 @@ public : QString generateSettings( void ); - bool isModified( void ) - { return IsModified; } - void setModified( bool m ) - { IsModified = m; } + bool isModified( void ); + inline void setModified( bool M ) + { ForceModified = M; } QList<NodeCollection> collectPossible( const char * Interface ); // return TRUE if we need gui to decide bool canStart( const char * Interface ); - bool regenerate( void ); private : - bool IsModified; + bool ForceModified; // collect strings in config file nobody wants QStringList LeftOvers; - }; diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp index 450d560..9403694 100644 --- a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp +++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp @@ -38,5 +38,5 @@ QString PPPAuthEdit::acceptable( void ) { } -bool PPPAuthEdit::commit( PPPData_t & D ) { +bool PPPAuthEdit::commit( PPPData & D ) { bool SM = 0; @@ -71,5 +71,5 @@ bool PPPAuthEdit::commit( PPPData_t & D ) { } -void PPPAuthEdit::showData( PPPData_t & D ) { +void PPPAuthEdit::showData( PPPData & D ) { switch( D.Auth.Mode ) { diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.h b/noncore/settings/networksettings2/ppp/PPPAuthedit.h index 2392569..7a06657 100644 --- a/noncore/settings/networksettings2/ppp/PPPAuthedit.h +++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.h @@ -8,6 +8,6 @@ public : PPPAuthEdit( QWidget * parent ); QString acceptable( void ); - bool commit( PPPData_t & Data ); - void showData( PPPData_t & Data ); + bool commit( PPPData & Data ); + void showData( PPPData & Data ); bool PAP_Checked( void ); diff --git a/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp b/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp index 22f8e59..270f695 100644 --- a/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp +++ b/noncore/settings/networksettings2/ppp/PPPDNSedit.cpp @@ -24,5 +24,5 @@ QString PPPDNSEdit::acceptable( void ) { } -bool PPPDNSEdit::commit( PPPData_t & D ) { +bool PPPDNSEdit::commit( PPPData & D ) { bool SM = 0; @@ -76,5 +76,5 @@ bool PPPDNSEdit::commit( PPPData_t & D ) { } -void PPPDNSEdit::showData( PPPData_t & D) { +void PPPDNSEdit::showData( PPPData & D) { DNSServerAssigned_RB->setChecked( D.DNS.ServerAssigned ); diff --git a/noncore/settings/networksettings2/ppp/PPPDNSedit.h b/noncore/settings/networksettings2/ppp/PPPDNSedit.h index 43e0067..1ca8c21 100644 --- a/noncore/settings/networksettings2/ppp/PPPDNSedit.h +++ b/noncore/settings/networksettings2/ppp/PPPDNSedit.h @@ -8,6 +8,6 @@ public : PPPDNSEdit( QWidget * parent ); QString acceptable( void ); - bool commit( PPPData_t & Data ); - void showData( PPPData_t & Data ); + bool commit( PPPData & Data ); + void showData( PPPData & Data ); public slots : diff --git a/noncore/settings/networksettings2/ppp/PPPGUI.ui b/noncore/settings/networksettings2/ppp/PPPGUI.ui index 777e4a9..4c79fe3 100644 --- a/noncore/settings/networksettings2/ppp/PPPGUI.ui +++ b/noncore/settings/networksettings2/ppp/PPPGUI.ui @@ -12,6 +12,6 @@ <x>0</x> <y>0</y> - <width>124</width> - <height>29</height> + <width>528</width> + <height>345</height> </rect> </property> @@ -29,5 +29,5 @@ <property stdset="1"> <name>margin</name> - <number>2</number> + <number>0</number> </property> <property stdset="1"> @@ -55,4 +55,16 @@ </property> </item> + <item> + <property> + <name>text</name> + <string>Commands</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Dialing</string> + </property> + </item> <property stdset="1"> <name>name</name> @@ -77,5 +89,5 @@ <height>-1</height> </sizehint> - <container>0</container> + <container>1</container> <sizepolicy> <hordata>7</hordata> diff --git a/noncore/settings/networksettings2/ppp/PPPIPGUI.ui b/noncore/settings/networksettings2/ppp/PPPIPGUI.ui index f3d5019..21bd29e 100644 --- a/noncore/settings/networksettings2/ppp/PPPIPGUI.ui +++ b/noncore/settings/networksettings2/ppp/PPPIPGUI.ui @@ -12,6 +12,6 @@ <x>0</x> <y>0</y> - <width>133</width> - <height>235</height> + <width>258</width> + <height>232</height> </rect> </property> @@ -29,19 +29,15 @@ <property stdset="1"> <name>margin</name> - <number>3</number> + <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>2</number> + <number>1</number> </property> <widget> - <class>QButtonGroup</class> + <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>ButtonGroup4</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Box</enum> + <cstring>GroupBox1</cstring> </property> <property stdset="1"> @@ -55,8 +51,8 @@ <name>layoutSpacing</name> </property> - <vbox> + <grid> <property stdset="1"> <name>margin</name> - <number>2</number> + <number>3</number> </property> <property stdset="1"> @@ -64,153 +60,79 @@ <number>2</number> </property> - <widget> - <class>QRadioButton</class> + <widget row="0" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>IPServerAssigned_RB</cstring> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>true</bool> </property> <property stdset="1"> <name>text</name> - <string>Server assigned</string> + <string>Local</string> </property> + </widget> + <widget row="0" column="1" > + <class>QLineEdit</class> <property stdset="1"> - <name>checked</name> + <name>name</name> + <cstring>LocalAddress_LE</cstring> + </property> + <property stdset="1"> + <name>enabled</name> <bool>true</bool> </property> </widget> - <widget> - <class>QRadioButton</class> + <widget row="0" column="2" > + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>IPFixed_RB</cstring> + <cstring>ServerOverrulesLocal_CB</cstring> </property> <property stdset="1"> <name>text</name> - <string>Fixed</string> + <string>Server Overrules</string> </property> </widget> - <widget> - <class>QLayoutWidget</class> + <widget row="1" column="1" > + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>Layout11</cstring> + <cstring>RemoteAddress_LE</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>true</bool> </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>Spacer8</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>20</width> - <height>20</height> - </size> - </property> - <property> - <name>layoutMargin</name> - </property> - <property> - <name>layoutSpacing</name> - </property> - </spacer> - <widget> - <class>QFrame</class> - <property stdset="1"> - <name>name</name> - <cstring>Frame8</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</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>2</number> - </property> - <widget row="0" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>IPAddress_LE</cstring> - </property> - </widget> - <widget row="1" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Subnetmask</string> - </property> - </widget> - <widget row="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Address</string> - </property> - </widget> - <widget row="1" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>IPSubMask_LE</cstring> - </property> - </widget> - </grid> - </widget> - </hbox> </widget> - </vbox> + <widget row="1" column="2" > + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>ServerOverrulesRemote_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Server Overrules</string> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1_2</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>text</name> + <string>Remote</string> + </property> + </widget> + </grid> </widget> <widget> @@ -221,4 +143,11 @@ </property> <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> <name>title</name> <string>Gateway</string> @@ -233,5 +162,5 @@ <property stdset="1"> <name>margin</name> - <number>2</number> + <number>3</number> </property> <property stdset="1"> @@ -379,5 +308,5 @@ <property stdset="1"> <name>name</name> - <cstring>Layout3</cstring> + <cstring>Layout4</cstring> </property> <hbox> @@ -390,4 +319,15 @@ <number>6</number> </property> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>GWIsDefault_CB</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Set as default</string> + </property> + </widget> <spacer> <property> @@ -415,9 +355,9 @@ <property stdset="1"> <name>name</name> - <cstring>GWIsDefault_CB</cstring> + <cstring>GWIfNotSet_CB</cstring> </property> <property stdset="1"> <name>text</name> - <string>Set as default</string> + <string>Only if not yet set</string> </property> </widget> @@ -426,4 +366,25 @@ </vbox> </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer4</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> </vbox> </widget> @@ -435,10 +396,4 @@ <slot>setEnabled(bool)</slot> </connection> - <connection> - <sender>IPFixed_RB</sender> - <signal>toggled(bool)</signal> - <receiver>Frame8</receiver> - <slot>setEnabled(bool)</slot> - </connection> </connections> </UI> diff --git a/noncore/settings/networksettings2/ppp/PPPIPedit.cpp b/noncore/settings/networksettings2/ppp/PPPIPedit.cpp index 6965e5a..ef1b7c0 100644 --- a/noncore/settings/networksettings2/ppp/PPPIPedit.cpp +++ b/noncore/settings/networksettings2/ppp/PPPIPedit.cpp @@ -10,14 +10,5 @@ PPPIPEdit::PPPIPEdit( QWidget * Parent ) : PPPIPGUI( Parent ){ QString PPPIPEdit::acceptable( void ) { - if( IPFixed_RB->isChecked() ) { - if( IPAddress_LE->text().isEmpty() ) - return tr("IPAddress needed" ); - if( ! validIP( IPAddress_LE->text() ) ) - return tr("IPAddress not valid" ); - if( IPSubMask_LE->text().isEmpty() ) - return tr("Subnet mask needed" ); - if( ! validIP( IPSubMask_LE->text() ) ) - return tr("Subnet mask not valid" ); - } else if( GWFixed_RB->isChecked() ) { + if( GWFixed_RB->isChecked() ) { if( GWAddress_LE->text().isEmpty() ) return tr("Gateway address needed" ); @@ -29,15 +20,16 @@ QString PPPIPEdit::acceptable( void ) { } -bool PPPIPEdit::commit( PPPData_t & D ) { +bool PPPIPEdit::commit( PPPData & D ) { bool SM = 0; - CBM( D.IP.IPAutomatic, IPServerAssigned_RB, SM ); - if( ! D.IP.IPAutomatic ) { - TXTM( D.IP.IPAddress, IPAddress_LE, SM ); - TXTM( D.IP.IPSubMask, IPSubMask_LE, SM ); - } + CBM( D.IP.LocalOverrule, ServerOverrulesLocal_CB, SM ); + CBM( D.IP.RemoteOverrule, ServerOverrulesRemote_CB, SM ); + + TXTM( D.IP.LocalAddress, LocalAddress_LE, SM ); + TXTM( D.IP.RemoteAddress, RemoteAddress_LE, SM ); CBM( D.IP.GWAutomatic, GWServerAssigned_RB, SM ); + if( ! D.IP.GWAutomatic ) { TXTM( D.IP.GWAddress, GWAddress_LE, SM ); @@ -45,13 +37,18 @@ bool PPPIPEdit::commit( PPPData_t & D ) { CBM( D.IP.GWIsDefault, GWIsDefault_CB, SM ); + CBM( D.IP.GWIfNotSet, GWIfNotSet_CB, SM ); + return SM; } -void PPPIPEdit::showData( PPPData_t & D ) { - IPServerAssigned_RB->setChecked( D.IP.IPAutomatic ); - IPAddress_LE->setText( D.IP.IPAddress ); - IPSubMask_LE->setText( D.IP.IPSubMask ); +void PPPIPEdit::showData( PPPData & D ) { + ServerOverrulesLocal_CB->setChecked( D.IP.LocalOverrule ); + ServerOverrulesRemote_CB->setChecked( D.IP.RemoteOverrule ); + LocalAddress_LE->setText( D.IP.LocalAddress ); + RemoteAddress_LE->setText( D.IP.RemoteAddress ); + GWServerAssigned_RB->setChecked( D.IP.GWAutomatic ); GWAddress_LE->setText( D.IP.GWAddress ); GWIsDefault_CB->setChecked( D.IP.GWIsDefault ); + GWIfNotSet_CB->setChecked( D.IP.GWIfNotSet ); } diff --git a/noncore/settings/networksettings2/ppp/PPPIPedit.h b/noncore/settings/networksettings2/ppp/PPPIPedit.h index 153ee68..5ca4326 100644 --- a/noncore/settings/networksettings2/ppp/PPPIPedit.h +++ b/noncore/settings/networksettings2/ppp/PPPIPedit.h @@ -8,6 +8,6 @@ public : PPPIPEdit( QWidget * parent ); QString acceptable( void ); - bool commit( PPPData_t & Data ); - void showData( PPPData_t & Data ); + bool commit( PPPData & Data ); + void showData( PPPData & Data ); private : diff --git a/noncore/settings/networksettings2/ppp/PPPedit.cpp b/noncore/settings/networksettings2/ppp/PPPedit.cpp index eb4fdbf..17889aa 100644 --- a/noncore/settings/networksettings2/ppp/PPPedit.cpp +++ b/noncore/settings/networksettings2/ppp/PPPedit.cpp @@ -4,4 +4,6 @@ #include "PPPDNSedit.h" #include "PPPAuthedit.h" +#include "PPPRunedit.h" +#include "PPPDialingedit.h" #include "PPPedit.h" @@ -11,7 +13,12 @@ PPPEdit::PPPEdit( QWidget * Parent ) : PPPGUI( Parent ){ IP = new PPPIPEdit( Options_WS ); DNS = new PPPDNSEdit( Options_WS ); + Run = new PPPRunEdit( Options_WS ); + Dialing = new PPPDialingEdit( Options_WS ); + Options_WS->addWidget( Auth, 0 ); Options_WS->addWidget( IP, 1 ); Options_WS->addWidget( DNS, 2 ); + Options_WS->addWidget( Run, 3 ); + Options_WS->addWidget( Dialing, 4 ); Options_WS->raiseWidget( 0 ); @@ -30,5 +37,5 @@ QString PPPEdit::acceptable( void ) { } -bool PPPEdit::commit( PPPData_t & Data ) { +bool PPPEdit::commit( PPPData & Data ) { bool SM ; SM = Auth->commit( Data ); @@ -38,5 +45,5 @@ bool PPPEdit::commit( PPPData_t & Data ) { } -void PPPEdit::showData( PPPData_t & Data ) { +void PPPEdit::showData( PPPData & Data ) { Auth->showData( Data ) ; IP->showData( Data ); diff --git a/noncore/settings/networksettings2/ppp/PPPedit.h b/noncore/settings/networksettings2/ppp/PPPedit.h index 57d38ee..f674b17 100644 --- a/noncore/settings/networksettings2/ppp/PPPedit.h +++ b/noncore/settings/networksettings2/ppp/PPPedit.h @@ -5,4 +5,6 @@ class PPPAuthEdit; class PPPIPEdit; class PPPDNSEdit; +class PPPRunEdit; +class PPPDialingEdit; class PPPEdit : public PPPGUI { @@ -12,6 +14,6 @@ public : PPPEdit( QWidget * parent ); QString acceptable( void ); - bool commit( PPPData_t & Data ); - void showData( PPPData_t & Data ); + bool commit( PPPData & Data ); + void showData( PPPData & Data ); public slots : @@ -21,7 +23,9 @@ public slots : private : - PPPAuthEdit * Auth; - PPPDNSEdit * DNS; - PPPIPEdit * IP; + PPPAuthEdit * Auth; + PPPDNSEdit * DNS; + PPPIPEdit * IP; + PPPRunEdit * Run; + PPPDialingEdit * Dialing; }; diff --git a/noncore/settings/networksettings2/ppp/opie-networksettings2plugin-ppp.control b/noncore/settings/networksettings2/ppp/opie-networksettings2plugin-ppp.control index 7dfde38..19d1c89 100644 --- a/noncore/settings/networksettings2/ppp/opie-networksettings2plugin-ppp.control +++ b/noncore/settings/networksettings2/ppp/opie-networksettings2plugin-ppp.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-ppp +Package: opie-networksettings2plugin-ppp Files: plugins/networksettings2/libppp.so* Priority: optional diff --git a/noncore/settings/networksettings2/ppp/ppp.pro b/noncore/settings/networksettings2/ppp/ppp.pro index f866bee..dd3408c 100644 --- a/noncore/settings/networksettings2/ppp/ppp.pro +++ b/noncore/settings/networksettings2/ppp/ppp.pro @@ -7,4 +7,6 @@ HEADERS = ppp_NN.h \ PPPAuthedit.h \ PPPDNSedit.h \ + PPPRunedit.h \ + PPPDialingedit.h \ PPPIPedit.h SOURCES = ppp_NN.cpp \ @@ -12,4 +14,6 @@ SOURCES = ppp_NN.cpp \ PPPedit.cpp \ PPPDNSedit.cpp \ + PPPRunedit.cpp \ + PPPDialingedit.cpp \ PPPAuthedit.cpp \ ppprun.cpp \ @@ -18,5 +22,10 @@ INCLUDEPATH += $(OPIEDIR)/include ../ ../networksettings2 DEPENDPATH += $(OPIEDIR)/include ../ ../networksettings2 LIBS += -lqpe -INTERFACES = PPPGUI.ui PPPAuthGUI.ui PPPIPGUI.ui PPPDNSGUI.ui +INTERFACES = PPPGUI.ui \ + PPPAuthGUI.ui \ + PPPIPGUI.ui \ + PPPDNSGUI.ui \ + PPPDialingGUI.ui \ + PPPRunGUI.ui TARGET = ppp VERSION = 1.0.0 diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp index ff4465c..51ba27d 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp @@ -1,3 +1,4 @@ #include <qfile.h> +#include <resources.h> #include <qtextstream.h> #include "ppp_NN.h" @@ -7,6 +8,10 @@ QStringList * PPPNetNode::ProperFiles = 0; static const char * PPPNeeds[] = - { "line", - "modem", + { "modem", + 0 + }; + +static const char * PPPProvides[] = + { "connection", 0 }; @@ -17,14 +22,8 @@ static const char * PPPNeeds[] = PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) { - // proper files : will leak - ProperFiles =new QStringList; - *ProperFiles << "peers"; - *ProperFiles << "chatscript"; - - // system files NSResources->addSystemFile( - "pap-secrets", "/tmp/pap-secrets", 0 ); + "pap-secrets", "/etc/ppp/pap-secrets", 0 ); NSResources->addSystemFile( - "chap-secrets", "/tmp/chap-secrets", 0 ); + "chap-secrets", "/etc/ppp/chap-secrets", 0 ); } @@ -51,11 +50,12 @@ const char ** PPPNetNode::needs( void ) { } -const char * PPPNetNode::provides( void ) { - return "connection"; +const char ** PPPNetNode::provides( void ) { + return PPPProvides; } -QStringList * PPPNetNode::properFiles( void ) { - return ProperFiles; - +QStringList PPPNetNode::properFiles( void ) { + QStringList SL; + SL << "peers" << "chatscripts"; + return SL; } @@ -63,7 +63,7 @@ QStringList * PPPNetNode::properFiles( void ) { // /etc/ppp/pap-secrets // /etc/ppp/pap-secrets -bool PPPNetNode::hasDataForFile( const QString & S ) { - return S == "pap-secrets" || - S == "chap-secrets" ; +bool PPPNetNode::hasDataForFile( SystemFile & S ) { + return S.name() == "pap-secrets" || + S.name() == "chap-secrets" ; } diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h index 249be5a..3ead10e 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.h +++ b/noncore/settings/networksettings2/ppp/ppp_NN.h @@ -18,13 +18,13 @@ public: { return "Devices/ppp"; } - virtual bool hasDataForFile( const QString & S ); + virtual bool hasDataForFile( SystemFile & S ); virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); virtual QString genNic( long NicNr ); - virtual QStringList * properFiles( void ); + virtual QStringList properFiles( void ); private: diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp index ba639de..9e3bb64 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp @@ -17,10 +17,19 @@ APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) { Data.Auth.Secret = ""; - Data.IP.IPAutomatic = 1; - Data.IP.IPAddress = ""; - Data.IP.IPSubMask = ""; + Data.IP.LocalAddress = "10.0.0.1"; + Data.IP.RemoteAddress = "10.0.0.2"; + Data.IP.LocalOverrule = 1; + Data.IP.RemoteOverrule = 1; + Data.IP.GWAutomatic = 1; Data.IP.GWAddress = ""; Data.IP.GWIsDefault = 1; + Data.IP.GWIfNotSet = 1; + + Data.Run.PreConnect = ""; + Data.Run.PostConnect = ""; + Data.Run.PreDisconnect = ""; + Data.Run.PostDisconnect = ""; + GUI = 0; RT = 0; @@ -60,17 +69,31 @@ void APPP::setSpecificAttribute( QString & A, QString & V ) { } } else if( A.startsWith( "ip" ) ) { - if( A == "ipautomatic" ) { - Data.IP.IPAutomatic = (V == "yes"); - } else if( A == "gwautomatic" ) { + if( A == "iplocaloverrule" ) { + Data.IP.LocalOverrule = (V == "yes"); + } else if( A == "ipremoteoverrule" ) { + Data.IP.RemoteOverrule = (V == "yes"); + } else if( A == "ipgwautomatic" ) { Data.IP.GWAutomatic = (V == "yes"); - } else if( A == "gwisdefault" ) { + } else if( A == "ipgwisdefault" ) { Data.IP.GWIsDefault = (V == "yes"); - } else if( A == "ipaddress" ) { - Data.IP.IPAddress = V; - } else if( A == "ipsubmask" ) { - Data.IP.IPSubMask = V; - } else if( A == "gwaddress" ) { + } else if( A == "ipgwifnotset" ) { + Data.IP.GWIfNotSet = (V == "yes"); + } else if( A == "iplocaladdress" ) { + Data.IP.LocalAddress = V; + } else if( A == "ipremoteaddress" ) { + Data.IP.RemoteAddress = V; + } else if( A == "ipgwaddress" ) { Data.IP.GWAddress = V; } + } else if( A.startsWith( "run" ) ) { + if( A == "runpreconnect" ) { + Data.Run.PreConnect = V; + } else if( A == "runpostconnect" ) { + Data.Run.PostConnect = V; + } else if( A == "runpredisconnect" ) { + Data.Run.PreDisconnect = V; + } else if( A == "runpostdisconnect" ) { + Data.Run.PostDisconnect = V; + } } } @@ -92,10 +115,18 @@ void APPP::saveSpecificAttribute( QTextStream & TS ) { TS << "authserver=" << Data.Auth.Server << endl; TS << "authsecret=" << quote( Data.Auth.Secret ) << endl; - TS << "ipautomatic=" << ( ( Data.IP.IPAutomatic ) ? "yes" : "no" ) << endl; - TS << "gwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; - TS << "gwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; - TS << "ipaddress=" << Data.IP.IPAddress << endl; - TS << "ipsubmask=" << Data.IP.IPSubMask << endl; - TS << "gwaddress=" << Data.IP.GWAddress << endl; + TS << "ipgwautomatic=" << ( ( Data.IP.GWAutomatic ) ? "yes" : "no" ) << endl; + TS << "ipgwisdefault=" << ( ( Data.IP.GWIsDefault ) ? "yes" : "no" ) << endl; + TS << "ipgwifnotset=" << ( ( Data.IP.GWIfNotSet ) ? "yes" : "no" ) << endl; + TS << "iplocaloverrule=" << ( ( Data.IP.LocalOverrule ) ? "yes" : "no" ) << endl; + TS << "ipremoteoverrule=" << ( ( Data.IP.RemoteOverrule ) ? "yes" : "no" ) << endl; + TS << "iplocaladdress=" << Data.IP.LocalAddress << endl; + TS << "ipremoteaddress=" << Data.IP.RemoteAddress << endl; + TS << "ipgwaddress=" << Data.IP.GWAddress << endl; + + TS << "runpreconnect=" << Data.Run.PreConnect << endl; + TS << "runpostconnect=" << Data.Run.PostConnect << endl; + TS << "runpredisconnect=" << Data.Run.PreDisconnect << endl; + TS << "runpostdisconnect=" << Data.Run.PostDisconnect << endl; + } @@ -116,37 +147,18 @@ void APPP::commit( void ) { } -QFile * APPP::openFile( const QString & ID ) { - QFile * F = 0; - QString S; - - if( ID == "peers" ) { - S = removeSpaces( QString("/tmp/") + connection()->name() ); - - F = new QFile( S ); - - if( ! F->open( IO_WriteOnly ) ) { - Log(("Cannot open file %s\n", S.latin1() )); - return 0; - } - } else if ( ID == "chatscripts" ) { - S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" ); - F = new QFile( S ); - - if( ! F->open( IO_WriteOnly ) ) { - Log(("Cannot open file %s\n", S.latin1() )); - return 0; - } +bool APPP::openFile( SystemFile & SF ) { + if( SF.name() == "peers" ) { + SF.setPath( removeSpaces( + QString( "/tmp/ppp/peers/" ) + connection()->name() ) ); + return 1; + } else if ( SF.name() == "chatscripts" ) { + SF.setPath( removeSpaces( + QString( "/tmp/chatscripts/" ) + connection()->name() ) ); + return 1; } - if( F ) { - Log(("Generate proper file %s = %s\n", - ID.latin1(), F->name().latin1())); - } - return F; + return 0; } -short APPP::generateFile( const QString & ID, - const QString & Path, - QTextStream & TS, - long DevNr ) { +short APPP::generateFile( SystemFile & SF, long DevNr ) { short rvl, rvd; @@ -154,11 +166,12 @@ short APPP::generateFile( const QString & ID, rvd = 1; - if( ID == "pap-secrets" ) { - Log(("Generate PPP for %s\n", ID.latin1() )); + if( SF.name() == "pap-secrets" ) { + Log(("Generate PPP for %s\n", SF.name().latin1() )); + if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) { - TS << "# secrets for " + SF << "# secrets for " << connection()->name().latin1() << endl; - TS << Data.Auth.Client + SF << Data.Auth.Client << " " << Data.Auth.Server @@ -168,14 +181,14 @@ short APPP::generateFile( const QString & ID, rvl = 0; rvd = connection()->getToplevel()->generateFileEmbedded( - ID, Path, TS, DevNr ); + SF, DevNr ); } - } else if( ID == "chap-secrets" ) { - Log(("Generate PPP for %s\n", ID.latin1() )); + } else if( SF.name() == "chap-secrets" ) { + Log(("Generate PPP for %s\n", SF.name().latin1() )); if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) { // used for both EAP and Chap - TS << "# secrets for " + SF << "# secrets for " << connection()->name().latin1() << endl; - TS << Data.Auth.Client + SF << Data.Auth.Client << " " << Data.Auth.Server @@ -186,22 +199,23 @@ short APPP::generateFile( const QString & ID, rvl = 0; rvd = connection()->getToplevel()->generateFileEmbedded( - ID, Path, TS, DevNr ); + SF, DevNr ); } - } else if ( ID == "peers" ) { - QFileInfo FI(Path); - Log(("Generate PPP for %s\n", ID.latin1() )); + } else if ( SF.name() == "peers" ) { + + QFileInfo FI(SF.path()); + Log(("Generate PPP for %s\n", SF.name().latin1() )); - TS << "connect \"/usr/sbin/chat -v -f /etc/ppp/" + SF << "connect \"/usr/sbin/chat -v -f /etc/chatscripts/" << FI.baseName() - << ".chat\"" + << "\"" << endl; if( Data.IP.GWIsDefault ) { - TS << "defaultroute" + SF << "defaultroute" << endl; } - TS << "linkname " - << removeSpaces( ID.latin1() ) + SF << "linkname " + << removeSpaces( SF.name().latin1() ) << endl; @@ -209,10 +223,10 @@ short APPP::generateFile( const QString & ID, rvl = 0; rvd = connection()->getToplevel()->generateFileEmbedded( - ID, Path, TS, DevNr ); - } else if ( ID == "chatscripts" ) { - Log(("Generate PPP for %s\n", ID.latin1() )); + SF, DevNr ); + } else if ( SF.name() == "chatscripts" ) { + Log(("Generate PPP for %s\n", SF.name().latin1() )); rvl = 0; rvd = connection()->getToplevel()->generateFileEmbedded( - ID, Path, TS, DevNr ); + SF, DevNr ); } diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h index 0bf8fa9..76afb21 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NNI.h +++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h @@ -17,9 +17,5 @@ public : RuntimeInfo * runtime( void ) - { if( RT == 0 ) { - RT = new PPPRun( this, Data ); - } - return RT->runtimeInfo(); - } + { return (RT) ? RT : (RT = new PPPRun( this, Data ) ); } QWidget * edit( QWidget * parent ); @@ -30,8 +26,6 @@ public : { return (void *)&Data; } - virtual QFile * openFile( const QString & ID ); - short generateFile( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual bool openFile( SystemFile & Sf ); + short generateFile( SystemFile & TS, long DevNr ); diff --git a/noncore/settings/networksettings2/ppp/pppdata.h b/noncore/settings/networksettings2/ppp/pppdata.h index 9e8543c..68666f8 100644 --- a/noncore/settings/networksettings2/ppp/pppdata.h +++ b/noncore/settings/networksettings2/ppp/pppdata.h @@ -5,13 +5,19 @@ #include <qarray.h> -typedef struct PPPData { +class PPPData { + +public : + struct { - bool IPAutomatic; - QString IPAddress; - QString IPSubMask; + bool LocalOverrule; + bool RemoteOverrule; + QString LocalAddress; + QString RemoteAddress; bool GWAutomatic; QString GWAddress; bool GWIsDefault; + bool GWIfNotSet; } IP; + struct { short Mode; // 0 login, 1 chap/pap, 2 Terminal @@ -34,5 +40,11 @@ typedef struct PPPData { QArray<QString *> Servers; } DNS; -} PPPData_t; + struct { + QString PreConnect; + QString PostConnect; + QString PreDisconnect; + QString PostDisconnect; + } Run; +}; #endif diff --git a/noncore/settings/networksettings2/ppp/ppprun.cpp b/noncore/settings/networksettings2/ppp/ppprun.cpp index a8abc50..8403e6d 100644 --- a/noncore/settings/networksettings2/ppp/ppprun.cpp +++ b/noncore/settings/networksettings2/ppp/ppprun.cpp @@ -3,51 +3,17 @@ PPPRun::PPPRun( ANetNodeInstance * NNI, PPPData & Data ) : - AsConnection( NNI ), AsDevice( NNI ), Pat( "eth[0-9]" ) { - D = &Data; + RuntimeInfo( NNI ), Pat( "eth[0-9]" ) { + D = &Data; } -void PPPRun::detectState( NodeCollection * NC ) { +State_t PPPRun::detectState( void ) { if( isMyPPPDRunning( ) ) { - if( isMyPPPUp() ) { - NC->setCurrentState( IsUp ); - } else { - NC->setCurrentState( Available ); - } - } else { - NC->setCurrentState( Off ); // at least this - // but could also be unavailable - AsDevice::netNode()->nextNode()->runtime()->detectState( NC ); - } + return ( isMyPPPUp() ) ? IsUp : Available; + } + return Off; } -bool PPPRun::setState( NodeCollection * NC, Action_t A, bool ) { - switch( A ) { - case Activate : - NC->setCurrentState( Available ); - // no - break; - case Deactivate : - if( NC->currentState() == IsUp ) { - NC->state( Down ); - } - // cannot really disable - NC->setCurrentState( Available ); - break; - case Up : - if( NC->currentState() != IsUp ) { - // start my PPPD - NC->setCurrentState( IsUp ); - } - break; - case Down : - if( NC->currentState() == IsUp ) { - // stop my PPPD - NC->setCurrentState( Available ); - } - break; - default : // FT - break; - } - return 1; +QString PPPRun::setMyState( NodeCollection * NC, Action_t A, bool ) { + return QString(); } @@ -69,5 +35,5 @@ bool PPPRun::isMyPPPUp( void ) { ) { // this is a LAN card - if( Run->assignedNode() == AsDevice::netNode() ) { + if( Run->assignedConnection() == netNode()->connection() ) { // assigned to us return 1; @@ -81,2 +47,6 @@ bool PPPRun::handlesInterface( const QString & S ) { return Pat.match( S ) >= 0; } + +bool PPPRun::handlesInterface( InterfaceInfo * I ) { + return handlesInterface( I->Name ); +} diff --git a/noncore/settings/networksettings2/ppp/ppprun.h b/noncore/settings/networksettings2/ppp/ppprun.h index 90a3f25..2990a96 100644 --- a/noncore/settings/networksettings2/ppp/ppprun.h +++ b/noncore/settings/networksettings2/ppp/ppprun.h @@ -3,9 +3,8 @@ #include <qregexp.h> -#include <asconnection.h> -#include <asdevice.h> +#include <netnode.h> #include "pppdata.h" -class PPPRun : public AsConnection, public AsDevice { +class PPPRun : public RuntimeInfo { public : @@ -14,24 +13,16 @@ public : PPPData & Data ); - virtual AsDevice * asDevice( void ) - { return (AsDevice *)this; } - virtual AsConnection * asConnection( void ) - { return (AsConnection *)this; } - - virtual AsDevice * device( void ) - { return (AsDevice *)this; } + bool handlesInterface( const QString & I ); + bool handlesInterface( InterfaceInfo * ); - virtual RuntimeInfo * runtimeInfo( void ) - { return ( AsConnection *)this; } + State_t detectState( void ); + virtual RuntimeInfo * device( void ) + { return this; } + virtual RuntimeInfo * connection( void ) + { return this; } - protected : +protected : - void detectState( NodeCollection * NC ); - bool setState( NodeCollection * NC, Action_t A, bool ); - bool canSetState( State_t S, Action_t A ) - { return AsDevice::connection()->findNext( - AsDevice::netNode() )->runtime()->canSetState( S,A ); } - - bool handlesInterface( const QString & I ); + QString setMyState( NodeCollection * , Action_t, bool ); private : @@ -40,7 +31,6 @@ private : bool isMyPPPUp( void ); - PPPData_t * D; + PPPData * D; QRegExp Pat; - }; diff --git a/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control b/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control index c76f9b8..40c8b48 100644 --- a/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control +++ b/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-profile +Package: opie-networksettings2plugin-profile Files: plugins/networksettings2/libprofile.so* Priority: optional @@ -6,4 +6,4 @@ Maintainer: Wim Delvaux <wimpie@handhelds.org> Architecture: arm Depends: opie-networksettings2, libopiecore2, libopienet2 -Description: Network settings profile plugin. +Description: Network settings usage profile plugin. Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp index 945b48d..b7d8aa0 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.cpp +++ b/noncore/settings/networksettings2/profile/profile_NN.cpp @@ -1,2 +1,3 @@ +#include <resources.h> #include "profile_NN.h" #include "profile_NNI.h" @@ -6,4 +7,8 @@ static const char * ProfileNeeds[] = 0 }; +static const char * ProfileProvides[] = + { "fullsetup", + 0 + }; /** @@ -11,4 +16,8 @@ static const char * ProfileNeeds[] = */ ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) { + + NSResources->addSystemFile( + "interfaces", "/etc/network/interfaces", 1 ); + } @@ -35,6 +44,6 @@ const char ** ProfileNetNode::needs( void ) { } -const char * ProfileNetNode::provides( void ) { - return "fullsetup"; +const char ** ProfileNetNode::provides( void ) { + return ProfileProvides; } diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h index 1f1ee2c..f1648f9 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.h +++ b/noncore/settings/networksettings2/profile/profile_NN.h @@ -21,5 +21,5 @@ public: virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); private: diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp index f0f0b97..a1e1254 100644 --- a/noncore/settings/networksettings2/profile/profile_NNI.cpp +++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp @@ -1,2 +1,3 @@ +#include <opie2/odebug.h> #include "profileedit.h" #include "profile_NNI.h" @@ -51,7 +52,5 @@ void AProfile::commit( void ) { } -short AProfile::generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, +short AProfile::generateFileEmbedded( SystemFile & SF, long DevNr ) { @@ -60,14 +59,14 @@ short AProfile::generateFileEmbedded( const QString & ID, rvl = 1; - if( ID == "interfaces" ) { - Log(("Generate Profile for %s\n", ID.latin1() )); + if( SF.name() == "interfaces" ) { + Log(("Generate Profile for %s\n", SF.name().latin1() )); if( Data.TriggerVPN ) { // this profile triggers VPN -> insert trigger - TS << " up networksettings2 --triggervpn" + SF << " up networksettings2 --triggervpn" << endl; rvl = 0; } } - rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); + rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr ); return (rvd == 2 || rvl == 2 ) ? 2 : (rvd == 0 || rvl == 0 ) ? 0 : 1; diff --git a/noncore/settings/networksettings2/profile/profile_NNI.h b/noncore/settings/networksettings2/profile/profile_NNI.h index 957f4af..ccd746c 100644 --- a/noncore/settings/networksettings2/profile/profile_NNI.h +++ b/noncore/settings/networksettings2/profile/profile_NNI.h @@ -27,7 +27,5 @@ public : { return (void *)&Data; } - virtual short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFileEmbedded( SystemFile & TS, long DevNr ); diff --git a/noncore/settings/networksettings2/profile/profiledata.h b/noncore/settings/networksettings2/profile/profiledata.h index 246d50c..c9577e5 100644 --- a/noncore/settings/networksettings2/profile/profiledata.h +++ b/noncore/settings/networksettings2/profile/profiledata.h @@ -3,5 +3,6 @@ #include <qstring.h> -typedef struct ProfileData { +class ProfileData { +public : QString Description; // start up automatically @@ -12,5 +13,5 @@ typedef struct ProfileData { bool Disabled; bool TriggerVPN; -} ProfileData_t; +} ; #endif diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp index 87e503e..88aab15 100644 --- a/noncore/settings/networksettings2/profile/profileedit.cpp +++ b/noncore/settings/networksettings2/profile/profileedit.cpp @@ -6,5 +6,5 @@ #include <GUIUtils.h> -#include <asdevice.h> +#include <netnode.h> #include <resources.h> @@ -17,5 +17,5 @@ ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : NNI = TNNI; Dev = NNI->runtime()->device(); - if( ( II = Dev->assignedInterface() ) ) { + if( ( II = NNI->connection()->assignedInterface() ) ) { Refresh_CB->setEnabled( TRUE ); @@ -56,5 +56,5 @@ QString ProfileEdit::acceptable( void ) { } -void ProfileEdit::showData( ProfileData_t & Data ) { +void ProfileEdit::showData( ProfileData & Data ) { Description_LE->setText( Data.Description ); Automatic_CB->setChecked( Data.Automatic ); @@ -65,5 +65,5 @@ void ProfileEdit::showData( ProfileData_t & Data ) { -bool ProfileEdit::commit( ProfileData_t & Data ) { +bool ProfileEdit::commit( ProfileData & Data ) { bool SM = 0; TXTM( Data.Description, Description_LE, SM ); @@ -78,5 +78,5 @@ bool ProfileEdit::commit( ProfileData_t & Data ) { void ProfileEdit::SLOT_Refresh( void ) { - InterfaceInfo * II = Dev->assignedInterface(); + InterfaceInfo * II = NNI->connection()->assignedInterface(); NSResources->system().refreshStatistics( *II ); RcvBytes_LBL->setText( II->RcvBytes ); diff --git a/noncore/settings/networksettings2/profile/profileedit.h b/noncore/settings/networksettings2/profile/profileedit.h index b186b58..9cde845 100644 --- a/noncore/settings/networksettings2/profile/profileedit.h +++ b/noncore/settings/networksettings2/profile/profileedit.h @@ -4,5 +4,5 @@ #include <qtimer.h> class ANetNodeInstance; -class AsDevice; +class RuntimeInfo; class ProfileEdit : public ProfileGUI { @@ -14,6 +14,6 @@ public : ProfileEdit( QWidget * parent, ANetNodeInstance * NNI ); QString acceptable( void ); - bool commit( ProfileData_t & Data ); - void showData( ProfileData_t & Data ); + bool commit( ProfileData & Data ); + void showData( ProfileData & Data ); public slots : @@ -26,4 +26,4 @@ private : QTimer RefreshTimer; ANetNodeInstance * NNI; - AsDevice * Dev; + RuntimeInfo * Dev; }; diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp index 1a5b15b..ab57a00 100644 --- a/noncore/settings/networksettings2/profile/profilerun.cpp +++ b/noncore/settings/networksettings2/profile/profilerun.cpp @@ -3,65 +3,25 @@ #include "profilerun.h" -void ProfileRun::detectState( NodeCollection * NC ) { +State_t ProfileRun::detectState( void ) { if( Data->Disabled ) { - Log(( "%s disabled\n", NC->name().latin1() )); - NC->setCurrentState( Disabled ); - } else { - Log(( "%s not disabled\n", NC->name().latin1() )); - // find next item in connection - // convert to runtime and ask to detect the state - netNode()->nextNode()->runtime()->detectState( NC ); - } + return Disabled; + } + return Unknown; } -bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool F ) { - ANetNodeInstance * NNNI; - - NNNI = netNode()->nextNode(); - switch ( A ) { - case Enable : - if( NC->currentState() == Disabled ) { - Data->Disabled = 0; - NC->setCurrentState( Off ); // at least - // ... but request deeper - NNNI->runtime()->detectState(NC); - } - return 1; - case Disable : - switch( NC->currentState() ) { - case IsUp : - case Available : - // bring Deactivate (will bring down) - if( ! NNNI->runtime()->setState(NC, Deactivate) ) - return 0; - default : - break; - } +QString ProfileRun::setMyState( NodeCollection * NC, Action_t A, bool ) { + owarn << "Profile " << Data->Disabled << oendl; + if( A == Disable ) { + if( ! Data->Disabled ) { Data->Disabled = 1; - NC->setCurrentState( Disabled ); - return 1; - default : - break; - } - return NNNI->runtime()->setState(NC, A, F ); -} - -bool ProfileRun::canSetState( State_t Curr, Action_t A ) { - RuntimeInfo * RI; - switch ( A ) { - case Enable : - case Disable : - // always possible - return 1; - default : - break; + NC->setModified( 1 ); + } + } else if( A == Enable ) { + if( Data->Disabled ) { + Data->Disabled = 0; + NC->setModified( 1 ); + } } - RI = netNode()->nextNode()->runtime(); - return ( Curr != Disabled ) ? - RI->canSetState(Curr, A) : 0; -} -bool ProfileRun::handlesInterface( const QString & S ) { - // donno -> pass deeper - return netNode()->nextNode()->runtime()->handlesInterface(S); + return QString(); } diff --git a/noncore/settings/networksettings2/profile/profilerun.h b/noncore/settings/networksettings2/profile/profilerun.h index 400b56c..2d48b15 100644 --- a/noncore/settings/networksettings2/profile/profilerun.h +++ b/noncore/settings/networksettings2/profile/profilerun.h @@ -2,30 +2,28 @@ #define PROFILERUN_H -#include <asfullsetup.h> +#include <netnode.h> #include "profiledata.h" -class ProfileRun : public AsFullSetup { +class ProfileRun : public RuntimeInfo { public : ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) : - AsFullSetup( NNI ) + RuntimeInfo( NNI ) { Data = &D; } - void detectState( NodeCollection * NC ); - bool setState( NodeCollection * NC, Action_t A, bool ); - bool canSetState( State_t Curr, Action_t A ); - - bool handlesInterface( const QString & I ); - + virtual RuntimeInfo * fullSetup( void ) + { return this; } virtual const QString & description( void ) { return Data->Description; } - - virtual AsFullSetup * asFullSetup( void ) - { return (AsFullSetup *)this; } - virtual bool triggersVPN( void ) { return Data->TriggerVPN; } + State_t detectState( void ); + +protected : + + QString setMyState( NodeCollection * , Action_t, bool ); + private : diff --git a/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control b/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control index 8b8508c..ffb3012 100644 --- a/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control +++ b/noncore/settings/networksettings2/usb/opie-networksettings2plugin-usb.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-usb +Package: opie-networksettings2plugin-usb Files: plugins/networksettings2/libusb.so* Priority: optional diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index 14c479a..bd9ae2b 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp @@ -1,2 +1,3 @@ +#include <resources.h> #include "usb_NN.h" #include "usb_NNI.h" @@ -6,8 +7,15 @@ static const char * USBNeeds[] = }; +static const char * USBProvides[] = + { "device", + 0 + }; + /** * Constructor, find all of the possible interfaces */ USBNetNode::USBNetNode() : ANetNode(tr("USB Cable Connect")) { + NSResources->addSystemFile( + "interfaces", "/etc/network/interfaces", 1 ); } @@ -34,6 +42,6 @@ const char ** USBNetNode::needs( void ) { } -const char * USBNetNode::provides( void ) { - return "device"; +const char ** USBNetNode::provides( void ) { + return USBProvides; } diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h index 73da15a..b825cec 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.h +++ b/noncore/settings/networksettings2/usb/usb_NN.h @@ -21,5 +21,5 @@ public: virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); virtual QString genNic( long nr ); diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp index 50c6e8d..600b771 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.cpp +++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp @@ -33,7 +33,5 @@ void AUSB::commit( void ) { } -short AUSB::generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, +short AUSB::generateFileEmbedded( SystemFile & SF, long DevNr ) { @@ -43,8 +41,8 @@ short AUSB::generateFileEmbedded( const QString & ID, rvl = 1; - if( ID == "interfaces" ) { - Log(("Generate USB for %s\n", ID.latin1() )); + if( SF.name() == "interfaces" ) { + Log(("Generate USB for %s\n", SF.name().latin1() )); // generate mapping stanza for this interface - TS << " pre-up " + SF << " pre-up " << QPEApplication::qpeDir() << "bin/setmacaddress.sh " @@ -54,5 +52,5 @@ short AUSB::generateFileEmbedded( const QString & ID, rvl = 0; } - rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); + rvd = ANetNodeInstance::generateFileEmbedded(SF, DevNr ); return (rvd == 2 || rvl == 2 ) ? 2 : diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h index fcdfd91..27e71ee 100644 --- a/noncore/settings/networksettings2/usb/usb_NNI.h +++ b/noncore/settings/networksettings2/usb/usb_NNI.h @@ -27,7 +27,5 @@ public : { return (void *)&Data; } - virtual short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFileEmbedded( SystemFile & TS, long DevNr ); diff --git a/noncore/settings/networksettings2/usb/usbdata.h b/noncore/settings/networksettings2/usb/usbdata.h index c59f508..fa357b5 100644 --- a/noncore/settings/networksettings2/usb/usbdata.h +++ b/noncore/settings/networksettings2/usb/usbdata.h @@ -2,7 +2,8 @@ #define USB_DATA_H -typedef struct USBData { +class USBData { +public : bool Fake; -} USBData_t; +} ; #endif diff --git a/noncore/settings/networksettings2/usb/usbedit.cpp b/noncore/settings/networksettings2/usb/usbedit.cpp index 153c497..cc96b96 100644 --- a/noncore/settings/networksettings2/usb/usbedit.cpp +++ b/noncore/settings/networksettings2/usb/usbedit.cpp @@ -10,8 +10,8 @@ QString USBEdit::acceptable( void ) { } -void USBEdit::showData( USBData_t & Data ) { +void USBEdit::showData( USBData & Data ) { } -bool USBEdit::commit( USBData_t & Data ) { +bool USBEdit::commit( USBData & Data ) { return 1; } diff --git a/noncore/settings/networksettings2/usb/usbedit.h b/noncore/settings/networksettings2/usb/usbedit.h index 441f2f0..4179898 100644 --- a/noncore/settings/networksettings2/usb/usbedit.h +++ b/noncore/settings/networksettings2/usb/usbedit.h @@ -8,5 +8,5 @@ public : USBEdit( QWidget * parent ); QString acceptable( void ); - bool commit( USBData_t & Data ); - void showData( USBData_t & Data ); + bool commit( USBData & Data ); + void showData( USBData & Data ); }; diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index b8ac8a8..f8824e0 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp @@ -5,8 +5,9 @@ #include "usbrun.h" -void USBRun::detectState( NodeCollection * NC ) { +State_t USBRun::detectState( void ) { // unavailable : no card found // available : card found and assigned to us or free // up : card found and assigned to us and up + NodeCollection * NC = nodeCollection(); QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); System & Sys = NSResources->system(); @@ -28,8 +29,6 @@ void USBRun::detectState( NodeCollection * NC ) { Run = It.current(); if( X == Run->Name ) { - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; + NC->assignInterface( Run ); + return IsUp; } } @@ -37,16 +36,15 @@ void USBRun::detectState( NodeCollection * NC ) { } - Log(("Assigned %p\n", assignedInterface() )); - if( ( Run = assignedInterface() ) ) { + Log(("Assigned %p\n", NC->assignedInterface() )); + if( ( Run = NC->assignedInterface() ) ) { // we already have an interface assigned -> still present ? if( ! Run->IsUp ) { // usb is still free -> keep assignment - NC->setCurrentState( Available ); - return; + return Available; } // else interface is up but NOT us -> some other profile } // nothing (valid) assigned to us - assignInterface( 0 ); + NC->assignInterface( 0 ); // find possible interface @@ -66,82 +64,14 @@ void USBRun::detectState( NodeCollection * NC ) { ! Run->IsUp ) { - Log(("Released(OFF)\n" )); // proper type, and Not UP -> free - NC->setCurrentState( Off ); - return; + return Off; } } - // no free found - Log(("UNA\n" )); - NC->setCurrentState( Unavailable ); + return Unavailable; } -bool USBRun::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 ); - Log(("Assing %p\n", 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 USBRun::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; +QString USBRun::setMyState( NodeCollection *, Action_t , bool ) { + return QString(); } @@ -161,8 +91,8 @@ InterfaceInfo * USBRun::getInterface( void ) { ) { // this is a USB card - if( Run->assignedNode() == netNode() ) { + if( Run->assignedConnection() == netNode()->connection() ) { // assigned to us return Run; - } else if( Run->assignedNode() == 0 ) { + } else if( Run->assignedConnection() == 0 ) { // free best = Run; @@ -177,2 +107,6 @@ bool USBRun::handlesInterface( const QString & S ) { } +bool USBRun::handlesInterface( InterfaceInfo * I ) { + return handlesInterface( I->Name ); +} + diff --git a/noncore/settings/networksettings2/usb/usbrun.h b/noncore/settings/networksettings2/usb/usbrun.h index 03e21ab..6ce4fa2 100644 --- a/noncore/settings/networksettings2/usb/usbrun.h +++ b/noncore/settings/networksettings2/usb/usbrun.h @@ -2,9 +2,9 @@ #define USBRUN_H -#include <asdevice.h> +#include <netnode.h> #include <qregexp.h> #include "usbdata.h" -class USBRun : public AsDevice { +class USBRun : public RuntimeInfo { public : @@ -12,20 +12,19 @@ public : USBRun( ANetNodeInstance * NNI, USBData & Data ) : - AsDevice( NNI ), - Pat( "usb[0-9abcdef]" ) - { } + RuntimeInfo( NNI ), + Pat( "usb[0-9abcdef]" ) { + } - virtual AsDevice * device( void ) - { return (AsDevice *)this; } + virtual RuntimeInfo * device( void ) + { return this; } - virtual AsDevice * asDevice( void ) - { return (AsDevice *)this; } -protected : + bool handlesInterface( const QString & I ); + bool handlesInterface( InterfaceInfo * ); - void detectState( NodeCollection * ); - bool setState( NodeCollection * , Action_t A, bool ); - bool canSetState( State_t , Action_t A ); + State_t detectState( void ); - bool handlesInterface( const QString & I ); +protected : + + QString setMyState( NodeCollection * , Action_t, bool ); private : diff --git a/noncore/settings/networksettings2/vpn/opie-networksettings2plugin-vpn.control b/noncore/settings/networksettings2/vpn/opie-networksettings2plugin-vpn.control index b346c5d..08f131f 100644 --- a/noncore/settings/networksettings2/vpn/opie-networksettings2plugin-vpn.control +++ b/noncore/settings/networksettings2/vpn/opie-networksettings2plugin-vpn.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-vpn +Package: opie-networksettings2plugin-vpn Files: plugins/networksettings2/libvpn.so* Priority: optional diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp index 9d3b6e7..23ec04a 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp @@ -6,4 +6,8 @@ static const char * VPNNeeds[] = }; +static const char * VPNProvides[] = + { "connection", + 0 + }; /** * Constructor, find all of the possible interfaces @@ -34,6 +38,6 @@ const char ** VPNNetNode::needs( void ) { } -const char * VPNNetNode::provides( void ) { - return "connection"; +const char ** VPNNetNode::provides( void ) { + return VPNProvides; } diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h index 3c7b5e0..c2e43d4 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.h +++ b/noncore/settings/networksettings2/vpn/vpn_NN.h @@ -21,5 +21,5 @@ public: virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); private: diff --git a/noncore/settings/networksettings2/vpn/vpndata.h b/noncore/settings/networksettings2/vpn/vpndata.h index 5c986aa..ee88bc4 100644 --- a/noncore/settings/networksettings2/vpn/vpndata.h +++ b/noncore/settings/networksettings2/vpn/vpndata.h @@ -3,5 +3,6 @@ #include <qstring.h> -typedef struct VPNData { +class VPNData { +public : QString Device; QString LockFile; @@ -12,5 +13,5 @@ typedef struct VPNData { bool HardwareControl; bool SoftwareControl; -} VPNData_t; +} ; #endif diff --git a/noncore/settings/networksettings2/vpn/vpnedit.cpp b/noncore/settings/networksettings2/vpn/vpnedit.cpp index f336394..8445757 100644 --- a/noncore/settings/networksettings2/vpn/vpnedit.cpp +++ b/noncore/settings/networksettings2/vpn/vpnedit.cpp @@ -11,8 +11,8 @@ QString VPNEdit::acceptable( void ) { } -void VPNEdit::showData( VPNData_t & Data ) { +void VPNEdit::showData( VPNData & Data ) { } -bool VPNEdit::commit( VPNData_t & Data ) { +bool VPNEdit::commit( VPNData & Data ) { return 0; } diff --git a/noncore/settings/networksettings2/vpn/vpnedit.h b/noncore/settings/networksettings2/vpn/vpnedit.h index 76480cd..156bcc5 100644 --- a/noncore/settings/networksettings2/vpn/vpnedit.h +++ b/noncore/settings/networksettings2/vpn/vpnedit.h @@ -8,5 +8,5 @@ public : VPNEdit( QWidget * parent ); QString acceptable( void ); - bool commit( VPNData_t & Data ); - void showData( VPNData_t & Data ); + bool commit( VPNData & Data ); + void showData( VPNData & Data ); }; diff --git a/noncore/settings/networksettings2/vpn/vpnrun.cpp b/noncore/settings/networksettings2/vpn/vpnrun.cpp index ab2966c..64728aa 100644 --- a/noncore/settings/networksettings2/vpn/vpnrun.cpp +++ b/noncore/settings/networksettings2/vpn/vpnrun.cpp @@ -1,6 +1 @@ #include "vpnrun.h" - -bool VPNRun::handlesInterface( const QString & ) { - // to be figured out - return 0; -} diff --git a/noncore/settings/networksettings2/vpn/vpnrun.h b/noncore/settings/networksettings2/vpn/vpnrun.h index c19b609..9a55625 100644 --- a/noncore/settings/networksettings2/vpn/vpnrun.h +++ b/noncore/settings/networksettings2/vpn/vpnrun.h @@ -2,30 +2,25 @@ #define VPNRUN_H -#include <asconnection.h> +#include <netnode.h> #include "vpndata.h" -class VPNRun : public AsConnection { +class VPNRun : public RuntimeInfo { public : VPNRun( ANetNodeInstance * NNI, VPNData & Data ) : - AsConnection( NNI ) + RuntimeInfo( NNI ) { } - virtual AsConnection * asConnection( void ) - { return (AsConnection *)this; } -protected : - - void detectState( NodeCollection * ) - { } + virtual RuntimeInfo * connection( void ) + { return this; } - bool setState( NodeCollection *, Action_t, bool ) - { return 0; } + State_t detectState( void ) + { return Unknown; } - bool canSetState( State_t, Action_t ) - { return 0; } - - bool handlesInterface( const QString & I ); +protected : + QString setMyState( NodeCollection * , Action_t, bool ) + { return QString(); } }; diff --git a/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control b/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control index 14afd21..90f195a 100644 --- a/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control +++ b/noncore/settings/networksettings2/wlan/opie-networksettings2plugin-wlan.control @@ -1,3 +1,3 @@ -Package: opie-networksettingsplugin2-wlan +Package: opie-networksettings2plugin-wlan Files: plugins/networksettings2/libwlan.so* Priority: optional diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp index e4c3f60..36a5c33 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp @@ -1,2 +1,3 @@ +#include <resources.h> #include "wlan_NN.h" #include "wlan_NNI.h" @@ -6,8 +7,15 @@ static const char * WLanNeeds[] = }; +static const char * WLanProvides[] = + { "device", + 0 + }; + /** * Constructor, find all of the possible interfaces */ WLanNetNode::WLanNetNode() : ANetNode(tr("WLan Device")) { + NSResources->addSystemFile( + "interfaces", "/etc/network/interfaces", 1 ); InstanceCount = 2; } @@ -35,6 +43,6 @@ const char ** WLanNetNode::needs( void ) { } -const char * WLanNetNode::provides( void ) { - return "device"; +const char ** WLanNetNode::provides( void ) { + return WLanProvides; } diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h index c13c05c..4bffd3d 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.h +++ b/noncore/settings/networksettings2/wlan/wlan_NN.h @@ -21,5 +21,5 @@ public: virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); virtual long instanceCount( void ) diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp index 0e4fc4c..d5b1014 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp @@ -80,7 +80,5 @@ void AWLan::commit( void ) { } -short AWLan::generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, +short AWLan::generateFileEmbedded( SystemFile & SF, long DevNr ) { @@ -89,7 +87,7 @@ short AWLan::generateFileEmbedded( const QString & ID, rvl = 1; - if( ID == "interfaces" ) { - Log(("Generate WLanNNI for %s\n", ID.latin1() )); - TS << " wireless_essid \"" + if( SF.name() == "interfaces" ) { + Log(("Generate WLanNNI for %s\n", SF.name().latin1() )); + SF << " wireless_essid \"" << Data.ESSID << "\"" @@ -101,10 +99,10 @@ short AWLan::generateFileEmbedded( const QString & ID, if( gethostname(Buf, sizeof(Buf) ) == 0 ) { Buf[99] = '\0'; // just to make sure - TS << " wireless_nick " + SF << " wireless_nick " << Buf << endl; } } else { - TS << " wireless_nick \"" + SF << " wireless_nick \"" << Data.NodeName << "\"" @@ -125,5 +123,5 @@ short AWLan::generateFileEmbedded( const QString & ID, } - TS << " wireless_mode " + SF << " wireless_mode " << M << endl; @@ -131,5 +129,5 @@ short AWLan::generateFileEmbedded( const QString & ID, for( int i = 0; i < 4; i ++ ) { if( ! Data.Key[i].isEmpty() ) { - TS << " wireless_key" + SF << " wireless_key" << i << " " @@ -138,5 +136,5 @@ short AWLan::generateFileEmbedded( const QString & ID, } } - TS << " wireless_keymode " + SF << " wireless_keymode " << ((Data.AcceptNonEncrypted) ? "open" : "restricted") << endl; @@ -144,5 +142,5 @@ short AWLan::generateFileEmbedded( const QString & ID, rvl = 0; } - rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr); + rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr); return (rvd == 2 || rvl == 2 ) ? 2 : diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h index a9be65f..e3251c7 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NNI.h +++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h @@ -27,7 +27,5 @@ public : { return (void *)&Data; } - virtual short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFileEmbedded( SystemFile & Sf, long DevNr ); diff --git a/noncore/settings/networksettings2/wlan/wlandata.h b/noncore/settings/networksettings2/wlan/wlandata.h index 36990a9..f3cc1ab 100644 --- a/noncore/settings/networksettings2/wlan/wlandata.h +++ b/noncore/settings/networksettings2/wlan/wlandata.h @@ -3,5 +3,6 @@ #include <qstring.h> -typedef struct WLanData { +class WLanData { +public : QString ESSID; QString NodeName; @@ -12,5 +13,5 @@ typedef struct WLanData { QString Key[4]; bool AcceptNonEncrypted; -} WLanData_t; +} ; #endif diff --git a/noncore/settings/networksettings2/wlan/wlanedit.cpp b/noncore/settings/networksettings2/wlan/wlanedit.cpp index 8d3979e..74174bf 100644 --- a/noncore/settings/networksettings2/wlan/wlanedit.cpp +++ b/noncore/settings/networksettings2/wlan/wlanedit.cpp @@ -21,5 +21,5 @@ WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : Dev = NNI->runtime()->device(); WE = 0; - if( ( II = Dev->assignedInterface() ) ) { + if( ( II = NNI->connection()->assignedInterface() ) ) { // show data WE = new WExtensions( II->Name ); @@ -62,5 +62,5 @@ QString WLanEdit::acceptable( void ) { } -void WLanEdit::showData( WLanData_t & Data ) { +void WLanEdit::showData( WLanData & Data ) { Mode_CB->setCurrentItem( Data.Mode ); ESSID_LE->setText( Data.ESSID ); @@ -77,5 +77,5 @@ void WLanEdit::showData( WLanData_t & Data ) { } -bool WLanEdit::commit( WLanData_t & Data ) { +bool WLanEdit::commit( WLanData & Data ) { bool SM = 0; diff --git a/noncore/settings/networksettings2/wlan/wlanedit.h b/noncore/settings/networksettings2/wlan/wlanedit.h index e550c14..8f219d9 100644 --- a/noncore/settings/networksettings2/wlan/wlanedit.h +++ b/noncore/settings/networksettings2/wlan/wlanedit.h @@ -5,5 +5,5 @@ class ANetNodeInstance; -class AsDevice; +class RuntimeInfo; class WExtensions; @@ -15,6 +15,6 @@ public : ~WLanEdit( void ); QString acceptable( void ); - void showData( WLanData_t & Data ); - bool commit( WLanData_t & Data ); + void showData( WLanData & Data ); + bool commit( WLanData & Data ); public slots : @@ -26,5 +26,5 @@ private : ANetNodeInstance * NNI; - AsDevice * Dev; + RuntimeInfo * Dev; QTimer RefreshTimer; WExtensions * WE; diff --git a/noncore/settings/networksettings2/wlan/wlanrun.cpp b/noncore/settings/networksettings2/wlan/wlanrun.cpp index 3f1d4a9..fe49c4e 100644 --- a/noncore/settings/networksettings2/wlan/wlanrun.cpp +++ b/noncore/settings/networksettings2/wlan/wlanrun.cpp @@ -6,5 +6,5 @@ #include "wlanrun.h" -void WLanRun::detectState( NodeCollection * NC ) { +State_t WLanRun::detectState( void ) { // unavailable : no card found @@ -12,4 +12,5 @@ void WLanRun::detectState( NodeCollection * NC ) { // up : card found and assigned to us and up + NodeCollection * NC = nodeCollection(); QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); System & Sys = NSResources->system(); @@ -30,8 +31,6 @@ void WLanRun::detectState( NodeCollection * NC ) { Run = It.current(); if( X == Run->Name ) { - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; + NC->assignInterface( Run ); + return IsUp; } } @@ -39,15 +38,14 @@ void WLanRun::detectState( NodeCollection * NC ) { } - if( ( Run = assignedInterface() ) ) { + if( ( Run = NC->assignedInterface() ) ) { // we already have an interface assigned -> still present ? if( ! Run->IsUp ) { // usb is still free -> keep assignment - NC->setCurrentState( Available ); - return; + return Available; } // else interface is up but NOT us -> some other profile } // nothing (valid) assigned to us - assignInterface( 0 ); + NC->assignInterface( 0 ); // find possible interface @@ -65,79 +63,16 @@ void WLanRun::detectState( NodeCollection * NC ) { ) { // proper type, and Not UP -> free - NC->setCurrentState( Off ); - return; + return Off; } } - // no free found - NC->setCurrentState( Unavailable ); + return Unavailable; } -bool WLanRun::setState( NodeCollection * NC, Action_t A, bool ) { +QString WLanRun::setMyState( NodeCollection * , Action_t , 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; + return QString(); } @@ -160,8 +95,8 @@ InterfaceInfo * WLanRun::getInterface( void ) { ) { // this is a LAN card - if( Run->assignedNode() == netNode() ) { + if( Run->assignedConnection() == netNode()->connection() ) { // assigned to us return Run; - } else if( Run->assignedNode() == 0 ) { + } else if( Run->assignedConnection() == 0 ) { // free best = Run; diff --git a/noncore/settings/networksettings2/wlan/wlanrun.h b/noncore/settings/networksettings2/wlan/wlanrun.h index 25d5b96..fd325d4 100644 --- a/noncore/settings/networksettings2/wlan/wlanrun.h +++ b/noncore/settings/networksettings2/wlan/wlanrun.h @@ -3,29 +3,28 @@ #include <qregexp.h> -#include <asdevice.h> +#include <netnode.h> #include "wlandata.h" -class WLanRun : public AsDevice { +class WLanRun : public RuntimeInfo { public : WLanRun( ANetNodeInstance * NNI, WLanData & Data ) : - AsDevice( NNI ), - Pat( "wlan[0-9]" ) - { } + RuntimeInfo( NNI ), + Pat( "wlan[0-9]" ) { + } - virtual AsDevice * device( void ) - { return (AsDevice *)this; } - virtual AsDevice * asDevice( void ) - { return (AsDevice *)this; } + virtual RuntimeInfo * device( void ) + { return this; } -protected : - - 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 ); + State_t detectState( void ); + +protected : + + QString setMyState( NodeCollection * , Action_t, bool ); + private : diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h index 9972c00..7b52ce4 100644 --- a/noncore/settings/packagemanager/oconfitem.h +++ b/noncore/settings/packagemanager/oconfitem.h @@ -39,5 +39,10 @@ class OConfItem { public: - enum Type { Source, Destination, Option, Arch, NotDefined }; + enum Type { Source=0x01, + GzSource=0x02, + Destination=0x04, + Option=0x08, + Arch=0x10, + NotDefined=0x20 }; OConfItem( Type type = NotDefined, const QString &name = QString::null, diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index f2d7e39..a885ef8 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp @@ -115,5 +115,6 @@ OConfItemList *OIpkg::servers() { // Retrieve only servers - return filterConfItems( OConfItem::Source ); + return filterConfItems( (OConfItem::Type)((int)OConfItem::Source | + (int)OConfItem::GzSource) ); } @@ -544,4 +545,5 @@ void OIpkg::loadConfiguration() if ( !line.startsWith( "#" ) || line.startsWith( "#src" ) || + line.startsWith( "#src/gz" ) || line.startsWith( "#dest" ) || line.startsWith( "#arch" ) || @@ -619,5 +621,6 @@ OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) { OConfItem *item = it.current(); - if ( retrieveAll || item->type() == typefilter ) + if ( retrieveAll || + ( item->type() & typefilter ) ) { sl->append( item ); diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control index da3ddfe..0153d40 100644 --- a/noncore/settings/packagemanager/opie-packagemanager.control +++ b/noncore/settings/packagemanager/opie-packagemanager.control @@ -3,8 +3,8 @@ Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/package Priority: optional Section: opie/settings -Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg (>=0.99.120) +Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg0 (>=0.99.120), ipkg-link Replaces: packagemanager Architecture: arm Maintainer: Dan Williams (drw@handhelds.org) Description: Opie package management client -Version: 0.6.1$EXTRAVERSION +Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/tools/opie-sh/opie-sh.control b/noncore/tools/opie-sh/opie-sh.control index 106a183..496a036 100644 --- a/noncore/tools/opie-sh/opie-sh.control +++ b/noncore/tools/opie-sh/opie-sh.control @@ -5,5 +5,5 @@ Section: opie/sh Maintainer: Thomas Stephens <spiralman@softhome.net> Architecture: arm -Version: 0.5-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal License: GPL diff --git a/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.control b/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.control index 3c3463f..0d6b235 100644 --- a/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.control +++ b/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.control @@ -2,5 +2,5 @@ Package: opie-sh-wavelanchooser Files: bin/opie-sh-wavelanchooser.sh apps/Opie-SH/opie-sh-wavelanchooser.desktop pics/opie-sh-scripts/qtwavelan.png Installed-Size: 0 -Version: 0.1-20020527-1 +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal (1.5.0+), opie-sh Priority: optional diff --git a/noncore/unsupported/filebrowser/opie-filebrowser.control b/noncore/unsupported/filebrowser/opie-filebrowser.control index d40bd8a..50080a1 100644 --- a/noncore/unsupported/filebrowser/opie-filebrowser.control +++ b/noncore/unsupported/filebrowser/opie-filebrowser.control @@ -5,5 +5,5 @@ Section: opie/applications Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal Description: Browse the file system diff --git a/noncore/unsupported/gsmtool/opie-gsmtool.control b/noncore/unsupported/gsmtool/opie-gsmtool.control index 6bd3b46..d987b11 100644 --- a/noncore/unsupported/gsmtool/opie-gsmtool.control +++ b/noncore/unsupported/gsmtool/opie-gsmtool.control @@ -5,5 +5,5 @@ Section: opie/applications Maintainer: David Woodhouse <dwmw2@infradead.org> Architecture: arm -Version: 1.0.0-2 +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, gsmlib License: Public Domain diff --git a/noncore/unsupported/oipkg/opie-oipkg.control b/noncore/unsupported/oipkg/opie-oipkg.control index 17e7049..da6c755 100644 --- a/noncore/unsupported/oipkg/opie-oipkg.control +++ b/noncore/unsupported/oipkg/opie-oipkg.control @@ -5,5 +5,5 @@ Section: opie/settings Maintainer: Patrick S. Vogt <tille@almana.ch> Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, ipkg (>0.99.20), ar Description: Opie Projects advanced gui ipkg installer diff --git a/noncore/unsupported/ubrowser/opie-ubrowser.control b/noncore/unsupported/ubrowser/opie-ubrowser.control index cf96888..bfa6c30 100644 --- a/noncore/unsupported/ubrowser/opie-ubrowser.control +++ b/noncore/unsupported/ubrowser/opie-ubrowser.control @@ -5,5 +5,5 @@ Section: opie/applications Maintainer: Thomas Stephens <spiralman@softhome.net> Architecture: arm -Version: 0.1-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal License: GPL |