Diffstat (limited to 'noncore/settings/networksettings2/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/main.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp new file mode 100644 index 0000000..bcef631 --- a/dev/null +++ b/noncore/settings/networksettings2/main.cpp | |||
@@ -0,0 +1,96 @@ | |||
1 | #include "networksettings.h" | ||
2 | #include <qpe/qpeapplication.h> | ||
3 | |||
4 | #include <opie/oapplicationfactory.h> | ||
5 | |||
6 | #ifdef GONE | ||
7 | |||
8 | OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) | ||
9 | |||
10 | #else | ||
11 | |||
12 | #define ACT_GUI 0 | ||
13 | #define ACT_REQUEST 1 | ||
14 | #define ACT_REGEN 2 | ||
15 | |||
16 | int main( int argc, char * argv[] ) { | ||
17 | int rv = 0; | ||
18 | int Action = ACT_GUI; | ||
19 | // could be overruled by -qws | ||
20 | QApplication::Type GuiType = QApplication::GuiClient; | ||
21 | |||
22 | #ifdef _WS_QWS_ | ||
23 | QPEApplication * TheApp; | ||
24 | #else | ||
25 | QApplication * TheApp; | ||
26 | #endif | ||
27 | |||
28 | for ( int i = 1; i < argc; i ++ ) { | ||
29 | int rmv; | ||
30 | rmv = 0; | ||
31 | if( strcmp( argv[i], "--regen" ) == 0 ) { | ||
32 | Action = ACT_REGEN; | ||
33 | GuiType = QApplication::Tty; | ||
34 | rmv = 1; | ||
35 | } | ||
36 | if( rmv ) { | ||
37 | memmove( argv+i, argv+i+rmv, | ||
38 | sizeof( char * ) * (argc-i-rmv) ); | ||
39 | i --; | ||
40 | argc -= rmv; | ||
41 | } | ||
42 | } | ||
43 | |||
44 | if( strstr( argv[0], "-request" ) ) { | ||
45 | // called from system to request something | ||
46 | GuiType = QApplication::Tty; | ||
47 | Action = ACT_REQUEST; | ||
48 | } | ||
49 | |||
50 | // Start Qt | ||
51 | #ifdef _WS_QWS_ | ||
52 | // because QPEApplication does not handle GuiType well | ||
53 | if( GuiType == QApplication::Tty ) { | ||
54 | // this cast is NOT correct but we do not use | ||
55 | // TheApp anymore ... | ||
56 | TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType ); | ||
57 | } else { | ||
58 | TheApp = new QPEApplication( argc, argv, GuiType ); | ||
59 | } | ||
60 | #else | ||
61 | TheApp = new QApplication( argc, argv, GuiType ); | ||
62 | #endif | ||
63 | |||
64 | // init qt with app widget | ||
65 | if( GuiType != QApplication::Tty ) { | ||
66 | QWidget * W = 0; | ||
67 | W = new NetworkSettings(0); | ||
68 | TheApp->setMainWidget( W ); | ||
69 | W->show(); | ||
70 | #ifdef _WS_QWS_ | ||
71 | W->showMaximized(); | ||
72 | #else | ||
73 | W->resize( W->sizeHint() ); | ||
74 | #endif | ||
75 | rv = TheApp->exec(); | ||
76 | delete W; | ||
77 | } else { | ||
78 | switch( Action ) { | ||
79 | case ACT_REQUEST : | ||
80 | NetworkSettings::canStart( argv[1] ); | ||
81 | break; | ||
82 | case ACT_REGEN : | ||
83 | // regen returns 0 if OK | ||
84 | rv = (NetworkSettings::regenerate()) ? 1 : 0; | ||
85 | break; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | return rv; | ||
90 | } | ||
91 | |||
92 | #endif | ||
93 | |||
94 | |||
95 | // main.cpp | ||
96 | |||