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 | |||
@@ -16,20 +16,24 @@ | |||
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 | #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> |
25 | 26 | ||
26 | #include <qcheckbox.h> | 27 | #include <qcheckbox.h> |
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 ) |
33 | { | 37 | { |
34 | valid=FALSE; | 38 | valid=FALSE; |
35 | Config cfg("Security"); | 39 | Config cfg("Security"); |
@@ -53,14 +57,31 @@ Security::Security( QWidget* parent, const char* name, WFlags fl ) | |||
53 | if ( sshAvailable() ) | 57 | if ( sshAvailable() ) |
54 | ssh->setChecked(cfg.readEntry("allow_ssh")); | 58 | ssh->setChecked(cfg.readEntry("allow_ssh")); |
55 | else | 59 | else |
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); |
64 | showMaximized(); | 85 | showMaximized(); |
65 | } | 86 | } |
66 | 87 | ||
@@ -74,12 +95,16 @@ void Security::updateGUI() | |||
74 | bool empty = passcode.isEmpty(); | 95 | bool empty = passcode.isEmpty(); |
75 | 96 | ||
76 | changepasscode->setText( empty ? tr("Set passcode" ) | 97 | changepasscode->setText( empty ? tr("Set passcode" ) |
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 | ||
83 | void Security::show() | 108 | void Security::show() |
84 | { | 109 | { |
85 | valid=FALSE; | 110 | valid=FALSE; |
@@ -157,12 +182,42 @@ void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) | |||
157 | } | 182 | } |
158 | uint n = (uint)sn.find(' ',x)-x; | 183 | uint n = (uint)sn.find(' ',x)-x; |
159 | auth_peer_bits = sn.mid(x,n).toInt(); | 184 | auth_peer_bits = sn.mid(x,n).toInt(); |
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; |
166 | parseNet(sn,auth_peer,auth_peer_bits); | 221 | parseNet(sn,auth_peer,auth_peer_bits); |
167 | selectNet(auth_peer,auth_peer_bits); | 222 | selectNet(auth_peer,auth_peer_bits); |
168 | } | 223 | } |
@@ -186,13 +241,30 @@ void Security::applySecurity() | |||
186 | if ( telnetAvailable() ) | 241 | if ( telnetAvailable() ) |
187 | cfg.writeEntry("allow_telnet",telnet->isChecked()); | 242 | cfg.writeEntry("allow_telnet",telnet->isChecked()); |
188 | if ( sshAvailable() ) | 243 | if ( sshAvailable() ) |
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() |
196 | { | 268 | { |
197 | QString new1; | 269 | QString new1; |
198 | QString new2; | 270 | QString new2; |