author | kergoth <kergoth> | 2003-08-09 17:42:14 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 17:42:14 (UTC) |
commit | 1ab4ca95e4d2cf24d32b38c9031cb6076351e730 (patch) (unidiff) | |
tree | 644d196b01c7f280981bd17da23c7592a18e5643 /core/settings/security/security.cpp | |
parent | ec14206f63dd93e9fb84c76cbc76fc1968637590 (diff) | |
download | opie-1ab4ca95e4d2cf24d32b38c9031cb6076351e730.zip opie-1ab4ca95e4d2cf24d32b38c9031cb6076351e730.tar.gz opie-1ab4ca95e4d2cf24d32b38c9031cb6076351e730.tar.bz2 |
Merge from BRANCH_1_0
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 | |||
@@ -19,6 +19,7 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "security.h" | 20 | #include "security.h" |
21 | 21 | ||
22 | #include <qpe/qpeapplication.h> | ||
22 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
23 | #include <qpe/password.h> | 24 | #include <qpe/password.h> |
24 | #include <qpe/qpedialog.h> | 25 | #include <qpe/qpedialog.h> |
@@ -27,6 +28,9 @@ | |||
27 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
28 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
29 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
31 | #include <qfile.h> | ||
32 | #include <qlistview.h> | ||
33 | #include <qtextstream.h> | ||
30 | 34 | ||
31 | Security::Security( QWidget* parent, const char* name, WFlags fl ) | 35 | Security::Security( QWidget* parent, const char* name, WFlags fl ) |
32 | : SecurityBase( parent, name, TRUE, fl ) | 36 | : SecurityBase( parent, name, TRUE, fl ) |
@@ -56,8 +60,25 @@ Security::Security( QWidget* parent, const char* name, WFlags fl ) | |||
56 | ssh->hide(); | 60 | ssh->hide(); |
57 | */ | 61 | */ |
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(); |
62 | 83 | ||
63 | dl = new QPEDialogListener(this); | 84 | dl = new QPEDialogListener(this); |
@@ -77,6 +98,10 @@ void Security::updateGUI() | |||
77 | : tr("Change passcode" ) ); | 98 | : tr("Change passcode" ) ); |
78 | passcode_poweron->setEnabled( !empty ); | 99 | passcode_poweron->setEnabled( !empty ); |
79 | clearpasscode->setEnabled( !empty ); | 100 | clearpasscode->setEnabled( !empty ); |
101 | |||
102 | autologinToggle->setChecked(autoLogin); | ||
103 | userlist->setEnabled(autoLogin); | ||
104 | |||
80 | } | 105 | } |
81 | 106 | ||
82 | 107 | ||
@@ -160,6 +185,36 @@ void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) | |||
160 | } | 185 | } |
161 | } | 186 | } |
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) |
164 | { | 219 | { |
165 | int auth_peer,auth_peer_bits; | 220 | int auth_peer,auth_peer_bits; |
@@ -189,7 +244,24 @@ void Security::applySecurity() | |||
189 | cfg.writeEntry("allow_ssh",ssh->isChecked()); | 244 | cfg.writeEntry("allow_ssh",ssh->isChecked()); |
190 | // ### write ssh/telnet sys config files | 245 | // ### write ssh/telnet sys config files |
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 | } |
194 | 266 | ||
195 | void Security::changePassCode() | 267 | void Security::changePassCode() |