summaryrefslogtreecommitdiff
path: root/core/settings/security
Side-by-side diff
Diffstat (limited to 'core/settings/security') (more/less context) (show whitespace changes)
-rw-r--r--core/settings/security/security.cpp72
-rw-r--r--core/settings/security/security.h6
-rw-r--r--core/settings/security/securitybase.ui253
3 files changed, 303 insertions, 28 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 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#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 )
{
valid=FALSE;
Config cfg("Security");
@@ -53,14 +57,31 @@ Security::Security( QWidget* parent, const char* name, WFlags fl )
if ( sshAvailable() )
ssh->setChecked(cfg.readEntry("allow_ssh"));
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();
}
@@ -74,12 +95,16 @@ void Security::updateGUI()
bool empty = passcode.isEmpty();
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()
{
valid=FALSE;
@@ -157,12 +182,42 @@ void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
}
uint n = (uint)sn.find(' ',x)-x;
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);
selectNet(auth_peer,auth_peer_bits);
}
@@ -186,13 +241,30 @@ void Security::applySecurity()
if ( telnetAvailable() )
cfg.writeEntry("allow_telnet",telnet->isChecked());
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()
{
QString new1;
QString new2;
diff --git a/core/settings/security/security.h b/core/settings/security/security.h
index efc83a2..2f18f91 100644
--- a/core/settings/security/security.h
+++ b/core/settings/security/security.h
@@ -40,24 +40,30 @@ protected:
void done(int);
private slots:
void changePassCode();
void clearPassCode();
void setSyncNet(const QString&);
+ void changeLoginName(int);
+ void toggleAutoLogin(bool);
+
private:
+ void loadUsers(void);
bool telnetAvailable() const;
bool sshAvailable() const;
void updateGUI();
static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits);
void selectNet(int auth_peer,int auth_peer_bits);
QString enterPassCode(const QString&);
QString passcode;
bool valid;
+ bool autoLogin;
+ QString autoLoginName;
QPEDialogListener *dl;
};
#endif // SECURITY_H
diff --git a/core/settings/security/securitybase.ui b/core/settings/security/securitybase.ui
index c2a8953..da25f39 100644
--- a/core/settings/security/securitybase.ui
+++ b/core/settings/security/securitybase.ui
@@ -8,36 +8,83 @@
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>277</width>
- <height>328</height>
+ <width>329</width>
+ <height>483</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Security Settings</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
- <grid>
+ <vbox>
<property stdset="1">
<name>margin</name>
- <number>3</number>
+ <number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
- <number>3</number>
+ <number>0</number>
+ </property>
+ <widget>
+ <class>QTabWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TabWidget2</cstring>
+ </property>
+ <property>
+ <name>layoutMargin</name>
</property>
- <widget row="0" column="0" >
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>tab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Passcode</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QGroupBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>GroupBox4</cstring>
+ </property>
+ <property stdset="1">
+ <name>title</name>
+ <string>Passcode</string>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout1</cstring>
</property>
<property>
@@ -73,29 +120,158 @@
<name>text</name>
<string>Clear passcode</string>
</property>
</widget>
</hbox>
</widget>
- <widget row="1" column="0" >
+ <widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>passcode_poweron</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Require pass code at power-on</string>
</property>
</widget>
- <widget row="3" column="0" >
- <class>QTabWidget</class>
+ <widget>
+ <class>QLabel</class>
<property stdset="1">
<name>name</name>
- <cstring>TabWidget2</cstring>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>7</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&lt;P&gt;Pass code protection provides a minimal level of protection from casual access to this device.</string>
+ </property>
+ <property stdset="1">
+ <name>textFormat</name>
+ <enum>RichText</enum>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignTop|AlignLeft</set>
+ </property>
+ <property>
+ <name>vAlign</name>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer3</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>tab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Login</string>
+ </attribute>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QGroupBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>GroupBox3</cstring>
+ </property>
+ <property stdset="1">
+ <name>title</name>
+ <string>Login</string>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>autologinToggle</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Login Automatically</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>userlist</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer2</cstring>
</property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
@@ -103,12 +279,31 @@
<name>title</name>
<string>Sync</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QGroupBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>GroupBox2</cstring>
+ </property>
+ <property stdset="1">
+ <name>title</name>
+ <string>Sync</string>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
@@ -119,12 +314,16 @@
<cstring>TextLabel1_2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Accept sync from network:</string>
</property>
+ <property stdset="1">
+ <name>textFormat</name>
+ <enum>RichText</enum>
+ </property>
</widget>
<widget>
<class>QComboBox</class>
<item>
<property>
<name>text</name>
@@ -181,35 +380,33 @@
<name>editable</name>
<bool>true</bool>
</property>
</widget>
</vbox>
</widget>
- </widget>
- <widget row="2" column="0" >
- <class>QLabel</class>
- <property stdset="1">
+ <spacer>
+ <property>
<name>name</name>
- <cstring>TextLabel1</cstring>
+ <cstring>Spacer1</cstring>
</property>
<property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>7</vsizetype>
- </sizepolicy>
+ <name>orientation</name>
+ <enum>Vertical</enum>
</property>
<property stdset="1">
- <name>text</name>
- <string>&lt;P&gt;Pass code protection provides a minimal level of protection from casual access to this device.</string>
- </property>
- <property stdset="1">
- <name>alignment</name>
- <set>AlignTop|AlignLeft</set>
+ <name>sizeType</name>
+ <enum>Expanding</enum>
</property>
<property>
- <name>vAlign</name>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
</property>
+ </spacer>
+ </vbox>
</widget>
- </grid>
+ </widget>
+ </vbox>
</widget>
</UI>