-rw-r--r-- | core/launcher/documentlist.cpp | 8 | ||||
-rw-r--r-- | core/launcher/qprocess_unix.cpp | 646 | ||||
-rw-r--r-- | core/launcher/screensaver.cpp | 386 | ||||
-rw-r--r-- | core/launcher/server.cpp | 434 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 851 |
5 files changed, 1164 insertions, 1161 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index 19ceb0f..44ceb0c 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp | |||
@@ -389,3 +389,3 @@ void DocumentList::DiffAppLnks() | |||
389 | if (!found) { | 389 | if (!found) { |
390 | qDebug("Item %s needs to be added",j->name().ascii() ); | 390 | odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; |
391 | d->serverGui->applicationAdded( j->type(), *j ); | 391 | d->serverGui->applicationAdded( j->type(), *j ); |
@@ -405,3 +405,3 @@ void DocumentList::DiffAppLnks() | |||
405 | if (!found) { | 405 | if (!found) { |
406 | qDebug("Item %s needs to be removed",i->name().ascii() ); | 406 | odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; |
407 | d->serverGui->applicationRemoved( i->type(), *i ); | 407 | d->serverGui->applicationRemoved( i->type(), *i ); |
@@ -424,6 +424,6 @@ void DocumentList::storageChanged() | |||
424 | // reloadAppLnks(); | 424 | // reloadAppLnks(); |
425 | qDebug("Reload App links took %i ms",t.elapsed() ); | 425 | odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; |
426 | reloadDocLnks(); | 426 | reloadDocLnks(); |
427 | // odebug << "Reload links took " << t.elapsed() << " ms " << oendl; | 427 | // odebug << "Reload links took " << t.elapsed() << " ms " << oendl; |
428 | qDebug("Reload All links took %i ms",t.elapsed() ); | 428 | odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; |
429 | // ### Optimization opportunity | 429 | // ### Optimization opportunity |
diff --git a/core/launcher/qprocess_unix.cpp b/core/launcher/qprocess_unix.cpp index 56e1b1d..97c0460 100644 --- a/core/launcher/qprocess_unix.cpp +++ b/core/launcher/qprocess_unix.cpp | |||
@@ -135,5 +135,5 @@ public: | |||
135 | #endif | 135 | #endif |
136 | socketStdin = 0; | 136 | socketStdin = 0; |
137 | socketStdout = 0; | 137 | socketStdout = 0; |
138 | socketStderr = 0; | 138 | socketStderr = 0; |
139 | } | 139 | } |
@@ -144,19 +144,19 @@ public: | |||
144 | #endif | 144 | #endif |
145 | if ( process != 0 ) { | 145 | if ( process != 0 ) { |
146 | if ( process->d->notifierStdin ) | 146 | if ( process->d->notifierStdin ) |
147 | process->d->notifierStdin->setEnabled( FALSE ); | 147 | process->d->notifierStdin->setEnabled( FALSE ); |
148 | if ( process->d->notifierStdout ) | 148 | if ( process->d->notifierStdout ) |
149 | process->d->notifierStdout->setEnabled( FALSE ); | 149 | process->d->notifierStdout->setEnabled( FALSE ); |
150 | if ( process->d->notifierStderr ) | 150 | if ( process->d->notifierStderr ) |
151 | process->d->notifierStderr->setEnabled( FALSE ); | 151 | process->d->notifierStderr->setEnabled( FALSE ); |
152 | process->d->proc = 0; | 152 | process->d->proc = 0; |
153 | } | 153 | } |
154 | if( socketStdin != 0 ) | 154 | if( socketStdin != 0 ) |
155 | ::close( socketStdin ); | 155 | ::close( socketStdin ); |
156 | // ### close these sockets even on parent exit or is it better only on | 156 | // ### close these sockets even on parent exit or is it better only on |
157 | // sigchld (but what do I have to do with them on exit then)? | 157 | // sigchld (but what do I have to do with them on exit then)? |
158 | if( socketStdout != 0 ) | 158 | if( socketStdout != 0 ) |
159 | ::close( socketStdout ); | 159 | ::close( socketStdout ); |
160 | if( socketStderr != 0 ) | 160 | if( socketStderr != 0 ) |
161 | ::close( socketStderr ); | 161 | ::close( socketStderr ); |
162 | } | 162 | } |
@@ -210,4 +210,4 @@ QProcessManager::QProcessManager() | |||
210 | if ( ::socketpair( AF_UNIX, SOCK_STREAM, 0, sigchldFd ) ) { | 210 | if ( ::socketpair( AF_UNIX, SOCK_STREAM, 0, sigchldFd ) ) { |
211 | sigchldFd[0] = 0; | 211 | sigchldFd[0] = 0; |
212 | sigchldFd[1] = 0; | 212 | sigchldFd[1] = 0; |
213 | } else { | 213 | } else { |
@@ -216,7 +216,7 @@ QProcessManager::QProcessManager() | |||
216 | #endif | 216 | #endif |
217 | QSocketNotifier *sn = new QSocketNotifier( sigchldFd[1], | 217 | QSocketNotifier *sn = new QSocketNotifier( sigchldFd[1], |
218 | QSocketNotifier::Read, this ); | 218 | QSocketNotifier::Read, this ); |
219 | connect( sn, SIGNAL(activated(int)), | 219 | connect( sn, SIGNAL(activated(int)), |
220 | this, SLOT(sigchldHnd(int)) ); | 220 | this, SLOT(sigchldHnd(int)) ); |
221 | sn->setEnabled( TRUE ); | 221 | sn->setEnabled( TRUE ); |
222 | } | 222 | } |
@@ -243,6 +243,6 @@ QProcessManager::QProcessManager() | |||
243 | /* | 243 | /* |
244 | Using qt_C_sigpipeHnd rather than SIG_IGN is a workaround | 244 | Using qt_C_sigpipeHnd rather than SIG_IGN is a workaround |
245 | for a strange problem where GNU tar (called by backuprestore) | 245 | for a strange problem where GNU tar (called by backuprestore) |
246 | would hang on filesystem-full. Strangely, the qt_C_sigpipeHnd | 246 | would hang on filesystem-full. Strangely, the qt_C_sigpipeHnd |
247 | is never even called, yet this avoids the hang. | 247 | is never even called, yet this avoids the hang. |
248 | */ | 248 | */ |
@@ -261,5 +261,5 @@ QProcessManager::~QProcessManager() | |||
261 | if ( sigchldFd[0] != 0 ) | 261 | if ( sigchldFd[0] != 0 ) |
262 | ::close( sigchldFd[0] ); | 262 | ::close( sigchldFd[0] ); |
263 | if ( sigchldFd[1] != 0 ) | 263 | if ( sigchldFd[1] != 0 ) |
264 | ::close( sigchldFd[1] ); | 264 | ::close( sigchldFd[1] ); |
265 | 265 | ||
@@ -299,3 +299,3 @@ void QProcessManager::cleanup() | |||
299 | if ( procList->count() == 0 ) { | 299 | if ( procList->count() == 0 ) { |
300 | QTimer::singleShot( 0, this, SLOT(removeMe()) ); | 300 | QTimer::singleShot( 0, this, SLOT(removeMe()) ); |
301 | } | 301 | } |
@@ -306,5 +306,5 @@ void QProcessManager::removeMe() | |||
306 | if ( procList->count() == 0 ) { | 306 | if ( procList->count() == 0 ) { |
307 | qprocess_cleanup_procmanager.remove( &QProcessPrivate::procManager ); | 307 | qprocess_cleanup_procmanager.remove( &QProcessPrivate::procManager ); |
308 | QProcessPrivate::procManager = 0; | 308 | QProcessPrivate::procManager = 0; |
309 | delete this; | 309 | delete this; |
310 | } | 310 | } |
@@ -324,7 +324,7 @@ void QProcessManager::sigchldHnd( int fd ) | |||
324 | while ( proc != 0 ) { | 324 | while ( proc != 0 ) { |
325 | removeProc = FALSE; | 325 | removeProc = FALSE; |
326 | process = proc->process; | 326 | process = proc->process; |
327 | QProcess *process_exit_notify=0; | 327 | QProcess *process_exit_notify=0; |
328 | if ( process != 0 ) { | 328 | if ( process != 0 ) { |
329 | if ( !process->isRunning() ) { | 329 | if ( !process->isRunning() ) { |
330 | #if defined(QT_QPROCESS_DEBUG) | 330 | #if defined(QT_QPROCESS_DEBUG) |
@@ -332,5 +332,5 @@ void QProcessManager::sigchldHnd( int fd ) | |||
332 | #endif | 332 | #endif |
333 | // read pending data | 333 | // read pending data |
334 | int nbytes = 0; | 334 | int nbytes = 0; |
335 | if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { | 335 | if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { |
336 | #if defined(QT_QPROCESS_DEBUG) | 336 | #if defined(QT_QPROCESS_DEBUG) |
@@ -338,6 +338,6 @@ void QProcessManager::sigchldHnd( int fd ) | |||
338 | #endif | 338 | #endif |
339 | process->socketRead( proc->socketStdout ); | 339 | process->socketRead( proc->socketStdout ); |
340 | } | 340 | } |
341 | nbytes = 0; | 341 | nbytes = 0; |
342 | if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { | 342 | if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { |
343 | #if defined(QT_QPROCESS_DEBUG) | 343 | #if defined(QT_QPROCESS_DEBUG) |
@@ -345,13 +345,13 @@ void QProcessManager::sigchldHnd( int fd ) | |||
345 | #endif | 345 | #endif |
346 | process->socketRead( proc->socketStderr ); | 346 | process->socketRead( proc->socketStderr ); |
347 | } | 347 | } |
348 | 348 | ||
349 | if ( process->notifyOnExit ) | 349 | if ( process->notifyOnExit ) |
350 | process_exit_notify = process; | 350 | process_exit_notify = process; |
351 | 351 | ||
352 | removeProc = TRUE; | 352 | removeProc = TRUE; |
353 | } | 353 | } |
354 | } else { | 354 | } else { |
355 | int status; | 355 | int status; |
356 | if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) { | 356 | if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) { |
357 | #if defined(QT_QPROCESS_DEBUG) | 357 | #if defined(QT_QPROCESS_DEBUG) |
@@ -359,14 +359,14 @@ void QProcessManager::sigchldHnd( int fd ) | |||
359 | #endif | 359 | #endif |
360 | removeProc = TRUE; | 360 | removeProc = TRUE; |
361 | } | 361 | } |
362 | } | 362 | } |
363 | if ( removeProc ) { | 363 | if ( removeProc ) { |
364 | QProc *oldproc = proc; | 364 | QProc *oldproc = proc; |
365 | proc = procList->next(); | 365 | proc = procList->next(); |
366 | remove( oldproc ); | 366 | remove( oldproc ); |
367 | } else { | 367 | } else { |
368 | proc = procList->next(); | 368 | proc = procList->next(); |
369 | } | 369 | } |
370 | if ( process_exit_notify ) | 370 | if ( process_exit_notify ) |
371 | emit process_exit_notify->processExited(); | 371 | emit process_exit_notify->processExited(); |
372 | } | 372 | } |
@@ -408,7 +408,7 @@ QProcessPrivate::~QProcessPrivate() | |||
408 | if ( proc != 0 ) { | 408 | if ( proc != 0 ) { |
409 | if ( proc->socketStdin != 0 ) { | 409 | if ( proc->socketStdin != 0 ) { |
410 | ::close( proc->socketStdin ); | 410 | ::close( proc->socketStdin ); |
411 | proc->socketStdin = 0; | 411 | proc->socketStdin = 0; |
412 | } | 412 | } |
413 | proc->process = 0; | 413 | proc->process = 0; |
414 | } | 414 | } |
@@ -416,3 +416,3 @@ QProcessPrivate::~QProcessPrivate() | |||
416 | while ( !stdinBuf.isEmpty() ) { | 416 | while ( !stdinBuf.isEmpty() ) { |
417 | delete stdinBuf.dequeue(); | 417 | delete stdinBuf.dequeue(); |
418 | } | 418 | } |
@@ -431,14 +431,14 @@ void QProcessPrivate::closeOpenSocketsForChild() | |||
431 | if ( procManager != 0 ) { | 431 | if ( procManager != 0 ) { |
432 | if ( procManager->sigchldFd[0] != 0 ) | 432 | if ( procManager->sigchldFd[0] != 0 ) |
433 | ::close( procManager->sigchldFd[0] ); | 433 | ::close( procManager->sigchldFd[0] ); |
434 | if ( procManager->sigchldFd[1] != 0 ) | 434 | if ( procManager->sigchldFd[1] != 0 ) |
435 | ::close( procManager->sigchldFd[1] ); | 435 | ::close( procManager->sigchldFd[1] ); |
436 | 436 | ||
437 | // close also the sockets from other QProcess instances | 437 | // close also the sockets from other QProcess instances |
438 | QProc *proc; | 438 | QProc *proc; |
439 | for ( proc=procManager->procList->first(); proc!=0; proc=procManager->procList->next() ) { | 439 | for ( proc=procManager->procList->first(); proc!=0; proc=procManager->procList->next() ) { |
440 | ::close( proc->socketStdin ); | 440 | ::close( proc->socketStdin ); |
441 | ::close( proc->socketStdout ); | 441 | ::close( proc->socketStdout ); |
442 | ::close( proc->socketStderr ); | 442 | ::close( proc->socketStderr ); |
443 | } | 443 | } |
444 | } | 444 | } |
@@ -450,4 +450,4 @@ void QProcessPrivate::newProc( pid_t pid, QProcess *process ) | |||
450 | if ( procManager == 0 ) { | 450 | if ( procManager == 0 ) { |
451 | procManager = new QProcessManager; | 451 | procManager = new QProcessManager; |
452 | qprocess_cleanup_procmanager.add( &procManager ); | 452 | qprocess_cleanup_procmanager.add( &procManager ); |
453 | } | 453 | } |
@@ -465,5 +465,5 @@ QT_SIGNAL_RETTYPE qt_C_sigchldHnd( QT_SIGNAL_ARGS ) | |||
465 | if ( QProcessPrivate::procManager == 0 ) | 465 | if ( QProcessPrivate::procManager == 0 ) |
466 | return; | 466 | return; |
467 | if ( QProcessPrivate::procManager->sigchldFd[0] == 0 ) | 467 | if ( QProcessPrivate::procManager->sigchldFd[0] == 0 ) |
468 | return; | 468 | return; |
469 | 469 | ||
@@ -510,5 +510,5 @@ QByteArray* QProcess::bufStdout() | |||
510 | if ( d->proc && d->proc->socketStdout ) { | 510 | if ( d->proc && d->proc->socketStdout ) { |
511 | // ### can this cause a blocking behaviour (maybe do a ioctl() to see | 511 | // ### can this cause a blocking behaviour (maybe do a ioctl() to see |
512 | // if data is available)? | 512 | // if data is available)? |
513 | socketRead( d->proc->socketStdout ); | 513 | socketRead( d->proc->socketStdout ); |
514 | } | 514 | } |
@@ -520,5 +520,5 @@ QByteArray* QProcess::bufStderr() | |||
520 | if ( d->proc && d->proc->socketStderr ) { | 520 | if ( d->proc && d->proc->socketStderr ) { |
521 | // ### can this cause a blocking behaviour (maybe do a ioctl() to see | 521 | // ### can this cause a blocking behaviour (maybe do a ioctl() to see |
522 | // if data is available)? | 522 | // if data is available)? |
523 | socketRead( d->proc->socketStderr ); | 523 | socketRead( d->proc->socketStderr ); |
524 | } | 524 | } |
@@ -531,7 +531,7 @@ void QProcess::consumeBufStdout( int consume ) | |||
531 | if ( consume==-1 || (uint)consume >= n ) { | 531 | if ( consume==-1 || (uint)consume >= n ) { |
532 | d->bufStdout.resize( 0 ); | 532 | d->bufStdout.resize( 0 ); |
533 | } else { | 533 | } else { |
534 | QByteArray tmp( n - consume ); | 534 | QByteArray tmp( n - consume ); |
535 | memcpy( tmp.data(), d->bufStdout.data()+consume, n-consume ); | 535 | memcpy( tmp.data(), d->bufStdout.data()+consume, n-consume ); |
536 | d->bufStdout = tmp; | 536 | d->bufStdout = tmp; |
537 | } | 537 | } |
@@ -543,7 +543,7 @@ void QProcess::consumeBufStderr( int consume ) | |||
543 | if ( consume==-1 || (uint)consume >= n ) { | 543 | if ( consume==-1 || (uint)consume >= n ) { |
544 | d->bufStderr.resize( 0 ); | 544 | d->bufStderr.resize( 0 ); |
545 | } else { | 545 | } else { |
546 | QByteArray tmp( n - consume ); | 546 | QByteArray tmp( n - consume ); |
547 | memcpy( tmp.data(), d->bufStderr.data()+consume, n-consume ); | 547 | memcpy( tmp.data(), d->bufStderr.data()+consume, n-consume ); |
548 | d->bufStderr = tmp; | 548 | d->bufStderr = tmp; |
549 | } | 549 | } |
@@ -610,9 +610,9 @@ bool QProcess::start( QStringList *env ) | |||
610 | if ( (comms & Stdin) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStdin ) == -1 ) { | 610 | if ( (comms & Stdin) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStdin ) == -1 ) { |
611 | return FALSE; | 611 | return FALSE; |
612 | } | 612 | } |
613 | if ( (comms & Stderr) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStderr ) == -1 ) { | 613 | if ( (comms & Stderr) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStderr ) == -1 ) { |
614 | return FALSE; | 614 | return FALSE; |
615 | } | 615 | } |
616 | if ( (comms & Stdout) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStdout ) == -1 ) { | 616 | if ( (comms & Stdout) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStdout ) == -1 ) { |
617 | return FALSE; | 617 | return FALSE; |
618 | } | 618 | } |
@@ -623,5 +623,5 @@ bool QProcess::start( QStringList *env ) | |||
623 | if ( pipe( fd ) < 0 ) { | 623 | if ( pipe( fd ) < 0 ) { |
624 | // non critical error, go on | 624 | // non critical error, go on |
625 | fd[0] = 0; | 625 | fd[0] = 0; |
626 | fd[1] = 0; | 626 | fd[1] = 0; |
627 | } | 627 | } |
@@ -633,4 +633,4 @@ bool QProcess::start( QStringList *env ) | |||
633 | for ( QStringList::Iterator it = _arguments.begin(); it != _arguments.end(); ++it ) { | 633 | for ( QStringList::Iterator it = _arguments.begin(); it != _arguments.end(); ++it ) { |
634 | arglistQ[i] = (*it).local8Bit(); | 634 | arglistQ[i] = (*it).local8Bit(); |
635 | arglist[i] = arglistQ[i]; | 635 | arglist[i] = arglistQ[i]; |
636 | #if defined(QT_QPROCESS_DEBUG) | 636 | #if defined(QT_QPROCESS_DEBUG) |
@@ -638,3 +638,3 @@ bool QProcess::start( QStringList *env ) | |||
638 | #endif | 638 | #endif |
639 | i++; | 639 | i++; |
640 | } | 640 | } |
@@ -645,4 +645,4 @@ bool QProcess::start( QStringList *env ) | |||
645 | if ( d->procManager == 0 ) { | 645 | if ( d->procManager == 0 ) { |
646 | d->procManager = new QProcessManager; | 646 | d->procManager = new QProcessManager; |
647 | qprocess_cleanup_procmanager.add( &d->procManager ); | 647 | qprocess_cleanup_procmanager.add( &d->procManager ); |
648 | } | 648 | } |
@@ -653,87 +653,87 @@ bool QProcess::start( QStringList *env ) | |||
653 | if ( pid == 0 ) { | 653 | if ( pid == 0 ) { |
654 | // child | 654 | // child |
655 | d->closeOpenSocketsForChild(); | 655 | d->closeOpenSocketsForChild(); |
656 | if ( comms & Stdin ) { | 656 | if ( comms & Stdin ) { |
657 | ::close( sStdin[1] ); | 657 | ::close( sStdin[1] ); |
658 | ::dup2( sStdin[0], STDIN_FILENO ); | 658 | ::dup2( sStdin[0], STDIN_FILENO ); |
659 | } | 659 | } |
660 | if ( comms & Stdout ) { | 660 | if ( comms & Stdout ) { |
661 | ::close( sStdout[0] ); | 661 | ::close( sStdout[0] ); |
662 | ::dup2( sStdout[1], STDOUT_FILENO ); | 662 | ::dup2( sStdout[1], STDOUT_FILENO ); |
663 | } | 663 | } |
664 | if ( comms & Stderr ) { | 664 | if ( comms & Stderr ) { |
665 | ::close( sStderr[0] ); | 665 | ::close( sStderr[0] ); |
666 | ::dup2( sStderr[1], STDERR_FILENO ); | 666 | ::dup2( sStderr[1], STDERR_FILENO ); |
667 | } | 667 | } |
668 | if ( comms & DupStderr ) { | 668 | if ( comms & DupStderr ) { |
669 | ::dup2( STDOUT_FILENO, STDERR_FILENO ); | 669 | ::dup2( STDOUT_FILENO, STDERR_FILENO ); |
670 | } | 670 | } |
671 | #ifndef QT_NO_DIR | 671 | #ifndef QT_NO_DIR |
672 | ::chdir( workingDir.absPath().latin1() ); | 672 | ::chdir( workingDir.absPath().latin1() ); |
673 | #endif | 673 | #endif |
674 | if ( fd[0] ) | 674 | if ( fd[0] ) |
675 | ::close( fd[0] ); | 675 | ::close( fd[0] ); |
676 | if ( fd[1] ) | 676 | if ( fd[1] ) |
677 | ::fcntl( fd[1], F_SETFD, FD_CLOEXEC ); // close on exec shows sucess | 677 | ::fcntl( fd[1], F_SETFD, FD_CLOEXEC ); // close on exec shows sucess |
678 | 678 | ||
679 | if ( env == 0 ) { // inherit environment and start process | 679 | if ( env == 0 ) { // inherit environment and start process |
680 | ::execvp( arglist[0], (char*const*)arglist ); // ### cast not nice | 680 | ::execvp( arglist[0], (char*const*)arglist ); // ### cast not nice |
681 | } else { // start process with environment settins as specified in env | 681 | } else { // start process with environment settins as specified in env |
682 | // construct the environment for exec | 682 | // construct the environment for exec |
683 | int numEntries = env->count(); | 683 | int numEntries = env->count(); |
684 | bool setLibraryPath = | 684 | bool setLibraryPath = |
685 | env->grep( QRegExp( "^LD_LIBRARY_PATH=" ) ).isEmpty() && | 685 | env->grep( QRegExp( "^LD_LIBRARY_PATH=" ) ).isEmpty() && |
686 | getenv( "LD_LIBRARY_PATH" ) != 0; | 686 | getenv( "LD_LIBRARY_PATH" ) != 0; |
687 | if ( setLibraryPath ) | 687 | if ( setLibraryPath ) |
688 | numEntries++; | 688 | numEntries++; |
689 | QCString *envlistQ = new QCString[ numEntries + 1 ]; | 689 | QCString *envlistQ = new QCString[ numEntries + 1 ]; |
690 | const char** envlist = new const char*[ numEntries + 1 ]; | 690 | const char** envlist = new const char*[ numEntries + 1 ]; |
691 | int i = 0; | 691 | int i = 0; |
692 | if ( setLibraryPath ) { | 692 | if ( setLibraryPath ) { |
693 | envlistQ[i] = QString( "LD_LIBRARY_PATH=%1" ).arg( getenv( "LD_LIBRARY_PATH" ) ).local8Bit(); | 693 | envlistQ[i] = QString( "LD_LIBRARY_PATH=%1" ).arg( getenv( "LD_LIBRARY_PATH" ) ).local8Bit(); |
694 | envlist[i] = envlistQ[i]; | 694 | envlist[i] = envlistQ[i]; |
695 | i++; | 695 | i++; |
696 | } | 696 | } |
697 | for ( QStringList::Iterator it = env->begin(); it != env->end(); ++it ) { | 697 | for ( QStringList::Iterator it = env->begin(); it != env->end(); ++it ) { |
698 | envlistQ[i] = (*it).local8Bit(); | 698 | envlistQ[i] = (*it).local8Bit(); |
699 | envlist[i] = envlistQ[i]; | 699 | envlist[i] = envlistQ[i]; |
700 | i++; | 700 | i++; |
701 | } | 701 | } |
702 | envlist[i] = 0; | 702 | envlist[i] = 0; |
703 | 703 | ||
704 | // look for the executable in the search path | 704 | // look for the executable in the search path |
705 | if ( _arguments.count()>0 && getenv("PATH")!=0 ) { | 705 | if ( _arguments.count()>0 && getenv("PATH")!=0 ) { |
706 | QString command = _arguments[0]; | 706 | QString command = _arguments[0]; |
707 | if ( !command.contains( '/' ) ) { | 707 | if ( !command.contains( '/' ) ) { |
708 | QStringList pathList = QStringList::split( ':', getenv( "PATH" ) ); | 708 | QStringList pathList = QStringList::split( ':', getenv( "PATH" ) ); |
709 | for (QStringList::Iterator it = pathList.begin(); it != pathList.end(); ++it ) { | 709 | for (QStringList::Iterator it = pathList.begin(); it != pathList.end(); ++it ) { |
710 | QString dir = *it; | 710 | QString dir = *it; |
711 | #ifdef Q_OS_MACX | 711 | #ifdef Q_OS_MACX |
712 | if(QFile::exists(dir + "/" + command + ".app")) //look in a bundle | 712 | if(QFile::exists(dir + "/" + command + ".app")) //look in a bundle |
713 | dir += "/" + command + ".app/Contents/MacOS"; | 713 | dir += "/" + command + ".app/Contents/MacOS"; |
714 | #endif | 714 | #endif |
715 | #ifndef QT_NO_DIR | 715 | #ifndef QT_NO_DIR |
716 | QFileInfo fileInfo( dir, command ); | 716 | QFileInfo fileInfo( dir, command ); |
717 | #else | 717 | #else |
718 | QFileInfo fileInfo( dir + "/" + command ); | 718 | QFileInfo fileInfo( dir + "/" + command ); |
719 | #endif | 719 | #endif |
720 | if ( fileInfo.isExecutable() ) { | 720 | if ( fileInfo.isExecutable() ) { |
721 | arglistQ[0] = fileInfo.filePath().local8Bit(); | 721 | arglistQ[0] = fileInfo.filePath().local8Bit(); |
722 | arglist[0] = arglistQ[0]; | 722 | arglist[0] = arglistQ[0]; |
723 | break; | 723 | break; |
724 | } | 724 | } |
725 | } | 725 | } |
726 | } | 726 | } |
727 | } | 727 | } |
728 | ::execve( arglist[0], (char*const*)arglist, (char*const*)envlist ); // ### casts not nice | 728 | ::execve( arglist[0], (char*const*)arglist, (char*const*)envlist ); // ### casts not nice |
729 | } | 729 | } |
730 | if ( fd[1] ) { | 730 | if ( fd[1] ) { |
731 | char buf = 0; | 731 | char buf = 0; |
732 | ::write( fd[1], &buf, 1 ); | 732 | ::write( fd[1], &buf, 1 ); |
733 | ::close( fd[1] ); | 733 | ::close( fd[1] ); |
734 | } | 734 | } |
735 | ::exit( -1 ); | 735 | ::exit( -1 ); |
736 | } else if ( pid == -1 ) { | 736 | } else if ( pid == -1 ) { |
737 | // error forking | 737 | // error forking |
738 | goto error; | 738 | goto error; |
739 | } | 739 | } |
@@ -742,19 +742,19 @@ bool QProcess::start( QStringList *env ) | |||
742 | if ( fd[1] ) | 742 | if ( fd[1] ) |
743 | ::close( fd[1] ); | 743 | ::close( fd[1] ); |
744 | if ( fd[0] ) { | 744 | if ( fd[0] ) { |
745 | char buf; | 745 | char buf; |
746 | for ( ;; ) { | 746 | for ( ;; ) { |
747 | int n = ::read( fd[0], &buf, 1 ); | 747 | int n = ::read( fd[0], &buf, 1 ); |
748 | if ( n==1 ) { | 748 | if ( n==1 ) { |
749 | // socket was not closed => error | 749 | // socket was not closed => error |
750 | d->proc = 0; | 750 | d->proc = 0; |
751 | goto error; | 751 | goto error; |
752 | } else if ( n==-1 ) { | 752 | } else if ( n==-1 ) { |
753 | if ( errno==EAGAIN || errno==EINTR ) | 753 | if ( errno==EAGAIN || errno==EINTR ) |
754 | // try it again | 754 | // try it again |
755 | continue; | 755 | continue; |
756 | } | 756 | } |
757 | break; | 757 | break; |
758 | } | 758 | } |
759 | ::close( fd[0] ); | 759 | ::close( fd[0] ); |
760 | } | 760 | } |
@@ -764,29 +764,29 @@ bool QProcess::start( QStringList *env ) | |||
764 | if ( comms & Stdin ) { | 764 | if ( comms & Stdin ) { |
765 | ::close( sStdin[0] ); | 765 | ::close( sStdin[0] ); |
766 | d->proc->socketStdin = sStdin[1]; | 766 | d->proc->socketStdin = sStdin[1]; |
767 | d->notifierStdin = new QSocketNotifier( sStdin[1], QSocketNotifier::Write ); | 767 | d->notifierStdin = new QSocketNotifier( sStdin[1], QSocketNotifier::Write ); |
768 | connect( d->notifierStdin, SIGNAL(activated(int)), | 768 | connect( d->notifierStdin, SIGNAL(activated(int)), |
769 | this, SLOT(socketWrite(int)) ); | 769 | this, SLOT(socketWrite(int)) ); |
770 | // setup notifiers for the sockets | 770 | // setup notifiers for the sockets |
771 | if ( !d->stdinBuf.isEmpty() ) { | 771 | if ( !d->stdinBuf.isEmpty() ) { |
772 | d->notifierStdin->setEnabled( TRUE ); | 772 | d->notifierStdin->setEnabled( TRUE ); |
773 | } | 773 | } |
774 | } | 774 | } |
775 | if ( comms & Stdout ) { | 775 | if ( comms & Stdout ) { |
776 | ::close( sStdout[1] ); | 776 | ::close( sStdout[1] ); |
777 | d->proc->socketStdout = sStdout[0]; | 777 | d->proc->socketStdout = sStdout[0]; |
778 | d->notifierStdout = new QSocketNotifier( sStdout[0], QSocketNotifier::Read ); | 778 | d->notifierStdout = new QSocketNotifier( sStdout[0], QSocketNotifier::Read ); |
779 | connect( d->notifierStdout, SIGNAL(activated(int)), | 779 | connect( d->notifierStdout, SIGNAL(activated(int)), |
780 | this, SLOT(socketRead(int)) ); | 780 | this, SLOT(socketRead(int)) ); |
781 | if ( ioRedirection ) | 781 | if ( ioRedirection ) |
782 | d->notifierStdout->setEnabled( TRUE ); | 782 | d->notifierStdout->setEnabled( TRUE ); |
783 | } | 783 | } |
784 | if ( comms & Stderr ) { | 784 | if ( comms & Stderr ) { |
785 | ::close( sStderr[1] ); | 785 | ::close( sStderr[1] ); |
786 | d->proc->socketStderr = sStderr[0]; | 786 | d->proc->socketStderr = sStderr[0]; |
787 | d->notifierStderr = new QSocketNotifier( sStderr[0], QSocketNotifier::Read ); | 787 | d->notifierStderr = new QSocketNotifier( sStderr[0], QSocketNotifier::Read ); |
788 | connect( d->notifierStderr, SIGNAL(activated(int)), | 788 | connect( d->notifierStderr, SIGNAL(activated(int)), |
789 | this, SLOT(socketRead(int)) ); | 789 | this, SLOT(socketRead(int)) ); |
790 | if ( ioRedirection ) | 790 | if ( ioRedirection ) |
791 | d->notifierStderr->setEnabled( TRUE ); | 791 | d->notifierStderr->setEnabled( TRUE ); |
792 | } | 792 | } |
@@ -803,14 +803,14 @@ error: | |||
803 | if ( d->procManager ) | 803 | if ( d->procManager ) |
804 | d->procManager->cleanup(); | 804 | d->procManager->cleanup(); |
805 | if ( comms & Stdin ) { | 805 | if ( comms & Stdin ) { |
806 | ::close( sStdin[1] ); | 806 | ::close( sStdin[1] ); |
807 | ::close( sStdin[0] ); | 807 | ::close( sStdin[0] ); |
808 | } | 808 | } |
809 | if ( comms & Stdout ) { | 809 | if ( comms & Stdout ) { |
810 | ::close( sStdout[0] ); | 810 | ::close( sStdout[0] ); |
811 | ::close( sStdout[1] ); | 811 | ::close( sStdout[1] ); |
812 | } | 812 | } |
813 | if ( comms & Stderr ) { | 813 | if ( comms & Stderr ) { |
814 | ::close( sStderr[0] ); | 814 | ::close( sStderr[0] ); |
815 | ::close( sStderr[1] ); | 815 | ::close( sStderr[1] ); |
816 | } | 816 | } |
@@ -837,3 +837,3 @@ void QProcess::tryTerminate() const | |||
837 | if ( d->proc != 0 ) | 837 | if ( d->proc != 0 ) |
838 | ::kill( d->proc->pid, SIGTERM ); | 838 | ::kill( d->proc->pid, SIGTERM ); |
839 | } | 839 | } |
@@ -867,3 +867,3 @@ void QProcess::kill() const | |||
867 | if ( d->proc != 0 ) | 867 | if ( d->proc != 0 ) |
868 | ::kill( d->proc->pid, SIGKILL ); | 868 | ::kill( d->proc->pid, SIGKILL ); |
869 | } | 869 | } |
@@ -881,6 +881,6 @@ bool QProcess::isRunning() const | |||
881 | #endif | 881 | #endif |
882 | return FALSE; | 882 | return FALSE; |
883 | } | 883 | } |
884 | if ( d->proc == 0 ) | 884 | if ( d->proc == 0 ) |
885 | return FALSE; | 885 | return FALSE; |
886 | int status; | 886 | int status; |
@@ -888,9 +888,9 @@ bool QProcess::isRunning() const | |||
888 | { | 888 | { |
889 | // compute the exit values | 889 | // compute the exit values |
890 | QProcess *that = (QProcess*)this; // mutable | 890 | QProcess *that = (QProcess*)this; // mutable |
891 | that->exitNormal = WIFEXITED( status ) != 0; | 891 | that->exitNormal = WIFEXITED( status ) != 0; |
892 | if ( exitNormal ) { | 892 | if ( exitNormal ) { |
893 | that->exitStat = (char)WEXITSTATUS( status ); | 893 | that->exitStat = (char)WEXITSTATUS( status ); |
894 | } | 894 | } |
895 | d->exitValuesCalculated = TRUE; | 895 | d->exitValuesCalculated = TRUE; |
896 | #if defined(QT_QPROCESS_DEBUG) | 896 | #if defined(QT_QPROCESS_DEBUG) |
@@ -898,3 +898,3 @@ bool QProcess::isRunning() const | |||
898 | #endif | 898 | #endif |
899 | return FALSE; | 899 | return FALSE; |
900 | } | 900 | } |
@@ -925,3 +925,3 @@ void QProcess::writeToStdin( const QByteArray& buf ) | |||
925 | if ( d->notifierStdin != 0 ) | 925 | if ( d->notifierStdin != 0 ) |
926 | d->notifierStdin->setEnabled( TRUE ); | 926 | d->notifierStdin->setEnabled( TRUE ); |
927 | } | 927 | } |
@@ -940,12 +940,12 @@ void QProcess::closeStdin() | |||
940 | if ( d->proc == 0 ) | 940 | if ( d->proc == 0 ) |
941 | return; | 941 | return; |
942 | if ( d->proc->socketStdin !=0 ) { | 942 | if ( d->proc->socketStdin !=0 ) { |
943 | while ( !d->stdinBuf.isEmpty() ) { | 943 | while ( !d->stdinBuf.isEmpty() ) { |
944 | delete d->stdinBuf.dequeue(); | 944 | delete d->stdinBuf.dequeue(); |
945 | } | 945 | } |
946 | delete d->notifierStdin; | 946 | delete d->notifierStdin; |
947 | d->notifierStdin = 0; | 947 | d->notifierStdin = 0; |
948 | if ( ::close( d->proc->socketStdin ) != 0 ) { | 948 | if ( ::close( d->proc->socketStdin ) != 0 ) { |
949 | owarn << "Could not close stdin of child process" << oendl; | 949 | owarn << "Could not close stdin of child process" << oendl; |
950 | } | 950 | } |
951 | #if defined(QT_QPROCESS_DEBUG) | 951 | #if defined(QT_QPROCESS_DEBUG) |
@@ -953,3 +953,3 @@ void QProcess::closeStdin() | |||
953 | #endif | 953 | #endif |
954 | d->proc->socketStdin = 0; | 954 | d->proc->socketStdin = 0; |
955 | } | 955 | } |
@@ -965,6 +965,6 @@ void QProcess::socketRead( int fd ) | |||
965 | if ( d->socketReadCalled ) { | 965 | if ( d->socketReadCalled ) { |
966 | // the slots that are connected to the readyRead...() signals might | 966 | // the slots that are connected to the readyRead...() signals might |
967 | // trigger a recursive call of socketRead(). Avoid this since you get a | 967 | // trigger a recursive call of socketRead(). Avoid this since you get a |
968 | // blocking read otherwise. | 968 | // blocking read otherwise. |
969 | return; | 969 | return; |
970 | } | 970 | } |
@@ -974,3 +974,3 @@ void QProcess::socketRead( int fd ) | |||
974 | if ( fd == 0 ) | 974 | if ( fd == 0 ) |
975 | return; | 975 | return; |
976 | const int bufsize = 4096; | 976 | const int bufsize = 4096; |
@@ -980,8 +980,8 @@ void QProcess::socketRead( int fd ) | |||
980 | if ( fd == d->proc->socketStdout ) { | 980 | if ( fd == d->proc->socketStdout ) { |
981 | buffer = &d->bufStdout; | 981 | buffer = &d->bufStdout; |
982 | } else if ( fd == d->proc->socketStderr ) { | 982 | } else if ( fd == d->proc->socketStderr ) { |
983 | buffer = &d->bufStderr; | 983 | buffer = &d->bufStderr; |
984 | } else { | 984 | } else { |
985 | // this case should never happen, but just to be safe | 985 | // this case should never happen, but just to be safe |
986 | return; | 986 | return; |
987 | } | 987 | } |
@@ -993,8 +993,8 @@ void QProcess::socketRead( int fd ) | |||
993 | if ( n > 0 ) | 993 | if ( n > 0 ) |
994 | buffer->resize( oldSize + n ); | 994 | buffer->resize( oldSize + n ); |
995 | else | 995 | else |
996 | buffer->resize( oldSize ); | 996 | buffer->resize( oldSize ); |
997 | // eof or error? | 997 | // eof or error? |
998 | if ( n == 0 || n == -1 ) { | 998 | if ( n == 0 || n == -1 ) { |
999 | if ( fd == d->proc->socketStdout ) { | 999 | if ( fd == d->proc->socketStdout ) { |
1000 | #if defined(QT_QPROCESS_DEBUG) | 1000 | #if defined(QT_QPROCESS_DEBUG) |
@@ -1002,9 +1002,9 @@ void QProcess::socketRead( int fd ) | |||
1002 | #endif | 1002 | #endif |
1003 | d->notifierStdout->setEnabled( FALSE ); | 1003 | d->notifierStdout->setEnabled( FALSE ); |
1004 | delete d->notifierStdout; | 1004 | delete d->notifierStdout; |
1005 | d->notifierStdout = 0; | 1005 | d->notifierStdout = 0; |
1006 | ::close( d->proc->socketStdout ); | 1006 | ::close( d->proc->socketStdout ); |
1007 | d->proc->socketStdout = 0; | 1007 | d->proc->socketStdout = 0; |
1008 | return; | 1008 | return; |
1009 | } else if ( fd == d->proc->socketStderr ) { | 1009 | } else if ( fd == d->proc->socketStderr ) { |
1010 | #if defined(QT_QPROCESS_DEBUG) | 1010 | #if defined(QT_QPROCESS_DEBUG) |
@@ -1012,9 +1012,9 @@ void QProcess::socketRead( int fd ) | |||
1012 | #endif | 1012 | #endif |
1013 | d->notifierStderr->setEnabled( FALSE ); | 1013 | d->notifierStderr->setEnabled( FALSE ); |
1014 | delete d->notifierStderr; | 1014 | delete d->notifierStderr; |
1015 | d->notifierStderr = 0; | 1015 | d->notifierStderr = 0; |
1016 | ::close( d->proc->socketStderr ); | 1016 | ::close( d->proc->socketStderr ); |
1017 | d->proc->socketStderr = 0; | 1017 | d->proc->socketStderr = 0; |
1018 | return; | 1018 | return; |
1019 | } | 1019 | } |
1020 | } | 1020 | } |
@@ -1022,9 +1022,9 @@ void QProcess::socketRead( int fd ) | |||
1022 | while ( n == bufsize ) { | 1022 | while ( n == bufsize ) { |
1023 | oldSize = buffer->size(); | 1023 | oldSize = buffer->size(); |
1024 | buffer->resize( oldSize + bufsize ); | 1024 | buffer->resize( oldSize + bufsize ); |
1025 | n = ::read( fd, buffer->data()+oldSize, bufsize ); | 1025 | n = ::read( fd, buffer->data()+oldSize, bufsize ); |
1026 | if ( n > 0 ) | 1026 | if ( n > 0 ) |
1027 | buffer->resize( oldSize + n ); | 1027 | buffer->resize( oldSize + n ); |
1028 | else | 1028 | else |
1029 | buffer->resize( oldSize ); | 1029 | buffer->resize( oldSize ); |
1030 | } | 1030 | } |
@@ -1034,12 +1034,12 @@ void QProcess::socketRead( int fd ) | |||
1034 | #if defined(QT_QPROCESS_DEBUG) | 1034 | #if defined(QT_QPROCESS_DEBUG) |
1035 | qDebug( "QProcess::socketRead(): %d bytes read from stdout (%d)", | 1035 | odebug << "QProcess::socketRead(): " << buffer->size()-oldSize << "bytes read from stdout (" |
1036 | buffer->size()-oldSize, fd ); | 1036 | << fd << ")" << oendl; |
1037 | #endif | 1037 | #endif |
1038 | emit readyReadStdout(); | 1038 | emit readyReadStdout(); |
1039 | } else if ( fd == d->proc->socketStderr ) { | 1039 | } else if ( fd == d->proc->socketStderr ) { |
1040 | #if defined(QT_QPROCESS_DEBUG) | 1040 | #if defined(QT_QPROCESS_DEBUG) |
1041 | qDebug( "QProcess::socketRead(): %d bytes read from stderr (%d)", | 1041 | odebug << "QProcess::socketRead(): " << buffer->size()-oldSize << " bytes read from stderr (" |
1042 | buffer->size()-oldSize, fd ); | 1042 | << fd << ")" << oendl; |
1043 | #endif | 1043 | #endif |
1044 | emit readyReadStderr(); | 1044 | emit readyReadStderr(); |
1045 | } | 1045 | } |
@@ -1056,6 +1056,6 @@ void QProcess::socketWrite( int fd ) | |||
1056 | if ( fd != d->proc->socketStdin || d->proc->socketStdin == 0 ) | 1056 | if ( fd != d->proc->socketStdin || d->proc->socketStdin == 0 ) |
1057 | return; | 1057 | return; |
1058 | if ( d->stdinBuf.isEmpty() ) { | 1058 | if ( d->stdinBuf.isEmpty() ) { |
1059 | d->notifierStdin->setEnabled( FALSE ); | 1059 | d->notifierStdin->setEnabled( FALSE ); |
1060 | return; | 1060 | return; |
1061 | } | 1061 | } |
@@ -1065,12 +1065,12 @@ void QProcess::socketWrite( int fd ) | |||
1065 | ssize_t ret = ::write( fd, | 1065 | ssize_t ret = ::write( fd, |
1066 | d->stdinBuf.head()->data() + d->stdinBufRead, | 1066 | d->stdinBuf.head()->data() + d->stdinBufRead, |
1067 | d->stdinBuf.head()->size() - d->stdinBufRead ); | 1067 | d->stdinBuf.head()->size() - d->stdinBufRead ); |
1068 | if ( ret > 0 ) | 1068 | if ( ret > 0 ) |
1069 | d->stdinBufRead += ret; | 1069 | d->stdinBufRead += ret; |
1070 | if ( d->stdinBufRead == (ssize_t)d->stdinBuf.head()->size() ) { | 1070 | if ( d->stdinBufRead == (ssize_t)d->stdinBuf.head()->size() ) { |
1071 | d->stdinBufRead = 0; | 1071 | d->stdinBufRead = 0; |
1072 | delete d->stdinBuf.dequeue(); | 1072 | delete d->stdinBuf.dequeue(); |
1073 | if ( wroteToStdinConnected && d->stdinBuf.isEmpty() ) | 1073 | if ( wroteToStdinConnected && d->stdinBuf.isEmpty() ) |
1074 | emit wroteToStdin(); | 1074 | emit wroteToStdin(); |
1075 | socketWrite( fd ); | 1075 | socketWrite( fd ); |
1076 | } | 1076 | } |
@@ -1107,11 +1107,11 @@ void QProcess::setIoRedirection( bool value ) | |||
1107 | if ( ioRedirection ) { | 1107 | if ( ioRedirection ) { |
1108 | if ( d->notifierStdout ) | 1108 | if ( d->notifierStdout ) |
1109 | d->notifierStdout->setEnabled( TRUE ); | 1109 | d->notifierStdout->setEnabled( TRUE ); |
1110 | if ( d->notifierStderr ) | 1110 | if ( d->notifierStderr ) |
1111 | d->notifierStderr->setEnabled( TRUE ); | 1111 | d->notifierStderr->setEnabled( TRUE ); |
1112 | } else { | 1112 | } else { |
1113 | if ( d->notifierStdout ) | 1113 | if ( d->notifierStdout ) |
1114 | d->notifierStdout->setEnabled( FALSE ); | 1114 | d->notifierStdout->setEnabled( FALSE ); |
1115 | if ( d->notifierStderr ) | 1115 | if ( d->notifierStderr ) |
1116 | d->notifierStderr->setEnabled( FALSE ); | 1116 | d->notifierStderr->setEnabled( FALSE ); |
1117 | } | 1117 | } |
@@ -1154,3 +1154,3 @@ QProcess::PID QProcess::processIdentifier() | |||
1154 | if ( d->proc == 0 ) | 1154 | if ( d->proc == 0 ) |
1155 | return -1; | 1155 | return -1; |
1156 | return d->proc->pid; | 1156 | return d->proc->pid; |
@@ -1161,3 +1161,3 @@ int QProcess::priority() const | |||
1161 | if ( d->proc ) | 1161 | if ( d->proc ) |
1162 | return getpriority(PRIO_PROCESS,d->proc->pid); | 1162 | return getpriority(PRIO_PROCESS,d->proc->pid); |
1163 | return 0; | 1163 | return 0; |
@@ -1168,3 +1168,3 @@ void QProcess::setPriority(int p) | |||
1168 | if ( d->proc ) | 1168 | if ( d->proc ) |
1169 | setpriority(PRIO_PROCESS,d->proc->pid,p); | 1169 | setpriority(PRIO_PROCESS,d->proc->pid,p); |
1170 | } | 1170 | } |
diff --git a/core/launcher/screensaver.cpp b/core/launcher/screensaver.cpp index a7d23c4..f818d62 100644 --- a/core/launcher/screensaver.cpp +++ b/core/launcher/screensaver.cpp | |||
@@ -7,2 +7,3 @@ | |||
7 | #include <opie2/odevice.h> | 7 | #include <opie2/odevice.h> |
8 | #include <opie2/odebug.h> | ||
8 | 9 | ||
@@ -14,32 +15,32 @@ using namespace Opie::Core; | |||
14 | OpieScreenSaver::OpieScreenSaver ( ) | 15 | OpieScreenSaver::OpieScreenSaver ( ) |
15 | : QObject ( 0, "screensaver" ), QWSScreenSaver ( ) | 16 | : QObject ( 0, "screensaver" ), QWSScreenSaver ( ) |
16 | { | 17 | { |
17 | m_disable_suspend = 100; | 18 | m_disable_suspend = 100; |
18 | m_enable_dim = false; | 19 | m_enable_dim = false; |
19 | m_enable_lightoff = false; | 20 | m_enable_lightoff = false; |
20 | m_enable_suspend = false; | 21 | m_enable_suspend = false; |
21 | m_onlylcdoff = false; | 22 | m_onlylcdoff = false; |
22 | 23 | ||
23 | m_enable_dim_ac = false; | 24 | m_enable_dim_ac = false; |
24 | m_enable_lightoff_ac = false; | 25 | m_enable_lightoff_ac = false; |
25 | m_enable_suspend_ac = false; | 26 | m_enable_suspend_ac = false; |
26 | m_onlylcdoff_ac = false; | 27 | m_onlylcdoff_ac = false; |
27 | 28 | ||
28 | m_use_light_sensor = false; | 29 | m_use_light_sensor = false; |
29 | m_backlight_sensor = -1; | 30 | m_backlight_sensor = -1; |
30 | ::memset ( m_sensordata, 0xff, LS_Count * sizeof( m_sensordata [0] )); | 31 | ::memset ( m_sensordata, 0xff, LS_Count * sizeof( m_sensordata [0] )); |
31 | 32 | ||
32 | m_lcd_status = true; | 33 | m_lcd_status = true; |
33 | 34 | ||
34 | m_backlight_normal = -1; | 35 | m_backlight_normal = -1; |
35 | m_backlight_current = -1; | 36 | m_backlight_current = -1; |
36 | m_backlight_forcedoff = false; | 37 | m_backlight_forcedoff = false; |
37 | 38 | ||
38 | m_on_ac = false; | 39 | m_on_ac = false; |
39 | 40 | ||
40 | m_level = -1; | 41 | m_level = -1; |
41 | 42 | ||
42 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 43 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
43 | ODevice::inst ( )-> setDisplayStatus ( true ); | 44 | ODevice::inst ( )-> setDisplayStatus ( true ); |
44 | setBacklight ( -1 ); | 45 | setBacklight ( -1 ); |
45 | } | 46 | } |
@@ -52,10 +53,10 @@ void OpieScreenSaver::restore() | |||
52 | { | 53 | { |
53 | m_level = -1; | 54 | m_level = -1; |
54 | 55 | ||
55 | if ( !m_lcd_status ) { // We must have turned it off | 56 | if ( !m_lcd_status ) { // We must have turned it off |
56 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 57 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
57 | m_lcd_status = true; | 58 | m_lcd_status = true; |
58 | } | 59 | } |
59 | 60 | ||
60 | setBacklightInternal ( -1 ); | 61 | setBacklightInternal ( -1 ); |
61 | } | 62 | } |
@@ -72,48 +73,48 @@ bool OpieScreenSaver::save( int level ) | |||
72 | { | 73 | { |
73 | m_level = level; | 74 | m_level = level; |
74 | 75 | ||
75 | switch ( level ) { | 76 | switch ( level ) { |
76 | case 0: | 77 | case 0: |
77 | if (( m_on_ac && m_enable_dim_ac ) || | 78 | if (( m_on_ac && m_enable_dim_ac ) || |
78 | ( !m_on_ac && m_enable_dim )) { | 79 | ( !m_on_ac && m_enable_dim )) { |
79 | if (( m_disable_suspend > 0 ) && ( m_backlight_current > 1 ) && !m_use_light_sensor ) | 80 | if (( m_disable_suspend > 0 ) && ( m_backlight_current > 1 ) && !m_use_light_sensor ) |
80 | setBacklightInternal ( 1 ); // lowest non-off | 81 | setBacklightInternal ( 1 ); // lowest non-off |
81 | } | 82 | } |
82 | return true; | 83 | return true; |
83 | break; | 84 | break; |
84 | 85 | ||
85 | case 1: | 86 | case 1: |
86 | if (( m_on_ac && m_enable_lightoff_ac ) || | 87 | if (( m_on_ac && m_enable_lightoff_ac ) || |
87 | ( !m_on_ac && m_enable_lightoff )) { | 88 | ( !m_on_ac && m_enable_lightoff )) { |
88 | if ( m_disable_suspend > 1 ) | 89 | if ( m_disable_suspend > 1 ) |
89 | setBacklightInternal ( 0 ); // off | 90 | setBacklightInternal ( 0 ); // off |
90 | } | 91 | } |
91 | return true; | 92 | return true; |
92 | break; | 93 | break; |
93 | 94 | ||
94 | case 2: | 95 | case 2: |
95 | if (( m_on_ac && !m_enable_suspend_ac ) || | 96 | if (( m_on_ac && !m_enable_suspend_ac ) || |
96 | ( !m_on_ac && !m_enable_suspend )) { | 97 | ( !m_on_ac && !m_enable_suspend )) { |
97 | return true; | 98 | return true; |
98 | } | 99 | } |
99 | 100 | ||
100 | if (( m_on_ac && m_onlylcdoff_ac ) || | 101 | if (( m_on_ac && m_onlylcdoff_ac ) || |
101 | ( !m_on_ac && m_onlylcdoff )) { | 102 | ( !m_on_ac && m_onlylcdoff )) { |
102 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 103 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
103 | m_lcd_status = false; | 104 | m_lcd_status = false; |
104 | return true; | 105 | return true; |
105 | } | 106 | } |
106 | 107 | ||
107 | // We're going to suspend the whole machine | 108 | // We're going to suspend the whole machine |
108 | 109 | ||
109 | if (( m_disable_suspend > 2 ) && !Network::networkOnline ( )) { | 110 | if (( m_disable_suspend > 2 ) && !Network::networkOnline ( )) { |
110 | // TODO: why is this key F34 hard coded? -- schurig | 111 | // TODO: why is this key F34 hard coded? -- schurig |
111 | // Does this now only work an devices with a ODevice::filter? | 112 | // Does this now only work an devices with a ODevice::filter? |
112 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 113 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
113 | return true; | 114 | return true; |
114 | } | 115 | } |
115 | 116 | ||
116 | break; | 117 | break; |
117 | } | 118 | } |
118 | return false; | 119 | return false; |
119 | } | 120 | } |
@@ -136,37 +137,37 @@ void OpieScreenSaver::setIntervals ( int dim, int lightoff, int suspend ) | |||
136 | { | 137 | { |
137 | Config config ( "apm" ); | 138 | Config config ( "apm" ); |
138 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); | 139 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); |
139 | 140 | ||
140 | int v[ 4 ]; | 141 | int v[ 4 ]; |
141 | if ( dim < 0 ) | 142 | if ( dim < 0 ) |
142 | dim = config. readNumEntry ( "Dim", m_on_ac ? 60 : 30 ); | 143 | dim = config. readNumEntry ( "Dim", m_on_ac ? 60 : 30 ); |
143 | if ( lightoff < 0 ) | 144 | if ( lightoff < 0 ) |
144 | lightoff = config. readNumEntry ( "LightOff", m_on_ac ? 120 : 20 ); | 145 | lightoff = config. readNumEntry ( "LightOff", m_on_ac ? 120 : 20 ); |
145 | if ( suspend < 0 ) | 146 | if ( suspend < 0 ) |
146 | suspend = config. readNumEntry ( "Suspend", m_on_ac ? 0 : 60 ); | 147 | suspend = config. readNumEntry ( "Suspend", m_on_ac ? 0 : 60 ); |
147 | 148 | ||
148 | if ( m_on_ac ) { | 149 | if ( m_on_ac ) { |
149 | m_enable_dim_ac = ( dim > 0 ); | 150 | m_enable_dim_ac = ( dim > 0 ); |
150 | m_enable_lightoff_ac = ( lightoff > 0 ); | 151 | m_enable_lightoff_ac = ( lightoff > 0 ); |
151 | m_enable_suspend_ac = ( suspend > 0 ); | 152 | m_enable_suspend_ac = ( suspend > 0 ); |
152 | m_onlylcdoff_ac = config.readBoolEntry ( "LcdOffOnly", false ); | 153 | m_onlylcdoff_ac = config.readBoolEntry ( "LcdOffOnly", false ); |
153 | } | 154 | } |
154 | else { | 155 | else { |
155 | m_enable_dim = ( dim > 0 ); | 156 | m_enable_dim = ( dim > 0 ); |
156 | m_enable_lightoff = ( lightoff > 0 ); | 157 | m_enable_lightoff = ( lightoff > 0 ); |
157 | m_enable_suspend = ( suspend > 0 ); | 158 | m_enable_suspend = ( suspend > 0 ); |
158 | m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false ); | 159 | m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false ); |
159 | } | 160 | } |
160 | 161 | ||
161 | //odebug << "screen saver intervals: " << dim << " " << lightoff << " " << suspend << "" << oendl; | 162 | //odebug << "screen saver intervals: " << dim << " " << lightoff << " " << suspend << "" << oendl; |
162 | 163 | ||
163 | v [ 0 ] = QMAX( 1000 * dim, 100 ); | 164 | v [ 0 ] = QMAX( 1000 * dim, 100 ); |
164 | v [ 1 ] = QMAX( 1000 * lightoff, 100 ); | 165 | v [ 1 ] = QMAX( 1000 * lightoff, 100 ); |
165 | v [ 2 ] = QMAX( 1000 * suspend, 100 ); | 166 | v [ 2 ] = QMAX( 1000 * suspend, 100 ); |
166 | v [ 3 ] = 0; | 167 | v [ 3 ] = 0; |
167 | 168 | ||
168 | if ( !dim && !lightoff && !suspend ) | 169 | if ( !dim && !lightoff && !suspend ) |
169 | QWSServer::setScreenSaverInterval( 0 ); | 170 | QWSServer::setScreenSaverInterval( 0 ); |
170 | else | 171 | else |
171 | QWSServer::setScreenSaverIntervals( v ); | 172 | QWSServer::setScreenSaverIntervals( v ); |
172 | } | 173 | } |
@@ -182,3 +183,3 @@ void OpieScreenSaver::setInterval ( int interval ) | |||
182 | { | 183 | { |
183 | setIntervals ( -1, -1, interval ); | 184 | setIntervals ( -1, -1, interval ); |
184 | } | 185 | } |
@@ -188,5 +189,5 @@ void OpieScreenSaver::setMode ( int mode ) | |||
188 | { | 189 | { |
189 | if ( mode > m_disable_suspend ) | 190 | if ( mode > m_disable_suspend ) |
190 | setInterval ( -1 ); | 191 | setInterval ( -1 ); |
191 | m_disable_suspend = mode; | 192 | m_disable_suspend = mode; |
192 | } | 193 | } |
@@ -205,35 +206,36 @@ void OpieScreenSaver::setBacklight ( int bright ) | |||
205 | { | 206 | { |
206 | // Read from config | 207 | // Read from config |
207 | Config config ( "apm" ); | 208 | Config config ( "apm" ); |
208 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); | 209 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); |
209 | m_backlight_normal = config. readNumEntry ( "Brightness", m_on_ac ? 255 : 127 ); | 210 | m_backlight_normal = config. readNumEntry ( "Brightness", m_on_ac ? 255 : 127 ); |
210 | int contrast = config. readNumEntry ( "Contrast", 127); | 211 | int contrast = config. readNumEntry ( "Contrast", 127); |
211 | m_use_light_sensor = config. readBoolEntry ( "LightSensor", false ); | 212 | m_use_light_sensor = config. readBoolEntry ( "LightSensor", false ); |
212 | 213 | ||
213 | //qDebug ( "setBacklight: %d (norm: %d) (ls: %d)", bright, m_backlight_normal, m_use_light_sensor ? 1 : 0 ); | 214 | //odebug << "setBacklight: " << bright << " (norm: " << m_backlight_normal << ") (ls: " |
214 | 215 | // << ( m_use_light_sensor ? 1 : 0 ) << ")" << oendl; | |
215 | killTimers ( ); | 216 | |
216 | if (( bright < 0 ) && m_use_light_sensor ) { | 217 | killTimers ( ); |
217 | QStringList sl = config. readListEntry ( "LightSensorData", ';' ); | 218 | if (( bright < 0 ) && m_use_light_sensor ) { |
218 | 219 | QStringList sl = config. readListEntry ( "LightSensorData", ';' ); | |
219 | m_sensordata [LS_SensorMin] = 40; | 220 | |
220 | m_sensordata [LS_SensorMax] = 215; | 221 | m_sensordata [LS_SensorMin] = 40; |
221 | m_sensordata [LS_LightMin] = 1; | 222 | m_sensordata [LS_SensorMax] = 215; |
222 | m_sensordata [LS_LightMax] = 255; | 223 | m_sensordata [LS_LightMin] = 1; |
223 | m_sensordata [LS_Steps] = 12; | 224 | m_sensordata [LS_LightMax] = 255; |
224 | m_sensordata [LS_Interval] = 2000; | 225 | m_sensordata [LS_Steps] = 12; |
225 | 226 | m_sensordata [LS_Interval] = 2000; | |
226 | for ( uint i = 0; i < LS_Count; i++ ) { | 227 | |
227 | if ( i < sl. count ( )) | 228 | for ( uint i = 0; i < LS_Count; i++ ) { |
228 | m_sensordata [i] = sl [i]. toInt ( ); | 229 | if ( i < sl. count ( )) |
229 | } | 230 | m_sensordata [i] = sl [i]. toInt ( ); |
230 | if ( m_sensordata [LS_Steps] < 2 ) // sanity check to avoid SIGFPE | 231 | } |
231 | m_sensordata [LS_Steps] = 2; | 232 | if ( m_sensordata [LS_Steps] < 2 ) // sanity check to avoid SIGFPE |
232 | 233 | m_sensordata [LS_Steps] = 2; | |
233 | timerEvent ( 0 ); | 234 | |
234 | startTimer ( m_sensordata [LS_Interval] ); | 235 | timerEvent ( 0 ); |
235 | } | 236 | startTimer ( m_sensordata [LS_Interval] ); |
236 | 237 | } | |
237 | setBacklightInternal ( bright ); | 238 | |
238 | ODevice::inst ( )-> setDisplayContrast(contrast); | 239 | setBacklightInternal ( bright ); |
240 | ODevice::inst ( )-> setDisplayContrast(contrast); | ||
239 | } | 241 | } |
@@ -252,21 +254,21 @@ void OpieScreenSaver::setBacklightInternal ( int bright ) | |||
252 | { | 254 | { |
253 | if ( bright == -3 ) { | 255 | if ( bright == -3 ) { |
254 | // Forced on | 256 | // Forced on |
255 | m_backlight_forcedoff = false; | 257 | m_backlight_forcedoff = false; |
256 | bright = -1; | 258 | bright = -1; |
257 | } | 259 | } |
258 | if ( m_backlight_forcedoff && bright != -2 ) | 260 | if ( m_backlight_forcedoff && bright != -2 ) |
259 | return ; | 261 | return ; |
260 | if ( bright == -2 ) { | 262 | if ( bright == -2 ) { |
261 | // Toggle between off and on | 263 | // Toggle between off and on |
262 | bright = m_backlight_current ? 0 : -1; | 264 | bright = m_backlight_current ? 0 : -1; |
263 | m_backlight_forcedoff = !bright; | 265 | m_backlight_forcedoff = !bright; |
264 | } | 266 | } |
265 | if ( bright == -1 ) | 267 | if ( bright == -1 ) |
266 | bright = m_use_light_sensor ? m_backlight_sensor : m_backlight_normal; | 268 | bright = m_use_light_sensor ? m_backlight_sensor : m_backlight_normal; |
267 | 269 | ||
268 | if ( bright != m_backlight_current ) { | 270 | if ( bright != m_backlight_current ) { |
269 | ODevice::inst ( )-> setDisplayBrightness ( bright ); | 271 | ODevice::inst ( )-> setDisplayBrightness ( bright ); |
270 | m_backlight_current = bright; | 272 | m_backlight_current = bright; |
271 | } | 273 | } |
272 | } | 274 | } |
@@ -280,21 +282,23 @@ void OpieScreenSaver::timerEvent ( QTimerEvent * ) | |||
280 | { | 282 | { |
281 | int s = ODevice::inst ( )-> readLightSensor ( ) * 256 / ODevice::inst ( )-> lightSensorResolution ( ); | 283 | int s = ODevice::inst ( )-> readLightSensor ( ) * 256 / ODevice::inst ( )-> lightSensorResolution ( ); |
282 | 284 | ||
283 | if ( s < m_sensordata [LS_SensorMin] ) | 285 | if ( s < m_sensordata [LS_SensorMin] ) |
284 | m_backlight_sensor = m_sensordata [LS_LightMax]; | 286 | m_backlight_sensor = m_sensordata [LS_LightMax]; |
285 | else if ( s >= m_sensordata [LS_SensorMax] ) | 287 | else if ( s >= m_sensordata [LS_SensorMax] ) |
286 | m_backlight_sensor = m_sensordata [LS_LightMin]; | 288 | m_backlight_sensor = m_sensordata [LS_LightMin]; |
287 | else { | 289 | else { |
288 | int dx = m_sensordata [LS_SensorMax] - m_sensordata [LS_SensorMin]; | 290 | int dx = m_sensordata [LS_SensorMax] - m_sensordata [LS_SensorMin]; |
289 | int dy = m_sensordata [LS_LightMax] - m_sensordata [LS_LightMin]; | 291 | int dy = m_sensordata [LS_LightMax] - m_sensordata [LS_LightMin]; |
290 | 292 | ||
291 | int stepno = ( s - m_sensordata [LS_SensorMin] ) * m_sensordata [LS_Steps] / dx; // dx is never 0 | 293 | int stepno = ( s - m_sensordata [LS_SensorMin] ) * m_sensordata [LS_Steps] / dx; // dx is never 0 |
292 | 294 | ||
293 | m_backlight_sensor = m_sensordata [LS_LightMax] - dy * stepno / ( m_sensordata [LS_Steps] - 1 ); | 295 | m_backlight_sensor = m_sensordata [LS_LightMax] - dy * stepno / ( m_sensordata [LS_Steps] - 1 ); |
294 | } | 296 | } |
295 | 297 | ||
296 | //qDebug ( "f(%d) = %d [%d - %d] -> [%d - %d] / %d", s, m_backlight_sensor, m_sensordata [LS_SensorMin], m_sensordata [LS_SensorMax], m_sensordata [LS_LightMin], m_sensordata [LS_LightMax], m_sensordata [LS_Steps] ); | 298 | odebug << "f(" << s << ") = " << m_backlight_sensor << " [" << m_sensordata [LS_SensorMin] |
299 | << " - " << m_sensordata [LS_SensorMax] << " ] -> [" << m_sensordata [LS_LightMin] | ||
300 | << " - " << m_sensordata [LS_LightMax] << "] / " << m_sensordata [LS_Steps] << oendl; | ||
297 | 301 | ||
298 | if ( m_level <= 0 ) | 302 | if ( m_level <= 0 ) |
299 | setBacklightInternal ( -1 ); | 303 | setBacklightInternal ( -1 ); |
300 | } | 304 | } |
@@ -307,6 +311,6 @@ void OpieScreenSaver::setDisplayState ( bool on ) | |||
307 | { | 311 | { |
308 | if ( m_lcd_status != on ) { | 312 | if ( m_lcd_status != on ) { |
309 | ODevice::inst ( ) -> setDisplayStatus ( on ); | 313 | ODevice::inst ( ) -> setDisplayStatus ( on ); |
310 | m_lcd_status = on; | 314 | m_lcd_status = on; |
311 | } | 315 | } |
312 | } | 316 | } |
@@ -319,10 +323,10 @@ void OpieScreenSaver::powerStatusChanged ( PowerStatus ps ) | |||
319 | { | 323 | { |
320 | bool newonac = ( ps. acStatus ( ) == PowerStatus::Online ); | 324 | bool newonac = ( ps. acStatus ( ) == PowerStatus::Online ); |
321 | 325 | ||
322 | if ( newonac != m_on_ac ) { | 326 | if ( newonac != m_on_ac ) { |
323 | m_on_ac = newonac; | 327 | m_on_ac = newonac; |
324 | setInterval ( -1 ); | 328 | setInterval ( -1 ); |
325 | setBacklight ( -1 ); | 329 | setBacklight ( -1 ); |
326 | restore ( ); | 330 | restore ( ); |
327 | } | 331 | } |
328 | } | 332 | } |
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index b9fa1e5..950032d 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp | |||
@@ -80,12 +80,12 @@ static QWidget *calibrate(bool) | |||
80 | static QWidget *new##T( bool maximized ) { \ | 80 | static QWidget *new##T( bool maximized ) { \ |
81 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ | 81 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ |
82 | if ( maximized ) { \ | 82 | if ( maximized ) { \ |
83 | if ( qApp->desktop()->width() <= 350 ) { \ | 83 | if ( qApp->desktop()->width() <= 350 ) { \ |
84 | w->showMaximized(); \ | 84 | w->showMaximized(); \ |
85 | } else { \ | 85 | } else { \ |
86 | w->resize( QSize( 300, 300 ) ); \ | 86 | w->resize( QSize( 300, 300 ) ); \ |
87 | } \ | 87 | } \ |
88 | } \ | 88 | } \ |
89 | w->show(); \ | 89 | w->show(); \ |
90 | return w; \ | 90 | return w; \ |
91 | } | 91 | } |
@@ -109,10 +109,10 @@ static Global::Command builtins[] = { | |||
109 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) | 109 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) |
110 | { "calibrate", calibrate, 1, 0 }, // No tr | 110 | { "calibrate", calibrate, 1, 0 }, // No tr |
111 | #endif | 111 | #endif |
112 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) | 112 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) |
113 | { "shutdown", Global::shutdown, 1, 0 }, // No tr | 113 | { "shutdown", Global::shutdown, 1, 0 }, // No tr |
114 | // { "run", run, 1, 0 }, // No tr | 114 | // { "run", run, 1, 0 }, // No tr |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | { 0, calibrate,0, 0 }, | 117 | { 0, calibrate, 0, 0 }, |
118 | }; | 118 | }; |
@@ -168,3 +168,3 @@ Server::Server() : | |||
168 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), | 168 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), |
169 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); | 169 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); |
170 | 170 | ||
@@ -172,3 +172,3 @@ Server::Server() : | |||
172 | connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 172 | connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
173 | this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); | 173 | this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); |
174 | 174 | ||
@@ -204,16 +204,16 @@ static bool hasVisibleWindow(const QString& clientname, bool partial) | |||
204 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 204 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
205 | if ( w->client()->identity() == clientname ) { | 205 | if ( w->client()->identity() == clientname ) { |
206 | if ( partial && !w->isFullyObscured() ) | 206 | if ( partial && !w->isFullyObscured() ) |
207 | return TRUE; | 207 | return TRUE; |
208 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { | 208 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { |
209 | # if QT_VERSION < 0x030000 | 209 | # if QT_VERSION < 0x030000 |
210 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, | 210 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, |
211 | QSize(qt_screen->width(),qt_screen->height()) ); | 211 | QSize(qt_screen->width(),qt_screen->height()) ); |
212 | # else | 212 | # else |
213 | QRect mwr = qt_maxWindowRect; | 213 | QRect mwr = qt_maxWindowRect; |
214 | # endif | 214 | # endif |
215 | if ( mwr.contains(w->requested().boundingRect()) ) | 215 | if ( mwr.contains(w->requested().boundingRect()) ) |
216 | return TRUE; | 216 | return TRUE; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
@@ -228,5 +228,5 @@ void Server::activate(const ODeviceButton* button, bool held) | |||
228 | if ( held ) { | 228 | if ( held ) { |
229 | om = button->heldAction(); | 229 | om = button->heldAction(); |
230 | } else { | 230 | } else { |
231 | om = button->pressedAction(); | 231 | om = button->pressedAction(); |
232 | } | 232 | } |
@@ -241,12 +241,12 @@ void Server::activate(const ODeviceButton* button, bool held) | |||
241 | if ( !sr.isNull() ) { | 241 | if ( !sr.isNull() ) { |
242 | QString app = sr.app(); | 242 | QString app = sr.app(); |
243 | bool vis = hasVisibleWindow(app, app != "qpe"); | 243 | bool vis = hasVisibleWindow(app, app != "qpe"); |
244 | if ( sr.message() == "raise()" && vis ) { | 244 | if ( sr.message() == "raise()" && vis ) { |
245 | sr.setMessage("nextView()"); | 245 | sr.setMessage("nextView()"); |
246 | } else { | 246 | } else { |
247 | // "back door" | 247 | // "back door" |
248 | sr << (int)vis; | 248 | sr << (int)vis; |
249 | } | 249 | } |
250 | 250 | ||
251 | sr.send(); | 251 | sr.send(); |
252 | } | 252 | } |
@@ -294,10 +294,10 @@ bool Server::setKeyboardLayout( const QString &kb ) | |||
294 | if ( kb == "us101" ) { // No tr | 294 | if ( kb == "us101" ) { // No tr |
295 | om = 0; | 295 | om = 0; |
296 | } else if ( kb == "jp109" ) { | 296 | } else if ( kb == "jp109" ) { |
297 | om = new QIntDict<QWSServer::KeyMap>(37); | 297 | om = new QIntDict<QWSServer::KeyMap>(37); |
298 | const KeyOverride *k = jp109keys; | 298 | const KeyOverride *k = jp109keys; |
299 | while ( k->scan_code ) { | 299 | while ( k->scan_code ) { |
300 | om->insert( k->scan_code, &k->map ); | 300 | om->insert( k->scan_code, &k->map ); |
301 | k++; | 301 | k++; |
302 | } | 302 | } |
303 | } | 303 | } |
@@ -315,6 +315,6 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
315 | if ( msg == "securityChanged()" ) { | 315 | if ( msg == "securityChanged()" ) { |
316 | if ( transferServer ) | 316 | if ( transferServer ) |
317 | transferServer->authorizeConnections(); | 317 | transferServer->authorizeConnections(); |
318 | if ( qcopBridge ) | 318 | if ( qcopBridge ) |
319 | qcopBridge->authorizeConnections(); | 319 | qcopBridge->authorizeConnections(); |
320 | } | 320 | } |
@@ -323,5 +323,5 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
323 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { | 323 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { |
324 | int mode, pid; | 324 | int mode, pid; |
325 | stream >> mode >> pid; | 325 | stream >> mode >> pid; |
326 | tsmMonitor->setTempMode(mode, pid); | 326 | tsmMonitor->setTempMode(mode, pid); |
327 | } | 327 | } |
@@ -329,48 +329,48 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
329 | else if ( msg == "linkChanged(QString)" ) { | 329 | else if ( msg == "linkChanged(QString)" ) { |
330 | QString link; | 330 | QString link; |
331 | stream >> link; | 331 | stream >> link; |
332 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; | 332 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; |
333 | docList->linkChanged(link); | 333 | docList->linkChanged(link); |
334 | } else if ( msg == "serviceChanged(QString)" ) { | 334 | } else if ( msg == "serviceChanged(QString)" ) { |
335 | MimeType::updateApplications(); | 335 | MimeType::updateApplications(); |
336 | } else if ( msg == "mkdir(QString)" ) { | 336 | } else if ( msg == "mkdir(QString)" ) { |
337 | QString dir; | 337 | QString dir; |
338 | stream >> dir; | 338 | stream >> dir; |
339 | if ( !dir.isEmpty() ) | 339 | if ( !dir.isEmpty() ) |
340 | mkdir( dir ); | 340 | mkdir( dir ); |
341 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 341 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
342 | QString baseFile, sigFile; | 342 | QString baseFile, sigFile; |
343 | stream >> baseFile >> sigFile; | 343 | stream >> baseFile >> sigFile; |
344 | QRsync::generateSignature( baseFile, sigFile ); | 344 | QRsync::generateSignature( baseFile, sigFile ); |
345 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 345 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
346 | QString baseFile, sigFile, deltaFile; | 346 | QString baseFile, sigFile, deltaFile; |
347 | stream >> baseFile >> sigFile >> deltaFile; | 347 | stream >> baseFile >> sigFile >> deltaFile; |
348 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 348 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
349 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 349 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
350 | QString baseFile, deltaFile; | 350 | QString baseFile, deltaFile; |
351 | stream >> baseFile >> deltaFile; | 351 | stream >> baseFile >> deltaFile; |
352 | if ( !QFile::exists( baseFile ) ) { | 352 | if ( !QFile::exists( baseFile ) ) { |
353 | QFile f( baseFile ); | 353 | QFile f( baseFile ); |
354 | f.open( IO_WriteOnly ); | 354 | f.open( IO_WriteOnly ); |
355 | f.close(); | 355 | f.close(); |
356 | } | 356 | } |
357 | QRsync::applyDiff( baseFile, deltaFile ); | 357 | QRsync::applyDiff( baseFile, deltaFile ); |
358 | #ifndef QT_NO_COP | 358 | #ifndef QT_NO_COP |
359 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 359 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
360 | e << baseFile; | 360 | e << baseFile; |
361 | #endif | 361 | #endif |
362 | } else if ( msg == "rdiffCleanup()" ) { | 362 | } else if ( msg == "rdiffCleanup()" ) { |
363 | mkdir( "/tmp/rdiff" ); | 363 | mkdir( "/tmp/rdiff" ); |
364 | QDir dir; | 364 | QDir dir; |
365 | dir.setPath( "/tmp/rdiff" ); | 365 | dir.setPath( "/tmp/rdiff" ); |
366 | QStringList entries = dir.entryList(); | 366 | QStringList entries = dir.entryList(); |
367 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 367 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
368 | dir.remove( *it ); | 368 | dir.remove( *it ); |
369 | } else if ( msg == "sendHandshakeInfo()" ) { | 369 | } else if ( msg == "sendHandshakeInfo()" ) { |
370 | QString home = getenv( "HOME" ); | 370 | QString home = getenv( "HOME" ); |
371 | #ifndef QT_NO_COP | 371 | #ifndef QT_NO_COP |
372 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 372 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
373 | e << home; | 373 | e << home; |
374 | int locked = (int) ServerApplication::screenLocked(); | 374 | int locked = (int) ServerApplication::screenLocked(); |
375 | e << locked; | 375 | e << locked; |
376 | #endif | 376 | #endif |
@@ -385,68 +385,68 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
385 | else if ( msg == "sendVersionInfo()" ) { | 385 | else if ( msg == "sendVersionInfo()" ) { |
386 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); | 386 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); |
387 | /* ### FIXME Architecture ### */ | 387 | /* ### FIXME Architecture ### */ |
388 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; | 388 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; |
389 | } else if ( msg == "sendCardInfo()" ) { | 389 | } else if ( msg == "sendCardInfo()" ) { |
390 | #ifndef QT_NO_COP | 390 | #ifndef QT_NO_COP |
391 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 391 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
392 | #endif | 392 | #endif |
393 | storage->update(); | 393 | storage->update(); |
394 | const QList<FileSystem> &fs = storage->fileSystems(); | 394 | const QList<FileSystem> &fs = storage->fileSystems(); |
395 | QListIterator<FileSystem> it ( fs ); | 395 | QListIterator<FileSystem> it ( fs ); |
396 | QString s; | 396 | QString s; |
397 | QString homeDir = getenv("HOME"); | 397 | QString homeDir = getenv("HOME"); |
398 | QString homeFs, homeFsPath; | 398 | QString homeFs, homeFsPath; |
399 | for ( ; it.current(); ++it ) { | 399 | for ( ; it.current(); ++it ) { |
400 | int k4 = (*it)->blockSize()/256; | 400 | int k4 = (*it)->blockSize()/256; |
401 | if ( (*it)->isRemovable() ) { | 401 | if ( (*it)->isRemovable() ) { |
402 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr | 402 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr |
403 | + QString::number( (*it)->availBlocks() * k4/4 ) | 403 | + QString::number( (*it)->availBlocks() * k4/4 ) |
404 | + "K " + (*it)->options() + ";"; | 404 | + "K " + (*it)->options() + ";"; |
405 | } else if ( homeDir.contains( (*it)->path() ) && | 405 | } else if ( homeDir.contains( (*it)->path() ) && |
406 | (*it)->path().length() > homeFsPath.length() ) { | 406 | (*it)->path().length() > homeFsPath.length() ) { |
407 | homeFsPath = (*it)->path(); | 407 | homeFsPath = (*it)->path(); |
408 | homeFs = | 408 | homeFs = |
409 | (*it)->name() + "=" + homeDir + "/Documents " // No tr | 409 | (*it)->name() + "=" + homeDir + "/Documents " // No tr |
410 | + QString::number( (*it)->availBlocks() * k4/4 ) | 410 | + QString::number( (*it)->availBlocks() * k4/4 ) |
411 | + "K " + (*it)->options() + ";"; | 411 | + "K " + (*it)->options() + ";"; |
412 | } | 412 | } |
413 | } | 413 | } |
414 | if ( !homeFs.isEmpty() ) | 414 | if ( !homeFs.isEmpty() ) |
415 | s += homeFs; | 415 | s += homeFs; |
416 | 416 | ||
417 | #ifndef QT_NO_COP | 417 | #ifndef QT_NO_COP |
418 | e << s; | 418 | e << s; |
419 | #endif | 419 | #endif |
420 | } else if ( msg == "sendSyncDate(QString)" ) { | 420 | } else if ( msg == "sendSyncDate(QString)" ) { |
421 | QString app; | 421 | QString app; |
422 | stream >> app; | 422 | stream >> app; |
423 | Config cfg( "qpe" ); | 423 | Config cfg( "qpe" ); |
424 | cfg.setGroup("SyncDate"); | 424 | cfg.setGroup("SyncDate"); |
425 | #ifndef QT_NO_COP | 425 | #ifndef QT_NO_COP |
426 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 426 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
427 | e << app << cfg.readEntry( app ); | 427 | e << app << cfg.readEntry( app ); |
428 | #endif | 428 | #endif |
429 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 429 | //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " |
430 | //cfg.readEntry( app ).latin1() ); | 430 | // << cfg.readEntry( app ).latin1() << oendl; |
431 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 431 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
432 | QString app, date; | 432 | QString app, date; |
433 | stream >> app >> date; | 433 | stream >> app >> date; |
434 | Config cfg( "qpe" ); | 434 | Config cfg( "qpe" ); |
435 | cfg.setGroup("SyncDate"); | 435 | cfg.setGroup("SyncDate"); |
436 | cfg.writeEntry( app, date ); | 436 | cfg.writeEntry( app, date ); |
437 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; | 437 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; |
438 | } else if ( msg == "startSync(QString)" ) { | 438 | } else if ( msg == "startSync(QString)" ) { |
439 | QString what; | 439 | QString what; |
440 | stream >> what; | 440 | stream >> what; |
441 | delete syncDialog; | 441 | delete syncDialog; |
442 | syncDialog = new SyncDialog( this, what ); | 442 | syncDialog = new SyncDialog( this, what ); |
443 | syncDialog->show(); | 443 | syncDialog->show(); |
444 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); | 444 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); |
445 | } else if ( msg == "stopSync()") { | 445 | } else if ( msg == "stopSync()") { |
446 | delete syncDialog; | 446 | delete syncDialog; |
447 | syncDialog = 0; | 447 | syncDialog = 0; |
448 | } else if (msg == "restoreDone(QString)") { | 448 | } else if (msg == "restoreDone(QString)") { |
449 | docList->restoreDone(); | 449 | docList->restoreDone(); |
450 | } else if ( msg == "getAllDocLinks()" ) { | 450 | } else if ( msg == "getAllDocLinks()" ) { |
451 | docList->sendAllDocLinks(); | 451 | docList->sendAllDocLinks(); |
452 | } | 452 | } |
@@ -454,27 +454,27 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data) | |||
454 | else if ( msg == "setMouseProto(QString)" ) { | 454 | else if ( msg == "setMouseProto(QString)" ) { |
455 | QString mice; | 455 | QString mice; |
456 | stream >> mice; | 456 | stream >> mice; |
457 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 457 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
458 | qwsServer->openMouse(); | 458 | qwsServer->openMouse(); |
459 | } else if ( msg == "setKeyboard(QString)" ) { | 459 | } else if ( msg == "setKeyboard(QString)" ) { |
460 | QString kb; | 460 | QString kb; |
461 | stream >> kb; | 461 | stream >> kb; |
462 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 462 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
463 | qwsServer->openKeyboard(); | 463 | qwsServer->openKeyboard(); |
464 | 464 | ||
465 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { | 465 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { |
466 | int delay, period; | 466 | int delay, period; |
467 | stream >> delay >> period; | 467 | stream >> delay >> period; |
468 | qwsSetKeyboardAutoRepeat( delay, period ); | 468 | qwsSetKeyboardAutoRepeat( delay, period ); |
469 | Config cfg( "qpe" ); | 469 | Config cfg( "qpe" ); |
470 | cfg.setGroup("Keyboard"); | 470 | cfg.setGroup("Keyboard"); |
471 | cfg.writeEntry( "RepeatDelay", delay ); | 471 | cfg.writeEntry( "RepeatDelay", delay ); |
472 | cfg.writeEntry( "RepeatPeriod", period ); | 472 | cfg.writeEntry( "RepeatPeriod", period ); |
473 | } else if ( msg == "setKeyboardLayout(QString)" ) { | 473 | } else if ( msg == "setKeyboardLayout(QString)" ) { |
474 | QString kb; | 474 | QString kb; |
475 | stream >> kb; | 475 | stream >> kb; |
476 | setKeyboardLayout( kb ); | 476 | setKeyboardLayout( kb ); |
477 | Config cfg( "qpe" ); | 477 | Config cfg( "qpe" ); |
478 | cfg.setGroup("Keyboard"); | 478 | cfg.setGroup("Keyboard"); |
479 | cfg.writeEntry( "Layout", kb ); | 479 | cfg.writeEntry( "Layout", kb ); |
480 | } else if ( msg == "autoStart(QString)" ) { | 480 | } else if ( msg == "autoStart(QString)" ) { |
@@ -531,12 +531,12 @@ void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) | |||
531 | if ( msg == "reloadApps()" ) { | 531 | if ( msg == "reloadApps()" ) { |
532 | docList->reloadAppLnks(); | 532 | docList->reloadAppLnks(); |
533 | } else if ( msg == "soundAlarm()" ) { | 533 | } else if ( msg == "soundAlarm()" ) { |
534 | ServerApplication::soundAlarm(); | 534 | ServerApplication::soundAlarm(); |
535 | } | 535 | } |
536 | else if ( msg == "setLed(int,bool)" ) { | 536 | else if ( msg == "setLed(int,bool)" ) { |
537 | int led, status; | 537 | int led, status; |
538 | stream >> led >> status; | 538 | stream >> led >> status; |
539 | 539 | ||
540 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); | 540 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); |
541 | if ( ll. count ( )){ | 541 | if ( ll. count ( )) { |
542 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; | 542 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; |
@@ -562,3 +562,3 @@ bool Server::mkdir(const QString &localPath) | |||
562 | if (fullDir.exists()) | 562 | if (fullDir.exists()) |
563 | return true; | 563 | return true; |
564 | 564 | ||
@@ -575,3 +575,3 @@ bool Server::mkdir(const QString &localPath) | |||
575 | //odebug << "No seperators found in path " << localPath << "" << oendl; | 575 | //odebug << "No seperators found in path " << localPath << "" << oendl; |
576 | checkedPath = QDir::currentDirPath(); | 576 | checkedPath = QDir::currentDirPath(); |
577 | } | 577 | } |
@@ -579,21 +579,21 @@ bool Server::mkdir(const QString &localPath) | |||
579 | while (checkedPath != localPath) { | 579 | while (checkedPath != localPath) { |
580 | // no more seperators found, use the local path | 580 | // no more seperators found, use the local path |
581 | if (dirIndex == -1) | 581 | if (dirIndex == -1) |
582 | checkedPath = localPath; | 582 | checkedPath = localPath; |
583 | else { | 583 | else { |
584 | // the next directory to check | 584 | // the next directory to check |
585 | checkedPath = localPath.left(dirIndex) + "/"; | 585 | checkedPath = localPath.left(dirIndex) + "/"; |
586 | // advance the iterator; the next dir seperator | 586 | // advance the iterator; the next dir seperator |
587 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 587 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
588 | } | 588 | } |
589 | 589 | ||
590 | QDir checkDir(checkedPath); | 590 | QDir checkDir(checkedPath); |
591 | if (!checkDir.exists()) { | 591 | if (!checkDir.exists()) { |
592 | //odebug << "mkdir making dir " << checkedPath << "" << oendl; | 592 | //odebug << "mkdir making dir " << checkedPath << "" << oendl; |
593 | 593 | ||
594 | if (!checkDir.mkdir(checkedPath)) { | 594 | if (!checkDir.mkdir(checkedPath)) { |
595 | odebug << "Unable to make directory " << checkedPath << "" << oendl; | 595 | odebug << "Unable to make directory " << checkedPath << "" << oendl; |
596 | return FALSE; | 596 | return FALSE; |
597 | } | 597 | } |
598 | } | 598 | } |
599 | 599 | ||
@@ -611,25 +611,25 @@ void Server::startTransferServer() | |||
611 | if ( !qcopBridge ) { | 611 | if ( !qcopBridge ) { |
612 | // start qcop bridge server | 612 | // start qcop bridge server |
613 | qcopBridge = new QCopBridge( 4243 ); | 613 | qcopBridge = new QCopBridge( 4243 ); |
614 | if ( qcopBridge->ok() ) { | 614 | if ( qcopBridge->ok() ) { |
615 | // ... OK | 615 | // ... OK |
616 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), | 616 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), |
617 | this, SLOT(syncConnectionClosed(const QHostAddress&)) ); | 617 | this, SLOT(syncConnectionClosed(const QHostAddress&)) ); |
618 | } else { | 618 | } else { |
619 | delete qcopBridge; | 619 | delete qcopBridge; |
620 | qcopBridge = 0; | 620 | qcopBridge = 0; |
621 | } | 621 | } |
622 | } | 622 | } |
623 | if ( !transferServer ) { | 623 | if ( !transferServer ) { |
624 | // start transfer server | 624 | // start transfer server |
625 | transferServer = new TransferServer( 4242 ); | 625 | transferServer = new TransferServer( 4242 ); |
626 | if ( transferServer->ok() ) { | 626 | if ( transferServer->ok() ) { |
627 | // ... OK | 627 | // ... OK |
628 | } else { | 628 | } else { |
629 | delete transferServer; | 629 | delete transferServer; |
630 | transferServer = 0; | 630 | transferServer = 0; |
631 | } | 631 | } |
632 | } | 632 | } |
633 | if ( !transferServer || !qcopBridge ) | 633 | if ( !transferServer || !qcopBridge ) |
634 | tid_xfer = startTimer( 2000 ); | 634 | tid_xfer = startTimer( 2000 ); |
635 | } | 635 | } |
@@ -639,5 +639,5 @@ void Server::timerEvent( QTimerEvent *e ) | |||
639 | if ( e->timerId() == tid_xfer ) { | 639 | if ( e->timerId() == tid_xfer ) { |
640 | killTimer( tid_xfer ); | 640 | killTimer( tid_xfer ); |
641 | tid_xfer = 0; | 641 | tid_xfer = 0; |
642 | startTransferServer(); | 642 | startTransferServer(); |
643 | } | 643 | } |
@@ -646,7 +646,7 @@ void Server::timerEvent( QTimerEvent *e ) | |||
646 | else if ( e->timerId() == tid_today ) { | 646 | else if ( e->timerId() == tid_today ) { |
647 | QDate today = QDate::currentDate(); | 647 | QDate today = QDate::currentDate(); |
648 | if ( today != last_today_show ) { | 648 | if ( today != last_today_show ) { |
649 | last_today_show = today; | 649 | last_today_show = today; |
650 | Config cfg("today"); | 650 | Config cfg("today"); |
651 | cfg.setGroup("Start"); | 651 | cfg.setGroup("Start"); |
652 | #ifndef QPE_DEFAULT_TODAY_MODE | 652 | #ifndef QPE_DEFAULT_TODAY_MODE |
@@ -654,6 +654,6 @@ void Server::timerEvent( QTimerEvent *e ) | |||
654 | #endif | 654 | #endif |
655 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { | 655 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { |
656 | QCopEnvelope env(Service::channel("today"),"raise()"); | 656 | QCopEnvelope env(Service::channel("today"),"raise()"); |
657 | } | 657 | } |
658 | } | 658 | } |
659 | } | 659 | } |
@@ -683,5 +683,5 @@ void Server::pokeTimeMonitors() | |||
683 | for (const char* ch = tms.first(); ch; ch=tms.next()) { | 683 | for (const char* ch = tms.first(); ch; ch=tms.next()) { |
684 | QString t = getenv("TZ"); | 684 | QString t = getenv("TZ"); |
685 | QCopEnvelope e(ch, "timeChange(QString)"); | 685 | QCopEnvelope e(ch, "timeChange(QString)"); |
686 | e << t; | 686 | e << t; |
687 | } | 687 | } |
@@ -724,3 +724,3 @@ void Server::preloadApps() | |||
724 | #ifndef QT_NO_COP | 724 | #ifndef QT_NO_COP |
725 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 725 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
726 | #endif | 726 | #endif |
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 4b764e3..c3f936e 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -64,7 +64,7 @@ void TransferServer::authorizeConnections() | |||
64 | while ( it.current() ) { | 64 | while ( it.current() ) { |
65 | if ( !it.current()->verifyAuthorised() ) { | 65 | if ( !it.current()->verifyAuthorised() ) { |
66 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); | 66 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); |
67 | connections.removeRef( it.current() ); | 67 | connections.removeRef( it.current() ); |
68 | } else | 68 | } else |
69 | ++it; | 69 | ++it; |
70 | } | 70 | } |
@@ -106,5 +106,5 @@ QString SyncAuthentication::ownerName() | |||
106 | if (QFile::exists(vfilename)) { | 106 | if (QFile::exists(vfilename)) { |
107 | Contact c; | 107 | Contact c; |
108 | c = Contact::readVCard( vfilename )[0]; | 108 | c = Contact::readVCard( vfilename )[0]; |
109 | return c.fullName(); | 109 | return c.fullName(); |
110 | } | 110 | } |
@@ -129,14 +129,14 @@ int SyncAuthentication::isAuthorized(QHostAddress peeraddress) | |||
129 | Config cfg("Security"); | 129 | Config cfg("Security"); |
130 | cfg.setGroup("Sync"); | 130 | cfg.setGroup("Sync"); |
131 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); | 131 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); |
132 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); | 132 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); |
133 | 133 | ||
134 | // QHostAddress allowed; | 134 | // QHostAddress allowed; |
135 | // allowed.setAddress(allowedstr); | 135 | // allowed.setAddress(allowedstr); |
136 | // uint auth_peer = allowed.ip4Addr(); | 136 | // uint auth_peer = allowed.ip4Addr(); |
137 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); | 137 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); |
138 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined | 138 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined |
139 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); | 139 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); |
140 | 140 | ||
141 | return (peeraddress.ip4Addr() & mask) == auth_peer; | 141 | return (peeraddress.ip4Addr() & mask) == auth_peer; |
142 | } | 142 | } |
@@ -163,3 +163,3 @@ bool SyncAuthentication::checkPassword( const QString& password ) | |||
163 | if ( cpwd == "x" && spw ) | 163 | if ( cpwd == "x" && spw ) |
164 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); | 164 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); |
165 | 165 | ||
@@ -168,3 +168,3 @@ bool SyncAuthentication::checkPassword( const QString& password ) | |||
168 | if ( cpwd == cpassword ) | 168 | if ( cpwd == cpassword ) |
169 | return TRUE; | 169 | return TRUE; |
170 | #endif | 170 | #endif |
@@ -204,18 +204,18 @@ bool SyncAuthentication::checkPassword( const QString& password ) | |||
204 | if ( password.isEmpty() ) { | 204 | if ( password.isEmpty() ) { |
205 | if ( denials < 3 || now > lastdenial+600 ) { | 205 | if ( denials < 3 || now > lastdenial+600 ) { |
206 | QMessageBox unauth( | 206 | QMessageBox unauth( |
207 | tr("Sync Connection"), | 207 | tr("Sync Connection"), |
208 | tr("<p>An unauthorized system is requesting access to this device." | 208 | tr("<p>An unauthorized system is requesting access to this device." |
209 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " | 209 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " |
210 | "please upgrade or change the security setting to use IntelliSync." ), | 210 | "please upgrade or change the security setting to use IntelliSync." ), |
211 | QMessageBox::Warning, | 211 | QMessageBox::Warning, |
212 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 212 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
213 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 213 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
214 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); | 214 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); |
215 | unauth.exec(); | 215 | unauth.exec(); |
216 | 216 | ||
217 | denials++; | 217 | denials++; |
218 | lastdenial=now; | 218 | lastdenial=now; |
219 | } | 219 | } |
220 | return FALSE; | 220 | return FALSE; |
221 | 221 | ||
@@ -234,55 +234,55 @@ bool SyncAuthentication::checkPassword( const QString& password ) | |||
234 | if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { | 234 | if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { |
235 | Config cfg( "Security" ); | 235 | Config cfg( "Security" ); |
236 | cfg.setGroup("Sync"); | 236 | cfg.setGroup("Sync"); |
237 | QStringList pwds = cfg.readListEntry("Passwords",' '); | 237 | QStringList pwds = cfg.readListEntry("Passwords",' '); |
238 | for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) { | 238 | for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) { |
239 | #ifndef Q_OS_WIN32 | 239 | #ifndef Q_OS_WIN32 |
240 | QString cpassword = QString::fromLocal8Bit( | 240 | QString cpassword = QString::fromLocal8Bit( |
241 | crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) ); | 241 | crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) ); |
242 | #else | 242 | #else |
243 | // ### revise | 243 | // ### revise |
244 | QString cpassword(""); | 244 | QString cpassword(""); |
245 | #endif | 245 | #endif |
246 | if ( *it == cpassword ) { | 246 | if ( *it == cpassword ) { |
247 | lock--; | 247 | lock--; |
248 | return TRUE; | 248 | return TRUE; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | // Unrecognized system. Be careful... | 252 | // Unrecognized system. Be careful... |
253 | QMessageBox unrecbox( | 253 | QMessageBox unrecbox( |
254 | tr("Sync Connection"), | 254 | tr("Sync Connection"), |
255 | tr("<p>An unrecognized system is requesting access to this device." | 255 | tr( "<p>An unrecognized system is requesting access to this device." |
256 | "<p>If you have just initiated a Sync for the first time, this is normal."), | 256 | "<p>If you have just initiated a Sync for the first time, this is normal."), |
257 | QMessageBox::Warning, | 257 | QMessageBox::Warning, |
258 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, | 258 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, |
259 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 259 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
260 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Deny")); | 260 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Deny")); |
261 | unrecbox.setButtonText(QMessageBox::Yes, tr("Allow")); | 261 | unrecbox.setButtonText(QMessageBox::Yes, tr("Allow")); |
262 | 262 | ||
263 | if ( (denials > 2 && now < lastdenial+600) | 263 | if ( (denials > 2 && now < lastdenial+600) |
264 | || unrecbox.exec() != QMessageBox::Yes) | 264 | || unrecbox.exec() != QMessageBox::Yes) |
265 | { | 265 | { |
266 | denials++; | 266 | denials++; |
267 | lastdenial=now; | 267 | lastdenial=now; |
268 | lock--; | 268 | lock--; |
269 | return FALSE; | 269 | return FALSE; |
270 | } else { | 270 | } else { |
271 | const char salty[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/."; | 271 | const char salty[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/."; |
272 | char salt[2]; | 272 | char salt[2]; |
273 | salt[0]= salty[rand() % (sizeof(salty)-1)]; | 273 | salt[0]= salty[rand() % (sizeof(salty)-1)]; |
274 | salt[1]= salty[rand() % (sizeof(salty)-1)]; | 274 | salt[1]= salty[rand() % (sizeof(salty)-1)]; |
275 | #ifndef Q_OS_WIN32 | 275 | #ifndef Q_OS_WIN32 |
276 | QString cpassword = QString::fromLocal8Bit( | 276 | QString cpassword = QString::fromLocal8Bit( |
277 | crypt( password.mid(8).local8Bit(), salt ) ); | 277 | crypt( password.mid(8).local8Bit(), salt ) ); |
278 | #else | 278 | #else |
279 | //### revise | 279 | //### revise |
280 | QString cpassword(""); | 280 | QString cpassword(""); |
281 | #endif | 281 | #endif |
282 | denials=0; | 282 | denials=0; |
283 | pwds.prepend(cpassword); | 283 | pwds.prepend(cpassword); |
284 | cfg.writeEntry("Passwords",pwds,' '); | 284 | cfg.writeEntry("Passwords",pwds,' '); |
285 | lock--; | 285 | lock--; |
286 | return TRUE; | 286 | return TRUE; |
287 | } | 287 | } |
288 | } | 288 | } |
@@ -307,4 +307,4 @@ ServerPI::ServerPI( int socket, QObject *parent, const char* name ) | |||
307 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { | 307 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { |
308 | state = Forbidden; | 308 | state = Forbidden; |
309 | startTimer( 0 ); | 309 | startTimer( 0 ); |
310 | } else | 310 | } else |
@@ -312,28 +312,28 @@ ServerPI::ServerPI( int socket, QObject *parent, const char* name ) | |||
312 | { | 312 | { |
313 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); | 313 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); |
314 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 314 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
315 | 315 | ||
316 | passiv = FALSE; | 316 | passiv = FALSE; |
317 | for( int i = 0; i < 4; i++ ) | 317 | for( int i = 0; i < 4; i++ ) |
318 | wait[i] = FALSE; | 318 | wait[i] = FALSE; |
319 | 319 | ||
320 | send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr | 320 | send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr |
321 | state = Wait_USER; | 321 | state = Wait_USER; |
322 | 322 | ||
323 | dtp = new ServerDTP( this ); | 323 | dtp = new ServerDTP( this ); |
324 | connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); | 324 | connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); |
325 | connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); | 325 | connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); |
326 | connect( dtp, SIGNAL( error(int) ), SLOT( dtpError(int) ) ); | 326 | connect( dtp, SIGNAL( error(int) ), SLOT( dtpError(int) ) ); |
327 | 327 | ||
328 | 328 | ||
329 | directory = QDir::currentDirPath(); | 329 | directory = QDir::currentDirPath(); |
330 | 330 | ||
331 | static int p = 1024; | 331 | static int p = 1024; |
332 | 332 | ||
333 | while ( !serversocket || !serversocket->ok() ) { | 333 | while ( !serversocket || !serversocket->ok() ) { |
334 | delete serversocket; | 334 | delete serversocket; |
335 | serversocket = new ServerSocket( ++p, this ); | 335 | serversocket = new ServerSocket( ++p, this ); |
336 | } | 336 | } |
337 | connect( serversocket, SIGNAL( newIncomming(int) ), | 337 | connect( serversocket, SIGNAL( newIncomming(int) ), |
338 | SLOT( newConnection(int) ) ); | 338 | SLOT( newConnection(int) ) ); |
339 | } | 339 | } |
@@ -354,4 +354,4 @@ bool ServerPI::verifyAuthorised() | |||
354 | if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { | 354 | if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { |
355 | state = Forbidden; | 355 | state = Forbidden; |
356 | return FALSE; | 356 | return FALSE; |
357 | } | 357 | } |
@@ -376,3 +376,3 @@ void ServerPI::read() | |||
376 | while ( canReadLine() ) | 376 | while ( canReadLine() ) |
377 | process( readLine().stripWhiteSpace() ); | 377 | process( readLine().stripWhiteSpace() ); |
378 | } | 378 | } |
@@ -384,5 +384,5 @@ bool ServerPI::checkReadFile( const QString& file ) | |||
384 | if ( file[0] != "/" ) | 384 | if ( file[0] != "/" ) |
385 | filename = directory.path() + "/" + file; | 385 | filename = directory.path() + "/" + file; |
386 | else | 386 | else |
387 | filename = file; | 387 | filename = file; |
388 | 388 | ||
@@ -397,5 +397,5 @@ bool ServerPI::checkWriteFile( const QString& file ) | |||
397 | if ( file[0] != "/" ) | 397 | if ( file[0] != "/" ) |
398 | filename = directory.path() + "/" + file; | 398 | filename = directory.path() + "/" + file; |
399 | else | 399 | else |
400 | filename = file; | 400 | filename = file; |
401 | 401 | ||
@@ -404,4 +404,4 @@ bool ServerPI::checkWriteFile( const QString& file ) | |||
404 | if ( fi.exists() ) | 404 | if ( fi.exists() ) |
405 | if ( !QFile( filename ).remove() ) | 405 | if ( !QFile( filename ).remove() ) |
406 | return FALSE; | 406 | return FALSE; |
407 | return TRUE; | 407 | return TRUE; |
@@ -423,3 +423,3 @@ void ServerPI::process( const QString& message ) | |||
423 | if ( msg.count() >= 2 ) | 423 | if ( msg.count() >= 2 ) |
424 | arg = msg[1]; | 424 | arg = msg[1]; |
425 | 425 | ||
@@ -439,5 +439,5 @@ void ServerPI::process( const QString& message ) | |||
439 | if ( cmd == "QUIT" ) { | 439 | if ( cmd == "QUIT" ) { |
440 | send( "211 Good bye!" ); // No tr | 440 | send( "211 Good bye!" ); // No tr |
441 | close(); | 441 | close(); |
442 | return; | 442 | return; |
443 | } | 443 | } |
@@ -446,3 +446,3 @@ void ServerPI::process( const QString& message ) | |||
446 | if ( Connected == state ) | 446 | if ( Connected == state ) |
447 | return; | 447 | return; |
448 | 448 | ||
@@ -451,9 +451,9 @@ void ServerPI::process( const QString& message ) | |||
451 | 451 | ||
452 | if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) { | 452 | if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) { |
453 | send( "530 Please login with USER and PASS" ); // No tr | 453 | send( "530 Please login with USER and PASS" ); // No tr |
454 | return; | 454 | return; |
455 | } | 455 | } |
456 | send( "331 User name ok, need password" ); // No tr | 456 | send( "331 User name ok, need password" ); // No tr |
457 | state = Wait_PASS; | 457 | state = Wait_PASS; |
458 | return; | 458 | return; |
459 | } | 459 | } |
@@ -463,9 +463,9 @@ void ServerPI::process( const QString& message ) | |||
463 | 463 | ||
464 | if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) { | 464 | if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) { |
465 | send( "530 Please login with USER and PASS" ); // No tr | 465 | send( "530 Please login with USER and PASS" ); // No tr |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | send( "230 User logged in, proceed" ); // No tr | 468 | send( "230 User logged in, proceed" ); // No tr |
469 | state = Ready; | 469 | state = Ready; |
470 | return; | 470 | return; |
471 | } | 471 | } |
@@ -476,3 +476,3 @@ void ServerPI::process( const QString& message ) | |||
476 | if ( cmd != "STOR" ) | 476 | if ( cmd != "STOR" ) |
477 | storFileSize = -1; | 477 | storFileSize = -1; |
478 | 478 | ||
@@ -480,4 +480,4 @@ void ServerPI::process( const QString& message ) | |||
480 | if ( cmd == "ACCT" ) { | 480 | if ( cmd == "ACCT" ) { |
481 | // even wu-ftp does not support it | 481 | // even wu-ftp does not support it |
482 | send( "502 Command not implemented" ); // No tr | 482 | send( "502 Command not implemented" ); // No tr |
483 | } | 483 | } |
@@ -487,10 +487,10 @@ void ServerPI::process( const QString& message ) | |||
487 | 487 | ||
488 | if ( !args.isEmpty() ) { | 488 | if ( !args.isEmpty() ) { |
489 | if ( directory.cd( args, TRUE ) ) | 489 | if ( directory.cd( args, TRUE ) ) |
490 | send( "250 Requested file action okay, completed" ); // No tr | 490 | send( "250 Requested file action okay, completed" ); // No tr |
491 | else | 491 | else |
492 | send( "550 Requested action not taken" ); // No tr | 492 | send( "550 Requested action not taken" ); // No tr |
493 | } | 493 | } |
494 | else | 494 | else |
495 | send( "500 Syntax error, command unrecognized" ); // No tr | 495 | send( "500 Syntax error, command unrecognized" ); // No tr |
496 | } | 496 | } |
@@ -499,6 +499,6 @@ void ServerPI::process( const QString& message ) | |||
499 | else if ( cmd == "CDUP" ) { | 499 | else if ( cmd == "CDUP" ) { |
500 | if ( directory.cdUp() ) | 500 | if ( directory.cdUp() ) |
501 | send( "250 Requested file action okay, completed" ); // No tr | 501 | send( "250 Requested file action okay, completed" ); // No tr |
502 | else | 502 | else |
503 | send( "550 Requested action not taken" ); // No tr | 503 | send( "550 Requested action not taken" ); // No tr |
504 | } | 504 | } |
@@ -507,4 +507,4 @@ void ServerPI::process( const QString& message ) | |||
507 | else if ( cmd == "SMNT" ) { | 507 | else if ( cmd == "SMNT" ) { |
508 | // even wu-ftp does not support it | 508 | // even wu-ftp does not support it |
509 | send( "502 Command not implemented" ); // No tr | 509 | send( "502 Command not implemented" ); // No tr |
510 | } | 510 | } |
@@ -513,4 +513,4 @@ void ServerPI::process( const QString& message ) | |||
513 | else if ( cmd == "REIN" ) { | 513 | else if ( cmd == "REIN" ) { |
514 | // even wu-ftp does not support it | 514 | // even wu-ftp does not support it |
515 | send( "502 Command not implemented" ); // No tr | 515 | send( "502 Command not implemented" ); // No tr |
516 | } | 516 | } |
@@ -523,6 +523,6 @@ void ServerPI::process( const QString& message ) | |||
523 | else if ( cmd == "PORT" ) { | 523 | else if ( cmd == "PORT" ) { |
524 | if ( parsePort( arg ) ) | 524 | if ( parsePort( arg ) ) |
525 | send( "200 Command okay" ); // No tr | 525 | send( "200 Command okay" ); // No tr |
526 | else | 526 | else |
527 | send( "500 Syntax error, command unrecognized" ); // No tr | 527 | send( "500 Syntax error, command unrecognized" ); // No tr |
528 | } | 528 | } |
@@ -531,7 +531,7 @@ void ServerPI::process( const QString& message ) | |||
531 | else if ( cmd == "PASV" ) { | 531 | else if ( cmd == "PASV" ) { |
532 | passiv = TRUE; | 532 | passiv = TRUE; |
533 | send( "227 Entering Passive Mode (" // No tr | 533 | send( "227 Entering Passive Mode (" // No tr |
534 | + address().toString().replace( QRegExp( "\\." ), "," ) + "," | 534 | + address().toString().replace( QRegExp( "\\." ), "," ) + "," |
535 | + QString::number( ( serversocket->port() ) >> 8 ) + "," | 535 | + QString::number( ( serversocket->port() ) >> 8 ) + "," |
536 | + QString::number( ( serversocket->port() ) & 0xFF ) +")" ); | 536 | + QString::number( ( serversocket->port() ) & 0xFF ) +")" ); |
537 | } | 537 | } |
@@ -540,6 +540,6 @@ void ServerPI::process( const QString& message ) | |||
540 | else if ( cmd == "TYPE" ) { | 540 | else if ( cmd == "TYPE" ) { |
541 | if ( arg.upper() == "A" || arg.upper() == "I" ) | 541 | if ( arg.upper() == "A" || arg.upper() == "I" ) |
542 | send( "200 Command okay" ); // No tr | 542 | send( "200 Command okay" ); // No tr |
543 | else | 543 | else |
544 | send( "504 Command not implemented for that parameter" ); // No tr | 544 | send( "504 Command not implemented for that parameter" ); // No tr |
545 | } | 545 | } |
@@ -548,6 +548,6 @@ void ServerPI::process( const QString& message ) | |||
548 | else if ( cmd == "STRU" ) { | 548 | else if ( cmd == "STRU" ) { |
549 | if ( arg.upper() == "F" ) | 549 | if ( arg.upper() == "F" ) |
550 | send( "200 Command okay" ); // No tr | 550 | send( "200 Command okay" ); // No tr |
551 | else | 551 | else |
552 | send( "504 Command not implemented for that parameter" ); // No tr | 552 | send( "504 Command not implemented for that parameter" ); // No tr |
553 | } | 553 | } |
@@ -556,6 +556,6 @@ void ServerPI::process( const QString& message ) | |||
556 | else if ( cmd == "MODE" ) { | 556 | else if ( cmd == "MODE" ) { |
557 | if ( arg.upper() == "S" ) | 557 | if ( arg.upper() == "S" ) |
558 | send( "200 Command okay" ); // No tr | 558 | send( "200 Command okay" ); // No tr |
559 | else | 559 | else |
560 | send( "504 Command not implemented for that parameter" ); // No tr | 560 | send( "504 Command not implemented for that parameter" ); // No tr |
561 | } | 561 | } |
@@ -568,11 +568,11 @@ void ServerPI::process( const QString& message ) | |||
568 | else if ( cmd == "RETR" ) | 568 | else if ( cmd == "RETR" ) |
569 | if ( !args.isEmpty() && checkReadFile( absFilePath( args ) ) | 569 | if ( !args.isEmpty() && checkReadFile( absFilePath( args ) ) |
570 | || backupRestoreGzip( absFilePath( args ) ) ) { | 570 | || backupRestoreGzip( absFilePath( args ) ) ) { |
571 | send( "150 File status okay" ); // No tr | 571 | send( "150 File status okay" ); // No tr |
572 | sendFile( absFilePath( args ) ); | 572 | sendFile( absFilePath( args ) ); |
573 | } | 573 | } |
574 | else { | 574 | else { |
575 | odebug << "550 Requested action not taken" << oendl; | 575 | odebug << "550 Requested action not taken" << oendl; |
576 | send( "550 Requested action not taken" ); // No tr | 576 | send( "550 Requested action not taken" ); // No tr |
577 | } | 577 | } |
578 | 578 | ||
@@ -580,8 +580,8 @@ void ServerPI::process( const QString& message ) | |||
580 | else if ( cmd == "STOR" ) | 580 | else if ( cmd == "STOR" ) |
581 | if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) { | 581 | if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) { |
582 | send( "150 File status okay" ); // No tr | 582 | send( "150 File status okay" ); // No tr |
583 | retrieveFile( absFilePath( args ) ); | 583 | retrieveFile( absFilePath( args ) ); |
584 | } | 584 | } |
585 | else | 585 | else |
586 | send( "550 Requested action not taken" ); // No tr | 586 | send( "550 Requested action not taken" ); // No tr |
587 | 587 | ||
@@ -589,3 +589,3 @@ void ServerPI::process( const QString& message ) | |||
589 | else if ( cmd == "STOU" ) { | 589 | else if ( cmd == "STOU" ) { |
590 | send( "502 Command not implemented" ); // No tr | 590 | send( "502 Command not implemented" ); // No tr |
591 | } | 591 | } |
@@ -594,3 +594,3 @@ void ServerPI::process( const QString& message ) | |||
594 | else if ( cmd == "APPE" ) { | 594 | else if ( cmd == "APPE" ) { |
595 | send( "502 Command not implemented" ); // No tr | 595 | send( "502 Command not implemented" ); // No tr |
596 | } | 596 | } |
@@ -599,4 +599,4 @@ void ServerPI::process( const QString& message ) | |||
599 | else if ( cmd == "ALLO" ) { | 599 | else if ( cmd == "ALLO" ) { |
600 | storFileSize = args.toInt(); | 600 | storFileSize = args.toInt(); |
601 | send( "200 Command okay" ); // No tr | 601 | send( "200 Command okay" ); // No tr |
602 | } | 602 | } |
@@ -605,3 +605,3 @@ void ServerPI::process( const QString& message ) | |||
605 | else if ( cmd == "REST" ) { | 605 | else if ( cmd == "REST" ) { |
606 | send( "502 Command not implemented" ); // No tr | 606 | send( "502 Command not implemented" ); // No tr |
607 | } | 607 | } |
@@ -610,14 +610,14 @@ void ServerPI::process( const QString& message ) | |||
610 | else if ( cmd == "RNFR" ) { | 610 | else if ( cmd == "RNFR" ) { |
611 | renameFrom = QString::null; | 611 | renameFrom = QString::null; |
612 | if ( args.isEmpty() ) | 612 | if ( args.isEmpty() ) |
613 | send( "500 Syntax error, command unrecognized" ); // No tr | 613 | send( "500 Syntax error, command unrecognized" ); // No tr |
614 | else { | 614 | else { |
615 | QFile file( absFilePath( args ) ); | 615 | QFile file( absFilePath( args ) ); |
616 | if ( file.exists() ) { | 616 | if ( file.exists() ) { |
617 | send( "350 File exists, ready for destination name" ); // No tr | 617 | send( "350 File exists, ready for destination name" ); // No tr |
618 | renameFrom = absFilePath( args ); | 618 | renameFrom = absFilePath( args ); |
619 | } | 619 | } |
620 | else | 620 | else |
621 | send( "550 Requested action not taken" ); // No tr | 621 | send( "550 Requested action not taken" ); // No tr |
622 | } | 622 | } |
623 | } | 623 | } |
@@ -626,13 +626,13 @@ void ServerPI::process( const QString& message ) | |||
626 | else if ( cmd == "RNTO" ) { | 626 | else if ( cmd == "RNTO" ) { |
627 | if ( lastCommand != "RNFR" ) | 627 | if ( lastCommand != "RNFR" ) |
628 | send( "503 Bad sequence of commands" ); // No tr | 628 | send( "503 Bad sequence of commands" ); // No tr |
629 | else if ( args.isEmpty() ) | 629 | else if ( args.isEmpty() ) |
630 | send( "500 Syntax error, command unrecognized" ); // No tr | 630 | send( "500 Syntax error, command unrecognized" ); // No tr |
631 | else { | 631 | else { |
632 | QDir dir( absFilePath( args ) ); | 632 | QDir dir( absFilePath( args ) ); |
633 | if ( dir.rename( renameFrom, absFilePath( args ), TRUE ) ) | 633 | if ( dir.rename( renameFrom, absFilePath( args ), TRUE ) ) |
634 | send( "250 Requested file action okay, completed." ); // No tr | 634 | send( "250 Requested file action okay, completed." ); // No tr |
635 | else | 635 | else |
636 | send( "550 Requested action not taken" ); // No tr | 636 | send( "550 Requested action not taken" ); // No tr |
637 | } | 637 | } |
638 | } | 638 | } |
@@ -641,7 +641,7 @@ void ServerPI::process( const QString& message ) | |||
641 | else if ( cmd.contains( "ABOR" ) ) { | 641 | else if ( cmd.contains( "ABOR" ) ) { |
642 | dtp->close(); | 642 | dtp->close(); |
643 | if ( dtp->dtpMode() != ServerDTP::Idle ) | 643 | if ( dtp->dtpMode() != ServerDTP::Idle ) |
644 | send( "426 Connection closed; transfer aborted" ); // No tr | 644 | send( "426 Connection closed; transfer aborted" ); // No tr |
645 | else | 645 | else |
646 | send( "226 Closing data connection" ); // No tr | 646 | send( "226 Closing data connection" ); // No tr |
647 | } | 647 | } |
@@ -650,14 +650,14 @@ void ServerPI::process( const QString& message ) | |||
650 | else if ( cmd == "DELE" ) { | 650 | else if ( cmd == "DELE" ) { |
651 | if ( args.isEmpty() ) | 651 | if ( args.isEmpty() ) |
652 | send( "500 Syntax error, command unrecognized" ); // No tr | 652 | send( "500 Syntax error, command unrecognized" ); // No tr |
653 | else { | 653 | else { |
654 | QFile file( absFilePath( args ) ) ; | 654 | QFile file( absFilePath( args ) ) ; |
655 | if ( file.remove() ) { | 655 | if ( file.remove() ) { |
656 | send( "250 Requested file action okay, completed" ); // No tr | 656 | send( "250 Requested file action okay, completed" ); // No tr |
657 | QCopEnvelope e("QPE/System", "linkChanged(QString)" ); | 657 | QCopEnvelope e("QPE/System", "linkChanged(QString)" ); |
658 | e << file.name(); | 658 | e << file.name(); |
659 | } else { | 659 | } else { |
660 | send( "550 Requested action not taken" ); // No tr | 660 | send( "550 Requested action not taken" ); // No tr |
661 | } | 661 | } |
662 | } | 662 | } |
663 | } | 663 | } |
@@ -666,11 +666,11 @@ void ServerPI::process( const QString& message ) | |||
666 | else if ( cmd == "RMD" ) { | 666 | else if ( cmd == "RMD" ) { |
667 | if ( args.isEmpty() ) | 667 | if ( args.isEmpty() ) |
668 | send( "500 Syntax error, command unrecognized" ); // No tr | 668 | send( "500 Syntax error, command unrecognized" ); // No tr |
669 | else { | 669 | else { |
670 | QDir dir; | 670 | QDir dir; |
671 | if ( dir.rmdir( absFilePath( args ), TRUE ) ) | 671 | if ( dir.rmdir( absFilePath( args ), TRUE ) ) |
672 | send( "250 Requested file action okay, completed" ); // No tr | 672 | send( "250 Requested file action okay, completed" ); // No tr |
673 | else | 673 | else |
674 | send( "550 Requested action not taken" ); // No tr | 674 | send( "550 Requested action not taken" ); // No tr |
675 | } | 675 | } |
676 | } | 676 | } |
@@ -679,13 +679,13 @@ void ServerPI::process( const QString& message ) | |||
679 | else if ( cmd == "MKD" ) { | 679 | else if ( cmd == "MKD" ) { |
680 | if ( args.isEmpty() ) { | 680 | if ( args.isEmpty() ) { |
681 | odebug << " Error: no arg" << oendl; | 681 | odebug << " Error: no arg" << oendl; |
682 | send( "500 Syntax error, command unrecognized" ); // No tr | 682 | send( "500 Syntax error, command unrecognized" ); // No tr |
683 | } | 683 | } |
684 | else { | 684 | else { |
685 | QDir dir; | 685 | QDir dir; |
686 | if ( dir.mkdir( absFilePath( args ), TRUE ) ) | 686 | if ( dir.mkdir( absFilePath( args ), TRUE ) ) |
687 | send( "250 Requested file action okay, completed." ); // No tr | 687 | send( "250 Requested file action okay, completed." ); // No tr |
688 | else | 688 | else |
689 | send( "550 Requested action not taken" ); // No tr | 689 | send( "550 Requested action not taken" ); // No tr |
690 | } | 690 | } |
691 | } | 691 | } |
@@ -694,3 +694,3 @@ void ServerPI::process( const QString& message ) | |||
694 | else if ( cmd == "PWD" ) { | 694 | else if ( cmd == "PWD" ) { |
695 | send( "257 \"" + directory.path() +"\"" ); | 695 | send( "257 \"" + directory.path() +"\"" ); |
696 | } | 696 | } |
@@ -699,6 +699,6 @@ void ServerPI::process( const QString& message ) | |||
699 | else if ( cmd == "LIST" ) { | 699 | else if ( cmd == "LIST" ) { |
700 | if ( sendList( absFilePath( args ) ) ) | 700 | if ( sendList( absFilePath( args ) ) ) |
701 | send( "150 File status okay" ); // No tr | 701 | send( "150 File status okay" ); // No tr |
702 | else | 702 | else |
703 | send( "500 Syntax error, command unrecognized" ); // No tr | 703 | send( "500 Syntax error, command unrecognized" ); // No tr |
704 | } | 704 | } |
@@ -707,28 +707,28 @@ void ServerPI::process( const QString& message ) | |||
707 | else if ( cmd == "SIZE" ) { | 707 | else if ( cmd == "SIZE" ) { |
708 | QString filePath = absFilePath( args ); | 708 | QString filePath = absFilePath( args ); |
709 | QFileInfo fi( filePath ); | 709 | QFileInfo fi( filePath ); |
710 | bool gzipfile = backupRestoreGzip( filePath ); | 710 | bool gzipfile = backupRestoreGzip( filePath ); |
711 | if ( !fi.exists() && !gzipfile ) | 711 | if ( !fi.exists() && !gzipfile ) |
712 | send( "500 Syntax error, command unrecognized" ); // No tr | 712 | send( "500 Syntax error, command unrecognized" ); // No tr |
713 | else { | 713 | else { |
714 | if ( !gzipfile ) | 714 | if ( !gzipfile ) |
715 | send( "213 " + QString::number( fi.size() ) ); | 715 | send( "213 " + QString::number( fi.size() ) ); |
716 | else { | 716 | else { |
717 | Process duproc( QString("du") ); | 717 | Process duproc( QString("du") ); |
718 | duproc.addArgument("-s"); | 718 | duproc.addArgument("-s"); |
719 | QString in, out; | 719 | QString in, out; |
720 | if ( !duproc.exec(in, out) ) { | 720 | if ( !duproc.exec(in, out) ) { |
721 | odebug << "du process failed; just sending back 1K" << oendl; | 721 | odebug << "du process failed; just sending back 1K" << oendl; |
722 | send( "213 1024"); | 722 | send( "213 1024"); |
723 | } | 723 | } |
724 | else { | 724 | else { |
725 | QString size = out.left( out.find("\t") ); | 725 | QString size = out.left( out.find("\t") ); |
726 | int guess = size.toInt()/5; | 726 | int guess = size.toInt()/5; |
727 | if ( filePath.contains("doc") ) // No tr | 727 | if ( filePath.contains("doc") ) // No tr |
728 | guess *= 1000; | 728 | guess *= 1000; |
729 | odebug << "sending back gzip guess of " << guess << "" << oendl; | 729 | odebug << "sending back gzip guess of " << guess << "" << oendl; |
730 | send( "213 " + QString::number(guess) ); | 730 | send( "213 " + QString::number(guess) ); |
731 | } | 731 | } |
732 | } | 732 | } |
733 | } | 733 | } |
734 | } | 734 | } |
@@ -736,3 +736,3 @@ void ServerPI::process( const QString& message ) | |||
736 | else if ( cmd == "NLST" ) { | 736 | else if ( cmd == "NLST" ) { |
737 | send( "502 Command not implemented" ); // No tr | 737 | send( "502 Command not implemented" ); // No tr |
738 | } | 738 | } |
@@ -741,3 +741,3 @@ void ServerPI::process( const QString& message ) | |||
741 | else if ( cmd == "SITE" ) { | 741 | else if ( cmd == "SITE" ) { |
742 | send( "502 Command not implemented" ); // No tr | 742 | send( "502 Command not implemented" ); // No tr |
743 | } | 743 | } |
@@ -746,3 +746,3 @@ void ServerPI::process( const QString& message ) | |||
746 | else if ( cmd == "SYST" ) { | 746 | else if ( cmd == "SYST" ) { |
747 | send( "215 UNIX Type: L8" ); // No tr | 747 | send( "215 UNIX Type: L8" ); // No tr |
748 | } | 748 | } |
@@ -751,3 +751,3 @@ void ServerPI::process( const QString& message ) | |||
751 | else if ( cmd == "STAT" ) { | 751 | else if ( cmd == "STAT" ) { |
752 | send( "502 Command not implemented" ); // No tr | 752 | send( "502 Command not implemented" ); // No tr |
753 | } | 753 | } |
@@ -756,3 +756,3 @@ void ServerPI::process( const QString& message ) | |||
756 | else if ( cmd == "HELP" ) { | 756 | else if ( cmd == "HELP" ) { |
757 | send( "502 Command not implemented" ); // No tr | 757 | send( "502 Command not implemented" ); // No tr |
758 | } | 758 | } |
@@ -761,3 +761,3 @@ void ServerPI::process( const QString& message ) | |||
761 | else if ( cmd == "NOOP" ) { | 761 | else if ( cmd == "NOOP" ) { |
762 | send( "200 Command okay" ); // No tr | 762 | send( "200 Command okay" ); // No tr |
763 | } | 763 | } |
@@ -766,3 +766,3 @@ void ServerPI::process( const QString& message ) | |||
766 | else | 766 | else |
767 | send( "502 Command not implemented" ); // No tr | 767 | send( "502 Command not implemented" ); // No tr |
768 | 768 | ||
@@ -774,3 +774,3 @@ bool ServerPI::backupRestoreGzip( const QString &file ) | |||
774 | return (file.find( "backup" ) != -1 && // No tr | 774 | return (file.find( "backup" ) != -1 && // No tr |
775 | file.findRev( ".tgz" ) == (int)file.length()-4 ); | 775 | file.findRev( ".tgz" ) == (int)file.length()-4 ); |
776 | } | 776 | } |
@@ -783,4 +783,3 @@ bool ServerPI::backupRestoreGzip( const QString &file, QStringList &targets ) | |||
783 | targets = info.dirPath( TRUE ); | 783 | targets = info.dirPath( TRUE ); |
784 | qDebug("ServerPI::backupRestoreGzip for %s = %s", file.latin1(), | 784 | odebug << "ServerPI::backupRestoreGzip for " << file.latin1() << " = " << targets.join(" ").latin1() << oendl; |
785 | targets.join(" ").latin1() ); | ||
786 | return true; | 785 | return true; |
@@ -793,6 +792,6 @@ void ServerPI::sendFile( const QString& file ) | |||
793 | if ( passiv ) { | 792 | if ( passiv ) { |
794 | wait[SendFile] = TRUE; | 793 | wait[SendFile] = TRUE; |
795 | waitfile = file; | 794 | waitfile = file; |
796 | if ( waitsocket ) | 795 | if ( waitsocket ) |
797 | newConnection( waitsocket ); | 796 | newConnection( waitsocket ); |
798 | } | 797 | } |
@@ -801,3 +800,3 @@ void ServerPI::sendFile( const QString& file ) | |||
801 | if ( backupRestoreGzip( file, targets ) ) | 800 | if ( backupRestoreGzip( file, targets ) ) |
802 | dtp->sendGzipFile( file, targets, peeraddress, peerport ); | 801 | dtp->sendGzipFile( file, targets, peeraddress, peerport ); |
803 | else dtp->sendFile( file, peeraddress, peerport ); | 802 | else dtp->sendFile( file, peeraddress, peerport ); |
@@ -809,6 +808,6 @@ void ServerPI::retrieveFile( const QString& file ) | |||
809 | if ( passiv ) { | 808 | if ( passiv ) { |
810 | wait[RetrieveFile] = TRUE; | 809 | wait[RetrieveFile] = TRUE; |
811 | waitfile = file; | 810 | waitfile = file; |
812 | if ( waitsocket ) | 811 | if ( waitsocket ) |
813 | newConnection( waitsocket ); | 812 | newConnection( waitsocket ); |
814 | } | 813 | } |
@@ -817,5 +816,5 @@ void ServerPI::retrieveFile( const QString& file ) | |||
817 | if ( backupRestoreGzip( file, targets ) ) | 816 | if ( backupRestoreGzip( file, targets ) ) |
818 | dtp->retrieveGzipFile( file, peeraddress, peerport ); | 817 | dtp->retrieveGzipFile( file, peeraddress, peerport ); |
819 | else | 818 | else |
820 | dtp->retrieveFile( file, peeraddress, peerport, storFileSize ); | 819 | dtp->retrieveFile( file, peeraddress, peerport, storFileSize ); |
821 | } | 820 | } |
@@ -830,3 +829,3 @@ bool ServerPI::parsePort( const QString& pp ) | |||
830 | peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) + | 829 | peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) + |
831 | ( p[2].toInt() << 8 ) + p[3].toInt() ); | 830 | ( p[2].toInt() << 8 ) + p[3].toInt() ); |
832 | peerport = ( p[4].toInt() << 8 ) + p[5].toInt(); | 831 | peerport = ( p[4].toInt() << 8 ) + p[5].toInt(); |
@@ -839,7 +838,7 @@ void ServerPI::dtpCompleted() | |||
839 | if ( dtp->dtpMode() == ServerDTP::RetrieveFile ) { | 838 | if ( dtp->dtpMode() == ServerDTP::RetrieveFile ) { |
840 | QString fn = dtp->fileName(); | 839 | QString fn = dtp->fileName(); |
841 | if ( fn.right(8)==".desktop" && fn.find("/Documents/")>=0 ) { | 840 | if ( fn.right(8)==".desktop" && fn.find("/Documents/")>=0 ) { |
842 | QCopEnvelope e("QPE/System", "linkChanged(QString)" ); | 841 | QCopEnvelope e("QPE/System", "linkChanged(QString)" ); |
843 | e << fn; | 842 | e << fn; |
844 | } | 843 | } |
845 | } | 844 | } |
@@ -872,3 +871,3 @@ bool ServerPI::sendList( const QString& arg ) | |||
872 | if ( !buffer.open( IO_WriteOnly ) ) | 871 | if ( !buffer.open( IO_WriteOnly ) ) |
873 | return FALSE; | 872 | return FALSE; |
874 | 873 | ||
@@ -878,3 +877,3 @@ bool ServerPI::sendList( const QString& arg ) | |||
878 | if ( fn.isEmpty() ) | 877 | if ( fn.isEmpty() ) |
879 | fn = directory.path(); | 878 | fn = directory.path(); |
880 | 879 | ||
@@ -885,3 +884,3 @@ bool ServerPI::sendList( const QString& arg ) | |||
885 | if ( fi.isFile() ) { | 884 | if ( fi.isFile() ) { |
886 | ts << fileListing( &fi ) << endl; | 885 | ts << fileListing( &fi ) << endl; |
887 | } | 886 | } |
@@ -890,26 +889,26 @@ bool ServerPI::sendList( const QString& arg ) | |||
890 | else if ( fi.isDir() ) { | 889 | else if ( fi.isDir() ) { |
891 | QDir dir( fn ); | 890 | QDir dir( fn ); |
892 | const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden ); | 891 | const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden ); |
893 | 892 | ||
894 | QFileInfoListIterator it( *list ); | 893 | QFileInfoListIterator it( *list ); |
895 | QFileInfo *info; | 894 | QFileInfo *info; |
896 | 895 | ||
897 | unsigned long total = 0; | 896 | unsigned long total = 0; |
898 | while ( ( info = it.current() ) ) { | 897 | while ( ( info = it.current() ) ) { |
899 | if ( info->fileName() != "." && info->fileName() != ".." ) | 898 | if ( info->fileName() != "." && info->fileName() != ".." ) |
900 | total += info->size(); | 899 | total += info->size(); |
901 | ++it; | 900 | ++it; |
902 | } | 901 | } |
903 | 902 | ||
904 | ts << "total " << QString::number( total / 1024 ) << endl; // No tr | 903 | ts << "total " << QString::number( total / 1024 ) << endl; // No tr |
905 | 904 | ||
906 | it.toFirst(); | 905 | it.toFirst(); |
907 | while ( ( info = it.current() ) ) { | 906 | while ( ( info = it.current() ) ) { |
908 | if ( info->fileName() == "." || info->fileName() == ".." ) { | 907 | if ( info->fileName() == "." || info->fileName() == ".." ) { |
909 | ++it; | 908 | ++it; |
910 | continue; | 909 | continue; |
911 | } | 910 | } |
912 | ts << fileListing( info ) << endl; | 911 | ts << fileListing( info ) << endl; |
913 | ++it; | 912 | ++it; |
914 | } | 913 | } |
915 | } | 914 | } |
@@ -917,9 +916,9 @@ bool ServerPI::sendList( const QString& arg ) | |||
917 | if ( passiv ) { | 916 | if ( passiv ) { |
918 | waitarray = buffer.buffer(); | 917 | waitarray = buffer.buffer(); |
919 | wait[SendByteArray] = TRUE; | 918 | wait[SendByteArray] = TRUE; |
920 | if ( waitsocket ) | 919 | if ( waitsocket ) |
921 | newConnection( waitsocket ); | 920 | newConnection( waitsocket ); |
922 | } | 921 | } |
923 | else | 922 | else |
924 | dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); | 923 | dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); |
925 | return TRUE; | 924 | return TRUE; |
@@ -934,7 +933,7 @@ QString ServerPI::fileListing( QFileInfo *info ) | |||
934 | if ( info->isDir() ) | 933 | if ( info->isDir() ) |
935 | s += "d"; | 934 | s += "d"; |
936 | else if ( info->isSymLink() ) | 935 | else if ( info->isSymLink() ) |
937 | s += "l"; | 936 | s += "l"; |
938 | else | 937 | else |
939 | s += "-"; | 938 | s += "-"; |
940 | 939 | ||
@@ -947,3 +946,3 @@ QString ServerPI::fileListing( QFileInfo *info ) | |||
947 | if ( info->isDir() ) | 946 | if ( info->isDir() ) |
948 | subdirs = 2; | 947 | subdirs = 2; |
949 | // FIXME : this is to slow | 948 | // FIXME : this is to slow |
@@ -957,3 +956,3 @@ QString ServerPI::fileListing( QFileInfo *info ) | |||
957 | if ( o.isEmpty() ) | 956 | if ( o.isEmpty() ) |
958 | o = QString::number(info->ownerId()); | 957 | o = QString::number(info->ownerId()); |
959 | s += o.leftJustify( 8, ' ', TRUE ) + " "; | 958 | s += o.leftJustify( 8, ' ', TRUE ) + " "; |
@@ -963,3 +962,3 @@ QString ServerPI::fileListing( QFileInfo *info ) | |||
963 | if ( g.isEmpty() ) | 962 | if ( g.isEmpty() ) |
964 | g = QString::number(info->groupId()); | 963 | g = QString::number(info->groupId()); |
965 | s += g.leftJustify( 8, ' ', TRUE ) + " "; | 964 | s += g.leftJustify( 8, ' ', TRUE ) + " "; |
@@ -973,5 +972,5 @@ QString ServerPI::fileListing( QFileInfo *info ) | |||
973 | s += date.monthName( date.month() ) + " " | 972 | s += date.monthName( date.month() ) + " " |
974 | + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " | 973 | + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " |
975 | + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" | 974 | + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" |
976 | + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " "; | 975 | + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " "; |
977 | 976 | ||
@@ -1022,8 +1021,8 @@ void ServerPI::newConnection( int socket ) | |||
1022 | if ( wait[SendFile] ) { | 1021 | if ( wait[SendFile] ) { |
1023 | QStringList targets; | 1022 | QStringList targets; |
1024 | if ( backupRestoreGzip( waitfile, targets ) ) | 1023 | if ( backupRestoreGzip( waitfile, targets ) ) |
1025 | dtp->sendGzipFile( waitfile, targets ); | 1024 | dtp->sendGzipFile( waitfile, targets ); |
1026 | else | 1025 | else |
1027 | dtp->sendFile( waitfile ); | 1026 | dtp->sendFile( waitfile ); |
1028 | dtp->setSocket( socket ); | 1027 | dtp->setSocket( socket ); |
1029 | } | 1028 | } |
@@ -1032,5 +1031,5 @@ void ServerPI::newConnection( int socket ) | |||
1032 | if ( backupRestoreGzip( waitfile ) ) | 1031 | if ( backupRestoreGzip( waitfile ) ) |
1033 | dtp->retrieveGzipFile( waitfile ); | 1032 | dtp->retrieveGzipFile( waitfile ); |
1034 | else | 1033 | else |
1035 | dtp->retrieveFile( waitfile, storFileSize ); | 1034 | dtp->retrieveFile( waitfile, storFileSize ); |
1036 | dtp->setSocket( socket ); | 1035 | dtp->setSocket( socket ); |
@@ -1038,4 +1037,4 @@ void ServerPI::newConnection( int socket ) | |||
1038 | else if ( wait[SendByteArray] ) { | 1037 | else if ( wait[SendByteArray] ) { |
1039 | dtp->sendByteArray( waitarray ); | 1038 | dtp->sendByteArray( waitarray ); |
1040 | dtp->setSocket( socket ); | 1039 | dtp->setSocket( socket ); |
1041 | } | 1040 | } |
@@ -1043,10 +1042,10 @@ void ServerPI::newConnection( int socket ) | |||
1043 | odebug << "retrieve byte array" << oendl; | 1042 | odebug << "retrieve byte array" << oendl; |
1044 | dtp->retrieveByteArray(); | 1043 | dtp->retrieveByteArray(); |
1045 | dtp->setSocket( socket ); | 1044 | dtp->setSocket( socket ); |
1046 | } | 1045 | } |
1047 | else | 1046 | else |
1048 | waitsocket = socket; | 1047 | waitsocket = socket; |
1049 | 1048 | ||
1050 | for( int i = 0; i < 4; i++ ) | 1049 | for( int i = 0; i < 4; i++ ) |
1051 | wait[i] = FALSE; | 1050 | wait[i] = FALSE; |
1052 | } | 1051 | } |
@@ -1059,3 +1058,3 @@ QString ServerPI::absFilePath( const QString& file ) | |||
1059 | if ( file[0] != "/" ) | 1058 | if ( file[0] != "/" ) |
1060 | filepath = directory.path() + "/" + file; | 1059 | filepath = directory.path() + "/" + file; |
1061 | 1060 | ||
@@ -1090,5 +1089,5 @@ ServerDTP::ServerDTP( QObject *parent, const char* name) | |||
1090 | connect( retrieveTargzProc, SIGNAL( processExited() ), | 1089 | connect( retrieveTargzProc, SIGNAL( processExited() ), |
1091 | SIGNAL( completed() ) ); | 1090 | SIGNAL( completed() ) ); |
1092 | connect( retrieveTargzProc, SIGNAL( processExited() ), | 1091 | connect( retrieveTargzProc, SIGNAL( processExited() ), |
1093 | SLOT( extractTarDone() ) ); | 1092 | SLOT( extractTarDone() ) ); |
1094 | } | 1093 | } |
@@ -1099,10 +1098,10 @@ ServerDTP::~ServerDTP() | |||
1099 | if ( RetrieveFile == mode && file.isOpen() ) { | 1098 | if ( RetrieveFile == mode && file.isOpen() ) { |
1100 | // We're being shutdown before the client closed. | 1099 | // We're being shutdown before the client closed. |
1101 | file.close(); | 1100 | file.close(); |
1102 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { | 1101 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { |
1103 | odebug << "STOR incomplete" << oendl; | 1102 | odebug << "STOR incomplete" << oendl; |
1104 | file.remove(); | 1103 | file.remove(); |
1105 | } | 1104 | } |
1106 | } else { | 1105 | } else { |
1107 | file.close(); | 1106 | file.close(); |
1108 | } | 1107 | } |
@@ -1142,6 +1141,6 @@ void ServerDTP::connected() | |||
1142 | if ( bytesToWrite() <= block_size && !file.atEnd() ) { | 1141 | if ( bytesToWrite() <= block_size && !file.atEnd() ) { |
1143 | QCString s; | 1142 | QCString s; |
1144 | s.resize( block_size ); | 1143 | s.resize( block_size ); |
1145 | int bytes = file.readBlock( s.data(), block_size ); | 1144 | int bytes = file.readBlock( s.data(), block_size ); |
1146 | writeBlock( s.data(), bytes ); | 1145 | writeBlock( s.data(), bytes ); |
1147 | } | 1146 | } |
@@ -1160,3 +1159,3 @@ void ServerDTP::connected() | |||
1160 | qWarning("Error starting %s", | 1159 | qWarning("Error starting %s", |
1161 | createTargzProc->arguments().join(" ").latin1()); | 1160 | createTargzProc->arguments().join(" ").latin1()); |
1162 | break; | 1161 | break; |
@@ -1214,6 +1213,6 @@ void ServerDTP::connectionClosed() | |||
1214 | if ( SendFile == mode ) { | 1213 | if ( SendFile == mode ) { |
1215 | if ( bytes_written == file.size() ) | 1214 | if ( bytes_written == file.size() ) |
1216 | emit completed(); | 1215 | emit completed(); |
1217 | else | 1216 | else |
1218 | emit failed(); | 1217 | emit failed(); |
1219 | } | 1218 | } |
@@ -1222,6 +1221,6 @@ void ServerDTP::connectionClosed() | |||
1222 | else if ( SendBuffer == mode ) { | 1221 | else if ( SendBuffer == mode ) { |
1223 | if ( bytes_written == buf.size() ) | 1222 | if ( bytes_written == buf.size() ) |
1224 | emit completed(); | 1223 | emit completed(); |
1225 | else | 1224 | else |
1226 | emit failed(); | 1225 | emit failed(); |
1227 | } | 1226 | } |
@@ -1230,10 +1229,10 @@ void ServerDTP::connectionClosed() | |||
1230 | else if ( RetrieveFile == mode ) { | 1229 | else if ( RetrieveFile == mode ) { |
1231 | file.close(); | 1230 | file.close(); |
1232 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { | 1231 | if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { |
1233 | odebug << "STOR incomplete" << oendl; | 1232 | odebug << "STOR incomplete" << oendl; |
1234 | file.remove(); | 1233 | file.remove(); |
1235 | emit failed(); | 1234 | emit failed(); |
1236 | } else { | 1235 | } else { |
1237 | emit completed(); | 1236 | emit completed(); |
1238 | } | 1237 | } |
1239 | } | 1238 | } |
@@ -1242,4 +1241,4 @@ void ServerDTP::connectionClosed() | |||
1242 | odebug << "Done writing ungzip file; closing input" << oendl; | 1241 | odebug << "Done writing ungzip file; closing input" << oendl; |
1243 | retrieveTargzProc->flushStdin(); | 1242 | retrieveTargzProc->flushStdin(); |
1244 | retrieveTargzProc->closeStdin(); | 1243 | retrieveTargzProc->closeStdin(); |
1245 | } | 1244 | } |
@@ -1248,4 +1247,4 @@ void ServerDTP::connectionClosed() | |||
1248 | else if ( RetrieveBuffer == mode ) { | 1247 | else if ( RetrieveBuffer == mode ) { |
1249 | buf.close(); | 1248 | buf.close(); |
1250 | emit completed(); | 1249 | emit completed(); |
1251 | } | 1250 | } |
@@ -1262,14 +1261,14 @@ void ServerDTP::bytesWritten( int bytes ) | |||
1262 | 1261 | ||
1263 | if ( bytes_written == file.size() ) { | 1262 | if ( bytes_written == file.size() ) { |
1264 | // odebug << "Debug: Sending complete: " << file.size() << " bytes" << oendl; | 1263 | // odebug << "Debug: Sending complete: " << file.size() << " bytes" << oendl; |
1265 | file.close(); | 1264 | file.close(); |
1266 | emit completed(); | 1265 | emit completed(); |
1267 | mode = Idle; | 1266 | mode = Idle; |
1268 | } | 1267 | } |
1269 | else if( !file.atEnd() ) { | 1268 | else if( !file.atEnd() ) { |
1270 | QCString s; | 1269 | QCString s; |
1271 | s.resize( block_size ); | 1270 | s.resize( block_size ); |
1272 | int bytes = file.readBlock( s.data(), block_size ); | 1271 | int bytes = file.readBlock( s.data(), block_size ); |
1273 | writeBlock( s.data(), bytes ); | 1272 | writeBlock( s.data(), bytes ); |
1274 | } | 1273 | } |
1275 | } | 1274 | } |
@@ -1279,7 +1278,7 @@ void ServerDTP::bytesWritten( int bytes ) | |||
1279 | 1278 | ||
1280 | if ( bytes_written == buf.size() ) { | 1279 | if ( bytes_written == buf.size() ) { |
1281 | // odebug << "Debug: Sending complete: " << buf.size() << " bytes" << oendl; | 1280 | // odebug << "Debug: Sending complete: " << buf.size() << " bytes" << oendl; |
1282 | emit completed(); | 1281 | emit completed(); |
1283 | mode = Idle; | 1282 | mode = Idle; |
1284 | } | 1283 | } |
1285 | } | 1284 | } |
@@ -1291,15 +1290,15 @@ void ServerDTP::readyRead() | |||
1291 | if ( RetrieveFile == mode ) { | 1290 | if ( RetrieveFile == mode ) { |
1292 | QCString s; | 1291 | QCString s; |
1293 | s.resize( bytesAvailable() ); | 1292 | s.resize( bytesAvailable() ); |
1294 | readBlock( s.data(), bytesAvailable() ); | 1293 | readBlock( s.data(), bytesAvailable() ); |
1295 | file.writeBlock( s.data(), s.size() ); | 1294 | file.writeBlock( s.data(), s.size() ); |
1296 | } | 1295 | } |
1297 | else if ( RetrieveGzipFile == mode ) { | 1296 | else if ( RetrieveGzipFile == mode ) { |
1298 | if ( !retrieveTargzProc->isRunning() ) | 1297 | if ( !retrieveTargzProc->isRunning() ) |
1299 | retrieveTargzProc->start(); | 1298 | retrieveTargzProc->start(); |
1300 | 1299 | ||
1301 | QByteArray s; | 1300 | QByteArray s; |
1302 | s.resize( bytesAvailable() ); | 1301 | s.resize( bytesAvailable() ); |
1303 | readBlock( s.data(), bytesAvailable() ); | 1302 | readBlock( s.data(), bytesAvailable() ); |
1304 | retrieveTargzProc->writeToStdin( s ); | 1303 | retrieveTargzProc->writeToStdin( s ); |
1305 | odebug << "wrote " << s.size() << " bytes to ungzip " << oendl; | 1304 | odebug << "wrote " << s.size() << " bytes to ungzip " << oendl; |
@@ -1308,6 +1307,6 @@ void ServerDTP::readyRead() | |||
1308 | else if ( RetrieveBuffer == mode ) { | 1307 | else if ( RetrieveBuffer == mode ) { |
1309 | QCString s; | 1308 | QCString s; |
1310 | s.resize( bytesAvailable() ); | 1309 | s.resize( bytesAvailable() ); |
1311 | readBlock( s.data(), bytesAvailable() ); | 1310 | readBlock( s.data(), bytesAvailable() ); |
1312 | buf.writeBlock( s.data(), s.size() ); | 1311 | buf.writeBlock( s.data(), s.size() ); |
1313 | } | 1312 | } |
@@ -1328,3 +1327,3 @@ void ServerDTP::targzDone() | |||
1328 | disconnect( createTargzProc, SIGNAL( readyReadStdout() ), | 1327 | disconnect( createTargzProc, SIGNAL( readyReadStdout() ), |
1329 | this, SLOT( writeTargzBlock() ) ); | 1328 | this, SLOT( writeTargzBlock() ) ); |
1330 | } | 1329 | } |
@@ -1345,4 +1344,4 @@ void ServerDTP::sendFile( const QString fn ) | |||
1345 | void ServerDTP::sendGzipFile( const QString &fn, | 1344 | void ServerDTP::sendGzipFile( const QString &fn, |
1346 | const QStringList &archiveTargets, | 1345 | const QStringList &archiveTargets, |
1347 | const QHostAddress& host, Q_UINT16 port ) | 1346 | const QHostAddress& host, Q_UINT16 port ) |
1348 | { | 1347 | { |
@@ -1353,3 +1352,3 @@ void ServerDTP::sendGzipFile( const QString &fn, | |||
1353 | void ServerDTP::sendGzipFile( const QString &fn, | 1352 | void ServerDTP::sendGzipFile( const QString &fn, |
1354 | const QStringList &archiveTargets ) | 1353 | const QStringList &archiveTargets ) |
1355 | { | 1354 | { |
@@ -1364,3 +1363,3 @@ void ServerDTP::sendGzipFile( const QString &fn, | |||
1364 | connect( createTargzProc, | 1363 | connect( createTargzProc, |
1365 | SIGNAL( readyReadStdout() ), SLOT( writeTargzBlock() ) ); | 1364 | SIGNAL( readyReadStdout() ), SLOT( writeTargzBlock() ) ); |
1366 | } | 1365 | } |
@@ -1390,3 +1389,3 @@ void ServerDTP::retrieveGzipFile( const QString &fn ) | |||
1390 | connect( retrieveTargzProc, SIGNAL( processExited() ), | 1389 | connect( retrieveTargzProc, SIGNAL( processExited() ), |
1391 | SLOT( extractTarDone() ) ); | 1390 | SLOT( extractTarDone() ) ); |
1392 | } | 1391 | } |