summaryrefslogtreecommitdiff
authorzecke <zecke>2003-08-25 14:46:43 (UTC)
committer zecke <zecke>2003-08-25 14:46:43 (UTC)
commit292b097e7db25dd231381c5b09307a1fbe81a492 (patch) (side-by-side diff)
treeb103c6c5e15e784dc07af55539672a72559da821
parent5f292b6e4fc0f4ee8e4bced9a916f6bdce864b6b (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/custom-ipaq.h1
-rw-r--r--library/custom-ramses.h1
-rw-r--r--library/custom-sharp.h1
-rw-r--r--library/custom-simpad.h7
-rw-r--r--library/global.cpp59
-rw-r--r--library/inputmethodinterface.h19
-rw-r--r--library/qcopenvelope_qws.cpp66
-rw-r--r--library/qpeapplication.cpp152
-rw-r--r--library/qpeapplication.h6
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 @@
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#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 @@
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#define QPE_NEED_CALIBRATION
#define QPE_HAVE_TOGGLELIGHT
#define QPE_STARTMENU
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <fcntl.h>
#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 @@
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#define QPE_NEED_CALIBRATION
#define QPE_OWNAPM
#define QPE_HAVE_TOGGLELIGHT
#define QPE_NOCIBAUD
#define QPE_STARTMENU
#include <asm/sharp_apm.h>
#ifndef APM_IOC_BATTERY_BACK_CHK
#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32)
#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 @@
+/*
+ * GPLv2 only zecke@handhelds.org
+ hOlgAr
+ */
+
+
+#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)
Executes the application identfied by \a c, passing \a
document if it isn't null.
Note that a better approach might be to send a QCop message to the
application's QPE/Application/\e{appname} channel.
*/
void Global::execute( const QString &c, const QString& document )
{
- if ( qApp->type() != QApplication::GuiServer ) {
// ask the server to do the work
#if !defined(QT_NO_COP)
- if ( document.isNull() ) {
- QCopEnvelope e( "QPE/System", "execute(QString)" );
- e << c;
- } else {
- QCopEnvelope e( "QPE/System", "execute(QString,QString)" );
- e << c << document;
- }
-#endif
- return;
- }
-
- // Attempt to execute the app using a builtin class for the app first
- // else try and find it in the bin directory
- if (builtin) {
- for (int i = 0; builtin[i].file; i++) {
- if ( builtin[i].file == c ) {
- if ( running[i] ) {
- if ( !document.isNull() && builtin[i].documentary )
- setDocument(running[i], document);
- running[i]->raise();
- running[i]->show();
- running[i]->setActiveWindow();
- } else {
- running[i] = builtin[i].func( builtin[i].maximized );
- }
-#ifndef QT_NO_COP
- QCopEnvelope e("QPE/System", "notBusy(QString)" );
- e << c; // that was quick ;-)
-#endif
- return;
- }
- }
- }
-
- //Global::invoke(c, document);
-
- // Convert the command line in to a list of arguments
- QStringList list = QStringList::split(QRegExp(" *"),c);
-
-#if !defined(QT_NO_COP)
- QString ap=list[0];
-
- qDebug("executing %s", ap.latin1() );
-
- /* if need be, sending a qcop message will result in an invoke, see
- preceeding function */
- invoke( ap );
- //{ QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); }
- if ( !document.isEmpty() ) {
- QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" );
- env << document;
+ if ( document.isNull() ) {
+ QCopEnvelope e( "QPE/System", "execute(QString)" );
+ e << c;
+ } else {
+ QCopEnvelope e( "QPE/System", "execute(QString,QString)" );
+ e << c << document;
}
#endif
+ return;
}
/*!
Returns the string \a s with the characters '\', '"', and '$' quoted
by a preceeding '\'.
\sa stringQuote()
*/
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
{
virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ) = 0;
virtual void resetState() = 0;
virtual QPixmap *icon() = 0;
virtual QString name() = 0;
virtual void onKeyPress( QObject *receiver, const char *slot ) = 0;
};
-// {70F0991C-8282-4625-A279-BD9D7D959FF6}
+// {70F0991C-8282-4625-A279-BD9D7D959FF6}
#ifndef IID_ExtInputMethod
#define IID_ExtInputMethod QUuid( 0x70f0991c, 0x8282, 0x4625, 0xa2, 0x79, 0xbd, 0x9d, 0x7d, 0x95, 0x9f, 0xf6)
#endif
struct ExtInputMethodInterface : public QUnknownInterface
{
- virtual QWSInputMethod *inputMethod() = 0;
- virtual QPixmap *icon() = 0;
+ //identifying functions.
virtual QString name() = 0;
- virtual QWidget *widget( QWidget *parent, Qt::WFlags f )= 0;
+ virtual QPixmap *icon() = 0;
+
+ // state managment.
+ virtual void resetState() = 0;
+
+ virtual QWidget *keyboardWidget( QWidget *parent, Qt::WFlags f ) = 0;
+ // filenames, not menu names.
+ virtual QStringList compatible() = 0;
+
+ virtual QWSInputMethod *inputMethod() = 0;
+ virtual QWidget *statusWidget( QWidget *parent, Qt::WFlags f )= 0;
+
+ virtual void qcopReceive( const QCString &msg, const QByteArray &data )= 0;
};
#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()
QByteArray data = ((QBuffer*)device())->buffer();
const int pref=16;
if ( qstrncmp(ch.data(),"QPE/Application/",pref)==0 ) {
QString qcopfn("/tmp/qcop-msg-");
qcopfn += ch.mid(pref);
QFile qcopfile(qcopfn);
if ( qcopfile.open(IO_WriteOnly | IO_Append) ) {
+#ifndef Q_OS_WIN32
if(flock(qcopfile.handle(), LOCK_EX)) {
- /* some error occured */
+ /* some error occurred */
qWarning(QString("Failed to obtain file lock on %1 (%2)")
.arg(qcopfn).arg( errno ));
}
- /* file locked, but might be stale (e.g. program for whatever
- reason did not start). I modified more than 1 minute ago,
- truncate the file */
- struct stat buf;
- time_t t;
- if (!fstat(qcopfile.handle(), &buf) && (time(&t) != (time_t)-1) ) {
- // success on fstat, lets compare times
- if (buf.st_ctime + 60 < t) {
- qWarning("stale file " + qcopfn + " found. Truncating");
- ftruncate(qcopfile.handle(), 0);
- qcopfile.reset();
- }
+#endif
+ {
+ QDataStream ds(&qcopfile);
+ ds << ch << msg << data;
+ qcopfile.flush();
+#ifndef Q_OS_WIN32
+ flock(qcopfile.handle(), LOCK_UN);
+#endif
+ qcopfile.close();
}
- if ( !QCopChannel::isRegistered(ch) ) {
- int fsize = qcopfile.size();
- {
- QDataStream ds(&qcopfile);
- ds << ch << msg << data;
- flock(qcopfile.handle(), LOCK_UN);
- qcopfile.close();
- }
-
- if (fsize == 0) {
- QString cmd = ch.mid(pref);
- Global::execute(cmd);
- }
-
- char c;
- for (int i=0; (c=msg[i]); i++) {
- if ( c == ' ' ) {
- // Return-value required
- // ###### wait for it
- break;
- } else if ( c == '(' ) {
- // No return value
- break;
- }
- }
- goto end;
- } // endif isRegisterd
- flock(qcopfile.handle(), LOCK_UN);
- qcopfile.close();
- qcopfile.remove();
+ QByteArray b;
+ QDataStream stream(b, IO_WriteOnly);
+ stream << QString(ch.mid(pref));
+ QCopChannel::send("QPE/Server", "processQCop(QString)", b);
+ delete device();
+ return;
} else {
- qWarning(QString("Failed to obtain file lock on %1")
+ qWarning(QString("Failed to open file %1")
.arg(qcopfn));
} // endif open
}
else if (qstrncmp(ch.data(), "QPE/SOAP/", 9) == 0) {
// If this is a message that should go along the SOAP channel, we move the
// endpoint URL to the data section.
QString endpoint = ch.mid(9);
-
+
ch = "QPE/SOAP";
// Since byte arrays are explicitly shared, this is appended to the data variable..
*this << endpoint;
}
+
QCopChannel::send(ch,msg,data);
-end:
delete device();
}
#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 @@
#include <qlabel.h>
#include <qdialog.h>
#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
#include <qplatinumstyle.h>
#include <qwindowsstyle.h>
@@ -300,16 +303,26 @@ public:
while ( !r && sl > 0 );
}
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 ) {
case 0: {
Config cfg( "qpe" );
@@ -481,16 +494,45 @@ 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.
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 )
/*!
Constructs a QPEApplication just as you would construct
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();
if ( dw < 200 ) {
setFont( QFont( "vera", 8 ) );
@@ -546,29 +588,35 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
setFont( QFont( "vera", 10 ) );
AppLnk::setSmallIconSize( 14 );
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 );
connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
@@ -603,40 +651,41 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
argc -= 1;
}
}
/* 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 ) {
QString lang = *it;
installTranslation( lang + "/libopie.qm");
installTranslation( lang + "/libqpe.qm" );
installTranslation( lang + "/" + d->appName + ".qm" );
//###language/font hack; should look it up somewhere
#ifdef QWS
- if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
- QFont fn = FontManager::unicodeFont( FontManager::Proportional );
- setFont( fn );
- }
+ 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 ) {
setVolume();
}
@@ -645,16 +694,61 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
QPEMenuToolFocusManager::initialize();
#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>;
}
/*!
@@ -1119,30 +1213,16 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
stream >> t;
if ( t.isNull() )
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;
AlarmServer::addAlarm( when, channel, message, data );
}
@@ -1203,18 +1283,32 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
}
else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
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
}
/*!
\internal
*/
@@ -1301,17 +1395,21 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
QDataStream stream( data, IO_ReadOnly );
QString doc;
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();
if ( !p ) {
// 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:
static void setInputMethodHint( QWidget *, InputMethodHint );
static InputMethodHint inputMethodHint( QWidget * );
void showMainWidget( QWidget*, bool nomax=FALSE );
void showMainDocumentWidget( QWidget*, bool nomax=FALSE );
static void showDialog( QDialog*, bool nomax=FALSE );
static int execDialog( QDialog*, bool nomax=FALSE );
+ /* Merge setTempScreenSaverMode */
+#ifdef QTOPIA_INTERNAL_INITAPP
+ void initApp( int argv, char **argv );
+#endif
static void setKeepRunning();
bool keepRunning() const;
bool keyboardGrabbed() const;
int exec();
@@ -96,16 +100,17 @@ signals:
void clockChanged( bool pm );
void micChanged( bool muted );
void volumeChanged( bool muted );
void appMessage( const QCString& msg, const QByteArray& data);
void weekChanged( bool startOnMonday );
void dateFormatChanged( DateFormat );
void flush();
void reload();
+ /* linkChanged signal */
private slots:
void systemMessage( const QCString &msg, const QByteArray &data );
void pidMessage( const QCString &msg, const QByteArray &data );
void removeSenderFromStylusDict();
void hideOrQuit();
protected:
@@ -121,16 +126,17 @@ protected:
#if QT_VERSION > 233
virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!)
#endif
private:
#ifndef QT_NO_TRANSLATION
void installTranslation( const QString& baseName );
#endif
void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
+ void processQCopFile();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QCopChannel *sysChannel;
QCopChannel *pidChannel;
#endif
QPEApplicationData *d;
bool reserved_sh;