author | zecke <zecke> | 2004-03-14 18:16:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-14 18:16:11 (UTC) |
commit | 105a35c8e6f2ea63a074f9eb94336b6cbe065b04 (patch) (unidiff) | |
tree | 1756a1a026335b9767dd120285a4ebfee11e25a7 | |
parent | 9e54b8bd8343af7c301da17d82596d6027e53309 (diff) | |
download | opie-105a35c8e6f2ea63a074f9eb94336b6cbe065b04.zip opie-105a35c8e6f2ea63a074f9eb94336b6cbe065b04.tar.gz opie-105a35c8e6f2ea63a074f9eb94336b6cbe065b04.tar.bz2 |
Convert to ODP
-rw-r--r-- | core/opie-login/config.in | 2 | ||||
-rw-r--r-- | core/opie-login/loginwindowimpl.cpp | 26 | ||||
-rw-r--r-- | core/opie-login/main.cpp | 10 |
3 files changed, 19 insertions, 19 deletions
diff --git a/core/opie-login/config.in b/core/opie-login/config.in index 339b589..a71319c 100644 --- a/core/opie-login/config.in +++ b/core/opie-login/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config OPIE-LOGIN | 1 | config OPIE-LOGIN |
2 | boolean "opie-login (Initial Login app, ala xdm/kdm/gdm)" | 2 | boolean "opie-login (Initial Login app, ala xdm/kdm/gdm)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIECORE2 |
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp index e1b9360..32f98f3 100644 --- a/core/opie-login/loginwindowimpl.cpp +++ b/core/opie-login/loginwindowimpl.cpp | |||
@@ -1,250 +1,250 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | #include <qpe/version.h> | 27 | #include <qpe/version.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qtimer.h> | 31 | #include <qtimer.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #if QT_VERSION < 300 | 36 | #if QT_VERSION < 300 |
37 | #include <qgfx_qws.h> | 37 | #include <qgfx_qws.h> |
38 | #endif | 38 | #endif |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | 40 | ||
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
44 | 44 | ||
45 | #include <opie/odevice.h> | 45 | #include <opie2/odevice.h> |
46 | 46 | ||
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | 49 | ||
50 | #include "loginwindowimpl.h" | 50 | #include "loginwindowimpl.h" |
51 | #include "loginapplication.h" | 51 | #include "loginapplication.h" |
52 | #include "inputmethods.h" | 52 | #include "inputmethods.h" |
53 | 53 | ||
54 | using namespace Opie; | 54 | using namespace Opie::Core; |
55 | 55 | ||
56 | 56 | ||
57 | LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) | 57 | LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) |
58 | { | 58 | { |
59 | QPopupMenu *pop = new QPopupMenu ( this ); | 59 | QPopupMenu *pop = new QPopupMenu ( this ); |
60 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart())); | 60 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart())); |
61 | pop-> insertItem ( tr( "Quit" ), this, SLOT( quit())); | 61 | pop-> insertItem ( tr( "Quit" ), this, SLOT( quit())); |
62 | m_menu-> setPopup ( pop ); | 62 | m_menu-> setPopup ( pop ); |
63 | 63 | ||
64 | QCopChannel *channel = new QCopChannel ( "QPE/TaskBar", this ); | 64 | QCopChannel *channel = new QCopChannel ( "QPE/TaskBar", this ); |
65 | connect ( channel, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( receive(const QCString&,const QByteArray&))); | 65 | connect ( channel, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( receive(const QCString&,const QByteArray&))); |
66 | 66 | ||
67 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); | 67 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); |
68 | m_input = new InputMethods ( m_taskbar ); | 68 | m_input = new InputMethods ( m_taskbar ); |
69 | connect ( m_input, SIGNAL( inputToggled(bool)), this, SLOT( calcMaxWindowRect())); | 69 | connect ( m_input, SIGNAL( inputToggled(bool)), this, SLOT( calcMaxWindowRect())); |
70 | lay-> addWidget ( m_input ); | 70 | lay-> addWidget ( m_input ); |
71 | lay-> addStretch ( 10 ); | 71 | lay-> addStretch ( 10 ); |
72 | 72 | ||
73 | setActiveWindow ( ); | 73 | setActiveWindow ( ); |
74 | m_password-> setFocus ( ); | 74 | m_password-> setFocus ( ); |
75 | 75 | ||
76 | m_user-> insertStringList ( lApp-> allUsers ( )); | 76 | m_user-> insertStringList ( lApp-> allUsers ( )); |
77 | 77 | ||
78 | //there is no point in displaying the IM for a zaurus | 78 | //there is no point in displaying the IM for a zaurus |
79 | if (ODevice::inst ( )-> series ( ) != Model_Zaurus){ | 79 | if (ODevice::inst ( )-> series ( ) != Model_Zaurus){ |
80 | QTimer::singleShot ( 0, this, SLOT( showIM())); | 80 | QTimer::singleShot ( 0, this, SLOT( showIM())); |
81 | } | 81 | } |
82 | 82 | ||
83 | QString opiedir = ::getenv ( "OPIEDIR" ); | 83 | QString opiedir = ::getenv ( "OPIEDIR" ); |
84 | QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); | 84 | QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); |
85 | 85 | ||
86 | if ( !bgpix. isNull ( )) { | 86 | if ( !bgpix. isNull ( )) { |
87 | setBackgroundPixmap ( bgpix ); | 87 | setBackgroundPixmap ( bgpix ); |
88 | m_caption-> setBackgroundPixmap ( bgpix); | 88 | m_caption-> setBackgroundPixmap ( bgpix); |
89 | TextLabel1-> setBackgroundPixmap ( bgpix); | 89 | TextLabel1-> setBackgroundPixmap ( bgpix); |
90 | TextLabel2-> setBackgroundPixmap ( bgpix); | 90 | TextLabel2-> setBackgroundPixmap ( bgpix); |
91 | } | 91 | } |
92 | 92 | ||
93 | m_caption-> setText ( tr("<center>Welcome to OPIE %1</center><center>& %2 %3</center>"). arg(QPE_VERSION). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); | 93 | m_caption-> setText ( tr("<center>Welcome to OPIE %1</center><center>& %2 %3</center>"). arg(QPE_VERSION). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); |
94 | 94 | ||
95 | Config cfg ( "opie-login" ); | 95 | Config cfg ( "opie-login" ); |
96 | cfg. setGroup ( "General" ); | 96 | cfg. setGroup ( "General" ); |
97 | QString last = cfg. readEntry ( "LastLogin" ); | 97 | QString last = cfg. readEntry ( "LastLogin" ); |
98 | 98 | ||
99 | if ( !last. isEmpty ( )) | 99 | if ( !last. isEmpty ( )) |
100 | m_user-> setEditText ( last ); | 100 | m_user-> setEditText ( last ); |
101 | 101 | ||
102 | calcMaxWindowRect ( ); | 102 | calcMaxWindowRect ( ); |
103 | } | 103 | } |
104 | 104 | ||
105 | LoginWindowImpl::~LoginWindowImpl ( ) | 105 | LoginWindowImpl::~LoginWindowImpl ( ) |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data ) | 110 | void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data ) |
111 | { | 111 | { |
112 | QDataStream stream ( data, IO_ReadOnly ); | 112 | QDataStream stream ( data, IO_ReadOnly ); |
113 | 113 | ||
114 | if ( msg == "hideInputMethod()" ) | 114 | if ( msg == "hideInputMethod()" ) |
115 | m_input-> hideInputMethod ( ); | 115 | m_input-> hideInputMethod ( ); |
116 | else if ( msg == "showInputMethod()" ) | 116 | else if ( msg == "showInputMethod()" ) |
117 | m_input-> showInputMethod ( ); | 117 | m_input-> showInputMethod ( ); |
118 | else if ( msg == "reloadInputMethods()" ) | 118 | else if ( msg == "reloadInputMethods()" ) |
119 | m_input-> loadInputMethods ( ); | 119 | m_input-> loadInputMethods ( ); |
120 | } | 120 | } |
121 | 121 | ||
122 | void LoginWindowImpl::calcMaxWindowRect ( ) | 122 | void LoginWindowImpl::calcMaxWindowRect ( ) |
123 | { | 123 | { |
124 | #ifdef Q_WS_QWS | 124 | #ifdef Q_WS_QWS |
125 | QRect wr; | 125 | QRect wr; |
126 | int displayWidth = qApp-> desktop ( )-> width ( ); | 126 | int displayWidth = qApp-> desktop ( )-> width ( ); |
127 | QRect ir = m_input-> inputRect ( ); | 127 | QRect ir = m_input-> inputRect ( ); |
128 | if ( ir.isValid() ) | 128 | if ( ir.isValid() ) |
129 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); | 129 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); |
130 | else | 130 | else |
131 | wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 ); | 131 | wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 ); |
132 | 132 | ||
133 | #if QT_VERSION < 300 | 133 | #if QT_VERSION < 300 |
134 | wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 134 | wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
135 | #endif | 135 | #endif |
136 | 136 | ||
137 | QWSServer::setMaxWindowRect( wr ); | 137 | QWSServer::setMaxWindowRect( wr ); |
138 | #endif | 138 | #endif |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) | 142 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) |
143 | { | 143 | { |
144 | switch ( e-> key ( )) { | 144 | switch ( e-> key ( )) { |
145 | case HardKey_Suspend: suspend ( ); | 145 | case HardKey_Suspend: suspend ( ); |
146 | break; | 146 | break; |
147 | case HardKey_Backlight: backlight ( ); | 147 | case HardKey_Backlight: backlight ( ); |
148 | break; | 148 | break; |
149 | default: e-> ignore ( ); | 149 | default: e-> ignore ( ); |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | LoginWindow::keyPressEvent ( e ); | 152 | LoginWindow::keyPressEvent ( e ); |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | void LoginWindowImpl::toggleEchoMode ( bool t ) | 156 | void LoginWindowImpl::toggleEchoMode ( bool t ) |
157 | { | 157 | { |
158 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); | 158 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); |
159 | } | 159 | } |
160 | 160 | ||
161 | void LoginWindowImpl::showIM ( ) | 161 | void LoginWindowImpl::showIM ( ) |
162 | { | 162 | { |
163 | m_input-> showInputMethod ( ); | 163 | m_input-> showInputMethod ( ); |
164 | } | 164 | } |
165 | 165 | ||
166 | void LoginWindowImpl::restart ( ) | 166 | void LoginWindowImpl::restart ( ) |
167 | { | 167 | { |
168 | qApp-> quit ( ); | 168 | qApp-> quit ( ); |
169 | } | 169 | } |
170 | 170 | ||
171 | void LoginWindowImpl::quit ( ) | 171 | void LoginWindowImpl::quit ( ) |
172 | { | 172 | { |
173 | lApp-> quitToConsole ( ); | 173 | lApp-> quitToConsole ( ); |
174 | } | 174 | } |
175 | 175 | ||
176 | void LoginWindowImpl::suspend ( ) | 176 | void LoginWindowImpl::suspend ( ) |
177 | { | 177 | { |
178 | ODevice::inst ( )-> suspend ( ); | 178 | ODevice::inst ( )-> suspend ( ); |
179 | 179 | ||
180 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 180 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
181 | e << -3; // Force on | 181 | e << -3; // Force on |
182 | } | 182 | } |
183 | 183 | ||
184 | void LoginWindowImpl::backlight ( ) | 184 | void LoginWindowImpl::backlight ( ) |
185 | { | 185 | { |
186 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 186 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
187 | e << -2; // toggle | 187 | e << -2; // toggle |
188 | } | 188 | } |
189 | 189 | ||
190 | class WaitLogo : public QLabel { | 190 | class WaitLogo : public QLabel { |
191 | public: | 191 | public: |
192 | WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) | 192 | WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) |
193 | { | 193 | { |
194 | QImage img = Resource::loadImage ( "launcher/new_wait" ); | 194 | QImage img = Resource::loadImage ( "launcher/new_wait" ); |
195 | QPixmap pix; | 195 | QPixmap pix; |
196 | pix. convertFromImage ( img ); | 196 | pix. convertFromImage ( img ); |
197 | setPixmap ( pix ); | 197 | setPixmap ( pix ); |
198 | setAlignment ( AlignCenter ); | 198 | setAlignment ( AlignCenter ); |
199 | move ( 0, 0 ); | 199 | move ( 0, 0 ); |
200 | resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); | 200 | resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); |
201 | 201 | ||
202 | m_visible = false; | 202 | m_visible = false; |
203 | show ( ); | 203 | show ( ); |
204 | } | 204 | } |
205 | 205 | ||
206 | virtual void showEvent ( QShowEvent *e ) | 206 | virtual void showEvent ( QShowEvent *e ) |
207 | { | 207 | { |
208 | QLabel::showEvent ( e ); | 208 | QLabel::showEvent ( e ); |
209 | m_visible = true; | 209 | m_visible = true; |
210 | } | 210 | } |
211 | 211 | ||
212 | virtual void paintEvent ( QPaintEvent *e ) | 212 | virtual void paintEvent ( QPaintEvent *e ) |
213 | { | 213 | { |
214 | QLabel::paintEvent ( e ); | 214 | QLabel::paintEvent ( e ); |
215 | if ( m_visible ) | 215 | if ( m_visible ) |
216 | qApp-> quit ( ); | 216 | qApp-> quit ( ); |
217 | } | 217 | } |
218 | 218 | ||
219 | private: | 219 | private: |
220 | bool m_visible; | 220 | bool m_visible; |
221 | }; | 221 | }; |
222 | 222 | ||
223 | void LoginWindowImpl::login ( ) | 223 | void LoginWindowImpl::login ( ) |
224 | { | 224 | { |
225 | const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); | 225 | const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); |
226 | const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); | 226 | const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); |
227 | 227 | ||
228 | if ( !user || !user [0] ) | 228 | if ( !user || !user [0] ) |
229 | return; | 229 | return; |
230 | if ( !pass ) | 230 | if ( !pass ) |
231 | pass = ""; | 231 | pass = ""; |
232 | 232 | ||
233 | if ( lApp-> checkPassword ( user, pass )) { | 233 | if ( lApp-> checkPassword ( user, pass )) { |
234 | Config cfg ( "opie-login" ); | 234 | Config cfg ( "opie-login" ); |
235 | cfg. setGroup ( "General" ); | 235 | cfg. setGroup ( "General" ); |
236 | cfg. writeEntry ( "LastLogin", user ); | 236 | cfg. writeEntry ( "LastLogin", user ); |
237 | cfg. write ( ); | 237 | cfg. write ( ); |
238 | 238 | ||
239 | lApp-> setLoginAs ( user ); | 239 | lApp-> setLoginAs ( user ); |
240 | 240 | ||
241 | // Draw a big wait icon, the image can be altered in later revisions | 241 | // Draw a big wait icon, the image can be altered in later revisions |
242 | m_input-> hideInputMethod ( ); | 242 | m_input-> hideInputMethod ( ); |
243 | new WaitLogo ( ); | 243 | new WaitLogo ( ); |
244 | // WaitLogo::showEvent() calls qApp-> quit() | 244 | // WaitLogo::showEvent() calls qApp-> quit() |
245 | } | 245 | } |
246 | else { | 246 | else { |
247 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); | 247 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); |
248 | m_password-> clear ( ); | 248 | m_password-> clear ( ); |
249 | } | 249 | } |
250 | } | 250 | } |
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp index 6aa7287..f0a8ba2 100644 --- a/core/opie-login/main.cpp +++ b/core/opie-login/main.cpp | |||
@@ -1,383 +1,383 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This file is free software; you can | 5 | _;:, .> :=|. This file is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "loginapplication.h" | 28 | #include "loginapplication.h" |
29 | #include "loginwindowimpl.h" | 29 | #include "loginwindowimpl.h" |
30 | #include "calibrate.h" | 30 | #include "calibrate.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/odevice.h> | 33 | #include <opie2/odevice.h> |
34 | #include <qpe/qpestyle.h> | 34 | #include <qpe/qpestyle.h> |
35 | #include <qpe/power.h> | 35 | #include <qpe/power.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qfile.h> | 43 | #include <qfile.h> |
44 | 44 | ||
45 | /* STD */ | 45 | /* STD */ |
46 | #include <sys/types.h> | 46 | #include <sys/types.h> |
47 | #include <time.h> | 47 | #include <time.h> |
48 | #include <sys/time.h> | 48 | #include <sys/time.h> |
49 | #include <sys/resource.h> | 49 | #include <sys/resource.h> |
50 | #include <unistd.h> | 50 | #include <unistd.h> |
51 | #include <syslog.h> | 51 | #include <syslog.h> |
52 | #include <sys/wait.h> | 52 | #include <sys/wait.h> |
53 | #include <stdio.h> | 53 | #include <stdio.h> |
54 | #include <stdlib.h> | 54 | #include <stdlib.h> |
55 | #include <signal.h> | 55 | #include <signal.h> |
56 | #include <getopt.h> | 56 | #include <getopt.h> |
57 | #include <string.h> | 57 | #include <string.h> |
58 | 58 | ||
59 | using namespace Opie; | 59 | using namespace Opie::Core; |
60 | 60 | ||
61 | int login_main ( int argc, char **argv, pid_t ppid ); | 61 | int login_main ( int argc, char **argv, pid_t ppid ); |
62 | void sigterm ( int sig ); | 62 | void sigterm ( int sig ); |
63 | void sigint ( int sig ); | 63 | void sigint ( int sig ); |
64 | void exit_closelog ( ); | 64 | void exit_closelog ( ); |
65 | 65 | ||
66 | static struct option long_options [] = { | 66 | static struct option long_options [] = { |
67 | { "autologin", 1, 0, 'a' }, | 67 | { "autologin", 1, 0, 'a' }, |
68 | { 0, 0, 0, 0 } | 68 | { 0, 0, 0, 0 } |
69 | }; | 69 | }; |
70 | 70 | ||
71 | 71 | ||
72 | int main ( int argc, char **argv ) | 72 | int main ( int argc, char **argv ) |
73 | { | 73 | { |
74 | int userExited = 0; | 74 | int userExited = 0; |
75 | pid_t ppid = ::getpid ( ); | 75 | pid_t ppid = ::getpid ( ); |
76 | 76 | ||
77 | if ( ::geteuid ( ) != 0 ) { | 77 | if ( ::geteuid ( ) != 0 ) { |
78 | ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); | 78 | ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); |
79 | return 1; | 79 | return 1; |
80 | } | 80 | } |
81 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and | 81 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and |
82 | ::setuid ( 0 ); // messes up things like config files | 82 | ::setuid ( 0 ); // messes up things like config files |
83 | 83 | ||
84 | char *autolog = 0; | 84 | char *autolog = 0; |
85 | int c; | 85 | int c; |
86 | while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { | 86 | while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { |
87 | switch ( c ) { | 87 | switch ( c ) { |
88 | case 'a': | 88 | case 'a': |
89 | autolog = optarg; | 89 | autolog = optarg; |
90 | break; | 90 | break; |
91 | default: | 91 | default: |
92 | ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); | 92 | ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); |
93 | return 2; | 93 | return 2; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | //struct rlimit rl; | 97 | //struct rlimit rl; |
98 | //::getrlimit ( RLIMIT_NOFILE, &rl ); | 98 | //::getrlimit ( RLIMIT_NOFILE, &rl ); |
99 | 99 | ||
100 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) | 100 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) |
101 | // ::close ( i ); | 101 | // ::close ( i ); |
102 | 102 | ||
103 | ::setpgid ( 0, 0 ); | 103 | ::setpgid ( 0, 0 ); |
104 | ::setsid ( ); | 104 | ::setsid ( ); |
105 | 105 | ||
106 | ::signal ( SIGTERM, sigterm ); | 106 | ::signal ( SIGTERM, sigterm ); |
107 | ::signal ( SIGINT, sigterm ); | 107 | ::signal ( SIGINT, sigterm ); |
108 | 108 | ||
109 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); | 109 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); |
110 | ::atexit ( exit_closelog ); | 110 | ::atexit ( exit_closelog ); |
111 | 111 | ||
112 | while ( true ) { | 112 | while ( true ) { |
113 | pid_t child = ::fork ( ); | 113 | pid_t child = ::fork ( ); |
114 | 114 | ||
115 | if ( child < 0 ) { | 115 | if ( child < 0 ) { |
116 | ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); | 116 | ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); |
117 | break; | 117 | break; |
118 | } | 118 | } |
119 | else if ( child > 0 ) { | 119 | else if ( child > 0 ) { |
120 | int status = 0; | 120 | int status = 0; |
121 | time_t started = ::time ( 0 ); | 121 | time_t started = ::time ( 0 ); |
122 | 122 | ||
123 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } | 123 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } |
124 | 124 | ||
125 | LoginApplication::logout ( ); | 125 | LoginApplication::logout ( ); |
126 | 126 | ||
127 | if (( ::time ( 0 ) - started ) < 3 ) { | 127 | if (( ::time ( 0 ) - started ) < 3 ) { |
128 | if ( autolog ) { | 128 | if ( autolog ) { |
129 | ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); | 129 | ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); |
130 | autolog = 0; | 130 | autolog = 0; |
131 | } | 131 | } |
132 | else { | 132 | else { |
133 | ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); | 133 | ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | } | 136 | } |
137 | int killedbysig = 0; | 137 | int killedbysig = 0; |
138 | userExited=0; | 138 | userExited=0; |
139 | if (WIFEXITED(status)!=0 ) { | 139 | if (WIFEXITED(status)!=0 ) { |
140 | if (WEXITSTATUS(status)==137) { | 140 | if (WEXITSTATUS(status)==137) { |
141 | userExited=1; | 141 | userExited=1; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | if ( WIFSIGNALED( status )) { | 145 | if ( WIFSIGNALED( status )) { |
146 | switch ( WTERMSIG( status )) { | 146 | switch ( WTERMSIG( status )) { |
147 | case SIGTERM: | 147 | case SIGTERM: |
148 | case SIGINT : | 148 | case SIGINT : |
149 | case SIGKILL: | 149 | case SIGKILL: |
150 | break; | 150 | break; |
151 | 151 | ||
152 | default : | 152 | default : |
153 | killedbysig = WTERMSIG( status ); | 153 | killedbysig = WTERMSIG( status ); |
154 | break; | 154 | break; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | if ( killedbysig ) { // qpe was killed by an uncaught signal | 157 | if ( killedbysig ) { // qpe was killed by an uncaught signal |
158 | qApp = 0; | 158 | qApp = 0; |
159 | 159 | ||
160 | ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); | 160 | ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); |
161 | 161 | ||
162 | QWSServer::setDesktopBackground ( QImage ( )); | 162 | QWSServer::setDesktopBackground ( QImage ( )); |
163 | QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); | 163 | QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); |
164 | app-> setFont ( QFont ( "Helvetica", 10 )); | 164 | app-> setFont ( QFont ( "Helvetica", 10 )); |
165 | app-> setStyle ( new QPEStyle ( )); | 165 | app-> setStyle ( new QPEStyle ( )); |
166 | 166 | ||
167 | // const char *sig = ::strsignal ( killedbysig ); | 167 | // const char *sig = ::strsignal ( killedbysig ); |
168 | const char *sig = ::sys_siglist[killedbysig]; | 168 | const char *sig = ::sys_siglist[killedbysig]; |
169 | QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); | 169 | QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); |
170 | l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); | 170 | l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); |
171 | l-> setAlignment ( Qt::AlignCenter ); | 171 | l-> setAlignment ( Qt::AlignCenter ); |
172 | l-> move ( 0, 0 ); | 172 | l-> move ( 0, 0 ); |
173 | l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); | 173 | l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); |
174 | l-> show ( ); | 174 | l-> show ( ); |
175 | QTimer::singleShot ( 3000, app, SLOT( quit())); | 175 | QTimer::singleShot ( 3000, app, SLOT( quit())); |
176 | app-> exec ( ); | 176 | app-> exec ( ); |
177 | delete app; | 177 | delete app; |
178 | qApp = 0; | 178 | qApp = 0; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | else { | 181 | else { |
182 | if ( !autolog ) { | 182 | if ( !autolog ) { |
183 | QString confFile=QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 183 | QString confFile=QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
184 | Config cfg ( confFile, Config::File ); | 184 | Config cfg ( confFile, Config::File ); |
185 | cfg. setGroup ( "General" ); | 185 | cfg. setGroup ( "General" ); |
186 | QString user = cfg. readEntry ( "AutoLogin" ); | 186 | QString user = cfg. readEntry ( "AutoLogin" ); |
187 | 187 | ||
188 | if ( !user. isEmpty ( )) | 188 | if ( !user. isEmpty ( )) |
189 | autolog = ::strdup ( user. latin1 ( )); | 189 | autolog = ::strdup ( user. latin1 ( )); |
190 | } | 190 | } |
191 | 191 | ||
192 | if ( autolog && !userExited ) { | 192 | if ( autolog && !userExited ) { |
193 | 193 | ||
194 | QWSServer::setDesktopBackground( QImage() ); | 194 | QWSServer::setDesktopBackground( QImage() ); |
195 | ODevice::inst ( )-> setDisplayStatus ( true ); | 195 | ODevice::inst ( )-> setDisplayStatus ( true ); |
196 | ODevice::inst ( )-> setSoftSuspend ( false ); | 196 | ODevice::inst ( )-> setSoftSuspend ( false ); |
197 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); | 197 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); |
198 | LoginApplication::setLoginAs ( autolog ); | 198 | LoginApplication::setLoginAs ( autolog ); |
199 | 199 | ||
200 | 200 | ||
201 | if ( LoginApplication::changeIdentity ( )) | 201 | if ( LoginApplication::changeIdentity ( )) |
202 | ::exit ( LoginApplication::login ( )); | 202 | ::exit ( LoginApplication::login ( )); |
203 | else | 203 | else |
204 | ::exit ( 0 ); | 204 | ::exit ( 0 ); |
205 | } | 205 | } |
206 | else { | 206 | else { |
207 | ::exit ( login_main ( argc, argv, ppid )); | 207 | ::exit ( login_main ( argc, argv, ppid )); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | } | 210 | } |
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | 213 | ||
214 | void sigterm ( int /*sig*/ ) | 214 | void sigterm ( int /*sig*/ ) |
215 | { | 215 | { |
216 | ::exit ( 0 ); | 216 | ::exit ( 0 ); |
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | void exit_closelog ( ) | 220 | void exit_closelog ( ) |
221 | { | 221 | { |
222 | ::closelog ( ); | 222 | ::closelog ( ); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | class LoginScreenSaver : public QWSScreenSaver | 226 | class LoginScreenSaver : public QWSScreenSaver |
227 | { | 227 | { |
228 | public: | 228 | public: |
229 | LoginScreenSaver ( ) | 229 | LoginScreenSaver ( ) |
230 | { | 230 | { |
231 | m_lcd_status = true; | 231 | m_lcd_status = true; |
232 | 232 | ||
233 | m_backlight_bright = -1; | 233 | m_backlight_bright = -1; |
234 | m_backlight_forcedoff = false; | 234 | m_backlight_forcedoff = false; |
235 | 235 | ||
236 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 236 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
237 | ODevice::inst ( )-> setDisplayStatus ( true ); | 237 | ODevice::inst ( )-> setDisplayStatus ( true ); |
238 | } | 238 | } |
239 | void restore() | 239 | void restore() |
240 | { | 240 | { |
241 | if ( !m_lcd_status ) // We must have turned it off | 241 | if ( !m_lcd_status ) // We must have turned it off |
242 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 242 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
243 | 243 | ||
244 | setBacklight ( -3 ); | 244 | setBacklight ( -3 ); |
245 | } | 245 | } |
246 | bool save( int level ) | 246 | bool save( int level ) |
247 | { | 247 | { |
248 | switch ( level ) { | 248 | switch ( level ) { |
249 | case 0: | 249 | case 0: |
250 | if ( backlight() > 1 ) | 250 | if ( backlight() > 1 ) |
251 | setBacklight( 1 ); // lowest non-off | 251 | setBacklight( 1 ); // lowest non-off |
252 | return true; | 252 | return true; |
253 | break; | 253 | break; |
254 | case 1: | 254 | case 1: |
255 | setBacklight( 0 ); // off | 255 | setBacklight( 0 ); // off |
256 | return true; | 256 | return true; |
257 | break; | 257 | break; |
258 | case 2: | 258 | case 2: |
259 | // We're going to suspend the whole machine | 259 | // We're going to suspend the whole machine |
260 | if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { | 260 | if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { |
261 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 261 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
262 | return true; | 262 | return true; |
263 | } | 263 | } |
264 | break; | 264 | break; |
265 | } | 265 | } |
266 | return false; | 266 | return false; |
267 | } | 267 | } |
268 | 268 | ||
269 | private: | 269 | private: |
270 | public: | 270 | public: |
271 | void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) | 271 | void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) |
272 | { | 272 | { |
273 | int v [4]; | 273 | int v [4]; |
274 | 274 | ||
275 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 275 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
276 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | 276 | v [ 1 ] = QMAX( 1000 * i2, 100 ); |
277 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | 277 | v [ 2 ] = QMAX( 1000 * i3, 100 ); |
278 | v [ 3 ] = 0; | 278 | v [ 3 ] = 0; |
279 | 279 | ||
280 | if ( !i1 && !i2 && !i3 ) | 280 | if ( !i1 && !i2 && !i3 ) |
281 | QWSServer::setScreenSaverInterval ( 0 ); | 281 | QWSServer::setScreenSaverInterval ( 0 ); |
282 | else | 282 | else |
283 | QWSServer::setScreenSaverIntervals ( v ); | 283 | QWSServer::setScreenSaverIntervals ( v ); |
284 | } | 284 | } |
285 | 285 | ||
286 | int backlight ( ) | 286 | int backlight ( ) |
287 | { | 287 | { |
288 | if ( m_backlight_bright == -1 ) | 288 | if ( m_backlight_bright == -1 ) |
289 | m_backlight_bright = 255; | 289 | m_backlight_bright = 255; |
290 | 290 | ||
291 | return m_backlight_bright; | 291 | return m_backlight_bright; |
292 | } | 292 | } |
293 | 293 | ||
294 | void setBacklight ( int bright ) | 294 | void setBacklight ( int bright ) |
295 | { | 295 | { |
296 | if ( bright == -3 ) { | 296 | if ( bright == -3 ) { |
297 | // Forced on | 297 | // Forced on |
298 | m_backlight_forcedoff = false; | 298 | m_backlight_forcedoff = false; |
299 | bright = -1; | 299 | bright = -1; |
300 | } | 300 | } |
301 | if ( m_backlight_forcedoff && bright != -2 ) | 301 | if ( m_backlight_forcedoff && bright != -2 ) |
302 | return ; | 302 | return ; |
303 | if ( bright == -2 ) { | 303 | if ( bright == -2 ) { |
304 | // Toggle between off and on | 304 | // Toggle between off and on |
305 | bright = m_backlight_bright ? 0 : -1; | 305 | bright = m_backlight_bright ? 0 : -1; |
306 | m_backlight_forcedoff = !bright; | 306 | m_backlight_forcedoff = !bright; |
307 | } | 307 | } |
308 | 308 | ||
309 | m_backlight_bright = bright; | 309 | m_backlight_bright = bright; |
310 | 310 | ||
311 | bright = backlight ( ); | 311 | bright = backlight ( ); |
312 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 312 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); |
313 | 313 | ||
314 | m_backlight_bright = bright; | 314 | m_backlight_bright = bright; |
315 | } | 315 | } |
316 | 316 | ||
317 | private: | 317 | private: |
318 | bool m_lcd_status; | 318 | bool m_lcd_status; |
319 | 319 | ||
320 | int m_backlight_bright; | 320 | int m_backlight_bright; |
321 | bool m_backlight_forcedoff; | 321 | bool m_backlight_forcedoff; |
322 | }; | 322 | }; |
323 | 323 | ||
324 | 324 | ||
325 | namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting | 325 | namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting |
326 | 326 | ||
327 | 327 | ||
328 | int login_main ( int argc, char **argv, pid_t ppid ) | 328 | int login_main ( int argc, char **argv, pid_t ppid ) |
329 | { | 329 | { |
330 | QWSServer::setDesktopBackground( QImage() ); | 330 | QWSServer::setDesktopBackground( QImage() ); |
331 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); | 331 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); |
332 | 332 | ||
333 | Opie::force_appearance = 0; | 333 | Opie::force_appearance = 0; |
334 | 334 | ||
335 | app-> setFont ( QFont ( "Helvetica", 10 )); | 335 | app-> setFont ( QFont ( "Helvetica", 10 )); |
336 | app-> setStyle ( new QPEStyle ( )); | 336 | app-> setStyle ( new QPEStyle ( )); |
337 | 337 | ||
338 | ODevice::inst ( )-> setSoftSuspend ( true ); | 338 | ODevice::inst ( )-> setSoftSuspend ( true ); |
339 | 339 | ||
340 | if ( QWSServer::mouseHandler() && | 340 | if ( QWSServer::mouseHandler() && |
341 | QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { | 341 | QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { |
342 | if ( !QFile::exists ( "/etc/pointercal" )) { | 342 | if ( !QFile::exists ( "/etc/pointercal" )) { |
343 | // Make sure calibration widget starts on top. | 343 | // Make sure calibration widget starts on top. |
344 | Calibrate *cal = new Calibrate; | 344 | Calibrate *cal = new Calibrate; |
345 | cal-> exec ( ); | 345 | cal-> exec ( ); |
346 | delete cal; | 346 | delete cal; |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | LoginScreenSaver *saver = new LoginScreenSaver; | 350 | LoginScreenSaver *saver = new LoginScreenSaver; |
351 | 351 | ||
352 | saver-> setIntervals ( ); | 352 | saver-> setIntervals ( ); |
353 | QWSServer::setScreenSaver ( saver ); | 353 | QWSServer::setScreenSaver ( saver ); |
354 | saver-> restore ( ); | 354 | saver-> restore ( ); |
355 | 355 | ||
356 | 356 | ||
357 | LoginWindowImpl *lw = new LoginWindowImpl ( ); | 357 | LoginWindowImpl *lw = new LoginWindowImpl ( ); |
358 | app-> setMainWidget ( lw ); | 358 | app-> setMainWidget ( lw ); |
359 | lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); | 359 | lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); |
360 | lw-> show ( ); | 360 | lw-> show ( ); |
361 | 361 | ||
362 | int rc = app-> exec ( ); | 362 | int rc = app-> exec ( ); |
363 | 363 | ||
364 | ODevice::inst ( )-> setSoftSuspend ( false ); | 364 | ODevice::inst ( )-> setSoftSuspend ( false ); |
365 | 365 | ||
366 | if ( app-> loginAs ( )) { | 366 | if ( app-> loginAs ( )) { |
367 | if ( app-> changeIdentity ( )) { | 367 | if ( app-> changeIdentity ( )) { |
368 | app-> login ( ); | 368 | app-> login ( ); |
369 | 369 | ||
370 | // if login succeeds, it never comes back | 370 | // if login succeeds, it never comes back |
371 | 371 | ||
372 | QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." )); | 372 | QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." )); |
373 | rc = 1; | 373 | rc = 1; |
374 | } | 374 | } |
375 | else { | 375 | else { |
376 | QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); | 376 | QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); |
377 | rc = 2; | 377 | rc = 2; |
378 | } | 378 | } |
379 | 379 | ||
380 | } | 380 | } |
381 | return rc; | 381 | return rc; |
382 | } | 382 | } |
383 | 383 | ||