summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-16 15:34:05 (UTC)
committer zecke <zecke>2002-10-16 15:34:05 (UTC)
commit321cea04e34658fde3de47c104682b5cefce6eeb (patch) (side-by-side diff)
treeabdf45ae54d24dedfd20e4e40371df5f39687139
parent61f2f6ef32685002710f197dc8990fd9e99d83a5 (diff)
downloadopie-321cea04e34658fde3de47c104682b5cefce6eeb.zip
opie-321cea04e34658fde3de47c104682b5cefce6eeb.tar.gz
opie-321cea04e34658fde3de47c104682b5cefce6eeb.tar.bz2
more implementation!!
OCOPClient now tries to start the server
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--x11/ipc/client/ocopclient.cpp25
-rw-r--r--x11/ipc/client/ocopclient.h4
-rw-r--r--x11/libqpe-x11/qpe/qpeapplication.cpp207
-rw-r--r--x11/libqpe-x11/qpe/qpeapplication.h23
4 files changed, 243 insertions, 16 deletions
diff --git a/x11/ipc/client/ocopclient.cpp b/x11/ipc/client/ocopclient.cpp
index 43e426c..ac6e4a3 100644
--- a/x11/ipc/client/ocopclient.cpp
+++ b/x11/ipc/client/ocopclient.cpp
@@ -5,2 +5,3 @@
#include <sys/socket.h>
+#include <sys/types.h>
#include <sys/un.h>
@@ -18,2 +19,3 @@ OCOPClient::OCOPClient( const QString& path, QObject* obj )
{
+ m_tries = 0;
init(QFile::encodeName(path) );
@@ -21,5 +23,13 @@ OCOPClient::OCOPClient( const QString& path, QObject* obj )
OCOPClient::~OCOPClient() {
+ delete m_notify;
close( m_socket );
}
+void OCOPClient::init() {
+ // failed start ther server NOW!!!
+ startUP();
+ QCString str;
+ init(str );
+}
void OCOPClient::init( const QCString& ) {
+ m_tries++;
struct sockaddr_un unix_adr;
@@ -27,3 +37,4 @@ void OCOPClient::init( const QCString& ) {
qWarning("could not socket");
- QTimer::singleShot(400, this,SLOT(init() ) );
+ if ( m_tries < 8 )
+ QTimer::singleShot(400, this,SLOT(init() ) );
return;
@@ -38,3 +49,4 @@ void OCOPClient::init( const QCString& ) {
close( m_socket );
- QTimer::singleShot(400, this, SLOT(init() ) );
+ if ( m_tries < 8 )
+ QTimer::singleShot(400, this, SLOT(init() ) );
return;
@@ -129 +141,10 @@ void OCOPClient::call( const OCOPPacket& pack ) {
}
+void OCOPClient::startUP() {
+ qWarning("Start me up");
+ pid_t pi = fork();
+ if ( pi == 0 ) {
+ setsid();
+ execlp("opie-ipc", "opie-ipc", NULL );
+ _exit(1);
+ }
+}
diff --git a/x11/ipc/client/ocopclient.h b/x11/ipc/client/ocopclient.h
index e9544b9..53018a5 100644
--- a/x11/ipc/client/ocopclient.h
+++ b/x11/ipc/client/ocopclient.h
@@ -46,2 +46,3 @@ signals:
private slots:
+ void init();
void init(const QCString& pa);
@@ -49,2 +50,3 @@ private slots:
private:
+ void startUP();
OCOPPacket packet()const;
@@ -54,3 +56,3 @@ private:
int m_socket;
-private slots:
+ int m_tries;
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp
index 891e132..6e4a96c 100644
--- a/x11/libqpe-x11/qpe/qpeapplication.cpp
+++ b/x11/libqpe-x11/qpe/qpeapplication.cpp
@@ -205,2 +205,12 @@ namespace {
// QPEApplication
+QPEApplication::~QPEApplication() {
+ qWarning("~QPEApplication");
+ ungrabKeyboard();
+ qWarning("UngrabKeyboard");
+
+// delete m_sys;
+// delete m_pid;
+
+ delete d;
+}
QPEApplication::QPEApplication(int &arg, char** argv, Type t)
@@ -236,3 +246,6 @@ QPEApplication::QPEApplication(int &arg, char** argv, Type t)
- m_sys = new QCopChannel( "QPE/System", this );
+ /* Hmmm damn we need to make the parent 0l otherwise it get's deleted
+ * past the QApplication
+ */
+ m_sys = new QCopChannel( "QPE/System", 0l);
connect(m_sys, SIGNAL( received( const QCString&, const QByteArray& ) ),
@@ -245,3 +258,3 @@ QPEApplication::QPEApplication(int &arg, char** argv, Type t)
channel = "QPE/Application/"+ channel;
- m_pid = new QCopChannel( channel, this );
+ m_pid = new QCopChannel( channel, 0l );
connect(m_pid, SIGNAL( received( const QCString&, const QByteArray& ) ),
@@ -308,5 +321,2 @@ void QPEApplication::initTranslations() {
}
-QPEApplication::~QPEApplication() {
- delete d;
-}
QString QPEApplication::qpeDir() {
@@ -388,8 +398,2 @@ void QPEApplication::ungrabKeyboard() {
}
-void QPEApplication::setStylusOperation( QWidget*, StylusMode ) {
-
-}
-QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* ) {
-
-}
void QPEApplication::showMainWidget( QWidget* wid, bool b) {
@@ -437,4 +441,8 @@ int QPEApplication::exec() {
- if ( d->keep_running )
- return QApplication::exec();
+ if ( d->keep_running ) {
+ qWarning("going to exec");
+ int a = QApplication::exec();
+ qWarning("left");
+ return a;
+ }
@@ -444,2 +452,3 @@ int QPEApplication::exec() {
}
+ qWarning("processing events!");
processEvents();
@@ -450,4 +459,176 @@ void QPEApplication::internalSetStyle( const QString& ) {
}
+void QPEApplication::systemMessage( const QCString&, const QByteArray& ) {
+
+}
+void QPEApplication::pidMessage( const QCString&, const QByteArray& ) {
+
+}
+void QPEApplication::timerEvent( QTimerEvent* e ) {
+ if ( e->timerId() == d->presstimer && d->presswidget ) {
+ // Right pressed
+ postEvent( d->presswidget,
+ new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
+ RightButton, LeftButton ) );
+ killTimer( d->presstimer );
+ d->presstimer = 0;
+ }
+}
+
+// InputMethods Hints
+namespace {
+ static QPtrDict<void>* inputMethodDict = 0;
+ static void createInputMethodDict(){
+ if ( !inputMethodDict )
+ inputMethodDict = new QPtrDict<void>;
+ }
+
+ static QPtrDict<void>* stylusDict = 0;
+ static void createDict() {
+ if ( !stylusDict )
+ stylusDict = new QPtrDict<void>;
+ }
+};
+
+void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) {
+ createInputMethodDict();
+ if ( mode == Normal ) {
+ inputMethodDict->remove
+ ( w );
+ }else {
+ inputMethodDict->insert( w, ( void* ) mode );
+ }
+}
+QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) {
+ if ( inputMethodDict && w )
+ return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
+ return Normal;
+}
+
+
+void QPEApplication::removeSenderFromStylusDict() {
+ stylusDict->remove( ( void* ) sender() );
+ if ( d->presswidget == sender() )
+ d->presswidget = 0;
+}
+void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) {
+ createDict();
+ if ( mode == LeftOnly ) {
+ stylusDict->remove
+ ( w );
+ w->removeEventFilter( qApp );
+ }else {
+ stylusDict->insert( w, ( void* ) mode );
+ connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
+ w->installEventFilter( qApp );
+ }
+}
+QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) {
+ if ( stylusDict )
+ return ( StylusMode ) ( int ) stylusDict->find( w );
+ return LeftOnly;
+}
+
+// eventFilter......
+bool QPEApplication::eventFilter( QObject* o, QEvent* e ) {
+ if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
+ QMouseEvent * me = ( QMouseEvent* ) e;
+ StylusMode mode = (StylusMode)(int)stylusDict->find(o);
+ switch (mode) {
+ case RightOnHold:
+ switch ( me->type() ) {
+ case QEvent::MouseButtonPress:
+ if ( me->button() == LeftButton ) {
+ d->presstimer = startTimer(500); // #### pref.
+ d->presswidget = (QWidget*)o;
+ d->presspos = me->pos();
+ d->rightpressed = FALSE;
+ }
+ break;
+ case QEvent::MouseMove:
+ if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
+ killTimer(d->presstimer);
+ d->presstimer = 0;
+ }
+ break;
+ case QEvent::MouseButtonRelease:
+ if ( me->button() == LeftButton ) {
+ if ( d->presstimer ) {
+ killTimer(d->presstimer);
+ d->presstimer = 0;
+ }
+ if ( d->rightpressed && d->presswidget ) {
+ // Right released
+ postEvent( d->presswidget,
+ new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
+ RightButton, LeftButton + RightButton ) );
+ // Left released, off-widget
+ postEvent( d->presswidget,
+ new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
+ LeftButton, LeftButton ) );
+ postEvent( d->presswidget,
+ new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
+ LeftButton, LeftButton ) );
+ d->rightpressed = FALSE;
+ return TRUE; // don't send the real Left release
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ ;
+ }
+ }
+ else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
+ QKeyEvent *ke = (QKeyEvent *)e;
+ if ( ke->key() == Key_Enter ) {
+ if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
+ postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
+ ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+// Quit stuff
+void QPEApplication::restart() {
+
+}
+void QPEApplication::shutdown() {
+}
+void QPEApplication::tryQuit() {
+ qWarning("TryQuit!!");
+ if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
+ return ; // Inside modal loop or konsole. Too hard to save state.
+ {
+ QCopEnvelope e( "QPE/System", "closing(QString)" );
+ e << d->appName;
+ }
+ processEvents();
+ quit();
+}
+void QPEApplication::hideOrQuit() {
+ qWarning("hide or close");
+ processEvents();
+ qWarning("past processing");
+
+ // If we are a preloaded application we don't actually quit, so emit
+ // a System message indicating we're quasi-closing.
+ if ( d->preloaded && d->qpe_main_widget )
+
+ {
+ qWarning("hiding");
+ QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
+ e << d->appName;
+ d->qpe_main_widget->hide();
+ }
+ else
+ quit();
+}
diff --git a/x11/libqpe-x11/qpe/qpeapplication.h b/x11/libqpe-x11/qpe/qpeapplication.h
index cd385db..2af1c66 100644
--- a/x11/libqpe-x11/qpe/qpeapplication.h
+++ b/x11/libqpe-x11/qpe/qpeapplication.h
@@ -8,2 +8,3 @@
#include <qapplication.h>
+#include <qevent.h>
@@ -18,2 +19,3 @@ public:
+
static QString qpeDir();
@@ -34,2 +36,10 @@ public:
+ enum InputMethodHint {
+ Normal,
+ AlwaysOff,
+ AlwaysOn
+ };
+ static void setInputMethodHint( QWidget*, InputMethodHint );
+ static InputMethodHint inputMethodHint( QWidget* );
+
void showMainWidget( QWidget*, bool nomax = FALSE );
@@ -62,2 +72,15 @@ private:
+private slots:
+ void hideOrQuit();
+ void systemMessage( const QCString&, const QByteArray& );
+ void pidMessage( const QCString&, const QByteArray& );
+ void removeSenderFromStylusDict();
+protected:
+ virtual void restart();
+ virtual void shutdown();
+ bool eventFilter( QObject*, QEvent* );
+ void timerEvent( QTimerEvent* );
+ void raiseAppropriateWindow();
+ virtual void tryQuit();
+
private: