Diffstat (limited to 'core/settings/security/security.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/settings/security/security.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp index 4701506..75a181b 100644 --- a/core/settings/security/security.cpp +++ b/core/settings/security/security.cpp | |||
@@ -21,2 +21,3 @@ | |||
21 | 21 | ||
22 | #include <qpe/qpeapplication.h> | ||
22 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
@@ -29,2 +30,5 @@ | |||
29 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
31 | #include <qfile.h> | ||
32 | #include <qlistview.h> | ||
33 | #include <qtextstream.h> | ||
30 | 34 | ||
@@ -58,4 +62,21 @@ Security::Security( QWidget* parent, const char* name, WFlags fl ) | |||
58 | 62 | ||
63 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | ||
64 | Config loginCfg(configFile,Config::File); | ||
65 | |||
66 | loginCfg.setGroup("General"); | ||
67 | autoLoginName=loginCfg.readEntry("AutoLogin",""); | ||
68 | |||
69 | if (autoLoginName.stripWhiteSpace().isEmpty()) { | ||
70 | autoLogin=false; | ||
71 | } else { | ||
72 | autoLogin=true; | ||
73 | } | ||
74 | |||
75 | |||
76 | connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); | ||
77 | connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); | ||
59 | connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); | 78 | connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); |
60 | connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); | 79 | connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); |
80 | |||
81 | loadUsers(); | ||
61 | updateGUI(); | 82 | updateGUI(); |
@@ -79,2 +100,6 @@ void Security::updateGUI() | |||
79 | clearpasscode->setEnabled( !empty ); | 100 | clearpasscode->setEnabled( !empty ); |
101 | |||
102 | autologinToggle->setChecked(autoLogin); | ||
103 | userlist->setEnabled(autoLogin); | ||
104 | |||
80 | } | 105 | } |
@@ -162,2 +187,32 @@ void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) | |||
162 | 187 | ||
188 | void Security::loadUsers ( void ) | ||
189 | { | ||
190 | QFile passwd("/etc/passwd"); | ||
191 | if ( passwd.open(IO_ReadOnly) ) { | ||
192 | QTextStream t( &passwd ); | ||
193 | QString s; | ||
194 | QStringList account; | ||
195 | while ( !t.eof() ) { | ||
196 | account = QStringList::split(':',t.readLine()); | ||
197 | |||
198 | // Hide disabled accounts | ||
199 | if (*account.at(1)!="*") { | ||
200 | |||
201 | userlist->insertItem(*account.at(0)); | ||
202 | // Highlight this item if it is set to autologinToggle | ||
203 | if ( *account.at(0) == autoLoginName) | ||
204 | userlist->setCurrentItem(userlist->count()-1); | ||
205 | } | ||
206 | } | ||
207 | passwd.close(); | ||
208 | } | ||
209 | |||
210 | } | ||
211 | void Security::toggleAutoLogin(bool val) | ||
212 | { | ||
213 | autoLogin=val; | ||
214 | userlist->setEnabled(val); | ||
215 | if (!autoLogin) | ||
216 | autoLoginName=userlist->currentText(); | ||
217 | } | ||
163 | void Security::setSyncNet(const QString& sn) | 218 | void Security::setSyncNet(const QString& sn) |
@@ -191,3 +246,20 @@ void Security::applySecurity() | |||
191 | */ | 246 | */ |
247 | |||
248 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | ||
249 | Config loginCfg(configFile,Config::File); | ||
250 | loginCfg.setGroup("General"); | ||
251 | |||
252 | if (autoLogin) { | ||
253 | loginCfg.writeEntry("AutoLogin",autoLoginName); | ||
254 | } else { | ||
255 | loginCfg.removeEntry("AutoLogin"); | ||
256 | } | ||
257 | |||
258 | } | ||
192 | } | 259 | } |
260 | |||
261 | void Security::changeLoginName( int idx ) | ||
262 | { | ||
263 | autoLoginName = userlist->text(idx);; | ||
264 | updateGUI(); | ||
193 | } | 265 | } |