diff options
author | Olli Werwolff <qt-info@nokia.com> | 2011-06-07 09:04:56 +0200 |
---|---|---|
committer | Olli Werwolff <qt-info@nokia.com> | 2011-06-24 09:39:26 +0200 |
commit | 0612b4d1b9b8b1147b865eca07c79c74ee524e73 (patch) | |
tree | 458817331f6d6c0ee9e2f8af65ca9ef47b366511 /src | |
parent | f0eb961b35f6994ce03a3574bcd56acb385c14b9 (diff) |
Use version specific local servers in application-/mobilitymanager
In order to support the installation of more than one simulator at the
same time each simulator version uses its specific local server.
Reviewed-by: ckamm
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/mobility/mobilitymanager.cpp | 15 | ||||
-rw-r--r-- | src/mobility/mobilitymanager.h | 5 | ||||
-rw-r--r-- | src/other/applicationmanager.cpp | 11 | ||||
-rw-r--r-- | src/other/applicationmanager.h | 3 | ||||
-rw-r--r-- | src/other/deviceitem.h | 2 | ||||
-rw-r--r-- | src/ui/mainwindow.cpp | 6 |
7 files changed, 22 insertions, 24 deletions
diff --git a/src/main.cpp b/src/main.cpp index 261a4c4..e45958c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -85,7 +85,7 @@ static void registerSimulator(const QString &location) settings->beginGroup(SIMULATOR_APP_QT_VERSIONS_KEY); QList<QString> supportedQtVersion; - supportedQtVersion << "4.7.4.0"; + supportedQtVersion << "4.7.4.0" << "4.8.0.0"; foreach(const QString &version, supportedQtVersion) { QList<QString> simulators; QVariant value = settings->value(version); @@ -151,7 +151,7 @@ int main(int argc, char **argv) QCoreApplication::setOrganizationName(SIMULATOR_APP_VENDOR); QCoreApplication::setApplicationName(SIMULATOR_APP_NAME); - SharedTools::QtSingleApplication app(SIMULATOR_APP_NAME, argc, argv); + SharedTools::QtSingleApplication app(SIMULATOR_APP_NAME + simulatorVersion.toString(), argc, argv); QDir::setCurrent(app.applicationDirPath()); diff --git a/src/mobility/mobilitymanager.cpp b/src/mobility/mobilitymanager.cpp index 888ea64..2508ba0 100644 --- a/src/mobility/mobilitymanager.cpp +++ b/src/mobility/mobilitymanager.cpp @@ -56,13 +56,14 @@ using namespace QtMobility; int MobilityClient::contactsClientsCount = 0; -MobilityServer::MobilityServer(MobilityData *mobility, QObject *parent) +MobilityServer::MobilityServer(const VersionStruct &version, MobilityData *mobility, QObject *parent) : QObject(parent) + , mVersion(version) , mMobility(mobility) { mServer = new QLocalServer(); - QLocalServer::removeServer(SIMULATOR_MOBILITY_SERVERNAME); - if (!mServer->listen(SIMULATOR_MOBILITY_SERVERNAME)) { + QLocalServer::removeServer(SIMULATOR_MOBILITY_SERVERNAME + mVersion.toString()); + if (!mServer->listen(SIMULATOR_MOBILITY_SERVERNAME + mVersion.toString())) { qFatal("Could not open mobility server"); } connect(mServer, SIGNAL(newConnection()), this, SLOT(newConnection())); @@ -81,7 +82,7 @@ MobilityServer::~MobilityServer() { if (mServer) { mServer->close(); - QLocalServer::removeServer(SIMULATOR_DISPLAY_SERVERNAME); + QLocalServer::removeServer(SIMULATOR_MOBILITY_SERVERNAME + mVersion.toString()); delete mServer; mServer = 0; } @@ -140,7 +141,7 @@ void MobilityServer::newConnection() // success: register client emit applicationConnected(cmd.reply.appId, cmd.request.version); - mClients.append(new MobilityClient(cmd.request.applicationPid, socket, this)); + mClients.append(new MobilityClient(mVersion.toString(), cmd.request.applicationPid, socket, this)); } void MobilityServer::removeClient(MobilityClient *c) @@ -148,7 +149,7 @@ void MobilityServer::removeClient(MobilityClient *c) mClients.removeAll(c); } -MobilityClient::MobilityClient(qint64 pid, QLocalSocket *receiveSocket, MobilityServer *server) +MobilityClient::MobilityClient(const QString &simVersion, qint64 pid, QLocalSocket *receiveSocket, MobilityServer *server) : QObject(server) , mPid(pid) , mReceiveSocket(receiveSocket) @@ -160,7 +161,7 @@ MobilityClient::MobilityClient(qint64 pid, QLocalSocket *receiveSocket, Mobility { // initiate sendSocket as a backchannel to the client mSendSocket = new QLocalSocket(this); - mSendSocket->connectToServer(qt_mobilityServerName(pid)); + mSendSocket->connectToServer(qt_mobilityServerName(simVersion, pid)); if (!mSendSocket->waitForConnected(1000)) qFatal("Couldn't set up back channel to mobility interface of client"); diff --git a/src/mobility/mobilitymanager.h b/src/mobility/mobilitymanager.h index d5ab70f..4d413ee 100644 --- a/src/mobility/mobilitymanager.h +++ b/src/mobility/mobilitymanager.h @@ -75,9 +75,8 @@ class MobilityServer : public QObject { Q_OBJECT public: - explicit MobilityServer(MobilityData *mobility, QObject *parent = 0); + explicit MobilityServer(const VersionStruct &version, MobilityData *mobility, QObject *parent = 0); ~MobilityServer(); - void setVersion(VersionStruct version) { mVersion = version; } private slots: void newConnection(); @@ -101,7 +100,7 @@ class MobilityClient : public QObject { Q_OBJECT public: - MobilityClient(qint64 pid, QLocalSocket *receiveSocket, MobilityServer *server); + MobilityClient(const QString &simVersion, qint64 pid, QLocalSocket *receiveSocket, MobilityServer *server); ~MobilityClient(); public slots: diff --git a/src/other/applicationmanager.cpp b/src/other/applicationmanager.cpp index c1697ee..bac97c2 100644 --- a/src/other/applicationmanager.cpp +++ b/src/other/applicationmanager.cpp @@ -62,8 +62,9 @@ namespace { int gAppIdCounter = 0; } -ApplicationManager::ApplicationManager(QObject *parent) +ApplicationManager::ApplicationManager(const VersionStruct &simulatorVersion, QObject *parent) : QObject(parent) + , mVersion(simulatorVersion) , mServer(0) , mPhononManager(0) , mWidgetManager(0) @@ -72,15 +73,15 @@ ApplicationManager::ApplicationManager(QObject *parent) { // simulator socket connection QLocalSocket checkSocket; - checkSocket.connectToServer(SIMULATOR_DISPLAY_SERVERNAME); + checkSocket.connectToServer(SIMULATOR_DISPLAY_SERVERNAME + mVersion.toString()); if (checkSocket.waitForConnected(100)) { mSimulatorStarted = true; return; } mServer = new QLocalServer(); - QLocalServer::removeServer(SIMULATOR_DISPLAY_SERVERNAME); - if (!mServer->listen(SIMULATOR_DISPLAY_SERVERNAME)) { + QLocalServer::removeServer(SIMULATOR_DISPLAY_SERVERNAME + mVersion.toString()); + if (!mServer->listen(SIMULATOR_DISPLAY_SERVERNAME + mVersion.toString())) { qFatal("Could not open mServer"); } connect(mServer, SIGNAL(newConnection()), this, SLOT(handleConnection())); @@ -105,7 +106,7 @@ ApplicationManager::~ApplicationManager() { if (mServer) { mServer->close(); - QLocalServer::removeServer(SIMULATOR_DISPLAY_SERVERNAME); + QLocalServer::removeServer(SIMULATOR_DISPLAY_SERVERNAME + mVersion.toString()); delete mServer; mServer = 0; } diff --git a/src/other/applicationmanager.h b/src/other/applicationmanager.h index 7770545..d93261d 100644 --- a/src/other/applicationmanager.h +++ b/src/other/applicationmanager.h @@ -50,7 +50,7 @@ class ApplicationManager : public QObject { Q_OBJECT public: - ApplicationManager(QObject* parent = 0); + ApplicationManager(const VersionStruct &simulatorVersion, QObject* parent = 0); ~ApplicationManager(); Application* applicationForId(int); @@ -64,7 +64,6 @@ public: bool hasApplications() const; bool simulatorAlreadyStarted() const; bool initializeFontDirectory(); - void setVersion(VersionStruct version) { mVersion = version; } signals: void applicationRegistered(Application*); diff --git a/src/other/deviceitem.h b/src/other/deviceitem.h index 37fb8d3..a042d61 100644 --- a/src/other/deviceitem.h +++ b/src/other/deviceitem.h @@ -51,7 +51,7 @@ enum Orientation { topUp = 0x0000001, topDown = 0x0000002, leftUp = 0x0000004, - rightUp = 0x0000008, + rightUp = 0x0000008 }; Q_DECLARE_FLAGS(SupportedOrientations, Orientation) diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 6deb5c3..2703f75 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -106,18 +106,16 @@ MainWindow::MainWindow(QWidget *parent) { setWindowIcon(QIcon(":/ui/icons/hicolor/256x256/apps/Nokia-Simulator.png")); - applicationManager = new ApplicationManager(this); + applicationManager = new ApplicationManager(simulatorVersion, this); if (applicationManager->simulatorAlreadyStarted() || !applicationManager->initializeFontDirectory()) { QTimer::singleShot(0, this, SLOT(close())); startupError = true; return; } - applicationManager->setVersion(simulatorVersion); MobilityData *mobility = new MobilityData(this); - mobilityServer = new MobilityServer(mobility, this); - mobilityServer->setVersion(simulatorVersion); + mobilityServer = new MobilityServer(simulatorVersion, mobility, this); setWindowTitle(tr("Qt Simulator")); #ifdef Q_OS_MAC |