summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-04-23 10:29:00 (UTC)
committer mickeyl <mickeyl>2004-04-23 10:29:00 (UTC)
commitd84d16cffe92bfafc5f2433f646dcfa00e6cd7f6 (patch) (unidiff)
tree6111ac63519b629e12f818b52a8d8bf1515b46c6
parent448732c964768b5be8677a95aa1f9b07bad9e8a2 (diff)
downloadopie-d84d16cffe92bfafc5f2433f646dcfa00e6cd7f6.zip
opie-d84d16cffe92bfafc5f2433f646dcfa00e6cd7f6.tar.gz
opie-d84d16cffe92bfafc5f2433f646dcfa00e6cd7f6.tar.bz2
gcc 3.4 fixlet
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/global.cpp b/library/global.cpp
index 5ac969b..ec87555 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -446,257 +446,257 @@ void Global::hideInputMethod()
446 \internal 446 \internal
447*/ 447*/
448bool Global::isBuiltinCommand( const QString &name ) 448bool Global::isBuiltinCommand( const QString &name )
449{ 449{
450 if(!builtin) 450 if(!builtin)
451 return FALSE; // yes, it can happen 451 return FALSE; // yes, it can happen
452 for (int i = 0; builtin[i].file; i++) { 452 for (int i = 0; builtin[i].file; i++) {
453 if ( builtin[i].file == name ) { 453 if ( builtin[i].file == name ) {
454 return TRUE; 454 return TRUE;
455 } 455 }
456 } 456 }
457 return FALSE; 457 return FALSE;
458} 458}
459 459
460Global::Command* Global::builtin=0; 460Global::Command* Global::builtin=0;
461QGuardedPtr<QWidget> *Global::running=0; 461QGuardedPtr<QWidget> *Global::running=0;
462 462
463/*! 463/*!
464 \class Global::Command 464 \class Global::Command
465 \brief The Global::Command class is internal. 465 \brief The Global::Command class is internal.
466 \internal 466 \internal
467*/ 467*/
468 468
469/*! 469/*!
470 \internal 470 \internal
471*/ 471*/
472void Global::setBuiltinCommands( Command* list ) 472void Global::setBuiltinCommands( Command* list )
473{ 473{
474 if ( running ) 474 if ( running )
475 delete [] running; 475 delete [] running;
476 476
477 builtin = list; 477 builtin = list;
478 int count = 0; 478 int count = 0;
479 if (!builtin) 479 if (!builtin)
480 return; 480 return;
481 while ( builtin[count].file ) 481 while ( builtin[count].file )
482 count++; 482 count++;
483 483
484 running = new QGuardedPtr<QWidget> [ count ]; 484 running = new QGuardedPtr<QWidget> [ count ];
485} 485}
486 486
487/*! 487/*!
488 \internal 488 \internal
489*/ 489*/
490void Global::setDocument( QWidget* receiver, const QString& document ) 490void Global::setDocument( QWidget* receiver, const QString& document )
491{ 491{
492 Emitter emitter(receiver,document); 492 Emitter emitter(receiver,document);
493} 493}
494 494
495/*! 495/*!
496 \internal 496 \internal
497*/ 497*/
498bool Global::terminateBuiltin( const QString& n ) 498bool Global::terminateBuiltin( const QString& n )
499{ 499{
500 if (!builtin) 500 if (!builtin)
501 return FALSE; 501 return FALSE;
502 for (int i = 0; builtin[i].file; i++) { 502 for (int i = 0; builtin[i].file; i++) {
503 if ( builtin[i].file == n ) { 503 if ( builtin[i].file == n ) {
504 delete running[i]; 504 delete running[i];
505 return TRUE; 505 return TRUE;
506 } 506 }
507 } 507 }
508 return FALSE; 508 return FALSE;
509} 509}
510 510
511/*! 511/*!
512 \internal 512 \internal
513*/ 513*/
514void Global::terminate( const AppLnk* app ) 514void Global::terminate( const AppLnk* app )
515{ 515{
516 //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this 516 //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this
517 517
518#ifndef QT_NO_COP 518#ifndef QT_NO_COP
519 QCString channel = "QPE/Application/" + app->exec().utf8(); 519 QCString channel = "QPE/Application/" + app->exec().utf8();
520 if ( QCopChannel::isRegistered(channel) ) { 520 if ( QCopChannel::isRegistered(channel) ) {
521 QCopEnvelope e(channel, "quit()"); 521 QCopEnvelope e(channel, "quit()");
522 } 522 }
523#endif 523#endif
524} 524}
525 525
526/*! 526/*!
527 Low-level function to run command \a c. 527 Low-level function to run command \a c.
528 528
529 \warning Do not use this function. Use execute instead. 529 \warning Do not use this function. Use execute instead.
530 530
531 \sa execute() 531 \sa execute()
532*/ 532*/
533void Global::invoke(const QString &c) 533void Global::invoke(const QString &c)
534{ 534{
535 // Convert the command line in to a list of arguments 535 // Convert the command line in to a list of arguments
536 QStringList list = QStringList::split(QRegExp(" *"),c); 536 QStringList list = QStringList::split(QRegExp(" *"),c);
537 537
538#if !defined(QT_NO_COP) 538#if !defined(QT_NO_COP)
539 QString ap=list[0]; 539 QString ap=list[0];
540 // see if the application is already running 540 // see if the application is already running
541 // XXX should lock file /tmp/qcop-msg-ap 541 // XXX should lock file /tmp/qcop-msg-ap
542 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { 542 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) {
543 // If the channel is already register, the app is already running, so show it. 543 // If the channel is already register, the app is already running, so show it.
544 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } 544 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); }
545 545
546 //QCopEnvelope e("QPE/System", "notBusy(QString)" ); 546 //QCopEnvelope e("QPE/System", "notBusy(QString)" );
547 //e << ap; 547 //e << ap;
548 return; 548 return;
549 } 549 }
550 // XXX should unlock file /tmp/qcop-msg-ap 550 // XXX should unlock file /tmp/qcop-msg-ap
551 //see if it is being started 551 //see if it is being started
552 if ( StartingAppList::isStarting( ap ) ) { 552 if ( StartingAppList::isStarting( ap ) ) {
553 // FIXME take it out for now, since it leads to a much to short showing of wait if 553 // FIXME take it out for now, since it leads to a much to short showing of wait if
554 // some entry is clicked. 554 // some entry is clicked.
555 // Real cause is that ::execute is called twice for document tab. But it would need some larger changes 555 // Real cause is that ::execute is called twice for document tab. But it would need some larger changes
556 // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there 556 // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there
557 // had the idea that an apploader belongs to the launcher ... 557 // had the idea that an apploader belongs to the launcher ...
558 //QCopEnvelope e("QPE/System", "notBusy(QString)" ); 558 //QCopEnvelope e("QPE/System", "notBusy(QString)" );
559 //e << ap; 559 //e << ap;
560 return; 560 return;
561 } 561 }
562 562
563#endif 563#endif
564 564
565#ifdef QT_NO_QWS_MULTIPROCESS 565#ifdef QT_NO_QWS_MULTIPROCESS
566 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); 566 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 );
567#else 567#else
568 568
569 QStrList slist; 569 QStrList slist;
570 unsigned int j; 570 unsigned int j;
571 for ( j = 0; j < list.count(); j++ ) 571 for ( j = 0; j < list.count(); j++ )
572 slist.append( list[j].utf8() ); 572 slist.append( list[j].utf8() );
573 573
574 const char **args = new (const char *)[slist.count() + 1]; 574 const char **args = new const char *[slist.count() + 1];
575 for ( j = 0; j < slist.count(); j++ ) 575 for ( j = 0; j < slist.count(); j++ )
576 args[j] = slist.at(j); 576 args[j] = slist.at(j);
577 args[j] = NULL; 577 args[j] = NULL;
578 578
579#if !defined(QT_NO_COP) 579#if !defined(QT_NO_COP)
580 // an attempt to show a wait... 580 // an attempt to show a wait...
581 // more logic should be used, but this will be fine for the moment... 581 // more logic should be used, but this will be fine for the moment...
582 QCopEnvelope ( "QPE/System", "busy()" ); 582 QCopEnvelope ( "QPE/System", "busy()" );
583#endif 583#endif
584 584
585#ifdef HAVE_QUICKEXEC 585#ifdef HAVE_QUICKEXEC
586#ifdef Q_OS_MACX 586#ifdef Q_OS_MACX
587 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".dylib"; 587 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".dylib";
588#else 588#else
589 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; 589 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so";
590#endif 590#endif
591 qDebug("libfile = %s", libexe.latin1() ); 591 qDebug("libfile = %s", libexe.latin1() );
592 if ( QFile::exists( libexe ) ) { 592 if ( QFile::exists( libexe ) ) {
593 qDebug("calling quickexec %s", libexe.latin1() ); 593 qDebug("calling quickexec %s", libexe.latin1() );
594 quickexecv( libexe.utf8().data(), (const char **)args ); 594 quickexecv( libexe.utf8().data(), (const char **)args );
595 } else 595 } else
596#endif 596#endif
597 { 597 {
598 bool success = false; 598 bool success = false;
599 int pfd [2]; 599 int pfd [2];
600 if ( ::pipe ( pfd ) < 0 ) 600 if ( ::pipe ( pfd ) < 0 )
601 pfd [0] = pfd [1] = -1; 601 pfd [0] = pfd [1] = -1;
602 602
603 pid_t pid = ::fork ( ); 603 pid_t pid = ::fork ( );
604 604
605 if ( pid == 0 ) { // child 605 if ( pid == 0 ) { // child
606 for ( int fd = 3; fd < 100; fd++ ) { 606 for ( int fd = 3; fd < 100; fd++ ) {
607 if ( fd != pfd [1] ) 607 if ( fd != pfd [1] )
608 ::close ( fd ); 608 ::close ( fd );
609 } 609 }
610 ::setpgid ( ::getpid ( ), ::getppid ( )); 610 ::setpgid ( ::getpid ( ), ::getppid ( ));
611 611
612 // Closing of fd[1] indicates that the execvp succeeded! 612 // Closing of fd[1] indicates that the execvp succeeded!
613 if ( pfd [1] >= 0 ) 613 if ( pfd [1] >= 0 )
614 ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); 614 ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC );
615 615
616 // Try bindir first, so that foo/bar works too 616 // Try bindir first, so that foo/bar works too
617 ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); 617 ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args );
618 ::execvp ( args [0], (char * const *) args ); 618 ::execvp ( args [0], (char * const *) args );
619 619
620 char resultByte = 1; 620 char resultByte = 1;
621 if ( pfd [1] >= 0 ) 621 if ( pfd [1] >= 0 )
622 ::write ( pfd [1], &resultByte, 1 ); 622 ::write ( pfd [1], &resultByte, 1 );
623 ::_exit ( -1 ); 623 ::_exit ( -1 );
624 } 624 }
625 else if ( pid > 0 ) { 625 else if ( pid > 0 ) {
626 success = true; 626 success = true;
627 627
628 if ( pfd [1] >= 0 ) 628 if ( pfd [1] >= 0 )
629 ::close ( pfd [1] ); 629 ::close ( pfd [1] );
630 if ( pfd [0] >= 0 ) { 630 if ( pfd [0] >= 0 ) {
631 while ( true ) { 631 while ( true ) {
632 char resultByte; 632 char resultByte;
633 int n = ::read ( pfd [0], &resultByte, 1 ); 633 int n = ::read ( pfd [0], &resultByte, 1 );
634 if ( n == 1 ) { 634 if ( n == 1 ) {
635 success = false; 635 success = false;
636 break; 636 break;
637 } 637 }
638 if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) 638 if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR )))
639 continue; 639 continue;
640 640
641 break; // success 641 break; // success
642 } 642 }
643 ::close ( pfd [0] ); 643 ::close ( pfd [0] );
644 } 644 }
645 } 645 }
646 if ( success ) 646 if ( success )
647 StartingAppList::add( list[0] ); 647 StartingAppList::add( list[0] );
648 else 648 else
649 QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); 649 QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 );
650 } 650 }
651#endif //QT_NO_QWS_MULTIPROCESS 651#endif //QT_NO_QWS_MULTIPROCESS
652} 652}
653 653
654 654
655/*! 655/*!
656 Executes the application identfied by \a c, passing \a 656 Executes the application identfied by \a c, passing \a
657 document if it isn't null. 657 document if it isn't null.
658 658
659 Note that a better approach might be to send a QCop message to the 659 Note that a better approach might be to send a QCop message to the
660 application's QPE/Application/\e{appname} channel. 660 application's QPE/Application/\e{appname} channel.
661*/ 661*/
662void Global::execute( const QString &c, const QString& document ) 662void Global::execute( const QString &c, const QString& document )
663{ 663{
664 // ask the server to do the work 664 // ask the server to do the work
665#if !defined(QT_NO_COP) 665#if !defined(QT_NO_COP)
666 if ( document.isNull() ) { 666 if ( document.isNull() ) {
667 QCopEnvelope e( "QPE/System", "execute(QString)" ); 667 QCopEnvelope e( "QPE/System", "execute(QString)" );
668 e << c; 668 e << c;
669 } else { 669 } else {
670 QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); 670 QCopEnvelope e( "QPE/System", "execute(QString,QString)" );
671 e << c << document; 671 e << c << document;
672 } 672 }
673#endif 673#endif
674 return; 674 return;
675} 675}
676 676
677/*! 677/*!
678 Returns the string \a s with the characters '\', '"', and '$' quoted 678 Returns the string \a s with the characters '\', '"', and '$' quoted
679 by a preceeding '\'. 679 by a preceeding '\'.
680 680
681 \sa stringQuote() 681 \sa stringQuote()
682*/ 682*/
683QString Global::shellQuote(const QString& s) 683QString Global::shellQuote(const QString& s)
684{ 684{
685 QString r="\""; 685 QString r="\"";
686 for (int i=0; i<(int)s.length(); i++) { 686 for (int i=0; i<(int)s.length(); i++) {
687 char c = s[i].latin1(); 687 char c = s[i].latin1();
688 switch (c) { 688 switch (c) {
689 case '\\': case '"': case '$': 689 case '\\': case '"': case '$':
690 r+="\\"; 690 r+="\\";
691 } 691 }
692 r += s[i]; 692 r += s[i];
693 } 693 }
694 r += "\""; 694 r += "\"";
695 return r; 695 return r;
696} 696}
697 697
698/*! 698/*!
699 Returns the string \a s with the characters '\' and '"' quoted by a 699 Returns the string \a s with the characters '\' and '"' quoted by a
700 preceeding '\'. 700 preceeding '\'.
701 701
702 \sa shellQuote() 702 \sa shellQuote()