author | sandman <sandman> | 2002-10-17 00:39:31 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-17 00:39:31 (UTC) |
commit | 259d10f40405fd77ba0a8947782f716be94da3a5 (patch) (unidiff) | |
tree | 636cb3a899d27a8fe41f377fabc5bd170a74c6dc | |
parent | 5d28c61d84da1814d356540b557bbfe026da98aa (diff) | |
download | opie-259d10f40405fd77ba0a8947782f716be94da3a5.zip opie-259d10f40405fd77ba0a8947782f716be94da3a5.tar.gz opie-259d10f40405fd77ba0a8947782f716be94da3a5.tar.bz2 |
- fix for bug #292 (Improper behaviour of frontlight disabling)
- fix for bug #199 (Desktop visible on resume before password dialog
appears)
-rw-r--r-- | core/launcher/desktop.cpp | 34 | ||||
-rw-r--r-- | library/password.cpp | 24 | ||||
-rw-r--r-- | library/password.h | 1 |
3 files changed, 46 insertions, 13 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 0e60839..d74b745 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -152,65 +152,65 @@ void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | |||
152 | currentPriority = INT_MAX; | 152 | currentPriority = INT_MAX; |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | class QPEScreenSaver : public QWSScreenSaver | 156 | class QPEScreenSaver : public QWSScreenSaver |
157 | { | 157 | { |
158 | private: | 158 | private: |
159 | int LcdOn; | 159 | int LcdOn; |
160 | 160 | ||
161 | public: | 161 | public: |
162 | QPEScreenSaver() | 162 | QPEScreenSaver() |
163 | { | 163 | { |
164 | m_disable_suspend = 100; | 164 | m_disable_suspend = 100; |
165 | m_enable_dim = false; | 165 | m_enable_dim = false; |
166 | m_enable_lightoff = false; | 166 | m_enable_lightoff = false; |
167 | m_enable_onlylcdoff = false; | 167 | m_enable_onlylcdoff = false; |
168 | 168 | ||
169 | m_lcd_status = true; | 169 | m_lcd_status = true; |
170 | 170 | ||
171 | m_backlight_bright = -1; | 171 | m_backlight_bright = -1; |
172 | m_backlight_forcedoff = false; | 172 | m_backlight_forcedoff = false; |
173 | 173 | ||
174 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 174 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
175 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 175 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
176 | } | 176 | } |
177 | void restore() | 177 | void restore() |
178 | { | 178 | { |
179 | if ( !m_lcd_status ) { // We must have turned it off | 179 | if ( !m_lcd_status ) { // We must have turned it off |
180 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 180 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
181 | m_lcd_status = true; | 181 | m_lcd_status = true; |
182 | } | 182 | } |
183 | 183 | ||
184 | setBacklight ( -3 ); | 184 | setBacklight ( -1 ); |
185 | } | 185 | } |
186 | bool save( int level ) | 186 | bool save( int level ) |
187 | { | 187 | { |
188 | switch ( level ) { | 188 | switch ( level ) { |
189 | case 0: | 189 | case 0: |
190 | if ( m_disable_suspend > 0 && m_enable_dim ) { | 190 | if ( m_disable_suspend > 0 && m_enable_dim ) { |
191 | if ( backlight() > 1 ) | 191 | if ( backlight() > 1 ) |
192 | setBacklight( 1 ); // lowest non-off | 192 | setBacklight( 1 ); // lowest non-off |
193 | } | 193 | } |
194 | return true; | 194 | return true; |
195 | break; | 195 | break; |
196 | case 1: | 196 | case 1: |
197 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { | 197 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { |
198 | setBacklight( 0 ); // off | 198 | setBacklight( 0 ); // off |
199 | } | 199 | } |
200 | return true; | 200 | return true; |
201 | break; | 201 | break; |
202 | case 2: | 202 | case 2: |
203 | if ( m_enable_onlylcdoff ) { | 203 | if ( m_enable_onlylcdoff ) { |
204 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 204 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
205 | m_lcd_status = false; | 205 | m_lcd_status = false; |
206 | return true; | 206 | return true; |
207 | } | 207 | } |
208 | else // We're going to suspend the whole machine | 208 | else // We're going to suspend the whole machine |
209 | { | 209 | { |
210 | if ( ( m_disable_suspend > 2 ) && | 210 | if ( ( m_disable_suspend > 2 ) && |
211 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && | 211 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && |
212 | ( !Network::networkOnline ( ) ) ) { | 212 | ( !Network::networkOnline ( ) ) ) { |
213 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 213 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
214 | return true; | 214 | return true; |
215 | } | 215 | } |
216 | } | 216 | } |
@@ -303,70 +303,72 @@ public: | |||
303 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 303 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); |
304 | 304 | ||
305 | m_backlight_bright = bright; | 305 | m_backlight_bright = bright; |
306 | } | 306 | } |
307 | 307 | ||
308 | void setDisplayState ( bool on ) | 308 | void setDisplayState ( bool on ) |
309 | { | 309 | { |
310 | if ( m_lcd_status != on ) { | 310 | if ( m_lcd_status != on ) { |
311 | ODevice::inst ( ) -> setDisplayStatus ( on ); | 311 | ODevice::inst ( ) -> setDisplayStatus ( on ); |
312 | m_lcd_status = on; | 312 | m_lcd_status = on; |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | private: | 316 | private: |
317 | int m_disable_suspend; | 317 | int m_disable_suspend; |
318 | bool m_enable_dim; | 318 | bool m_enable_dim; |
319 | bool m_enable_lightoff; | 319 | bool m_enable_lightoff; |
320 | bool m_enable_onlylcdoff; | 320 | bool m_enable_onlylcdoff; |
321 | 321 | ||
322 | bool m_lcd_status; | 322 | bool m_lcd_status; |
323 | 323 | ||
324 | int m_backlight_bright; | 324 | int m_backlight_bright; |
325 | bool m_backlight_forcedoff; | 325 | bool m_backlight_forcedoff; |
326 | }; | 326 | }; |
327 | 327 | ||
328 | 328 | ||
329 | void DesktopApplication::switchLCD ( bool on ) | 329 | void DesktopApplication::switchLCD ( bool on ) |
330 | { | 330 | { |
331 | if ( qApp ) { | 331 | if ( qApp ) { |
332 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 332 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
333 | 333 | ||
334 | if ( dapp-> m_screensaver ) { | 334 | if ( dapp-> m_screensaver ) { |
335 | if ( on ) | 335 | if ( on ) { |
336 | dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 ); | 336 | dapp-> m_screensaver-> setDisplayState ( true ); |
337 | else | 337 | dapp-> m_screensaver-> setBacklight ( -3 ); |
338 | dapp-> m_screensaver-> save ( 1 ); | 338 | } |
339 | 339 | else { | |
340 | } | 340 | dapp-> m_screensaver-> setDisplayState ( false ); |
341 | } | ||
342 | } | ||
341 | } | 343 | } |
342 | } | 344 | } |
343 | 345 | ||
344 | 346 | ||
345 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 347 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
346 | : QPEApplication( argc, argv, appType ) | 348 | : QPEApplication( argc, argv, appType ) |
347 | { | 349 | { |
348 | 350 | ||
349 | QTimer * t = new QTimer( this ); | 351 | QTimer * t = new QTimer( this ); |
350 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); | 352 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); |
351 | t->start( 10000 ); | 353 | t->start( 10000 ); |
352 | ps = new PowerStatus; | 354 | ps = new PowerStatus; |
353 | pa = new DesktopPowerAlerter( 0 ); | 355 | pa = new DesktopPowerAlerter( 0 ); |
354 | 356 | ||
355 | channel = new QCopChannel( "QPE/Desktop", this ); | 357 | channel = new QCopChannel( "QPE/Desktop", this ); |
356 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 358 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
357 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 359 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
358 | 360 | ||
359 | channel = new QCopChannel( "QPE/System", this ); | 361 | channel = new QCopChannel( "QPE/System", this ); |
360 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 362 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
361 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 363 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
362 | 364 | ||
363 | m_screensaver = new QPEScreenSaver; | 365 | m_screensaver = new QPEScreenSaver; |
364 | 366 | ||
365 | m_screensaver-> setInterval ( -1 ); | 367 | m_screensaver-> setInterval ( -1 ); |
366 | QWSServer::setScreenSaver( m_screensaver ); | 368 | QWSServer::setScreenSaver( m_screensaver ); |
367 | } | 369 | } |
368 | 370 | ||
369 | 371 | ||
370 | DesktopApplication::~DesktopApplication() | 372 | DesktopApplication::~DesktopApplication() |
371 | { | 373 | { |
372 | delete ps; | 374 | delete ps; |
@@ -833,83 +835,93 @@ void Desktop::execAutoStart() | |||
833 | Config cfg( "autostart" ); | 835 | Config cfg( "autostart" ); |
834 | cfg.setGroup( "AutoStart" ); | 836 | cfg.setGroup( "AutoStart" ); |
835 | appName = cfg.readEntry( "Apps", "" ); | 837 | appName = cfg.readEntry( "Apps", "" ); |
836 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 838 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
837 | // If the time between suspend and resume was longer then the | 839 | // If the time between suspend and resume was longer then the |
838 | // value saved as delay, start the app | 840 | // value saved as delay, start the app |
839 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 841 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
840 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 842 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
841 | e << QString( appName ); | 843 | e << QString( appName ); |
842 | } | 844 | } |
843 | } | 845 | } |
844 | 846 | ||
845 | #if defined(QPE_HAVE_TOGGLELIGHT) | 847 | #if defined(QPE_HAVE_TOGGLELIGHT) |
846 | #include <qpe/config.h> | 848 | #include <qpe/config.h> |
847 | 849 | ||
848 | #include <sys/ioctl.h> | 850 | #include <sys/ioctl.h> |
849 | #include <sys/types.h> | 851 | #include <sys/types.h> |
850 | #include <fcntl.h> | 852 | #include <fcntl.h> |
851 | #include <unistd.h> | 853 | #include <unistd.h> |
852 | #include <errno.h> | 854 | #include <errno.h> |
853 | #include <linux/ioctl.h> | 855 | #include <linux/ioctl.h> |
854 | #include <time.h> | 856 | #include <time.h> |
855 | #endif | 857 | #endif |
856 | 858 | ||
857 | 859 | ||
858 | void Desktop::togglePower() | 860 | void Desktop::togglePower() |
859 | { | 861 | { |
860 | static bool excllock = false; | 862 | static bool excllock = false; |
861 | 863 | ||
862 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); | 864 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); |
863 | 865 | ||
864 | if ( excllock ) | 866 | if ( excllock ) |
865 | return ; | 867 | return; |
866 | 868 | ||
867 | excllock = true; | 869 | excllock = true; |
868 | 870 | ||
869 | bool wasloggedin = loggedin; | 871 | bool wasloggedin = loggedin; |
870 | loggedin = 0; | 872 | loggedin = 0; |
871 | suspendTime = QDateTime::currentDateTime(); | 873 | suspendTime = QDateTime::currentDateTime(); |
872 | 874 | ||
873 | ODevice::inst ( ) -> suspend ( ); | 875 | #ifdef QWS |
876 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | ||
877 | // Should use a big black window instead. | ||
878 | // But this would not show up fast enough | ||
879 | QGfx *g = qt_screen-> screenGfx ( ); | ||
880 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | ||
881 | delete g; | ||
882 | } | ||
883 | #endif | ||
884 | |||
885 | ODevice::inst ( )-> suspend ( ); | ||
874 | 886 | ||
875 | QWSServer::screenSaverActivate ( false ); | ||
876 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 887 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
888 | QWSServer::screenSaverActivate ( false ); | ||
877 | 889 | ||
878 | { | 890 | { |
879 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 891 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
880 | } | 892 | } |
881 | 893 | ||
882 | if ( wasloggedin ) | 894 | if ( wasloggedin ) |
883 | login( TRUE ); | 895 | login ( true ); |
884 | 896 | ||
885 | execAutoStart(); | 897 | execAutoStart(); |
886 | //qcopBridge->closeOpenConnections(); | 898 | //qcopBridge->closeOpenConnections(); |
887 | 899 | ||
888 | excllock = false; | 900 | excllock = false; |
889 | } | 901 | } |
890 | 902 | ||
891 | void Desktop::toggleLight() | 903 | void Desktop::toggleLight() |
892 | { | 904 | { |
893 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 905 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
894 | e << -2; // toggle | 906 | e << -2; // toggle |
895 | } | 907 | } |
896 | 908 | ||
897 | void Desktop::toggleSymbolInput() | 909 | void Desktop::toggleSymbolInput() |
898 | { | 910 | { |
899 | tb->toggleSymbolInput(); | 911 | tb->toggleSymbolInput(); |
900 | } | 912 | } |
901 | 913 | ||
902 | void Desktop::toggleNumLockState() | 914 | void Desktop::toggleNumLockState() |
903 | { | 915 | { |
904 | tb->toggleNumLockState(); | 916 | tb->toggleNumLockState(); |
905 | } | 917 | } |
906 | 918 | ||
907 | void Desktop::toggleCapsLockState() | 919 | void Desktop::toggleCapsLockState() |
908 | { | 920 | { |
909 | tb->toggleCapsLockState(); | 921 | tb->toggleCapsLockState(); |
910 | } | 922 | } |
911 | 923 | ||
912 | void Desktop::styleChange( QStyle &s ) | 924 | void Desktop::styleChange( QStyle &s ) |
913 | { | 925 | { |
914 | QWidget::styleChange( s ); | 926 | QWidget::styleChange( s ); |
915 | int displayw = qApp->desktop() ->width(); | 927 | int displayw = qApp->desktop() ->width(); |
diff --git a/library/password.cpp b/library/password.cpp index 4b22b65..6d126c4 100644 --- a/library/password.cpp +++ b/library/password.cpp | |||
@@ -1,62 +1,62 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "password.h" | 20 | #include "password.h" |
21 | #include "config.h" | 21 | #include "config.h" |
22 | #include "global.h" | 22 | #include "global.h" |
23 | #include "backend/contact.h" | 23 | #include "backend/contact.h" |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlineedit.h> | 25 | #include <qlineedit.h> |
26 | #include <qtextview.h> | 26 | #include <qtextview.h> |
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include <qapplication.h> | 28 | #include <qapplication.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qwindowsystem_qws.h> | 30 | //#include <qwindowsystem_qws.h> |
31 | 31 | ||
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | 33 | ||
34 | #include <unistd.h> //for sleep | 34 | #include <unistd.h> //for sleep |
35 | #include "passwordbase_p.h" | 35 | #include "passwordbase_p.h" |
36 | 36 | ||
37 | class PasswordDialog : public PasswordBase | 37 | class PasswordDialog : public PasswordBase |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | 40 | ||
41 | public: | 41 | public: |
42 | PasswordDialog( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 42 | PasswordDialog( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
43 | ~PasswordDialog(); | 43 | ~PasswordDialog(); |
44 | 44 | ||
45 | void clear(); | 45 | void clear(); |
46 | void setPrompt( const QString& ); | 46 | void setPrompt( const QString& ); |
47 | 47 | ||
48 | signals: | 48 | signals: |
49 | void passwordEntered( const QString& ); | 49 | void passwordEntered( const QString& ); |
50 | 50 | ||
51 | protected: | 51 | protected: |
52 | bool eventFilter( QObject*, QEvent* ); | 52 | bool eventFilter( QObject*, QEvent* ); |
53 | void keyPressEvent( QKeyEvent * ); | 53 | void keyPressEvent( QKeyEvent * ); |
54 | 54 | ||
55 | private: | 55 | private: |
56 | void input( QString ); | 56 | void input( QString ); |
57 | friend class Password; | 57 | friend class Password; |
58 | QString text; | 58 | QString text; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | 61 | ||
62 | extern "C" char *crypt(const char *key, const char *salt); | 62 | extern "C" char *crypt(const char *key, const char *salt); |
@@ -256,78 +256,98 @@ public: | |||
256 | 256 | ||
257 | private: | 257 | private: |
258 | QTextView *tv; | 258 | QTextView *tv; |
259 | }; | 259 | }; |
260 | 260 | ||
261 | /*! | 261 | /*! |
262 | Returns a crypted password entered by the user when prompted with \a prompt | 262 | Returns a crypted password entered by the user when prompted with \a prompt |
263 | The returned value is QString::null if the user cancels the operation, | 263 | The returned value is QString::null if the user cancels the operation, |
264 | or the empty string if the user enters no password (but confirms the | 264 | or the empty string if the user enters no password (but confirms the |
265 | dialog). | 265 | dialog). |
266 | */ | 266 | */ |
267 | 267 | ||
268 | QString Password::getPassword( const QString& prompt ) | 268 | QString Password::getPassword( const QString& prompt ) |
269 | { | 269 | { |
270 | PasswdDlg pd(0,0,TRUE); | 270 | PasswdDlg pd(0,0,TRUE); |
271 | pd.passw->setPrompt( prompt ); | 271 | pd.passw->setPrompt( prompt ); |
272 | 272 | ||
273 | pd.showMaximized(); | 273 | pd.showMaximized(); |
274 | int r = pd.exec(); | 274 | int r = pd.exec(); |
275 | 275 | ||
276 | if ( r == QDialog::Accepted ) { | 276 | if ( r == QDialog::Accepted ) { |
277 | if (pd.passw->text.isEmpty()) | 277 | if (pd.passw->text.isEmpty()) |
278 | return ""; | 278 | return ""; |
279 | else | 279 | else |
280 | return qcrypt(pd.passw->text,"a0"); | 280 | return qcrypt(pd.passw->text,"a0"); |
281 | } else { | 281 | } else { |
282 | return QString::null; | 282 | return QString::null; |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | 286 | ||
287 | /*! | 287 | /*! |
288 | Return if a prompt for the user's passcode is needed. | ||
289 | |||
290 | If \a at_poweron is TRUE, the dialog is only used if the user's | ||
291 | preference request it at poweron | ||
292 | |||
293 | Opie extension to speed up suspend/resume. | ||
294 | */ | ||
295 | |||
296 | bool Password::needToAuthenticate(bool at_poweron) | ||
297 | { | ||
298 | Config cfg("Security"); | ||
299 | cfg.setGroup("Passcode"); | ||
300 | QString passcode = cfg.readEntry("passcode"); | ||
301 | |||
302 | return ( !passcode.isEmpty() | ||
303 | && (!at_poweron || cfg.readNumEntry("passcode_poweron",0)) ); | ||
304 | } | ||
305 | |||
306 | /*! | ||
288 | Prompt, fullscreen, for the user's passcode until they get it right. | 307 | Prompt, fullscreen, for the user's passcode until they get it right. |
289 | 308 | ||
290 | If \a at_poweron is TRUE, the dialog is only used if the user's | 309 | If \a at_poweron is TRUE, the dialog is only used if the user's |
291 | preference request it at poweron; either way, the screen is always repainted | 310 | preference request it at poweron; either way, the screen is always repainted |
292 | by this function. (this functionality may move to the caller of this function). | 311 | by this function. (this functionality may move to the caller of this function). |
293 | */ | 312 | */ |
294 | 313 | ||
295 | void Password::authenticate(bool at_poweron) | 314 | void Password::authenticate(bool at_poweron) |
296 | { | 315 | { |
297 | Config cfg("Security"); | 316 | Config cfg("Security"); |
298 | cfg.setGroup("Passcode"); | 317 | cfg.setGroup("Passcode"); |
299 | QString passcode = cfg.readEntry("passcode"); | 318 | QString passcode = cfg.readEntry("passcode"); |
300 | if ( !passcode.isEmpty() | 319 | if ( !passcode.isEmpty() |
301 | && (!at_poweron || cfg.readNumEntry("passcode_poweron",0)) ) | 320 | && (!at_poweron || cfg.readNumEntry("passcode_poweron",0)) ) |
302 | { | 321 | { |
303 | // Do it as a fullscreen modal dialog | 322 | // Do it as a fullscreen modal dialog |
304 | PasswdDlg pd(0,0,TRUE,TRUE); | 323 | PasswdDlg pd(0,0,TRUE,TRUE); |
305 | 324 | ||
306 | // see if there is contact information. | 325 | // see if there is contact information. |
307 | OwnerDlg *oi = 0; | 326 | OwnerDlg *oi = 0; |
308 | QString vfilename = Global::applicationFileName("addressbook", | 327 | QString vfilename = Global::applicationFileName("addressbook", |
309 | "businesscard.vcf"); | 328 | "businesscard.vcf"); |
310 | if (QFile::exists(vfilename)) { | 329 | if (QFile::exists(vfilename)) { |
311 | Contact c; | 330 | Contact c; |
312 | c = Contact::readVCard( vfilename )[0]; | 331 | c = Contact::readVCard( vfilename )[0]; |
313 | 332 | ||
314 | oi = new OwnerDlg(0, 0, c, TRUE, TRUE); | 333 | oi = new OwnerDlg(0, 0, c, TRUE, TRUE); |
315 | } | 334 | } |
316 | 335 | ||
317 | pd.reset(); | 336 | pd.reset(); |
318 | pd.exec(); | 337 | pd.exec(); |
319 | while (qcrypt(pd.passw->text, "a0") != passcode) { | 338 | while (qcrypt(pd.passw->text, "a0") != passcode) { |
320 | if (oi) | 339 | if (oi) |
321 | oi->exec(); | 340 | oi->exec(); |
322 | pd.reset(); | 341 | pd.reset(); |
323 | pd.exec(); | 342 | pd.exec(); |
324 | } | 343 | } |
325 | } else if ( at_poweron ) { | 344 | } else if ( at_poweron ) { |
326 | // refresh screen #### should probably be in caller | 345 | // refresh screen #### should probably be in caller |
327 | // Not needed (we took away the screen blacking) | 346 | // Not needed (we took away the screen blacking) TT |
347 | // Not needed (we have intelligent screen blacking) sandman | ||
328 | //if ( qwsServer ) | 348 | //if ( qwsServer ) |
329 | //qwsServer->refresh(); | 349 | //qwsServer->refresh(); |
330 | } | 350 | } |
331 | } | 351 | } |
332 | 352 | ||
333 | #include "password.moc" | 353 | #include "password.moc" |
diff --git a/library/password.h b/library/password.h index a3a3e45..a2f2c3c 100644 --- a/library/password.h +++ b/library/password.h | |||
@@ -1,32 +1,33 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PASSWORD_H | 20 | #ifndef PASSWORD_H |
21 | #define PASSWORD_H | 21 | #define PASSWORD_H |
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | 24 | ||
25 | class Password | 25 | class Password |
26 | { | 26 | { |
27 | public: | 27 | public: |
28 | static bool needToAuthenticate(bool atpoweron=FALSE); // Opie extension to speed up suspend/resume (sandman) | ||
28 | static void authenticate(bool atpoweron=FALSE); | 29 | static void authenticate(bool atpoweron=FALSE); |
29 | static QString getPassword( const QString& prompt ); | 30 | static QString getPassword( const QString& prompt ); |
30 | }; | 31 | }; |
31 | 32 | ||
32 | #endif // PASSWORD_H | 33 | #endif // PASSWORD_H |