summaryrefslogtreecommitdiff
path: root/core/settings/security
Unidiff
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 @@
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
31Security::Security( QWidget* parent, const char* name, WFlags fl ) 35Security::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
83void Security::show() 108void 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
188void 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}
211void Security::toggleAutoLogin(bool val)
212{
213 autoLogin=val;
214 userlist->setEnabled(val);
215 if (!autoLogin)
216 autoLoginName=userlist->currentText();
217}
163void Security::setSyncNet(const QString& sn) 218void 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
261void Security::changeLoginName( int idx )
262{
263 autoLoginName = userlist->text(idx);;
264 updateGUI();
193} 265}
194 266
195void Security::changePassCode() 267void Security::changePassCode()
196{ 268{
197 QString new1; 269 QString new1;
198 QString new2; 270 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:
40 void done(int); 40 void done(int);
41 41
42private slots: 42private slots:
43 void changePassCode(); 43 void changePassCode();
44 void clearPassCode(); 44 void clearPassCode();
45 void setSyncNet(const QString&); 45 void setSyncNet(const QString&);
46 void changeLoginName(int);
47 void toggleAutoLogin(bool);
48
46 49
47private: 50private:
51 void loadUsers(void);
48 bool telnetAvailable() const; 52 bool telnetAvailable() const;
49 bool sshAvailable() const; 53 bool sshAvailable() const;
50 void updateGUI(); 54 void updateGUI();
51 55
52 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits); 56 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits);
53 void selectNet(int auth_peer,int auth_peer_bits); 57 void selectNet(int auth_peer,int auth_peer_bits);
54 58
55 QString enterPassCode(const QString&); 59 QString enterPassCode(const QString&);
56 QString passcode; 60 QString passcode;
57 bool valid; 61 bool valid;
62 bool autoLogin;
63 QString autoLoginName;
58 64
59 QPEDialogListener *dl; 65 QPEDialogListener *dl;
60}; 66};
61 67
62 68
63#endif // SECURITY_H 69#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 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>277</width> 14 <width>329</width>
15 <height>328</height> 15 <height>483</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Security Settings</string> 20 <string>Security Settings</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <grid> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>3</number> 31 <number>0</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>3</number> 35 <number>0</number>
36 </property>
37 <widget>
38 <class>QTabWidget</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>TabWidget2</cstring>
42 </property>
43 <property>
44 <name>layoutMargin</name>
36 </property> 45 </property>
37 <widget row="0" column="0" > 46 <widget>
47 <class>QWidget</class>
48 <property stdset="1">
49 <name>name</name>
50 <cstring>tab</cstring>
51 </property>
52 <attribute>
53 <name>title</name>
54 <string>Passcode</string>
55 </attribute>
56 <vbox>
57 <property stdset="1">
58 <name>margin</name>
59 <number>6</number>
60 </property>
61 <property stdset="1">
62 <name>spacing</name>
63 <number>6</number>
64 </property>
65 <widget>
66 <class>QGroupBox</class>
67 <property stdset="1">
68 <name>name</name>
69 <cstring>GroupBox4</cstring>
70 </property>
71 <property stdset="1">
72 <name>title</name>
73 <string>Passcode</string>
74 </property>
75 <vbox>
76 <property stdset="1">
77 <name>margin</name>
78 <number>11</number>
79 </property>
80 <property stdset="1">
81 <name>spacing</name>
82 <number>6</number>
83 </property>
84 <widget>
38 <class>QLayoutWidget</class> 85 <class>QLayoutWidget</class>
39 <property stdset="1"> 86 <property stdset="1">
40 <name>name</name> 87 <name>name</name>
41 <cstring>Layout1</cstring> 88 <cstring>Layout1</cstring>
42 </property> 89 </property>
43 <property> 90 <property>
@@ -73,29 +120,158 @@
73 <name>text</name> 120 <name>text</name>
74 <string>Clear passcode</string> 121 <string>Clear passcode</string>
75 </property> 122 </property>
76 </widget> 123 </widget>
77 </hbox> 124 </hbox>
78 </widget> 125 </widget>
79 <widget row="1" column="0" > 126 <widget>
80 <class>QCheckBox</class> 127 <class>QCheckBox</class>
81 <property stdset="1"> 128 <property stdset="1">
82 <name>name</name> 129 <name>name</name>
83 <cstring>passcode_poweron</cstring> 130 <cstring>passcode_poweron</cstring>
84 </property> 131 </property>
85 <property stdset="1"> 132 <property stdset="1">
86 <name>text</name> 133 <name>text</name>
87 <string>Require pass code at power-on</string> 134 <string>Require pass code at power-on</string>
88 </property> 135 </property>
89 </widget> 136 </widget>
90 <widget row="3" column="0" > 137 <widget>
91 <class>QTabWidget</class> 138 <class>QLabel</class>
92 <property stdset="1"> 139 <property stdset="1">
93 <name>name</name> 140 <name>name</name>
94 <cstring>TabWidget2</cstring> 141 <cstring>TextLabel1</cstring>
142 </property>
143 <property stdset="1">
144 <name>sizePolicy</name>
145 <sizepolicy>
146 <hsizetype>5</hsizetype>
147 <vsizetype>7</vsizetype>
148 </sizepolicy>
149 </property>
150 <property stdset="1">
151 <name>text</name>
152 <string>&lt;P&gt;Pass code protection provides a minimal level of protection from casual access to this device.</string>
153 </property>
154 <property stdset="1">
155 <name>textFormat</name>
156 <enum>RichText</enum>
157 </property>
158 <property stdset="1">
159 <name>alignment</name>
160 <set>AlignTop|AlignLeft</set>
161 </property>
162 <property>
163 <name>vAlign</name>
164 </property>
165 </widget>
166 </vbox>
167 </widget>
168 <spacer>
169 <property>
170 <name>name</name>
171 <cstring>Spacer3</cstring>
172 </property>
173 <property stdset="1">
174 <name>orientation</name>
175 <enum>Vertical</enum>
176 </property>
177 <property stdset="1">
178 <name>sizeType</name>
179 <enum>Expanding</enum>
180 </property>
181 <property>
182 <name>sizeHint</name>
183 <size>
184 <width>20</width>
185 <height>20</height>
186 </size>
187 </property>
188 </spacer>
189 </vbox>
190 </widget>
191 <widget>
192 <class>QWidget</class>
193 <property stdset="1">
194 <name>name</name>
195 <cstring>tab</cstring>
196 </property>
197 <attribute>
198 <name>title</name>
199 <string>Login</string>
200 </attribute>
201 <vbox>
202 <property stdset="1">
203 <name>margin</name>
204 <number>6</number>
205 </property>
206 <property stdset="1">
207 <name>spacing</name>
208 <number>6</number>
209 </property>
210 <widget>
211 <class>QGroupBox</class>
212 <property stdset="1">
213 <name>name</name>
214 <cstring>GroupBox3</cstring>
215 </property>
216 <property stdset="1">
217 <name>title</name>
218 <string>Login</string>
219 </property>
220 <vbox>
221 <property stdset="1">
222 <name>margin</name>
223 <number>11</number>
224 </property>
225 <property stdset="1">
226 <name>spacing</name>
227 <number>6</number>
228 </property>
229 <widget>
230 <class>QCheckBox</class>
231 <property stdset="1">
232 <name>name</name>
233 <cstring>autologinToggle</cstring>
234 </property>
235 <property stdset="1">
236 <name>text</name>
237 <string>Login Automatically</string>
238 </property>
239 </widget>
240 <widget>
241 <class>QComboBox</class>
242 <property stdset="1">
243 <name>name</name>
244 <cstring>userlist</cstring>
245 </property>
246 </widget>
247 </vbox>
248 </widget>
249 <spacer>
250 <property>
251 <name>name</name>
252 <cstring>Spacer2</cstring>
95 </property> 253 </property>
254 <property stdset="1">
255 <name>orientation</name>
256 <enum>Vertical</enum>
257 </property>
258 <property stdset="1">
259 <name>sizeType</name>
260 <enum>Expanding</enum>
261 </property>
262 <property>
263 <name>sizeHint</name>
264 <size>
265 <width>20</width>
266 <height>20</height>
267 </size>
268 </property>
269 </spacer>
270 </vbox>
271 </widget>
96 <widget> 272 <widget>
97 <class>QWidget</class> 273 <class>QWidget</class>
98 <property stdset="1"> 274 <property stdset="1">
99 <name>name</name> 275 <name>name</name>
100 <cstring>tab</cstring> 276 <cstring>tab</cstring>
101 </property> 277 </property>
@@ -103,12 +279,31 @@
103 <name>title</name> 279 <name>title</name>
104 <string>Sync</string> 280 <string>Sync</string>
105 </attribute> 281 </attribute>
106 <vbox> 282 <vbox>
107 <property stdset="1"> 283 <property stdset="1">
108 <name>margin</name> 284 <name>margin</name>
285 <number>6</number>
286 </property>
287 <property stdset="1">
288 <name>spacing</name>
289 <number>6</number>
290 </property>
291 <widget>
292 <class>QGroupBox</class>
293 <property stdset="1">
294 <name>name</name>
295 <cstring>GroupBox2</cstring>
296 </property>
297 <property stdset="1">
298 <name>title</name>
299 <string>Sync</string>
300 </property>
301 <vbox>
302 <property stdset="1">
303 <name>margin</name>
109 <number>11</number> 304 <number>11</number>
110 </property> 305 </property>
111 <property stdset="1"> 306 <property stdset="1">
112 <name>spacing</name> 307 <name>spacing</name>
113 <number>6</number> 308 <number>6</number>
114 </property> 309 </property>
@@ -119,12 +314,16 @@
119 <cstring>TextLabel1_2</cstring> 314 <cstring>TextLabel1_2</cstring>
120 </property> 315 </property>
121 <property stdset="1"> 316 <property stdset="1">
122 <name>text</name> 317 <name>text</name>
123 <string>Accept sync from network:</string> 318 <string>Accept sync from network:</string>
124 </property> 319 </property>
320 <property stdset="1">
321 <name>textFormat</name>
322 <enum>RichText</enum>
323 </property>
125 </widget> 324 </widget>
126 <widget> 325 <widget>
127 <class>QComboBox</class> 326 <class>QComboBox</class>
128 <item> 327 <item>
129 <property> 328 <property>
130 <name>text</name> 329 <name>text</name>
@@ -181,35 +380,33 @@
181 <name>editable</name> 380 <name>editable</name>
182 <bool>true</bool> 381 <bool>true</bool>
183 </property> 382 </property>
184 </widget> 383 </widget>
185 </vbox> 384 </vbox>
186 </widget> 385 </widget>
187 </widget> 386 <spacer>
188 <widget row="2" column="0" > 387 <property>
189 <class>QLabel</class>
190 <property stdset="1">
191 <name>name</name> 388 <name>name</name>
192 <cstring>TextLabel1</cstring> 389 <cstring>Spacer1</cstring>
193 </property> 390 </property>
194 <property stdset="1"> 391 <property stdset="1">
195 <name>sizePolicy</name> 392 <name>orientation</name>
196 <sizepolicy> 393 <enum>Vertical</enum>
197 <hsizetype>5</hsizetype>
198 <vsizetype>7</vsizetype>
199 </sizepolicy>
200 </property> 394 </property>
201 <property stdset="1"> 395 <property stdset="1">
202 <name>text</name> 396 <name>sizeType</name>
203 <string>&lt;P&gt;Pass code protection provides a minimal level of protection from casual access to this device.</string> 397 <enum>Expanding</enum>
204 </property>
205 <property stdset="1">
206 <name>alignment</name>
207 <set>AlignTop|AlignLeft</set>
208 </property> 398 </property>
209 <property> 399 <property>
210 <name>vAlign</name> 400 <name>sizeHint</name>
401 <size>
402 <width>20</width>
403 <height>20</height>
404 </size>
211 </property> 405 </property>
406 </spacer>
407 </vbox>
212 </widget> 408 </widget>
213 </grid> 409 </widget>
410 </vbox>
214</widget> 411</widget>
215</UI> 412</UI>