author | sandman <sandman> | 2002-10-06 22:19:48 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-06 22:19:48 (UTC) |
commit | 685c08f1c48813f9d222446f0516b8e20635607e (patch) (unidiff) | |
tree | 52792fd22ebaa26ee82ac500c0250d6ffea941f8 | |
parent | a60fbe6f441b906489984b0dbc239259adacdcbc (diff) | |
download | opie-685c08f1c48813f9d222446f0516b8e20635607e.zip opie-685c08f1c48813f9d222446f0516b8e20635607e.tar.gz opie-685c08f1c48813f9d222446f0516b8e20635607e.tar.bz2 |
- password line-edit now gets focus on user change
- the "OPIE - please wait" logo is displayed while the launcher is loading
-rw-r--r-- | core/opie-login/loginwindow.ui | 6 | ||||
-rw-r--r-- | core/opie-login/loginwindowimpl.cpp | 19 |
2 files changed, 25 insertions, 0 deletions
diff --git a/core/opie-login/loginwindow.ui b/core/opie-login/loginwindow.ui index edd0819..5a35c8d 100644 --- a/core/opie-login/loginwindow.ui +++ b/core/opie-login/loginwindow.ui | |||
@@ -152,261 +152,267 @@ | |||
152 | </widget> | 152 | </widget> |
153 | <widget row="1" column="1" > | 153 | <widget row="1" column="1" > |
154 | <class>QLayoutWidget</class> | 154 | <class>QLayoutWidget</class> |
155 | <property stdset="1"> | 155 | <property stdset="1"> |
156 | <name>name</name> | 156 | <name>name</name> |
157 | <cstring>Layout5</cstring> | 157 | <cstring>Layout5</cstring> |
158 | </property> | 158 | </property> |
159 | <property> | 159 | <property> |
160 | <name>layoutSpacing</name> | 160 | <name>layoutSpacing</name> |
161 | </property> | 161 | </property> |
162 | <hbox> | 162 | <hbox> |
163 | <property stdset="1"> | 163 | <property stdset="1"> |
164 | <name>margin</name> | 164 | <name>margin</name> |
165 | <number>0</number> | 165 | <number>0</number> |
166 | </property> | 166 | </property> |
167 | <property stdset="1"> | 167 | <property stdset="1"> |
168 | <name>spacing</name> | 168 | <name>spacing</name> |
169 | <number>4</number> | 169 | <number>4</number> |
170 | </property> | 170 | </property> |
171 | <widget> | 171 | <widget> |
172 | <class>QLineEdit</class> | 172 | <class>QLineEdit</class> |
173 | <property stdset="1"> | 173 | <property stdset="1"> |
174 | <name>name</name> | 174 | <name>name</name> |
175 | <cstring>m_password</cstring> | 175 | <cstring>m_password</cstring> |
176 | </property> | 176 | </property> |
177 | <property stdset="1"> | 177 | <property stdset="1"> |
178 | <name>autoMask</name> | 178 | <name>autoMask</name> |
179 | <bool>true</bool> | 179 | <bool>true</bool> |
180 | </property> | 180 | </property> |
181 | <property stdset="1"> | 181 | <property stdset="1"> |
182 | <name>echoMode</name> | 182 | <name>echoMode</name> |
183 | <enum>Password</enum> | 183 | <enum>Password</enum> |
184 | </property> | 184 | </property> |
185 | </widget> | 185 | </widget> |
186 | <widget> | 186 | <widget> |
187 | <class>QToolButton</class> | 187 | <class>QToolButton</class> |
188 | <property stdset="1"> | 188 | <property stdset="1"> |
189 | <name>name</name> | 189 | <name>name</name> |
190 | <cstring>ToolButton3</cstring> | 190 | <cstring>ToolButton3</cstring> |
191 | </property> | 191 | </property> |
192 | <property stdset="1"> | 192 | <property stdset="1"> |
193 | <name>text</name> | 193 | <name>text</name> |
194 | <string></string> | 194 | <string></string> |
195 | </property> | 195 | </property> |
196 | <property stdset="1"> | 196 | <property stdset="1"> |
197 | <name>pixmap</name> | 197 | <name>pixmap</name> |
198 | <pixmap>image0</pixmap> | 198 | <pixmap>image0</pixmap> |
199 | </property> | 199 | </property> |
200 | <property stdset="1"> | 200 | <property stdset="1"> |
201 | <name>toggleButton</name> | 201 | <name>toggleButton</name> |
202 | <bool>true</bool> | 202 | <bool>true</bool> |
203 | </property> | 203 | </property> |
204 | <property stdset="1"> | 204 | <property stdset="1"> |
205 | <name>toggleButton</name> | 205 | <name>toggleButton</name> |
206 | <bool>true</bool> | 206 | <bool>true</bool> |
207 | </property> | 207 | </property> |
208 | </widget> | 208 | </widget> |
209 | <widget> | 209 | <widget> |
210 | <class>QToolButton</class> | 210 | <class>QToolButton</class> |
211 | <property stdset="1"> | 211 | <property stdset="1"> |
212 | <name>name</name> | 212 | <name>name</name> |
213 | <cstring>ToolButton1</cstring> | 213 | <cstring>ToolButton1</cstring> |
214 | </property> | 214 | </property> |
215 | <property stdset="1"> | 215 | <property stdset="1"> |
216 | <name>text</name> | 216 | <name>text</name> |
217 | <string></string> | 217 | <string></string> |
218 | </property> | 218 | </property> |
219 | <property stdset="1"> | 219 | <property stdset="1"> |
220 | <name>pixmap</name> | 220 | <name>pixmap</name> |
221 | <pixmap>image1</pixmap> | 221 | <pixmap>image1</pixmap> |
222 | </property> | 222 | </property> |
223 | </widget> | 223 | </widget> |
224 | </hbox> | 224 | </hbox> |
225 | </widget> | 225 | </widget> |
226 | <widget row="1" column="0" > | 226 | <widget row="1" column="0" > |
227 | <class>QLabel</class> | 227 | <class>QLabel</class> |
228 | <property stdset="1"> | 228 | <property stdset="1"> |
229 | <name>name</name> | 229 | <name>name</name> |
230 | <cstring>TextLabel2</cstring> | 230 | <cstring>TextLabel2</cstring> |
231 | </property> | 231 | </property> |
232 | <property stdset="1"> | 232 | <property stdset="1"> |
233 | <name>autoMask</name> | 233 | <name>autoMask</name> |
234 | <bool>true</bool> | 234 | <bool>true</bool> |
235 | </property> | 235 | </property> |
236 | <property stdset="1"> | 236 | <property stdset="1"> |
237 | <name>backgroundOrigin</name> | 237 | <name>backgroundOrigin</name> |
238 | <enum>ParentOrigin</enum> | 238 | <enum>ParentOrigin</enum> |
239 | </property> | 239 | </property> |
240 | <property stdset="1"> | 240 | <property stdset="1"> |
241 | <name>text</name> | 241 | <name>text</name> |
242 | <string>Password</string> | 242 | <string>Password</string> |
243 | </property> | 243 | </property> |
244 | </widget> | 244 | </widget> |
245 | </grid> | 245 | </grid> |
246 | </widget> | 246 | </widget> |
247 | <widget> | 247 | <widget> |
248 | <class>Line</class> | 248 | <class>Line</class> |
249 | <property stdset="1"> | 249 | <property stdset="1"> |
250 | <name>name</name> | 250 | <name>name</name> |
251 | <cstring>Line1</cstring> | 251 | <cstring>Line1</cstring> |
252 | </property> | 252 | </property> |
253 | <property stdset="1"> | 253 | <property stdset="1"> |
254 | <name>orientation</name> | 254 | <name>orientation</name> |
255 | <enum>Horizontal</enum> | 255 | <enum>Horizontal</enum> |
256 | </property> | 256 | </property> |
257 | </widget> | 257 | </widget> |
258 | <widget> | 258 | <widget> |
259 | <class>QLayoutWidget</class> | 259 | <class>QLayoutWidget</class> |
260 | <property stdset="1"> | 260 | <property stdset="1"> |
261 | <name>name</name> | 261 | <name>name</name> |
262 | <cstring>Layout3</cstring> | 262 | <cstring>Layout3</cstring> |
263 | </property> | 263 | </property> |
264 | <property> | 264 | <property> |
265 | <name>layoutSpacing</name> | 265 | <name>layoutSpacing</name> |
266 | </property> | 266 | </property> |
267 | <hbox> | 267 | <hbox> |
268 | <property stdset="1"> | 268 | <property stdset="1"> |
269 | <name>margin</name> | 269 | <name>margin</name> |
270 | <number>0</number> | 270 | <number>0</number> |
271 | </property> | 271 | </property> |
272 | <property stdset="1"> | 272 | <property stdset="1"> |
273 | <name>spacing</name> | 273 | <name>spacing</name> |
274 | <number>4</number> | 274 | <number>4</number> |
275 | </property> | 275 | </property> |
276 | <widget> | 276 | <widget> |
277 | <class>QPushButton</class> | 277 | <class>QPushButton</class> |
278 | <property stdset="1"> | 278 | <property stdset="1"> |
279 | <name>name</name> | 279 | <name>name</name> |
280 | <cstring>m_login</cstring> | 280 | <cstring>m_login</cstring> |
281 | </property> | 281 | </property> |
282 | <property stdset="1"> | 282 | <property stdset="1"> |
283 | <name>autoMask</name> | 283 | <name>autoMask</name> |
284 | <bool>true</bool> | 284 | <bool>true</bool> |
285 | </property> | 285 | </property> |
286 | <property stdset="1"> | 286 | <property stdset="1"> |
287 | <name>text</name> | 287 | <name>text</name> |
288 | <string>Login</string> | 288 | <string>Login</string> |
289 | </property> | 289 | </property> |
290 | </widget> | 290 | </widget> |
291 | <widget> | 291 | <widget> |
292 | <class>QPushButton</class> | 292 | <class>QPushButton</class> |
293 | <property stdset="1"> | 293 | <property stdset="1"> |
294 | <name>name</name> | 294 | <name>name</name> |
295 | <cstring>m_suspend</cstring> | 295 | <cstring>m_suspend</cstring> |
296 | </property> | 296 | </property> |
297 | <property stdset="1"> | 297 | <property stdset="1"> |
298 | <name>autoMask</name> | 298 | <name>autoMask</name> |
299 | <bool>true</bool> | 299 | <bool>true</bool> |
300 | </property> | 300 | </property> |
301 | <property stdset="1"> | 301 | <property stdset="1"> |
302 | <name>text</name> | 302 | <name>text</name> |
303 | <string>Suspend</string> | 303 | <string>Suspend</string> |
304 | </property> | 304 | </property> |
305 | </widget> | 305 | </widget> |
306 | <widget> | 306 | <widget> |
307 | <class>QPushButton</class> | 307 | <class>QPushButton</class> |
308 | <property stdset="1"> | 308 | <property stdset="1"> |
309 | <name>name</name> | 309 | <name>name</name> |
310 | <cstring>m_menu</cstring> | 310 | <cstring>m_menu</cstring> |
311 | </property> | 311 | </property> |
312 | <property stdset="1"> | 312 | <property stdset="1"> |
313 | <name>autoMask</name> | 313 | <name>autoMask</name> |
314 | <bool>true</bool> | 314 | <bool>true</bool> |
315 | </property> | 315 | </property> |
316 | <property stdset="1"> | 316 | <property stdset="1"> |
317 | <name>text</name> | 317 | <name>text</name> |
318 | <string>Menu</string> | 318 | <string>Menu</string> |
319 | </property> | 319 | </property> |
320 | </widget> | 320 | </widget> |
321 | </hbox> | 321 | </hbox> |
322 | </widget> | 322 | </widget> |
323 | <spacer> | 323 | <spacer> |
324 | <property> | 324 | <property> |
325 | <name>name</name> | 325 | <name>name</name> |
326 | <cstring>Spacer1</cstring> | 326 | <cstring>Spacer1</cstring> |
327 | </property> | 327 | </property> |
328 | <property stdset="1"> | 328 | <property stdset="1"> |
329 | <name>orientation</name> | 329 | <name>orientation</name> |
330 | <enum>Vertical</enum> | 330 | <enum>Vertical</enum> |
331 | </property> | 331 | </property> |
332 | <property stdset="1"> | 332 | <property stdset="1"> |
333 | <name>sizeType</name> | 333 | <name>sizeType</name> |
334 | <enum>Expanding</enum> | 334 | <enum>Expanding</enum> |
335 | </property> | 335 | </property> |
336 | <property> | 336 | <property> |
337 | <name>sizeHint</name> | 337 | <name>sizeHint</name> |
338 | <size> | 338 | <size> |
339 | <width>20</width> | 339 | <width>20</width> |
340 | <height>20</height> | 340 | <height>20</height> |
341 | </size> | 341 | </size> |
342 | </property> | 342 | </property> |
343 | </spacer> | 343 | </spacer> |
344 | </vbox> | 344 | </vbox> |
345 | </widget> | 345 | </widget> |
346 | <widget> | 346 | <widget> |
347 | <class>QFrame</class> | 347 | <class>QFrame</class> |
348 | <property stdset="1"> | 348 | <property stdset="1"> |
349 | <name>name</name> | 349 | <name>name</name> |
350 | <cstring>m_taskbar</cstring> | 350 | <cstring>m_taskbar</cstring> |
351 | </property> | 351 | </property> |
352 | <property stdset="1"> | 352 | <property stdset="1"> |
353 | <name>frameShape</name> | 353 | <name>frameShape</name> |
354 | <enum>NoFrame</enum> | 354 | <enum>NoFrame</enum> |
355 | </property> | 355 | </property> |
356 | <property stdset="1"> | 356 | <property stdset="1"> |
357 | <name>frameShadow</name> | 357 | <name>frameShadow</name> |
358 | <enum>Raised</enum> | 358 | <enum>Raised</enum> |
359 | </property> | 359 | </property> |
360 | <property stdset="1"> | 360 | <property stdset="1"> |
361 | <name>margin</name> | 361 | <name>margin</name> |
362 | <number>0</number> | 362 | <number>0</number> |
363 | </property> | 363 | </property> |
364 | </widget> | 364 | </widget> |
365 | </vbox> | 365 | </vbox> |
366 | </widget> | 366 | </widget> |
367 | <images> | 367 | <images> |
368 | <image> | 368 | <image> |
369 | <name>image0</name> | 369 | <name>image0</name> |
370 | <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141a808a2983b03284848a298304c108240e15033141045829580cac07ac4e590f5d0c22a4876caf32d45898797a48044caf32c22948e629c39d0457a78ce60f65b8f104ec50d6c366af1e865eb4b0aab5e602008bcd444d</data> | 370 | <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141a808a2983b03284848a298304c108240e15033141045829580cac07ac4e590f5d0c22a4876caf32d45898797a48044caf32c22948e629c39d0457a78ce60f65b8f104ec50d6c366af1e865eb4b0aab5e602008bcd444d</data> |
371 | </image> | 371 | </image> |
372 | <image> | 372 | <image> |
373 | <name>image1</name> | 373 | <name>image1</name> |
374 | <data format="XPM.GZ" length="341">789c558fcd0a02310c84ef7d8ad0b915c9bae84d7c04c5a3201e4275d1c32ab8eb41c477b73fa96e43a1f30d4d266d1ced771b728d194619af9efc451ee44ecfbe7f1d8eebb7b1ed92c259506b67c63279dade6fe7a81134e6a9224ac4ae2bc85565075004901c8820731069a648b490effc26eac4a25dcc195373c94231b87a8349fabf894b7a3d27a76af8cf01eb0e534757d70da1bf8a933f2bf30509e84b68</data> | 374 | <data format="XPM.GZ" length="341">789c558fcd0a02310c84ef7d8ad0b915c9bae84d7c04c5a3201e4275d1c32ab8eb41c477b73fa96e43a1f30d4d266d1ced771b728d194619af9efc451ee44ecfbe7f1d8eebb7b1ed92c259506b67c63279dade6fe7a81134e6a9224ac4ae2bc85565075004901c8820731069a648b490effc26eac4a25dcc195373c94231b87a8349fabf894b7a3d27a76af8cf01eb0e534757d70da1bf8a933f2bf30509e84b68</data> |
375 | </image> | 375 | </image> |
376 | </images> | 376 | </images> |
377 | <connections> | 377 | <connections> |
378 | <connection> | 378 | <connection> |
379 | <sender>ToolButton1</sender> | 379 | <sender>ToolButton1</sender> |
380 | <signal>clicked()</signal> | 380 | <signal>clicked()</signal> |
381 | <receiver>m_password</receiver> | 381 | <receiver>m_password</receiver> |
382 | <slot>clear()</slot> | 382 | <slot>clear()</slot> |
383 | </connection> | 383 | </connection> |
384 | <connection> | 384 | <connection> |
385 | <sender>ToolButton3</sender> | 385 | <sender>ToolButton3</sender> |
386 | <signal>toggled(bool)</signal> | 386 | <signal>toggled(bool)</signal> |
387 | <receiver>LoginWindow</receiver> | 387 | <receiver>LoginWindow</receiver> |
388 | <slot>toggleEchoMode(bool)</slot> | 388 | <slot>toggleEchoMode(bool)</slot> |
389 | </connection> | 389 | </connection> |
390 | <connection> | 390 | <connection> |
391 | <sender>m_suspend</sender> | 391 | <sender>m_suspend</sender> |
392 | <signal>clicked()</signal> | 392 | <signal>clicked()</signal> |
393 | <receiver>LoginWindow</receiver> | 393 | <receiver>LoginWindow</receiver> |
394 | <slot>suspend()</slot> | 394 | <slot>suspend()</slot> |
395 | </connection> | 395 | </connection> |
396 | <connection> | 396 | <connection> |
397 | <sender>m_password</sender> | 397 | <sender>m_password</sender> |
398 | <signal>returnPressed()</signal> | 398 | <signal>returnPressed()</signal> |
399 | <receiver>m_login</receiver> | 399 | <receiver>m_login</receiver> |
400 | <slot>animateClick()</slot> | 400 | <slot>animateClick()</slot> |
401 | </connection> | 401 | </connection> |
402 | <connection> | 402 | <connection> |
403 | <sender>m_login</sender> | 403 | <sender>m_login</sender> |
404 | <signal>clicked()</signal> | 404 | <signal>clicked()</signal> |
405 | <receiver>LoginWindow</receiver> | 405 | <receiver>LoginWindow</receiver> |
406 | <slot>login()</slot> | 406 | <slot>login()</slot> |
407 | </connection> | 407 | </connection> |
408 | <connection> | ||
409 | <sender>m_user</sender> | ||
410 | <signal>activated(int)</signal> | ||
411 | <receiver>m_password</receiver> | ||
412 | <slot>setFocus()</slot> | ||
413 | </connection> | ||
408 | <slot access="public">login()</slot> | 414 | <slot access="public">login()</slot> |
409 | <slot access="public">suspend()</slot> | 415 | <slot access="public">suspend()</slot> |
410 | <slot access="public">toggleEchoMode(bool)</slot> | 416 | <slot access="public">toggleEchoMode(bool)</slot> |
411 | </connections> | 417 | </connections> |
412 | </UI> | 418 | </UI> |
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp index 63baaa6..c59338f 100644 --- a/core/opie-login/loginwindowimpl.cpp +++ b/core/opie-login/loginwindowimpl.cpp | |||
@@ -1,326 +1,345 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qframe.h> | 4 | #include <qframe.h> |
5 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
6 | #include <qtimer.h> | 6 | #include <qtimer.h> |
7 | #include <qcombobox.h> | 7 | #include <qcombobox.h> |
8 | #include <qpixmap.h> | 8 | #include <qpixmap.h> |
9 | #include <qlabel.h> | 9 | #include <qlabel.h> |
10 | #include <qpopupmenu.h> | 10 | #include <qpopupmenu.h> |
11 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
12 | #include <qimage.h> | ||
12 | 13 | ||
14 | #include <qpe/resource.h> | ||
13 | #include <qpe/qcopenvelope_qws.h> | 15 | #include <qpe/qcopenvelope_qws.h> |
14 | 16 | ||
15 | #include <opie/odevice.h> | 17 | #include <opie/odevice.h> |
16 | 18 | ||
17 | #include <stdio.h> | 19 | #include <stdio.h> |
18 | 20 | ||
19 | #include <pwd.h> | 21 | #include <pwd.h> |
20 | #include <grp.h> | 22 | #include <grp.h> |
21 | #include <unistd.h> | 23 | #include <unistd.h> |
22 | #include <stdlib.h> | 24 | #include <stdlib.h> |
23 | #include <signal.h> | 25 | #include <signal.h> |
24 | 26 | ||
25 | #ifdef USEPAM | 27 | #ifdef USEPAM |
26 | extern "C" { | 28 | extern "C" { |
27 | #include <security/pam_appl.h> | 29 | #include <security/pam_appl.h> |
28 | } | 30 | } |
29 | #else | 31 | #else |
30 | #include <crypt.h> | 32 | #include <crypt.h> |
31 | #include <shadow.h> | 33 | #include <shadow.h> |
32 | #endif | 34 | #endif |
33 | 35 | ||
34 | #include "loginwindowimpl.h" | 36 | #include "loginwindowimpl.h" |
35 | #include "inputmethods.h" | 37 | #include "inputmethods.h" |
36 | 38 | ||
37 | using namespace Opie; | 39 | using namespace Opie; |
38 | 40 | ||
39 | 41 | ||
40 | LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) | 42 | LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) |
41 | { | 43 | { |
42 | QPopupMenu *pop = new QPopupMenu ( this ); | 44 | QPopupMenu *pop = new QPopupMenu ( this ); |
43 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); | 45 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); |
44 | pop-> insertItem ( tr( "Quit" ), this, SLOT( quit ( ))); | 46 | pop-> insertItem ( tr( "Quit" ), this, SLOT( quit ( ))); |
45 | m_menu-> setPopup ( pop ); | 47 | m_menu-> setPopup ( pop ); |
46 | 48 | ||
47 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); | 49 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); |
48 | m_input = new InputMethods ( m_taskbar ); | 50 | m_input = new InputMethods ( m_taskbar ); |
49 | lay-> addWidget ( m_input ); | 51 | lay-> addWidget ( m_input ); |
50 | lay-> addStretch ( 10 ); | 52 | lay-> addStretch ( 10 ); |
51 | 53 | ||
52 | setActiveWindow ( ); | 54 | setActiveWindow ( ); |
53 | m_password-> setFocus ( ); | 55 | m_password-> setFocus ( ); |
54 | 56 | ||
55 | m_user-> insertStringList ( getAllUsers ( )); | 57 | m_user-> insertStringList ( getAllUsers ( )); |
56 | 58 | ||
57 | QTimer::singleShot ( 0, this, SLOT( showIM ( ))); | 59 | QTimer::singleShot ( 0, this, SLOT( showIM ( ))); |
58 | 60 | ||
59 | QString opiedir = ::getenv ( "OPIEDIR" ); | 61 | QString opiedir = ::getenv ( "OPIEDIR" ); |
60 | QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); | 62 | QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); |
61 | 63 | ||
62 | if ( !bgpix. isNull ( )) | 64 | if ( !bgpix. isNull ( )) |
63 | setBackgroundPixmap ( bgpix ); | 65 | setBackgroundPixmap ( bgpix ); |
64 | 66 | ||
65 | m_caption-> setText ( m_caption-> text ( ) + tr( "<center>%1 %2</center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); | 67 | m_caption-> setText ( m_caption-> text ( ) + tr( "<center>%1 %2</center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); |
66 | } | 68 | } |
67 | 69 | ||
68 | LoginWindowImpl::~LoginWindowImpl ( ) | 70 | LoginWindowImpl::~LoginWindowImpl ( ) |
69 | { | 71 | { |
70 | } | 72 | } |
71 | 73 | ||
72 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) | 74 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) |
73 | { | 75 | { |
74 | switch ( e-> key ( )) { | 76 | switch ( e-> key ( )) { |
75 | case HardKey_Suspend: suspend ( ); | 77 | case HardKey_Suspend: suspend ( ); |
76 | break; | 78 | break; |
77 | case HardKey_Backlight: backlight ( ); | 79 | case HardKey_Backlight: backlight ( ); |
78 | break; | 80 | break; |
79 | default: e-> ignore ( ); | 81 | default: e-> ignore ( ); |
80 | break; | 82 | break; |
81 | } | 83 | } |
82 | LoginWindow::keyPressEvent ( e ); | 84 | LoginWindow::keyPressEvent ( e ); |
83 | } | 85 | } |
84 | 86 | ||
85 | 87 | ||
86 | void LoginWindowImpl::toggleEchoMode ( bool t ) | 88 | void LoginWindowImpl::toggleEchoMode ( bool t ) |
87 | { | 89 | { |
88 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); | 90 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); |
89 | } | 91 | } |
90 | 92 | ||
93 | |||
91 | QStringList LoginWindowImpl::getAllUsers ( ) | 94 | QStringList LoginWindowImpl::getAllUsers ( ) |
92 | { | 95 | { |
93 | struct passwd *pwd; | 96 | struct passwd *pwd; |
94 | QStringList sl; | 97 | QStringList sl; |
95 | 98 | ||
96 | while (( pwd = ::getpwent ( ))) { | 99 | while (( pwd = ::getpwent ( ))) { |
97 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) | 100 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) |
98 | sl << QString ( pwd-> pw_name ); | 101 | sl << QString ( pwd-> pw_name ); |
99 | } | 102 | } |
100 | 103 | ||
101 | ::endpwent ( ); | 104 | ::endpwent ( ); |
102 | 105 | ||
103 | return sl; | 106 | return sl; |
104 | } | 107 | } |
105 | 108 | ||
106 | void LoginWindowImpl::showIM ( ) | 109 | void LoginWindowImpl::showIM ( ) |
107 | { | 110 | { |
108 | m_input-> showInputMethod ( ); | 111 | m_input-> showInputMethod ( ); |
109 | } | 112 | } |
110 | 113 | ||
111 | void LoginWindowImpl::restart ( ) | 114 | void LoginWindowImpl::restart ( ) |
112 | { | 115 | { |
113 | qApp-> quit ( ); | 116 | qApp-> quit ( ); |
114 | } | 117 | } |
115 | 118 | ||
116 | void LoginWindowImpl::quit ( ) | 119 | void LoginWindowImpl::quit ( ) |
117 | { | 120 | { |
118 | qApp-> quit ( ); | 121 | qApp-> quit ( ); |
119 | ::kill ( ::getppid ( ), SIGUSR1 ); | 122 | ::kill ( ::getppid ( ), SIGUSR1 ); |
120 | } | 123 | } |
121 | 124 | ||
122 | void LoginWindowImpl::suspend ( ) | 125 | void LoginWindowImpl::suspend ( ) |
123 | { | 126 | { |
124 | ODevice::inst ( )-> suspend ( ); | 127 | ODevice::inst ( )-> suspend ( ); |
125 | 128 | ||
126 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 129 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
127 | e << -3; // Force on | 130 | e << -3; // Force on |
128 | } | 131 | } |
129 | 132 | ||
130 | void LoginWindowImpl::backlight ( ) | 133 | void LoginWindowImpl::backlight ( ) |
131 | { | 134 | { |
132 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 135 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
133 | e << -2; // toggle | 136 | e << -2; // toggle |
134 | } | 137 | } |
135 | 138 | ||
136 | #ifdef USEPAM | 139 | #ifdef USEPAM |
137 | 140 | ||
138 | static const char *_PAM_SERVICE = "xdm"; | 141 | static const char *_PAM_SERVICE = "xdm"; |
139 | static const char *PAM_password; | 142 | static const char *PAM_password; |
140 | 143 | ||
141 | typedef const struct pam_message pam_message_type; | 144 | typedef const struct pam_message pam_message_type; |
142 | 145 | ||
143 | static int PAM_conv( int, pam_message_type **, struct pam_response **, void * ); | 146 | static int PAM_conv( int, pam_message_type **, struct pam_response **, void * ); |
144 | 147 | ||
145 | static struct pam_conv PAM_conversation = { | 148 | static struct pam_conv PAM_conversation = { |
146 | &PAM_conv, | 149 | &PAM_conv, |
147 | NULL | 150 | NULL |
148 | }; | 151 | }; |
149 | 152 | ||
150 | //---------------------------------------------------------------------------- | 153 | //---------------------------------------------------------------------------- |
151 | 154 | ||
152 | static char *COPY_STRING( const char * s ) { | 155 | static char *COPY_STRING( const char * s ) { |
153 | return (s) ? strdup(s) : (char *)NULL; | 156 | return (s) ? strdup(s) : (char *)NULL; |
154 | } | 157 | } |
155 | 158 | ||
156 | #define GET_MEM if (reply) realloc(reply, size);\ | 159 | #define GET_MEM if (reply) realloc(reply, size);\ |
157 | else reply = (struct pam_response *)malloc(size); \ | 160 | else reply = (struct pam_response *)malloc(size); \ |
158 | if (!reply) return PAM_CONV_ERR; \ | 161 | if (!reply) return PAM_CONV_ERR; \ |
159 | size += sizeof(struct pam_response) | 162 | size += sizeof(struct pam_response) |
160 | 163 | ||
161 | 164 | ||
162 | static int PAM_conv( int num_msg, pam_message_type **msg, | 165 | static int PAM_conv( int num_msg, pam_message_type **msg, |
163 | struct pam_response **resp, void *) | 166 | struct pam_response **resp, void *) |
164 | { | 167 | { |
165 | int count = 0, replies = 0; | 168 | int count = 0, replies = 0; |
166 | struct pam_response *reply = NULL; | 169 | struct pam_response *reply = NULL; |
167 | int size = sizeof(struct pam_response); | 170 | int size = sizeof(struct pam_response); |
168 | 171 | ||
169 | for( count = 0; count < num_msg; count++ ) { | 172 | for( count = 0; count < num_msg; count++ ) { |
170 | switch (msg[count]->msg_style) { | 173 | switch (msg[count]->msg_style) { |
171 | case PAM_PROMPT_ECHO_ON: | 174 | case PAM_PROMPT_ECHO_ON: |
172 | /* user name given to PAM already */ | 175 | /* user name given to PAM already */ |
173 | return PAM_CONV_ERR; | 176 | return PAM_CONV_ERR; |
174 | 177 | ||
175 | case PAM_PROMPT_ECHO_OFF: | 178 | case PAM_PROMPT_ECHO_OFF: |
176 | /* wants password */ | 179 | /* wants password */ |
177 | GET_MEM; | 180 | GET_MEM; |
178 | reply[replies].resp_retcode = PAM_SUCCESS; | 181 | reply[replies].resp_retcode = PAM_SUCCESS; |
179 | reply[replies].resp = COPY_STRING(PAM_password); | 182 | reply[replies].resp = COPY_STRING(PAM_password); |
180 | replies++; | 183 | replies++; |
181 | /* PAM frees resp */ | 184 | /* PAM frees resp */ |
182 | break; | 185 | break; |
183 | case PAM_TEXT_INFO: | 186 | case PAM_TEXT_INFO: |
184 | break; | 187 | break; |
185 | default: | 188 | default: |
186 | /* unknown or PAM_ERROR_MSG */ | 189 | /* unknown or PAM_ERROR_MSG */ |
187 | if (reply) free (reply); | 190 | if (reply) free (reply); |
188 | return PAM_CONV_ERR; | 191 | return PAM_CONV_ERR; |
189 | } | 192 | } |
190 | } | 193 | } |
191 | if (reply) *resp = reply; | 194 | if (reply) *resp = reply; |
192 | return PAM_SUCCESS; | 195 | return PAM_SUCCESS; |
193 | } | 196 | } |
194 | 197 | ||
195 | 198 | ||
196 | static bool pwcheck_PAM( const char *user, const char *password ) | 199 | static bool pwcheck_PAM( const char *user, const char *password ) |
197 | { | 200 | { |
198 | bool pw_correct = false; | 201 | bool pw_correct = false; |
199 | int pam_error; | 202 | int pam_error; |
200 | int pam_return = 0; | 203 | int pam_return = 0; |
201 | pam_handle_t *pamh = 0; | 204 | pam_handle_t *pamh = 0; |
202 | PAM_password = password; | 205 | PAM_password = password; |
203 | 206 | ||
204 | pam_error = pam_start( _PAM_SERVICE, user, &PAM_conversation, &pamh ); | 207 | pam_error = pam_start( _PAM_SERVICE, user, &PAM_conversation, &pamh ); |
205 | if( pam_error == PAM_SUCCESS ) { | 208 | if( pam_error == PAM_SUCCESS ) { |
206 | pam_error = pam_authenticate( pamh, 0 ); | 209 | pam_error = pam_authenticate( pamh, 0 ); |
207 | if( pam_error == PAM_SUCCESS ) { | 210 | if( pam_error == PAM_SUCCESS ) { |
208 | //-- password correct | 211 | //-- password correct |
209 | pw_correct = true; | 212 | pw_correct = true; |
210 | pam_return = PAM_SUCCESS; | 213 | pam_return = PAM_SUCCESS; |
211 | } else { | 214 | } else { |
212 | pam_return = pam_error; | 215 | pam_return = pam_error; |
213 | } | 216 | } |
214 | } else { | 217 | } else { |
215 | // cerr << "PAM error: " << pam_strerror( pamh, pam_error ) << endl; | 218 | // cerr << "PAM error: " << pam_strerror( pamh, pam_error ) << endl; |
216 | } | 219 | } |
217 | pam_end( pamh, pam_return ); | 220 | pam_end( pamh, pam_return ); |
218 | return pw_correct; | 221 | return pw_correct; |
219 | } | 222 | } |
220 | 223 | ||
221 | #else | 224 | #else |
222 | 225 | ||
223 | //---------------------------------------------------------------------------- | 226 | //---------------------------------------------------------------------------- |
224 | 227 | ||
225 | static bool pwcheck_Unix( const char *user, const char *pass ) | 228 | static bool pwcheck_Unix( const char *user, const char *pass ) |
226 | { | 229 | { |
227 | char *encrypted, *correct; | 230 | char *encrypted, *correct; |
228 | struct passwd *pw; | 231 | struct passwd *pw; |
229 | 232 | ||
230 | if ( !user || !pass ) | 233 | if ( !user || !pass ) |
231 | return false; | 234 | return false; |
232 | 235 | ||
233 | pw = getpwnam ( user ); | 236 | pw = getpwnam ( user ); |
234 | 237 | ||
235 | if ( !pw ) | 238 | if ( !pw ) |
236 | return false; | 239 | return false; |
237 | 240 | ||
238 | if (( strcmp ( pw-> pw_passwd, "x" ) == 0 ) || ( strcmp ( pw-> pw_passwd, "*" ) == 0 )) { | 241 | if (( strcmp ( pw-> pw_passwd, "x" ) == 0 ) || ( strcmp ( pw-> pw_passwd, "*" ) == 0 )) { |
239 | struct spwd *sp = getspnam ( pw-> pw_name ); | 242 | struct spwd *sp = getspnam ( pw-> pw_name ); |
240 | 243 | ||
241 | if ( !sp ) | 244 | if ( !sp ) |
242 | return false; | 245 | return false; |
243 | 246 | ||
244 | correct = sp-> sp_pwdp; | 247 | correct = sp-> sp_pwdp; |
245 | } | 248 | } |
246 | else | 249 | else |
247 | correct = pw-> pw_passwd; | 250 | correct = pw-> pw_passwd; |
248 | 251 | ||
249 | if ( correct == 0 || correct[0] == '\0' ) | 252 | if ( correct == 0 || correct[0] == '\0' ) |
250 | return true; | 253 | return true; |
251 | 254 | ||
252 | encrypted = crypt ( pass, correct ); | 255 | encrypted = crypt ( pass, correct ); |
253 | return ( strcmp ( encrypted, correct ) == 0 ); | 256 | return ( strcmp ( encrypted, correct ) == 0 ); |
254 | } | 257 | } |
255 | 258 | ||
256 | #endif | 259 | #endif |
257 | 260 | ||
258 | 261 | ||
259 | bool LoginWindowImpl::changeIdentity ( const char *user ) | 262 | bool LoginWindowImpl::changeIdentity ( const char *user ) |
260 | { | 263 | { |
261 | const char *DEFAULT_LOGIN_PATH = "/bin:/usr/bin"; | 264 | const char *DEFAULT_LOGIN_PATH = "/bin:/usr/bin"; |
262 | const char *DEFAULT_ROOT_LOGIN_PATH = "/usr/sbin:/bin:/usr/bin:/sbin"; | 265 | const char *DEFAULT_ROOT_LOGIN_PATH = "/usr/sbin:/bin:/usr/bin:/sbin"; |
263 | 266 | ||
264 | bool fail = false; | 267 | bool fail = false; |
265 | struct passwd *pw = getpwnam ( user ); | 268 | struct passwd *pw = getpwnam ( user ); |
266 | 269 | ||
267 | fail |= ( pw == 0 ); | 270 | fail |= ( pw == 0 ); |
268 | fail |= ( initgroups ( pw-> pw_name, pw-> pw_gid )); | 271 | fail |= ( initgroups ( pw-> pw_name, pw-> pw_gid )); |
269 | endgrent ( ); | 272 | endgrent ( ); |
270 | fail |= ( setgid ( pw-> pw_gid )); | 273 | fail |= ( setgid ( pw-> pw_gid )); |
271 | fail |= ( setuid ( pw-> pw_uid )); | 274 | fail |= ( setuid ( pw-> pw_uid )); |
272 | 275 | ||
273 | fail |= ( chdir ( pw-> pw_dir ) && chdir ( "/" )); | 276 | fail |= ( chdir ( pw-> pw_dir ) && chdir ( "/" )); |
274 | 277 | ||
275 | fail |= ( setenv ( "HOME", pw-> pw_dir, 1 )); | 278 | fail |= ( setenv ( "HOME", pw-> pw_dir, 1 )); |
276 | fail |= ( setenv ( "SHELL", pw-> pw_shell, 1 )); | 279 | fail |= ( setenv ( "SHELL", pw-> pw_shell, 1 )); |
277 | fail |= ( setenv ( "USER", pw-> pw_name, 1 )); | 280 | fail |= ( setenv ( "USER", pw-> pw_name, 1 )); |
278 | fail |= ( setenv ( "LOGNAME", pw-> pw_name, 1 )); | 281 | fail |= ( setenv ( "LOGNAME", pw-> pw_name, 1 )); |
279 | fail |= ( setenv ( "PATH", ( pw-> pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH ), 1 )); | 282 | fail |= ( setenv ( "PATH", ( pw-> pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH ), 1 )); |
280 | 283 | ||
281 | return !fail; | 284 | return !fail; |
282 | } | 285 | } |
283 | 286 | ||
284 | void LoginWindowImpl::login ( ) | 287 | void LoginWindowImpl::login ( ) |
285 | { | 288 | { |
286 | const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); | 289 | const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); |
287 | const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); | 290 | const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); |
288 | bool ok; | 291 | bool ok; |
289 | 292 | ||
290 | if ( !user || !user [0] ) | 293 | if ( !user || !user [0] ) |
291 | return; | 294 | return; |
292 | if ( !pass ) | 295 | if ( !pass ) |
293 | pass = ""; | 296 | pass = ""; |
294 | 297 | ||
295 | #if defined( USEPAM ) | 298 | #if defined( USEPAM ) |
296 | ok = pwcheck_PAM ( user, pass ); | 299 | ok = pwcheck_PAM ( user, pass ); |
297 | #else | 300 | #else |
298 | ok = pwcheck_Unix ( user, pass ); | 301 | ok = pwcheck_Unix ( user, pass ); |
299 | #endif | 302 | #endif |
300 | 303 | ||
301 | if ( ok ) { | 304 | if ( ok ) { |
302 | if ( changeIdentity ( user )) { | 305 | if ( changeIdentity ( user )) { |
306 | // Draw a big wait icon, the image can be altered in later revisions | ||
307 | QWidget *d = QApplication::desktop ( ); | ||
308 | m_input-> hideInputMethod ( ); | ||
309 | |||
310 | QImage img = Resource::loadImage( "launcher/new_wait" ); | ||
311 | QPixmap pix; | ||
312 | pix. convertFromImage ( img ); | ||
313 | QLabel *w = new QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ); | ||
314 | w-> setPixmap ( pix ); | ||
315 | w-> setAlignment ( AlignCenter ); | ||
316 | w-> showMaximized ( ); | ||
317 | qApp-> processEvents ( ); | ||
318 | |||
303 | char *opie = ::getenv ( "OPIEDIR" ); | 319 | char *opie = ::getenv ( "OPIEDIR" ); |
304 | char *arg = new char [::strlen ( opie ) + 8 + 1]; | 320 | char *arg = new char [::strlen ( opie ) + 8 + 1]; |
305 | 321 | ||
306 | ::strcpy ( arg, opie ); | 322 | ::strcpy ( arg, opie ); |
307 | ::strcat ( arg, "/bin/qpe" ); | 323 | ::strcat ( arg, "/bin/qpe" ); |
308 | 324 | ||
309 | // start qpe via a login shell | 325 | // start qpe via a login shell |
310 | ::execl ( "/bin/sh", "-sh", "-c", arg, 0 ); | 326 | ::execl ( "/bin/sh", "-sh", "-c", arg, 0 ); |
311 | 327 | ||
328 | w-> hide ( ); | ||
329 | delete w; | ||
330 | |||
312 | QMessageBox::critical ( this, tr( "Failure" ), tr( "Could not start OPIE\n(%1)." ). arg ( arg )); | 331 | QMessageBox::critical ( this, tr( "Failure" ), tr( "Could not start OPIE\n(%1)." ). arg ( arg )); |
313 | delete [] arg; | 332 | delete [] arg; |
314 | 333 | ||
315 | restart ( ); | 334 | restart ( ); |
316 | } | 335 | } |
317 | else { | 336 | else { |
318 | QMessageBox::critical ( this, tr( "Failure" ), tr( "Could not switch to new user identity" )); | 337 | QMessageBox::critical ( this, tr( "Failure" ), tr( "Could not switch to new user identity" )); |
319 | restart ( ); | 338 | restart ( ); |
320 | } | 339 | } |
321 | } | 340 | } |
322 | else { | 341 | else { |
323 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); | 342 | QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); |
324 | m_password-> clear ( ); | 343 | m_password-> clear ( ); |
325 | } | 344 | } |
326 | } | 345 | } |