Diffstat (limited to 'core/settings/security/security.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/settings/security/security.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp index 81363d2..1b90121 100644 --- a/core/settings/security/security.cpp +++ b/core/settings/security/security.cpp | |||
@@ -27,106 +27,116 @@ | |||
27 | 27 | ||
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qlistview.h> | 33 | #include <qlistview.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | 35 | ||
36 | Security::Security( QWidget* parent, const char* name, WFlags fl ) | 36 | Security::Security( QWidget* parent, const char* name, WFlags fl ) |
37 | : SecurityBase( parent, name, TRUE, fl ) | 37 | : SecurityBase( parent, name, TRUE, fl ) |
38 | { | 38 | { |
39 | valid=FALSE; | 39 | valid=FALSE; |
40 | Config cfg("Security"); | 40 | Config cfg("Security"); |
41 | cfg.setGroup("Passcode"); | 41 | cfg.setGroup("Passcode"); |
42 | passcode = cfg.readEntry("passcode"); | 42 | passcode = cfg.readEntry("passcode"); |
43 | passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE)); | 43 | passcode_poweron->setChecked(cfg.readBoolEntry("passcode_poweron",FALSE)); |
44 | cfg.setGroup("Sync"); | 44 | cfg.setGroup("Sync"); |
45 | int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 | 45 | int auth_peer = cfg.readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 |
46 | int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); | 46 | int auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); |
47 | selectNet(auth_peer,auth_peer_bits); | 47 | selectNet(auth_peer,auth_peer_bits); |
48 | connect(syncnet, SIGNAL(textChanged(const QString&)), | 48 | connect(syncnet, SIGNAL(textChanged(const QString&)), |
49 | this, SLOT(setSyncNet(const QString&))); | 49 | this, SLOT(setSyncNet(const QString&))); |
50 | 50 | ||
51 | cfg.setGroup("Sync"); | ||
52 | QString sa = cfg.readEntry("syncapp","Qtopia"); | ||
53 | |||
54 | //There must be a better way to do that... | ||
55 | for (int i=0; i<syncapp->count(); i++) { | ||
56 | if ( syncapp->text(i) == sa ) { | ||
57 | syncapp->setCurrentItem(i); | ||
58 | } | ||
59 | } | ||
60 | |||
51 | /* | 61 | /* |
52 | cfg.setGroup("Remote"); | 62 | cfg.setGroup("Remote"); |
53 | if ( telnetAvailable() ) | 63 | if ( telnetAvailable() ) |
54 | telnet->setChecked(cfg.readEntry("allow_telnet")); | 64 | telnet->setChecked(cfg.readEntry("allow_telnet")); |
55 | else | 65 | else |
56 | telnet->hide(); | 66 | telnet->hide(); |
57 | 67 | ||
58 | if ( sshAvailable() ) | 68 | if ( sshAvailable() ) |
59 | ssh->setChecked(cfg.readEntry("allow_ssh")); | 69 | ssh->setChecked(cfg.readEntry("allow_ssh")); |
60 | else | 70 | else |
61 | ssh->hide(); | 71 | ssh->hide(); |
62 | */ | 72 | */ |
63 | 73 | ||
64 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 74 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
65 | Config loginCfg(configFile,Config::File); | 75 | Config loginCfg(configFile,Config::File); |
66 | 76 | ||
67 | loginCfg.setGroup("General"); | 77 | loginCfg.setGroup("General"); |
68 | autoLoginName=loginCfg.readEntry("AutoLogin",""); | 78 | autoLoginName=loginCfg.readEntry("AutoLogin",""); |
69 | 79 | ||
70 | if (autoLoginName.stripWhiteSpace().isEmpty()) { | 80 | if (autoLoginName.stripWhiteSpace().isEmpty()) { |
71 | autoLogin=false; | 81 | autoLogin=false; |
72 | } else { | 82 | } else { |
73 | autoLogin=true; | 83 | autoLogin=true; |
74 | } | 84 | } |
75 | 85 | ||
76 | cfg.setGroup("SyncMode"); | 86 | cfg.setGroup("SyncMode"); |
77 | int mode = cfg.readNumEntry("Mode",2); // Default to Sharp | 87 | int mode = cfg.readNumEntry("Mode",2); // Default to Sharp |
78 | syncModeCombo->setCurrentItem( mode - 1 ); | 88 | syncModeCombo->setCurrentItem( mode - 1 ); |
79 | 89 | ||
80 | connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); | 90 | connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); |
81 | connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); | 91 | connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); |
82 | connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); | 92 | connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); |
83 | connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); | 93 | connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); |
94 | connect(syncapp,SIGNAL(activated(int)), this, SLOT(changeSyncApp())); | ||
84 | 95 | ||
85 | loadUsers(); | 96 | loadUsers(); |
86 | updateGUI(); | 97 | updateGUI(); |
87 | 98 | ||
88 | dl = new QPEDialogListener(this); | 99 | dl = new QPEDialogListener(this); |
89 | showMaximized(); | 100 | showMaximized(); |
90 | } | 101 | } |
91 | 102 | ||
92 | Security::~Security() | 103 | Security::~Security() |
93 | { | 104 | { |
94 | } | 105 | } |
95 | 106 | ||
96 | 107 | ||
97 | void Security::updateGUI() | 108 | void Security::updateGUI() |
98 | { | 109 | { |
99 | bool empty = passcode.isEmpty(); | 110 | bool empty = passcode.isEmpty(); |
100 | 111 | ||
101 | changepasscode->setText( empty ? tr("Set passcode" ) | 112 | changepasscode->setText( empty ? tr("Set passcode" ) |
102 | : tr("Change passcode" ) ); | 113 | : tr("Change passcode" ) ); |
103 | passcode_poweron->setEnabled( !empty ); | 114 | passcode_poweron->setEnabled( !empty ); |
104 | clearpasscode->setEnabled( !empty ); | 115 | clearpasscode->setEnabled( !empty ); |
105 | 116 | ||
106 | autologinToggle->setChecked(autoLogin); | 117 | autologinToggle->setChecked(autoLogin); |
107 | userlist->setEnabled(autoLogin); | 118 | userlist->setEnabled(autoLogin); |
108 | |||
109 | } | 119 | } |
110 | 120 | ||
111 | 121 | ||
112 | void Security::show() | 122 | void Security::show() |
113 | { | 123 | { |
114 | //valid=FALSE; | 124 | //valid=FALSE; |
115 | setEnabled(FALSE); | 125 | setEnabled(FALSE); |
116 | SecurityBase::show(); | 126 | SecurityBase::show(); |
117 | if ( passcode.isEmpty() ) { | 127 | if ( passcode.isEmpty() ) { |
118 | // could insist... | 128 | // could insist... |
119 | //changePassCode(); | 129 | //changePassCode(); |
120 | //if ( passcode.isEmpty() ) | 130 | //if ( passcode.isEmpty() ) |
121 | //reject(); | 131 | //reject(); |
122 | } else { | 132 | } else { |
123 | if (!valid) // security passcode was not asked yet, so ask now | 133 | if (!valid) // security passcode was not asked yet, so ask now |
124 | { | 134 | { |
125 | QString pc = enterPassCode(tr("Enter passcode")); | 135 | QString pc = enterPassCode(tr("Enter passcode")); |
126 | if ( pc != passcode ) { | 136 | if ( pc != passcode ) { |
127 | QMessageBox::critical(this, tr("Passcode incorrect"), | 137 | QMessageBox::critical(this, tr("Passcode incorrect"), |
128 | tr("The passcode entered is incorrect.\nAccess denied")); | 138 | tr("The passcode entered is incorrect.\nAccess denied")); |
129 | reject(); | 139 | reject(); |
130 | return; | 140 | return; |
131 | } | 141 | } |
132 | } | 142 | } |
@@ -228,69 +238,90 @@ void Security::toggleAutoLogin(bool val) | |||
228 | 238 | ||
229 | 239 | ||
230 | 240 | ||
231 | void Security::setSyncNet(const QString& sn) | 241 | void Security::setSyncNet(const QString& sn) |
232 | { | 242 | { |
233 | int auth_peer,auth_peer_bits; | 243 | int auth_peer,auth_peer_bits; |
234 | parseNet(sn,auth_peer,auth_peer_bits); | 244 | parseNet(sn,auth_peer,auth_peer_bits); |
235 | selectNet(auth_peer,auth_peer_bits); | 245 | selectNet(auth_peer,auth_peer_bits); |
236 | } | 246 | } |
237 | 247 | ||
238 | void Security::applySecurity() | 248 | void Security::applySecurity() |
239 | { | 249 | { |
240 | if ( valid ) { | 250 | if ( valid ) { |
241 | Config cfg("Security"); | 251 | Config cfg("Security"); |
242 | cfg.setGroup("Passcode"); | 252 | cfg.setGroup("Passcode"); |
243 | cfg.writeEntry("passcode",passcode); | 253 | cfg.writeEntry("passcode",passcode); |
244 | cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); | 254 | cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); |
245 | cfg.setGroup("Sync"); | 255 | cfg.setGroup("Sync"); |
246 | int auth_peer=0; | 256 | int auth_peer=0; |
247 | int auth_peer_bits; | 257 | int auth_peer_bits; |
248 | QString sn = syncnet->currentText(); | 258 | QString sn = syncnet->currentText(); |
249 | parseNet(sn,auth_peer,auth_peer_bits); | 259 | parseNet(sn,auth_peer,auth_peer_bits); |
250 | cfg.writeEntry("auth_peer",auth_peer); | 260 | cfg.writeEntry("auth_peer",auth_peer); |
251 | cfg.writeEntry("auth_peer_bits",auth_peer_bits); | 261 | cfg.writeEntry("auth_peer_bits",auth_peer_bits); |
262 | cfg.writeEntry("syncapp",syncapp->currentText()); | ||
263 | |||
252 | /* | 264 | /* |
253 | cfg.setGroup("Remote"); | 265 | cfg.setGroup("Remote"); |
254 | if ( telnetAvailable() ) | 266 | if ( telnetAvailable() ) |
255 | cfg.writeEntry("allow_telnet",telnet->isChecked()); | 267 | cfg.writeEntry("allow_telnet",telnet->isChecked()); |
256 | if ( sshAvailable() ) | 268 | if ( sshAvailable() ) |
257 | cfg.writeEntry("allow_ssh",ssh->isChecked()); | 269 | cfg.writeEntry("allow_ssh",ssh->isChecked()); |
258 | // ### write ssh/telnet sys config files | 270 | // ### write ssh/telnet sys config files |
259 | */ | 271 | */ |
260 | 272 | ||
261 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 273 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
262 | Config loginCfg(configFile,Config::File); | 274 | Config loginCfg(configFile,Config::File); |
263 | loginCfg.setGroup("General"); | 275 | loginCfg.setGroup("General"); |
264 | 276 | ||
265 | if (autoLogin) { | 277 | if (autoLogin) { |
266 | loginCfg.writeEntry("AutoLogin",autoLoginName); | 278 | loginCfg.writeEntry("AutoLogin",autoLoginName); |
267 | } else { | 279 | } else { |
268 | loginCfg.removeEntry("AutoLogin"); | 280 | loginCfg.removeEntry("AutoLogin"); |
269 | } | 281 | } |
270 | 282 | ||
271 | } | 283 | } |
272 | } | 284 | } |
285 | void Security::changeSyncApp() | ||
286 | { | ||
287 | // Don't say i didn't tell ya | ||
288 | if (syncapp->currentText() == "IntelliSync") { | ||
289 | QMessageBox attn( | ||
290 | tr("WARNING"), | ||
291 | tr("<p>Selecting IntelliSync here will disable the FTP password." | ||
292 | "<p>Every machine in your netrange will be able to sync with " | ||
293 | "your Zaurus!"), | ||
294 | QMessageBox::Warning, | ||
295 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | ||
296 | 0, QString::null, TRUE, WStyle_StaysOnTop); | ||
297 | attn.setButtonText(QMessageBox::Cancel, tr("Ok")); | ||
298 | attn.exec(); | ||
299 | } | ||
300 | updateGUI(); | ||
301 | } | ||
302 | |||
303 | |||
273 | 304 | ||
274 | void Security::changeLoginName( int idx ) | 305 | void Security::changeLoginName( int idx ) |
275 | { | 306 | { |
276 | autoLoginName = userlist->text(idx);; | 307 | autoLoginName = userlist->text(idx);; |
277 | updateGUI(); | 308 | updateGUI(); |
278 | } | 309 | } |
279 | 310 | ||
280 | void Security::changePassCode() | 311 | void Security::changePassCode() |
281 | { | 312 | { |
282 | QString new1; | 313 | QString new1; |
283 | QString new2; | 314 | QString new2; |
284 | 315 | ||
285 | do { | 316 | do { |
286 | new1 = enterPassCode(tr("Enter new passcode")); | 317 | new1 = enterPassCode(tr("Enter new passcode")); |
287 | if ( new1.isNull() ) | 318 | if ( new1.isNull() ) |
288 | return; | 319 | return; |
289 | new2 = enterPassCode(tr("Re-enter new passcode")); | 320 | new2 = enterPassCode(tr("Re-enter new passcode")); |
290 | if ( new2.isNull() ) | 321 | if ( new2.isNull() ) |
291 | return; | 322 | return; |
292 | } while (new1 != new2); | 323 | } while (new1 != new2); |
293 | 324 | ||
294 | passcode = new1; | 325 | passcode = new1; |
295 | updateGUI(); | 326 | updateGUI(); |
296 | } | 327 | } |