-rw-r--r-- | core/settings/launcher/tabdialog.cpp | 6 | ||||
-rw-r--r-- | core/settings/security/security.cpp | 72 | ||||
-rw-r--r-- | core/settings/security/security.h | 6 | ||||
-rw-r--r-- | core/settings/security/securitybase.ui | 253 |
4 files changed, 306 insertions, 31 deletions
diff --git a/core/settings/launcher/tabdialog.cpp b/core/settings/launcher/tabdialog.cpp index 5f68010..de99a09 100644 --- a/core/settings/launcher/tabdialog.cpp +++ b/core/settings/launcher/tabdialog.cpp @@ -91,9 +91,9 @@ public: calculateGrid ( Bottom ); - new SampleItem ( this, tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" )); - new SampleItem ( this, tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" )); - new SampleItem ( this, tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" )); + new SampleItem ( this, QObject::tr( "Sample 1" ), Resource::loadPixmap ( "datebook/DateBook" )); + new SampleItem ( this, QObject::tr( "Sample 2" ), Resource::loadPixmap ( "Calibrate" )); + new SampleItem ( this, QObject::tr( "Sample 3" ), Resource::loadPixmap ( "UnknownDocument" )); setBackgroundType ( TabConfig::Ruled, QString::null ); 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 @@ **********************************************************************/ #include "security.h" +#include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/password.h> #include <qpe/qpedialog.h> @@ -27,6 +28,9 @@ #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 ) @@ -56,8 +60,25 @@ Security::Security( QWidget* parent, const char* name, WFlags fl ) 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); @@ -77,6 +98,10 @@ void Security::updateGUI() : tr("Change passcode" ) ); passcode_poweron->setEnabled( !empty ); clearpasscode->setEnabled( !empty ); + + autologinToggle->setChecked(autoLogin); + userlist->setEnabled(autoLogin); + } @@ -160,6 +185,36 @@ void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) } } +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; @@ -189,7 +244,24 @@ void Security::applySecurity() 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() 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 @@ -43,8 +43,12 @@ 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(); @@ -55,6 +59,8 @@ private: QString enterPassCode(const QString&); QString passcode; bool valid; + bool autoLogin; + QString autoLoginName; QPEDialogListener *dl; }; 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 @@ -11,8 +11,8 @@ <rect> <x>0</x> <y>0</y> - <width>277</width> - <height>328</height> + <width>329</width> + <height>483</height> </rect> </property> <property stdset="1"> @@ -25,16 +25,63 @@ <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> @@ -76,7 +123,7 @@ </widget> </hbox> </widget> - <widget row="1" column="0" > + <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> @@ -87,12 +134,141 @@ <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><P>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"> @@ -106,6 +282,25 @@ <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"> @@ -122,6 +317,10 @@ <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> @@ -184,32 +383,30 @@ </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><P>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> |