1 --- qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.cpp 2009-12-16 10:43:33.000000000 +0000
2 +++ qtsingleapplication/src/qtlocalpeer.cpp 2010-07-10 16:26:50.000000000 +0100
4 #include "qtlocalpeer.h"
5 #include <QtCore/QCoreApplication>
6 #include <QtCore/QTime>
10 #include <QtCore/QLibrary>
13 bool QtLocalPeer::sendMessage(const QString &message, int timeout)
15 + return sendMessage(message.toUtf8(), timeout);
18 +bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout)
27 - QByteArray uMsg(message.toUtf8());
28 QDataStream ds(&socket);
29 - ds.writeBytes(uMsg.constData(), uMsg.size());
30 + ds.writeBytes(message.constData(), message.size());
31 bool res = socket.waitForBytesWritten(timeout);
32 res &= socket.waitForReadyRead(timeout); // wait for ack
33 res &= (socket.read(qstrlen(ack)) == ack);
38 - QString message(QString::fromUtf8(uMsg));
39 socket->write(ack, qstrlen(ack));
40 socket->waitForBytesWritten(1000);
42 - emit messageReceived(message); //### (might take a long time to return)
43 + emit messageReceived(uMsg); //### (might take a long time to return)
44 + emit messageReceived(QString::fromUtf8(uMsg));
46 --- qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h 2009-12-16 10:43:33.000000000 +0000
47 +++ qtsingleapplication/src/qtlocalpeer.h 2010-07-10 16:26:16.000000000 +0100
49 QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
51 bool sendMessage(const QString &message, int timeout);
52 + bool sendMessage(const QByteArray &message, int timeout);
53 QString applicationId() const
57 void messageReceived(const QString &message);
58 + void messageReceived(const QByteArray &message);
61 void receiveConnection();
62 --- qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp 2009-12-16 10:43:33.000000000 +0000
63 +++ qtsingleapplication/src/qtlockedfile_win.cpp 2010-07-10 16:26:33.000000000 +0100
68 - QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
69 + QT_WA( { mutex = CreateMutexW(NULL, FALSE, (WCHAR*)mname.utf16()); },
70 { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
72 qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
77 - QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
78 + QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (WCHAR*)mname.utf16()); },
79 { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
81 if (GetLastError() != ERROR_FILE_NOT_FOUND)
82 --- qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp 2009-12-16 10:43:33.000000000 +0000
83 +++ qtsingleapplication/src/qtsingleapplication.cpp 2010-07-10 16:23:53.000000000 +0100
86 peer = new QtLocalPeer(this, appId);
87 connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
88 + connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
93 return peer->sendMessage(message, timeout);
96 +bool QtSingleApplication::sendMessage(const QByteArray &message, int timeout)
98 + return peer->sendMessage(message, timeout);
103 Returns the application identifier. Two processes with the same
104 @@ -291,10 +297,14 @@
105 void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
108 - if (activateOnMessage)
109 + if (activateOnMessage) {
110 connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
112 + connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
115 disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
116 + disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
121 --- qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h 2009-12-16 10:43:33.000000000 +0000
122 +++ qtsingleapplication/src/qtsingleapplication.h 2010-07-10 16:23:53.000000000 +0100
126 bool sendMessage(const QString &message, int timeout = 5000);
127 + bool sendMessage(const QByteArray &message, int timeout = 5000);
128 void activateWindow();
132 void messageReceived(const QString &message);
133 + void messageReceived(const QByteArray &message);
137 --- qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp 2009-12-16 10:43:33.000000000 +0000
138 +++ qtsingleapplication/src/qtsinglecoreapplication.cpp 2010-07-10 16:32:33.000000000 +0100
141 peer = new QtLocalPeer(this);
142 connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
143 + connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
149 peer = new QtLocalPeer(this, appId);
150 connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
151 + connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
156 return peer->sendMessage(message, timeout);
159 +bool QtSingleCoreApplication::sendMessage(const QByteArray &message, int timeout)
161 + return peer->sendMessage(message, timeout);
166 Returns the application identifier. Two processes with the same
167 --- qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h 2009-12-16 10:43:33.000000000 +0000
168 +++ qtsingleapplication/src/qtsinglecoreapplication.h 2010-07-10 16:32:33.000000000 +0100
172 bool sendMessage(const QString &message, int timeout = 5000);
173 + bool sendMessage(const QByteArray &message, int timeout = 5000);
177 void messageReceived(const QString &message);
178 + void messageReceived(const QByteArray &message);