-rw-r--r-- | core/settings/security/security.cpp | 17 | ||||
-rw-r--r-- | core/settings/security/securitybase.ui | 27 |
2 files changed, 38 insertions, 6 deletions
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp index 75a181b..c4726b3 100644 --- a/core/settings/security/security.cpp +++ b/core/settings/security/security.cpp | |||
@@ -14,24 +14,25 @@ | |||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
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/qpeapplication.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/password.h> | 24 | #include <qpe/password.h> |
25 | #include <qpe/qpedialog.h> | 25 | #include <qpe/qpedialog.h> |
26 | #include <qpe/qcopenvelope_qws.h> | ||
26 | 27 | ||
27 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
28 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
29 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
30 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
31 | #include <qfile.h> | 32 | #include <qfile.h> |
32 | #include <qlistview.h> | 33 | #include <qlistview.h> |
33 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
34 | 35 | ||
35 | Security::Security( QWidget* parent, const char* name, WFlags fl ) | 36 | Security::Security( QWidget* parent, const char* name, WFlags fl ) |
36 | : SecurityBase( parent, name, TRUE, fl ) | 37 | : SecurityBase( parent, name, TRUE, fl ) |
37 | { | 38 | { |
@@ -63,24 +64,27 @@ | |||
63 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 64 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
64 | Config loginCfg(configFile,Config::File); | 65 | Config loginCfg(configFile,Config::File); |
65 | 66 | ||
66 | loginCfg.setGroup("General"); | 67 | loginCfg.setGroup("General"); |
67 | autoLoginName=loginCfg.readEntry("AutoLogin",""); | 68 | autoLoginName=loginCfg.readEntry("AutoLogin",""); |
68 | 69 | ||
69 | if (autoLoginName.stripWhiteSpace().isEmpty()) { | 70 | if (autoLoginName.stripWhiteSpace().isEmpty()) { |
70 | autoLogin=false; | 71 | autoLogin=false; |
71 | } else { | 72 | } else { |
72 | autoLogin=true; | 73 | autoLogin=true; |
73 | } | 74 | } |
74 | 75 | ||
76 | cfg.setGroup("SyncMode"); | ||
77 | int mode = cfg.readNumEntry("Mode",2); // Default to Sharp | ||
78 | syncModeCombo->setCurrentItem( mode - 1 ); | ||
75 | 79 | ||
76 | connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); | 80 | connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); |
77 | connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); | 81 | connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); |
78 | connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); | 82 | connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); |
79 | connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); | 83 | connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); |
80 | 84 | ||
81 | loadUsers(); | 85 | loadUsers(); |
82 | updateGUI(); | 86 | updateGUI(); |
83 | 87 | ||
84 | dl = new QPEDialogListener(this); | 88 | dl = new QPEDialogListener(this); |
85 | showMaximized(); | 89 | showMaximized(); |
86 | } | 90 | } |
@@ -123,24 +127,25 @@ void Security::show() | |||
123 | reject(); | 127 | reject(); |
124 | return; | 128 | return; |
125 | } | 129 | } |
126 | } | 130 | } |
127 | setEnabled(TRUE); | 131 | setEnabled(TRUE); |
128 | valid=TRUE; | 132 | valid=TRUE; |
129 | } | 133 | } |
130 | 134 | ||
131 | void Security::accept() | 135 | void Security::accept() |
132 | { | 136 | { |
133 | applySecurity(); | 137 | applySecurity(); |
134 | QDialog::accept(); | 138 | QDialog::accept(); |
139 | QCopEnvelope env("QPE/System", "securityChanged()" ); | ||
135 | } | 140 | } |
136 | 141 | ||
137 | void Security::done(int r) | 142 | void Security::done(int r) |
138 | { | 143 | { |
139 | QDialog::done(r); | 144 | QDialog::done(r); |
140 | close(); | 145 | close(); |
141 | } | 146 | } |
142 | 147 | ||
143 | void Security::selectNet(int auth_peer,int auth_peer_bits) | 148 | void Security::selectNet(int auth_peer,int auth_peer_bits) |
144 | { | 149 | { |
145 | QString sn; | 150 | QString sn; |
146 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { | 151 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { |
@@ -176,52 +181,52 @@ void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) | |||
176 | } else { | 181 | } else { |
177 | int x=0; | 182 | int x=0; |
178 | for (int i=0; i<4; i++) { | 183 | for (int i=0; i<4; i++) { |
179 | int nx = sn.find(QChar(i==3 ? '/' : '.'),x); | 184 | int nx = sn.find(QChar(i==3 ? '/' : '.'),x); |
180 | auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); | 185 | auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); |
181 | x = nx+1; | 186 | x = nx+1; |
182 | } | 187 | } |
183 | uint n = (uint)sn.find(' ',x)-x; | 188 | uint n = (uint)sn.find(' ',x)-x; |
184 | auth_peer_bits = sn.mid(x,n).toInt(); | 189 | auth_peer_bits = sn.mid(x,n).toInt(); |
185 | } | 190 | } |
186 | } | 191 | } |
187 | 192 | ||
188 | void Security::loadUsers ( void ) | 193 | void Security::loadUsers ( void ) |
189 | { | 194 | { |
190 | QFile passwd("/etc/passwd"); | 195 | QFile passwd("/etc/passwd"); |
191 | if ( passwd.open(IO_ReadOnly) ) { | 196 | if ( passwd.open(IO_ReadOnly) ) { |
192 | QTextStream t( &passwd ); | 197 | QTextStream t( &passwd ); |
193 | QString s; | 198 | QString s; |
194 | QStringList account; | 199 | QStringList account; |
195 | while ( !t.eof() ) { | 200 | while ( !t.eof() ) { |
196 | account = QStringList::split(':',t.readLine()); | 201 | account = QStringList::split(':',t.readLine()); |
197 | 202 | ||
198 | // Hide disabled accounts | 203 | // Hide disabled accounts |
199 | if (*account.at(1)!="*") { | 204 | if (*account.at(1)!="*") { |
200 | 205 | ||
201 | userlist->insertItem(*account.at(0)); | 206 | userlist->insertItem(*account.at(0)); |
202 | // Highlight this item if it is set to autologinToggle | 207 | // Highlight this item if it is set to autologinToggle |
203 | if ( *account.at(0) == autoLoginName) | 208 | if ( *account.at(0) == autoLoginName) |
204 | userlist->setCurrentItem(userlist->count()-1); | 209 | userlist->setCurrentItem(userlist->count()-1); |
205 | } | 210 | } |
206 | } | 211 | } |
207 | passwd.close(); | 212 | passwd.close(); |
208 | } | 213 | } |
209 | 214 | ||
210 | } | 215 | } |
211 | void Security::toggleAutoLogin(bool val) | 216 | void Security::toggleAutoLogin(bool val) |
212 | { | 217 | { |
213 | autoLogin=val; | 218 | autoLogin=val; |
214 | userlist->setEnabled(val); | 219 | userlist->setEnabled(val); |
215 | if (!autoLogin) | 220 | if (!autoLogin) |
216 | autoLoginName=userlist->currentText(); | 221 | autoLoginName=userlist->currentText(); |
217 | } | 222 | } |
218 | void Security::setSyncNet(const QString& sn) | 223 | void Security::setSyncNet(const QString& sn) |
219 | { | 224 | { |
220 | int auth_peer,auth_peer_bits; | 225 | int auth_peer,auth_peer_bits; |
221 | parseNet(sn,auth_peer,auth_peer_bits); | 226 | parseNet(sn,auth_peer,auth_peer_bits); |
222 | selectNet(auth_peer,auth_peer_bits); | 227 | selectNet(auth_peer,auth_peer_bits); |
223 | } | 228 | } |
224 | 229 | ||
225 | void Security::applySecurity() | 230 | void Security::applySecurity() |
226 | { | 231 | { |
227 | if ( valid ) { | 232 | if ( valid ) { |
@@ -246,24 +251,26 @@ void Security::applySecurity() | |||
246 | */ | 251 | */ |
247 | 252 | ||
248 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 253 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
249 | Config loginCfg(configFile,Config::File); | 254 | Config loginCfg(configFile,Config::File); |
250 | loginCfg.setGroup("General"); | 255 | loginCfg.setGroup("General"); |
251 | 256 | ||
252 | if (autoLogin) { | 257 | if (autoLogin) { |
253 | loginCfg.writeEntry("AutoLogin",autoLoginName); | 258 | loginCfg.writeEntry("AutoLogin",autoLoginName); |
254 | } else { | 259 | } else { |
255 | loginCfg.removeEntry("AutoLogin"); | 260 | loginCfg.removeEntry("AutoLogin"); |
256 | } | 261 | } |
257 | 262 | ||
263 | cfg.setGroup("SyncMode"); | ||
264 | cfg.writeEntry("Mode", syncModeCombo->currentItem()+1 ); | ||
258 | } | 265 | } |
259 | } | 266 | } |
260 | 267 | ||
261 | void Security::changeLoginName( int idx ) | 268 | void Security::changeLoginName( int idx ) |
262 | { | 269 | { |
263 | autoLoginName = userlist->text(idx);; | 270 | autoLoginName = userlist->text(idx);; |
264 | updateGUI(); | 271 | updateGUI(); |
265 | } | 272 | } |
266 | 273 | ||
267 | void Security::changePassCode() | 274 | void Security::changePassCode() |
268 | { | 275 | { |
269 | QString new1; | 276 | QString new1; |
diff --git a/core/settings/security/securitybase.ui b/core/settings/security/securitybase.ui index da25f39..73290e5 100644 --- a/core/settings/security/securitybase.ui +++ b/core/settings/security/securitybase.ui | |||
@@ -2,25 +2,25 @@ | |||
2 | <class>SecurityBase</class> | 2 | <class>SecurityBase</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QDialog</class> | 4 | <class>QDialog</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>SecurityBase</cstring> | 7 | <cstring>SecurityBase</cstring> |
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>329</width> | 14 | <width>339</width> |
15 | <height>483</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> |
@@ -372,24 +372,49 @@ | |||
372 | <string>None</string> | 372 | <string>None</string> |
373 | </property> | 373 | </property> |
374 | </item> | 374 | </item> |
375 | <property stdset="1"> | 375 | <property stdset="1"> |
376 | <name>name</name> | 376 | <name>name</name> |
377 | <cstring>syncnet</cstring> | 377 | <cstring>syncnet</cstring> |
378 | </property> | 378 | </property> |
379 | <property stdset="1"> | 379 | <property stdset="1"> |
380 | <name>editable</name> | 380 | <name>editable</name> |
381 | <bool>true</bool> | 381 | <bool>true</bool> |
382 | </property> | 382 | </property> |
383 | </widget> | 383 | </widget> |
384 | <widget> | ||
385 | <class>QComboBox</class> | ||
386 | <item> | ||
387 | <property> | ||
388 | <name>text</name> | ||
389 | <string>Qtopia 1.7</string> | ||
390 | </property> | ||
391 | </item> | ||
392 | <item> | ||
393 | <property> | ||
394 | <name>text</name> | ||
395 | <string>Opie 1.0</string> | ||
396 | </property> | ||
397 | </item> | ||
398 | <item> | ||
399 | <property> | ||
400 | <name>text</name> | ||
401 | <string>Both</string> | ||
402 | </property> | ||
403 | </item> | ||
404 | <property stdset="1"> | ||
405 | <name>name</name> | ||
406 | <cstring>syncModeCombo</cstring> | ||
407 | </property> | ||
408 | </widget> | ||
384 | </vbox> | 409 | </vbox> |
385 | </widget> | 410 | </widget> |
386 | <spacer> | 411 | <spacer> |
387 | <property> | 412 | <property> |
388 | <name>name</name> | 413 | <name>name</name> |
389 | <cstring>Spacer1</cstring> | 414 | <cstring>Spacer1</cstring> |
390 | </property> | 415 | </property> |
391 | <property stdset="1"> | 416 | <property stdset="1"> |
392 | <name>orientation</name> | 417 | <name>orientation</name> |
393 | <enum>Vertical</enum> | 418 | <enum>Vertical</enum> |
394 | </property> | 419 | </property> |
395 | <property stdset="1"> | 420 | <property stdset="1"> |