summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-14 23:33:00 (UTC)
committer sandman <sandman>2002-10-14 23:33:00 (UTC)
commitb3ad9188f40cf6e3c170cc48be3ed180d509036f (patch) (unidiff)
tree04978e0fb1bd258244a6578a27ab09e3c6843d75
parentc7aed90e02d06502dff04043103c5db0883cc011 (diff)
downloadopie-b3ad9188f40cf6e3c170cc48be3ed180d509036f.zip
opie-b3ad9188f40cf6e3c170cc48be3ed180d509036f.tar.gz
opie-b3ad9188f40cf6e3c170cc48be3ed180d509036f.tar.bz2
autologin feature can now (also) be configured by:
~/Settings/opie-login.conf: [General] AutoLogin=<user> command line options override config file settings !
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opie-login/main.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index 8f795e3..579a93a 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -23,48 +23,49 @@
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27 27
28#define _GNU_SOURCE 28#define _GNU_SOURCE
29 29
30#include <sys/types.h> 30#include <sys/types.h>
31#include <time.h> 31#include <time.h>
32#include <sys/time.h> 32#include <sys/time.h>
33#include <sys/resource.h> 33#include <sys/resource.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <syslog.h> 35#include <syslog.h>
36#include <sys/wait.h> 36#include <sys/wait.h>
37#include <stdio.h> 37#include <stdio.h>
38#include <stdlib.h> 38#include <stdlib.h>
39#include <signal.h> 39#include <signal.h>
40#include <getopt.h> 40#include <getopt.h>
41#include <string.h> 41#include <string.h>
42 42
43#include <qpe/qpeapplication.h> 43#include <qpe/qpeapplication.h>
44#include <qpe/qcopenvelope_qws.h> 44#include <qpe/qcopenvelope_qws.h>
45#include <qpe/qpestyle.h> 45#include <qpe/qpestyle.h>
46#include <qpe/power.h> 46#include <qpe/power.h>
47#include <qpe/config.h>
47 48
48#include <opie/odevice.h> 49#include <opie/odevice.h>
49 50
50#include <qwindowsystem_qws.h> 51#include <qwindowsystem_qws.h>
51#include <qmessagebox.h> 52#include <qmessagebox.h>
52#include <qlabel.h> 53#include <qlabel.h>
53#include <qtimer.h> 54#include <qtimer.h>
54#include <qfile.h> 55#include <qfile.h>
55 56
56#include "loginapplication.h" 57#include "loginapplication.h"
57#include "loginwindowimpl.h" 58#include "loginwindowimpl.h"
58#include "calibrate.h" 59#include "calibrate.h"
59 60
60using namespace Opie; 61using namespace Opie;
61 62
62int login_main ( int argc, char **argv ); 63int login_main ( int argc, char **argv );
63void sigterm ( int sig ); 64void sigterm ( int sig );
64void exit_closelog ( ); 65void exit_closelog ( );
65 66
66static struct option long_options [] = { 67static struct option long_options [] = {
67 { "autologin", 1, 0, 'a' }, 68 { "autologin", 1, 0, 'a' },
68 { 0, 0, 0, 0 } 69 { 0, 0, 0, 0 }
69}; 70};
70 71
@@ -143,57 +144,66 @@ int main ( int argc, char **argv )
143 } 144 }
144 } 145 }
145 if ( killedbysig ) { // qpe was killed by an uncaught signal 146 if ( killedbysig ) { // qpe was killed by an uncaught signal
146 qApp = 0; 147 qApp = 0;
147 148
148 QWSServer::setDesktopBackground ( QImage ( )); 149 QWSServer::setDesktopBackground ( QImage ( ));
149 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); 150 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer );
150 app-> setFont ( QFont ( "Helvetica", 10 )); 151 app-> setFont ( QFont ( "Helvetica", 10 ));
151 app-> setStyle ( new QPEStyle ( )); 152 app-> setStyle ( new QPEStyle ( ));
152 153
153 const char *sig = ::strsignal ( killedbysig ); 154 const char *sig = ::strsignal ( killedbysig );
154 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); 155 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool );
155 l-> setText ( LoginWindowImpl::tr( "OPIE was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); 156 l-> setText ( LoginWindowImpl::tr( "OPIE was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig ));
156 l-> setAlignment ( Qt::AlignCenter ); 157 l-> setAlignment ( Qt::AlignCenter );
157 l-> move ( 0, 0 ); 158 l-> move ( 0, 0 );
158 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 159 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
159 l-> show ( ); 160 l-> show ( );
160 QTimer::singleShot ( 3000, app, SLOT( quit ( ))); 161 QTimer::singleShot ( 3000, app, SLOT( quit ( )));
161 app-> exec ( ); 162 app-> exec ( );
162 delete app; 163 delete app;
163 qApp = 0; 164 qApp = 0;
164 } 165 }
165 } 166 }
166 else { 167 else {
168 if ( !autolog ) {
169 Config cfg ( "opie-login" );
170 cfg. setGroup ( "General" );
171 QString user = cfg. readEntry ( "AutoLogin" );
172
173 if ( !user. isEmpty ( ))
174 autolog = ::strdup ( user. latin1 ( ));
175 }
176
167 if ( autolog ) { 177 if ( autolog ) {
168 LoginApplication::setLoginAs ( autolog ); 178 LoginApplication::setLoginAs ( autolog );
169 179
170 if ( LoginApplication::changeIdentity ( )) 180 if ( LoginApplication::changeIdentity ( ))
171 ::exit ( LoginApplication::login ( )); 181 ::exit ( LoginApplication::login ( ));
172 else 182 else
173 ::exit ( 0 ); 183 ::exit ( 0 );
174 } 184 }
175 else 185 else
176 ::exit ( login_main ( argc, argv )); 186 ::exit ( login_main ( argc, argv ));
177 } 187 }
178 } 188 }
179 return 0; 189 return 0;
180} 190}
181 191
182void sigterm ( int /*sig*/ ) 192void sigterm ( int /*sig*/ )
183{ 193{
184 ::exit ( 0 ); 194 ::exit ( 0 );
185} 195}
186 196
187 197
188void exit_closelog ( ) 198void exit_closelog ( )
189{ 199{
190 ::closelog ( ); 200 ::closelog ( );
191} 201}
192 202
193 203
194class LoginScreenSaver : public QWSScreenSaver 204class LoginScreenSaver : public QWSScreenSaver
195{ 205{
196public: 206public:
197 LoginScreenSaver ( ) 207 LoginScreenSaver ( )
198 { 208 {
199 m_lcd_status = true; 209 m_lcd_status = true;