diff options
author | Jeremy Katz <jeremy.katz@nokia.com> | 2009-10-01 12:08:11 (GMT) |
---|---|---|
committer | Jeremy Katz <jeremy.katz@nokia.com> | 2009-10-01 12:12:28 (GMT) |
commit | 072e748adbdab1d51b240b9983ce82b213b66f18 (patch) | |
tree | 67d170ab4e0bba06adc3479ea6af3214e24636e4 /src | |
parent | 938ba08e7bf90063127b298da25a124441659e89 (diff) | |
download | Qt-072e748adbdab1d51b240b9983ce82b213b66f18.zip Qt-072e748adbdab1d51b240b9983ce82b213b66f18.tar.gz Qt-072e748adbdab1d51b240b9983ce82b213b66f18.tar.bz2 |
Enable qws/qvfb use for multiple users on one machine
Task-number: QTBUG-1711
Reviewed-by: Paul
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/embedded/qscreenvfb_qws.cpp | 8 | ||||
-rw-r--r-- | src/gui/embedded/qsoundqss_qws.cpp | 11 | ||||
-rw-r--r-- | src/gui/embedded/qvfbhdr.h | 19 | ||||
-rw-r--r-- | src/gui/embedded/qwscommand_qws_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_qws.cpp | 18 |
5 files changed, 32 insertions, 26 deletions
diff --git a/src/gui/embedded/qscreenvfb_qws.cpp b/src/gui/embedded/qscreenvfb_qws.cpp index 19d4fa8..d71336d 100644 --- a/src/gui/embedded/qscreenvfb_qws.cpp +++ b/src/gui/embedded/qscreenvfb_qws.cpp @@ -196,7 +196,7 @@ bool QVFbScreen::connect(const QString &displaySpec) if (displayArgs.contains(QLatin1String("Gray"))) grayscale = true; - key_t key = ftok(QByteArray(QT_VFB_MOUSE_PIPE).replace("%1", QByteArray::number(displayId)), 'b'); + key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLocal8Bit(), 'b'); if (key == -1) return false; @@ -330,8 +330,7 @@ void QVFbScreen::disconnect() bool QVFbScreen::initDevice() { #ifndef QT_NO_QWS_MOUSE_QVFB - const QString mouseDev = QString::fromLatin1(QT_VFB_MOUSE_PIPE) - .arg(displayId); + const QString mouseDev = QT_VFB_MOUSE_PIPE(displayId); d_ptr->mouse = new QVFbMouseHandler(QLatin1String("QVFbMouse"), mouseDev); qwsServer->setDefaultMouse("None"); if (d_ptr->mouse) @@ -339,8 +338,7 @@ bool QVFbScreen::initDevice() #endif #if !defined(QT_NO_QWS_KBD_QVFB) && !defined(QT_NO_QWS_KEYBOARD) - const QString keyboardDev = QString::fromLatin1(QT_VFB_KEYBOARD_PIPE) - .arg(displayId); + const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId); d_ptr->keyboard = new QVFbKeyboardHandler(keyboardDev); qwsServer->setDefaultKeyboard("None"); #endif diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp index 6bac8dc..b859be5 100644 --- a/src/gui/embedded/qsoundqss_qws.cpp +++ b/src/gui/embedded/qsoundqss_qws.cpp @@ -67,6 +67,8 @@ #include <qdebug.h> +#include <qvfbhdr.h> + extern int errno; QT_BEGIN_NAMESPACE @@ -79,7 +81,6 @@ QT_BEGIN_NAMESPACE static int sound_speed = 44100; #ifndef QT_NO_QWS_SOUNDSERVER extern int qws_display_id; -#define SOUND_PIPE "/tmp/.qt_soundserver-%1" #endif static char *zeroMem = 0; @@ -708,7 +709,7 @@ protected: #ifndef QT_NO_QWS_SOUNDSERVER QWSSoundServerSocket::QWSSoundServerSocket(QObject *parent) : - QWSServerSocket(QString::fromLatin1(SOUND_PIPE).arg(qws_display_id), parent) + QWSServerSocket(QT_VFB_SOUND_PIPE(qws_display_id), parent) { connect(this, SIGNAL(newConnection()), this, SLOT(newConnection())); } @@ -716,7 +717,7 @@ QWSSoundServerSocket::QWSSoundServerSocket(QObject *parent) : #ifdef QT3_SUPPORT QWSSoundServerSocket::QWSSoundServerSocket(QObject *parent, const char *name) : - QWSServerSocket(QString::fromLatin1(SOUND_PIPE).arg(qws_display_id), parent) + QWSServerSocket(QT_VFB_SOUND_PIPE(qws_display_id), parent) { if (name) setObjectName(QString::fromAscii(name)); @@ -1395,7 +1396,7 @@ void QWSSoundServer::translateSoundCompleted( int, int sid ) QWSSoundClient::QWSSoundClient(QObject* parent) : QWSSocket(parent) { - connectToLocalFile(QString::fromLatin1(SOUND_PIPE).arg(qws_display_id)); + connectToLocalFile(QT_VFB_SOUND_PIPE(qws_display_id)); QObject::connect(this,SIGNAL(readyRead()), this,SLOT(tryReadCommand())); if( state() == QWS_SOCK_BASE::ConnectedState ) QTimer::singleShot(1, this, SIGNAL(connected())); @@ -1409,7 +1410,7 @@ QWSSoundClient::~QWSSoundClient( ) void QWSSoundClient::reconnect() { - connectToLocalFile(QString::fromLatin1(SOUND_PIPE).arg(qws_display_id)); + connectToLocalFile(QT_VFB_SOUND_PIPE(qws_display_id)); if( state() == QWS_SOCK_BASE::ConnectedState ) emit connected(); else emit error( QTcpSocket::ConnectionRefusedError ); } diff --git a/src/gui/embedded/qvfbhdr.h b/src/gui/embedded/qvfbhdr.h index 73e08e0..f02286e 100644 --- a/src/gui/embedded/qvfbhdr.h +++ b/src/gui/embedded/qvfbhdr.h @@ -52,9 +52,22 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#define QT_VFB_MOUSE_PIPE "/tmp/.qtvfb_mouse-%1" -#define QT_VFB_KEYBOARD_PIPE "/tmp/.qtvfb_keyboard-%1" -#define QT_VFB_MAP "/tmp/.qtvfb_map-%1" +#ifndef QT_QWS_TEMP_DIR +#define QT_QWS_TEMP_DIR "/tmp" +#endif + +#define QT_VFB_DATADIR(DISPLAY) QString("%1/qtembedded-%2-%3") \ + .arg(QT_QWS_TEMP_DIR).arg(getuid()).arg(DISPLAY) + +#define QT_VFB_MOUSE_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \ + .append("/qtvfb_mouse") +#define QT_VFB_KEYBOARD_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \ + .append("/qtvfb_keyboard") +#define QT_VFB_MAP(DISPLAY) QT_VFB_DATADIR(DISPLAY) \ + .append("/qtvfb_map") +#define QT_VFB_SOUND_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \ + .append("/qt_soundserver") +#define QTE_PIPE "QtEmbedded" struct QVFbHeader { diff --git a/src/gui/embedded/qwscommand_qws_p.h b/src/gui/embedded/qwscommand_qws_p.h index d92c6af..f986a9d 100644 --- a/src/gui/embedded/qwscommand_qws_p.h +++ b/src/gui/embedded/qwscommand_qws_p.h @@ -75,8 +75,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#define QTE_PIPE "QtEmbedded-%1" - class QRect; /********************************************************************* diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp index e9284f7..01c64f1 100644 --- a/src/gui/kernel/qapplication_qws.cpp +++ b/src/gui/kernel/qapplication_qws.cpp @@ -110,6 +110,8 @@ #include <sys/stat.h> #include <sys/types.h> +#include <qvfbhdr.h> + #ifndef QT_NO_QWS_MULTIPROCESS #ifdef QT_NO_QSHM #include <sys/ipc.h> @@ -199,14 +201,9 @@ QString qws_dataDir() static QString result; if (!result.isEmpty()) return result; - QByteArray dataDir; -#ifdef QT_QWS_TEMP_DIR - dataDir = QT_QWS_TEMP_DIR; -#else - dataDir = "/tmp"; -#endif - dataDir += "/qtembedded-"; - dataDir += QByteArray::number(qws_display_id); + result = QT_VFB_DATADIR(qws_display_id); + QByteArray dataDir = result.toLocal8Bit(); + if (QT_MKDIR(dataDir, 0700)) { if (errno != EEXIST) { qFatal("Cannot create Qt for Embedded Linux data directory: %s", dataDir.constData()); @@ -227,16 +224,15 @@ QString qws_dataDir() if ((buf.st_mode & 0677) != 0600) qFatal("Qt for Embedded Linux data directory has incorrect permissions: %s", dataDir.constData()); #endif - dataDir += '/'; - result = QString::fromLocal8Bit(dataDir); + result.append("/"); return result; } // Get the filename of the pipe Qt for Embedded Linux uses for server/client comms Q_GUI_EXPORT QString qws_qtePipeFilename() { - return (qws_dataDir() + QString::fromLatin1(QTE_PIPE).arg(qws_display_id)); + return (qws_dataDir().append(QTE_PIPE)); } static void setMaxWindowRect(const QRect &rect) |