summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opie-login/loginwindowimpl.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp
index ac24894..547a9b3 100644
--- a/core/opie-login/loginwindowimpl.cpp
+++ b/core/opie-login/loginwindowimpl.cpp
@@ -1,262 +1,259 @@
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 < 0x030000 36#if QT_VERSION < 0x030000
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>
42#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
43#include <qpe/config.h> 42#include <qpe/config.h>
44 43
45#include <opie2/odevice.h> 44#include <opie2/odevice.h>
45#include <opie2/oresource.h>
46 46
47#include <stdio.h> 47#include <stdio.h>
48#include <stdlib.h> 48#include <stdlib.h>
49 49
50#include "passworddialogimpl.h" 50#include "passworddialogimpl.h"
51#include "loginwindowimpl.h" 51#include "loginwindowimpl.h"
52#include "loginapplication.h" 52#include "loginapplication.h"
53#include "inputmethods.h" 53#include "inputmethods.h"
54 54
55using namespace Opie::Core; 55using namespace Opie::Core;
56 56
57 57
58LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) 58LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose )
59{ 59{
60 QPopupMenu *pop = new QPopupMenu ( this ); 60 QPopupMenu *pop = new QPopupMenu ( this );
61 pop-> insertItem ( tr( "Restart" ), this, SLOT( restart())); 61 pop-> insertItem ( tr( "Restart" ), this, SLOT( restart()));
62 pop-> insertItem ( tr( "Quit" ), this, SLOT( quit())); 62 pop-> insertItem ( tr( "Quit" ), this, SLOT( quit()));
63 m_menu-> setPopup ( pop ); 63 m_menu-> setPopup ( pop );
64 64
65 QCopChannel *channel = new QCopChannel ( "QPE/TaskBar", this ); 65 QCopChannel *channel = new QCopChannel ( "QPE/TaskBar", this );
66 connect ( channel, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( receive(const QCString&,const QByteArray&))); 66 connect ( channel, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( receive(const QCString&,const QByteArray&)));
67 67
68 QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); 68 QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 );
69 m_input = new InputMethods ( m_taskbar ); 69 m_input = new InputMethods ( m_taskbar );
70 connect ( m_input, SIGNAL( inputToggled(bool)), this, SLOT( calcMaxWindowRect())); 70 connect ( m_input, SIGNAL( inputToggled(bool)), this, SLOT( calcMaxWindowRect()));
71 lay-> addWidget ( m_input ); 71 lay-> addWidget ( m_input );
72 lay-> addStretch ( 10 ); 72 lay-> addStretch ( 10 );
73 73
74 setActiveWindow ( ); 74 setActiveWindow ( );
75 m_password-> setFocus ( ); 75 m_password-> setFocus ( );
76 76
77 m_user-> insertStringList ( lApp-> allUsers ( )); 77 m_user-> insertStringList ( lApp-> allUsers ( ));
78 78
79 //there is no point in displaying the IM for a zaurus 79 //there is no point in displaying the IM for a zaurus
80 if (ODevice::inst ( )-> series ( ) != Model_Zaurus){ 80 if (ODevice::inst ( )-> series ( ) != Model_Zaurus){
81 QTimer::singleShot ( 0, this, SLOT( showIM())); 81 QTimer::singleShot ( 0, this, SLOT( showIM()));
82 } 82 }
83 83
84 QString opiedir = ::getenv ( "OPIEDIR" ); 84 QString opiedir = ::getenv ( "OPIEDIR" );
85 QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); 85 QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" );
86 86
87 if ( !bgpix. isNull ( )) { 87 if ( !bgpix. isNull ( )) {
88 setBackgroundPixmap ( bgpix ); 88 setBackgroundPixmap ( bgpix );
89 m_caption-> setBackgroundPixmap ( bgpix); 89 m_caption-> setBackgroundPixmap ( bgpix);
90 TextLabel1-> setBackgroundPixmap ( bgpix); 90 TextLabel1-> setBackgroundPixmap ( bgpix);
91 TextLabel2-> setBackgroundPixmap ( bgpix); 91 TextLabel2-> setBackgroundPixmap ( bgpix);
92 } 92 }
93 93
94 //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 //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 ( )));
95 95
96 Config cfg ( "opie-login" ); 96 Config cfg ( "opie-login" );
97 cfg. setGroup ( "General" ); 97 cfg. setGroup ( "General" );
98 QString last = cfg. readEntry ( "LastLogin" ); 98 QString last = cfg. readEntry ( "LastLogin" );
99 99
100 if ( !last. isEmpty ( )) 100 if ( !last. isEmpty ( ))
101 m_user-> setEditText ( last ); 101 m_user-> setEditText ( last );
102 102
103 calcMaxWindowRect ( ); 103 calcMaxWindowRect ( );
104 104
105 if ( PasswordDialogImpl::needDialog() ) 105 if ( PasswordDialogImpl::needDialog() )
106 QTimer::singleShot(10, this, SLOT(showPasswordDialog()) ); 106 QTimer::singleShot(10, this, SLOT(showPasswordDialog()) );
107 107
108 108
109} 109}
110 110
111LoginWindowImpl::~LoginWindowImpl ( ) 111LoginWindowImpl::~LoginWindowImpl ( )
112{ 112{
113} 113}
114 114
115 115
116void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data ) 116void LoginWindowImpl::receive ( const QCString &msg, const QByteArray &data )
117{ 117{
118 QDataStream stream ( data, IO_ReadOnly ); 118 QDataStream stream ( data, IO_ReadOnly );
119 119
120 if ( msg == "hideInputMethod()" ) 120 if ( msg == "hideInputMethod()" )
121 m_input-> hideInputMethod ( ); 121 m_input-> hideInputMethod ( );
122 else if ( msg == "showInputMethod()" ) 122 else if ( msg == "showInputMethod()" )
123 m_input-> showInputMethod ( ); 123 m_input-> showInputMethod ( );
124 else if ( msg == "reloadInputMethods()" ) 124 else if ( msg == "reloadInputMethods()" )
125 m_input-> loadInputMethods ( ); 125 m_input-> loadInputMethods ( );
126} 126}
127 127
128void LoginWindowImpl::calcMaxWindowRect ( ) 128void LoginWindowImpl::calcMaxWindowRect ( )
129{ 129{
130#ifdef Q_WS_QWS 130#ifdef Q_WS_QWS
131 QRect wr; 131 QRect wr;
132 int displayWidth = qApp-> desktop ( )-> width ( ); 132 int displayWidth = qApp-> desktop ( )-> width ( );
133 QRect ir = m_input-> inputRect ( ); 133 QRect ir = m_input-> inputRect ( );
134 if ( ir.isValid() ) 134 if ( ir.isValid() )
135 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 135 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
136 else 136 else
137 wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 ); 137 wr.setCoords( 0, 0, displayWidth-1, m_taskbar->y()-1 );
138 138
139#if QT_VERSION < 0x030000 139#if QT_VERSION < 0x030000
140 wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 140 wr = qt_screen-> mapToDevice ( wr, QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
141#endif 141#endif
142 142
143 QWSServer::setMaxWindowRect( wr ); 143 QWSServer::setMaxWindowRect( wr );
144#endif 144#endif
145} 145}
146 146
147 147
148void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) 148void LoginWindowImpl::keyPressEvent ( QKeyEvent *e )
149{ 149{
150 switch ( e-> key ( )) { 150 switch ( e-> key ( )) {
151 case HardKey_Suspend: suspend ( ); 151 case HardKey_Suspend: suspend ( );
152 break; 152 break;
153 case HardKey_Backlight: backlight ( ); 153 case HardKey_Backlight: backlight ( );
154 break; 154 break;
155 default: e-> ignore ( ); 155 default: e-> ignore ( );
156 break; 156 break;
157 } 157 }
158 LoginWindow::keyPressEvent ( e ); 158 LoginWindow::keyPressEvent ( e );
159} 159}
160 160
161 161
162void LoginWindowImpl::toggleEchoMode ( bool t ) 162void LoginWindowImpl::toggleEchoMode ( bool t )
163{ 163{
164 m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); 164 m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password );
165} 165}
166 166
167void LoginWindowImpl::showIM ( ) 167void LoginWindowImpl::showIM ( )
168{ 168{
169 m_input-> showInputMethod ( ); 169 m_input-> showInputMethod ( );
170} 170}
171 171
172void LoginWindowImpl::restart ( ) 172void LoginWindowImpl::restart ( )
173{ 173{
174 qApp-> quit ( ); 174 qApp-> quit ( );
175} 175}
176 176
177void LoginWindowImpl::quit ( ) 177void LoginWindowImpl::quit ( )
178{ 178{
179 lApp-> quitToConsole ( ); 179 lApp-> quitToConsole ( );
180} 180}
181 181
182void LoginWindowImpl::suspend ( ) 182void LoginWindowImpl::suspend ( )
183{ 183{
184 ODevice::inst ( )-> suspend ( ); 184 ODevice::inst ( )-> suspend ( );
185 185
186 QCopEnvelope e("QPE/System", "setBacklight(int)"); 186 QCopEnvelope e("QPE/System", "setBacklight(int)");
187 e << -3; // Force on 187 e << -3; // Force on
188} 188}
189 189
190void LoginWindowImpl::backlight ( ) 190void LoginWindowImpl::backlight ( )
191{ 191{
192 QCopEnvelope e("QPE/System", "setBacklight(int)"); 192 QCopEnvelope e("QPE/System", "setBacklight(int)");
193 e << -2; // toggle 193 e << -2; // toggle
194} 194}
195 195
196class WaitLogo : public QLabel { 196class WaitLogo : public QLabel {
197public: 197public:
198 WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool ) 198 WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool )
199 { 199 {
200 QImage img = Resource::loadImage ( "launcher/new_wait" ); 200 setPixmap( Opie::Core::OResource::loadPixmap( "launcher/new_wait" ) );
201 QPixmap pix;
202 pix. convertFromImage ( img );
203 setPixmap ( pix );
204 setAlignment ( AlignCenter ); 201 setAlignment ( AlignCenter );
205 move ( 0, 0 ); 202 move ( 0, 0 );
206 resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( )); 203 resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( ));
207 204
208 m_visible = false; 205 m_visible = false;
209 show ( ); 206 show ( );
210 } 207 }
211 208
212 virtual void showEvent ( QShowEvent *e ) 209 virtual void showEvent ( QShowEvent *e )
213 { 210 {
214 QLabel::showEvent ( e ); 211 QLabel::showEvent ( e );
215 m_visible = true; 212 m_visible = true;
216 } 213 }
217 214
218 virtual void paintEvent ( QPaintEvent *e ) 215 virtual void paintEvent ( QPaintEvent *e )
219 { 216 {
220 QLabel::paintEvent ( e ); 217 QLabel::paintEvent ( e );
221 if ( m_visible ) 218 if ( m_visible )
222 qApp-> quit ( ); 219 qApp-> quit ( );
223 } 220 }
224 221
225private: 222private:
226 bool m_visible; 223 bool m_visible;
227}; 224};
228 225
229void LoginWindowImpl::login ( ) 226void LoginWindowImpl::login ( )
230{ 227{
231 const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); 228 const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( ));
232 const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); 229 const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( ));
233 230
234 if ( !user || !user [0] ) 231 if ( !user || !user [0] )
235 return; 232 return;
236 if ( !pass ) 233 if ( !pass )
237 pass = ""; 234 pass = "";
238 235
239 if ( lApp-> checkPassword ( user, pass )) { 236 if ( lApp-> checkPassword ( user, pass )) {
240 Config cfg ( "opie-login" ); 237 Config cfg ( "opie-login" );
241 cfg. setGroup ( "General" ); 238 cfg. setGroup ( "General" );
242 cfg. writeEntry ( "LastLogin", user ); 239 cfg. writeEntry ( "LastLogin", user );
243 cfg. write ( ); 240 cfg. write ( );
244 241
245 lApp-> setLoginAs ( user ); 242 lApp-> setLoginAs ( user );
246 243
247 // Draw a big wait icon, the image can be altered in later revisions 244 // Draw a big wait icon, the image can be altered in later revisions
248 m_input-> hideInputMethod ( ); 245 m_input-> hideInputMethod ( );
249 new WaitLogo ( ); 246 new WaitLogo ( );
250 // WaitLogo::showEvent() calls qApp-> quit() 247 // WaitLogo::showEvent() calls qApp-> quit()
251 } 248 }
252 else { 249 else {
253 QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." )); 250 QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." ));
254 m_password-> clear ( ); 251 m_password-> clear ( );
255 } 252 }
256} 253}
257 254
258void LoginWindowImpl::showPasswordDialog() { 255void LoginWindowImpl::showPasswordDialog() {
259 PasswordDialogImpl dia( this ); 256 PasswordDialogImpl dia( this );
260 dia.showMaximized(); 257 dia.showMaximized();
261 dia.exec(); 258 dia.exec();
262} 259}