summaryrefslogtreecommitdiff
path: root/library/global.cpp
authorsandman <sandman>2002-11-24 18:21:41 (UTC)
committer sandman <sandman>2002-11-24 18:21:41 (UTC)
commit89bf0723eefc1e66a104fe8135f1a5389f021442 (patch) (unidiff)
treea7db1ba8fa34d8226fe9baa9e7c488c86ad95445 /library/global.cpp
parentee62e73ddc29a5015c4a3e569be90dbfce4652c6 (diff)
downloadopie-89bf0723eefc1e66a104fe8135f1a5389f021442.zip
opie-89bf0723eefc1e66a104fe8135f1a5389f021442.tar.gz
opie-89bf0723eefc1e66a104fe8135f1a5389f021442.tar.bz2
- LD_PRELOADing of libpreload.so in case the user selected [x] Force style
settings in appearance - Some code to NOT style some applications, based on the binary name (also selectable in appearance)
Diffstat (limited to 'library/global.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/library/global.cpp b/library/global.cpp
index 9b3c51e..42c2729 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -559,105 +559,121 @@ void Global::invoke(const QString &c)
559 // XXX should lock file /tmp/qcop-msg-ap 559 // XXX should lock file /tmp/qcop-msg-ap
560 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { 560 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) {
561 // If the channel is already register, the app is already running, so show it. 561 // If the channel is already register, the app is already running, so show it.
562 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } 562 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); }
563 563
564 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 564 QCopEnvelope e("QPE/System", "notBusy(QString)" );
565 e << ap; 565 e << ap;
566 return; 566 return;
567 } 567 }
568 // XXX should unlock file /tmp/qcop-msg-ap 568 // XXX should unlock file /tmp/qcop-msg-ap
569 //see if it is being started 569 //see if it is being started
570 if ( StartingAppList::isStarting( ap ) ) { 570 if ( StartingAppList::isStarting( ap ) ) {
571 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 571 QCopEnvelope e("QPE/System", "notBusy(QString)" );
572 e << ap; 572 e << ap;
573 return; 573 return;
574 } 574 }
575 575
576#endif 576#endif
577 577
578#ifdef QT_NO_QWS_MULTIPROCESS 578#ifdef QT_NO_QWS_MULTIPROCESS
579 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); 579 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 );
580#else 580#else
581 581
582 QStrList slist; 582 QStrList slist;
583 unsigned int j; 583 unsigned int j;
584 for ( j = 0; j < list.count(); j++ ) 584 for ( j = 0; j < list.count(); j++ )
585 slist.append( list[j].utf8() ); 585 slist.append( list[j].utf8() );
586 586
587 const char **args = new (const char *)[slist.count() + 1]; 587 const char **args = new (const char *)[slist.count() + 1];
588 for ( j = 0; j < slist.count(); j++ ) 588 for ( j = 0; j < slist.count(); j++ )
589 args[j] = slist.at(j); 589 args[j] = slist.at(j);
590 args[j] = NULL; 590 args[j] = NULL;
591 591
592#if !defined(QT_NO_COP) 592#if !defined(QT_NO_COP)
593 // an attempt to show a wait... 593 // an attempt to show a wait...
594 // more logic should be used, but this will be fine for the moment... 594 // more logic should be used, but this will be fine for the moment...
595 QCopEnvelope ( "QPE/System", "busy()" ); 595 QCopEnvelope ( "QPE/System", "busy()" );
596#endif 596#endif
597 597
598#ifdef HAVE_QUICKEXEC 598#ifdef HAVE_QUICKEXEC
599 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; 599 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so";
600 qDebug("libfile = %s", libexe.latin1() ); 600 qDebug("libfile = %s", libexe.latin1() );
601 if ( QFile::exists( libexe ) ) { 601 if ( QFile::exists( libexe ) ) {
602 qDebug("calling quickexec %s", libexe.latin1() ); 602 qDebug("calling quickexec %s", libexe.latin1() );
603 quickexecv( libexe.utf8().data(), (const char **)args ); 603 quickexecv( libexe.utf8().data(), (const char **)args );
604 } else 604 } else
605#endif 605#endif
606 { 606 {
607 char *oldpre = ::getenv ( "LD_PRELOAD" );
608
609 extern bool opie_block_style;
610
611 QString newpre = QPEApplication::qpeDir ( ) + "/lib/libpreload.so";
612 if ( opie_block_style && QFile::exists ( newpre )) {
613 if ( oldpre && oldpre [0] )
614 newpre = newpre + ":" + oldpre;
615 ::setenv ( "LD_PRELOAD", newpre. latin1( ), 1 );
616 qDebug ( "\nPRELOADING\n" );
617 }
618
607 if ( !::vfork() ) { 619 if ( !::vfork() ) {
608 for ( int fd = 3; fd < 100; fd++ ) 620 for ( int fd = 3; fd < 100; fd++ )
609 ::close( fd ); 621 ::close( fd );
610 ::setpgid( ::getpid(), ::getppid() ); 622 ::setpgid( ::getpid(), ::getppid() );
611 // Try bindir first, so that foo/bar works too 623 // Try bindir first, so that foo/bar works too
612 ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); 624 ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args );
613 ::execvp( args[0], (char * const *)args ); 625 ::execvp( args[0], (char * const *)args );
614 _exit( -1 ); 626 _exit( -1 );
615 } 627 }
628 if ( oldpre )
629 ::setenv ( "LD_PRELOAD", oldpre, 1 );
630 else
631 ::unsetenv ( "LD_PRELOAD" );
616 } 632 }
617 StartingAppList::add( list[0] ); 633 StartingAppList::add( list[0] );
618#endif //QT_NO_QWS_MULTIPROCESS 634#endif //QT_NO_QWS_MULTIPROCESS
619} 635}
620 636
621 637
622/*! 638/*!
623 Executes the application identfied by \a c, passing \a 639 Executes the application identfied by \a c, passing \a
624 document if it isn't null. 640 document if it isn't null.
625 641
626 Note that a better approach might be to send a QCop message to the 642 Note that a better approach might be to send a QCop message to the
627 application's QPE/Application/\e{appname} channel. 643 application's QPE/Application/\e{appname} channel.
628*/ 644*/
629void Global::execute( const QString &c, const QString& document ) 645void Global::execute( const QString &c, const QString& document )
630{ 646{
631 if ( qApp->type() != QApplication::GuiServer ) { 647 if ( qApp->type() != QApplication::GuiServer ) {
632 // ask the server to do the work 648 // ask the server to do the work
633#if !defined(QT_NO_COP) 649#if !defined(QT_NO_COP)
634 if ( document.isNull() ) { 650 if ( document.isNull() ) {
635 QCopEnvelope e( "QPE/System", "execute(QString)" ); 651 QCopEnvelope e( "QPE/System", "execute(QString)" );
636 e << c; 652 e << c;
637 } else { 653 } else {
638 QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); 654 QCopEnvelope e( "QPE/System", "execute(QString,QString)" );
639 e << c << document; 655 e << c << document;
640 } 656 }
641#endif 657#endif
642 return; 658 return;
643 } 659 }
644 660
645 // Attempt to execute the app using a builtin class for the app first 661 // Attempt to execute the app using a builtin class for the app first
646 // else try and find it in the bin directory 662 // else try and find it in the bin directory
647 if (builtin) { 663 if (builtin) {
648 for (int i = 0; builtin[i].file; i++) { 664 for (int i = 0; builtin[i].file; i++) {
649 if ( builtin[i].file == c ) { 665 if ( builtin[i].file == c ) {
650 if ( running[i] ) { 666 if ( running[i] ) {
651 if ( !document.isNull() && builtin[i].documentary ) 667 if ( !document.isNull() && builtin[i].documentary )
652 setDocument(running[i], document); 668 setDocument(running[i], document);
653 running[i]->raise(); 669 running[i]->raise();
654 running[i]->show(); 670 running[i]->show();
655 running[i]->setActiveWindow(); 671 running[i]->setActiveWindow();
656 } else { 672 } else {
657 running[i] = builtin[i].func( builtin[i].maximized ); 673 running[i] = builtin[i].func( builtin[i].maximized );
658 } 674 }
659#ifndef QT_NO_COP 675#ifndef QT_NO_COP
660 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 676 QCopEnvelope e("QPE/System", "notBusy(QString)" );
661 e << c; // that was quick ;-) 677 e << c; // that was quick ;-)
662#endif 678#endif
663 return; 679 return;