summaryrefslogtreecommitdiff
path: root/library/global.cpp
Unidiff
Diffstat (limited to 'library/global.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/library/global.cpp b/library/global.cpp
index 9b908bf..d02e711 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -16,47 +16,43 @@
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
21#include <qpe/qpedebug.h> 21#include <qpe/qpedebug.h>
22#include <qpe/global.h> 22#include <qpe/global.h>
23#include <qpe/qdawg.h> 23#include <qpe/qdawg.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/storage.h> 26#include <qpe/storage.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 28#include <qpe/qcopenvelope_qws.h>
29#include "qpe/qcopenvelope_qws.h"
30#endif
31 29
32#include <qfile.h> 30#include <qfile.h>
33#include <qlabel.h> 31#include <qlabel.h>
34#include <qtimer.h> 32#include <qtimer.h>
35#include <qmap.h> 33#include <qmap.h>
36#include <qdict.h> 34#include <qdict.h>
37#include <qdir.h> 35#include <qdir.h>
38#include <qmessagebox.h> 36#include <qmessagebox.h>
39#include <qregexp.h> 37#include <qregexp.h>
40 38
41#include <stdlib.h> 39#include <stdlib.h>
42#include <sys/stat.h> 40#include <sys/stat.h>
43#include <sys/wait.h> 41#include <sys/wait.h>
44#include <sys/types.h> 42#include <sys/types.h>
45#include <fcntl.h> 43#include <fcntl.h>
46#include <unistd.h> 44#include <unistd.h>
47 45
48#ifdef QWS
49#include <qwindowsystem_qws.h> // for qwsServer 46#include <qwindowsystem_qws.h> // for qwsServer
50#endif
51#include <qdatetime.h> 47#include <qdatetime.h>
52 48
53#include <qfile.h> 49#include <qfile.h>
54 50
55namespace { 51namespace {
56 // checks if the storage should be searched 52 // checks if the storage should be searched
57 bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke 53 bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke
58 QFile file(path ); 54 QFile file(path );
59 if(!file.open(IO_ReadOnly ) ) 55 if(!file.open(IO_ReadOnly ) )
60 return true; 56 return true;
61 57
62 QByteArray array = file.readAll(); 58 QByteArray array = file.readAll();
@@ -101,31 +97,29 @@ private slots:
101private: 97private:
102 StartingAppList( QObject *parent=0, const char* name=0 ) ; 98 StartingAppList( QObject *parent=0, const char* name=0 ) ;
103 99
104 QDict<QTime> dict; 100 QDict<QTime> dict;
105 static StartingAppList *appl; 101 static StartingAppList *appl;
106}; 102};
107 103
108StartingAppList* StartingAppList::appl = 0; 104StartingAppList* StartingAppList::appl = 0;
109 105
110StartingAppList::StartingAppList( QObject *parent, const char* name ) 106StartingAppList::StartingAppList( QObject *parent, const char* name )
111 :QObject( parent, name ) 107 :QObject( parent, name )
112{ 108{
113#ifdef QWS
114#if QT_VERSION >= 232 && !defined(QT_NO_COP) 109#if QT_VERSION >= 232 && !defined(QT_NO_COP)
115 connect( qwsServer, SIGNAL( newChannel(const QString&)), 110 connect( qwsServer, SIGNAL( newChannel(const QString&)),
116 this, SLOT( handleNewChannel(const QString&)) ); 111 this, SLOT( handleNewChannel(const QString&)) );
117 dict.setAutoDelete( TRUE ); 112 dict.setAutoDelete( TRUE );
118#endif 113#endif
119#endif
120} 114}
121 115
122void StartingAppList::add( const QString& name ) 116void StartingAppList::add( const QString& name )
123{ 117{
124#if QT_VERSION >= 232 && !defined(QT_NO_COP) 118#if QT_VERSION >= 232 && !defined(QT_NO_COP)
125 if ( !appl ) 119 if ( !appl )
126 appl = new StartingAppList; 120 appl = new StartingAppList;
127 QTime *t = new QTime; 121 QTime *t = new QTime;
128 t->start(); 122 t->start();
129 appl->dict.insert( "QPE/Application/" + name, t ); 123 appl->dict.insert( "QPE/Application/" + name, t );
130#endif 124#endif
131} 125}
@@ -384,92 +378,92 @@ void Global::createDocDir()
384 docDirCreated = TRUE; 378 docDirCreated = TRUE;
385 mkdir( QPEApplication::documentDir().latin1(), 0755 ); 379 mkdir( QPEApplication::documentDir().latin1(), 0755 );
386 } 380 }
387} 381}
388 382
389 383
390/*! 384/*!
391 Displays a status \a message to the user. This usually appears 385 Displays a status \a message to the user. This usually appears
392 in the taskbar for a short amount of time, then disappears. 386 in the taskbar for a short amount of time, then disappears.
393*/ 387*/
394void Global::statusMessage(const QString& message) 388void Global::statusMessage(const QString& message)
395{ 389{
396#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 390#if!defined(QT_NO_COP)
397 QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); 391 QCopEnvelope e( "QPE/TaskBar", "message(QString)" );
398 e << message; 392 e << message;
399#endif 393#endif
400} 394}
401 395
402/*! 396/*!
403 \internal 397 \internal
404*/ 398*/
405void Global::applyStyle() 399void Global::applyStyle()
406{ 400{
407#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 401#if !defined(QT_NO_COP)
408 QCopChannel::send( "QPE/System", "applyStyle()" ); 402 QCopChannel::send( "QPE/System", "applyStyle()" );
409#else 403#else
410 ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version 404 ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version
411#endif 405#endif
412} 406}
413 407
414/*! 408/*!
415 \internal 409 \internal
416*/ 410*/
417QWidget *Global::shutdown( bool ) 411QWidget *Global::shutdown( bool )
418{ 412{
419#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 413#if !defined(QT_NO_COP)
420 QCopChannel::send( "QPE/System", "shutdown()" ); 414 QCopChannel::send( "QPE/System", "shutdown()" );
421#endif 415#endif
422 return 0; 416 return 0;
423} 417}
424 418
425/*! 419/*!
426 \internal 420 \internal
427*/ 421*/
428QWidget *Global::restart( bool ) 422QWidget *Global::restart( bool )
429{ 423{
430#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 424#if !defined(QT_NO_COP)
431 QCopChannel::send( "QPE/System", "restart()" ); 425 QCopChannel::send( "QPE/System", "restart()" );
432#endif 426#endif
433 return 0; 427 return 0;
434} 428}
435 429
436/*! 430/*!
437 Explicitly show the current input method. 431 Explicitly show the current input method.
438 432
439 Input methods are indicated in the taskbar by a small icon. If the 433 Input methods are indicated in the taskbar by a small icon. If the
440 input method is activated (shown) then it takes up some proportion 434 input method is activated (shown) then it takes up some proportion
441 of the bottom of the screen, to allow the user to interact (input 435 of the bottom of the screen, to allow the user to interact (input
442 characters) with it. 436 characters) with it.
443 437
444 \sa hideInputMethod() 438 \sa hideInputMethod()
445*/ 439*/
446void Global::showInputMethod() 440void Global::showInputMethod()
447{ 441{
448#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 442#if !defined(QT_NO_COP)
449 QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); 443 QCopChannel::send( "QPE/TaskBar", "showInputMethod()" );
450#endif 444#endif
451} 445}
452 446
453/*! 447/*!
454 Explicitly hide the current input method. 448 Explicitly hide the current input method.
455 449
456 The current input method is still indicated in the taskbar, but no 450 The current input method is still indicated in the taskbar, but no
457 longer takes up screen space, and can no longer be interacted with. 451 longer takes up screen space, and can no longer be interacted with.
458 452
459 \sa showInputMethod() 453 \sa showInputMethod()
460*/ 454*/
461void Global::hideInputMethod() 455void Global::hideInputMethod()
462{ 456{
463#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 457#if !defined(QT_NO_COP)
464 QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); 458 QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" );
465#endif 459#endif
466} 460}
467 461
468 462
469/*! 463/*!
470 \internal 464 \internal
471*/ 465*/
472bool Global::isBuiltinCommand( const QString &name ) 466bool Global::isBuiltinCommand( const QString &name )
473{ 467{
474 if(!builtin) 468 if(!builtin)
475 return FALSE; // yes, it can happen 469 return FALSE; // yes, it can happen
@@ -550,25 +544,25 @@ void Global::terminate( const AppLnk* app )
550/*! 544/*!
551 Low-level function to run command \a c. 545 Low-level function to run command \a c.
552 546
553 \warning Do not use this function. Use execute instead. 547 \warning Do not use this function. Use execute instead.
554 548
555 \sa execute() 549 \sa execute()
556*/ 550*/
557void Global::invoke(const QString &c) 551void Global::invoke(const QString &c)
558{ 552{
559 // Convert the command line in to a list of arguments 553 // Convert the command line in to a list of arguments
560 QStringList list = QStringList::split(QRegExp(" *"),c); 554 QStringList list = QStringList::split(QRegExp(" *"),c);
561 555
562#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 556#if !defined(QT_NO_COP)
563 QString ap=list[0]; 557 QString ap=list[0];
564 // see if the application is already running 558 // see if the application is already running
565 // XXX should lock file /tmp/qcop-msg-ap 559 // XXX should lock file /tmp/qcop-msg-ap
566 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { 560 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) {
567 // 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.
568 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } 562 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); }
569 563
570 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 564 QCopEnvelope e("QPE/System", "notBusy(QString)" );
571 e << ap; 565 e << ap;
572 return; 566 return;
573 } 567 }
574 // XXX should unlock file /tmp/qcop-msg-ap 568 // XXX should unlock file /tmp/qcop-msg-ap
@@ -586,25 +580,25 @@ void Global::invoke(const QString &c)
586#else 580#else
587 581
588 QStrList slist; 582 QStrList slist;
589 unsigned int j; 583 unsigned int j;
590 for ( j = 0; j < list.count(); j++ ) 584 for ( j = 0; j < list.count(); j++ )
591 slist.append( list[j].utf8() ); 585 slist.append( list[j].utf8() );
592 586
593 const char **args = new (const char *)[slist.count() + 1]; 587 const char **args = new (const char *)[slist.count() + 1];
594 for ( j = 0; j < slist.count(); j++ ) 588 for ( j = 0; j < slist.count(); j++ )
595 args[j] = slist.at(j); 589 args[j] = slist.at(j);
596 args[j] = NULL; 590 args[j] = NULL;
597 591
598#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 592#if !defined(QT_NO_COP)
599 // an attempt to show a wait... 593 // an attempt to show a wait...
600 // 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...
601 QCopEnvelope ( "QPE/System", "busy()" ); 595 QCopEnvelope ( "QPE/System", "busy()" );
602#endif 596#endif
603 597
604#ifdef HAVE_QUICKEXEC 598#ifdef HAVE_QUICKEXEC
605 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; 599 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so";
606 qDebug("libfile = %s", libexe.latin1() ); 600 qDebug("libfile = %s", libexe.latin1() );
607 if ( QFile::exists( libexe ) ) { 601 if ( QFile::exists( libexe ) ) {
608 qDebug("calling quickexec %s", libexe.latin1() ); 602 qDebug("calling quickexec %s", libexe.latin1() );
609 quickexecv( libexe.utf8().data(), (const char **)args ); 603 quickexecv( libexe.utf8().data(), (const char **)args );
610 } else 604 } else
@@ -627,25 +621,25 @@ void Global::invoke(const QString &c)
627 621
628/*! 622/*!
629 Executes the application identfied by \a c, passing \a 623 Executes the application identfied by \a c, passing \a
630 document if it isn't null. 624 document if it isn't null.
631 625
632 Note that a better approach might be to send a QCop message to the 626 Note that a better approach might be to send a QCop message to the
633 application's QPE/Application/\e{appname} channel. 627 application's QPE/Application/\e{appname} channel.
634*/ 628*/
635void Global::execute( const QString &c, const QString& document ) 629void Global::execute( const QString &c, const QString& document )
636{ 630{
637 if ( qApp->type() != QApplication::GuiServer ) { 631 if ( qApp->type() != QApplication::GuiServer ) {
638 // ask the server to do the work 632 // ask the server to do the work
639#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 633#if !defined(QT_NO_COP)
640 if ( document.isNull() ) { 634 if ( document.isNull() ) {
641 QCopEnvelope e( "QPE/System", "execute(QString)" ); 635 QCopEnvelope e( "QPE/System", "execute(QString)" );
642 e << c; 636 e << c;
643 } else { 637 } else {
644 QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); 638 QCopEnvelope e( "QPE/System", "execute(QString,QString)" );
645 e << c << document; 639 e << c << document;
646 } 640 }
647#endif 641#endif
648 return; 642 return;
649 } 643 }
650 644
651 // Attempt to execute the app using a builtin class for the app first 645 // Attempt to execute the app using a builtin class for the app first
@@ -667,25 +661,25 @@ void Global::execute( const QString &c, const QString& document )
667 e << c; // that was quick ;-) 661 e << c; // that was quick ;-)
668#endif 662#endif
669 return; 663 return;
670 } 664 }
671 } 665 }
672 } 666 }
673 667
674 //Global::invoke(c, document); 668 //Global::invoke(c, document);
675 669
676 // Convert the command line in to a list of arguments 670 // Convert the command line in to a list of arguments
677 QStringList list = QStringList::split(QRegExp(" *"),c); 671 QStringList list = QStringList::split(QRegExp(" *"),c);
678 672
679#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 673#if !defined(QT_NO_COP)
680 QString ap=list[0]; 674 QString ap=list[0];
681 675
682 qDebug("executing %s", ap.latin1() ); 676 qDebug("executing %s", ap.latin1() );
683 677
684 /* if need be, sending a qcop message will result in an invoke, see 678 /* if need be, sending a qcop message will result in an invoke, see
685 preceeding function */ 679 preceeding function */
686 invoke( ap ); 680 invoke( ap );
687 //{ QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } 681 //{ QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); }
688 if ( !document.isEmpty() ) { 682 if ( !document.isEmpty() ) {
689 QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); 683 QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" );
690 env << document; 684 env << document;
691 } 685 }