From a9c188235c97e07b0eb96b13adbcdfd4bad64767 Mon Sep 17 00:00:00 2001 From: wimpie Date: Tue, 04 Jan 2005 01:35:26 +0000 Subject: CONTROL files : changed version string NS2 many changes and first release of OT2 --- 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 @@ -7,4 +7,4 @@ Architecture: arm 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 @@ -4,6 +4,6 @@ Priority: optional Section: opie/settings Maintainer: Patrick S. Vogt 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 @@ -6,4 +6,4 @@ Depends: task-opie-minimal, libopiecore2, libopieui2 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 @@ -4,7 +4,7 @@ Package: opie-bartender Section: opie/applications Maintainer: L.J. Potter Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal Description: Bartender drink receipe database lookup, and blood alcohol estimator. 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/applications Maintainer: Opie Team 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 Description: Opie terminal app 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/applications Maintainer: Opie Team 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 Description: Opie terminal app 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 @@ -5,7 +5,7 @@ Section: opie Maintainer: ljp 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,6 +1,6 @@ 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 Section: opie/games 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,6 +1,6 @@ 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 Section: opie/games 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/games Maintainer: Mark Westcott Architecture: arm -Version: 0.8-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal License: GPL Description: The famous hit Bill game 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/games Maintainer: leseb Architecture: arm -Version: 0.3-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopiecore2 Description: The game of Checkers A game for the Opie environment. 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,6 +1,6 @@ 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 Section: opie/games 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 @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -27,20 +28,16 @@ #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::iterator deleteIterator = playerData.begin(); - for ( ; deleteIterator != playerData.end() ; deleteIterator++ ) - { - delete ( *deleteIterator ); - } } void OHighscore::getList() @@ -64,7 +61,7 @@ void OHighscore::getList() pPlayerData->points = temp; pPlayerData->level = cfg.readNumEntry( "Level" ); - playerData.push_back( pPlayerData ); + playerData.append( pPlayerData ); if ( (temp < lowest) ) lowest = temp; rest++; @@ -83,7 +80,7 @@ void OHighscore::getList() pPlayerData->points = 0; pPlayerData->level = 0; - playerData.push_back( pPlayerData ); + playerData.append( pPlayerData ); } } @@ -100,41 +97,41 @@ void OHighscore::checkIfItIsANewhighscore( int points) void OHighscore::insertData( QString name , int punkte , int playerLevel ) { Config cfg ( "tetrix" ); + t_playerData * Run; + int index = 0; int entryNumber = 1; - std::list::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; temp->sName = name; 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++; } //////////////////////////////////////// return; } - insertIterator++; } } @@ -177,20 +174,30 @@ void OHighscoreDialog::createHighscoreListView() int pos = 10; int points_ = 0; int level_ = 0; - - std::list::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 pos--; 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 @@ -12,12 +12,13 @@ class QVBoxLayout; class QListView; #include -#include +#include -using namespace std; - -struct t_playerData +class t_playerData { + +public : + QString sName; int points; int level; @@ -45,7 +46,7 @@ class OHighscore : public QWidget */ void insertData( QString , int , int ); - list playerData; + QList playerData; /* * As Qt/e does not support QInputDialog I did that code myself @@ -53,8 +54,6 @@ class OHighscore : public QWidget QString getName(); private: - list::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 @@ -12,7 +12,7 @@ SOURCES = main.cpp \ ohighscoredlg.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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/multimedia Maintainer: Michael 'Mickey' Lauer Architecture: arm -Version: 1.0.1 +Version: $QPE_VERSION$EXTRAVERSION Depends: libqpe1, libopiecore2, libopieui2 Description: A Camera Application A Camera Application to use with the Sharp CE-AG06. 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 @@ -3,7 +3,7 @@ Files: root/usr/lib/libao.so* root/usr/lib/libogg* root/usr/lib/libvorbi Section: ;ibs Essential: no Priority: optional -Version: 0.7-$SUB_VERSION.3 +Version: $QPE_VERSION$EXTRAVERSION Architecture: arm Maintainer: Maximilian Reiss Depends: libc6 (>= 2.1), opie-mediaplayer2 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/multimedia Maintainer: L.J.Potter , Maximilian Reiss 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 more. Also it is streaming capable. 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 @@ -3,7 +3,7 @@ Priority: optional Section: opie/multimedia Maintainer: Camilo Mesias , ljp Architecture: arm -Version: 0.0.8 +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal Description: Guitar Chord generator application Allows naming of chords using base note and key. Fretboard diagrams are 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 @@ -4,7 +4,7 @@ Priority: optional Section: system Maintainer: Rajko Albrecht 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 License: LGPL 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 @@ -4,7 +4,7 @@ Priority: optional Section: libs Maintainer: Rajko Albrecht , Juergen Graf , Maximilian Reiß 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 License: LGPL 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/pim Maintainer: Rajko Albrecht , Juergen Graf , Maximilian Reiß 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) License: LGPL 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/applets Maintainer: Rajko Albrecht , Juergen Graf , Maximilian Reiß Architecture: arm -Version: 0.5-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopiecore2, opie-mail Description: A Biff-like mailchecker License: LGPL 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 @@ -4,6 +4,6 @@ Priority: optional Section: opie/applications Maintainer: Wenzel Jakob 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 @@ -4,6 +4,6 @@ Priority: optional Section: opie/applications Maintainer: Michael 'Mickey' Lauer 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 @@ -9,4 +9,3 @@ using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory ) - 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/applications Maintainer: Holger Freyther Architecture: arm -Version: 0.3.4-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal License: GPL Description: Bluetooth pin application 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 @@ -12,7 +12,7 @@ 0 0 - 258 + 254 245 @@ -29,21 +29,6 @@ spacing 6 - - QLabel - - name - txtStatus - - - text - - - - textFormat - RichText - - name @@ -66,6 +51,21 @@ + QLabel + + name + txtStatus + + + text + + + + textFormat + RichText + + + QLayoutWidget name 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 @@ -5,6 +5,6 @@ Section: libs Maintainer: Maximilian Reiß 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/settings Maintainer: Maximilian Reiß Architecture: arm -Version: 0.5.4-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, libopietooth1, opie-bluepin License: GPL Description: Bluetooth Manager application 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/applications Maintainer: Michael 'Mickey' Lauer 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/settings Maintainer: Clement Seveillac 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. This is a bluetooth-based authentication plugin (you need 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/settings Maintainer: Clement Seveillac Architecture: arm -Version: 0.0.2.3 +Version: $QPE_VERSION$EXTRAVERSION Depends: libopiecore2, opie-security Description: Dummy plugin for opie-security authentication. This is a very simple authentication plugin (you just have 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/settings Maintainer: Clement Seveillac Architecture: arm -Version: 0.0.1.6 +Version: $QPE_VERSION$EXTRAVERSION Depends: libopiecore2, opie-security Description: Notice plugin for opie-security authentication. It allows you to display e.g. a notice from your legal departement. 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/settings Maintainer: Clement Seveillac Architecture: arm -Version: 0.0.2.6 +Version: $QPE_VERSION$EXTRAVERSION Depends: libopiecore2, opie-security Description: PIN plugin for opie-security authentication. Simple PIN-based authentication plugin (replicate the functionality 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 @@ -22,21 +22,15 @@ ActivateVPN::ActivateVPN( void ) : ActivateVPNGUI( 0, 0, TRUE ), NSD() { QCheckListItem * CI; - printf( "%d\n", __LINE__ ); VPN_LV->clear(); VPN_LV->header()->hide(); - printf( "%d\n", __LINE__ ); for( QDictIterator 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 @@ -1,20 +1,24 @@ 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 VERSION = 1.0.0 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,6 +1,6 @@ #include "bluetoothBNEPedit.h" #include "bluetoothBNEP_NNI.h" -#include "bluetooth_NN.h" +#include "bluetoothBNEP_NN.h" ABluetoothBNEP::ABluetoothBNEP( BluetoothBNEPNetNode * PNN ) : ANetNodeInstance( PNN ), Data() { 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 @@ -3,9 +3,12 @@ #include -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 @@ -4,246 +4,158 @@ #include #include "bluetoothBNEPrun.h" -QDict * 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; - - 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 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 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 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 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 +#include #include "bluetoothBNEPdata.h" -class BluetoothBNEPRun : public AsDevice { +#include +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 * 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 @@ -11,8 +11,8 @@ 0 0 - 283 - 199 + 488 + 604 @@ -28,17 +28,38 @@ margin - 2 + 0 spacing - 2 + 3 + QLabel + + name + TextLabel5_2 + + + text + Selected devices with gprs capability + + + alignment + WordBreak|AlignVCenter|AlignLeft + + + wordwrap + + + QLayoutWidget name - Layout4 + Layout8 + + + layoutSpacing @@ -47,45 +68,120 @@ spacing - 6 + 3 QLabel name - TextLabel4 + TextLabel5 text - Name + Address QLineEdit name - Name_LE + Address_LE + + + + QToolButton + + name + FindDevice_TB + + + text + ... - QLabel + QLayoutWidget name - TextLabel3 + Layout7 - - text - Description - - - - QMultiLineEdit - - name - Description_LE + + layoutSpacing + + + margin + 0 + + + spacing + 3 + + + QLabel + + name + TextLabel2 + + + text + Channel + + + + QSpinBox + + name + Channel_SB + + + sizePolicy + + 0 + 0 + + + + minValue + 1 + + + + QLabel + + name + TextLabel2_2 + + + text + Name + + + + QLabel + + name + Name_LBL + + + sizePolicy + + 7 + 1 + + + + frameShape + Box + + + indent + 0 + + + QLayoutWidget @@ -93,6 +189,9 @@ name Layout5 + + layoutSpacing + margin @@ -100,32 +199,133 @@ spacing - 6 + 3 - QCheckBox + QLabel name - Automatic_CB + TextLabel7 + + + sizePolicy + + 7 + 1 + text - Start automatically + Addresses + + + alignment + AlignVCenter|AlignLeft + + + vAlign + + + + QToolButton + + name + Add_TB + + + text + ... - QCheckBox + QToolButton name - Confirm_CB + Remove_TB text - Confirm before start + ... + + QListView + + + text + Name + + + clickable + true + + + resizeable + true + + + + + text + Channel + + + clickable + true + + + resizeable + true + + + + + text + Address + + + clickable + true + + + resizeable + true + + + + name + Addresses_LV + + + allColumnsShowFocus + true + + + + + Add_TB + clicked() + BluetoothRFCOMM_FRM + SLOT_AddServer() + + + Remove_TB + clicked() + BluetoothRFCOMM_FRM + SLOT_RemoveServer() + + + FindDevice_TB + clicked() + BluetoothRFCOMM_FRM + SLOT_FindDevice() + + SLOT_AddServer() + SLOT_RemoveServer() + SLOT_FindDevice() + 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,16 +1,35 @@ #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 @@ -2,17 +2,21 @@ #define BLUETOOTHRFCOMM_DATA_H #include +#include -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 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #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 @@ -1,13 +1,27 @@ #include "bluetoothRFCOMMdata.h" #include "bluetoothRFCOMMGUI.h" +#include +using namespace Opietooth2; + class BluetoothRFCOMMEdit : public BluetoothRFCOMMGUI { 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 +#include #include "bluetoothRFCOMMdata.h" -class BluetoothRFCOMMRun : public AsLine { +#include +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 @@ -12,6 +12,11 @@ static const char * BluetoothBNEPNeeds[] = { 0 }; +static const char * BluetoothBNEPProvides[] = + { "device", + 0 + }; + /** * Constructor, find all of the possible interfaces */ @@ -42,8 +47,8 @@ const char ** BluetoothBNEPNetNode::needs( void ) { return BluetoothBNEPNeeds; } -const char * BluetoothBNEPNetNode::provides( void ) { - return "device"; +const char ** BluetoothBNEPNetNode::provides( void ) { + return BluetoothBNEPProvides; } QString BluetoothBNEPNetNode::genNic( long nr ) { 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 @@ -22,7 +22,7 @@ public: virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); virtual const char ** needs( void ); private: 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 @@ -1,4 +1,4 @@ config NS2BT 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,9 +1,9 @@ -Package: opie-networksettingsplugin2-bluetooth +Package: opie-networksettings2plugin-bluetooth Files: plugins/networksettings2/libbluetooth.so* Priority: optional Section: opie/settings Maintainer: Wim Delvaux 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 @@ -5,6 +5,11 @@ static const char * CableNeeds[] = { 0 }; +static const char * CableProvides[] = + { "line", + 0 + }; + /** * Constructor, find all of the possible interfaces */ @@ -32,8 +37,8 @@ const char ** CableNetNode::needs( void ) { return CableNeeds; } -const char * CableNetNode::provides( void ) { - return "line"; +const char ** CableNetNode::provides( void ) { + return CableProvides; } void CableNetNode::setSpecificAttribute( QString & , QString & ) { 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 @@ -20,7 +20,7 @@ public: virtual const QString nodeDescription() ; 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 @@ -49,25 +49,23 @@ void ACable::saveSpecificAttribute( QTextStream & TS ) { ((Data.SoftwareControl) ? "yes" : "no") << endl; } -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; 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/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 @@ -26,9 +26,7 @@ public : virtual void * data( void ) { return (void *)&Data; } - short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + short generateFileEmbedded( SystemFile & Sf, long DevNr ); protected : @@ -38,7 +36,7 @@ protected : 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 @@ -3,7 +3,10 @@ #include -typedef struct CableData { +class CableData { + +public : + QString Device; QString LockFile; long Speed; @@ -13,6 +16,6 @@ typedef struct CableData { bool HardwareControl; 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 @@ -17,7 +17,7 @@ static long SpeedTable[] = { 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 ); for( long * Run = SpeedTable; *Run != -1; *Run ++ ) { @@ -40,7 +40,7 @@ QString CableEdit::acceptable( void ) { return QString(); } -bool CableEdit::commit( CableData_t & D ) { +bool CableEdit::commit( CableData & D ) { bool SM = 0; TXTM( D.Device, DeviceFile_LE, SM ); 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 @@ -7,6 +7,6 @@ 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 @@ -2,27 +2,19 @@ #include #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(); } QString CableRun::deviceFile( void ) { 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 +#include #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,4 +1,4 @@ -Package: opie-networksettingsplugin2-bluetooth +Package: opie-networksettings2plugin-cable Files: plugins/networksettings2/libcable.so* Priority: optional Section: opie/settings 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,9 +1,11 @@ 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 source noncore/settings/networksettings2/network/config.in @@ -16,3 +18,4 @@ config NS2 source noncore/settings/networksettings2/bluetooth/config.in 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,3 +1,4 @@ +#include #include #include #include @@ -31,6 +32,13 @@ public: MyQCheckListItem( QListViewItem *parent, const QString & S, Type T ) : 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 ); @@ -116,48 +124,70 @@ NodeCollection * EditConnection::getTmpCollection( void ) { // update content 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 ; 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(); } TmpIsValid = 1; @@ -187,12 +217,11 @@ void EditConnection::setConnection( NodeCollection * NC ) { TmpIsValid = 0; 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; while( it ) { @@ -209,6 +238,7 @@ void EditConnection::setConnection( NodeCollection * NC ) { } it = it->nextSibling(); } + if( ! Found ) { // this means that this level is NOT present in collection // probably INCOMPATIBEL collection OR Missing plugin @@ -216,11 +246,31 @@ void EditConnection::setConnection( NodeCollection * NC ) { 0, tr( "Error presentig Connection" ), tr( "

Old connection or missing plugin \"%1\"

" ). - 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( "

Old connection or missing plugin \"%1\"

" ). + arg(NNI->nodeClass()->name()) ); + } else { + QMessageBox::warning( + 0, + tr( "Error presentig Connection" ), + tr( "

Missing connection\"%1\"

" ). + arg(it->text(0)) ); + } + return; + } it = it->firstChild(); } } @@ -269,7 +319,7 @@ void EditConnection::buildFullTree( void ) { NSResources->netNode2Description( "fullsetup" ) ); 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 Iter(NSResources->netNodes()); Iter.current(); @@ -284,7 +334,9 @@ void EditConnection::buildFullTree( void ) { MyQCheckListItem * it = new MyQCheckListItem( TheTop, 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 ); buildSubTree( it, NN ); @@ -299,7 +351,7 @@ void EditConnection::buildSubTree( QListViewItem * it, ANetNode *NN ) { // this node has alternatives -> needs radio buttons it = new MyQCheckListItem( it, - NSResources->netNode2Name(NNL[0]->provides()), + NSResources->netNode2Name(NN->needs()[0]), QCheckListItem::Controller ); it->setSelectable( FALSE ); } @@ -387,10 +439,11 @@ 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( "" ); } @@ -539,39 +592,40 @@ 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 @@ -5,6 +5,11 @@ static const char * IRDANeeds[] = { 0 }; +static const char * IRDAProvides[] = + { "line", + 0 + }; + /** * Constructor, find all of the possible interfaces */ @@ -32,8 +37,8 @@ const char ** IRDANetNode::needs( void ) { return IRDANeeds; } -const char * IRDANetNode::provides( void ) { - return "line"; +const char ** IRDANetNode::provides( void ) { + return IRDAProvides; } void IRDANetNode::setSpecificAttribute( QString & , QString & ) { 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 @@ -20,7 +20,7 @@ public: virtual const QString nodeDescription() ; 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 @@ -3,7 +3,8 @@ #include -typedef struct IRDAData { +class IRDAData { +public : QString Device; QString LockFile; long Speed; @@ -13,6 +14,6 @@ typedef struct IRDAData { bool HardwareControl; 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 +#include #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,4 +1,4 @@ -Package: opie-networksettingsplugin2-irda +Package: opie-networksettings2plugin-irda Files: plugins/networksettings2/libirda.so* Priority: optional Section: opie/settings 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 @@ -2,7 +2,13 @@ #include "lancard_NNI.h" static const char * LanCardNeeds[] = - { 0 }; + { 0 + }; + +static const char * LanCardProvides[] = + { "device", + 0 + }; /** * Constructor, find all of the possible interfaces @@ -34,8 +40,8 @@ const char ** LanCardNetNode::needs( void ) { return LanCardNeeds; } -const char * LanCardNetNode::provides( void ) { - return "device"; +const char ** LanCardNetNode::provides( void ) { + return LanCardProvides; } QString LanCardNetNode::genNic( long nr ) { 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 @@ -25,7 +25,7 @@ public: virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); QStringList & addressesOfNIC( void ) { return NICMACAddresses; } 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 @@ -4,10 +4,11 @@ #include #include -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 @@ -4,13 +4,15 @@ #include #include "lancardrun.h" -void LanCardRun::detectState( NodeCollection * NC ) { +State_t LanCardRun::detectState( void ) { // 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()); + NodeCollection * NC = nodeCollection(); + QString S = QString( "/tmp/profile-%1.up" ). + arg( NC->number()); System & Sys = NSResources->system(); InterfaceInfo * Run; @@ -28,26 +30,23 @@ void LanCardRun::detectState( NodeCollection * NC ) { ++It ) { Run = It.current(); if( X == Run->Name ) { - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; + NC->assignInterface( Run ); + return IsUp; } } } } - 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 for( QDictIterator It(Sys.interfaces()); @@ -63,81 +62,38 @@ void LanCardRun::detectState( NodeCollection * NC ) { ! Run->IsUp ) { // 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(); } // get interface that is free or assigned to us @@ -158,10 +114,10 @@ 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 @@ -1,33 +1,31 @@ #ifndef LANCARDRUN_H #define LANCARDRUN_H -#include +#include #include #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,4 +1,4 @@ -Package: opie-networksettingsplugin2-lancard +Package: opie-networksettings2plugin-lancard Files: plugins/networksettings2/liblancard.so* Priority: optional Section: opie/settings 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 @@ -3,6 +3,7 @@ #include "activatevpn.h" #include "networksettings.h" +#include #include #include @@ -24,6 +25,17 @@ OPIE_EXPORT_APP( OApplicationFactory ) #define ACT_PROMPT 3 // used by interfaces to trigger VPN #define ACT_VPN 4 +// activate opietooth +#define ACT_OT 5 + +// include Opietooth GUI +#include +using namespace Opietooth2; + +#include +#include +#include +#include int main( int argc, char * argv[] ) { int rv = 0; @@ -50,6 +62,9 @@ int main( int argc, char * argv[] ) { } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { Action = ACT_VPN; rmv = 1; + } else if( strcmp( argv[i], "--opietooth" ) == 0 ) { + Action = ACT_OT; + rmv = 1; } if( rmv ) { memmove( argv+i, argv+i+rmv, @@ -64,6 +79,8 @@ int main( int argc, char * argv[] ) { GuiType = QApplication::Tty; Action = ACT_REQUEST; Log(("Request : %s\n", argv[1] )); + } else if( strstr( argv[0], "-opietooth" ) ) { + Action = ACT_OT; } // Start Qt @@ -86,15 +103,12 @@ int main( int argc, char * argv[] ) { case ACT_REQUEST : { 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 printf( "%s-cNN-disallowed", argv[1] ); @@ -103,8 +117,9 @@ int main( int argc, char * argv[] ) { break; 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; case ACT_PROMPT : @@ -125,8 +140,16 @@ 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_ W->showMaximized(); @@ -134,6 +157,7 @@ int main( int argc, char * argv[] ) { W->resize( W->sizeHint() ); #endif rv = TheApp->exec(); + delete W; } break; 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 @@ -2,7 +2,12 @@ #include "modem_NNI.h" static const char * ModemNeeds[] = - { "line" + { "line", + 0 + }; +static const char * ModemProvides[] = + { "modem", + 0 }; /** @@ -33,8 +38,8 @@ const char ** ModemNetNode::needs( void ) { return ModemNeeds; } -const char * ModemNetNode::provides( void ) { - return "line"; +const char ** ModemNetNode::provides( void ) { + return ModemProvides; } void ModemNetNode::setSpecificAttribute( QString & , QString & ) { 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 @@ -20,7 +20,7 @@ public: virtual const QString nodeDescription() ; 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 @@ -2,7 +2,8 @@ #define MODEM_DATA_H #include -typedef struct ModemData { +class ModemData { +public : QString Device; QString LockFile; long Speed; @@ -12,6 +13,6 @@ typedef struct ModemData { bool HardwareControl; 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 @@ -9,10 +9,10 @@ QString ModemEdit::acceptable( void ) { return QString(); } -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 @@ -7,6 +7,6 @@ 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 +#include #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,4 +1,4 @@ -Package: opie-networksettingsplugin2-modem +Package: opie-networksettings2plugin-modem Files: plugins/networksettings2/libmodem.so* Priority: optional Section: opie/settings 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,5 +1,6 @@ #include -#include +#include +#include #include "network_NN.h" #include "network_NNI.h" @@ -8,10 +9,18 @@ static const char * NetworkNeeds[] = 0 }; +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 ); } /** @@ -32,31 +41,34 @@ ANetNodeInstance * NetworkNetNode::createInstance( void ) { return new ANetwork( this ); } -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; return 0; @@ -68,8 +80,8 @@ const char ** NetworkNetNode::needs( void ) { return NetworkNeeds; } -const char * NetworkNetNode::provides( void ) { - return "connection"; +const char ** NetworkNetNode::provides( void ) { + return NetworkProvides; } void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { 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 @@ -14,11 +14,9 @@ public: NetworkNetNode(); 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 ); virtual const QString pixmapName() @@ -27,7 +25,7 @@ public: virtual const QString nodeDescription() ; 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,5 +1,5 @@ #include -#include +#include #include "networkedit.h" #include "network_NNI.h" #include "network_NN.h" @@ -99,69 +99,67 @@ void ANetwork::commit( void ) { setModified( 1 ); } -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 ; QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 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" << connection()->number() << "-allowed inet dhcp" << endl; - TS << " up echo \"" + SF << " up echo \"" << NIC << "\" > /tmp/profile-" << connection()->number() << ".up" << 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-" << connection()->number() << ".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; @@ -175,7 +173,7 @@ short ANetwork::generateFile( const QString & ID, arg( ipal[1].toShort() & nmal[1].toShort() ). arg( ipal[2].toShort() & nmal[2].toShort() ). arg( ipal[3].toShort() & nmal[3].toShort() ); - TS << " network " + SF << " network " << NW << endl; } @@ -183,28 +181,28 @@ short ANetwork::generateFile( const QString & ID, for ( QStringList::Iterator it = Data.PreUp_SL.begin(); it != Data.PreUp_SL.end(); ++it ) { - TS << " pre-up " + SF << " pre-up " << (*it) << endl; } for ( QStringList::Iterator it = Data.PostUp_SL.begin(); it != Data.PostUp_SL.end(); ++it ) { - TS << " up " + SF << " up " << (*it) << endl; } for ( QStringList::Iterator it = Data.PreDown_SL.begin(); it != Data.PreDown_SL.end(); ++it ) { - TS << " down " + SF << " down " << (*it) << endl; } for ( QStringList::Iterator it = Data.PostDown_SL.begin(); it != Data.PostDown_SL.end(); ++it ) { - TS << " post-down " + SF << " post-down " << (*it) << endl; } @@ -212,7 +210,7 @@ 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 : (rvd == 0 || rvl == 0 ) ? 0 : 1; 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 @@ -27,11 +27,9 @@ public : virtual void * data( void ) { 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 : @@ -41,7 +39,7 @@ protected : 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 @@ -3,7 +3,8 @@ #include #include -typedef struct NetworkData { +class NetworkData { +public : bool UseDHCP; QString Hostname; bool SendHostname; @@ -17,6 +18,6 @@ typedef struct NetworkData { QStringList PostUp_SL; 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 @@ -65,7 +65,7 @@ QString NetworkEdit::acceptable( void ) { return QString(); } -bool NetworkEdit::commit( NetworkData_t & Data ) { +bool NetworkEdit::commit( NetworkData & Data ) { bool SM = 0; CBM( Data.UseDHCP, DHCP_CB, SM ); TXTM( Data.IPAddress, IPAddress_LE, SM ); @@ -85,7 +85,7 @@ bool NetworkEdit::commit( NetworkData_t & Data ) { return SM; } -void NetworkEdit::showData( NetworkData_t & Data ) { +void NetworkEdit::showData( NetworkData & Data ) { DHCP_CB->setChecked( Data.UseDHCP ); SendHostname_CB->setChecked( Data.SendHostname ); Hostname_LE->setText( Data.Hostname ); 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 @@ -9,8 +9,8 @@ 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 -#include +#include +#include #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 +#include #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,4 +1,4 @@ -Package: opie-networksettingsplugin2-network +Package: opie-networksettings2plugin-network Files: plugins/networksettings2/libnetwork.so* Priority: optional Section: opie/settings 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 @@ -2,8 +2,12 @@ #include #include +#include +#include + #include #include +#include #include #include #include @@ -15,7 +19,6 @@ #include #include -#include #include "networksettings.h" #include "netnode.h" #include "editconnection.h" @@ -31,13 +34,24 @@ NetworkSettings::NetworkSettings( QWidget *parent, Add_TB->setPixmap( NSResources->getPixmap( "add" ) ); 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(); @@ -72,7 +86,15 @@ 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 &) ) ); UpdateTimer->start( 5000 ); @@ -87,9 +109,13 @@ NetworkSettings::NetworkSettings( QWidget *parent, 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, "

" ); + S.append( "

" ); // problem saving QMessageBox::warning( 0, @@ -97,6 +123,7 @@ NetworkSettings::~NetworkSettings() { } SLOT_GenerateConfig(); + NSD.setModified( 0 ); } } @@ -167,14 +194,13 @@ void NetworkSettings::SLOT_DeleteNode( void ) { 1, 0 ) == 1 ) { NSResources->removeConnection( LBI->text() ); delete LBI; - setModified( 1 ); + NSD.setModified( 1 ); } } void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { QString OldName = ""; - printf( "------------------ Edit NOde\n" ); EditConnection EC( this ); if( LBI ) { @@ -196,7 +222,6 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { // toplevel item -> store NodeCollection * NC = EC.connection(); if( NC->isModified() ) { - setModified( 1 ); if( LBI ) { if( NC->name() != OldName ) { // find if new name is free @@ -249,62 +274,55 @@ 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( "<>" ) ); + } 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( "<>" ) ); - } 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 ); } void NetworkSettings::SLOT_CheckState( void ) { @@ -321,42 +339,49 @@ void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { } void NetworkSettings::SLOT_GenerateConfig( void ) { - NSD.regenerate(); + QString S = NSD.generateSettings(); + if( ! S.isEmpty() ) { + S.insert( 0, "

" ); + S.append( "

" ); + 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, "

" ); + Msg.append( "

" ); QMessageBox::warning( 0, tr( "Activating profile" ), Msg ); 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 ) return; @@ -364,33 +389,55 @@ void NetworkSettings::SLOT_On( void ) { NodeCollection * NC = 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, "

" ); + Msg.append( "

" ); 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 ) return; @@ -398,59 +445,57 @@ void NetworkSettings::SLOT_Connect( void ) { NodeCollection * NC = 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, "

" ); + Msg.append( "

" ); 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(); } 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 @@ -7,6 +7,7 @@ class ANetNodeInstance; class QTimer; class QListBoxItem; class QEvent; +class OLedBox; class NetworkSettings : public NetworkSettingsGUI { @@ -17,16 +18,11 @@ public : NetworkSettings( QWidget *parent=0, 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 : void SLOT_AddNode( void ); @@ -34,10 +30,11 @@ public slots : void SLOT_ShowNode( QListBoxItem * ); 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 ); void SLOT_QCopMessage( const QCString&,const QByteArray& ); @@ -50,4 +47,13 @@ private : void updateProfileState( QListBoxItem * it ); 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 @@ -11,9 +11,9 @@ SOURCES = main.cpp \ activateprofile.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 \ activatevpnGUI.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 @@ -31,6 +31,15 @@ Data = Wdg->currentItem(); \ } +#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 ); #endif 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 @@ -1,6 +1,8 @@ #ifndef __UTILS_H #define __UTILS_H +#include + #define Log(x) VLog x extern void VLog( char * Format, ... ); extern void LogClose( void ); 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 @@ -2,7 +2,6 @@ #include #include - #include #include #include @@ -11,10 +10,24 @@ #include "resources.h" #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 ) { if( X[0] == '"' ) { @@ -65,6 +78,21 @@ void ANetNode::setAttribute( QString & Attr, QString & Value ){ setSpecificAttribute( Attr, 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 ; +} + // // // ANETNODEINSTANCE @@ -84,7 +112,7 @@ void ANetNodeInstance::initialize( void ) { } void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ - if( Attr == "name" ) { + if( Attr == "__name" ) { setName( Value.latin1() ); } else { setSpecificAttribute( Attr, Value ); @@ -92,7 +120,7 @@ void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ } void ANetNodeInstance::saveAttributes( QTextStream & TS ) { - TS << "name=" << name() << endl; + TS << "__name=" << name() << endl; saveSpecificAttribute( TS ); } @@ -112,6 +140,7 @@ NodeCollection::NodeCollection( void ) : QList() { Name=""; IsNew = 1; CurrentState = Unchecked; + AssignedInterface = 0; } NodeCollection::NodeCollection( QTextStream & TS ) : @@ -123,6 +152,7 @@ NodeCollection::NodeCollection( QTextStream & TS ) : Index = -1; Name=""; IsNew = 0; + AssignedInterface = 0; CurrentState = Unchecked; do { @@ -147,7 +177,6 @@ NodeCollection::NodeCollection( QTextStream & TS ) : if( A == "name" ) { Name = N; } else if( A == "number" ) { - Log(( "Profile number %s\n", N.latin1() )); setNumber( N.toLong() ); } else if( A == "node" ) { ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); @@ -159,6 +188,9 @@ NodeCollection::NodeCollection( QTextStream & TS ) : } } } while( 1 ); + + Log(( "Profile number %s : %d nodes\n", + N.latin1(), count() )); } @@ -167,7 +199,7 @@ NodeCollection::~NodeCollection( void ) { const QString & NodeCollection::description( void ) { ANetNodeInstance * NNI = getToplevel(); - return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; + return (NNI) ? NNI->runtime()->description() : Name; } void NodeCollection::append( ANetNodeInstance * NNI ) { @@ -254,7 +286,8 @@ QPixmap NodeCollection::devicePixmap( void ) { QPixmap pm = NSResources->getPixmap( getToplevel()->nextNode()->pixmapName()+"-large"); - QPixmap Mini = NSResources->getPixmap( device()->netNode()->pixmapName() ); + QPixmap Mini = NSResources->getPixmap( + device()->netNode()->pixmapName() ); if( pm.isNull() || Mini.isNull() ) return Resource::loadPixmap("Unknown"); @@ -280,11 +313,11 @@ QString NodeCollection::stateName( State_t S) { case Disabled : 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 : break; @@ -300,38 +333,179 @@ 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 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(); } } return 0; } +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 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 @@ -10,6 +10,7 @@ #include #include +#include // difference feature interfaces class AsDevice; @@ -26,6 +27,7 @@ class NodeCollection; class QTextStream; class RuntimeInfo; class InterfaceInfo; +class NSResources; extern QString & deQuote( QString & X ); extern QString quote( QString X ); @@ -55,21 +57,21 @@ typedef enum State { } State_t; 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: @@ -90,8 +92,7 @@ public: { Done = D; } // does this Node provide a Connection - inline bool isToplevel( void ) - { return strcmp( provides(), "fullsetup") == 0 ; } + bool isToplevel( void ); // set the value of an attribute void setAttribute( QString & Attr, QString & Value ) ; @@ -110,27 +111,38 @@ 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 virtual QString genNic( long ) @@ -141,9 +153,10 @@ public: virtual long instanceCount( void ) { 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(); } // // @@ -160,8 +173,10 @@ public: // create a blank instance of a net node 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; protected : @@ -224,7 +239,7 @@ public: inline const QString pixmapName( void ) { return NodeType->pixmapName(); } - inline const char * provides( void ) + inline const char ** provides( void ) { return NodeType->provides(); } inline const char ** needs( void ) @@ -244,32 +259,28 @@ 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 ); } // generate code specific for this node but embedded // 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; } // return true if this node instance is triggered by this trigger @@ -323,33 +334,118 @@ public : RuntimeInfo( ANetNodeInstance * TheNNI ) { 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 : @@ -358,6 +454,11 @@ 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; }; @@ -392,28 +493,32 @@ public : return getToplevel()->runtime()->handlesInterface( S ); } + // 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 QPixmap devicePixmap( void ); @@ -424,10 +529,7 @@ public : inline QString stateName( bool Update = 0 ) { 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 ); @@ -456,16 +558,14 @@ 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 ) { return getToplevel()->triggeredBy( Trigger ); } @@ -489,6 +589,8 @@ private : bool IsModified; int Done; + InterfaceInfo * AssignedInterface; + }; #endif 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 @@ -5,13 +5,9 @@ DESTDIR = $(OPIEDIR)/lib$(PROJMAK) 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 \ system.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 @@ -45,15 +45,20 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), // avoid recursive 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; + } } } } @@ -61,23 +66,17 @@ 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( "

Devices that can handle IP packets

" ) ); - NodeTypeDescriptionMap.insert( "line", - tr( "

Devices that can handle single bytes

" ) ); - NodeTypeDescriptionMap.insert( "connection", - tr( "

Nodes that provide working IP connections

" ) ); - NodeTypeDescriptionMap.insert( "fullsetup", - tr( "

Fully configured connection profile

" ) ); - - // define system files - addSystemFile( "interfaces", "/tmp/interfaces", 1 ); + // define built in Node types to Description map + addNodeType( "device", tr( "Network Device" ), + tr( "

Devices that can handle IP packets

" ) ); + addNodeType( "line", tr( "Character device" ), + tr( "

Devices that can handle single bytes

" ) ); + addNodeType( "connection", tr( "IP Connection" ), + tr( "

Nodes that provide working IP connections

" ) ); + addNodeType( "fullsetup", tr( "Connection Profile" ), + tr( "

Fully configured connection profile

" ) ); + addNodeType( "GPRS", tr( "Connection to GPRS device" ), + tr( "

Connection to a GPRS capable device

" ) ); // get access to the system TheSystem = new System(); @@ -88,6 +87,15 @@ TheNSResources::~TheNSResources( void ) { delete TheSystem; } +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, bool KDI ) { @@ -220,8 +228,10 @@ QPixmap TheNSResources::getPixmap( const QString & QS ) { QPixmap P; 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; } @@ -269,6 +279,16 @@ NodeCollection * TheNSResources::findConnection( const QString & S ) { return ConnectionsMap[ S ]; } +NodeCollection * TheNSResources::getConnection( int nr ) { + for( QDictIterator it(ConnectionsMap); + it.current(); + ++it ) { + if( it.current()->number() == nr ) { + return it.current(); + } + } + return 0; +} /* void TheNSResources::renumberConnections( void ) { Name2Connection_t & M = NSResources->connections(); 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 @@ -67,6 +67,11 @@ public : return (NNT) ? NNT->NetNode : 0; } + // define new plugin (=node) + void addNodeType( const QString & ID, + const QString & LongName, + const QString & Description ); + Name2SystemFile_t & systemFiles( void ) { return SystemFiles; } void addSystemFile( const QString & ID, @@ -99,6 +104,7 @@ public : void addConnection( NodeCollection * NC ); 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 @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -50,63 +52,118 @@ System::~System( void ) { delete ProcDevNet; } -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; } 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 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; } void System::refreshStatistics( InterfaceInfo & I ) { @@ -198,15 +255,29 @@ 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 // SIOCGIFCONF does not return ALL interfaces ???!? ProcDevNet = new QFile(PROCNETDEV); if( ! ProcDevNet->open(IO_ReadOnly) ) { + owarn << "Cannot open " + << PROCNETDEV + << " " + << errno + << " " + << strerror( errno ) + << oendl; delete ProcDevNet; ProcDevNet =0; + ::close( sockfd ); return; } @@ -229,10 +300,10 @@ 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 ); // get dynamic info @@ -256,7 +327,7 @@ void System::probeInterfaces( void ) { IFI->MACAddress = ""; 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 )); IFI->CardType = ifrs.ifr_hwaddr.sa_family; @@ -324,7 +395,7 @@ 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 if( ioctl(sockfd, SIOCGIFFLAGS, &ifrs) >= 0 ) { @@ -354,35 +425,25 @@ void System::probeInterfaces( void ) { } else { 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 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; } #include @@ -394,24 +455,29 @@ void VLog( char * Format, ... ) { va_start(l, 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 { fprintf( logf, "____ OPEN LOGFILE ____\n"); } } - if( (long)logf > 1 ) { + if( (unsigned long)logf > 1 ) { vfprintf( logf, Format, l ); } va_end( l ); + fflush( logf ); } @@ -426,8 +492,82 @@ 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 @@ -1,15 +1,53 @@ #ifndef __SYSTEM__H #define __SYSTEM__H +#include + +#include + +using namespace Opie::Core; + // for hardware types #include #include #include #include +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 { public : @@ -22,13 +60,13 @@ public : DstAddress() { } - 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 QString MACAddress; // MAC address @@ -64,10 +102,10 @@ public : { return ProbedInterfaces[N]; } // 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 void refreshStatistics( InterfaceInfo & ); @@ -75,16 +113,23 @@ public : // reloads interfaces 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 : QDict ProbedInterfaces; FILE * OutputOfCmd; QFile * ProcDevNet; - }; #endif 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 @@ -16,6 +16,7 @@ SystemFile::SystemFile( const QString & N, bool KDI ){ Name = N; Path = P; + InAppend = 0; F = 0; // get template info { QString S; @@ -63,37 +64,82 @@ SystemFile::SystemFile( const QString & N, KnowsDeviceInstances = KDI; } +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 ); return 1; } 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(); delete F; 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; } bool SystemFile::preSection( void ) { 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 @@ -14,15 +14,25 @@ public : SystemFile( const QString & Name, 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 ); @@ -45,6 +55,7 @@ private : bool hasPreDeviceSection; bool hasPostDeviceSection; bool KnowsDeviceInstances; + bool InAppend; }; #endif 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 @@ -11,8 +11,8 @@ 0 0 - 144 - 260 + 383 + 359 @@ -68,7 +68,7 @@ spacing - 1 + 0 QToolButton @@ -167,14 +167,7 @@ QToolButton name - Enable_TB - - - sizePolicy - - 0 - 0 - + Disable_TB text @@ -193,14 +186,7 @@ QToolButton name - On_TB - - - sizePolicy - - 0 - 0 - + Down_TB text @@ -208,51 +194,33 @@ toggleButton - true + false toggleButton - true + false - QToolButton + QFrame name - Connect_TB + LED_Frm - sizePolicy - - 0 - 0 - - - - text - ... - - - toggleButton - true + frameShape + NoFrame - toggleButton - true + frameShadow + Raised QToolButton name - Disconnect_TB - - - sizePolicy - - 0 - 0 - + Up_TB text @@ -260,11 +228,11 @@ toggleButton - true + false toggleButton - true + false @@ -479,12 +447,6 @@ - Add_TB - clicked() - NetworkSettingsGUI - SLOT_AddNode() - - Delete_TB clicked() NetworkSettingsGUI @@ -497,24 +459,6 @@ SLOT_CheckState() - Enable_TB - clicked() - NetworkSettingsGUI - SLOT_Enable() - - - Connect_TB - clicked() - NetworkSettingsGUI - SLOT_Connect() - - - On_TB - clicked() - NetworkSettingsGUI - SLOT_On() - - GenConfig_TB clicked() NetworkSettingsGUI @@ -551,22 +495,40 @@ SLOT_ToMessages() - Disconnect_TB + Add_TB + clicked() + NetworkSettingsGUI + SLOT_AddNode() + + + Disable_TB + toggled(bool) + NetworkSettingsGUI + SLOT_Disable(bool) + + + Down_TB + clicked() + NetworkSettingsGUI + SLOT_Down() + + + Up_TB clicked() NetworkSettingsGUI - SLOT_Disconnect() + SLOT_Up() SLOT_AddNode() SLOT_CheckState() - SLOT_Connect() SLOT_DeleteNode() + SLOT_Disable(bool) SLOT_EditNode( QListBoxItem *) - SLOT_Enable() SLOT_GenerateConfig() - SLOT_On() + SLOT_SetState(int) SLOT_ShowNode( QListBoxItem*) SLOT_ToMessages() SLOT_ToProfile() - SLOT_Disconnect() + SLOT_Up() + SLOT_Down() 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,4 +1,5 @@ #include +#include #include #include #include @@ -6,7 +7,7 @@ #include #include "nsdata.h" -#include +#include #include static QString CfgFile; @@ -27,8 +28,46 @@ NetworkSettingsData::NetworkSettingsData( void ) { Log(( "Cfg from %s\n", CfgFile.latin1() )); // 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 )); + } + } + } + } } // saving is done by caller @@ -44,6 +83,8 @@ void NetworkSettingsData::loadSettings( void ) { QFile F( CfgFile ); QTextStream TS( &F ); + ForceModified = 0; + do { if( ! F.open(IO_ReadOnly) ) @@ -85,11 +126,9 @@ void NetworkSettingsData::loadSettings( void ) { S = deQuote(S); // 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 )); } if( NN == 0 && NNI == 0 ) { @@ -138,9 +177,13 @@ 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 ) ); + } } } @@ -220,7 +263,13 @@ QString NetworkSettingsData::saveSettings( void ) { // proper files AND system files regenerated // - setModified( 0 ); + + for( QDictIterator it(NSResources->connections()); + it.current(); + ++it ) { + it.current()->setModified( 0 ); + } + return ErrS; } @@ -231,8 +280,7 @@ QString NetworkSettingsData::generateSettings( void ) { NodeCollection * NC; ANetNodeInstance * NNI; ANetNodeInstance * FirstWithData; - SystemFile * SF; - AsDevice * CurDev; + RuntimeInfo * CurDev; ANetNode * NN, * CurDevNN = 0; long NoOfDevs; long DevCtStart; @@ -241,49 +289,109 @@ QString NetworkSettingsData::generateSettings( void ) { // regenerate system files Log( ( "Generating settings from %s\n", CfgFile.latin1() )); - // - // generate files proper to each netnodeinstance - // - { Name2Instance_t & NNIs = NSResources->netNodeInstances(); - - for( QDictIterator 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 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 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", + "

Cannot open proper file \"%1\" for node \"%2\"

" ). + arg( (*it) ).arg( CurDevNN->name() ); + return S; + } + + if( ! SF.open() ) { + S = qApp->translate( "NetworkSettings", + "

Cannot open proper file \"%1\" for node \"%2\"

" ). + arg( (*it) ).arg( CurDevNN->name() ); + return S; + } + + // preamble on first + if( FirstItem ) { + if( CurDevNN->generatePreamble( SF ) == 2 ) { S = qApp->translate( "NetworkSettings", - "

Cannot generate files proper to \"%1\"

" ). - arg(NNI->nodeClass()->name()) ; - delete F; + "

Error in section \"preamble\" for proper file \"%1\" and node \"%2\"

" ). + 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", + "

Error in section for node \"%1\" for proper file \"%2\" and node class \"%3\"

" ). + 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", + "

Cannot open proper file \"%1\" for node \"%2\"

" ). + arg( (*it) ).arg( CurDevNN->name() ); + return S; + } + + if( CurDevNN->generatePostamble( SF ) == 2 ) { + S = qApp->translate( "NetworkSettings", + "

Error in section \"postamble\" for proper file \"%1\" and node \"%2\"

" ). + arg( (*it) ). + arg( CurDevNN->name() ); + return S; + } + } // no postamble + } } } } // - // generate all system files + // generate all registered files // for( QDictIterator sfit(SFM); sfit.current(); ++sfit ) { + SystemFile * SF; + SF = sfit.current(); // reset all @@ -306,7 +414,7 @@ QString NetworkSettingsData::generateSettings( void ) { ncit.current()->setDone(0); } - Log( ( "Generating %s\n", SF->name().latin1() )); + Log( ( "Generating system file %s\n", SF->name().latin1() )); needToGenerate = 0; @@ -318,7 +426,7 @@ QString NetworkSettingsData::generateSettings( void ) { NN = nnit.current()->NetNode; - if( NN->hasDataForFile( SF->name() ) ) { + if( NN->hasDataForFile( *SF ) ) { // netnode can have data // are there instances of this node ? @@ -345,7 +453,12 @@ QString NetworkSettingsData::generateSettings( void ) { } // ok generate this system file - SF->open(); + if( ! SF->open() ) { + S = qApp->translate( "NetworkSettings", + "

Cannot open system file \"%1\"

" ). + arg( SF->name() ); + return S; + } // global presection for this system file if( ! SF->preSection() ) { @@ -367,7 +480,7 @@ QString NetworkSettingsData::generateSettings( void ) { continue; } - if( ! NC->hasDataForFile( SF->name() ) ) { + if( ! NC->hasDataForFile( *SF ) ) { // no data continue; } @@ -375,17 +488,13 @@ QString NetworkSettingsData::generateSettings( void ) { Log(("Generating %s for connection %s\n", 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 CurDev = NC->device(); // class of that node CurDevNN = CurDev->netNode()->nodeClass(); - Log(( "%s is done %d\n", - FirstWithData->nodeClass()->name(), - FirstWithData->nodeClass()->done() )); - if( ! FirstWithData->nodeClass()->done() ) { // generate fixed part if( ! SF->preDeviceSection( CurDevNN ) ) { @@ -396,7 +505,9 @@ QString NetworkSettingsData::generateSettings( void ) { } if( FirstWithData->nodeClass()->generateFile( - SF->name(), SF->path(), *SF, -1 ) == 2 ) { + *SF, + FirstWithData, + -2 ) == 2 ) { S = qApp->translate( "NetworkSettings", "

Error in section \"Common\" for file \"%1\" and node \"%2\"

" ). arg( SF->name() ). @@ -404,6 +515,9 @@ QString NetworkSettingsData::generateSettings( void ) { return S; } FirstWithData->nodeClass()->setDone( 1 ); + Log(( "Systemfile %s for node instance %s is done\n", + SF->name().latin1(), + FirstWithData->name() )); } NoOfDevs = 0; @@ -414,17 +528,13 @@ QString NetworkSettingsData::generateSettings( void ) { NoOfDevs = CurDevNN->instanceCount(); } - 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 // generate common device specific part for( int i = DevCtStart; i < NoOfDevs ; i ++ ) { if( FirstWithData->nodeClass()->generateFile( - SF->name(), SF->path(), *SF, CurDev->netNode(), i ) == 2 ) { + *SF, CurDev->netNode(), i ) == 2 ) { S = qApp->translate( "NetworkSettings", "

Error in section \"Device\" for file \"%1\" and node \"%2\"

" ). arg( SF->name() ). @@ -433,6 +543,11 @@ 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() + )); } // generate profile specific info @@ -446,9 +561,11 @@ QString NetworkSettingsData::generateSettings( void ) { continue; } - 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 ) ) { S = qApp->translate( "NetworkSettings", @@ -458,8 +575,7 @@ QString NetworkSettingsData::generateSettings( void ) { return S; } - switch( NNI->generateFile( - SF->name(), SF->path(), *SF, i ) ) { + switch( NNI->generateFile( *SF, i ) ) { case 0 : (*SF) << endl; break; @@ -569,9 +685,14 @@ bool NetworkSettingsData::canStart( const char * Interface ) { break; 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 case Available : @@ -589,15 +710,16 @@ bool NetworkSettingsData::canStart( const char * Interface ) { return 0; } -/* - 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 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 @@ -1,7 +1,7 @@ #ifndef __NSDATA_H #define __NSDATA_H -#include "netnode.h" +#include class NetworkSettingsData { @@ -15,23 +15,20 @@ 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 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; - }; #endif 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 @@ -37,7 +37,7 @@ QString PPPAuthEdit::acceptable( void ) { return QString(); } -bool PPPAuthEdit::commit( PPPData_t & D ) { +bool PPPAuthEdit::commit( PPPData & D ) { bool SM = 0; if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) || @@ -70,7 +70,7 @@ bool PPPAuthEdit::commit( PPPData_t & D ) { return SM; } -void PPPAuthEdit::showData( PPPData_t & D ) { +void PPPAuthEdit::showData( PPPData & D ) { switch( D.Auth.Mode ) { case 0 : 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 @@ -7,8 +7,8 @@ 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 @@ -23,7 +23,7 @@ QString PPPDNSEdit::acceptable( void ) { return QString(); } -bool PPPDNSEdit::commit( PPPData_t & D ) { +bool PPPDNSEdit::commit( PPPData & D ) { bool SM = 0; CBM( D.DNS.ServerAssigned, DNSServerAssigned_RB, SM ); @@ -75,7 +75,7 @@ bool PPPDNSEdit::commit( PPPData_t & D ) { return SM; } -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 @@ -7,8 +7,8 @@ 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 @@ -11,8 +11,8 @@ 0 0 - 124 - 29 + 528 + 345 @@ -28,7 +28,7 @@ margin - 2 + 0 spacing @@ -54,6 +54,18 @@ DNS Settings + + + text + Commands + + + + + text + Dialing + + name PPPOptions_CB @@ -76,7 +88,7 @@ -1 -1 - 0 + 1 7 7 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 @@ -11,8 +11,8 @@ 0 0 - 133 - 235 + 258 + 232 @@ -28,21 +28,17 @@ margin - 3 + 0 spacing - 2 + 1 - QButtonGroup + QGroupBox name - ButtonGroup4 - - - frameShape - Box + GroupBox1 title @@ -54,164 +50,90 @@ layoutSpacing - + margin - 2 + 3 spacing 2 - - QRadioButton + + QLabel name - IPServerAssigned_RB + TextLabel1 + + + enabled + true text - Server assigned + Local + + + QLineEdit - checked + name + LocalAddress_LE + + + enabled true - - QRadioButton + + QCheckBox name - IPFixed_RB + ServerOverrulesLocal_CB text - Fixed + Server Overrules - - QLayoutWidget + + QLineEdit name - Layout11 + RemoteAddress_LE + + + enabled + true - - - margin - 0 - - - spacing - 6 - - - - name - Spacer8 - - - orientation - Horizontal - - - sizeType - Fixed - - - sizeHint - - 20 - 20 - - - - layoutMargin - - - layoutSpacing - - - - QFrame - - name - Frame8 - - - enabled - false - - - sizePolicy - - 7 - 5 - - - - frameShape - NoFrame - - - frameShadow - Raised - - - layoutMargin - - - layoutSpacing - - - - margin - 2 - - - spacing - 2 - - - QLineEdit - - name - IPAddress_LE - - - - QLabel - - name - TextLabel3 - - - text - Subnetmask - - - - QLabel - - name - TextLabel2 - - - text - Address - - - - QLineEdit - - name - IPSubMask_LE - - - - - - + + QCheckBox + + name + ServerOverrulesRemote_CB + + + text + Server Overrules + + + + QLabel + + name + TextLabel1_2 + + + enabled + true + + + text + Remote + + + QButtonGroup @@ -220,6 +142,13 @@ ButtonGroup5 + sizePolicy + + 5 + 1 + + + title Gateway @@ -232,7 +161,7 @@ margin - 2 + 3 spacing @@ -378,7 +307,7 @@ QLayoutWidget name - Layout3 + Layout4 @@ -389,6 +318,17 @@ spacing 6 + + QCheckBox + + name + GWIsDefault_CB + + + text + Set as default + + name @@ -414,17 +354,38 @@ QCheckBox name - GWIsDefault_CB + GWIfNotSet_CB text - Set as default + Only if not yet set + + + name + Spacer4 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + @@ -434,11 +395,5 @@ Frame9 setEnabled(bool) - - IPFixed_RB - toggled(bool) - Frame8 - setEnabled(bool) - 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 @@ -9,16 +9,7 @@ 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" ); if( ! validIP( GWAddress_LE->text() ) ) @@ -28,30 +19,36 @@ QString PPPIPEdit::acceptable( void ) { return QString(); } -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 ); } 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 @@ -7,8 +7,8 @@ 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 @@ -3,6 +3,8 @@ #include "PPPIPedit.h" #include "PPPDNSedit.h" #include "PPPAuthedit.h" +#include "PPPRunedit.h" +#include "PPPDialingedit.h" #include "PPPedit.h" PPPEdit::PPPEdit( QWidget * Parent ) : PPPGUI( Parent ){ @@ -10,9 +12,14 @@ PPPEdit::PPPEdit( QWidget * Parent ) : PPPGUI( Parent ){ Auth = new PPPAuthEdit( Options_WS ); 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 ); } @@ -29,7 +36,7 @@ QString PPPEdit::acceptable( void ) { return S; } -bool PPPEdit::commit( PPPData_t & Data ) { +bool PPPEdit::commit( PPPData & Data ) { bool SM ; SM = Auth->commit( Data ); SM |= IP->commit( Data ); @@ -37,7 +44,7 @@ bool PPPEdit::commit( PPPData_t & Data ) { return SM; } -void PPPEdit::showData( PPPData_t & Data ) { +void PPPEdit::showData( PPPData & Data ) { Auth->showData( Data ) ; IP->showData( Data ); DNS->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 @@ -4,6 +4,8 @@ class PPPAuthEdit; class PPPIPEdit; class PPPDNSEdit; +class PPPRunEdit; +class PPPDialingEdit; class PPPEdit : public PPPGUI { @@ -11,8 +13,8 @@ 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 : @@ -20,8 +22,10 @@ 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,4 +1,4 @@ -Package: opie-networksettingsplugin2-ppp +Package: opie-networksettings2plugin-ppp Files: plugins/networksettings2/libppp.so* Priority: optional Section: opie/settings 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 @@ -6,18 +6,27 @@ HEADERS = ppp_NN.h \ PPPedit.h \ PPPAuthedit.h \ PPPDNSedit.h \ + PPPRunedit.h \ + PPPDialingedit.h \ PPPIPedit.h SOURCES = ppp_NN.cpp \ ppp_NNI.cpp \ PPPedit.cpp \ PPPDNSedit.cpp \ + PPPRunedit.cpp \ + PPPDialingedit.cpp \ PPPAuthedit.cpp \ ppprun.cpp \ PPPIPedit.cpp 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,4 +1,5 @@ #include +#include #include #include "ppp_NN.h" #include "ppp_NNI.h" @@ -6,8 +7,12 @@ QStringList * PPPNetNode::ProperFiles = 0; static const char * PPPNeeds[] = - { "line", - "modem", + { "modem", + 0 + }; + +static const char * PPPProvides[] = + { "connection", 0 }; @@ -16,16 +21,10 @@ 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 ); } /** @@ -50,21 +49,22 @@ const char ** PPPNetNode::needs( void ) { return PPPNeeds; } -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; } // need to generate : // /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" ; } QString PPPNetNode::genNic( long NicNr ) { 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 @@ -17,15 +17,15 @@ public: virtual const QString pixmapName() { 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 @@ -16,12 +16,21 @@ APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) { Data.Auth.Server = "*"; 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; @@ -59,19 +68,33 @@ void APPP::setSpecificAttribute( QString & A, QString & V ) { Data.Auth.Secret = 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; + } } } @@ -91,12 +114,20 @@ void APPP::saveSpecificAttribute( QTextStream & TS ) { TS << "authclient=" << Data.Auth.Client << endl; 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; + } QWidget * APPP::edit( QWidget * parent ) { @@ -115,51 +146,33 @@ 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; rvl = 1; 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 << " " @@ -167,16 +180,16 @@ short APPP::generateFile( const QString & ID, << endl; 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 << " " @@ -185,35 +198,36 @@ 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; // insert other data here 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 ); } return (rvd == 2 || rvl == 2 ) ? 2 : 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 @@ -16,11 +16,7 @@ public : APPP( PPPNetNode * PNN ); 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 ); QString acceptable( void ); @@ -29,10 +25,8 @@ public : virtual void * data( void ) { 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 ); protected : 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 @@ -4,15 +4,21 @@ #include #include -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 struct { @@ -33,6 +39,12 @@ typedef struct PPPData { QString DomainName; QArray 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 @@ -2,53 +2,19 @@ #include "ppprun.h" 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(); } bool PPPRun::isMyPPPDRunning( void ) { @@ -68,7 +34,7 @@ bool PPPRun::isMyPPPUp( void ) { Run->IsPointToPoint ) { // this is a LAN card - if( Run->assignedNode() == AsDevice::netNode() ) { + if( Run->assignedConnection() == netNode()->connection() ) { // assigned to us return 1; } @@ -80,3 +46,7 @@ bool PPPRun::isMyPPPUp( void ) { 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 @@ -2,46 +2,36 @@ #define PPPRUN_H #include -#include -#include +#include #include "pppdata.h" -class PPPRun : public AsConnection, public AsDevice { +class PPPRun : public RuntimeInfo { public : PPPRun( ANetNodeInstance * NNI, 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 : bool isMyPPPDRunning( void ); bool isMyPPPUp( void ); - PPPData_t * D; + PPPData * D; QRegExp Pat; - }; #endif 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,9 +1,9 @@ -Package: opie-networksettingsplugin2-profile +Package: opie-networksettings2plugin-profile Files: plugins/networksettings2/libprofile.so* Priority: optional Section: opie/settings Maintainer: Wim Delvaux 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,3 +1,4 @@ +#include #include "profile_NN.h" #include "profile_NNI.h" @@ -5,11 +6,19 @@ static const char * ProfileNeeds[] = { "connection", 0 }; +static const char * ProfileProvides[] = + { "fullsetup", + 0 + }; /** * Constructor, find all of the possible interfaces */ ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) { + + NSResources->addSystemFile( + "interfaces", "/etc/network/interfaces", 1 ); + } /** @@ -34,8 +43,8 @@ const char ** ProfileNetNode::needs( void ) { return ProfileNeeds; } -const char * ProfileNetNode::provides( void ) { - return "fullsetup"; +const char ** ProfileNetNode::provides( void ) { + return ProfileProvides; } void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { 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 @@ -20,7 +20,7 @@ public: virtual const QString nodeDescription() ; 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,3 +1,4 @@ +#include #include "profileedit.h" #include "profile_NNI.h" #include "profile_NN.h" @@ -50,25 +51,23 @@ void AProfile::commit( void ) { setModified( 1 ); } -short AProfile::generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, +short AProfile::generateFileEmbedded( SystemFile & SF, long DevNr ) { short rvl, rvd; 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 @@ -26,9 +26,7 @@ public : virtual void * data( void ) { return (void *)&Data; } - virtual short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFileEmbedded( SystemFile & TS, long DevNr ); const QString & description( void ) 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 @@ -2,7 +2,8 @@ #define PROFILE_DATA_H #include -typedef struct ProfileData { +class ProfileData { +public : QString Description; // start up automatically bool Automatic; @@ -11,6 +12,6 @@ typedef struct ProfileData { // Do not bring this connection up 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 @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include "profileedit.h" @@ -16,7 +16,7 @@ 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 ); Snd_GB->setEnabled( TRUE ); @@ -55,7 +55,7 @@ QString ProfileEdit::acceptable( void ) { return QString(); } -void ProfileEdit::showData( ProfileData_t & Data ) { +void ProfileEdit::showData( ProfileData & Data ) { Description_LE->setText( Data.Description ); Automatic_CB->setChecked( Data.Automatic ); TriggersVPN_CB->setChecked( Data.TriggerVPN ); @@ -64,7 +64,7 @@ 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 ); @@ -77,7 +77,7 @@ 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 ); SndBytes_LBL->setText( II->SndBytes ); 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 @@ -3,7 +3,7 @@ #include class ANetNodeInstance; -class AsDevice; +class RuntimeInfo; class ProfileEdit : public ProfileGUI { @@ -13,8 +13,8 @@ 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 : @@ -25,5 +25,5 @@ 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 @@ -2,66 +2,26 @@ #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 @@ -1,32 +1,30 @@ #ifndef PROFILERUN_H #define PROFILERUN_H -#include +#include #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 : ProfileData * Data; 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,4 +1,4 @@ -Package: opie-networksettingsplugin2-usb +Package: opie-networksettings2plugin-usb Files: plugins/networksettings2/libusb.so* Priority: optional Section: opie/settings 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,3 +1,4 @@ +#include #include "usb_NN.h" #include "usb_NNI.h" @@ -5,10 +6,17 @@ static const char * USBNeeds[] = { 0 }; +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 ); } /** @@ -33,8 +41,8 @@ const char ** USBNetNode::needs( void ) { return USBNeeds; } -const char * USBNetNode::provides( void ) { - return "device"; +const char ** USBNetNode::provides( void ) { + return USBProvides; } QString USBNetNode::genNic( long ) { 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 @@ -20,7 +20,7 @@ public: 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 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 @@ -32,9 +32,7 @@ void AUSB::commit( void ) { } } -short AUSB::generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, +short AUSB::generateFileEmbedded( SystemFile & SF, long DevNr ) { QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); @@ -42,10 +40,10 @@ 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 " << NIC @@ -53,7 +51,7 @@ short AUSB::generateFileEmbedded( const QString & ID, << 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/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 @@ -26,9 +26,7 @@ public : virtual void * data( void ) { return (void *)&Data; } - virtual short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFileEmbedded( SystemFile & TS, long DevNr ); protected : 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 @@ -1,8 +1,9 @@ #ifndef USB_DATA_H #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 @@ -9,9 +9,9 @@ QString USBEdit::acceptable( void ) { return QString(); } -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 @@ -7,6 +7,6 @@ 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 @@ -4,10 +4,11 @@ #include #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(); InterfaceInfo * Run; @@ -27,27 +28,24 @@ void USBRun::detectState( NodeCollection * NC ) { ++It ) { Run = It.current(); if( X == Run->Name ) { - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; + NC->assignInterface( Run ); + return IsUp; } } } } - 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 for( QDictIterator It(Sys.interfaces()); @@ -65,84 +63,16 @@ void USBRun::detectState( NodeCollection * NC ) { Run->CardType == ARPHRD_ETHER && ! 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(); } // get interface that is free or assigned to us @@ -160,10 +90,10 @@ InterfaceInfo * USBRun::getInterface( void ) { Run->CardType == ARPHRD_ETHER ) { // 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; } @@ -176,3 +106,7 @@ bool USBRun::handlesInterface( const QString & S ) { return Pat.match( S ) >= 0; } +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 @@ -1,32 +1,31 @@ #ifndef USBRUN_H #define USBRUN_H -#include +#include #include #include "usbdata.h" -class USBRun : public AsDevice { +class USBRun : public RuntimeInfo { 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,4 +1,4 @@ -Package: opie-networksettingsplugin2-vpn +Package: opie-networksettings2plugin-vpn Files: plugins/networksettings2/libvpn.so* Priority: optional Section: opie/settings 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 @@ -5,6 +5,10 @@ static const char * VPNNeeds[] = { 0 }; +static const char * VPNProvides[] = + { "connection", + 0 + }; /** * Constructor, find all of the possible interfaces */ @@ -33,8 +37,8 @@ const char ** VPNNetNode::needs( void ) { return VPNNeeds; } -const char * VPNNetNode::provides( void ) { - return "connection"; +const char ** VPNNetNode::provides( void ) { + return VPNProvides; } void VPNNetNode::setSpecificAttribute( QString & , QString & ) { 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 @@ -20,7 +20,7 @@ public: virtual const QString nodeDescription() ; 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 @@ -2,7 +2,8 @@ #define VPN_DATA_H #include -typedef struct VPNData { +class VPNData { +public : QString Device; QString LockFile; long Speed; @@ -11,6 +12,6 @@ typedef struct VPNData { short StopBits; 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 @@ -10,9 +10,9 @@ QString VPNEdit::acceptable( void ) { return QString(); } -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 @@ -7,6 +7,6 @@ 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 @@ -1,32 +1,27 @@ #ifndef VPNRUN_H #define VPNRUN_H -#include +#include #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(); } }; #endif 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,4 +1,4 @@ -Package: opie-networksettingsplugin2-wlan +Package: opie-networksettings2plugin-wlan Files: plugins/networksettings2/libwlan.so* Priority: optional Section: opie/settings 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,3 +1,4 @@ +#include #include "wlan_NN.h" #include "wlan_NNI.h" @@ -5,10 +6,17 @@ static const char * WLanNeeds[] = { 0 }; +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; } @@ -34,8 +42,8 @@ const char ** WLanNetNode::needs( void ) { return WLanNeeds; } -const char * WLanNetNode::provides( void ) { - return "device"; +const char ** WLanNetNode::provides( void ) { + return WLanProvides; } QString WLanNetNode::genNic( long nr ) { 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 @@ -20,7 +20,7 @@ public: virtual const QString nodeDescription() ; virtual ANetNodeInstance * createInstance( void ); virtual const char ** needs( void ); - virtual const char * provides( void ); + virtual const char ** provides( void ); virtual long instanceCount( void ) { return InstanceCount; } 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 @@ -79,18 +79,16 @@ void AWLan::commit( void ) { setModified( 1 ); } -short AWLan::generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, +short AWLan::generateFileEmbedded( SystemFile & SF, long DevNr ) { short rvl, rvd; 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 << "\"" << endl; @@ -100,12 +98,12 @@ short AWLan::generateFileEmbedded( const QString & ID, char Buf[100]; 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 << "\"" << endl; @@ -124,26 +122,26 @@ short AWLan::generateFileEmbedded( const QString & ID, break; } - TS << " wireless_mode " + SF << " wireless_mode " << M << endl; if( Data.Encrypted ) { for( int i = 0; i < 4; i ++ ) { if( ! Data.Key[i].isEmpty() ) { - TS << " wireless_key" + SF << " wireless_key" << i << " " << Data.Key[i] << endl; } } - TS << " wireless_keymode " + SF << " wireless_keymode " << ((Data.AcceptNonEncrypted) ? "open" : "restricted") << 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/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 @@ -26,9 +26,7 @@ public : virtual void * data( void ) { return (void *)&Data; } - virtual short generateFileEmbedded( const QString & ID, - const QString & Path, - QTextStream & TS, + virtual short generateFileEmbedded( SystemFile & Sf, long DevNr ); protected : 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 @@ -2,7 +2,8 @@ #define WLAN_DATA_H #include -typedef struct WLanData { +class WLanData { +public : QString ESSID; QString NodeName; short Mode; @@ -11,6 +12,6 @@ typedef struct WLanData { bool Encrypted; 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 @@ -20,7 +20,7 @@ WLanEdit::WLanEdit( QWidget * Parent, ANetNodeInstance * TNNI ) : NNI = TNNI; Dev = NNI->runtime()->device(); WE = 0; - if( ( II = Dev->assignedInterface() ) ) { + if( ( II = NNI->connection()->assignedInterface() ) ) { // show data WE = new WExtensions( II->Name ); @@ -61,7 +61,7 @@ QString WLanEdit::acceptable( void ) { return QString(); } -void WLanEdit::showData( WLanData_t & Data ) { +void WLanEdit::showData( WLanData & Data ) { Mode_CB->setCurrentItem( Data.Mode ); ESSID_LE->setText( Data.ESSID ); NodeName_LE->setText( Data.NodeName ); @@ -76,7 +76,7 @@ void WLanEdit::showData( WLanData_t & Data ) { Key4_LE->setText( Data.Key[3] ); } -bool WLanEdit::commit( WLanData_t & Data ) { +bool WLanEdit::commit( WLanData & Data ) { bool SM = 0; TXTM( Data.ESSID, ESSID_LE, SM ); 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 @@ -4,7 +4,7 @@ #include "wlanGUI.h" class ANetNodeInstance; -class AsDevice; +class RuntimeInfo; class WExtensions; class WLanEdit : public WLanGUI { @@ -14,8 +14,8 @@ public : WLanEdit( QWidget * parent, ANetNodeInstance * NNI ); ~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 : @@ -25,7 +25,7 @@ public slots : 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 @@ -5,12 +5,13 @@ #include #include "wlanrun.h" -void WLanRun::detectState( NodeCollection * NC ) { +State_t WLanRun::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(); InterfaceInfo * Run; @@ -29,26 +30,23 @@ void WLanRun::detectState( NodeCollection * NC ) { ++It ) { Run = It.current(); if( X == Run->Name ) { - Run->assignNode( netNode() ); - assignInterface( Run ); - NC->setCurrentState( IsUp ); - return; + NC->assignInterface( Run ); + return IsUp; } } } } - 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 for( QDictIterator It(Sys.interfaces()); @@ -64,81 +62,18 @@ void WLanRun::detectState( NodeCollection * NC ) { ! Run->IsUp ) { // 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(); } // get interface that is free or assigned to us @@ -159,10 +94,10 @@ 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 @@ -2,31 +2,30 @@ #define WLANRUN_H #include -#include +#include #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 : InterfaceInfo * getInterface( void ); 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 @@ -38,7 +38,12 @@ _;:, .> :=|. This program is free software; you can 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, const QString &value = QString::null, const QString &features = 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 @@ -114,7 +114,8 @@ OConfItemList *OIpkg::configItems() OConfItemList *OIpkg::servers() { // Retrieve only servers - return filterConfItems( OConfItem::Source ); + return filterConfItems( (OConfItem::Type)((int)OConfItem::Source | + (int)OConfItem::GzSource) ); } OConfItemList *OIpkg::destinations() @@ -543,6 +544,7 @@ void OIpkg::loadConfiguration() { if ( !line.startsWith( "#" ) || line.startsWith( "#src" ) || + line.startsWith( "#src/gz" ) || line.startsWith( "#dest" ) || line.startsWith( "#arch" ) || line.startsWith( "#option" ) ) @@ -618,7 +620,8 @@ OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) for ( ; it.current(); ++it ) { 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 @@ -2,9 +2,9 @@ Package: opie-packagemanager Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/sh Maintainer: Thomas Stephens Architecture: arm -Version: 0.5-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal License: GPL Description: A QDialog shell frontend 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 @@ -1,7 +1,7 @@ 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 Section: opie/sh 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/applications Maintainer: Opie Team Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal Description: Browse the file system The filebrowser for the Opie environment. 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/applications Maintainer: David Woodhouse Architecture: arm -Version: 1.0.0-2 +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal, gsmlib License: Public Domain Description: GSMTool program 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/settings Maintainer: Patrick S. Vogt 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 A GUI front-end to ipkg for the Opie environment. 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 @@ -4,7 +4,7 @@ Priority: optional Section: opie/applications Maintainer: Thomas Stephens Architecture: arm -Version: 0.1-$SUB_VERSION +Version: $QPE_VERSION$EXTRAVERSION Depends: task-opie-minimal License: GPL Description: A very small web browser -- cgit v0.9.0.2