summaryrefslogtreecommitdiff
authorcoredump <coredump>2003-11-27 12:26:07 (UTC)
committer coredump <coredump>2003-11-27 12:26:07 (UTC)
commit51ca35ecb7e22fc564ffe62184d4a75aa8537b1d (patch) (unidiff)
tree49bffaeeec6e8dba3b5d2dd5614ef77d50045c9e
parentafe4e5bcfdd3d67166cdbf28f4514783ada1d290 (diff)
downloadopie-51ca35ecb7e22fc564ffe62184d4a75aa8537b1d.zip
opie-51ca35ecb7e22fc564ffe62184d4a75aa8537b1d.tar.gz
opie-51ca35ecb7e22fc564ffe62184d4a75aa8537b1d.tar.bz2
Added: Default net-ranges are no longer hard-coded and can be edited
Bugfix: Show user-defined net-range upon application restart in drop-down list
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/security/security.cpp100
-rw-r--r--core/settings/security/security.h7
-rw-r--r--core/settings/security/securitybase.ui202
3 files changed, 228 insertions, 81 deletions
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp
index 1b90121..d7871b3 100644
--- a/core/settings/security/security.cpp
+++ b/core/settings/security/security.cpp
@@ -34,7 +34,7 @@
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, WStyle_ContextHelp )
38{ 38{
39 valid=FALSE; 39 valid=FALSE;
40 Config cfg("Security"); 40 Config cfg("Security");
@@ -44,14 +44,14 @@
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,TRUE);
48
48 connect(syncnet, SIGNAL(textChanged(const QString&)), 49 connect(syncnet, SIGNAL(textChanged(const QString&)),
49 this, SLOT(setSyncNet(const QString&))); 50 this, SLOT(setSyncNet(const QString&)));
50 51
51 cfg.setGroup("Sync"); 52 cfg.setGroup("Sync");
52 QString sa = cfg.readEntry("syncapp","Qtopia"); 53 QString sa = cfg.readEntry("syncapp","Qtopia");
53 54
54 //There must be a better way to do that...
55 for (int i=0; i<syncapp->count(); i++) { 55 for (int i=0; i<syncapp->count(); i++) {
56 if ( syncapp->text(i) == sa ) { 56 if ( syncapp->text(i) == sa ) {
57 syncapp->setCurrentItem(i); 57 syncapp->setCurrentItem(i);
@@ -86,12 +86,18 @@
86 cfg.setGroup("SyncMode"); 86 cfg.setGroup("SyncMode");
87 int mode = cfg.readNumEntry("Mode",2); // Default to Sharp 87 int mode = cfg.readNumEntry("Mode",2); // Default to Sharp
88 syncModeCombo->setCurrentItem( mode - 1 ); 88 syncModeCombo->setCurrentItem( mode - 1 );
89
90 //since nobody knows what this is and it doesn't do anything, i'll hide it # CoreDump
91 // is this work-in-progress or can it be removed?
92 syncModeCombo->hide();
89 93
90 connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); 94 connect(autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool)));
91 connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); 95 connect(userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int)));
92 connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode())); 96 connect(changepasscode,SIGNAL(clicked()), this, SLOT(changePassCode()));
93 connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode())); 97 connect(clearpasscode,SIGNAL(clicked()), this, SLOT(clearPassCode()));
94 connect(syncapp,SIGNAL(activated(int)), this, SLOT(changeSyncApp())); 98 connect(syncapp,SIGNAL(activated(int)), this, SLOT(changeSyncApp()));
99 connect(restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults()));
100 connect(deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry()));
95 101
96 loadUsers(); 102 loadUsers();
97 updateGUI(); 103 updateGUI();
@@ -104,6 +110,40 @@ Security::~Security()
104{ 110{
105} 111}
106 112
113void Security::deleteListEntry()
114{
115 syncnet->removeItem(syncnet->currentItem());
116}
117
118void Security::restoreDefaults()
119 {
120 QMessageBox unrecbox(
121 tr("Attention"),
122 tr("<p>All user-defined net ranges will be lost."),
123 QMessageBox::Warning,
124 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
125 0, QString::null, TRUE, WStyle_StaysOnTop);
126 unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel"));
127 unrecbox.setButtonText(QMessageBox::Yes, tr("Ok"));
128
129 if ( unrecbox.exec() == QMessageBox::Yes)
130 {
131 syncnet->clear();
132 insertDefaultRanges();
133 }
134}
135
136void Security::insertDefaultRanges()
137{
138 syncnet->insertItem( tr( "192.168.129.0/24" ) );
139 syncnet->insertItem( tr( "192.168.1.0/24" ) );
140 syncnet->insertItem( tr( "192.168.0.0/16" ) );
141 syncnet->insertItem( tr( "172.16.0.0/12" ) );
142 syncnet->insertItem( tr( "10.0.0.0/8" ) );
143 syncnet->insertItem( tr( "1.0.0.0/8" ) );
144 syncnet->insertItem( tr( "Any" ) );
145 syncnet->insertItem( tr( "None" ) );
146}
107 147
108void Security::updateGUI() 148void Security::updateGUI()
109{ 149{
@@ -158,7 +198,7 @@ void Security::done(int r)
158 close(); 198 close();
159} 199}
160 200
161void Security::selectNet(int auth_peer,int auth_peer_bits) 201void Security::selectNet(int auth_peer,int auth_peer_bits, bool update)
162{ 202{
163 QString sn; 203 QString sn;
164 if ( auth_peer_bits == 0 && auth_peer == 0 ) { 204 if ( auth_peer_bits == 0 && auth_peer == 0 ) {
@@ -173,6 +213,44 @@ void Security::selectNet(int auth_peer,int auth_peer_bits)
173 + QString::number((auth_peer>>0)&0xff) + "/" 213 + QString::number((auth_peer>>0)&0xff) + "/"
174 + QString::number(auth_peer_bits); 214 + QString::number(auth_peer_bits);
175 } 215 }
216
217 //insert user-defined list of netranges upon start
218 if (update) {
219 //User selected/active netrange first
220 syncnet->insertItem( tr( sn ) );
221
222 Config cfg("Security");
223 cfg.setGroup("Sync");
224
225 //set up defaults if needed, if someone manually deletes net0 he'll get a suprise hehe
226 QString test = cfg.readEntry("net0","");
227 if (test.isEmpty()) {
228 insertDefaultRanges();
229 } else {
230 // 10 ought to be enough for everybody... :)
231 // If you need more, don't forget to edit applySecurity() as well
232 bool already_there=FALSE;
233 for (int i=0; i<10; i++) {
234 QString target, netrange;
235 target.sprintf("net%d", i);
236 netrange = cfg.readEntry(target,"");
237 if (! netrange.isEmpty()){
238 //make sure we have no "twin" entries
239 for (int i=0; i<syncnet->count(); i++) {
240 if ( syncnet->text(i) == netrange ) {
241 already_there=TRUE;
242 }
243 }
244 if (! already_there) {
245 syncnet->insertItem( tr( netrange ) );
246 } else {
247 already_there=FALSE;
248 }
249 }
250 }
251 }
252 }
253
176 for (int i=0; i<syncnet->count(); i++) { 254 for (int i=0; i<syncnet->count(); i++) {
177 if ( syncnet->text(i).left(sn.length()) == sn ) { 255 if ( syncnet->text(i).left(sn.length()) == sn ) {
178 syncnet->setCurrentItem(i); 256 syncnet->setCurrentItem(i);
@@ -242,7 +320,7 @@ void Security::setSyncNet(const QString& sn)
242{ 320{
243 int auth_peer,auth_peer_bits; 321 int auth_peer,auth_peer_bits;
244 parseNet(sn,auth_peer,auth_peer_bits); 322 parseNet(sn,auth_peer,auth_peer_bits);
245 selectNet(auth_peer,auth_peer_bits); 323 selectNet(auth_peer,auth_peer_bits,FALSE);
246} 324}
247 325
248void Security::applySecurity() 326void Security::applySecurity()
@@ -257,8 +335,18 @@ void Security::applySecurity()
257 int auth_peer_bits; 335 int auth_peer_bits;
258 QString sn = syncnet->currentText(); 336 QString sn = syncnet->currentText();
259 parseNet(sn,auth_peer,auth_peer_bits); 337 parseNet(sn,auth_peer,auth_peer_bits);
338
339 //this is the *selected* (active) net range
260 cfg.writeEntry("auth_peer",auth_peer); 340 cfg.writeEntry("auth_peer",auth_peer);
261 cfg.writeEntry("auth_peer_bits",auth_peer_bits); 341 cfg.writeEntry("auth_peer_bits",auth_peer_bits);
342
343 //write back all other net ranges in *cleartext*
344 for (int i=0; i<10; i++) {
345 QString target;
346 target.sprintf("net%d", i);
347 cfg.writeEntry(target,syncnet->text(i));
348 }
349
262 cfg.writeEntry("syncapp",syncapp->currentText()); 350 cfg.writeEntry("syncapp",syncapp->currentText());
263 351
264 /* 352 /*
diff --git a/core/settings/security/security.h b/core/settings/security/security.h
index b1a3eca..72aa352 100644
--- a/core/settings/security/security.h
+++ b/core/settings/security/security.h
@@ -47,7 +47,9 @@ private slots:
47 void changeLoginName(int); 47 void changeLoginName(int);
48 void toggleAutoLogin(bool); 48 void toggleAutoLogin(bool);
49 void changeSyncApp(); 49 void changeSyncApp();
50 50 void restoreDefaults();
51 void insertDefaultRanges();
52 void deleteListEntry();
51 53
52private: 54private:
53 void loadUsers(void); 55 void loadUsers(void);
@@ -56,7 +58,8 @@ private:
56 void updateGUI(); 58 void updateGUI();
57 59
58 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits); 60 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits);
59 void selectNet(int auth_peer,int auth_peer_bits); 61 void selectNet(int auth_peer,int auth_peer_bits,bool update);
62
60 63
61 QString enterPassCode(const QString&); 64 QString enterPassCode(const QString&);
62 QString passcode; 65 QString passcode;
diff --git a/core/settings/security/securitybase.ui b/core/settings/security/securitybase.ui
index 934111e..1769ae1 100644
--- a/core/settings/security/securitybase.ui
+++ b/core/settings/security/securitybase.ui
@@ -11,7 +11,7 @@
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>321</width> 14 <width>309</width>
15 <height>483</height> 15 <height>483</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
@@ -109,6 +109,12 @@
109 <name>text</name> 109 <name>text</name>
110 <string>Change passcode</string> 110 <string>Change passcode</string>
111 </property> 111 </property>
112 <property>
113 <name>whatsThis</name>
114 <string>This button will let you change the security passcode.
115
116Note: This is *not* the sync password.</string>
117 </property>
112 </widget> 118 </widget>
113 <widget> 119 <widget>
114 <class>QPushButton</class> 120 <class>QPushButton</class>
@@ -120,6 +126,11 @@
120 <name>text</name> 126 <name>text</name>
121 <string>Clear passcode</string> 127 <string>Clear passcode</string>
122 </property> 128 </property>
129 <property>
130 <name>whatsThis</name>
131 <string>Delete the current passcode.
132You can enter a new one at any time.</string>
133 </property>
123 </widget> 134 </widget>
124 </hbox> 135 </hbox>
125 </widget> 136 </widget>
@@ -133,6 +144,10 @@
133 <name>text</name> 144 <name>text</name>
134 <string>Require pass code at power-on</string> 145 <string>Require pass code at power-on</string>
135 </property> 146 </property>
147 <property>
148 <name>whatsThis</name>
149 <string>If you enable this option, a passcode must be entered after every resume event of your Zaurus.</string>
150 </property>
136 </widget> 151 </widget>
137 <widget> 152 <widget>
138 <class>QLabel</class> 153 <class>QLabel</class>
@@ -236,6 +251,12 @@
236 <name>text</name> 251 <name>text</name>
237 <string>Login Automatically</string> 252 <string>Login Automatically</string>
238 </property> 253 </property>
254 <property>
255 <name>whatsThis</name>
256 <string>If you select this option, opie-login will automagically log you in with the user you have selected in the drop-down list.
257
258For the Zaurus 5x00 this is always the user "root".</string>
259 </property>
239 </widget> 260 </widget>
240 <widget> 261 <widget>
241 <class>QComboBox</class> 262 <class>QComboBox</class>
@@ -243,6 +264,13 @@
243 <name>name</name> 264 <name>name</name>
244 <cstring>userlist</cstring> 265 <cstring>userlist</cstring>
245 </property> 266 </property>
267 <property>
268 <name>whatsThis</name>
269 <string>This drop-down list allows you to select the user for auto-login
270(if enabled above).
271
272You can only select an actually configured user.</string>
273 </property>
246 </widget> 274 </widget>
247 </vbox> 275 </vbox>
248 </widget> 276 </widget>
@@ -279,7 +307,7 @@
279 <name>title</name> 307 <name>title</name>
280 <string>Sync</string> 308 <string>Sync</string>
281 </attribute> 309 </attribute>
282 <vbox> 310 <grid>
283 <property stdset="1"> 311 <property stdset="1">
284 <name>margin</name> 312 <name>margin</name>
285 <number>11</number> 313 <number>11</number>
@@ -288,7 +316,28 @@
288 <name>spacing</name> 316 <name>spacing</name>
289 <number>6</number> 317 <number>6</number>
290 </property> 318 </property>
291 <widget> 319 <spacer row="1" column="0" >
320 <property>
321 <name>name</name>
322 <cstring>Spacer1</cstring>
323 </property>
324 <property stdset="1">
325 <name>orientation</name>
326 <enum>Vertical</enum>
327 </property>
328 <property stdset="1">
329 <name>sizeType</name>
330 <enum>Expanding</enum>
331 </property>
332 <property>
333 <name>sizeHint</name>
334 <size>
335 <width>20</width>
336 <height>20</height>
337 </size>
338 </property>
339 </spacer>
340 <widget row="0" column="0" >
292 <class>QGroupBox</class> 341 <class>QGroupBox</class>
293 <property stdset="1"> 342 <property stdset="1">
294 <name>name</name> 343 <name>name</name>
@@ -324,54 +373,6 @@
324 </widget> 373 </widget>
325 <widget> 374 <widget>
326 <class>QComboBox</class> 375 <class>QComboBox</class>
327 <item>
328 <property>
329 <name>text</name>
330 <string>192.168.129.0/24 (default)</string>
331 </property>
332 </item>
333 <item>
334 <property>
335 <name>text</name>
336 <string>192.168.1.0/24</string>
337 </property>
338 </item>
339 <item>
340 <property>
341 <name>text</name>
342 <string>192.168.0.0/16</string>
343 </property>
344 </item>
345 <item>
346 <property>
347 <name>text</name>
348 <string>172.16.0.0/12</string>
349 </property>
350 </item>
351 <item>
352 <property>
353 <name>text</name>
354 <string>10.0.0.0/8</string>
355 </property>
356 </item>
357 <item>
358 <property>
359 <name>text</name>
360 <string>1.0.0.0/8</string>
361 </property>
362 </item>
363 <item>
364 <property>
365 <name>text</name>
366 <string>Any</string>
367 </property>
368 </item>
369 <item>
370 <property>
371 <name>text</name>
372 <string>None</string>
373 </property>
374 </item>
375 <property stdset="1"> 376 <property stdset="1">
376 <name>name</name> 377 <name>name</name>
377 <cstring>syncnet</cstring> 378 <cstring>syncnet</cstring>
@@ -380,6 +381,74 @@
380 <name>editable</name> 381 <name>editable</name>
381 <bool>true</bool> 382 <bool>true</bool>
382 </property> 383 </property>
384 <property>
385 <name>whatsThis</name>
386 <string>Select a net-range or enter a new one.
387
388This drop-down list lets you select a net range which is allowed to connect to your Zaurus.
389
390For example, a net range of 192.168.1.0/24 will allow any machine with an IP between 192.168.1.1 and 192.168.1.254 to connect to (and sync with) your Zaurus.
391
392The entry "All" will allow *any* IP to connect.
393The entry "None" will *deny* any connection.
394
395If unsure, select "Any".</string>
396 </property>
397 </widget>
398 <widget>
399 <class>QLayoutWidget</class>
400 <property stdset="1">
401 <name>name</name>
402 <cstring>Layout4</cstring>
403 </property>
404 <hbox>
405 <property stdset="1">
406 <name>margin</name>
407 <number>0</number>
408 </property>
409 <property stdset="1">
410 <name>spacing</name>
411 <number>6</number>
412 </property>
413 <widget>
414 <class>QPushButton</class>
415 <property stdset="1">
416 <name>name</name>
417 <cstring>deleteentry</cstring>
418 </property>
419 <property stdset="1">
420 <name>text</name>
421 <string>Delete Entry</string>
422 </property>
423 <property>
424 <name>whatsThis</name>
425 <string>Delete the selected net range from the list
426
427If you press this button, the currently selected net range will be deleted from the list of net ranges.
428
429If you hit this button in error, the button "Restore Defaults" will restore
430the list to the state it has been when you initially booted your Zaurus.</string>
431 </property>
432 </widget>
433 <widget>
434 <class>QPushButton</class>
435 <property stdset="1">
436 <name>name</name>
437 <cstring>restoredefaults</cstring>
438 </property>
439 <property stdset="1">
440 <name>text</name>
441 <string>Restore Defaults</string>
442 </property>
443 <property>
444 <name>whatsThis</name>
445 <string>This button will restore the list of net ranges
446to the defaults.
447
448Beware that all manually entered net ranges will be lost!</string>
449 </property>
450 </widget>
451 </hbox>
383 </widget> 452 </widget>
384 <widget> 453 <widget>
385 <class>QLabel</class> 454 <class>QLabel</class>
@@ -410,6 +479,14 @@
410 <name>name</name> 479 <name>name</name>
411 <cstring>syncapp</cstring> 480 <cstring>syncapp</cstring>
412 </property> 481 </property>
482 <property>
483 <name>whatsThis</name>
484 <string>This option changes the login behaviour of the internal FTP server.
485
486If you have problems syncing, try the "IntelliSync" setting, which will accept any password you throw at the sync (FTP) port.
487
488The default is Qtopia. It will let you log in with username "root" and password "Qtopia". The password is CaSeSeNsItIvE.</string>
489 </property>
413 </widget> 490 </widget>
414 <widget> 491 <widget>
415 <class>QComboBox</class> 492 <class>QComboBox</class>
@@ -438,28 +515,7 @@
438 </widget> 515 </widget>
439 </vbox> 516 </vbox>
440 </widget> 517 </widget>
441 <spacer> 518 </grid>
442 <property>
443 <name>name</name>
444 <cstring>Spacer1</cstring>
445 </property>
446 <property stdset="1">
447 <name>orientation</name>
448 <enum>Vertical</enum>
449 </property>
450 <property stdset="1">
451 <name>sizeType</name>
452 <enum>Expanding</enum>
453 </property>
454 <property>
455 <name>sizeHint</name>
456 <size>
457 <width>20</width>
458 <height>20</height>
459 </size>
460 </property>
461 </spacer>
462 </vbox>
463 </widget> 519 </widget>
464 </widget> 520 </widget>
465 </vbox> 521 </vbox>