summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Side-by-side diff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/qpeapplication.cpp142
1 files changed, 120 insertions, 22 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index d1a7cd2..b1b7ed4 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -48,12 +48,15 @@
#include <qdragobject.h>
#include <qtextcodec.h>
#include <qevent.h>
#include <qtooltip.h>
#include <qsignal.h>
#include <qmainwindow.h>
+
+#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
+#define QTOPIA_INTERNAL_INITAPP
#include "qpeapplication.h"
#include "qpestyle.h"
#include "styleinterface.h"
#if QT_VERSION >= 300
#include <qstylefactory.h>
#else
@@ -302,12 +305,22 @@ public:
return r;
}
private:
mutable QImageDrag *resImage;
};
+static int& hack(int& i)
+{
+#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
+ // These should be created, but aren't in Qt 2.3.0
+ (void)new QUtf8Codec;
+ (void)new QUtf16Codec;
+#endif
+ return i;
+}
+
static int muted = 0;
static int micMuted = 0;
static void setVolume( int t = 0, int percent = -1 )
{
switch ( t ) {
@@ -483,12 +496,41 @@ static void setTreble( int t = 0, int percent = -1 )
/*!
\fn void QPEApplication::reload()
*/
+
+
+void QPEApplication::processQCopFile()
+{
+ QString qcopfn("/tmp/qcop-msg-");
+ qcopfn += d->appName; // append command name
+
+ QFile f(qcopfn);
+ if ( f.open(IO_ReadWrite) ) {
+#ifndef Q_OS_WIN32
+ flock(f.handle(), LOCK_EX);
+#endif
+ QDataStream ds(&f);
+ QCString channel, message;
+ QByteArray data;
+ while(!ds.atEnd()) {
+ ds >> channel >> message >> data;
+ d->enqueueQCop(channel,message,data);
+ }
+ ::ftruncate(f.handle(), 0);
+#ifndef Q_OS_WIN32
+ f.flush();
+ flock(f.handle(), LOCK_UN);
+#endif
+ }
+#endif
+}
+
+
/*!
\fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
This signal is emitted when a message is received on this
application's QPE/Application/<i>appname</i> \link qcop.html
QCop\endlink channel.
@@ -520,13 +562,13 @@ static void setTreble( int t = 0, int percent = -1 )
a QApplication, passing \a argc, \a argv, and \a t.
For applications, \a t should be the default, GuiClient. Only
the Qtopia server passes GuiServer.
*/
QPEApplication::QPEApplication( int & argc, char **argv, Type t )
- : QApplication( argc, argv, t )
+ : QApplication( hack(argc), argv, t ), pidChannel( 0 )
{
d = new QPEApplicationData;
d->loadTextCodecs();
d->loadImageCodecs();
int dw = desktop() ->width();
@@ -548,25 +590,31 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
AppLnk::setBigIconSize( 32 );
}
QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
+
+
+ sysChannel = new QCopChannel( "QPE/System", this );
+ connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
+ this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
+
+/* COde now in initapp */
+#if 0
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QString qcopfn( "/tmp/qcop-msg-" );
qcopfn += QString( argv[ 0 ] ); // append command name
QFile f( qcopfn );
if ( f.open( IO_ReadOnly ) ) {
flock( f.handle(), LOCK_EX );
}
- sysChannel = new QCopChannel( "QPE/System", this );
- connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
- this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
+
QCString channel = QCString( argv[ 0 ] );
channel.replace( QRegExp( ".*/" ), "" );
d->appName = channel;
channel = "QPE/Application/" + channel;
pidChannel = new QCopChannel( channel, this );
@@ -605,13 +653,15 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
}
/* overide stored arguments */
setArgs( argc, argv );
#endif
-
+#else
+ initApp( argc, argv );
+#endif
// qwsSetDecoration( new QPEDecoration() );
#ifndef QT_NO_TRANSLATION
QStringList langs = Global::languageList();
for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
@@ -627,13 +677,12 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
QFont fn = FontManager::unicodeFont( FontManager::Proportional );
setFont( fn );
}
#endif
-
}
#endif
applyStyle();
if ( type() == GuiServer ) {
@@ -647,12 +696,57 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
#ifdef QT_NO_QWS_CURSOR
// if we have no cursor, probably don't want tooltips
QToolTip::setEnabled( FALSE );
#endif
}
+
+#ifdef QTOPIA_INTERNAL_INITAPP
+void QPEApplication::initApp( int argc, char **argv )
+{
+ delete pidChannel;
+ d->keep_running = TRUE;
+ d->preloaded = FALSE;
+ d->forceshow = FALSE;
+
+ QCString channel = QCString(argv[0]);
+
+ channel.replace(QRegExp(".*/"),"");
+ d->appName = channel;
+
+ qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
+
+ channel = "QPE/Application/" + channel;
+ pidChannel = new QCopChannel( channel, this);
+ connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
+ this, SLOT(pidMessage(const QCString &, const QByteArray &)));
+
+ processQCopFile();
+ d->keep_running = d->qcopq.isEmpty();
+
+ for (int a=0; a<argc; a++) {
+ if ( qstrcmp(argv[a],"-preload")==0 ) {
+ argv[a] = argv[a+1];
+ a++;
+ d->preloaded = TRUE;
+ argc-=1;
+ } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
+ argv[a] = argv[a+1];
+ a++;
+ d->preloaded = TRUE;
+ d->forceshow = TRUE;
+ argc-=1;
+ }
+ }
+
+ /* overide stored arguments */
+ setArgs(argc, argv);
+}
+#endif
+
+
static QPtrDict<void>* inputMethodDict = 0;
static void createInputMethodDict()
{
if ( !inputMethodDict )
inputMethodDict = new QPtrDict<void>;
}
@@ -1121,26 +1215,12 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
unsetenv( "TZ" );
else
setenv( "TZ", t.latin1(), 1 );
// emit the signal so everyone else knows...
emit timeChanged();
}
- else if ( msg == "execute(QString)" ) {
- if ( type() == GuiServer ) {
- QString t;
- stream >> t;
- Global::execute( t );
- }
- }
- else if ( msg == "execute(QString,QString)" ) {
- if ( type() == GuiServer ) {
- QString t, d;
- stream >> t >> d;
- Global::execute( t, d );
- }
- }
else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
if ( type() == GuiServer ) {
QDateTime when;
QCString channel, message;
int data;
stream >> when >> channel >> message >> data;
@@ -1205,14 +1285,28 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
int t, v;
stream >> t >> v;
setTreble( t, v );
}
else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
setTreble();
+ } else if ( msg == "getMarkedText()" ) {
+ if ( type() == GuiServer ) {
+ const ushort unicode = 'C'-'@';
+ const int scan = Key_C;
+ qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );
+ qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );
+ }
+ } else if ( msg == "newChannel(QString)") {
+ QString myChannel = "QPE/Application/" + d->appName;
+ QString channel;
+ stream >> channel;
+ if (channel == myChannel) {
+ processQCopFile();
+ d->sendQCopQ();
+ }
}
-
#endif
}
/*!
@@ -1303,13 +1397,17 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
stream >> doc;
QWidget *mw = mainWidget();
if ( !mw )
mw = d->qpe_main_widget;
if ( mw )
Global::setDocument( mw, doc );
- } else {
+ } else if ( msg == "QPEProcessQCop()" ) {
+ processQCopFile();
+ d->sendQCopQ();
+ }
+ {
bool p = d->keep_running;
d->keep_running = FALSE;
emit appMessage( msg, data);
if ( d->keep_running ) {
d->notbusysent = FALSE;
raiseAppropriateWindow();