author | wimpie <wimpie> | 2005-01-11 15:35:46 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-11 15:35:46 (UTC) |
commit | 4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9 (patch) (unidiff) | |
tree | 0e8adcc616a1d20b637aad3de568dcb45af05f71 /noncore/settings/networksettings2/main.cpp | |
parent | 32e8aa951218c0bd6118ee04bb22ef83b3b7ec2e (diff) | |
download | opie-4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9.zip opie-4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9.tar.gz opie-4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9.tar.bz2 |
vpn should now work IF only the vpn plugin would do something.
shortened logical interface names (busybox only supports 10 characters
and then ONLY if you recompile it with mappings enabled)
Other small fixes
Diffstat (limited to 'noncore/settings/networksettings2/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/main.cpp | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp index 973b4b7..2243826 100644 --- a/noncore/settings/networksettings2/main.cpp +++ b/noncore/settings/networksettings2/main.cpp | |||
@@ -20,16 +20,18 @@ OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) | |||
20 | // used by interfaces to request for allow of up/down | 20 | // used by interfaces to request for allow of up/down |
21 | #define ACT_REQUEST 1 | 21 | #define ACT_REQUEST 1 |
22 | // regenerate config files | 22 | // regenerate config files |
23 | #define ACT_REGEN 2 | 23 | #define ACT_REGEN 2 |
24 | // used by interfaces to request user prompt | 24 | // used by interfaces to request user prompt |
25 | #define ACT_PROMPT 3 | 25 | #define ACT_PROMPT 3 |
26 | // used by interfaces to trigger VPN | 26 | // used by interfaces to trigger VPN prompting |
27 | #define ACT_VPN 4 | 27 | #define ACT_TRIGGERVPN 4 |
28 | // activate opietooth | 28 | // activate opietooth |
29 | #define ACT_OT 5 | 29 | #define ACT_OT 5 |
30 | // prompt for VPN networks | ||
31 | #define ACT_PROMPTVPN 6 | ||
30 | 32 | ||
31 | // include Opietooth GUI | 33 | // include Opietooth GUI |
32 | #include <opietooth2/Opietooth.h> | 34 | #include <opietooth2/Opietooth.h> |
33 | using namespace Opietooth2; | 35 | using namespace Opietooth2; |
34 | 36 | ||
35 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
@@ -53,13 +55,17 @@ int main( int argc, char * argv[] ) { | |||
53 | GuiType = QApplication::Tty; | 55 | GuiType = QApplication::Tty; |
54 | rmv = 1; | 56 | rmv = 1; |
55 | } else if( strcmp( argv[i], "--prompt" ) == 0 ) { | 57 | } else if( strcmp( argv[i], "--prompt" ) == 0 ) { |
56 | Action = ACT_PROMPT; | 58 | Action = ACT_PROMPT; |
57 | rmv = 1; | 59 | rmv = 1; |
58 | } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { | 60 | } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { |
59 | Action = ACT_VPN; | 61 | GuiType = QApplication::Tty; |
62 | Action = ACT_TRIGGERVPN; | ||
63 | rmv = 1; | ||
64 | } else if( strcmp( argv[i], "--promptvpn" ) == 0 ) { | ||
65 | Action = ACT_PROMPTVPN; | ||
60 | rmv = 1; | 66 | rmv = 1; |
61 | } else if( strcmp( argv[i], "--opietooth" ) == 0 ) { | 67 | } else if( strcmp( argv[i], "--opietooth" ) == 0 ) { |
62 | Action = ACT_OT; | 68 | Action = ACT_OT; |
63 | rmv = 1; | 69 | rmv = 1; |
64 | } | 70 | } |
65 | if( rmv ) { | 71 | if( rmv ) { |
@@ -92,21 +98,30 @@ int main( int argc, char * argv[] ) { | |||
92 | // init qt with app widget | 98 | // init qt with app widget |
93 | 99 | ||
94 | switch( Action ) { | 100 | switch( Action ) { |
95 | case ACT_REQUEST : | 101 | case ACT_REQUEST : |
96 | { NetworkSettingsData NS; | 102 | { NetworkSettingsData NS; |
97 | if( NS.canStart( argv[1] ) ) { | 103 | if( NS.canStart( argv[1] ) ) { |
104 | QStringList SL; | ||
105 | SL << QPEApplication::qpeDir() + "bin/networksettings2" | ||
106 | << "--prompt" | ||
107 | << argv[1]; | ||
108 | // exec synchronous -> blocks | ||
109 | NSResources->system().execAsUser( SL, 1 ); | ||
110 | } | ||
111 | } | ||
112 | break; | ||
113 | case ACT_TRIGGERVPN : | ||
114 | { NetworkSettingsData NS; | ||
115 | if( NS.couldBeTriggered( argv[1] ) ) { | ||
116 | // there are VPNS that can be triggered | ||
98 | QStringList S; | 117 | QStringList S; |
99 | S << QPEApplication::qpeDir() + "/bin/networksettings2"; | 118 | S << QPEApplication::qpeDir() + "bin/networksettings2"; |
100 | S << "networksettings2"; | 119 | S << "--promptvpn"; |
101 | S << "--prompt"; | ||
102 | S << argv[1]; | 120 | S << argv[1]; |
103 | NSResources->system().execAsUser( S ); | 121 | NSResources->system().execAsUser( S ); |
104 | Log(("FAILED %s-cNN-allowed\n", argv[1] )); | ||
105 | // if we come here , failed | ||
106 | printf( "%s-cNN-disallowed", argv[1] ); | ||
107 | } | 122 | } |
108 | } | 123 | } |
109 | break; | 124 | break; |
110 | case ACT_REGEN : | 125 | case ACT_REGEN : |
111 | { NetworkSettingsData NS; | 126 | { NetworkSettingsData NS; |
112 | QString S= NS.generateSettings(); | 127 | QString S= NS.generateSettings(); |
@@ -114,23 +129,24 @@ int main( int argc, char * argv[] ) { | |||
114 | rv = ( S.isEmpty() ) ? 0 : 1; | 129 | rv = ( S.isEmpty() ) ? 0 : 1; |
115 | } | 130 | } |
116 | break; | 131 | break; |
117 | case ACT_PROMPT : | 132 | case ACT_PROMPT : |
118 | { ActivateProfile AP(argv[1]); | 133 | { ActivateProfile AP(argv[1]); |
119 | if( AP.exec() == QDialog::Accepted ) { | 134 | if( AP.exec() == QDialog::Accepted ) { |
120 | Log(("%s-c%ld-allowed\n", | 135 | Log(("allow profile %ld for %s\n", |
121 | argv[1], AP.selectedProfile() )); | 136 | AP.selectedProfile(), argv[1] )); |
122 | printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); | 137 | printf( "A%ld%s\n", AP.selectedProfile(), argv[1] ); |
123 | } else { | 138 | } else { |
124 | Log(("%s-c%NN-disallowed\n", argv[1] )); | 139 | Log(("disallow %s\n", argv[1] )); |
125 | printf( "%s-cNN-disallowed", argv[1] ); | 140 | printf( "D-%s\n", argv[1] ); |
126 | } | 141 | } |
127 | } | 142 | } |
128 | break; | 143 | break; |
129 | case ACT_VPN : | 144 | case ACT_PROMPTVPN : |
130 | { ActivateVPN AVPN; | 145 | { ActivateVPN AVPN( argv[1] ); |
146 | Log(("Trigger vpns on interface %s\n", argv[1] )); | ||
131 | AVPN.exec(); | 147 | AVPN.exec(); |
132 | } | 148 | } |
133 | break; | 149 | break; |
134 | case ACT_GUI : | 150 | case ACT_GUI : |
135 | case ACT_OT : | 151 | case ACT_OT : |
136 | { QWidget * W; | 152 | { QWidget * W; |