author | wimpie <wimpie> | 2004-08-12 12:46:55 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2004-08-12 12:46:55 (UTC) |
commit | 8f215ba9ceb395f262517855a99d7d2d303ca760 (patch) (unidiff) | |
tree | aa5f9b14c249217b4d3fc30f4771bdaf1c3545d3 /noncore/settings/networksettings2/main.cpp | |
parent | ef64880308b5035cc8ca2e4e79325db613af525b (diff) | |
download | opie-8f215ba9ceb395f262517855a99d7d2d303ca760.zip opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.gz opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.bz2 |
MANY changes
- now generates peers/pap-chap secrets files
(no chatscript yet)
(not all usefull ppp options included yet)
- still not ready for prime time yet
Diffstat (limited to 'noncore/settings/networksettings2/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/main.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp index 6c969fc..b32b323 100644 --- a/noncore/settings/networksettings2/main.cpp +++ b/noncore/settings/networksettings2/main.cpp | |||
@@ -1,58 +1,64 @@ | |||
1 | #include "nsdata.h" | 1 | #include "nsdata.h" |
2 | #include "activateprofile.h" | 2 | #include "activateprofile.h" |
3 | #include "activatevpn.h" | ||
3 | #include "networksettings.h" | 4 | #include "networksettings.h" |
4 | 5 | ||
5 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
6 | 7 | ||
7 | #include <opie2/oapplicationfactory.h> | 8 | #include <opie2/oapplicationfactory.h> |
8 | using namespace Opie::Core; | 9 | using namespace Opie::Core; |
9 | 10 | ||
10 | #ifdef GONE | 11 | #ifdef GONE |
11 | 12 | ||
12 | OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) | 13 | OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) |
13 | 14 | ||
14 | #else | 15 | #else |
15 | 16 | ||
16 | // just standard GUI | 17 | // just standard GUI |
17 | #define ACT_GUI 0 | 18 | #define ACT_GUI 0 |
18 | // used by interfaces to request for allow of up/down | 19 | // used by interfaces to request for allow of up/down |
19 | #define ACT_REQUEST 1 | 20 | #define ACT_REQUEST 1 |
20 | // regenerate config files | 21 | // regenerate config files |
21 | #define ACT_REGEN 2 | 22 | #define ACT_REGEN 2 |
22 | // used by interfaces to request user prompt | 23 | // used by interfaces to request user prompt |
23 | #define ACT_PROMPT 3 | 24 | #define ACT_PROMPT 3 |
25 | // used by interfaces to trigger VPN | ||
26 | #define ACT_VPN 4 | ||
24 | 27 | ||
25 | int main( int argc, char * argv[] ) { | 28 | int main( int argc, char * argv[] ) { |
26 | int rv = 0; | 29 | int rv = 0; |
27 | int Action = ACT_GUI; | 30 | int Action = ACT_GUI; |
28 | // could be overruled by -qws | 31 | // could be overruled by -qws |
29 | QApplication::Type GuiType = QApplication::GuiClient; | 32 | QApplication::Type GuiType = QApplication::GuiClient; |
30 | 33 | ||
31 | #ifdef _WS_QWS_ | 34 | #ifdef _WS_QWS_ |
32 | QPEApplication * TheApp; | 35 | QPEApplication * TheApp; |
33 | #else | 36 | #else |
34 | QApplication * TheApp; | 37 | QApplication * TheApp; |
35 | #endif | 38 | #endif |
36 | 39 | ||
37 | for ( int i = 1; i < argc; i ++ ) { | 40 | for ( int i = 1; i < argc; i ++ ) { |
38 | int rmv; | 41 | int rmv; |
39 | rmv = 0; | 42 | rmv = 0; |
40 | if( strcmp( argv[i], "--regen" ) == 0 ) { | 43 | if( strcmp( argv[i], "--regen" ) == 0 ) { |
41 | Action = ACT_REGEN; | 44 | Action = ACT_REGEN; |
42 | GuiType = QApplication::Tty; | 45 | GuiType = QApplication::Tty; |
43 | rmv = 1; | 46 | rmv = 1; |
44 | } else if( strcmp( argv[i], "--prompt" ) == 0 ) { | 47 | } else if( strcmp( argv[i], "--prompt" ) == 0 ) { |
45 | Action = ACT_PROMPT; | 48 | Action = ACT_PROMPT; |
46 | rmv = 1; | 49 | rmv = 1; |
50 | } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { | ||
51 | Action = ACT_VPN; | ||
52 | rmv = 1; | ||
47 | } | 53 | } |
48 | if( rmv ) { | 54 | if( rmv ) { |
49 | memmove( argv+i, argv+i+rmv, | 55 | memmove( argv+i, argv+i+rmv, |
50 | sizeof( char * ) * (argc-i-rmv) ); | 56 | sizeof( char * ) * (argc-i-rmv) ); |
51 | i --; | 57 | i --; |
52 | argc -= rmv; | 58 | argc -= rmv; |
53 | } | 59 | } |
54 | } | 60 | } |
55 | 61 | ||
56 | if( strstr( argv[0], "-request" ) ) { | 62 | if( strstr( argv[0], "-request" ) ) { |
57 | // called from system to request something | 63 | // called from system to request something |
58 | GuiType = QApplication::Tty; | 64 | GuiType = QApplication::Tty; |
@@ -69,61 +75,61 @@ int main( int argc, char * argv[] ) { | |||
69 | } else { | 75 | } else { |
70 | TheApp = new QPEApplication( argc, argv, GuiType ); | 76 | TheApp = new QPEApplication( argc, argv, GuiType ); |
71 | } | 77 | } |
72 | #else | 78 | #else |
73 | TheApp = new QApplication( argc, argv, GuiType ); | 79 | TheApp = new QApplication( argc, argv, GuiType ); |
74 | #endif | 80 | #endif |
75 | 81 | ||
76 | // init qt with app widget | 82 | // init qt with app widget |
77 | 83 | ||
78 | switch( Action ) { | 84 | switch( Action ) { |
79 | case ACT_REQUEST : | 85 | case ACT_REQUEST : |
80 | { NetworkSettingsData NS; | 86 | { NetworkSettingsData NS; |
81 | Log(("ACT_REQUEST\n")); | ||
82 | if( NS.canStart( argv[1] ) ) { | 87 | if( NS.canStart( argv[1] ) ) { |
83 | QString S; | 88 | QString S; |
84 | Log(("NEED FOR PROMPT\n" )); | ||
85 | S.sprintf( QPEApplication::qpeDir()+ | 89 | S.sprintf( QPEApplication::qpeDir()+ |
86 | "/bin/networksettings2" ); | 90 | "/bin/networksettings2" ); |
87 | char * MyArgv[4]; | 91 | char * MyArgv[4]; |
88 | MyArgv[0] = "networksettings2"; | 92 | MyArgv[0] = "networksettings2"; |
89 | MyArgv[1] = "--prompt"; | 93 | MyArgv[1] = "--prompt"; |
90 | MyArgv[2] = argv[1]; | 94 | MyArgv[2] = argv[1]; |
91 | MyArgv[3] = NULL; | 95 | MyArgv[3] = NULL; |
92 | NSResources->system().execAsUser( S, MyArgv ); | 96 | NSResources->system().execAsUser( S, MyArgv ); |
93 | // if we come here , failed | 97 | // if we come here , failed |
94 | printf( "%s-cNN-disallowed", argv[1] ); | 98 | printf( "%s-cNN-disallowed", argv[1] ); |
95 | } | 99 | } |
96 | } | 100 | } |
97 | break; | 101 | break; |
98 | case ACT_REGEN : | 102 | case ACT_REGEN : |
99 | { NetworkSettingsData NS; | 103 | { NetworkSettingsData NS; |
100 | Log(("REGEN\n" )); | ||
101 | // regen returns 0 if OK | 104 | // regen returns 0 if OK |
102 | rv = (NS.regenerate()) ? 1 : 0; | 105 | rv = (NS.regenerate()) ? 1 : 0; |
103 | } | 106 | } |
104 | break; | 107 | break; |
105 | case ACT_PROMPT : | 108 | case ACT_PROMPT : |
106 | { ActivateProfile AP(argv[1]); | 109 | { ActivateProfile AP(argv[1]); |
107 | Log(("PROMPT\n" )); | ||
108 | if( AP.exec() == QDialog::Accepted ) { | 110 | if( AP.exec() == QDialog::Accepted ) { |
109 | printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); | 111 | printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); |
110 | } else { | 112 | } else { |
111 | printf( "%s-cNN-disallowed", argv[1] ); | 113 | printf( "%s-cNN-disallowed", argv[1] ); |
112 | } | 114 | } |
113 | } | 115 | } |
114 | break; | 116 | break; |
117 | case ACT_VPN : | ||
118 | { ActivateVPN AVPN; | ||
119 | AVPN.exec(); | ||
120 | } | ||
121 | break; | ||
115 | case ACT_GUI : | 122 | case ACT_GUI : |
116 | { QWidget * W = new NetworkSettings(0); | 123 | { QWidget * W = new NetworkSettings(0); |
117 | Log(("GUI\n" )); | ||
118 | TheApp->setMainWidget( W ); | 124 | TheApp->setMainWidget( W ); |
119 | W->show(); | 125 | W->show(); |
120 | #ifdef _WS_QWS_ | 126 | #ifdef _WS_QWS_ |
121 | W->showMaximized(); | 127 | W->showMaximized(); |
122 | #else | 128 | #else |
123 | W->resize( W->sizeHint() ); | 129 | W->resize( W->sizeHint() ); |
124 | #endif | 130 | #endif |
125 | rv = TheApp->exec(); | 131 | rv = TheApp->exec(); |
126 | delete W; | 132 | delete W; |
127 | } | 133 | } |
128 | break; | 134 | break; |
129 | } | 135 | } |