author | zecke <zecke> | 2003-08-25 14:46:43 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-25 14:46:43 (UTC) |
commit | 292b097e7db25dd231381c5b09307a1fbe81a492 (patch) (unidiff) | |
tree | b103c6c5e15e784dc07af55539672a72559da821 /library | |
parent | 5f292b6e4fc0f4ee8e4bced9a916f6bdce864b6b (diff) | |
download | opie-292b097e7db25dd231381c5b09307a1fbe81a492.zip opie-292b097e7db25dd231381c5b09307a1fbe81a492.tar.gz opie-292b097e7db25dd231381c5b09307a1fbe81a492.tar.bz2 |
-instead of defining for an board we define now what this
boards need
QPE_NEED_CALIBRATE
-launcher is the only one executin application
-allow processing of QCOPfiles after start ( qpeapplication )
-qcopenvelope no longer calls Global::execute
-rw-r--r-- | library/custom-ipaq.h | 1 | ||||
-rw-r--r-- | library/custom-ramses.h | 1 | ||||
-rw-r--r-- | library/custom-sharp.h | 1 | ||||
-rw-r--r-- | library/custom-simpad.h | 7 | ||||
-rw-r--r-- | library/global.cpp | 59 | ||||
-rw-r--r-- | library/inputmethodinterface.h | 19 | ||||
-rw-r--r-- | library/qcopenvelope_qws.cpp | 66 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 152 | ||||
-rw-r--r-- | library/qpeapplication.h | 6 |
9 files changed, 183 insertions, 129 deletions
diff --git a/library/custom-ipaq.h b/library/custom-ipaq.h index 553b571..a9319fa 100644 --- a/library/custom-ipaq.h +++ b/library/custom-ipaq.h | |||
@@ -13,8 +13,9 @@ | |||
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QPE_NEED_CALIBRATION \ No newline at end of file | ||
diff --git a/library/custom-ramses.h b/library/custom-ramses.h index b841a66..9104931 100644 --- a/library/custom-ramses.h +++ b/library/custom-ramses.h | |||
@@ -13,16 +13,17 @@ | |||
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QPE_NEED_CALIBRATION | ||
21 | #define QPE_HAVE_TOGGLELIGHT | 22 | #define QPE_HAVE_TOGGLELIGHT |
22 | #define QPE_STARTMENU | 23 | #define QPE_STARTMENU |
23 | 24 | ||
24 | #include <unistd.h> | 25 | #include <unistd.h> |
25 | #include <stdio.h> | 26 | #include <stdio.h> |
26 | #include <signal.h> | 27 | #include <signal.h> |
27 | #include <fcntl.h> | 28 | #include <fcntl.h> |
28 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
diff --git a/library/custom-sharp.h b/library/custom-sharp.h index 3dab34f..3936875 100644 --- a/library/custom-sharp.h +++ b/library/custom-sharp.h | |||
@@ -13,16 +13,17 @@ | |||
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QPE_NEED_CALIBRATION | ||
21 | #define QPE_OWNAPM | 22 | #define QPE_OWNAPM |
22 | #define QPE_HAVE_TOGGLELIGHT | 23 | #define QPE_HAVE_TOGGLELIGHT |
23 | #define QPE_NOCIBAUD | 24 | #define QPE_NOCIBAUD |
24 | #define QPE_STARTMENU | 25 | #define QPE_STARTMENU |
25 | #include <asm/sharp_apm.h> | 26 | #include <asm/sharp_apm.h> |
26 | #ifndef APM_IOC_BATTERY_BACK_CHK | 27 | #ifndef APM_IOC_BATTERY_BACK_CHK |
27 | #define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) | 28 | #define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) |
28 | #endif | 29 | #endif |
diff --git a/library/custom-simpad.h b/library/custom-simpad.h new file mode 100644 index 0000000..3872dfd --- a/dev/null +++ b/library/custom-simpad.h | |||
@@ -0,0 +1,7 @@ | |||
1 | /* | ||
2 | * GPLv2 only zecke@handhelds.org | ||
3 | hOlgAr | ||
4 | */ | ||
5 | |||
6 | |||
7 | #define QPE_NEED_CALIBRATION \ No newline at end of file | ||
diff --git a/library/global.cpp b/library/global.cpp index 189b830..5c89430 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -671,72 +671,27 @@ void Global::invoke(const QString &c) | |||
671 | Executes the application identfied by \a c, passing \a | 671 | Executes the application identfied by \a c, passing \a |
672 | document if it isn't null. | 672 | document if it isn't null. |
673 | 673 | ||
674 | Note that a better approach might be to send a QCop message to the | 674 | Note that a better approach might be to send a QCop message to the |
675 | application's QPE/Application/\e{appname} channel. | 675 | application's QPE/Application/\e{appname} channel. |
676 | */ | 676 | */ |
677 | void Global::execute( const QString &c, const QString& document ) | 677 | void Global::execute( const QString &c, const QString& document ) |
678 | { | 678 | { |
679 | if ( qApp->type() != QApplication::GuiServer ) { | ||
680 | // ask the server to do the work | 679 | // ask the server to do the work |
681 | #if !defined(QT_NO_COP) | 680 | #if !defined(QT_NO_COP) |
682 | if ( document.isNull() ) { | 681 | if ( document.isNull() ) { |
683 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 682 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
684 | e << c; | 683 | e << c; |
685 | } else { | 684 | } else { |
686 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); | 685 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); |
687 | e << c << document; | 686 | e << c << document; |
688 | } | ||
689 | #endif | ||
690 | return; | ||
691 | } | ||
692 | |||
693 | // Attempt to execute the app using a builtin class for the app first | ||
694 | // else try and find it in the bin directory | ||
695 | if (builtin) { | ||
696 | for (int i = 0; builtin[i].file; i++) { | ||
697 | if ( builtin[i].file == c ) { | ||
698 | if ( running[i] ) { | ||
699 | if ( !document.isNull() && builtin[i].documentary ) | ||
700 | setDocument(running[i], document); | ||
701 | running[i]->raise(); | ||
702 | running[i]->show(); | ||
703 | running[i]->setActiveWindow(); | ||
704 | } else { | ||
705 | running[i] = builtin[i].func( builtin[i].maximized ); | ||
706 | } | ||
707 | #ifndef QT_NO_COP | ||
708 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | ||
709 | e << c; // that was quick ;-) | ||
710 | #endif | ||
711 | return; | ||
712 | } | ||
713 | } | ||
714 | } | ||
715 | |||
716 | //Global::invoke(c, document); | ||
717 | |||
718 | // Convert the command line in to a list of arguments | ||
719 | QStringList list = QStringList::split(QRegExp(" *"),c); | ||
720 | |||
721 | #if !defined(QT_NO_COP) | ||
722 | QString ap=list[0]; | ||
723 | |||
724 | qDebug("executing %s", ap.latin1() ); | ||
725 | |||
726 | /* if need be, sending a qcop message will result in an invoke, see | ||
727 | preceeding function */ | ||
728 | invoke( ap ); | ||
729 | //{ QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | ||
730 | if ( !document.isEmpty() ) { | ||
731 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); | ||
732 | env << document; | ||
733 | } | 687 | } |
734 | #endif | 688 | #endif |
689 | return; | ||
735 | } | 690 | } |
736 | 691 | ||
737 | /*! | 692 | /*! |
738 | Returns the string \a s with the characters '\', '"', and '$' quoted | 693 | Returns the string \a s with the characters '\', '"', and '$' quoted |
739 | by a preceeding '\'. | 694 | by a preceeding '\'. |
740 | 695 | ||
741 | \sa stringQuote() | 696 | \sa stringQuote() |
742 | */ | 697 | */ |
diff --git a/library/inputmethodinterface.h b/library/inputmethodinterface.h index 88a121d..488f601 100644 --- a/library/inputmethodinterface.h +++ b/library/inputmethodinterface.h | |||
@@ -42,23 +42,34 @@ struct InputMethodInterface : public QUnknownInterface | |||
42 | { | 42 | { |
43 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ) = 0; | 43 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ) = 0; |
44 | virtual void resetState() = 0; | 44 | virtual void resetState() = 0; |
45 | virtual QPixmap *icon() = 0; | 45 | virtual QPixmap *icon() = 0; |
46 | virtual QString name() = 0; | 46 | virtual QString name() = 0; |
47 | virtual void onKeyPress( QObject *receiver, const char *slot ) = 0; | 47 | virtual void onKeyPress( QObject *receiver, const char *slot ) = 0; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | // {70F0991C-8282-4625-A279-BD9D7D959FF6} | 50 | // {70F0991C-8282-4625-A279-BD9D7D959FF6} |
51 | #ifndef IID_ExtInputMethod | 51 | #ifndef IID_ExtInputMethod |
52 | #define IID_ExtInputMethod QUuid( 0x70f0991c, 0x8282, 0x4625, 0xa2, 0x79, 0xbd, 0x9d, 0x7d, 0x95, 0x9f, 0xf6) | 52 | #define IID_ExtInputMethod QUuid( 0x70f0991c, 0x8282, 0x4625, 0xa2, 0x79, 0xbd, 0x9d, 0x7d, 0x95, 0x9f, 0xf6) |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | struct ExtInputMethodInterface : public QUnknownInterface | 55 | struct ExtInputMethodInterface : public QUnknownInterface |
56 | { | 56 | { |
57 | virtual QWSInputMethod *inputMethod() = 0; | 57 | //identifying functions. |
58 | virtual QPixmap *icon() = 0; | ||
59 | virtual QString name() = 0; | 58 | virtual QString name() = 0; |
60 | virtual QWidget *widget( QWidget *parent, Qt::WFlags f )= 0; | 59 | virtual QPixmap *icon() = 0; |
60 | |||
61 | // state managment. | ||
62 | virtual void resetState() = 0; | ||
63 | |||
64 | virtual QWidget *keyboardWidget( QWidget *parent, Qt::WFlags f ) = 0; | ||
65 | // filenames, not menu names. | ||
66 | virtual QStringList compatible() = 0; | ||
67 | |||
68 | virtual QWSInputMethod *inputMethod() = 0; | ||
69 | virtual QWidget *statusWidget( QWidget *parent, Qt::WFlags f )= 0; | ||
70 | |||
71 | virtual void qcopReceive( const QCString &msg, const QByteArray &data )= 0; | ||
61 | }; | 72 | }; |
62 | 73 | ||
63 | 74 | ||
64 | #endif | 75 | #endif |
diff --git a/library/qcopenvelope_qws.cpp b/library/qcopenvelope_qws.cpp index 81bb0f5..0aac32b 100644 --- a/library/qcopenvelope_qws.cpp +++ b/library/qcopenvelope_qws.cpp | |||
@@ -97,77 +97,51 @@ QCopEnvelope::~QCopEnvelope() | |||
97 | QByteArray data = ((QBuffer*)device())->buffer(); | 97 | QByteArray data = ((QBuffer*)device())->buffer(); |
98 | const int pref=16; | 98 | const int pref=16; |
99 | if ( qstrncmp(ch.data(),"QPE/Application/",pref)==0 ) { | 99 | if ( qstrncmp(ch.data(),"QPE/Application/",pref)==0 ) { |
100 | QString qcopfn("/tmp/qcop-msg-"); | 100 | QString qcopfn("/tmp/qcop-msg-"); |
101 | qcopfn += ch.mid(pref); | 101 | qcopfn += ch.mid(pref); |
102 | QFile qcopfile(qcopfn); | 102 | QFile qcopfile(qcopfn); |
103 | 103 | ||
104 | if ( qcopfile.open(IO_WriteOnly | IO_Append) ) { | 104 | if ( qcopfile.open(IO_WriteOnly | IO_Append) ) { |
105 | #ifndef Q_OS_WIN32 | ||
105 | if(flock(qcopfile.handle(), LOCK_EX)) { | 106 | if(flock(qcopfile.handle(), LOCK_EX)) { |
106 | /* some error occured */ | 107 | /* some error occurred */ |
107 | qWarning(QString("Failed to obtain file lock on %1 (%2)") | 108 | qWarning(QString("Failed to obtain file lock on %1 (%2)") |
108 | .arg(qcopfn).arg( errno )); | 109 | .arg(qcopfn).arg( errno )); |
109 | } | 110 | } |
110 | /* file locked, but might be stale (e.g. program for whatever | 111 | #endif |
111 | reason did not start). I modified more than 1 minute ago, | 112 | { |
112 | truncate the file */ | 113 | QDataStream ds(&qcopfile); |
113 | struct stat buf; | 114 | ds << ch << msg << data; |
114 | time_t t; | 115 | qcopfile.flush(); |
115 | if (!fstat(qcopfile.handle(), &buf) && (time(&t) != (time_t)-1) ) { | 116 | #ifndef Q_OS_WIN32 |
116 | // success on fstat, lets compare times | 117 | flock(qcopfile.handle(), LOCK_UN); |
117 | if (buf.st_ctime + 60 < t) { | 118 | #endif |
118 | qWarning("stale file " + qcopfn + " found. Truncating"); | 119 | qcopfile.close(); |
119 | ftruncate(qcopfile.handle(), 0); | ||
120 | qcopfile.reset(); | ||
121 | } | ||
122 | } | 120 | } |
123 | 121 | ||
124 | if ( !QCopChannel::isRegistered(ch) ) { | 122 | QByteArray b; |
125 | int fsize = qcopfile.size(); | 123 | QDataStream stream(b, IO_WriteOnly); |
126 | { | 124 | stream << QString(ch.mid(pref)); |
127 | QDataStream ds(&qcopfile); | 125 | QCopChannel::send("QPE/Server", "processQCop(QString)", b); |
128 | ds << ch << msg << data; | 126 | delete device(); |
129 | flock(qcopfile.handle(), LOCK_UN); | 127 | return; |
130 | qcopfile.close(); | ||
131 | } | ||
132 | |||
133 | if (fsize == 0) { | ||
134 | QString cmd = ch.mid(pref); | ||
135 | Global::execute(cmd); | ||
136 | } | ||
137 | |||
138 | char c; | ||
139 | for (int i=0; (c=msg[i]); i++) { | ||
140 | if ( c == ' ' ) { | ||
141 | // Return-value required | ||
142 | // ###### wait for it | ||
143 | break; | ||
144 | } else if ( c == '(' ) { | ||
145 | // No return value | ||
146 | break; | ||
147 | } | ||
148 | } | ||
149 | goto end; | ||
150 | } // endif isRegisterd | ||
151 | flock(qcopfile.handle(), LOCK_UN); | ||
152 | qcopfile.close(); | ||
153 | qcopfile.remove(); | ||
154 | } else { | 128 | } else { |
155 | qWarning(QString("Failed to obtain file lock on %1") | 129 | qWarning(QString("Failed to open file %1") |
156 | .arg(qcopfn)); | 130 | .arg(qcopfn)); |
157 | } // endif open | 131 | } // endif open |
158 | } | 132 | } |
159 | else if (qstrncmp(ch.data(), "QPE/SOAP/", 9) == 0) { | 133 | else if (qstrncmp(ch.data(), "QPE/SOAP/", 9) == 0) { |
160 | // If this is a message that should go along the SOAP channel, we move the | 134 | // If this is a message that should go along the SOAP channel, we move the |
161 | // endpoint URL to the data section. | 135 | // endpoint URL to the data section. |
162 | QString endpoint = ch.mid(9); | 136 | QString endpoint = ch.mid(9); |
163 | 137 | ||
164 | ch = "QPE/SOAP"; | 138 | ch = "QPE/SOAP"; |
165 | // Since byte arrays are explicitly shared, this is appended to the data variable.. | 139 | // Since byte arrays are explicitly shared, this is appended to the data variable.. |
166 | *this << endpoint; | 140 | *this << endpoint; |
167 | } | 141 | } |
142 | |||
168 | QCopChannel::send(ch,msg,data); | 143 | QCopChannel::send(ch,msg,data); |
169 | end: | ||
170 | delete device(); | 144 | delete device(); |
171 | } | 145 | } |
172 | 146 | ||
173 | #endif | 147 | #endif |
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index d1a7cd2..b1b7ed4 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -46,16 +46,19 @@ | |||
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdragobject.h> | 48 | #include <qdragobject.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qevent.h> | 50 | #include <qevent.h> |
51 | #include <qtooltip.h> | 51 | #include <qtooltip.h> |
52 | #include <qsignal.h> | 52 | #include <qsignal.h> |
53 | #include <qmainwindow.h> | 53 | #include <qmainwindow.h> |
54 | |||
55 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
56 | #define QTOPIA_INTERNAL_INITAPP | ||
54 | #include "qpeapplication.h" | 57 | #include "qpeapplication.h" |
55 | #include "qpestyle.h" | 58 | #include "qpestyle.h" |
56 | #include "styleinterface.h" | 59 | #include "styleinterface.h" |
57 | #if QT_VERSION >= 300 | 60 | #if QT_VERSION >= 300 |
58 | #include <qstylefactory.h> | 61 | #include <qstylefactory.h> |
59 | #else | 62 | #else |
60 | #include <qplatinumstyle.h> | 63 | #include <qplatinumstyle.h> |
61 | #include <qwindowsstyle.h> | 64 | #include <qwindowsstyle.h> |
@@ -300,16 +303,26 @@ public: | |||
300 | while ( !r && sl > 0 ); | 303 | while ( !r && sl > 0 ); |
301 | } | 304 | } |
302 | return r; | 305 | return r; |
303 | } | 306 | } |
304 | private: | 307 | private: |
305 | mutable QImageDrag *resImage; | 308 | mutable QImageDrag *resImage; |
306 | }; | 309 | }; |
307 | 310 | ||
311 | static int& hack(int& i) | ||
312 | { | ||
313 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | ||
314 | // These should be created, but aren't in Qt 2.3.0 | ||
315 | (void)new QUtf8Codec; | ||
316 | (void)new QUtf16Codec; | ||
317 | #endif | ||
318 | return i; | ||
319 | } | ||
320 | |||
308 | static int muted = 0; | 321 | static int muted = 0; |
309 | static int micMuted = 0; | 322 | static int micMuted = 0; |
310 | 323 | ||
311 | static void setVolume( int t = 0, int percent = -1 ) | 324 | static void setVolume( int t = 0, int percent = -1 ) |
312 | { | 325 | { |
313 | switch ( t ) { | 326 | switch ( t ) { |
314 | case 0: { | 327 | case 0: { |
315 | Config cfg( "qpe" ); | 328 | Config cfg( "qpe" ); |
@@ -481,16 +494,45 @@ static void setTreble( int t = 0, int percent = -1 ) | |||
481 | ### | 494 | ### |
482 | */ | 495 | */ |
483 | 496 | ||
484 | /*! | 497 | /*! |
485 | \fn void QPEApplication::reload() | 498 | \fn void QPEApplication::reload() |
486 | 499 | ||
487 | */ | 500 | */ |
488 | 501 | ||
502 | |||
503 | |||
504 | void QPEApplication::processQCopFile() | ||
505 | { | ||
506 | QString qcopfn("/tmp/qcop-msg-"); | ||
507 | qcopfn += d->appName; // append command name | ||
508 | |||
509 | QFile f(qcopfn); | ||
510 | if ( f.open(IO_ReadWrite) ) { | ||
511 | #ifndef Q_OS_WIN32 | ||
512 | flock(f.handle(), LOCK_EX); | ||
513 | #endif | ||
514 | QDataStream ds(&f); | ||
515 | QCString channel, message; | ||
516 | QByteArray data; | ||
517 | while(!ds.atEnd()) { | ||
518 | ds >> channel >> message >> data; | ||
519 | d->enqueueQCop(channel,message,data); | ||
520 | } | ||
521 | ::ftruncate(f.handle(), 0); | ||
522 | #ifndef Q_OS_WIN32 | ||
523 | f.flush(); | ||
524 | flock(f.handle(), LOCK_UN); | ||
525 | #endif | ||
526 | } | ||
527 | #endif | ||
528 | } | ||
529 | |||
530 | |||
489 | /*! | 531 | /*! |
490 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 532 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
491 | 533 | ||
492 | This signal is emitted when a message is received on this | 534 | This signal is emitted when a message is received on this |
493 | application's QPE/Application/<i>appname</i> \link qcop.html | 535 | application's QPE/Application/<i>appname</i> \link qcop.html |
494 | QCop\endlink channel. | 536 | QCop\endlink channel. |
495 | 537 | ||
496 | The slot to which you connect this signal uses \a msg and \a data | 538 | The slot to which you connect this signal uses \a msg and \a data |
@@ -518,17 +560,17 @@ static void setTreble( int t = 0, int percent = -1 ) | |||
518 | /*! | 560 | /*! |
519 | Constructs a QPEApplication just as you would construct | 561 | Constructs a QPEApplication just as you would construct |
520 | a QApplication, passing \a argc, \a argv, and \a t. | 562 | a QApplication, passing \a argc, \a argv, and \a t. |
521 | 563 | ||
522 | For applications, \a t should be the default, GuiClient. Only | 564 | For applications, \a t should be the default, GuiClient. Only |
523 | the Qtopia server passes GuiServer. | 565 | the Qtopia server passes GuiServer. |
524 | */ | 566 | */ |
525 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 567 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
526 | : QApplication( argc, argv, t ) | 568 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
527 | { | 569 | { |
528 | d = new QPEApplicationData; | 570 | d = new QPEApplicationData; |
529 | d->loadTextCodecs(); | 571 | d->loadTextCodecs(); |
530 | d->loadImageCodecs(); | 572 | d->loadImageCodecs(); |
531 | int dw = desktop() ->width(); | 573 | int dw = desktop() ->width(); |
532 | 574 | ||
533 | if ( dw < 200 ) { | 575 | if ( dw < 200 ) { |
534 | setFont( QFont( "vera", 8 ) ); | 576 | setFont( QFont( "vera", 8 ) ); |
@@ -546,29 +588,35 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
546 | setFont( QFont( "vera", 10 ) ); | 588 | setFont( QFont( "vera", 10 ) ); |
547 | AppLnk::setSmallIconSize( 14 ); | 589 | AppLnk::setSmallIconSize( 14 ); |
548 | AppLnk::setBigIconSize( 32 ); | 590 | AppLnk::setBigIconSize( 32 ); |
549 | } | 591 | } |
550 | 592 | ||
551 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 593 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
552 | 594 | ||
553 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 595 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
596 | |||
597 | |||
598 | sysChannel = new QCopChannel( "QPE/System", this ); | ||
599 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | ||
600 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | ||
601 | |||
602 | /* COde now in initapp */ | ||
603 | #if 0 | ||
554 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 604 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
555 | 605 | ||
556 | QString qcopfn( "/tmp/qcop-msg-" ); | 606 | QString qcopfn( "/tmp/qcop-msg-" ); |
557 | qcopfn += QString( argv[ 0 ] ); // append command name | 607 | qcopfn += QString( argv[ 0 ] ); // append command name |
558 | 608 | ||
559 | QFile f( qcopfn ); | 609 | QFile f( qcopfn ); |
560 | if ( f.open( IO_ReadOnly ) ) { | 610 | if ( f.open( IO_ReadOnly ) ) { |
561 | flock( f.handle(), LOCK_EX ); | 611 | flock( f.handle(), LOCK_EX ); |
562 | } | 612 | } |
563 | 613 | ||
564 | sysChannel = new QCopChannel( "QPE/System", this ); | 614 | |
565 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | ||
566 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | ||
567 | 615 | ||
568 | QCString channel = QCString( argv[ 0 ] ); | 616 | QCString channel = QCString( argv[ 0 ] ); |
569 | channel.replace( QRegExp( ".*/" ), "" ); | 617 | channel.replace( QRegExp( ".*/" ), "" ); |
570 | d->appName = channel; | 618 | d->appName = channel; |
571 | channel = "QPE/Application/" + channel; | 619 | channel = "QPE/Application/" + channel; |
572 | pidChannel = new QCopChannel( channel, this ); | 620 | pidChannel = new QCopChannel( channel, this ); |
573 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 621 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
574 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 622 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
@@ -603,40 +651,41 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
603 | argc -= 1; | 651 | argc -= 1; |
604 | } | 652 | } |
605 | } | 653 | } |
606 | 654 | ||
607 | /* overide stored arguments */ | 655 | /* overide stored arguments */ |
608 | setArgs( argc, argv ); | 656 | setArgs( argc, argv ); |
609 | 657 | ||
610 | #endif | 658 | #endif |
611 | 659 | #else | |
660 | initApp( argc, argv ); | ||
661 | #endif | ||
612 | // qwsSetDecoration( new QPEDecoration() ); | 662 | // qwsSetDecoration( new QPEDecoration() ); |
613 | 663 | ||
614 | #ifndef QT_NO_TRANSLATION | 664 | #ifndef QT_NO_TRANSLATION |
615 | 665 | ||
616 | QStringList langs = Global::languageList(); | 666 | QStringList langs = Global::languageList(); |
617 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 667 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
618 | QString lang = *it; | 668 | QString lang = *it; |
619 | 669 | ||
620 | installTranslation( lang + "/libopie.qm"); | 670 | installTranslation( lang + "/libopie.qm"); |
621 | installTranslation( lang + "/libqpe.qm" ); | 671 | installTranslation( lang + "/libqpe.qm" ); |
622 | installTranslation( lang + "/" + d->appName + ".qm" ); | 672 | installTranslation( lang + "/" + d->appName + ".qm" ); |
623 | 673 | ||
624 | 674 | ||
625 | //###language/font hack; should look it up somewhere | 675 | //###language/font hack; should look it up somewhere |
626 | #ifdef QWS | 676 | #ifdef QWS |
627 | 677 | ||
628 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 678 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
629 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 679 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
630 | setFont( fn ); | 680 | setFont( fn ); |
631 | } | 681 | } |
632 | #endif | 682 | #endif |
633 | 683 | } | |
634 | } | ||
635 | #endif | 684 | #endif |
636 | 685 | ||
637 | applyStyle(); | 686 | applyStyle(); |
638 | 687 | ||
639 | if ( type() == GuiServer ) { | 688 | if ( type() == GuiServer ) { |
640 | setVolume(); | 689 | setVolume(); |
641 | } | 690 | } |
642 | 691 | ||
@@ -645,16 +694,61 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
645 | QPEMenuToolFocusManager::initialize(); | 694 | QPEMenuToolFocusManager::initialize(); |
646 | 695 | ||
647 | #ifdef QT_NO_QWS_CURSOR | 696 | #ifdef QT_NO_QWS_CURSOR |
648 | // if we have no cursor, probably don't want tooltips | 697 | // if we have no cursor, probably don't want tooltips |
649 | QToolTip::setEnabled( FALSE ); | 698 | QToolTip::setEnabled( FALSE ); |
650 | #endif | 699 | #endif |
651 | } | 700 | } |
652 | 701 | ||
702 | |||
703 | #ifdef QTOPIA_INTERNAL_INITAPP | ||
704 | void QPEApplication::initApp( int argc, char **argv ) | ||
705 | { | ||
706 | delete pidChannel; | ||
707 | d->keep_running = TRUE; | ||
708 | d->preloaded = FALSE; | ||
709 | d->forceshow = FALSE; | ||
710 | |||
711 | QCString channel = QCString(argv[0]); | ||
712 | |||
713 | channel.replace(QRegExp(".*/"),""); | ||
714 | d->appName = channel; | ||
715 | |||
716 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | ||
717 | |||
718 | channel = "QPE/Application/" + channel; | ||
719 | pidChannel = new QCopChannel( channel, this); | ||
720 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | ||
721 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | ||
722 | |||
723 | processQCopFile(); | ||
724 | d->keep_running = d->qcopq.isEmpty(); | ||
725 | |||
726 | for (int a=0; a<argc; a++) { | ||
727 | if ( qstrcmp(argv[a],"-preload")==0 ) { | ||
728 | argv[a] = argv[a+1]; | ||
729 | a++; | ||
730 | d->preloaded = TRUE; | ||
731 | argc-=1; | ||
732 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | ||
733 | argv[a] = argv[a+1]; | ||
734 | a++; | ||
735 | d->preloaded = TRUE; | ||
736 | d->forceshow = TRUE; | ||
737 | argc-=1; | ||
738 | } | ||
739 | } | ||
740 | |||
741 | /* overide stored arguments */ | ||
742 | setArgs(argc, argv); | ||
743 | } | ||
744 | #endif | ||
745 | |||
746 | |||
653 | static QPtrDict<void>* inputMethodDict = 0; | 747 | static QPtrDict<void>* inputMethodDict = 0; |
654 | static void createInputMethodDict() | 748 | static void createInputMethodDict() |
655 | { | 749 | { |
656 | if ( !inputMethodDict ) | 750 | if ( !inputMethodDict ) |
657 | inputMethodDict = new QPtrDict<void>; | 751 | inputMethodDict = new QPtrDict<void>; |
658 | } | 752 | } |
659 | 753 | ||
660 | /*! | 754 | /*! |
@@ -1119,30 +1213,16 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1119 | stream >> t; | 1213 | stream >> t; |
1120 | if ( t.isNull() ) | 1214 | if ( t.isNull() ) |
1121 | unsetenv( "TZ" ); | 1215 | unsetenv( "TZ" ); |
1122 | else | 1216 | else |
1123 | setenv( "TZ", t.latin1(), 1 ); | 1217 | setenv( "TZ", t.latin1(), 1 ); |
1124 | // emit the signal so everyone else knows... | 1218 | // emit the signal so everyone else knows... |
1125 | emit timeChanged(); | 1219 | emit timeChanged(); |
1126 | } | 1220 | } |
1127 | else if ( msg == "execute(QString)" ) { | ||
1128 | if ( type() == GuiServer ) { | ||
1129 | QString t; | ||
1130 | stream >> t; | ||
1131 | Global::execute( t ); | ||
1132 | } | ||
1133 | } | ||
1134 | else if ( msg == "execute(QString,QString)" ) { | ||
1135 | if ( type() == GuiServer ) { | ||
1136 | QString t, d; | ||
1137 | stream >> t >> d; | ||
1138 | Global::execute( t, d ); | ||
1139 | } | ||
1140 | } | ||
1141 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1221 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1142 | if ( type() == GuiServer ) { | 1222 | if ( type() == GuiServer ) { |
1143 | QDateTime when; | 1223 | QDateTime when; |
1144 | QCString channel, message; | 1224 | QCString channel, message; |
1145 | int data; | 1225 | int data; |
1146 | stream >> when >> channel >> message >> data; | 1226 | stream >> when >> channel >> message >> data; |
1147 | AlarmServer::addAlarm( when, channel, message, data ); | 1227 | AlarmServer::addAlarm( when, channel, message, data ); |
1148 | } | 1228 | } |
@@ -1203,18 +1283,32 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1203 | } | 1283 | } |
1204 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1284 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1205 | int t, v; | 1285 | int t, v; |
1206 | stream >> t >> v; | 1286 | stream >> t >> v; |
1207 | setTreble( t, v ); | 1287 | setTreble( t, v ); |
1208 | } | 1288 | } |
1209 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1289 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1210 | setTreble(); | 1290 | setTreble(); |
1291 | } else if ( msg == "getMarkedText()" ) { | ||
1292 | if ( type() == GuiServer ) { | ||
1293 | const ushort unicode = 'C'-'@'; | ||
1294 | const int scan = Key_C; | ||
1295 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | ||
1296 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | ||
1297 | } | ||
1298 | } else if ( msg == "newChannel(QString)") { | ||
1299 | QString myChannel = "QPE/Application/" + d->appName; | ||
1300 | QString channel; | ||
1301 | stream >> channel; | ||
1302 | if (channel == myChannel) { | ||
1303 | processQCopFile(); | ||
1304 | d->sendQCopQ(); | ||
1211 | } | 1305 | } |
1212 | 1306 | } | |
1213 | 1307 | ||
1214 | 1308 | ||
1215 | #endif | 1309 | #endif |
1216 | } | 1310 | } |
1217 | 1311 | ||
1218 | /*! | 1312 | /*! |
1219 | \internal | 1313 | \internal |
1220 | */ | 1314 | */ |
@@ -1301,17 +1395,21 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
1301 | QDataStream stream( data, IO_ReadOnly ); | 1395 | QDataStream stream( data, IO_ReadOnly ); |
1302 | QString doc; | 1396 | QString doc; |
1303 | stream >> doc; | 1397 | stream >> doc; |
1304 | QWidget *mw = mainWidget(); | 1398 | QWidget *mw = mainWidget(); |
1305 | if ( !mw ) | 1399 | if ( !mw ) |
1306 | mw = d->qpe_main_widget; | 1400 | mw = d->qpe_main_widget; |
1307 | if ( mw ) | 1401 | if ( mw ) |
1308 | Global::setDocument( mw, doc ); | 1402 | Global::setDocument( mw, doc ); |
1309 | } else { | 1403 | } else if ( msg == "QPEProcessQCop()" ) { |
1404 | processQCopFile(); | ||
1405 | d->sendQCopQ(); | ||
1406 | } | ||
1407 | { | ||
1310 | bool p = d->keep_running; | 1408 | bool p = d->keep_running; |
1311 | d->keep_running = FALSE; | 1409 | d->keep_running = FALSE; |
1312 | emit appMessage( msg, data); | 1410 | emit appMessage( msg, data); |
1313 | if ( d->keep_running ) { | 1411 | if ( d->keep_running ) { |
1314 | d->notbusysent = FALSE; | 1412 | d->notbusysent = FALSE; |
1315 | raiseAppropriateWindow(); | 1413 | raiseAppropriateWindow(); |
1316 | if ( !p ) { | 1414 | if ( !p ) { |
1317 | // Tell the system we're still chugging along... | 1415 | // Tell the system we're still chugging along... |
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 65a6d33..770ea23 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -77,16 +77,20 @@ public: | |||
77 | 77 | ||
78 | static void setInputMethodHint( QWidget *, InputMethodHint ); | 78 | static void setInputMethodHint( QWidget *, InputMethodHint ); |
79 | static InputMethodHint inputMethodHint( QWidget * ); | 79 | static InputMethodHint inputMethodHint( QWidget * ); |
80 | 80 | ||
81 | void showMainWidget( QWidget*, bool nomax=FALSE ); | 81 | void showMainWidget( QWidget*, bool nomax=FALSE ); |
82 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); | 82 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); |
83 | static void showDialog( QDialog*, bool nomax=FALSE ); | 83 | static void showDialog( QDialog*, bool nomax=FALSE ); |
84 | static int execDialog( QDialog*, bool nomax=FALSE ); | 84 | static int execDialog( QDialog*, bool nomax=FALSE ); |
85 | /* Merge setTempScreenSaverMode */ | ||
86 | #ifdef QTOPIA_INTERNAL_INITAPP | ||
87 | void initApp( int argv, char **argv ); | ||
88 | #endif | ||
85 | 89 | ||
86 | static void setKeepRunning(); | 90 | static void setKeepRunning(); |
87 | bool keepRunning() const; | 91 | bool keepRunning() const; |
88 | 92 | ||
89 | bool keyboardGrabbed() const; | 93 | bool keyboardGrabbed() const; |
90 | 94 | ||
91 | int exec(); | 95 | int exec(); |
92 | 96 | ||
@@ -96,16 +100,17 @@ signals: | |||
96 | void clockChanged( bool pm ); | 100 | void clockChanged( bool pm ); |
97 | void micChanged( bool muted ); | 101 | void micChanged( bool muted ); |
98 | void volumeChanged( bool muted ); | 102 | void volumeChanged( bool muted ); |
99 | void appMessage( const QCString& msg, const QByteArray& data); | 103 | void appMessage( const QCString& msg, const QByteArray& data); |
100 | void weekChanged( bool startOnMonday ); | 104 | void weekChanged( bool startOnMonday ); |
101 | void dateFormatChanged( DateFormat ); | 105 | void dateFormatChanged( DateFormat ); |
102 | void flush(); | 106 | void flush(); |
103 | void reload(); | 107 | void reload(); |
108 | /* linkChanged signal */ | ||
104 | 109 | ||
105 | private slots: | 110 | private slots: |
106 | void systemMessage( const QCString &msg, const QByteArray &data ); | 111 | void systemMessage( const QCString &msg, const QByteArray &data ); |
107 | void pidMessage( const QCString &msg, const QByteArray &data ); | 112 | void pidMessage( const QCString &msg, const QByteArray &data ); |
108 | void removeSenderFromStylusDict(); | 113 | void removeSenderFromStylusDict(); |
109 | void hideOrQuit(); | 114 | void hideOrQuit(); |
110 | 115 | ||
111 | protected: | 116 | protected: |
@@ -121,16 +126,17 @@ protected: | |||
121 | #if QT_VERSION > 233 | 126 | #if QT_VERSION > 233 |
122 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) | 127 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) |
123 | #endif | 128 | #endif |
124 | private: | 129 | private: |
125 | #ifndef QT_NO_TRANSLATION | 130 | #ifndef QT_NO_TRANSLATION |
126 | void installTranslation( const QString& baseName ); | 131 | void installTranslation( const QString& baseName ); |
127 | #endif | 132 | #endif |
128 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); | 133 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); |
134 | void processQCopFile(); | ||
129 | 135 | ||
130 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 136 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
131 | QCopChannel *sysChannel; | 137 | QCopChannel *sysChannel; |
132 | QCopChannel *pidChannel; | 138 | QCopChannel *pidChannel; |
133 | #endif | 139 | #endif |
134 | QPEApplicationData *d; | 140 | QPEApplicationData *d; |
135 | 141 | ||
136 | bool reserved_sh; | 142 | bool reserved_sh; |