author | harlekin <harlekin> | 2002-08-01 00:42:55 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-01 00:42:55 (UTC) |
commit | 26ff0c72228b9c89b079dfa381d448b6152eb408 (patch) (unidiff) | |
tree | 580c72ab759332a1fc3b3ae12fa26447090a682c | |
parent | b2978cf32ae5e6954fb118c89c1f70ee05d53ef4 (diff) | |
download | opie-26ff0c72228b9c89b079dfa381d448b6152eb408.zip opie-26ff0c72228b9c89b079dfa381d448b6152eb408.tar.gz opie-26ff0c72228b9c89b079dfa381d448b6152eb408.tar.bz2 |
gcc3.X fixes
-rw-r--r-- | core/apps/calibrate/calibrate.cpp | 2 | ||||
-rw-r--r-- | core/opie-login/loginwindowimpl.cpp | 1 | ||||
-rw-r--r-- | core/opie-login/main.cpp | 1 | ||||
-rw-r--r-- | core/opie-login/opie-login.pro | 4 |
4 files changed, 6 insertions, 2 deletions
diff --git a/core/apps/calibrate/calibrate.cpp b/core/apps/calibrate/calibrate.cpp index 1f4fb1b..b9ad73d 100644 --- a/core/apps/calibrate/calibrate.cpp +++ b/core/apps/calibrate/calibrate.cpp | |||
@@ -1,251 +1,253 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 | 20 | ||
21 | #include <math.h> | ||
22 | |||
21 | #include "calibrate.h" | 23 | #include "calibrate.h" |
22 | 24 | ||
23 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
24 | 26 | ||
25 | #include <qapplication.h> | 27 | #include <qapplication.h> |
26 | 28 | ||
27 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 29 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
28 | 30 | ||
29 | #include <qpainter.h> | 31 | #include <qpainter.h> |
30 | #include <qtimer.h> | 32 | #include <qtimer.h> |
31 | #include <qwindowsystem_qws.h> | 33 | #include <qwindowsystem_qws.h> |
32 | #include <qgfx_qws.h> | 34 | #include <qgfx_qws.h> |
33 | 35 | ||
34 | 36 | ||
35 | Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) : | 37 | Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) : |
36 | QDialog( parent, name, TRUE, wf | WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop ) | 38 | QDialog( parent, name, TRUE, wf | WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop ) |
37 | { | 39 | { |
38 | showCross = TRUE; | 40 | showCross = TRUE; |
39 | const int offset = 30; | 41 | const int offset = 30; |
40 | QRect desk = qApp->desktop() ->geometry(); | 42 | QRect desk = qApp->desktop() ->geometry(); |
41 | setGeometry( 0, 0, desk.width(), desk.height() ); | 43 | setGeometry( 0, 0, desk.width(), desk.height() ); |
42 | if ( desk.height() < 250 ) { | 44 | if ( desk.height() < 250 ) { |
43 | int w = desk.height() / 3; | 45 | int w = desk.height() / 3; |
44 | logo.convertFromImage( Resource::loadImage( "launcher/opielogo" ).smoothScale( w, w ) ); | 46 | logo.convertFromImage( Resource::loadImage( "launcher/opielogo" ).smoothScale( w, w ) ); |
45 | } | 47 | } |
46 | else { | 48 | else { |
47 | logo = Resource::loadPixmap( "launcher/opielogo" ); | 49 | logo = Resource::loadPixmap( "launcher/opielogo" ); |
48 | } | 50 | } |
49 | cd.screenPoints[ QWSPointerCalibrationData::TopLeft ] = QPoint( offset, offset ); | 51 | cd.screenPoints[ QWSPointerCalibrationData::TopLeft ] = QPoint( offset, offset ); |
50 | cd.screenPoints[ QWSPointerCalibrationData::BottomLeft ] = QPoint( offset, qt_screen->deviceHeight() - offset ); | 52 | cd.screenPoints[ QWSPointerCalibrationData::BottomLeft ] = QPoint( offset, qt_screen->deviceHeight() - offset ); |
51 | cd.screenPoints[ QWSPointerCalibrationData::BottomRight ] = QPoint( qt_screen->deviceWidth() - offset, qt_screen->deviceHeight() - offset ); | 53 | cd.screenPoints[ QWSPointerCalibrationData::BottomRight ] = QPoint( qt_screen->deviceWidth() - offset, qt_screen->deviceHeight() - offset ); |
52 | cd.screenPoints[ QWSPointerCalibrationData::TopRight ] = QPoint( qt_screen->deviceWidth() - offset, offset ); | 54 | cd.screenPoints[ QWSPointerCalibrationData::TopRight ] = QPoint( qt_screen->deviceWidth() - offset, offset ); |
53 | cd.screenPoints[ QWSPointerCalibrationData::Center ] = QPoint( qt_screen->deviceWidth() / 2, qt_screen->deviceHeight() / 2 ); | 55 | cd.screenPoints[ QWSPointerCalibrationData::Center ] = QPoint( qt_screen->deviceWidth() / 2, qt_screen->deviceHeight() / 2 ); |
54 | goodcd = cd; | 56 | goodcd = cd; |
55 | reset(); | 57 | reset(); |
56 | 58 | ||
57 | timer = new QTimer( this ); | 59 | timer = new QTimer( this ); |
58 | connect( timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); | 60 | connect( timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); |
59 | } | 61 | } |
60 | 62 | ||
61 | Calibrate::~Calibrate() | 63 | Calibrate::~Calibrate() |
62 | { | 64 | { |
63 | store(); | 65 | store(); |
64 | } | 66 | } |
65 | 67 | ||
66 | void Calibrate::show() | 68 | void Calibrate::show() |
67 | { | 69 | { |
68 | grabMouse(); | 70 | grabMouse(); |
69 | QWSServer::mouseHandler() ->getCalibration( &goodcd ); | 71 | QWSServer::mouseHandler() ->getCalibration( &goodcd ); |
70 | QWSServer::mouseHandler() ->clearCalibration(); | 72 | QWSServer::mouseHandler() ->clearCalibration(); |
71 | QDialog::show(); | 73 | QDialog::show(); |
72 | } | 74 | } |
73 | 75 | ||
74 | void Calibrate::store() | 76 | void Calibrate::store() |
75 | { | 77 | { |
76 | QWSServer::mouseHandler() ->calibrate( &goodcd ); | 78 | QWSServer::mouseHandler() ->calibrate( &goodcd ); |
77 | } | 79 | } |
78 | 80 | ||
79 | void Calibrate::hide() | 81 | void Calibrate::hide() |
80 | { | 82 | { |
81 | if ( isVisible() ) | 83 | if ( isVisible() ) |
82 | store(); | 84 | store(); |
83 | QDialog::hide(); | 85 | QDialog::hide(); |
84 | } | 86 | } |
85 | 87 | ||
86 | void Calibrate::reset() | 88 | void Calibrate::reset() |
87 | { | 89 | { |
88 | penPos = QPoint(); | 90 | penPos = QPoint(); |
89 | location = QWSPointerCalibrationData::TopLeft; | 91 | location = QWSPointerCalibrationData::TopLeft; |
90 | crossPos = fromDevice( cd.screenPoints[ location ] ); | 92 | crossPos = fromDevice( cd.screenPoints[ location ] ); |
91 | } | 93 | } |
92 | 94 | ||
93 | QPoint Calibrate::fromDevice( const QPoint &p ) | 95 | QPoint Calibrate::fromDevice( const QPoint &p ) |
94 | { | 96 | { |
95 | return qt_screen->mapFromDevice ( p, QSize( qt_screen->deviceWidth ( ), qt_screen->deviceHeight() ) ); | 97 | return qt_screen->mapFromDevice ( p, QSize( qt_screen->deviceWidth ( ), qt_screen->deviceHeight() ) ); |
96 | } | 98 | } |
97 | 99 | ||
98 | bool Calibrate::sanityCheck() | 100 | bool Calibrate::sanityCheck() |
99 | { | 101 | { |
100 | QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft]; | 102 | QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft]; |
101 | QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight]; | 103 | QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight]; |
102 | QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft]; | 104 | QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft]; |
103 | QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight]; | 105 | QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight]; |
104 | 106 | ||
105 | // not needed anywhere .. just calculate it, so it's there | 107 | // not needed anywhere .. just calculate it, so it's there |
106 | cd. devPoints [QWSPointerCalibrationData::Center] = QRect ( tl, br ). normalize ( ). center ( ); | 108 | cd. devPoints [QWSPointerCalibrationData::Center] = QRect ( tl, br ). normalize ( ). center ( ); |
107 | 109 | ||
108 | int dlx = QABS( bl. x ( ) - tl. x ( )); | 110 | int dlx = QABS( bl. x ( ) - tl. x ( )); |
109 | int dly = QABS( bl. y ( ) - tl. y ( )); | 111 | int dly = QABS( bl. y ( ) - tl. y ( )); |
110 | int drx = QABS( br. x ( ) - tr. x ( )); | 112 | int drx = QABS( br. x ( ) - tr. x ( )); |
111 | int dry = QABS( br. y ( ) - tr. y ( )); | 113 | int dry = QABS( br. y ( ) - tr. y ( )); |
112 | int dtx = QABS( tr. x ( ) - tl. x ( )); | 114 | int dtx = QABS( tr. x ( ) - tl. x ( )); |
113 | int dty = QABS( tr. y ( ) - tl. y ( )); | 115 | int dty = QABS( tr. y ( ) - tl. y ( )); |
114 | int dbx = QABS( br. x ( ) - bl. x ( )); | 116 | int dbx = QABS( br. x ( ) - bl. x ( )); |
115 | int dby = QABS( br. y ( ) - bl. y ( )); | 117 | int dby = QABS( br. y ( ) - bl. y ( )); |
116 | 118 | ||
117 | int dl = (int) ::sqrt (( dlx * dlx ) + ( dly * dly )); // calculate vector lengths for all sides | 119 | int dl = (int) ::sqrt (( dlx * dlx ) + ( dly * dly )); // calculate vector lengths for all sides |
118 | int dr = (int) ::sqrt (( drx * drx ) + ( dry * dry )); | 120 | int dr = (int) ::sqrt (( drx * drx ) + ( dry * dry )); |
119 | int dt = (int) ::sqrt (( dtx * dtx ) + ( dty * dty )); | 121 | int dt = (int) ::sqrt (( dtx * dtx ) + ( dty * dty )); |
120 | int db = (int) ::sqrt (( dbx * dbx ) + ( dby * dby )); | 122 | int db = (int) ::sqrt (( dbx * dbx ) + ( dby * dby )); |
121 | 123 | ||
122 | // Calculate leeway for x/y (we do not care if diff1/diff2 is for x or y here !) | 124 | // Calculate leeway for x/y (we do not care if diff1/diff2 is for x or y here !) |
123 | int diff1 = QABS( dl - dr ); | 125 | int diff1 = QABS( dl - dr ); |
124 | int avg1 = ( dl + dr ) / 2; | 126 | int avg1 = ( dl + dr ) / 2; |
125 | int diff2 = QABS( dt - db ); | 127 | int diff2 = QABS( dt - db ); |
126 | int avg2 = ( dt + db ) / 2; | 128 | int avg2 = ( dt + db ) / 2; |
127 | 129 | ||
128 | // Calculate leeway for "real" vector length against "manhattan" vector length | 130 | // Calculate leeway for "real" vector length against "manhattan" vector length |
129 | // This is a check, if the rect is rotated (other then 0/90/180/270) | 131 | // This is a check, if the rect is rotated (other then 0/90/180/270) |
130 | // It needs to be performed only for the triange (bl, tl, tr) | 132 | // It needs to be performed only for the triange (bl, tl, tr) |
131 | int diff3 = QABS(( dlx + dly + dtx + dty ) - ( dl + dt )); | 133 | int diff3 = QABS(( dlx + dly + dtx + dty ) - ( dl + dt )); |
132 | int avg3 = (( dlx + dly + dtx + dty ) + ( dl + dt )) / 2; | 134 | int avg3 = (( dlx + dly + dtx + dty ) + ( dl + dt )) / 2; |
133 | 135 | ||
134 | if (( diff1 > ( avg1 / 20 )) || // 5% leeway | 136 | if (( diff1 > ( avg1 / 20 )) || // 5% leeway |
135 | ( diff2 > ( avg2 / 20 )) || | 137 | ( diff2 > ( avg2 / 20 )) || |
136 | ( diff3 > ( avg3 / 20 ))) | 138 | ( diff3 > ( avg3 / 20 ))) |
137 | return false; | 139 | return false; |
138 | else | 140 | else |
139 | return true; | 141 | return true; |
140 | } | 142 | } |
141 | 143 | ||
142 | void Calibrate::moveCrosshair( QPoint pt ) | 144 | void Calibrate::moveCrosshair( QPoint pt ) |
143 | { | 145 | { |
144 | showCross = FALSE; | 146 | showCross = FALSE; |
145 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); | 147 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); |
146 | showCross = TRUE; | 148 | showCross = TRUE; |
147 | crossPos = pt; | 149 | crossPos = pt; |
148 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); | 150 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); |
149 | } | 151 | } |
150 | 152 | ||
151 | void Calibrate::paintEvent( QPaintEvent * ) | 153 | void Calibrate::paintEvent( QPaintEvent * ) |
152 | { | 154 | { |
153 | QPainter p( this ); | 155 | QPainter p( this ); |
154 | 156 | ||
155 | int y; | 157 | int y; |
156 | 158 | ||
157 | if ( !logo.isNull() ) { | 159 | if ( !logo.isNull() ) { |
158 | y = height() / 2 - logo.height() - 15; | 160 | y = height() / 2 - logo.height() - 15; |
159 | p.drawPixmap( ( width() - logo.width() ) / 2, y, logo ); | 161 | p.drawPixmap( ( width() - logo.width() ) / 2, y, logo ); |
160 | } | 162 | } |
161 | 163 | ||
162 | y = height() / 2 + 15; | 164 | y = height() / 2 + 15; |
163 | 165 | ||
164 | p.drawText( 0, y + height() / 8, width(), height() - y, AlignHCenter, | 166 | p.drawText( 0, y + height() / 8, width(), height() - y, AlignHCenter, |
165 | tr( "Touch the crosshairs firmly and\n" | 167 | tr( "Touch the crosshairs firmly and\n" |
166 | "accurately to calibrate your screen." ) ); | 168 | "accurately to calibrate your screen." ) ); |
167 | 169 | ||
168 | QFont f = p.font(); | 170 | QFont f = p.font(); |
169 | f.setBold( TRUE ); | 171 | f.setBold( TRUE ); |
170 | p.setFont( f ); | 172 | p.setFont( f ); |
171 | p.drawText( 0, y, width(), height() - y, AlignHCenter | WordBreak, | 173 | p.drawText( 0, y, width(), height() - y, AlignHCenter | WordBreak, |
172 | tr( "Welcome to Opie" ) ); | 174 | tr( "Welcome to Opie" ) ); |
173 | 175 | ||
174 | if ( showCross ) { | 176 | if ( showCross ) { |
175 | p.drawRect( crossPos.x() - 1, crossPos.y() - 8, 2, 7 ); | 177 | p.drawRect( crossPos.x() - 1, crossPos.y() - 8, 2, 7 ); |
176 | p.drawRect( crossPos.x() - 1, crossPos.y() + 1, 2, 7 ); | 178 | p.drawRect( crossPos.x() - 1, crossPos.y() + 1, 2, 7 ); |
177 | p.drawRect( crossPos.x() - 8, crossPos.y() - 1, 7, 2 ); | 179 | p.drawRect( crossPos.x() - 8, crossPos.y() - 1, 7, 2 ); |
178 | p.drawRect( crossPos.x() + 1, crossPos.y() - 1, 7, 2 ); | 180 | p.drawRect( crossPos.x() + 1, crossPos.y() - 1, 7, 2 ); |
179 | } | 181 | } |
180 | } | 182 | } |
181 | 183 | ||
182 | void Calibrate::mousePressEvent( QMouseEvent *e ) | 184 | void Calibrate::mousePressEvent( QMouseEvent *e ) |
183 | { | 185 | { |
184 | // map to device coordinates | 186 | // map to device coordinates |
185 | QPoint devPos = qt_screen->mapToDevice( e->pos(), QSize( qt_screen->width(), qt_screen->height() ) ); | 187 | QPoint devPos = qt_screen->mapToDevice( e->pos(), QSize( qt_screen->width(), qt_screen->height() ) ); |
186 | if ( penPos.isNull() ) | 188 | if ( penPos.isNull() ) |
187 | penPos = devPos; | 189 | penPos = devPos; |
188 | else | 190 | else |
189 | penPos = QPoint( ( penPos.x() + devPos.x() ) / 2, | 191 | penPos = QPoint( ( penPos.x() + devPos.x() ) / 2, |
190 | ( penPos.y() + devPos.y() ) / 2 ); | 192 | ( penPos.y() + devPos.y() ) / 2 ); |
191 | } | 193 | } |
192 | 194 | ||
193 | void Calibrate::mouseReleaseEvent( QMouseEvent * ) | 195 | void Calibrate::mouseReleaseEvent( QMouseEvent * ) |
194 | { | 196 | { |
195 | if ( timer->isActive() ) | 197 | if ( timer->isActive() ) |
196 | return ; | 198 | return ; |
197 | 199 | ||
198 | bool doMove = TRUE; | 200 | bool doMove = TRUE; |
199 | 201 | ||
200 | cd.devPoints[ location ] = penPos; | 202 | cd.devPoints[ location ] = penPos; |
201 | if ( location < QWSPointerCalibrationData::TopRight ) { | 203 | if ( location < QWSPointerCalibrationData::TopRight ) { |
202 | location = (QWSPointerCalibrationData::Location) ( int( location ) + 1 ); | 204 | location = (QWSPointerCalibrationData::Location) ( int( location ) + 1 ); |
203 | } | 205 | } |
204 | else { | 206 | else { |
205 | if ( sanityCheck() ) { | 207 | if ( sanityCheck() ) { |
206 | reset(); | 208 | reset(); |
207 | goodcd = cd; | 209 | goodcd = cd; |
208 | hide(); | 210 | hide(); |
209 | emit accept(); | 211 | emit accept(); |
210 | doMove = FALSE; | 212 | doMove = FALSE; |
211 | } | 213 | } |
212 | else { | 214 | else { |
213 | location = QWSPointerCalibrationData::TopLeft; | 215 | location = QWSPointerCalibrationData::TopLeft; |
214 | } | 216 | } |
215 | } | 217 | } |
216 | 218 | ||
217 | if ( doMove ) { | 219 | if ( doMove ) { |
218 | QPoint target = fromDevice( cd.screenPoints[ location ] ); | 220 | QPoint target = fromDevice( cd.screenPoints[ location ] ); |
219 | dx = ( target.x() - crossPos.x() ) / 10; | 221 | dx = ( target.x() - crossPos.x() ) / 10; |
220 | dy = ( target.y() - crossPos.y() ) / 10; | 222 | dy = ( target.y() - crossPos.y() ) / 10; |
221 | timer->start( 30 ); | 223 | timer->start( 30 ); |
222 | } | 224 | } |
223 | } | 225 | } |
224 | 226 | ||
225 | void Calibrate::timeout() | 227 | void Calibrate::timeout() |
226 | { | 228 | { |
227 | QPoint target = fromDevice( cd.screenPoints[ location ] ); | 229 | QPoint target = fromDevice( cd.screenPoints[ location ] ); |
228 | 230 | ||
229 | bool doneX = FALSE; | 231 | bool doneX = FALSE; |
230 | bool doneY = FALSE; | 232 | bool doneY = FALSE; |
231 | QPoint newPos( crossPos.x() + dx, crossPos.y() + dy ); | 233 | QPoint newPos( crossPos.x() + dx, crossPos.y() + dy ); |
232 | 234 | ||
233 | if ( QABS( crossPos.x() - target.x() ) <= QABS( dx ) ) { | 235 | if ( QABS( crossPos.x() - target.x() ) <= QABS( dx ) ) { |
234 | newPos.setX( target.x() ); | 236 | newPos.setX( target.x() ); |
235 | doneX = TRUE; | 237 | doneX = TRUE; |
236 | } | 238 | } |
237 | 239 | ||
238 | if ( QABS( crossPos.y() - target.y() ) <= QABS( dy ) ) { | 240 | if ( QABS( crossPos.y() - target.y() ) <= QABS( dy ) ) { |
239 | newPos.setY( target.y() ); | 241 | newPos.setY( target.y() ); |
240 | doneY = TRUE; | 242 | doneY = TRUE; |
241 | } | 243 | } |
242 | 244 | ||
243 | if ( doneX && doneY ) { | 245 | if ( doneX && doneY ) { |
244 | penPos = QPoint(); | 246 | penPos = QPoint(); |
245 | timer->stop(); | 247 | timer->stop(); |
246 | } | 248 | } |
247 | 249 | ||
248 | moveCrosshair( newPos ); | 250 | moveCrosshair( newPos ); |
249 | } | 251 | } |
250 | 252 | ||
251 | #endif // _WS_QWS_ | 253 | #endif // _WS_QWS_ |
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp index 3265b46..26d9225 100644 --- a/core/opie-login/loginwindowimpl.cpp +++ b/core/opie-login/loginwindowimpl.cpp | |||
@@ -1,279 +1,280 @@ | |||
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 | 12 | ||
13 | #include <qpe/qcopenvelope_qws.h> | 13 | #include <qpe/qcopenvelope_qws.h> |
14 | 14 | ||
15 | #include <opie/odevice.h> | 15 | #include <opie/odevice.h> |
16 | 16 | ||
17 | #include <stdio.h> | 17 | #include <stdio.h> |
18 | 18 | ||
19 | #include <pwd.h> | 19 | #include <pwd.h> |
20 | #include <grp.h> | 20 | #include <grp.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | 23 | ||
24 | #undef USEPAM // FOR my toolchain | ||
24 | #ifdef USEPAM | 25 | #ifdef USEPAM |
25 | extern "C" { | 26 | extern "C" { |
26 | #include <security/pam_appl.h> | 27 | #include <security/pam_appl.h> |
27 | } | 28 | } |
28 | #else | 29 | #else |
29 | #include <crypt.h> | 30 | #include <crypt.h> |
30 | #include <shadow.h> | 31 | #include <shadow.h> |
31 | #endif | 32 | #endif |
32 | 33 | ||
33 | #include "loginwindowimpl.h" | 34 | #include "loginwindowimpl.h" |
34 | #include "inputmethods.h" | 35 | #include "inputmethods.h" |
35 | 36 | ||
36 | LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) | 37 | LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) |
37 | { | 38 | { |
38 | QPopupMenu *pop = new QPopupMenu ( this ); | 39 | QPopupMenu *pop = new QPopupMenu ( this ); |
39 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); | 40 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); |
40 | m_menu-> setPopup ( pop ); | 41 | m_menu-> setPopup ( pop ); |
41 | 42 | ||
42 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); | 43 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); |
43 | m_input = new InputMethods ( m_taskbar ); | 44 | m_input = new InputMethods ( m_taskbar ); |
44 | lay-> addWidget ( m_input ); | 45 | lay-> addWidget ( m_input ); |
45 | lay-> addStretch ( 10 ); | 46 | lay-> addStretch ( 10 ); |
46 | 47 | ||
47 | setActiveWindow ( ); | 48 | setActiveWindow ( ); |
48 | m_password-> setFocus ( ); | 49 | m_password-> setFocus ( ); |
49 | 50 | ||
50 | m_user-> insertStringList ( getAllUsers ( )); | 51 | m_user-> insertStringList ( getAllUsers ( )); |
51 | 52 | ||
52 | QTimer::singleShot ( 0, this, SLOT( showIM ( ))); | 53 | QTimer::singleShot ( 0, this, SLOT( showIM ( ))); |
53 | 54 | ||
54 | QString opiedir = ::getenv ( "OPIEDIR" ); | 55 | QString opiedir = ::getenv ( "OPIEDIR" ); |
55 | QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); | 56 | QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); |
56 | 57 | ||
57 | if ( !bgpix. isNull ( )) | 58 | if ( !bgpix. isNull ( )) |
58 | setBackgroundPixmap ( bgpix ); | 59 | setBackgroundPixmap ( bgpix ); |
59 | 60 | ||
60 | m_caption-> setText ( m_caption-> text ( ) + tr( "<center><h1><u>%1 %2</u></h1></center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); | 61 | m_caption-> setText ( m_caption-> text ( ) + tr( "<center><h1><u>%1 %2</u></h1></center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); |
61 | } | 62 | } |
62 | 63 | ||
63 | LoginWindowImpl::~LoginWindowImpl ( ) | 64 | LoginWindowImpl::~LoginWindowImpl ( ) |
64 | { | 65 | { |
65 | } | 66 | } |
66 | 67 | ||
67 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) | 68 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) |
68 | { | 69 | { |
69 | switch ( e-> key ( )) { | 70 | switch ( e-> key ( )) { |
70 | case Key_F34: suspend ( ); | 71 | case Key_F34: suspend ( ); |
71 | break; | 72 | break; |
72 | case Key_F35: backlight ( ); | 73 | case Key_F35: backlight ( ); |
73 | break; | 74 | break; |
74 | default : e-> ignore ( ); | 75 | default : e-> ignore ( ); |
75 | break; | 76 | break; |
76 | } | 77 | } |
77 | LoginWindow::keyPressEvent ( e ); | 78 | LoginWindow::keyPressEvent ( e ); |
78 | } | 79 | } |
79 | 80 | ||
80 | 81 | ||
81 | void LoginWindowImpl::toggleEchoMode ( bool t ) | 82 | void LoginWindowImpl::toggleEchoMode ( bool t ) |
82 | { | 83 | { |
83 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); | 84 | m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); |
84 | } | 85 | } |
85 | 86 | ||
86 | QStringList LoginWindowImpl::getAllUsers ( ) | 87 | QStringList LoginWindowImpl::getAllUsers ( ) |
87 | { | 88 | { |
88 | struct passwd *pwd; | 89 | struct passwd *pwd; |
89 | QStringList sl; | 90 | QStringList sl; |
90 | 91 | ||
91 | while (( pwd = getpwent ( ))) { | 92 | while (( pwd = getpwent ( ))) { |
92 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) | 93 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) |
93 | sl << QString ( pwd-> pw_name ); | 94 | sl << QString ( pwd-> pw_name ); |
94 | } | 95 | } |
95 | 96 | ||
96 | endpwent ( ); | 97 | endpwent ( ); |
97 | 98 | ||
98 | return sl; | 99 | return sl; |
99 | } | 100 | } |
100 | 101 | ||
101 | void LoginWindowImpl::showIM ( ) | 102 | void LoginWindowImpl::showIM ( ) |
102 | { | 103 | { |
103 | m_input-> showInputMethod ( ); | 104 | m_input-> showInputMethod ( ); |
104 | } | 105 | } |
105 | 106 | ||
106 | void LoginWindowImpl::restart ( ) | 107 | void LoginWindowImpl::restart ( ) |
107 | { | 108 | { |
108 | qApp-> quit ( ); | 109 | qApp-> quit ( ); |
109 | } | 110 | } |
110 | 111 | ||
111 | void LoginWindowImpl::suspend ( ) | 112 | void LoginWindowImpl::suspend ( ) |
112 | { | 113 | { |
113 | system ( "apm -s" ); | 114 | system ( "apm -s" ); |
114 | usleep ( 1 * 1000 * 1000 ); | 115 | usleep ( 1 * 1000 * 1000 ); |
115 | { | 116 | { |
116 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 117 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
117 | e << -3; // Force on | 118 | e << -3; // Force on |
118 | } | 119 | } |
119 | } | 120 | } |
120 | 121 | ||
121 | void LoginWindowImpl::backlight ( ) | 122 | void LoginWindowImpl::backlight ( ) |
122 | { | 123 | { |
123 | { | 124 | { |
124 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 125 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
125 | e << -2; // toggle | 126 | e << -2; // toggle |
126 | } | 127 | } |
127 | } | 128 | } |
128 | 129 | ||
129 | #ifdef USEPAM | 130 | #ifdef USEPAM |
130 | 131 | ||
131 | static const char *_PAM_SERVICE = "xdm"; | 132 | static const char *_PAM_SERVICE = "xdm"; |
132 | static const char *PAM_password; | 133 | static const char *PAM_password; |
133 | 134 | ||
134 | typedef const struct pam_message pam_message_type; | 135 | typedef const struct pam_message pam_message_type; |
135 | 136 | ||
136 | static int PAM_conv( int, pam_message_type **, struct pam_response **, void * ); | 137 | static int PAM_conv( int, pam_message_type **, struct pam_response **, void * ); |
137 | 138 | ||
138 | static struct pam_conv PAM_conversation = { | 139 | static struct pam_conv PAM_conversation = { |
139 | &PAM_conv, | 140 | &PAM_conv, |
140 | NULL | 141 | NULL |
141 | }; | 142 | }; |
142 | 143 | ||
143 | //---------------------------------------------------------------------------- | 144 | //---------------------------------------------------------------------------- |
144 | 145 | ||
145 | static char *COPY_STRING( const char * s ) { | 146 | static char *COPY_STRING( const char * s ) { |
146 | return (s) ? strdup(s) : (char *)NULL; | 147 | return (s) ? strdup(s) : (char *)NULL; |
147 | } | 148 | } |
148 | 149 | ||
149 | #define GET_MEM if (reply) realloc(reply, size);\ | 150 | #define GET_MEM if (reply) realloc(reply, size);\ |
150 | else reply = (struct pam_response *)malloc(size); \ | 151 | else reply = (struct pam_response *)malloc(size); \ |
151 | if (!reply) return PAM_CONV_ERR; \ | 152 | if (!reply) return PAM_CONV_ERR; \ |
152 | size += sizeof(struct pam_response) | 153 | size += sizeof(struct pam_response) |
153 | 154 | ||
154 | 155 | ||
155 | static int PAM_conv( int num_msg, pam_message_type **msg, | 156 | static int PAM_conv( int num_msg, pam_message_type **msg, |
156 | struct pam_response **resp, void *) | 157 | struct pam_response **resp, void *) |
157 | { | 158 | { |
158 | int count = 0, replies = 0; | 159 | int count = 0, replies = 0; |
159 | struct pam_response *reply = NULL; | 160 | struct pam_response *reply = NULL; |
160 | int size = sizeof(struct pam_response); | 161 | int size = sizeof(struct pam_response); |
161 | 162 | ||
162 | for( count = 0; count < num_msg; count++ ) { | 163 | for( count = 0; count < num_msg; count++ ) { |
163 | switch (msg[count]->msg_style) { | 164 | switch (msg[count]->msg_style) { |
164 | case PAM_PROMPT_ECHO_ON: | 165 | case PAM_PROMPT_ECHO_ON: |
165 | /* user name given to PAM already */ | 166 | /* user name given to PAM already */ |
166 | return PAM_CONV_ERR; | 167 | return PAM_CONV_ERR; |
167 | 168 | ||
168 | case PAM_PROMPT_ECHO_OFF: | 169 | case PAM_PROMPT_ECHO_OFF: |
169 | /* wants password */ | 170 | /* wants password */ |
170 | GET_MEM; | 171 | GET_MEM; |
171 | reply[replies].resp_retcode = PAM_SUCCESS; | 172 | reply[replies].resp_retcode = PAM_SUCCESS; |
172 | reply[replies].resp = COPY_STRING(PAM_password); | 173 | reply[replies].resp = COPY_STRING(PAM_password); |
173 | replies++; | 174 | replies++; |
174 | /* PAM frees resp */ | 175 | /* PAM frees resp */ |
175 | break; | 176 | break; |
176 | case PAM_TEXT_INFO: | 177 | case PAM_TEXT_INFO: |
177 | break; | 178 | break; |
178 | default: | 179 | default: |
179 | /* unknown or PAM_ERROR_MSG */ | 180 | /* unknown or PAM_ERROR_MSG */ |
180 | if (reply) free (reply); | 181 | if (reply) free (reply); |
181 | return PAM_CONV_ERR; | 182 | return PAM_CONV_ERR; |
182 | } | 183 | } |
183 | } | 184 | } |
184 | if (reply) *resp = reply; | 185 | if (reply) *resp = reply; |
185 | return PAM_SUCCESS; | 186 | return PAM_SUCCESS; |
186 | } | 187 | } |
187 | 188 | ||
188 | 189 | ||
189 | static bool pwcheck_PAM( const char *user, const char *password ) | 190 | static bool pwcheck_PAM( const char *user, const char *password ) |
190 | { | 191 | { |
191 | bool pw_correct = false; | 192 | bool pw_correct = false; |
192 | int pam_error; | 193 | int pam_error; |
193 | int pam_return = 0; | 194 | int pam_return = 0; |
194 | pam_handle_t *pamh = 0; | 195 | pam_handle_t *pamh = 0; |
195 | PAM_password = password; | 196 | PAM_password = password; |
196 | 197 | ||
197 | pam_error = pam_start( _PAM_SERVICE, user, &PAM_conversation, &pamh ); | 198 | pam_error = pam_start( _PAM_SERVICE, user, &PAM_conversation, &pamh ); |
198 | if( pam_error == PAM_SUCCESS ) { | 199 | if( pam_error == PAM_SUCCESS ) { |
199 | pam_error = pam_authenticate( pamh, 0 ); | 200 | pam_error = pam_authenticate( pamh, 0 ); |
200 | if( pam_error == PAM_SUCCESS ) { | 201 | if( pam_error == PAM_SUCCESS ) { |
201 | //-- password correct | 202 | //-- password correct |
202 | pw_correct = true; | 203 | pw_correct = true; |
203 | pam_return = PAM_SUCCESS; | 204 | pam_return = PAM_SUCCESS; |
204 | } else { | 205 | } else { |
205 | pam_return = pam_error; | 206 | pam_return = pam_error; |
206 | } | 207 | } |
207 | } else { | 208 | } else { |
208 | // cerr << "PAM error: " << pam_strerror( pamh, pam_error ) << endl; | 209 | // cerr << "PAM error: " << pam_strerror( pamh, pam_error ) << endl; |
209 | } | 210 | } |
210 | pam_end( pamh, pam_return ); | 211 | pam_end( pamh, pam_return ); |
211 | return pw_correct; | 212 | return pw_correct; |
212 | } | 213 | } |
213 | 214 | ||
214 | #else | 215 | #else |
215 | 216 | ||
216 | //---------------------------------------------------------------------------- | 217 | //---------------------------------------------------------------------------- |
217 | 218 | ||
218 | static bool pwcheck_Unix( const char *user, const char *pass ) | 219 | static bool pwcheck_Unix( const char *user, const char *pass ) |
219 | { | 220 | { |
220 | char *encrypted, *correct; | 221 | char *encrypted, *correct; |
221 | struct passwd *pw; | 222 | struct passwd *pw; |
222 | 223 | ||
223 | if ( !user || !pass ) | 224 | if ( !user || !pass ) |
224 | return false; | 225 | return false; |
225 | 226 | ||
226 | pw = getpwnam ( user ); | 227 | pw = getpwnam ( user ); |
227 | 228 | ||
228 | if ( !pw ) | 229 | if ( !pw ) |
229 | return false; | 230 | return false; |
230 | 231 | ||
231 | if (( strcmp ( pw-> pw_passwd, "x" ) == 0 ) || ( strcmp ( pw-> pw_passwd, "*" ) == 0 )) { | 232 | if (( strcmp ( pw-> pw_passwd, "x" ) == 0 ) || ( strcmp ( pw-> pw_passwd, "*" ) == 0 )) { |
232 | struct spwd *sp = getspnam ( pw-> pw_name ); | 233 | struct spwd *sp = getspnam ( pw-> pw_name ); |
233 | 234 | ||
234 | if ( !sp ) | 235 | if ( !sp ) |
235 | return false; | 236 | return false; |
236 | 237 | ||
237 | correct = sp-> sp_pwdp; | 238 | correct = sp-> sp_pwdp; |
238 | } | 239 | } |
239 | else | 240 | else |
240 | correct = pw-> pw_passwd; | 241 | correct = pw-> pw_passwd; |
241 | 242 | ||
242 | if ( correct == 0 || correct[0] == '\0' ) | 243 | if ( correct == 0 || correct[0] == '\0' ) |
243 | return true; | 244 | return true; |
244 | 245 | ||
245 | encrypted = crypt ( pass, correct ); | 246 | encrypted = crypt ( pass, correct ); |
246 | return ( strcmp ( encrypted, correct ) == 0 ); | 247 | return ( strcmp ( encrypted, correct ) == 0 ); |
247 | } | 248 | } |
248 | 249 | ||
249 | #endif | 250 | #endif |
250 | 251 | ||
251 | 252 | ||
252 | bool LoginWindowImpl::changeIdentity ( const char *user ) | 253 | bool LoginWindowImpl::changeIdentity ( const char *user ) |
253 | { | 254 | { |
254 | const char *DEFAULT_LOGIN_PATH = "/bin:/usr/bin"; | 255 | const char *DEFAULT_LOGIN_PATH = "/bin:/usr/bin"; |
255 | const char *DEFAULT_ROOT_LOGIN_PATH = "/usr/sbin:/bin:/usr/bin:/sbin"; | 256 | const char *DEFAULT_ROOT_LOGIN_PATH = "/usr/sbin:/bin:/usr/bin:/sbin"; |
256 | 257 | ||
257 | bool fail = false; | 258 | bool fail = false; |
258 | struct passwd *pw = getpwnam ( user ); | 259 | struct passwd *pw = getpwnam ( user ); |
259 | 260 | ||
260 | fail |= ( pw == 0 ); | 261 | fail |= ( pw == 0 ); |
261 | printf ( "1 %d\n", fail ); | 262 | printf ( "1 %d\n", fail ); |
262 | fail |= ( initgroups ( pw-> pw_name, pw-> pw_gid )); | 263 | fail |= ( initgroups ( pw-> pw_name, pw-> pw_gid )); |
263 | endgrent ( ); | 264 | endgrent ( ); |
264 | printf ( "2 %d\n", fail ); | 265 | printf ( "2 %d\n", fail ); |
265 | fail |= ( setgid ( pw-> pw_gid )); | 266 | fail |= ( setgid ( pw-> pw_gid )); |
266 | printf ( "3 %d\n", fail ); | 267 | printf ( "3 %d\n", fail ); |
267 | fail |= ( setuid ( pw-> pw_uid )); | 268 | fail |= ( setuid ( pw-> pw_uid )); |
268 | 269 | ||
269 | printf ( "4 %d\n", fail ); | 270 | printf ( "4 %d\n", fail ); |
270 | fail |= ( chdir ( pw-> pw_dir ) && chdir ( "/" )); | 271 | fail |= ( chdir ( pw-> pw_dir ) && chdir ( "/" )); |
271 | 272 | ||
272 | printf ( "5 %d\n", fail ); | 273 | printf ( "5 %d\n", fail ); |
273 | fail |= ( setenv ( "HOME", pw-> pw_dir, 1 )); | 274 | fail |= ( setenv ( "HOME", pw-> pw_dir, 1 )); |
274 | printf ( "6 %d\n", fail ); | 275 | printf ( "6 %d\n", fail ); |
275 | fail |= ( setenv ( "SHELL", pw-> pw_shell, 1 )); | 276 | fail |= ( setenv ( "SHELL", pw-> pw_shell, 1 )); |
276 | printf ( "7 %d\n", fail ); | 277 | printf ( "7 %d\n", fail ); |
277 | fail |= ( setenv ( "USER", pw-> pw_name, 1 )); | 278 | fail |= ( setenv ( "USER", pw-> pw_name, 1 )); |
278 | printf ( "8 %d\n", fail ); | 279 | printf ( "8 %d\n", fail ); |
279 | fail |= ( setenv ( "LOGNAME", pw-> pw_name, 1 )); | 280 | fail |= ( setenv ( "LOGNAME", pw-> pw_name, 1 )); |
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp index 9d52b75..44d6f8d 100644 --- a/core/opie-login/main.cpp +++ b/core/opie-login/main.cpp | |||
@@ -1,178 +1,179 @@ | |||
1 | #include <sys/time.h> | 1 | #include <sys/time.h> |
2 | #include <sys/resource.h> | 2 | #include <sys/resource.h> |
3 | #include <unistd.h> | 3 | #include <unistd.h> |
4 | #include <syslog.h> | 4 | #include <syslog.h> |
5 | #include <sys/types.h> | 5 | #include <sys/types.h> |
6 | #include <sys/wait.h> | 6 | #include <sys/wait.h> |
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <stdlib.h> | ||
8 | 9 | ||
9 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
10 | #include <qpe/qcopenvelope_qws.h> | 11 | #include <qpe/qcopenvelope_qws.h> |
11 | 12 | ||
12 | #include <opie/odevice.h> | 13 | #include <opie/odevice.h> |
13 | 14 | ||
14 | #include <qwindowsystem_qws.h> | 15 | #include <qwindowsystem_qws.h> |
15 | #include <qfile.h> | 16 | #include <qfile.h> |
16 | 17 | ||
17 | #include "loginwindowimpl.h" | 18 | #include "loginwindowimpl.h" |
18 | #include "calibrate.h" | 19 | #include "calibrate.h" |
19 | 20 | ||
20 | int login_main ( int argc, char **argv ); | 21 | int login_main ( int argc, char **argv ); |
21 | 22 | ||
22 | 23 | ||
23 | int main ( int argc, char **argv ) | 24 | int main ( int argc, char **argv ) |
24 | { | 25 | { |
25 | if ( geteuid ( ) != 0 ) { | 26 | if ( geteuid ( ) != 0 ) { |
26 | fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); | 27 | fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); |
27 | return 1; | 28 | return 1; |
28 | } | 29 | } |
29 | 30 | ||
30 | //struct rlimit rl; | 31 | //struct rlimit rl; |
31 | //getrlimit ( RLIMIT_NOFILE, &rl ); | 32 | //getrlimit ( RLIMIT_NOFILE, &rl ); |
32 | 33 | ||
33 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) | 34 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) |
34 | // close ( i ); | 35 | // close ( i ); |
35 | 36 | ||
36 | setpgid ( 0, 0 ); | 37 | setpgid ( 0, 0 ); |
37 | setsid ( ); | 38 | setsid ( ); |
38 | 39 | ||
39 | openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); | 40 | openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); |
40 | 41 | ||
41 | while ( true ) { | 42 | while ( true ) { |
42 | pid_t child = fork ( ); | 43 | pid_t child = fork ( ); |
43 | 44 | ||
44 | if ( child < 0 ) { | 45 | if ( child < 0 ) { |
45 | syslog ( LOG_ERR, "Could not fork process" ); | 46 | syslog ( LOG_ERR, "Could not fork process" ); |
46 | break; | 47 | break; |
47 | 48 | ||
48 | } | 49 | } |
49 | else if ( child > 0 ) { | 50 | else if ( child > 0 ) { |
50 | int status = 0; | 51 | int status = 0; |
51 | 52 | ||
52 | while ( waitpid ( child, &status, 0 ) < 0 ) { } | 53 | while ( waitpid ( child, &status, 0 ) < 0 ) { } |
53 | } | 54 | } |
54 | else { | 55 | else { |
55 | exit ( login_main ( argc, argv )); | 56 | exit ( login_main ( argc, argv )); |
56 | } | 57 | } |
57 | } | 58 | } |
58 | closelog ( ); | 59 | closelog ( ); |
59 | } | 60 | } |
60 | 61 | ||
61 | 62 | ||
62 | class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter | 63 | class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter |
63 | { | 64 | { |
64 | public: | 65 | public: |
65 | ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) | 66 | ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) |
66 | { | 67 | { |
67 | bool doinst = false; | 68 | bool doinst = false; |
68 | 69 | ||
69 | m_model = ODevice::inst ( )-> model ( ); | 70 | m_model = ODevice::inst ( )-> model ( ); |
70 | m_power_timer = 0; | 71 | m_power_timer = 0; |
71 | 72 | ||
72 | switch ( m_model ) { | 73 | switch ( m_model ) { |
73 | case OMODEL_iPAQ_H31xx: | 74 | case OMODEL_iPAQ_H31xx: |
74 | case OMODEL_iPAQ_H36xx: | 75 | case OMODEL_iPAQ_H36xx: |
75 | case OMODEL_iPAQ_H37xx: | 76 | case OMODEL_iPAQ_H37xx: |
76 | case OMODEL_iPAQ_H38xx: doinst = true; | 77 | case OMODEL_iPAQ_H38xx: doinst = true; |
77 | break; | 78 | break; |
78 | default : break; | 79 | default : break; |
79 | } | 80 | } |
80 | if ( doinst ) | 81 | if ( doinst ) |
81 | QWSServer::setKeyboardFilter ( this ); | 82 | QWSServer::setKeyboardFilter ( this ); |
82 | } | 83 | } |
83 | 84 | ||
84 | virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 85 | virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
85 | { | 86 | { |
86 | bool kill = false; | 87 | bool kill = false; |
87 | 88 | ||
88 | // Rotate cursor keys 180° | 89 | // Rotate cursor keys 180° |
89 | switch ( m_model ) { | 90 | switch ( m_model ) { |
90 | case OMODEL_iPAQ_H31xx: | 91 | case OMODEL_iPAQ_H31xx: |
91 | case OMODEL_iPAQ_H38xx: { | 92 | case OMODEL_iPAQ_H38xx: { |
92 | int newkeycode = keycode; | 93 | int newkeycode = keycode; |
93 | 94 | ||
94 | switch ( keycode ) { | 95 | switch ( keycode ) { |
95 | case Key_Left : newkeycode = Key_Right; break; | 96 | case Key_Left : newkeycode = Key_Right; break; |
96 | case Key_Right: newkeycode = Key_Left; break; | 97 | case Key_Right: newkeycode = Key_Left; break; |
97 | case Key_Up : newkeycode = Key_Down; break; | 98 | case Key_Up : newkeycode = Key_Down; break; |
98 | case Key_Down : newkeycode = Key_Up; break; | 99 | case Key_Down : newkeycode = Key_Up; break; |
99 | } | 100 | } |
100 | if ( newkeycode != keycode ) { | 101 | if ( newkeycode != keycode ) { |
101 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 102 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
102 | kill = true; | 103 | kill = true; |
103 | } | 104 | } |
104 | break; | 105 | break; |
105 | } | 106 | } |
106 | default: break; | 107 | default: break; |
107 | } | 108 | } |
108 | 109 | ||
109 | // map Power Button short/long press to F34/F35 | 110 | // map Power Button short/long press to F34/F35 |
110 | switch ( m_model ) { | 111 | switch ( m_model ) { |
111 | case OMODEL_iPAQ_H31xx: | 112 | case OMODEL_iPAQ_H31xx: |
112 | case OMODEL_iPAQ_H36xx: | 113 | case OMODEL_iPAQ_H36xx: |
113 | case OMODEL_iPAQ_H37xx: | 114 | case OMODEL_iPAQ_H37xx: |
114 | case OMODEL_iPAQ_H38xx: { | 115 | case OMODEL_iPAQ_H38xx: { |
115 | if ( keycode == Key_SysReq ) { | 116 | if ( keycode == Key_SysReq ) { |
116 | if ( isPress ) { | 117 | if ( isPress ) { |
117 | m_power_timer = startTimer ( 500 ); | 118 | m_power_timer = startTimer ( 500 ); |
118 | } | 119 | } |
119 | else if ( m_power_timer ) { | 120 | else if ( m_power_timer ) { |
120 | killTimer ( m_power_timer ); | 121 | killTimer ( m_power_timer ); |
121 | m_power_timer = 0; | 122 | m_power_timer = 0; |
122 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); | 123 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); |
123 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); | 124 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); |
124 | } | 125 | } |
125 | kill = true; | 126 | kill = true; |
126 | } | 127 | } |
127 | break; | 128 | break; |
128 | } | 129 | } |
129 | default: break; | 130 | default: break; |
130 | } | 131 | } |
131 | return kill; | 132 | return kill; |
132 | } | 133 | } |
133 | 134 | ||
134 | virtual void timerEvent ( QTimerEvent * ) | 135 | virtual void timerEvent ( QTimerEvent * ) |
135 | { | 136 | { |
136 | killTimer ( m_power_timer ); | 137 | killTimer ( m_power_timer ); |
137 | m_power_timer = 0; | 138 | m_power_timer = 0; |
138 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); | 139 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); |
139 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); | 140 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); |
140 | } | 141 | } |
141 | 142 | ||
142 | private: | 143 | private: |
143 | OModel m_model; | 144 | OModel m_model; |
144 | int m_power_timer; | 145 | int m_power_timer; |
145 | }; | 146 | }; |
146 | 147 | ||
147 | 148 | ||
148 | 149 | ||
149 | 150 | ||
150 | int login_main ( int argc, char **argv ) | 151 | int login_main ( int argc, char **argv ) |
151 | { | 152 | { |
152 | QWSServer::setDesktopBackground( QImage() ); | 153 | QWSServer::setDesktopBackground( QImage() ); |
153 | QPEApplication app ( argc, argv, QApplication::GuiServer ); | 154 | QPEApplication app ( argc, argv, QApplication::GuiServer ); |
154 | 155 | ||
155 | (void) new ModelKeyFilter ( ); | 156 | (void) new ModelKeyFilter ( ); |
156 | 157 | ||
157 | { | 158 | { |
158 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 159 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
159 | e << -3; // Forced on | 160 | e << -3; // Forced on |
160 | } | 161 | } |
161 | 162 | ||
162 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 163 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
163 | if ( !QFile::exists ( "/etc/pointercal" )) { | 164 | if ( !QFile::exists ( "/etc/pointercal" )) { |
164 | // Make sure calibration widget starts on top. | 165 | // Make sure calibration widget starts on top. |
165 | Calibrate *cal = new Calibrate; | 166 | Calibrate *cal = new Calibrate; |
166 | cal-> exec ( ); | 167 | cal-> exec ( ); |
167 | delete cal; | 168 | delete cal; |
168 | } | 169 | } |
169 | #endif | 170 | #endif |
170 | 171 | ||
171 | LoginWindowImpl *lw = new LoginWindowImpl ( ); | 172 | LoginWindowImpl *lw = new LoginWindowImpl ( ); |
172 | app. setMainWidget ( lw ); | 173 | app. setMainWidget ( lw ); |
173 | lw-> setGeometry ( 0, 0, app. desktop ( )-> width ( ), app. desktop ( )-> height ( )); | 174 | lw-> setGeometry ( 0, 0, app. desktop ( )-> width ( ), app. desktop ( )-> height ( )); |
174 | lw-> show ( ); | 175 | lw-> show ( ); |
175 | 176 | ||
176 | return app. exec ( ); | 177 | return app. exec ( ); |
177 | } | 178 | } |
178 | 179 | ||
diff --git a/core/opie-login/opie-login.pro b/core/opie-login/opie-login.pro index 35c1ed0..ef449ab 100644 --- a/core/opie-login/opie-login.pro +++ b/core/opie-login/opie-login.pro | |||
@@ -1,25 +1,25 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on debug usepam | 2 | CONFIG = qt warn_on debug usepam |
3 | 3 | ||
4 | HEADERS = loginwindowimpl.h \ | 4 | HEADERS = loginwindowimpl.h \ |
5 | ../launcher/inputmethods.h \ | 5 | ../launcher/inputmethods.h \ |
6 | ../apps/calibrate/calibrate.h | 6 | ../apps/calibrate/calibrate.h |
7 | 7 | ||
8 | SOURCES = loginwindowimpl.cpp \ | 8 | SOURCES = loginwindowimpl.cpp \ |
9 | ../launcher/inputmethods.cpp \ | 9 | ../launcher/inputmethods.cpp \ |
10 | ../apps/calibrate/calibrate.cpp \ | 10 | ../apps/calibrate/calibrate.cpp \ |
11 | main.cpp | 11 | main.cpp |
12 | 12 | ||
13 | INTERFACES = loginwindow.ui | 13 | INTERFACES = loginwindow.ui |
14 | 14 | ||
15 | INCLUDEPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate | 15 | INCLUDEPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate |
16 | DEPENDPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate | 16 | DEPENDPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate |
17 | 17 | ||
18 | LIBS += -lqpe -lopie | 18 | LIBS += -lqpe -lopie |
19 | 19 | ||
20 | usepam:LIBS += -lpam | 20 | #usepam:LIBS += -lpam |
21 | usepam:DEFINES += USEPAM | 21 | #usepam:DEFINES += USEPAM |
22 | 22 | ||
23 | DESTDIR = $(OPIEDIR)/bin | 23 | DESTDIR = $(OPIEDIR)/bin |
24 | TARGET = opie-login | 24 | TARGET = opie-login |
25 | 25 | ||