-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 |
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 | |||
@@ -21,2 +21,3 @@ | |||
21 | 21 | ||
22 | #include <qpe/qpeapplication.h> | ||
22 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
@@ -29,2 +30,5 @@ | |||
29 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
31 | #include <qfile.h> | ||
32 | #include <qlistview.h> | ||
33 | #include <qtextstream.h> | ||
30 | 34 | ||
@@ -58,4 +62,21 @@ Security::Security( QWidget* parent, const char* name, WFlags fl ) | |||
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(); |
@@ -79,2 +100,6 @@ void Security::updateGUI() | |||
79 | clearpasscode->setEnabled( !empty ); | 100 | clearpasscode->setEnabled( !empty ); |
101 | |||
102 | autologinToggle->setChecked(autoLogin); | ||
103 | userlist->setEnabled(autoLogin); | ||
104 | |||
80 | } | 105 | } |
@@ -162,2 +187,32 @@ void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) | |||
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) |
@@ -191,3 +246,20 @@ void Security::applySecurity() | |||
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 | } |
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 | |||
@@ -45,4 +45,8 @@ private slots: | |||
45 | void setSyncNet(const QString&); | 45 | void setSyncNet(const QString&); |
46 | void changeLoginName(int); | ||
47 | void toggleAutoLogin(bool); | ||
48 | |||
46 | 49 | ||
47 | private: | 50 | private: |
51 | void loadUsers(void); | ||
48 | bool telnetAvailable() const; | 52 | bool telnetAvailable() const; |
@@ -57,2 +61,4 @@ private: | |||
57 | bool valid; | 61 | bool valid; |
62 | bool autoLogin; | ||
63 | QString autoLoginName; | ||
58 | 64 | ||
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 | |||
@@ -13,4 +13,4 @@ | |||
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> |
@@ -27,6 +27,6 @@ | |||
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> |
@@ -34,5 +34,52 @@ | |||
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> |
@@ -78,3 +125,3 @@ | |||
78 | </widget> | 125 | </widget> |
79 | <widget row="1" column="0" > | 126 | <widget> |
80 | <class>QCheckBox</class> | 127 | <class>QCheckBox</class> |
@@ -89,8 +136,137 @@ | |||
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><P>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> |
@@ -108,2 +284,21 @@ | |||
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> |
@@ -124,2 +319,6 @@ | |||
124 | </property> | 319 | </property> |
320 | <property stdset="1"> | ||
321 | <name>textFormat</name> | ||
322 | <enum>RichText</enum> | ||
323 | </property> | ||
125 | </widget> | 324 | </widget> |
@@ -186,29 +385,27 @@ | |||
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><P>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> |