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 @@ -18,16 +18,20 @@ ** **********************************************************************/ #include "security.h" +#include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/password.h> #include <qpe/qpedialog.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qcombobox.h> #include <qmessagebox.h> +#include <qfile.h> +#include <qlistview.h> +#include <qtextstream.h> Security::Security( QWidget* parent, const char* name, WFlags fl ) : SecurityBase( parent, name, TRUE, fl ) { @@ -55,10 +59,27 @@ Security::Security( QWidget* parent, const char* name, WFlags fl ) else ssh->hide(); */ + QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; + Config loginCfg(configFile,Config::File); + + loginCfg.setGroup("General"); + autoLoginName=loginCfg.readEntry("AutoLogin",""); + + if (autoLoginName.stripWhiteSpace().isEmpty()) { + autoLogin=false; + } else { + autoLogin=true; + } + + + connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); + connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); + + loadUsers(); updateGUI(); dl = new QPEDialogListener(this); showMaximized(); @@ -76,8 +97,12 @@ void Security::updateGUI() changepasscode->setText( empty ? tr("Set passcode" ) : tr("Change passcode" ) ); passcode_poweron->setEnabled( !empty ); clearpasscode->setEnabled( !empty ); + + autologinToggle->setChecked(autoLogin); + userlist->setEnabled(autoLogin); + } void Security::show() @@ -159,8 +184,38 @@ void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) auth_peer_bits = sn.mid(x,n).toInt(); } } +void Security::loadUsers ( void ) +{ + QFile passwd("/etc/passwd"); + if ( passwd.open(IO_ReadOnly) ) { + QTextStream t( &passwd ); + QString s; + QStringList account; + while ( !t.eof() ) { + account = QStringList::split(':',t.readLine()); + + // Hide disabled accounts + if (*account.at(1)!="*") { + + userlist->insertItem(*account.at(0)); + // Highlight this item if it is set to autologinToggle + if ( *account.at(0) == autoLoginName) + userlist->setCurrentItem(userlist->count()-1); + } + } + passwd.close(); + } + +} +void Security::toggleAutoLogin(bool val) +{ + autoLogin=val; + userlist->setEnabled(val); + if (!autoLogin) + autoLoginName=userlist->currentText(); +} void Security::setSyncNet(const QString& sn) { int auth_peer,auth_peer_bits; parseNet(sn,auth_peer,auth_peer_bits); @@ -188,9 +243,26 @@ void Security::applySecurity() if ( sshAvailable() ) cfg.writeEntry("allow_ssh",ssh->isChecked()); // ### write ssh/telnet sys config files */ + + QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; + Config loginCfg(configFile,Config::File); + loginCfg.setGroup("General"); + + if (autoLogin) { + loginCfg.writeEntry("AutoLogin",autoLoginName); + } else { + loginCfg.removeEntry("AutoLogin"); + } + + } } + +void Security::changeLoginName( int idx ) +{ + autoLoginName = userlist->text(idx);; + updateGUI(); } void Security::changePassCode() { |