summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/main.cpp
authorwimpie <wimpie>2005-01-04 01:35:26 (UTC)
committer wimpie <wimpie>2005-01-04 01:35:26 (UTC)
commita9c188235c97e07b0eb96b13adbcdfd4bad64767 (patch) (unidiff)
tree13f6ae5c499dc0c1d1bd4b763a1973a0fa8635cf /noncore/settings/networksettings2/main.cpp
parent48b6cd5966ec6cc0b968edf10ba1a1ad96ef165f (diff)
downloadopie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.zip
opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.gz
opie-a9c188235c97e07b0eb96b13adbcdfd4bad64767.tar.bz2
CONTROL files : changed version string
NS2 many changes and first release of OT2
Diffstat (limited to 'noncore/settings/networksettings2/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/main.cpp46
1 files changed, 35 insertions, 11 deletions
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
@@ -1,38 +1,50 @@
1#include "nsdata.h" 1#include "nsdata.h"
2#include "activateprofile.h" 2#include "activateprofile.h"
3#include "activatevpn.h" 3#include "activatevpn.h"
4#include "networksettings.h" 4#include "networksettings.h"
5 5
6#include <opie2/odebug.h>
6#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
7 8
8#include <opie2/oapplicationfactory.h> 9#include <opie2/oapplicationfactory.h>
9using namespace Opie::Core; 10using namespace Opie::Core;
10 11
11#ifdef GONE 12#ifdef GONE
12 13
13OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) 14OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> )
14 15
15#else 16#else
16 17
17// just standard GUI 18// just standard GUI
18#define ACT_GUI 0 19#define ACT_GUI 0
19// used by interfaces to request for allow of up/down 20// used by interfaces to request for allow of up/down
20#define ACT_REQUEST 1 21#define ACT_REQUEST 1
21// regenerate config files 22// regenerate config files
22#define ACT_REGEN 2 23#define ACT_REGEN 2
23// used by interfaces to request user prompt 24// used by interfaces to request user prompt
24#define ACT_PROMPT 3 25#define ACT_PROMPT 3
25// used by interfaces to trigger VPN 26// used by interfaces to trigger VPN
26#define ACT_VPN 4 27#define ACT_VPN 4
28// activate opietooth
29#define ACT_OT 5
30
31// include Opietooth GUI
32#include <opietooth2/Opietooth.h>
33using namespace Opietooth2;
34
35#include <qpushbutton.h>
36#include <qlayout.h>
37#include <qframe.h>
38#include <qlabel.h>
27 39
28int main( int argc, char * argv[] ) { 40int main( int argc, char * argv[] ) {
29 int rv = 0; 41 int rv = 0;
30 int Action = ACT_GUI; 42 int Action = ACT_GUI;
31 // could be overruled by -qws 43 // could be overruled by -qws
32 QApplication::Type GuiType = QApplication::GuiClient; 44 QApplication::Type GuiType = QApplication::GuiClient;
33 45
34#ifdef _WS_QWS_ 46#ifdef _WS_QWS_
35 QPEApplication * TheApp; 47 QPEApplication * TheApp;
36#else 48#else
37 QApplication * TheApp; 49 QApplication * TheApp;
38#endif 50#endif
@@ -41,108 +53,120 @@ int main( int argc, char * argv[] ) {
41 int rmv; 53 int rmv;
42 rmv = 0; 54 rmv = 0;
43 if( strcmp( argv[i], "--regen" ) == 0 ) { 55 if( strcmp( argv[i], "--regen" ) == 0 ) {
44 Action = ACT_REGEN; 56 Action = ACT_REGEN;
45 GuiType = QApplication::Tty; 57 GuiType = QApplication::Tty;
46 rmv = 1; 58 rmv = 1;
47 } else if( strcmp( argv[i], "--prompt" ) == 0 ) { 59 } else if( strcmp( argv[i], "--prompt" ) == 0 ) {
48 Action = ACT_PROMPT; 60 Action = ACT_PROMPT;
49 rmv = 1; 61 rmv = 1;
50 } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { 62 } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) {
51 Action = ACT_VPN; 63 Action = ACT_VPN;
52 rmv = 1; 64 rmv = 1;
65 } else if( strcmp( argv[i], "--opietooth" ) == 0 ) {
66 Action = ACT_OT;
67 rmv = 1;
53 } 68 }
54 if( rmv ) { 69 if( rmv ) {
55 memmove( argv+i, argv+i+rmv, 70 memmove( argv+i, argv+i+rmv,
56 sizeof( char * ) * (argc-i-rmv) ); 71 sizeof( char * ) * (argc-i-rmv) );
57 i --; 72 i --;
58 argc -= rmv; 73 argc -= rmv;
59 } 74 }
60 } 75 }
61 76
62 if( strstr( argv[0], "-request" ) ) { 77 if( strstr( argv[0], "-request" ) ) {
63 // called from system to request something 78 // called from system to request something
64 GuiType = QApplication::Tty; 79 GuiType = QApplication::Tty;
65 Action = ACT_REQUEST; 80 Action = ACT_REQUEST;
66 Log(("Request : %s\n", argv[1] )); 81 Log(("Request : %s\n", argv[1] ));
82 } else if( strstr( argv[0], "-opietooth" ) ) {
83 Action = ACT_OT;
67 } 84 }
68 85
69 // Start Qt 86 // Start Qt
70#ifdef _WS_QWS_ 87#ifdef _WS_QWS_
71 // because QPEApplication does not handle GuiType well 88 // because QPEApplication does not handle GuiType well
72 if( GuiType == QApplication::Tty ) { 89 if( GuiType == QApplication::Tty ) {
73 // this cast is NOT correct but we do not use 90 // this cast is NOT correct but we do not use
74 // TheApp anymore ... 91 // TheApp anymore ...
75 TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType ); 92 TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType );
76 } else { 93 } else {
77 TheApp = new QPEApplication( argc, argv, GuiType ); 94 TheApp = new QPEApplication( argc, argv, GuiType );
78 } 95 }
79#else 96#else
80 TheApp = new QApplication( argc, argv, GuiType ); 97 TheApp = new QApplication( argc, argv, GuiType );
81#endif 98#endif
82 99
83 // init qt with app widget 100 // init qt with app widget
84 101
85 switch( Action ) { 102 switch( Action ) {
86 case ACT_REQUEST : 103 case ACT_REQUEST :
87 { NetworkSettingsData NS; 104 { NetworkSettingsData NS;
88 if( NS.canStart( argv[1] ) ) { 105 if( NS.canStart( argv[1] ) ) {
89 QString S; 106 QStringList S;
90 S.sprintf( QPEApplication::qpeDir()+ 107 S << QPEApplication::qpeDir() + "/bin/networksettings2";
91 "bin/networksettings2" ); 108 S << "networksettings2";
92 char * MyArgv[4]; 109 S << "--prompt";
93 MyArgv[0] = "networksettings2"; 110 S << argv[1];
94 MyArgv[1] = "--prompt"; 111 NSResources->system().execAsUser( S );
95 MyArgv[2] = argv[1];
96 MyArgv[3] = NULL;
97 NSResources->system().execAsUser( S, MyArgv );
98 Log(("FAILED %s-cNN-allowed\n", argv[1] )); 112 Log(("FAILED %s-cNN-allowed\n", argv[1] ));
99 // if we come here , failed 113 // if we come here , failed
100 printf( "%s-cNN-disallowed", argv[1] ); 114 printf( "%s-cNN-disallowed", argv[1] );
101 } 115 }
102 } 116 }
103 break; 117 break;
104 case ACT_REGEN : 118 case ACT_REGEN :
105 { NetworkSettingsData NS; 119 { NetworkSettingsData NS;
120 QString S= NS.generateSettings();
106 // regen returns 0 if OK 121 // regen returns 0 if OK
107 rv = (NS.regenerate()) ? 1 : 0; 122 rv = ( S.isEmpty() ) ? 0 : 1;
108 } 123 }
109 break; 124 break;
110 case ACT_PROMPT : 125 case ACT_PROMPT :
111 { ActivateProfile AP(argv[1]); 126 { ActivateProfile AP(argv[1]);
112 if( AP.exec() == QDialog::Accepted ) { 127 if( AP.exec() == QDialog::Accepted ) {
113 Log(("%s-c%ld-allowed\n", 128 Log(("%s-c%ld-allowed\n",
114 argv[1], AP.selectedProfile() )); 129 argv[1], AP.selectedProfile() ));
115 printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); 130 printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() );
116 } else { 131 } else {
117 Log(("%s-c%NN-disallowed\n", argv[1] )); 132 Log(("%s-c%NN-disallowed\n", argv[1] ));
118 printf( "%s-cNN-disallowed", argv[1] ); 133 printf( "%s-cNN-disallowed", argv[1] );
119 } 134 }
120 } 135 }
121 break; 136 break;
122 case ACT_VPN : 137 case ACT_VPN :
123 { ActivateVPN AVPN; 138 { ActivateVPN AVPN;
124 AVPN.exec(); 139 AVPN.exec();
125 } 140 }
126 break; 141 break;
127 case ACT_GUI : 142 case ACT_GUI :
128 { QWidget * W = new NetworkSettings(0); 143 case ACT_OT :
144 { QWidget * W;
145
146 if( Action == ACT_OT ) {
147 W = new OTMain( 0 );
148 } else {
149 W = new NetworkSettings(0);
150 }
129 TheApp->setMainWidget( W ); 151 TheApp->setMainWidget( W );
152
130 W->show(); 153 W->show();
131#ifdef _WS_QWS_ 154#ifdef _WS_QWS_
132 W->showMaximized(); 155 W->showMaximized();
133#else 156#else
134 W->resize( W->sizeHint() ); 157 W->resize( W->sizeHint() );
135#endif 158#endif
136 rv = TheApp->exec(); 159 rv = TheApp->exec();
160
137 delete W; 161 delete W;
138 } 162 }
139 break; 163 break;
140 } 164 }
141 165
142 LogClose(); 166 LogClose();
143 167
144 return rv; 168 return rv;
145} 169}
146 170
147#endif 171#endif
148 172