summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-11-18 18:43:25 (UTC)
committer mickeyl <mickeyl>2003-11-18 18:43:25 (UTC)
commit22966b4e27b5460e005bb47b914264495f3f17bf (patch) (unidiff)
tree28611cac21ec8ede6c9a27e8e238007c5f7b3249
parent6b50f01126f1e22ed1cebef7db2901c7ff33116f (diff)
downloadopie-22966b4e27b5460e005bb47b914264495f3f17bf.zip
opie-22966b4e27b5460e005bb47b914264495f3f17bf.tar.gz
opie-22966b4e27b5460e005bb47b914264495f3f17bf.tar.bz2
Increase sync-friendlyness and repair broken sync with several
programs. Patch by Matthias Hentges <matthias@hentges.net> - thanks!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/transferserver.cpp50
-rw-r--r--core/settings/security/security.cpp41
-rw-r--r--core/settings/security/security.h1
-rw-r--r--core/settings/security/securitybase.ui34
4 files changed, 99 insertions, 27 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index 439e110..eea9f3a 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -1,990 +1,1000 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
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//#define _XOPEN_SOURCE 20//#define _XOPEN_SOURCE
21 21
22#include <qtopia/global.h> 22#include <qtopia/global.h>
23#include <qtopia/qpeapplication.h> 23#include <qtopia/qpeapplication.h>
24 24
25#ifndef Q_OS_WIN32 25#ifndef Q_OS_WIN32
26#include <pwd.h> 26#include <pwd.h>
27#include <sys/types.h> 27#include <sys/types.h>
28#include <unistd.h> 28#include <unistd.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#include <time.h> 30#include <time.h>
31 31
32#ifndef Q_OS_MACX 32#ifndef Q_OS_MACX
33#include <shadow.h> 33#include <shadow.h>
34#include <crypt.h> 34#include <crypt.h>
35#endif /* Q_OS_MACX */ 35#endif /* Q_OS_MACX */
36 36
37#else 37#else
38#include <stdlib.h> 38#include <stdlib.h>
39#include <time.h> 39#include <time.h>
40#endif 40#endif
41 41
42 42
43#if defined(_OS_LINUX_) 43#if defined(_OS_LINUX_)
44#include <shadow.h> 44#include <shadow.h>
45#endif 45#endif
46 46
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qtextstream.h> 49#include <qtextstream.h>
50#include <qdatastream.h> 50#include <qdatastream.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qstringlist.h> 52#include <qstringlist.h>
53#include <qfileinfo.h> 53#include <qfileinfo.h>
54#include <qregexp.h> 54#include <qregexp.h>
55//#include <qtopia/qcopchannel_qws.h> 55//#include <qtopia/qcopchannel_qws.h>
56#include <qtopia/process.h> 56#include <qtopia/process.h>
57#include <qtopia/global.h> 57#include <qtopia/global.h>
58#include <qtopia/config.h> 58#include <qtopia/config.h>
59#include <qtopia/private/contact.h> 59#include <qtopia/private/contact.h>
60#include <qtopia/quuid.h> 60#include <qtopia/quuid.h>
61#include <qtopia/version.h> 61#include <qtopia/version.h>
62#ifdef Q_WS_QWS 62#ifdef Q_WS_QWS
63#include <qtopia/qcopenvelope_qws.h> 63#include <qtopia/qcopenvelope_qws.h>
64#endif 64#endif
65 65
66#include "launcherglobal.h" 66#include "launcherglobal.h"
67 67
68#include "transferserver.h" 68#include "transferserver.h"
69#include <qtopia/qprocess.h> 69#include <qtopia/qprocess.h>
70 70
71const int block_size = 51200; 71const int block_size = 51200;
72 72
73TransferServer::TransferServer( Q_UINT16 port, QObject *parent, 73TransferServer::TransferServer( Q_UINT16 port, QObject *parent,
74 const char* name) 74 const char* name)
75 : QServerSocket( port, 1, parent, name ) 75 : QServerSocket( port, 1, parent, name )
76{ 76{
77 connections.setAutoDelete( TRUE ); 77 connections.setAutoDelete( TRUE );
78 if ( !ok() ) 78 if ( !ok() )
79 qWarning( "Failed to bind to port %d", port ); 79 qWarning( "Failed to bind to port %d", port );
80} 80}
81 81
82void TransferServer::authorizeConnections() 82void TransferServer::authorizeConnections()
83{ 83{
84 QListIterator<ServerPI> it(connections); 84 QListIterator<ServerPI> it(connections);
85 while ( it.current() ) { 85 while ( it.current() ) {
86 if ( !it.current()->verifyAuthorised() ) { 86 if ( !it.current()->verifyAuthorised() ) {
87 disconnect( it.current(), SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) ); 87 disconnect( it.current(), SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) );
88 connections.removeRef( it.current() ); 88 connections.removeRef( it.current() );
89 } else 89 } else
90 ++it; 90 ++it;
91 } 91 }
92} 92}
93 93
94void TransferServer::closed(ServerPI *item) 94void TransferServer::closed(ServerPI *item)
95{ 95{
96 connections.removeRef(item); 96 connections.removeRef(item);
97} 97}
98 98
99TransferServer::~TransferServer() 99TransferServer::~TransferServer()
100{ 100{
101} 101}
102 102
103void TransferServer::newConnection( int socket ) 103void TransferServer::newConnection( int socket )
104{ 104{
105 ServerPI *ptr = new ServerPI( socket, this ); 105 ServerPI *ptr = new ServerPI( socket, this );
106 connect( ptr, SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) ); 106 connect( ptr, SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) );
107 connections.append( ptr ); 107 connections.append( ptr );
108} 108}
109 109
110QString SyncAuthentication::serverId() 110QString SyncAuthentication::serverId()
111{ 111{
112 Config cfg("Security"); 112 Config cfg("Security");
113 cfg.setGroup("Sync"); 113 cfg.setGroup("Sync");
114 QString r = cfg.readEntry("serverid"); 114 QString r = cfg.readEntry("serverid");
115 115
116 if ( r.isEmpty() ) { 116 if ( r.isEmpty() ) {
117 r = Opie::Global::uuid(); 117 r = Opie::Global::uuid();
118 cfg.writeEntry("serverid", r ); 118 cfg.writeEntry("serverid", r );
119 } 119 }
120 return r; 120 return r;
121} 121}
122 122
123QString SyncAuthentication::ownerName() 123QString SyncAuthentication::ownerName()
124{ 124{
125 QString vfilename = Global::applicationFileName("addressbook", 125 QString vfilename = Global::applicationFileName("addressbook",
126 "businesscard.vcf"); 126 "businesscard.vcf");
127 if (QFile::exists(vfilename)) { 127 if (QFile::exists(vfilename)) {
128 Contact c; 128 Contact c;
129 c = Contact::readVCard( vfilename )[0]; 129 c = Contact::readVCard( vfilename )[0];
130 return c.fullName(); 130 return c.fullName();
131 } 131 }
132 132
133 return QString::null; 133 return QString::null;
134} 134}
135 135
136QString SyncAuthentication::loginName() 136QString SyncAuthentication::loginName()
137{ 137{
138 struct passwd *pw = 0L; 138 struct passwd *pw = 0L;
139#ifndef Q_OS_WIN32 139#ifndef Q_OS_WIN32
140 pw = getpwuid( geteuid() ); 140 pw = getpwuid( geteuid() );
141 return QString::fromLocal8Bit( pw->pw_name ); 141 return QString::fromLocal8Bit( pw->pw_name );
142#else 142#else
143 //### revise 143 //### revise
144 return QString(); 144 return QString();
145#endif 145#endif
146} 146}
147 147
148int SyncAuthentication::isAuthorized(QHostAddress peeraddress) 148int SyncAuthentication::isAuthorized(QHostAddress peeraddress)
149{ 149{
150 Config cfg("Security"); 150 Config cfg("Security");
151 cfg.setGroup("Sync"); 151 cfg.setGroup("Sync");
152 // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); 152 // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0");
153 uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); 153 uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100);
154 154
155 // QHostAddress allowed; 155 // QHostAddress allowed;
156 // allowed.setAddress(allowedstr); 156 // allowed.setAddress(allowedstr);
157 // uint auth_peer = allowed.ip4Addr(); 157 // uint auth_peer = allowed.ip4Addr();
158 uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); 158 uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24);
159 uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined 159 uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined
160 ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); 160 ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits));
161 161
162 return (peeraddress.ip4Addr() & mask) == auth_peer; 162 return (peeraddress.ip4Addr() & mask) == auth_peer;
163} 163}
164 164
165bool SyncAuthentication::checkUser( const QString& user ) 165bool SyncAuthentication::checkUser( const QString& user )
166{ 166{
167 if ( user.isEmpty() ) return FALSE; 167 if ( user.isEmpty() ) return FALSE;
168 QString euser = loginName(); 168 QString euser = loginName();
169 return user == euser; 169 return user == euser;
170} 170}
171 171
172bool SyncAuthentication::checkPassword( const QString& password ) 172bool SyncAuthentication::checkPassword( const QString& password )
173{ 173{
174#ifdef ALLOW_UNIX_USER_FTP 174#ifdef ALLOW_UNIX_USER_FTP
175 // First, check system password... 175 // First, check system password...
176 176
177 struct passwd *pw = 0; 177 struct passwd *pw = 0;
178 struct spwd *spw = 0; 178 struct spwd *spw = 0;
179 179
180 pw = getpwuid( geteuid() ); 180 pw = getpwuid( geteuid() );
181 spw = getspnam( pw->pw_name ); 181 spw = getspnam( pw->pw_name );
182 182
183 QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); 183 QString cpwd = QString::fromLocal8Bit( pw->pw_passwd );
184 if ( cpwd == "x" && spw ) 184 if ( cpwd == "x" && spw )
185 cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); 185 cpwd = QString::fromLocal8Bit( spw->sp_pwdp );
186 186
187 // Note: some systems use more than crypt for passwords. 187 // Note: some systems use more than crypt for passwords.
188 QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); 188 QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) );
189 if ( cpwd == cpassword ) 189 if ( cpwd == cpassword )
190 return TRUE; 190 return TRUE;
191#endif 191#endif
192 192
193 static int lastdenial=0; 193 static int lastdenial=0;
194 static int denials=0; 194 static int denials=0;
195 int now = time(0); 195 int now = time(0);
196 196
197 Config cfg("Security");
198 cfg.setGroup("Sync");
199 QString syncapp = cfg.readEntry("syncapp","Qtopia");
200
201 //No password needed if the user really wants it
202 if (syncapp == "IntelliSync") {
203 return TRUE;
204 }
205
197 // Detect old Qtopia Desktop (no password) 206 // Detect old Qtopia Desktop (no password)
198 if ( password.isEmpty() ) { 207 if ( password.isEmpty() ) {
199 if ( denials < 1 || now > lastdenial+600 ) { 208 if ( denials < 3 || now > lastdenial+600 ) {
200 QMessageBox unauth( 209 QMessageBox unauth(
201 tr("Sync Connection"), 210 tr("Sync Connection"),
202 tr("<p>An unauthorized system is requesting access to this device." 211 tr("<p>An unauthorized system is requesting access to this device."
203 "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " 212 "<p>If you are using a version of Qtopia Desktop older than 1.5.1, "
204 "please upgrade."), 213 "please upgrade or change the security setting to use IntelliSync." ),
205 QMessageBox::Warning, 214 QMessageBox::Warning,
206 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 215 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
207 0, QString::null, TRUE, WStyle_StaysOnTop); 216 0, QString::null, TRUE, WStyle_StaysOnTop);
208 unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); 217 unauth.setButtonText(QMessageBox::Cancel, tr("Deny"));
209 unauth.exec(); 218 unauth.exec();
210 219
211 denials++; 220 denials++;
212 lastdenial=now; 221 lastdenial=now;
213 } 222 }
214 return FALSE; 223 return FALSE;
215 } 224
225 }
216 226
217 // Second, check sync password... 227 // Second, check sync password...
218 228
219 static int lock=0; 229 static int lock=0;
220 if ( lock ) return FALSE; 230 if ( lock ) return FALSE;
221 231
222 ++lock; 232 ++lock;
223 233
224 /* 234 /*
225 * we need to support old Sync software and QtopiaDesktop 235 * we need to support old Sync software and QtopiaDesktop
226 */ 236 */
227 if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { 237 if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) {
228 Config cfg( "Security" ); 238 Config cfg( "Security" );
229 cfg.setGroup("Sync"); 239 cfg.setGroup("Sync");
230 QStringList pwds = cfg.readListEntry("Passwords",' '); 240 QStringList pwds = cfg.readListEntry("Passwords",' ');
231 for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) { 241 for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) {
232#ifndef Q_OS_WIN32 242#ifndef Q_OS_WIN32
233 QString cpassword = QString::fromLocal8Bit( 243 QString cpassword = QString::fromLocal8Bit(
234 crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) ); 244 crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) );
235#else 245#else
236 // ### revise 246 // ### revise
237 QString cpassword(""); 247 QString cpassword("");
238#endif 248#endif
239 if ( *it == cpassword ) { 249 if ( *it == cpassword ) {
240 lock--; 250 lock--;
241 return TRUE; 251 return TRUE;
242 } 252 }
243 } 253 }
244 254
245 // Unrecognized system. Be careful... 255 // Unrecognized system. Be careful...
246 QMessageBox unrecbox( 256 QMessageBox unrecbox(
247 tr("Sync Connection"), 257 tr("Sync Connection"),
248 tr("<p>An unrecognized system is requesting access to this device." 258 tr("<p>An unrecognized system is requesting access to this device."
249 "<p>If you have just initiated a Sync for the first time, this is normal."), 259 "<p>If you have just initiated a Sync for the first time, this is normal."),
250 QMessageBox::Warning, 260 QMessageBox::Warning,
251 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, 261 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
252 0, QString::null, TRUE, WStyle_StaysOnTop); 262 0, QString::null, TRUE, WStyle_StaysOnTop);
253 unrecbox.setButtonText(QMessageBox::Cancel, tr("Deny")); 263 unrecbox.setButtonText(QMessageBox::Cancel, tr("Deny"));
254 unrecbox.setButtonText(QMessageBox::Yes, tr("Allow")); 264 unrecbox.setButtonText(QMessageBox::Yes, tr("Allow"));
255 265
256 if ( (denials > 2 && now < lastdenial+600) 266 if ( (denials > 2 && now < lastdenial+600)
257 || unrecbox.exec() != QMessageBox::Yes) 267 || unrecbox.exec() != QMessageBox::Yes)
258 { 268 {
259 denials++; 269 denials++;
260 lastdenial=now; 270 lastdenial=now;
261 lock--; 271 lock--;
262 return FALSE; 272 return FALSE;
263 } else { 273 } else {
264 const char salty[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/."; 274 const char salty[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/.";
265 char salt[2]; 275 char salt[2];
266 salt[0]= salty[rand() % (sizeof(salty)-1)]; 276 salt[0]= salty[rand() % (sizeof(salty)-1)];
267 salt[1]= salty[rand() % (sizeof(salty)-1)]; 277 salt[1]= salty[rand() % (sizeof(salty)-1)];
268#ifndef Q_OS_WIN32 278#ifndef Q_OS_WIN32
269 QString cpassword = QString::fromLocal8Bit( 279 QString cpassword = QString::fromLocal8Bit(
270 crypt( password.mid(8).local8Bit(), salt ) ); 280 crypt( password.mid(8).local8Bit(), salt ) );
271#else 281#else
272 //### revise 282 //### revise
273 QString cpassword(""); 283 QString cpassword("");
274#endif 284#endif
275 denials=0; 285 denials=0;
276 pwds.prepend(cpassword); 286 pwds.prepend(cpassword);
277 cfg.writeEntry("Passwords",pwds,' '); 287 cfg.writeEntry("Passwords",pwds,' ');
278 lock--; 288 lock--;
279 return TRUE; 289 return TRUE;
280 } 290 }
281 } 291 }
282 lock--; 292 lock--;
283 293
284 return FALSE; 294 return FALSE;
285} 295}
286 296
287 297
288ServerPI::ServerPI( int socket, QObject *parent, const char* name ) 298ServerPI::ServerPI( int socket, QObject *parent, const char* name )
289 : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ), 299 : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ),
290 storFileSize(-1) 300 storFileSize(-1)
291{ 301{
292 state = Connected; 302 state = Connected;
293 303
294 setSocket( socket ); 304 setSocket( socket );
295 305
296 peerport = peerPort(); 306 peerport = peerPort();
297 peeraddress = peerAddress(); 307 peeraddress = peerAddress();
298 308
299#ifndef INSECURE 309#ifndef INSECURE
300 if ( !SyncAuthentication::isAuthorized(peeraddress) ) { 310 if ( !SyncAuthentication::isAuthorized(peeraddress) ) {
301 state = Forbidden; 311 state = Forbidden;
302 startTimer( 0 ); 312 startTimer( 0 );
303 } else 313 } else
304#endif 314#endif
305 { 315 {
306 connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); 316 connect( this, SIGNAL( readyRead() ), SLOT( read() ) );
307 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); 317 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
308 318
309 passiv = FALSE; 319 passiv = FALSE;
310 for( int i = 0; i < 4; i++ ) 320 for( int i = 0; i < 4; i++ )
311 wait[i] = FALSE; 321 wait[i] = FALSE;
312 322
313 send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr 323 send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr
314 state = Wait_USER; 324 state = Wait_USER;
315 325
316 dtp = new ServerDTP( this ); 326 dtp = new ServerDTP( this );
317 connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); 327 connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) );
318 connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); 328 connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) );
319 connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); 329 connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) );
320 330
321 331
322 directory = QDir::currentDirPath(); 332 directory = QDir::currentDirPath();
323 333
324 static int p = 1024; 334 static int p = 1024;
325 335
326 while ( !serversocket || !serversocket->ok() ) { 336 while ( !serversocket || !serversocket->ok() ) {
327 delete serversocket; 337 delete serversocket;
328 serversocket = new ServerSocket( ++p, this ); 338 serversocket = new ServerSocket( ++p, this );
329 } 339 }
330 connect( serversocket, SIGNAL( newIncomming( int ) ), 340 connect( serversocket, SIGNAL( newIncomming( int ) ),
331 SLOT( newConnection( int ) ) ); 341 SLOT( newConnection( int ) ) );
332 } 342 }
333} 343}
334 344
335ServerPI::~ServerPI() 345ServerPI::~ServerPI()
336{ 346{
337 close(); 347 close();
338 dtp->close(); 348 dtp->close();
339 delete dtp; 349 delete dtp;
340 delete serversocket; 350 delete serversocket;
341} 351}
342 352
343bool ServerPI::verifyAuthorised() 353bool ServerPI::verifyAuthorised()
344{ 354{
345 if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { 355 if ( !SyncAuthentication::isAuthorized(peerAddress()) ) {
346 state = Forbidden; 356 state = Forbidden;
347 return FALSE; 357 return FALSE;
348 } 358 }
349 return TRUE; 359 return TRUE;
350} 360}
351 361
352void ServerPI::connectionClosed() 362void ServerPI::connectionClosed()
353{ 363{
354 // qDebug( "Debug: Connection closed" ); 364 // qDebug( "Debug: Connection closed" );
355 emit connectionClosed(this); 365 emit connectionClosed(this);
356} 366}
357 367
358void ServerPI::send( const QString& msg ) 368void ServerPI::send( const QString& msg )
359{ 369{
360 QTextStream os( this ); 370 QTextStream os( this );
361 os << msg << endl; 371 os << msg << endl;
362 //qDebug( "Reply: %s", msg.latin1() ); 372 //qDebug( "Reply: %s", msg.latin1() );
363} 373}
364 374
365void ServerPI::read() 375void ServerPI::read()
366{ 376{
367 while ( canReadLine() ) 377 while ( canReadLine() )
368 process( readLine().stripWhiteSpace() ); 378 process( readLine().stripWhiteSpace() );
369} 379}
370 380
371bool ServerPI::checkReadFile( const QString& file ) 381bool ServerPI::checkReadFile( const QString& file )
372{ 382{
373 QString filename; 383 QString filename;
374 384
375 if ( file[0] != "/" ) 385 if ( file[0] != "/" )
376 filename = directory.path() + "/" + file; 386 filename = directory.path() + "/" + file;
377 else 387 else
378 filename = file; 388 filename = file;
379 389
380 QFileInfo fi( filename ); 390 QFileInfo fi( filename );
381 return ( fi.exists() && fi.isReadable() ); 391 return ( fi.exists() && fi.isReadable() );
382} 392}
383 393
384bool ServerPI::checkWriteFile( const QString& file ) 394bool ServerPI::checkWriteFile( const QString& file )
385{ 395{
386 QString filename; 396 QString filename;
387 397
388 if ( file[0] != "/" ) 398 if ( file[0] != "/" )
389 filename = directory.path() + "/" + file; 399 filename = directory.path() + "/" + file;
390 else 400 else
391 filename = file; 401 filename = file;
392 402
393 QFileInfo fi( filename ); 403 QFileInfo fi( filename );
394 404
395 if ( fi.exists() ) 405 if ( fi.exists() )
396 if ( !QFile( filename ).remove() ) 406 if ( !QFile( filename ).remove() )
397 return FALSE; 407 return FALSE;
398 return TRUE; 408 return TRUE;
399} 409}
400 410
401void ServerPI::process( const QString& message ) 411void ServerPI::process( const QString& message )
402{ 412{
403 //qDebug( "Command: %s", message.latin1() ); 413 //qDebug( "Command: %s", message.latin1() );
404 414
405 // split message using "," as separator 415 // split message using "," as separator
406 QStringList msg = QStringList::split( " ", message ); 416 QStringList msg = QStringList::split( " ", message );
407 if ( msg.isEmpty() ) return; 417 if ( msg.isEmpty() ) return;
408 418
409 // command token 419 // command token
410 QString cmd = msg[0].upper(); 420 QString cmd = msg[0].upper();
411 421
412 // argument token 422 // argument token
413 QString arg; 423 QString arg;
414 if ( msg.count() >= 2 ) 424 if ( msg.count() >= 2 )
415 arg = msg[1]; 425 arg = msg[1];
416 426
417 // full argument string 427 // full argument string
418 QString args; 428 QString args;
419 if ( msg.count() >= 2 ) { 429 if ( msg.count() >= 2 ) {
420 QStringList copy( msg ); 430 QStringList copy( msg );
421 // FIXME: for Qt3 431 // FIXME: for Qt3
422 // copy.pop_front() 432 // copy.pop_front()
423 copy.remove( copy.begin() ); 433 copy.remove( copy.begin() );
424 args = copy.join( " " ); 434 args = copy.join( " " );
425 } 435 }
426 436
427 //qDebug( "args: %s", args.latin1() ); 437 //qDebug( "args: %s", args.latin1() );
428 438
429 // we always respond to QUIT, regardless of state 439 // we always respond to QUIT, regardless of state
430 if ( cmd == "QUIT" ) { 440 if ( cmd == "QUIT" ) {
431 send( "211 Good bye!" ); // No tr 441 send( "211 Good bye!" ); // No tr
432 close(); 442 close();
433 return; 443 return;
434 } 444 }
435 445
436 // connected to client 446 // connected to client
437 if ( Connected == state ) 447 if ( Connected == state )
438 return; 448 return;
439 449
440 // waiting for user name 450 // waiting for user name
441 if ( Wait_USER == state ) { 451 if ( Wait_USER == state ) {
442 452
443 if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) { 453 if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) {
444 send( "530 Please login with USER and PASS" ); // No tr 454 send( "530 Please login with USER and PASS" ); // No tr
445 return; 455 return;
446 } 456 }
447 send( "331 User name ok, need password" ); // No tr 457 send( "331 User name ok, need password" ); // No tr
448 state = Wait_PASS; 458 state = Wait_PASS;
449 return; 459 return;
450 } 460 }
451 461
452 // waiting for password 462 // waiting for password
453 if ( Wait_PASS == state ) { 463 if ( Wait_PASS == state ) {
454 464
455 if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) { 465 if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) {
456 send( "530 Please login with USER and PASS" ); // No tr 466 send( "530 Please login with USER and PASS" ); // No tr
457 return; 467 return;
458 } 468 }
459 send( "230 User logged in, proceed" ); // No tr 469 send( "230 User logged in, proceed" ); // No tr
460 state = Ready; 470 state = Ready;
461 return; 471 return;
462 } 472 }
463 473
464 // ACCESS CONTROL COMMANDS 474 // ACCESS CONTROL COMMANDS
465 475
466 // Only an ALLO sent immediately before STOR is valid. 476 // Only an ALLO sent immediately before STOR is valid.
467 if ( cmd != "STOR" ) 477 if ( cmd != "STOR" )
468 storFileSize = -1; 478 storFileSize = -1;
469 479
470 // account (ACCT) 480 // account (ACCT)
471 if ( cmd == "ACCT" ) { 481 if ( cmd == "ACCT" ) {
472 // even wu-ftp does not support it 482 // even wu-ftp does not support it
473 send( "502 Command not implemented" ); // No tr 483 send( "502 Command not implemented" ); // No tr
474 } 484 }
475 485
476 // change working directory (CWD) 486 // change working directory (CWD)
477 else if ( cmd == "CWD" ) { 487 else if ( cmd == "CWD" ) {
478 488
479 if ( !args.isEmpty() ) { 489 if ( !args.isEmpty() ) {
480 if ( directory.cd( args, TRUE ) ) 490 if ( directory.cd( args, TRUE ) )
481 send( "250 Requested file action okay, completed" ); // No tr 491 send( "250 Requested file action okay, completed" ); // No tr
482 else 492 else
483 send( "550 Requested action not taken" ); // No tr 493 send( "550 Requested action not taken" ); // No tr
484 } 494 }
485 else 495 else
486 send( "500 Syntax error, command unrecognized" ); // No tr 496 send( "500 Syntax error, command unrecognized" ); // No tr
487 } 497 }
488 498
489 // change to parent directory (CDUP) 499 // change to parent directory (CDUP)
490 else if ( cmd == "CDUP" ) { 500 else if ( cmd == "CDUP" ) {
491 if ( directory.cdUp() ) 501 if ( directory.cdUp() )
492 send( "250 Requested file action okay, completed" ); // No tr 502 send( "250 Requested file action okay, completed" ); // No tr
493 else 503 else
494 send( "550 Requested action not taken" ); // No tr 504 send( "550 Requested action not taken" ); // No tr
495 } 505 }
496 506
497 // structure mount (SMNT) 507 // structure mount (SMNT)
498 else if ( cmd == "SMNT" ) { 508 else if ( cmd == "SMNT" ) {
499 // even wu-ftp does not support it 509 // even wu-ftp does not support it
500 send( "502 Command not implemented" ); // No tr 510 send( "502 Command not implemented" ); // No tr
501 } 511 }
502 512
503 // reinitialize (REIN) 513 // reinitialize (REIN)
504 else if ( cmd == "REIN" ) { 514 else if ( cmd == "REIN" ) {
505 // even wu-ftp does not support it 515 // even wu-ftp does not support it
506 send( "502 Command not implemented" ); // No tr 516 send( "502 Command not implemented" ); // No tr
507 } 517 }
508 518
509 519
510 // TRANSFER PARAMETER COMMANDS 520 // TRANSFER PARAMETER COMMANDS
511 521
512 522
513 // data port (PORT) 523 // data port (PORT)
514 else if ( cmd == "PORT" ) { 524 else if ( cmd == "PORT" ) {
515 if ( parsePort( arg ) ) 525 if ( parsePort( arg ) )
516 send( "200 Command okay" ); // No tr 526 send( "200 Command okay" ); // No tr
517 else 527 else
518 send( "500 Syntax error, command unrecognized" ); // No tr 528 send( "500 Syntax error, command unrecognized" ); // No tr
519 } 529 }
520 530
521 // passive (PASV) 531 // passive (PASV)
522 else if ( cmd == "PASV" ) { 532 else if ( cmd == "PASV" ) {
523 passiv = TRUE; 533 passiv = TRUE;
524 send( "227 Entering Passive Mode (" // No tr 534 send( "227 Entering Passive Mode (" // No tr
525 + address().toString().replace( QRegExp( "\\." ), "," ) + "," 535 + address().toString().replace( QRegExp( "\\." ), "," ) + ","
526 + QString::number( ( serversocket->port() ) >> 8 ) + "," 536 + QString::number( ( serversocket->port() ) >> 8 ) + ","
527 + QString::number( ( serversocket->port() ) & 0xFF ) +")" ); 537 + QString::number( ( serversocket->port() ) & 0xFF ) +")" );
528 } 538 }
529 539
530 // representation type (TYPE) 540 // representation type (TYPE)
531 else if ( cmd == "TYPE" ) { 541 else if ( cmd == "TYPE" ) {
532 if ( arg.upper() == "A" || arg.upper() == "I" ) 542 if ( arg.upper() == "A" || arg.upper() == "I" )
533 send( "200 Command okay" ); // No tr 543 send( "200 Command okay" ); // No tr
534 else 544 else
535 send( "504 Command not implemented for that parameter" ); // No tr 545 send( "504 Command not implemented for that parameter" ); // No tr
536 } 546 }
537 547
538 // file structure (STRU) 548 // file structure (STRU)
539 else if ( cmd == "STRU" ) { 549 else if ( cmd == "STRU" ) {
540 if ( arg.upper() == "F" ) 550 if ( arg.upper() == "F" )
541 send( "200 Command okay" ); // No tr 551 send( "200 Command okay" ); // No tr
542 else 552 else
543 send( "504 Command not implemented for that parameter" ); // No tr 553 send( "504 Command not implemented for that parameter" ); // No tr
544 } 554 }
545 555
546 // transfer mode (MODE) 556 // transfer mode (MODE)
547 else if ( cmd == "MODE" ) { 557 else if ( cmd == "MODE" ) {
548 if ( arg.upper() == "S" ) 558 if ( arg.upper() == "S" )
549 send( "200 Command okay" ); // No tr 559 send( "200 Command okay" ); // No tr
550 else 560 else
551 send( "504 Command not implemented for that parameter" ); // No tr 561 send( "504 Command not implemented for that parameter" ); // No tr
552 } 562 }
553 563
554 564
555 // FTP SERVICE COMMANDS 565 // FTP SERVICE COMMANDS
556 566
557 567
558 // retrieve (RETR) 568 // retrieve (RETR)
559 else if ( cmd == "RETR" ) 569 else if ( cmd == "RETR" )
560 if ( !args.isEmpty() && checkReadFile( absFilePath( args ) ) 570 if ( !args.isEmpty() && checkReadFile( absFilePath( args ) )
561 || backupRestoreGzip( absFilePath( args ) ) ) { 571 || backupRestoreGzip( absFilePath( args ) ) ) {
562 send( "150 File status okay" ); // No tr 572 send( "150 File status okay" ); // No tr
563 sendFile( absFilePath( args ) ); 573 sendFile( absFilePath( args ) );
564 } 574 }
565 else { 575 else {
566 qDebug("550 Requested action not taken"); 576 qDebug("550 Requested action not taken");
567 send( "550 Requested action not taken" ); // No tr 577 send( "550 Requested action not taken" ); // No tr
568 } 578 }
569 579
570 // store (STOR) 580 // store (STOR)
571 else if ( cmd == "STOR" ) 581 else if ( cmd == "STOR" )
572 if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) { 582 if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) {
573 send( "150 File status okay" ); // No tr 583 send( "150 File status okay" ); // No tr
574 retrieveFile( absFilePath( args ) ); 584 retrieveFile( absFilePath( args ) );
575 } 585 }
576 else 586 else
577 send( "550 Requested action not taken" ); // No tr 587 send( "550 Requested action not taken" ); // No tr
578 588
579 // store unique (STOU) 589 // store unique (STOU)
580 else if ( cmd == "STOU" ) { 590 else if ( cmd == "STOU" ) {
581 send( "502 Command not implemented" ); // No tr 591 send( "502 Command not implemented" ); // No tr
582 } 592 }
583 593
584 // append (APPE) 594 // append (APPE)
585 else if ( cmd == "APPE" ) { 595 else if ( cmd == "APPE" ) {
586 send( "502 Command not implemented" ); // No tr 596 send( "502 Command not implemented" ); // No tr
587 } 597 }
588 598
589 // allocate (ALLO) 599 // allocate (ALLO)
590 else if ( cmd == "ALLO" ) { 600 else if ( cmd == "ALLO" ) {
591 storFileSize = args.toInt(); 601 storFileSize = args.toInt();
592 send( "200 Command okay" ); // No tr 602 send( "200 Command okay" ); // No tr
593 } 603 }
594 604
595 // restart (REST) 605 // restart (REST)
596 else if ( cmd == "REST" ) { 606 else if ( cmd == "REST" ) {
597 send( "502 Command not implemented" ); // No tr 607 send( "502 Command not implemented" ); // No tr
598 } 608 }
599 609
600 // rename from (RNFR) 610 // rename from (RNFR)
601 else if ( cmd == "RNFR" ) { 611 else if ( cmd == "RNFR" ) {
602 renameFrom = QString::null; 612 renameFrom = QString::null;
603 if ( args.isEmpty() ) 613 if ( args.isEmpty() )
604 send( "500 Syntax error, command unrecognized" ); // No tr 614 send( "500 Syntax error, command unrecognized" ); // No tr
605 else { 615 else {
606 QFile file( absFilePath( args ) ); 616 QFile file( absFilePath( args ) );
607 if ( file.exists() ) { 617 if ( file.exists() ) {
608 send( "350 File exists, ready for destination name" ); // No tr 618 send( "350 File exists, ready for destination name" ); // No tr
609 renameFrom = absFilePath( args ); 619 renameFrom = absFilePath( args );
610 } 620 }
611 else 621 else
612 send( "550 Requested action not taken" ); // No tr 622 send( "550 Requested action not taken" ); // No tr
613 } 623 }
614 } 624 }
615 625
616 // rename to (RNTO) 626 // rename to (RNTO)
617 else if ( cmd == "RNTO" ) { 627 else if ( cmd == "RNTO" ) {
618 if ( lastCommand != "RNFR" ) 628 if ( lastCommand != "RNFR" )
619 send( "503 Bad sequence of commands" ); // No tr 629 send( "503 Bad sequence of commands" ); // No tr
620 else if ( args.isEmpty() ) 630 else if ( args.isEmpty() )
621 send( "500 Syntax error, command unrecognized" ); // No tr 631 send( "500 Syntax error, command unrecognized" ); // No tr
622 else { 632 else {
623 QDir dir( absFilePath( args ) ); 633 QDir dir( absFilePath( args ) );
624 if ( dir.rename( renameFrom, absFilePath( args ), TRUE ) ) 634 if ( dir.rename( renameFrom, absFilePath( args ), TRUE ) )
625 send( "250 Requested file action okay, completed." ); // No tr 635 send( "250 Requested file action okay, completed." ); // No tr
626 else 636 else
627 send( "550 Requested action not taken" ); // No tr 637 send( "550 Requested action not taken" ); // No tr
628 } 638 }
629 } 639 }
630 640
631 // abort (ABOR) 641 // abort (ABOR)
632 else if ( cmd.contains( "ABOR" ) ) { 642 else if ( cmd.contains( "ABOR" ) ) {
633 dtp->close(); 643 dtp->close();
634 if ( dtp->dtpMode() != ServerDTP::Idle ) 644 if ( dtp->dtpMode() != ServerDTP::Idle )
635 send( "426 Connection closed; transfer aborted" ); // No tr 645 send( "426 Connection closed; transfer aborted" ); // No tr
636 else 646 else
637 send( "226 Closing data connection" ); // No tr 647 send( "226 Closing data connection" ); // No tr
638 } 648 }
639 649
640 // delete (DELE) 650 // delete (DELE)
641 else if ( cmd == "DELE" ) { 651 else if ( cmd == "DELE" ) {
642 if ( args.isEmpty() ) 652 if ( args.isEmpty() )
643 send( "500 Syntax error, command unrecognized" ); // No tr 653 send( "500 Syntax error, command unrecognized" ); // No tr
644 else { 654 else {
645 QFile file( absFilePath( args ) ) ; 655 QFile file( absFilePath( args ) ) ;
646 if ( file.remove() ) { 656 if ( file.remove() ) {
647 send( "250 Requested file action okay, completed" ); // No tr 657 send( "250 Requested file action okay, completed" ); // No tr
648 QCopEnvelope e("QPE/System", "linkChanged(QString)" ); 658 QCopEnvelope e("QPE/System", "linkChanged(QString)" );
649 e << file.name(); 659 e << file.name();
650 } else { 660 } else {
651 send( "550 Requested action not taken" ); // No tr 661 send( "550 Requested action not taken" ); // No tr
652 } 662 }
653 } 663 }
654 } 664 }
655 665
656 // remove directory (RMD) 666 // remove directory (RMD)
657 else if ( cmd == "RMD" ) { 667 else if ( cmd == "RMD" ) {
658 if ( args.isEmpty() ) 668 if ( args.isEmpty() )
659 send( "500 Syntax error, command unrecognized" ); // No tr 669 send( "500 Syntax error, command unrecognized" ); // No tr
660 else { 670 else {
661 QDir dir; 671 QDir dir;
662 if ( dir.rmdir( absFilePath( args ), TRUE ) ) 672 if ( dir.rmdir( absFilePath( args ), TRUE ) )
663 send( "250 Requested file action okay, completed" ); // No tr 673 send( "250 Requested file action okay, completed" ); // No tr
664 else 674 else
665 send( "550 Requested action not taken" ); // No tr 675 send( "550 Requested action not taken" ); // No tr
666 } 676 }
667 } 677 }
668 678
669 // make directory (MKD) 679 // make directory (MKD)
670 else if ( cmd == "MKD" ) { 680 else if ( cmd == "MKD" ) {
671 if ( args.isEmpty() ) { 681 if ( args.isEmpty() ) {
672 qDebug(" Error: no arg"); 682 qDebug(" Error: no arg");
673 send( "500 Syntax error, command unrecognized" ); // No tr 683 send( "500 Syntax error, command unrecognized" ); // No tr
674 } 684 }
675 else { 685 else {
676 QDir dir; 686 QDir dir;
677 if ( dir.mkdir( absFilePath( args ), TRUE ) ) 687 if ( dir.mkdir( absFilePath( args ), TRUE ) )
678 send( "250 Requested file action okay, completed." ); // No tr 688 send( "250 Requested file action okay, completed." ); // No tr
679 else 689 else
680 send( "550 Requested action not taken" ); // No tr 690 send( "550 Requested action not taken" ); // No tr
681 } 691 }
682 } 692 }
683 693
684 // print working directory (PWD) 694 // print working directory (PWD)
685 else if ( cmd == "PWD" ) { 695 else if ( cmd == "PWD" ) {
686 send( "257 \"" + directory.path() +"\"" ); 696 send( "257 \"" + directory.path() +"\"" );
687 } 697 }
688 698
689 // list (LIST) 699 // list (LIST)
690 else if ( cmd == "LIST" ) { 700 else if ( cmd == "LIST" ) {
691 if ( sendList( absFilePath( args ) ) ) 701 if ( sendList( absFilePath( args ) ) )
692 send( "150 File status okay" ); // No tr 702 send( "150 File status okay" ); // No tr
693 else 703 else
694 send( "500 Syntax error, command unrecognized" ); // No tr 704 send( "500 Syntax error, command unrecognized" ); // No tr
695 } 705 }
696 706
697 // size (SIZE) 707 // size (SIZE)
698 else if ( cmd == "SIZE" ) { 708 else if ( cmd == "SIZE" ) {
699 QString filePath = absFilePath( args ); 709 QString filePath = absFilePath( args );
700 QFileInfo fi( filePath ); 710 QFileInfo fi( filePath );
701 bool gzipfile = backupRestoreGzip( filePath ); 711 bool gzipfile = backupRestoreGzip( filePath );
702 if ( !fi.exists() && !gzipfile ) 712 if ( !fi.exists() && !gzipfile )
703 send( "500 Syntax error, command unrecognized" ); // No tr 713 send( "500 Syntax error, command unrecognized" ); // No tr
704 else { 714 else {
705 if ( !gzipfile ) 715 if ( !gzipfile )
706 send( "213 " + QString::number( fi.size() ) ); 716 send( "213 " + QString::number( fi.size() ) );
707 else { 717 else {
708 Process duproc( QString("du") ); 718 Process duproc( QString("du") );
709 duproc.addArgument("-s"); 719 duproc.addArgument("-s");
710 QString in, out; 720 QString in, out;
711 if ( !duproc.exec(in, out) ) { 721 if ( !duproc.exec(in, out) ) {
712 qDebug("du process failed; just sending back 1K"); 722 qDebug("du process failed; just sending back 1K");
713 send( "213 1024"); 723 send( "213 1024");
714 } 724 }
715 else { 725 else {
716 QString size = out.left( out.find("\t") ); 726 QString size = out.left( out.find("\t") );
717 int guess = size.toInt()/5; 727 int guess = size.toInt()/5;
718 if ( filePath.contains("doc") ) // No tr 728 if ( filePath.contains("doc") ) // No tr
719 guess *= 1000; 729 guess *= 1000;
720 qDebug("sending back gzip guess of %d", guess); 730 qDebug("sending back gzip guess of %d", guess);
721 send( "213 " + QString::number(guess) ); 731 send( "213 " + QString::number(guess) );
722 } 732 }
723 } 733 }
724 } 734 }
725 } 735 }
726 // name list (NLST) 736 // name list (NLST)
727 else if ( cmd == "NLST" ) { 737 else if ( cmd == "NLST" ) {
728 send( "502 Command not implemented" ); // No tr 738 send( "502 Command not implemented" ); // No tr
729 } 739 }
730 740
731 // site parameters (SITE) 741 // site parameters (SITE)
732 else if ( cmd == "SITE" ) { 742 else if ( cmd == "SITE" ) {
733 send( "502 Command not implemented" ); // No tr 743 send( "502 Command not implemented" ); // No tr
734 } 744 }
735 745
736 // system (SYST) 746 // system (SYST)
737 else if ( cmd == "SYST" ) { 747 else if ( cmd == "SYST" ) {
738 send( "215 UNIX Type: L8" ); // No tr 748 send( "215 UNIX Type: L8" ); // No tr
739 } 749 }
740 750
741 // status (STAT) 751 // status (STAT)
742 else if ( cmd == "STAT" ) { 752 else if ( cmd == "STAT" ) {
743 send( "502 Command not implemented" ); // No tr 753 send( "502 Command not implemented" ); // No tr
744 } 754 }
745 755
746 // help (HELP ) 756 // help (HELP )
747 else if ( cmd == "HELP" ) { 757 else if ( cmd == "HELP" ) {
748 send( "502 Command not implemented" ); // No tr 758 send( "502 Command not implemented" ); // No tr
749 } 759 }
750 760
751 // noop (NOOP) 761 // noop (NOOP)
752 else if ( cmd == "NOOP" ) { 762 else if ( cmd == "NOOP" ) {
753 send( "200 Command okay" ); // No tr 763 send( "200 Command okay" ); // No tr
754 } 764 }
755 765
756 // not implemented 766 // not implemented
757 else 767 else
758 send( "502 Command not implemented" ); // No tr 768 send( "502 Command not implemented" ); // No tr
759 769
760 lastCommand = cmd; 770 lastCommand = cmd;
761} 771}
762 772
763bool ServerPI::backupRestoreGzip( const QString &file ) 773bool ServerPI::backupRestoreGzip( const QString &file )
764{ 774{
765 return (file.find( "backup" ) != -1 && // No tr 775 return (file.find( "backup" ) != -1 && // No tr
766 file.findRev( ".tgz" ) == (int)file.length()-4 ); 776 file.findRev( ".tgz" ) == (int)file.length()-4 );
767} 777}
768 778
769bool ServerPI::backupRestoreGzip( const QString &file, QStringList &targets ) 779bool ServerPI::backupRestoreGzip( const QString &file, QStringList &targets )
770{ 780{
771 if ( file.find( "backup" ) != -1 && // No tr 781 if ( file.find( "backup" ) != -1 && // No tr
772 file.findRev( ".tgz" ) == (int)file.length()-4 ) { 782 file.findRev( ".tgz" ) == (int)file.length()-4 ) {
773 QFileInfo info( file ); 783 QFileInfo info( file );
774 targets = info.dirPath( TRUE ); 784 targets = info.dirPath( TRUE );
775 qDebug("ServerPI::backupRestoreGzip for %s = %s", file.latin1(), 785 qDebug("ServerPI::backupRestoreGzip for %s = %s", file.latin1(),
776 targets.join(" ").latin1() ); 786 targets.join(" ").latin1() );
777 return true; 787 return true;
778 } 788 }
779 return false; 789 return false;
780} 790}
781 791
782void ServerPI::sendFile( const QString& file ) 792void ServerPI::sendFile( const QString& file )
783{ 793{
784 if ( passiv ) { 794 if ( passiv ) {
785 wait[SendFile] = TRUE; 795 wait[SendFile] = TRUE;
786 waitfile = file; 796 waitfile = file;
787 if ( waitsocket ) 797 if ( waitsocket )
788 newConnection( waitsocket ); 798 newConnection( waitsocket );
789 } 799 }
790 else { 800 else {
791 QStringList targets; 801 QStringList targets;
792 if ( backupRestoreGzip( file, targets ) ) 802 if ( backupRestoreGzip( file, targets ) )
793 dtp->sendGzipFile( file, targets, peeraddress, peerport ); 803 dtp->sendGzipFile( file, targets, peeraddress, peerport );
794 else dtp->sendFile( file, peeraddress, peerport ); 804 else dtp->sendFile( file, peeraddress, peerport );
795 } 805 }
796} 806}
797 807
798void ServerPI::retrieveFile( const QString& file ) 808void ServerPI::retrieveFile( const QString& file )
799{ 809{
800 if ( passiv ) { 810 if ( passiv ) {
801 wait[RetrieveFile] = TRUE; 811 wait[RetrieveFile] = TRUE;
802 waitfile = file; 812 waitfile = file;
803 if ( waitsocket ) 813 if ( waitsocket )
804 newConnection( waitsocket ); 814 newConnection( waitsocket );
805 } 815 }
806 else { 816 else {
807 QStringList targets; 817 QStringList targets;
808 if ( backupRestoreGzip( file, targets ) ) 818 if ( backupRestoreGzip( file, targets ) )
809 dtp->retrieveGzipFile( file, peeraddress, peerport ); 819 dtp->retrieveGzipFile( file, peeraddress, peerport );
810 else 820 else
811 dtp->retrieveFile( file, peeraddress, peerport, storFileSize ); 821 dtp->retrieveFile( file, peeraddress, peerport, storFileSize );
812 } 822 }
813} 823}
814 824
815bool ServerPI::parsePort( const QString& pp ) 825bool ServerPI::parsePort( const QString& pp )
816{ 826{
817 QStringList p = QStringList::split( ",", pp ); 827 QStringList p = QStringList::split( ",", pp );
818 if ( p.count() != 6 ) return FALSE; 828 if ( p.count() != 6 ) return FALSE;
819 829
820 // h1,h2,h3,h4,p1,p2 830 // h1,h2,h3,h4,p1,p2
821 peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) + 831 peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) +
822 ( p[2].toInt() << 8 ) + p[3].toInt() ); 832 ( p[2].toInt() << 8 ) + p[3].toInt() );
823 peerport = ( p[4].toInt() << 8 ) + p[5].toInt(); 833 peerport = ( p[4].toInt() << 8 ) + p[5].toInt();
824 return TRUE; 834 return TRUE;
825} 835}
826 836
827void ServerPI::dtpCompleted() 837void ServerPI::dtpCompleted()
828{ 838{
829 send( "226 Closing data connection, file transfer successful" ); // No tr 839 send( "226 Closing data connection, file transfer successful" ); // No tr
830 if ( dtp->dtpMode() == ServerDTP::RetrieveFile ) { 840 if ( dtp->dtpMode() == ServerDTP::RetrieveFile ) {
831 QString fn = dtp->fileName(); 841 QString fn = dtp->fileName();
832 if ( fn.right(8)==".desktop" && fn.find("/Documents/")>=0 ) { 842 if ( fn.right(8)==".desktop" && fn.find("/Documents/")>=0 ) {
833 QCopEnvelope e("QPE/System", "linkChanged(QString)" ); 843 QCopEnvelope e("QPE/System", "linkChanged(QString)" );
834 e << fn; 844 e << fn;
835 } 845 }
836 } 846 }
837 waitsocket = 0; 847 waitsocket = 0;
838 dtp->close(); 848 dtp->close();
839 storFileSize = -1; 849 storFileSize = -1;
840} 850}
841 851
842void ServerPI::dtpFailed() 852void ServerPI::dtpFailed()
843{ 853{
844 dtp->close(); 854 dtp->close();
845 waitsocket = 0; 855 waitsocket = 0;
846 send( "451 Requested action aborted: local error in processing" ); // No tr 856 send( "451 Requested action aborted: local error in processing" ); // No tr
847 storFileSize = -1; 857 storFileSize = -1;
848} 858}
849 859
850void ServerPI::dtpError( int ) 860void ServerPI::dtpError( int )
851{ 861{
852 dtp->close(); 862 dtp->close();
853 waitsocket = 0; 863 waitsocket = 0;
854 send( "451 Requested action aborted: local error in processing" ); // No tr 864 send( "451 Requested action aborted: local error in processing" ); // No tr
855 storFileSize = -1; 865 storFileSize = -1;
856} 866}
857 867
858bool ServerPI::sendList( const QString& arg ) 868bool ServerPI::sendList( const QString& arg )
859{ 869{
860 QByteArray listing; 870 QByteArray listing;
861 QBuffer buffer( listing ); 871 QBuffer buffer( listing );
862 872
863 if ( !buffer.open( IO_WriteOnly ) ) 873 if ( !buffer.open( IO_WriteOnly ) )
864 return FALSE; 874 return FALSE;
865 875
866 QTextStream ts( &buffer ); 876 QTextStream ts( &buffer );
867 QString fn = arg; 877 QString fn = arg;
868 878
869 if ( fn.isEmpty() ) 879 if ( fn.isEmpty() )
870 fn = directory.path(); 880 fn = directory.path();
871 881
872 QFileInfo fi( fn ); 882 QFileInfo fi( fn );
873 if ( !fi.exists() ) return FALSE; 883 if ( !fi.exists() ) return FALSE;
874 884
875 // return file listing 885 // return file listing
876 if ( fi.isFile() ) { 886 if ( fi.isFile() ) {
877 ts << fileListing( &fi ) << endl; 887 ts << fileListing( &fi ) << endl;
878 } 888 }
879 889
880 // return directory listing 890 // return directory listing
881 else if ( fi.isDir() ) { 891 else if ( fi.isDir() ) {
882 QDir dir( fn ); 892 QDir dir( fn );
883 const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden ); 893 const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden );
884 894
885 QFileInfoListIterator it( *list ); 895 QFileInfoListIterator it( *list );
886 QFileInfo *info; 896 QFileInfo *info;
887 897
888 unsigned long total = 0; 898 unsigned long total = 0;
889 while ( ( info = it.current() ) ) { 899 while ( ( info = it.current() ) ) {
890 if ( info->fileName() != "." && info->fileName() != ".." ) 900 if ( info->fileName() != "." && info->fileName() != ".." )
891 total += info->size(); 901 total += info->size();
892 ++it; 902 ++it;
893 } 903 }
894 904
895 ts << "total " << QString::number( total / 1024 ) << endl; // No tr 905 ts << "total " << QString::number( total / 1024 ) << endl; // No tr
896 906
897 it.toFirst(); 907 it.toFirst();
898 while ( ( info = it.current() ) ) { 908 while ( ( info = it.current() ) ) {
899 if ( info->fileName() == "." || info->fileName() == ".." ) { 909 if ( info->fileName() == "." || info->fileName() == ".." ) {
900 ++it; 910 ++it;
901 continue; 911 continue;
902 } 912 }
903 ts << fileListing( info ) << endl; 913 ts << fileListing( info ) << endl;
904 ++it; 914 ++it;
905 } 915 }
906 } 916 }
907 917
908 if ( passiv ) { 918 if ( passiv ) {
909 waitarray = buffer.buffer(); 919 waitarray = buffer.buffer();
910 wait[SendByteArray] = TRUE; 920 wait[SendByteArray] = TRUE;
911 if ( waitsocket ) 921 if ( waitsocket )
912 newConnection( waitsocket ); 922 newConnection( waitsocket );
913 } 923 }
914 else 924 else
915 dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); 925 dtp->sendByteArray( buffer.buffer(), peeraddress, peerport );
916 return TRUE; 926 return TRUE;
917} 927}
918 928
919QString ServerPI::fileListing( QFileInfo *info ) 929QString ServerPI::fileListing( QFileInfo *info )
920{ 930{
921 if ( !info ) return QString::null; 931 if ( !info ) return QString::null;
922 QString s; 932 QString s;
923 933
924 // type char 934 // type char
925 if ( info->isDir() ) 935 if ( info->isDir() )
926 s += "d"; 936 s += "d";
927 else if ( info->isSymLink() ) 937 else if ( info->isSymLink() )
928 s += "l"; 938 s += "l";
929 else 939 else
930 s += "-"; 940 s += "-";
931 941
932 // permisson string 942 // permisson string
933 s += permissionString( info ) + " "; 943 s += permissionString( info ) + " ";
934 944
935 // number of hardlinks 945 // number of hardlinks
936 int subdirs = 1; 946 int subdirs = 1;
937 947
938 if ( info->isDir() ) 948 if ( info->isDir() )
939 subdirs = 2; 949 subdirs = 2;
940 // FIXME : this is to slow 950 // FIXME : this is to slow
941 //if ( info->isDir() ) 951 //if ( info->isDir() )
942 //subdirs = QDir( info->absFilePath() ).entryList( QDir::Dirs ).count(); 952 //subdirs = QDir( info->absFilePath() ).entryList( QDir::Dirs ).count();
943 953
944 s += QString::number( subdirs ).rightJustify( 3, ' ', TRUE ) + " "; 954 s += QString::number( subdirs ).rightJustify( 3, ' ', TRUE ) + " ";
945 955
946 // owner 956 // owner
947 QString o = info->owner(); 957 QString o = info->owner();
948 if ( o.isEmpty() ) 958 if ( o.isEmpty() )
949 o = QString::number(info->ownerId()); 959 o = QString::number(info->ownerId());
950 s += o.leftJustify( 8, ' ', TRUE ) + " "; 960 s += o.leftJustify( 8, ' ', TRUE ) + " ";
951 961
952 // group 962 // group
953 QString g = info->group(); 963 QString g = info->group();
954 if ( g.isEmpty() ) 964 if ( g.isEmpty() )
955 g = QString::number(info->groupId()); 965 g = QString::number(info->groupId());
956 s += g.leftJustify( 8, ' ', TRUE ) + " "; 966 s += g.leftJustify( 8, ' ', TRUE ) + " ";
957 967
958 // file size in bytes 968 // file size in bytes
959 s += QString::number( info->size() ).rightJustify( 9, ' ', TRUE ) + " "; 969 s += QString::number( info->size() ).rightJustify( 9, ' ', TRUE ) + " ";
960 970
961 // last modified date 971 // last modified date
962 QDate date = info->lastModified().date(); 972 QDate date = info->lastModified().date();
963 QTime time = info->lastModified().time(); 973 QTime time = info->lastModified().time();
964 s += date.monthName( date.month() ) + " " 974 s += date.monthName( date.month() ) + " "
965 + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " 975 + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " "
966 + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" 976 + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":"
967 + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " "; 977 + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " ";
968 978
969 // file name 979 // file name
970 s += info->fileName(); 980 s += info->fileName();
971 981
972 return s; 982 return s;
973} 983}
974 984
975QString ServerPI::permissionString( QFileInfo *info ) 985QString ServerPI::permissionString( QFileInfo *info )
976{ 986{
977 if ( !info ) return QString( "---------" ); 987 if ( !info ) return QString( "---------" );
978 QString s; 988 QString s;
979 989
980 // user 990 // user
981 if ( info->permission( QFileInfo::ReadUser ) ) s += "r"; 991 if ( info->permission( QFileInfo::ReadUser ) ) s += "r";
982 else s += "-"; 992 else s += "-";
983 if ( info->permission( QFileInfo::WriteUser ) ) s += "w"; 993 if ( info->permission( QFileInfo::WriteUser ) ) s += "w";
984 else s += "-"; 994 else s += "-";
985 if ( info->permission( QFileInfo::ExeUser ) ) s += "x"; 995 if ( info->permission( QFileInfo::ExeUser ) ) s += "x";
986 else s += "-"; 996 else s += "-";
987 997
988 // group 998 // group
989 if ( info->permission( QFileInfo::ReadGroup ) ) s += "r"; 999 if ( info->permission( QFileInfo::ReadGroup ) ) s += "r";
990 else s += "-"; 1000 else s += "-";
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
@@ -1,320 +1,351 @@
1/********************************************************************** 1/**********************************************************************
2 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3 ** 3 **
4 ** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5 ** 5 **
6 ** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file. 9 ** packaging of this file.
10 ** 10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ** 13 **
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#include <qpe/qcopenvelope_qws.h>
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()));
84 94 connect(syncapp,SIGNAL(activated(int)), this, SLOT(changeSyncApp()));
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
92Security::~Security() 103Security::~Security()
93{ 104{
94} 105}
95 106
96 107
97void Security::updateGUI() 108void 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
112void Security::show() 122void 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 }
133 } 143 }
134 setEnabled(TRUE); 144 setEnabled(TRUE);
135 valid=TRUE; 145 valid=TRUE;
136} 146}
137 147
138void Security::accept() 148void Security::accept()
139{ 149{
140 applySecurity(); 150 applySecurity();
141 QDialog::accept(); 151 QDialog::accept();
142 QCopEnvelope env("QPE/System", "securityChanged()" ); 152 QCopEnvelope env("QPE/System", "securityChanged()" );
143} 153}
144 154
145void Security::done(int r) 155void Security::done(int r)
146{ 156{
147 QDialog::done(r); 157 QDialog::done(r);
148 close(); 158 close();
149} 159}
150 160
151void Security::selectNet(int auth_peer,int auth_peer_bits) 161void Security::selectNet(int auth_peer,int auth_peer_bits)
152{ 162{
153 QString sn; 163 QString sn;
154 if ( auth_peer_bits == 0 && auth_peer == 0 ) { 164 if ( auth_peer_bits == 0 && auth_peer == 0 ) {
155 sn = tr("Any"); 165 sn = tr("Any");
156 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { 166 } else if ( auth_peer_bits == 32 && auth_peer == 0 ) {
157 sn = tr("None"); 167 sn = tr("None");
158 } else { 168 } else {
159 sn = 169 sn =
160 QString::number((auth_peer>>24)&0xff) + "." 170 QString::number((auth_peer>>24)&0xff) + "."
161 + QString::number((auth_peer>>16)&0xff) + "." 171 + QString::number((auth_peer>>16)&0xff) + "."
162 + QString::number((auth_peer>>8)&0xff) + "." 172 + QString::number((auth_peer>>8)&0xff) + "."
163 + QString::number((auth_peer>>0)&0xff) + "/" 173 + QString::number((auth_peer>>0)&0xff) + "/"
164 + QString::number(auth_peer_bits); 174 + QString::number(auth_peer_bits);
165 } 175 }
166 for (int i=0; i<syncnet->count(); i++) { 176 for (int i=0; i<syncnet->count(); i++) {
167 if ( syncnet->text(i).left(sn.length()) == sn ) { 177 if ( syncnet->text(i).left(sn.length()) == sn ) {
168 syncnet->setCurrentItem(i); 178 syncnet->setCurrentItem(i);
169 return; 179 return;
170 } 180 }
171 } 181 }
172 qDebug("No match for \"%s\"",sn.latin1()); 182 qDebug("No match for \"%s\"",sn.latin1());
173} 183}
174 184
175void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) 185void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits)
176{ 186{
177 auth_peer=0; 187 auth_peer=0;
178 if ( sn == tr("Any") ) { 188 if ( sn == tr("Any") ) {
179 auth_peer = 0; 189 auth_peer = 0;
180 auth_peer_bits = 0; 190 auth_peer_bits = 0;
181 } else if ( sn == tr("None") ) { 191 } else if ( sn == tr("None") ) {
182 auth_peer = 0; 192 auth_peer = 0;
183 auth_peer_bits = 32; 193 auth_peer_bits = 32;
184 } else { 194 } else {
185 int x=0; 195 int x=0;
186 for (int i=0; i<4; i++) { 196 for (int i=0; i<4; i++) {
187 int nx = sn.find(QChar(i==3 ? '/' : '.'),x); 197 int nx = sn.find(QChar(i==3 ? '/' : '.'),x);
188 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); 198 auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt();
189 x = nx+1; 199 x = nx+1;
190 } 200 }
191 uint n = (uint)sn.find(' ',x)-x; 201 uint n = (uint)sn.find(' ',x)-x;
192 auth_peer_bits = sn.mid(x,n).toInt(); 202 auth_peer_bits = sn.mid(x,n).toInt();
193 } 203 }
194} 204}
195 205
196void Security::loadUsers ( void ) 206void Security::loadUsers ( void )
197{ 207{
198 QFile passwd("/etc/passwd"); 208 QFile passwd("/etc/passwd");
199 if ( passwd.open(IO_ReadOnly) ) { 209 if ( passwd.open(IO_ReadOnly) ) {
200 QTextStream t( &passwd ); 210 QTextStream t( &passwd );
201 QString s; 211 QString s;
202 QStringList account; 212 QStringList account;
203 while ( !t.eof() ) { 213 while ( !t.eof() ) {
204 account = QStringList::split(':',t.readLine()); 214 account = QStringList::split(':',t.readLine());
205 215
206 // Hide disabled accounts 216 // Hide disabled accounts
207 if (*account.at(1)!="*") { 217 if (*account.at(1)!="*") {
208 218
209 userlist->insertItem(*account.at(0)); 219 userlist->insertItem(*account.at(0));
210 // Highlight this item if it is set to autologinToggle 220 // Highlight this item if it is set to autologinToggle
211 if ( *account.at(0) == autoLoginName) 221 if ( *account.at(0) == autoLoginName)
212 userlist->setCurrentItem(userlist->count()-1); 222 userlist->setCurrentItem(userlist->count()-1);
213 } 223 }
214 } 224 }
215 passwd.close(); 225 passwd.close();
216 } 226 }
217 227
218} 228}
219 229
220void Security::toggleAutoLogin(bool val) 230void Security::toggleAutoLogin(bool val)
221{ 231{
222 autoLogin=val; 232 autoLogin=val;
223 userlist->setEnabled(val); 233 userlist->setEnabled(val);
224 if (!autoLogin) 234 if (!autoLogin)
225 autoLoginName=userlist->currentText(); 235 autoLoginName=userlist->currentText();
226} 236}
227 237
228 238
229 239
230 240
231void Security::setSyncNet(const QString& sn) 241void 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
238void Security::applySecurity() 248void 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}
285void 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
274void Security::changeLoginName( int idx ) 305void Security::changeLoginName( int idx )
275{ 306{
276 autoLoginName = userlist->text(idx);; 307 autoLoginName = userlist->text(idx);;
277 updateGUI(); 308 updateGUI();
278} 309}
279 310
280void Security::changePassCode() 311void 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}
297 328
298void Security::clearPassCode() 329void Security::clearPassCode()
299{ 330{
300 passcode = QString::null; 331 passcode = QString::null;
301 updateGUI(); 332 updateGUI();
302} 333}
303 334
304 335
305QString Security::enterPassCode(const QString& prompt) 336QString Security::enterPassCode(const QString& prompt)
306{ 337{
307 return Password::getPassword(prompt); 338 return Password::getPassword(prompt);
308} 339}
309 340
310bool Security::telnetAvailable() const 341bool Security::telnetAvailable() const
311{ 342{
312 // ### not implemented 343 // ### not implemented
313 return FALSE; 344 return FALSE;
314} 345}
315 346
316bool Security::sshAvailable() const 347bool Security::sshAvailable() const
317{ 348{
318 // ### not implemented 349 // ### not implemented
319 return FALSE; 350 return FALSE;
320} 351}
diff --git a/core/settings/security/security.h b/core/settings/security/security.h
index 52d56de..b1a3eca 100644
--- a/core/settings/security/security.h
+++ b/core/settings/security/security.h
@@ -1,71 +1,72 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
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#ifndef SECURITY_H 20#ifndef SECURITY_H
21#define SECURITY_H 21#define SECURITY_H
22 22
23#include "securitybase.h" 23#include "securitybase.h"
24 24
25class QPEDialogListener; 25class QPEDialogListener;
26 26
27class Security : public SecurityBase 27class Security : public SecurityBase
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30 30
31public: 31public:
32 static QString appName() { return QString::fromLatin1("security"); } 32 static QString appName() { return QString::fromLatin1("security"); }
33 Security( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 33 Security( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
34 ~Security(); 34 ~Security();
35 35
36 void show(); 36 void show();
37 37
38protected: 38protected:
39 void accept(); 39 void accept();
40 void applySecurity(); 40 void applySecurity();
41 void done(int); 41 void done(int);
42 42
43private slots: 43private slots:
44 void changePassCode(); 44 void changePassCode();
45 void clearPassCode(); 45 void clearPassCode();
46 void setSyncNet(const QString&); 46 void setSyncNet(const QString&);
47 void changeLoginName(int); 47 void changeLoginName(int);
48 void toggleAutoLogin(bool); 48 void toggleAutoLogin(bool);
49 void changeSyncApp();
49 50
50 51
51private: 52private:
52 void loadUsers(void); 53 void loadUsers(void);
53 bool telnetAvailable() const; 54 bool telnetAvailable() const;
54 bool sshAvailable() const; 55 bool sshAvailable() const;
55 void updateGUI(); 56 void updateGUI();
56 57
57 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits); 58 static void parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits);
58 void selectNet(int auth_peer,int auth_peer_bits); 59 void selectNet(int auth_peer,int auth_peer_bits);
59 60
60 QString enterPassCode(const QString&); 61 QString enterPassCode(const QString&);
61 QString passcode; 62 QString passcode;
62 bool valid; 63 bool valid;
63 bool autoLogin; 64 bool autoLogin;
64 QString autoLoginName; 65 QString autoLoginName;
65 66
66 QPEDialogListener *dl; 67 QPEDialogListener *dl;
67}; 68};
68 69
69 70
70#endif // SECURITY_H 71#endif // SECURITY_H
71 72
diff --git a/core/settings/security/securitybase.ui b/core/settings/security/securitybase.ui
index 9fb63a8..934111e 100644
--- a/core/settings/security/securitybase.ui
+++ b/core/settings/security/securitybase.ui
@@ -1,437 +1,467 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
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>321</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>
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>0</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>0</number> 35 <number>0</number>
36 </property> 36 </property>
37 <widget> 37 <widget>
38 <class>QTabWidget</class> 38 <class>QTabWidget</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
41 <cstring>TabWidget2</cstring> 41 <cstring>TabWidget2</cstring>
42 </property> 42 </property>
43 <property> 43 <property>
44 <name>layoutMargin</name> 44 <name>layoutMargin</name>
45 </property> 45 </property>
46 <widget> 46 <widget>
47 <class>QWidget</class> 47 <class>QWidget</class>
48 <property stdset="1"> 48 <property stdset="1">
49 <name>name</name> 49 <name>name</name>
50 <cstring>tab</cstring> 50 <cstring>tab</cstring>
51 </property> 51 </property>
52 <attribute> 52 <attribute>
53 <name>title</name> 53 <name>title</name>
54 <string>Passcode</string> 54 <string>Passcode</string>
55 </attribute> 55 </attribute>
56 <vbox> 56 <vbox>
57 <property stdset="1"> 57 <property stdset="1">
58 <name>margin</name> 58 <name>margin</name>
59 <number>6</number> 59 <number>6</number>
60 </property> 60 </property>
61 <property stdset="1"> 61 <property stdset="1">
62 <name>spacing</name> 62 <name>spacing</name>
63 <number>6</number> 63 <number>6</number>
64 </property> 64 </property>
65 <widget> 65 <widget>
66 <class>QGroupBox</class> 66 <class>QGroupBox</class>
67 <property stdset="1"> 67 <property stdset="1">
68 <name>name</name> 68 <name>name</name>
69 <cstring>GroupBox4</cstring> 69 <cstring>GroupBox4</cstring>
70 </property> 70 </property>
71 <property stdset="1"> 71 <property stdset="1">
72 <name>title</name> 72 <name>title</name>
73 <string>Passcode</string> 73 <string>Passcode</string>
74 </property> 74 </property>
75 <vbox> 75 <vbox>
76 <property stdset="1"> 76 <property stdset="1">
77 <name>margin</name> 77 <name>margin</name>
78 <number>11</number> 78 <number>11</number>
79 </property> 79 </property>
80 <property stdset="1"> 80 <property stdset="1">
81 <name>spacing</name> 81 <name>spacing</name>
82 <number>6</number> 82 <number>6</number>
83 </property> 83 </property>
84 <widget> 84 <widget>
85 <class>QLayoutWidget</class> 85 <class>QLayoutWidget</class>
86 <property stdset="1"> 86 <property stdset="1">
87 <name>name</name> 87 <name>name</name>
88 <cstring>Layout1</cstring> 88 <cstring>Layout1</cstring>
89 </property> 89 </property>
90 <property> 90 <property>
91 <name>layoutSpacing</name> 91 <name>layoutSpacing</name>
92 </property> 92 </property>
93 <hbox> 93 <hbox>
94 <property stdset="1"> 94 <property stdset="1">
95 <name>margin</name> 95 <name>margin</name>
96 <number>0</number> 96 <number>0</number>
97 </property> 97 </property>
98 <property stdset="1"> 98 <property stdset="1">
99 <name>spacing</name> 99 <name>spacing</name>
100 <number>-1</number> 100 <number>-1</number>
101 </property> 101 </property>
102 <widget> 102 <widget>
103 <class>QPushButton</class> 103 <class>QPushButton</class>
104 <property stdset="1"> 104 <property stdset="1">
105 <name>name</name> 105 <name>name</name>
106 <cstring>changepasscode</cstring> 106 <cstring>changepasscode</cstring>
107 </property> 107 </property>
108 <property stdset="1"> 108 <property stdset="1">
109 <name>text</name> 109 <name>text</name>
110 <string>Change passcode</string> 110 <string>Change passcode</string>
111 </property> 111 </property>
112 </widget> 112 </widget>
113 <widget> 113 <widget>
114 <class>QPushButton</class> 114 <class>QPushButton</class>
115 <property stdset="1"> 115 <property stdset="1">
116 <name>name</name> 116 <name>name</name>
117 <cstring>clearpasscode</cstring> 117 <cstring>clearpasscode</cstring>
118 </property> 118 </property>
119 <property stdset="1"> 119 <property stdset="1">
120 <name>text</name> 120 <name>text</name>
121 <string>Clear passcode</string> 121 <string>Clear passcode</string>
122 </property> 122 </property>
123 </widget> 123 </widget>
124 </hbox> 124 </hbox>
125 </widget> 125 </widget>
126 <widget> 126 <widget>
127 <class>QCheckBox</class> 127 <class>QCheckBox</class>
128 <property stdset="1"> 128 <property stdset="1">
129 <name>name</name> 129 <name>name</name>
130 <cstring>passcode_poweron</cstring> 130 <cstring>passcode_poweron</cstring>
131 </property> 131 </property>
132 <property stdset="1"> 132 <property stdset="1">
133 <name>text</name> 133 <name>text</name>
134 <string>Require pass code at power-on</string> 134 <string>Require pass code at power-on</string>
135 </property> 135 </property>
136 </widget> 136 </widget>
137 <widget> 137 <widget>
138 <class>QLabel</class> 138 <class>QLabel</class>
139 <property stdset="1"> 139 <property stdset="1">
140 <name>name</name> 140 <name>name</name>
141 <cstring>TextLabel1</cstring> 141 <cstring>TextLabel1</cstring>
142 </property> 142 </property>
143 <property stdset="1"> 143 <property stdset="1">
144 <name>sizePolicy</name> 144 <name>sizePolicy</name>
145 <sizepolicy> 145 <sizepolicy>
146 <hsizetype>5</hsizetype> 146 <hsizetype>5</hsizetype>
147 <vsizetype>7</vsizetype> 147 <vsizetype>7</vsizetype>
148 </sizepolicy> 148 </sizepolicy>
149 </property> 149 </property>
150 <property stdset="1"> 150 <property stdset="1">
151 <name>text</name> 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> 152 <string>&lt;P&gt;Pass code protection provides a minimal level of protection from casual access to this device.</string>
153 </property> 153 </property>
154 <property stdset="1"> 154 <property stdset="1">
155 <name>textFormat</name> 155 <name>textFormat</name>
156 <enum>RichText</enum> 156 <enum>RichText</enum>
157 </property> 157 </property>
158 <property stdset="1"> 158 <property stdset="1">
159 <name>alignment</name> 159 <name>alignment</name>
160 <set>AlignTop|AlignLeft</set> 160 <set>AlignTop|AlignLeft</set>
161 </property> 161 </property>
162 <property> 162 <property>
163 <name>vAlign</name> 163 <name>vAlign</name>
164 </property> 164 </property>
165 </widget> 165 </widget>
166 </vbox> 166 </vbox>
167 </widget> 167 </widget>
168 <spacer> 168 <spacer>
169 <property> 169 <property>
170 <name>name</name> 170 <name>name</name>
171 <cstring>Spacer3</cstring> 171 <cstring>Spacer3</cstring>
172 </property> 172 </property>
173 <property stdset="1"> 173 <property stdset="1">
174 <name>orientation</name> 174 <name>orientation</name>
175 <enum>Vertical</enum> 175 <enum>Vertical</enum>
176 </property> 176 </property>
177 <property stdset="1"> 177 <property stdset="1">
178 <name>sizeType</name> 178 <name>sizeType</name>
179 <enum>Expanding</enum> 179 <enum>Expanding</enum>
180 </property> 180 </property>
181 <property> 181 <property>
182 <name>sizeHint</name> 182 <name>sizeHint</name>
183 <size> 183 <size>
184 <width>20</width> 184 <width>20</width>
185 <height>20</height> 185 <height>20</height>
186 </size> 186 </size>
187 </property> 187 </property>
188 </spacer> 188 </spacer>
189 </vbox> 189 </vbox>
190 </widget> 190 </widget>
191 <widget> 191 <widget>
192 <class>QWidget</class> 192 <class>QWidget</class>
193 <property stdset="1"> 193 <property stdset="1">
194 <name>name</name> 194 <name>name</name>
195 <cstring>tab</cstring> 195 <cstring>tab</cstring>
196 </property> 196 </property>
197 <attribute> 197 <attribute>
198 <name>title</name> 198 <name>title</name>
199 <string>Login</string> 199 <string>Login</string>
200 </attribute> 200 </attribute>
201 <vbox> 201 <vbox>
202 <property stdset="1"> 202 <property stdset="1">
203 <name>margin</name> 203 <name>margin</name>
204 <number>6</number> 204 <number>6</number>
205 </property> 205 </property>
206 <property stdset="1"> 206 <property stdset="1">
207 <name>spacing</name> 207 <name>spacing</name>
208 <number>6</number> 208 <number>6</number>
209 </property> 209 </property>
210 <widget> 210 <widget>
211 <class>QGroupBox</class> 211 <class>QGroupBox</class>
212 <property stdset="1"> 212 <property stdset="1">
213 <name>name</name> 213 <name>name</name>
214 <cstring>GroupBox3</cstring> 214 <cstring>GroupBox3</cstring>
215 </property> 215 </property>
216 <property stdset="1"> 216 <property stdset="1">
217 <name>title</name> 217 <name>title</name>
218 <string>Login</string> 218 <string>Login</string>
219 </property> 219 </property>
220 <vbox> 220 <vbox>
221 <property stdset="1"> 221 <property stdset="1">
222 <name>margin</name> 222 <name>margin</name>
223 <number>11</number> 223 <number>11</number>
224 </property> 224 </property>
225 <property stdset="1"> 225 <property stdset="1">
226 <name>spacing</name> 226 <name>spacing</name>
227 <number>6</number> 227 <number>6</number>
228 </property> 228 </property>
229 <widget> 229 <widget>
230 <class>QCheckBox</class> 230 <class>QCheckBox</class>
231 <property stdset="1"> 231 <property stdset="1">
232 <name>name</name> 232 <name>name</name>
233 <cstring>autologinToggle</cstring> 233 <cstring>autologinToggle</cstring>
234 </property> 234 </property>
235 <property stdset="1"> 235 <property stdset="1">
236 <name>text</name> 236 <name>text</name>
237 <string>Login Automatically</string> 237 <string>Login Automatically</string>
238 </property> 238 </property>
239 </widget> 239 </widget>
240 <widget> 240 <widget>
241 <class>QComboBox</class> 241 <class>QComboBox</class>
242 <property stdset="1"> 242 <property stdset="1">
243 <name>name</name> 243 <name>name</name>
244 <cstring>userlist</cstring> 244 <cstring>userlist</cstring>
245 </property> 245 </property>
246 </widget> 246 </widget>
247 </vbox> 247 </vbox>
248 </widget> 248 </widget>
249 <spacer> 249 <spacer>
250 <property> 250 <property>
251 <name>name</name> 251 <name>name</name>
252 <cstring>Spacer2</cstring> 252 <cstring>Spacer2</cstring>
253 </property> 253 </property>
254 <property stdset="1"> 254 <property stdset="1">
255 <name>orientation</name> 255 <name>orientation</name>
256 <enum>Vertical</enum> 256 <enum>Vertical</enum>
257 </property> 257 </property>
258 <property stdset="1"> 258 <property stdset="1">
259 <name>sizeType</name> 259 <name>sizeType</name>
260 <enum>Expanding</enum> 260 <enum>Expanding</enum>
261 </property> 261 </property>
262 <property> 262 <property>
263 <name>sizeHint</name> 263 <name>sizeHint</name>
264 <size> 264 <size>
265 <width>20</width> 265 <width>20</width>
266 <height>20</height> 266 <height>20</height>
267 </size> 267 </size>
268 </property> 268 </property>
269 </spacer> 269 </spacer>
270 </vbox> 270 </vbox>
271 </widget> 271 </widget>
272 <widget> 272 <widget>
273 <class>QWidget</class> 273 <class>QWidget</class>
274 <property stdset="1"> 274 <property stdset="1">
275 <name>name</name> 275 <name>name</name>
276 <cstring>tab</cstring> 276 <cstring>tab</cstring>
277 </property> 277 </property>
278 <attribute> 278 <attribute>
279 <name>title</name> 279 <name>title</name>
280 <string>Sync</string> 280 <string>Sync</string>
281 </attribute> 281 </attribute>
282 <vbox> 282 <vbox>
283 <property stdset="1"> 283 <property stdset="1">
284 <name>margin</name> 284 <name>margin</name>
285 <number>6</number> 285 <number>11</number>
286 </property> 286 </property>
287 <property stdset="1"> 287 <property stdset="1">
288 <name>spacing</name> 288 <name>spacing</name>
289 <number>6</number> 289 <number>6</number>
290 </property> 290 </property>
291 <widget> 291 <widget>
292 <class>QGroupBox</class> 292 <class>QGroupBox</class>
293 <property stdset="1"> 293 <property stdset="1">
294 <name>name</name> 294 <name>name</name>
295 <cstring>GroupBox2</cstring> 295 <cstring>GroupBox2</cstring>
296 </property> 296 </property>
297 <property stdset="1"> 297 <property stdset="1">
298 <name>title</name> 298 <name>title</name>
299 <string>Sync</string> 299 <string>Sync</string>
300 </property> 300 </property>
301 <vbox> 301 <vbox>
302 <property stdset="1"> 302 <property stdset="1">
303 <name>margin</name> 303 <name>margin</name>
304 <number>11</number> 304 <number>11</number>
305 </property> 305 </property>
306 <property stdset="1"> 306 <property stdset="1">
307 <name>spacing</name> 307 <name>spacing</name>
308 <number>6</number> 308 <number>6</number>
309 </property> 309 </property>
310 <widget> 310 <widget>
311 <class>QLabel</class> 311 <class>QLabel</class>
312 <property stdset="1"> 312 <property stdset="1">
313 <name>name</name> 313 <name>name</name>
314 <cstring>TextLabel1_2</cstring> 314 <cstring>TextLabel1_2</cstring>
315 </property> 315 </property>
316 <property stdset="1"> 316 <property stdset="1">
317 <name>text</name> 317 <name>text</name>
318 <string>Accept sync from network:</string> 318 <string>Accept sync from network:</string>
319 </property> 319 </property>
320 <property stdset="1"> 320 <property stdset="1">
321 <name>textFormat</name> 321 <name>textFormat</name>
322 <enum>RichText</enum> 322 <enum>RichText</enum>
323 </property> 323 </property>
324 </widget> 324 </widget>
325 <widget> 325 <widget>
326 <class>QComboBox</class> 326 <class>QComboBox</class>
327 <item> 327 <item>
328 <property> 328 <property>
329 <name>text</name> 329 <name>text</name>
330 <string>192.168.129.0/24 (default)</string> 330 <string>192.168.129.0/24 (default)</string>
331 </property> 331 </property>
332 </item> 332 </item>
333 <item> 333 <item>
334 <property> 334 <property>
335 <name>text</name> 335 <name>text</name>
336 <string>192.168.1.0/24</string> 336 <string>192.168.1.0/24</string>
337 </property> 337 </property>
338 </item> 338 </item>
339 <item> 339 <item>
340 <property> 340 <property>
341 <name>text</name> 341 <name>text</name>
342 <string>192.168.0.0/16</string> 342 <string>192.168.0.0/16</string>
343 </property> 343 </property>
344 </item> 344 </item>
345 <item> 345 <item>
346 <property> 346 <property>
347 <name>text</name> 347 <name>text</name>
348 <string>172.16.0.0/12</string> 348 <string>172.16.0.0/12</string>
349 </property> 349 </property>
350 </item> 350 </item>
351 <item> 351 <item>
352 <property> 352 <property>
353 <name>text</name> 353 <name>text</name>
354 <string>10.0.0.0/8</string> 354 <string>10.0.0.0/8</string>
355 </property> 355 </property>
356 </item> 356 </item>
357 <item> 357 <item>
358 <property> 358 <property>
359 <name>text</name> 359 <name>text</name>
360 <string>1.0.0.0/8</string> 360 <string>1.0.0.0/8</string>
361 </property> 361 </property>
362 </item> 362 </item>
363 <item> 363 <item>
364 <property> 364 <property>
365 <name>text</name> 365 <name>text</name>
366 <string>Any</string> 366 <string>Any</string>
367 </property> 367 </property>
368 </item> 368 </item>
369 <item> 369 <item>
370 <property> 370 <property>
371 <name>text</name> 371 <name>text</name>
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> 384 <widget>
385 <class>QLabel</class>
386 <property stdset="1">
387 <name>name</name>
388 <cstring>TextLabel2</cstring>
389 </property>
390 <property stdset="1">
391 <name>text</name>
392 <string>Select your sync software</string>
393 </property>
394 </widget>
395 <widget>
396 <class>QComboBox</class>
397 <item>
398 <property>
399 <name>text</name>
400 <string>QTopia</string>
401 </property>
402 </item>
403 <item>
404 <property>
405 <name>text</name>
406 <string>IntelliSync</string>
407 </property>
408 </item>
409 <property stdset="1">
410 <name>name</name>
411 <cstring>syncapp</cstring>
412 </property>
413 </widget>
414 <widget>
385 <class>QComboBox</class> 415 <class>QComboBox</class>
386 <item> 416 <item>
387 <property> 417 <property>
388 <name>text</name> 418 <name>text</name>
389 <string>Qtopia 1.7</string> 419 <string>Qtopia 1.7</string>
390 </property> 420 </property>
391 </item> 421 </item>
392 <item> 422 <item>
393 <property> 423 <property>
394 <name>text</name> 424 <name>text</name>
395 <string>Opie 1.0</string> 425 <string>Opie 1.0</string>
396 </property> 426 </property>
397 </item> 427 </item>
398 <item> 428 <item>
399 <property> 429 <property>
400 <name>text</name> 430 <name>text</name>
401 <string>Both</string> 431 <string>Both</string>
402 </property> 432 </property>
403 </item> 433 </item>
404 <property stdset="1"> 434 <property stdset="1">
405 <name>name</name> 435 <name>name</name>
406 <cstring>syncModeCombo</cstring> 436 <cstring>syncModeCombo</cstring>
407 </property> 437 </property>
408 </widget> 438 </widget>
409 </vbox> 439 </vbox>
410 </widget> 440 </widget>
411 <spacer> 441 <spacer>
412 <property> 442 <property>
413 <name>name</name> 443 <name>name</name>
414 <cstring>Spacer1</cstring> 444 <cstring>Spacer1</cstring>
415 </property> 445 </property>
416 <property stdset="1"> 446 <property stdset="1">
417 <name>orientation</name> 447 <name>orientation</name>
418 <enum>Vertical</enum> 448 <enum>Vertical</enum>
419 </property> 449 </property>
420 <property stdset="1"> 450 <property stdset="1">
421 <name>sizeType</name> 451 <name>sizeType</name>
422 <enum>Expanding</enum> 452 <enum>Expanding</enum>
423 </property> 453 </property>
424 <property> 454 <property>
425 <name>sizeHint</name> 455 <name>sizeHint</name>
426 <size> 456 <size>
427 <width>20</width> 457 <width>20</width>
428 <height>20</height> 458 <height>20</height>
429 </size> 459 </size>
430 </property> 460 </property>
431 </spacer> 461 </spacer>
432 </vbox> 462 </vbox>
433 </widget> 463 </widget>
434 </widget> 464 </widget>
435 </vbox> 465 </vbox>
436</widget> 466</widget>
437</UI> 467</UI>