author | wimpie <wimpie> | 2004-04-03 21:33:30 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-04-03 21:33:30 (UTC) |
commit | d82581fff0a7fa02b5c391a5b0bcfbfd1e5a6843 (patch) (side-by-side diff) | |
tree | 32ccf2da6464c498c4c43c750e1391a06a1ad431 /noncore/settings/networksettings2/main.cpp | |
parent | 41ba1a87a850785caf94d0b50675281fb6561168 (diff) | |
download | opie-d82581fff0a7fa02b5c391a5b0bcfbfd1e5a6843.zip opie-d82581fff0a7fa02b5c391a5b0bcfbfd1e5a6843.tar.gz opie-d82581fff0a7fa02b5c391a5b0bcfbfd1e5a6843.tar.bz2 |
Factored out non-gui data class
Added support for prompting
Diffstat (limited to 'noncore/settings/networksettings2/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/main.cpp | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp index bcef631..1e1270e 100644 --- a/noncore/settings/networksettings2/main.cpp +++ b/noncore/settings/networksettings2/main.cpp @@ -1,46 +1,56 @@ +#include "nsdata.h" +#include "activateprofile.h" #include "networksettings.h" #include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> #ifdef GONE OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) #else +// just standard GUI #define ACT_GUI 0 +// used by interfaces to request for allow of up/down #define ACT_REQUEST 1 +// regenerate config files #define ACT_REGEN 2 +// used by interfaces to request user prompt +#define ACT_PROMPT 3 int main( int argc, char * argv[] ) { int rv = 0; int Action = ACT_GUI; // could be overruled by -qws QApplication::Type GuiType = QApplication::GuiClient; #ifdef _WS_QWS_ QPEApplication * TheApp; #else QApplication * TheApp; #endif for ( int i = 1; i < argc; i ++ ) { int rmv; rmv = 0; if( strcmp( argv[i], "--regen" ) == 0 ) { Action = ACT_REGEN; GuiType = QApplication::Tty; rmv = 1; + } else if( strcmp( argv[i], "--prompt" ) == 0 ) { + Action = ACT_PROMPT; + rmv = 1; } if( rmv ) { memmove( argv+i, argv+i+rmv, sizeof( char * ) * (argc-i-rmv) ); i --; argc -= rmv; } } if( strstr( argv[0], "-request" ) ) { // called from system to request something GuiType = QApplication::Tty; @@ -53,44 +63,57 @@ int main( int argc, char * argv[] ) { if( GuiType == QApplication::Tty ) { // this cast is NOT correct but we do not use // TheApp anymore ... TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType ); } else { TheApp = new QPEApplication( argc, argv, GuiType ); } #else TheApp = new QApplication( argc, argv, GuiType ); #endif // init qt with app widget - if( GuiType != QApplication::Tty ) { - QWidget * W = 0; - W = new NetworkSettings(0); - TheApp->setMainWidget( W ); - W->show(); + + switch( Action ) { + case ACT_REQUEST : + { NetworkSettingsData NS; + NS.canStart( argv[1] ); + } + break; + case ACT_REGEN : + { NetworkSettingsData NS; + // regen returns 0 if OK + rv = (NS.regenerate()) ? 1 : 0; + } + break; + case ACT_PROMPT : + { ActivateProfile AP(argv[1]); + if( AP.exec() == QDialog::Accepted ) { + printf( "%s-c%d-allowed", AP.selectedProfile() ); + } else { + printf( "%s-cNN-disallowed" ); + } + } + break; + case ACT_GUI : + { QWidget * W = new NetworkSettings(0); + TheApp->setMainWidget( W ); + W->show(); #ifdef _WS_QWS_ - W->showMaximized(); + W->showMaximized(); #else - W->resize( W->sizeHint() ); + W->resize( W->sizeHint() ); #endif - rv = TheApp->exec(); - delete W; - } else { - switch( Action ) { - case ACT_REQUEST : - NetworkSettings::canStart( argv[1] ); - break; - case ACT_REGEN : - // regen returns 0 if OK - rv = (NetworkSettings::regenerate()) ? 1 : 0; - break; - } + rv = TheApp->exec(); + delete W; + } + break; } return rv; } #endif // main.cpp |