packages: QtSingleApplication/qtsingleapplication.patch (NEW) - from http:/...

glen glen at pld-linux.org
Mon Sep 6 15:26:22 CEST 2010


Author: glen                         Date: Mon Sep  6 13:26:22 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- from http://clementine-player.googlecode.com/svn/trunk/3rdparty/qtsingleapplication/qtsingleapplication.patch

---- Files affected:
packages/QtSingleApplication:
   qtsingleapplication.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/QtSingleApplication/qtsingleapplication.patch
diff -u /dev/null packages/QtSingleApplication/qtsingleapplication.patch:1.1
--- /dev/null	Mon Sep  6 15:26:22 2010
+++ packages/QtSingleApplication/qtsingleapplication.patch	Mon Sep  6 15:26:16 2010
@@ -0,0 +1,231 @@
+diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.cpp qtsingleapplication/qtlocalpeer.cpp
+--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.cpp	2009-12-16 10:43:33.000000000 +0000
++++ qtsingleapplication/qtlocalpeer.cpp	2010-07-10 16:26:50.000000000 +0100
+@@ -48,6 +48,7 @@
+ #include "qtlocalpeer.h"
+ #include <QtCore/QCoreApplication>
+ #include <QtCore/QTime>
++#include <QtDebug>
+ 
+ #if defined(Q_OS_WIN)
+ #include <QtCore/QLibrary>
+@@ -59,14 +60,12 @@
+ #include <time.h>
+ #endif
+ 
+-namespace QtLP_Private {
+ #include "qtlockedfile.cpp"
+ #if defined(Q_OS_WIN)
+ #include "qtlockedfile_win.cpp"
+ #else
+ #include "qtlockedfile_unix.cpp"
+ #endif
+-}
+ 
+ const char* QtLocalPeer::ack = "ack";
+ 
+@@ -118,7 +117,7 @@
+     if (lockFile.isLocked())
+         return false;
+ 
+-    if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
++    if (!lockFile.lock(QtLockedFile::WriteLock, false))
+         return true;
+ 
+     bool res = server->listen(socketName);
+@@ -138,6 +137,11 @@
+ 
+ bool QtLocalPeer::sendMessage(const QString &message, int timeout)
+ {
++    return sendMessage(message.toUtf8(), timeout);
++}
++
++bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout)
++{
+     if (!isClient())
+         return false;
+ 
+@@ -160,9 +164,8 @@
+     if (!connOk)
+         return false;
+ 
+-    QByteArray uMsg(message.toUtf8());
+     QDataStream ds(&socket);
+-    ds.writeBytes(uMsg.constData(), uMsg.size());
++    ds.writeBytes(message.constData(), message.size());
+     bool res = socket.waitForBytesWritten(timeout);
+     res &= socket.waitForReadyRead(timeout);   // wait for ack
+     res &= (socket.read(qstrlen(ack)) == ack);
+@@ -195,9 +198,9 @@
+         delete socket;
+         return;
+     }
+-    QString message(QString::fromUtf8(uMsg));
+     socket->write(ack, qstrlen(ack));
+     socket->waitForBytesWritten(1000);
+     delete socket;
+-    emit messageReceived(message); //### (might take a long time to return)
++    emit messageReceived(uMsg); //### (might take a long time to return)
++    emit messageReceived(QString::fromUtf8(uMsg));
+ }
+diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h qtsingleapplication/qtlocalpeer.h
+--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h	2009-12-16 10:43:33.000000000 +0000
++++ qtsingleapplication/qtlocalpeer.h	2010-07-10 16:26:16.000000000 +0100
+@@ -49,9 +49,7 @@
+ #include <QtNetwork/QLocalSocket>
+ #include <QtCore/QDir>
+ 
+-namespace QtLP_Private {
+ #include "qtlockedfile.h"
+-}
+ 
+ class QtLocalPeer : public QObject
+ {
+@@ -61,11 +59,13 @@
+     QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
+     bool isClient();
+     bool sendMessage(const QString &message, int timeout);
++    bool sendMessage(const QByteArray &message, int timeout);
+     QString applicationId() const
+         { return id; }
+ 
+ Q_SIGNALS:
+     void messageReceived(const QString &message);
++    void messageReceived(const QByteArray &message);
+ 
+ protected Q_SLOTS:
+     void receiveConnection();
+@@ -74,7 +74,7 @@
+     QString id;
+     QString socketName;
+     QLocalServer* server;
+-    QtLP_Private::QtLockedFile lockFile;
++    QtLockedFile lockFile;
+ 
+ private:
+     static const char* ack;
+diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp qtsingleapplication/qtlockedfile_win.cpp
+--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp	2009-12-16 10:43:33.000000000 +0000
++++ qtsingleapplication/qtlockedfile_win.cpp	2010-07-10 16:26:33.000000000 +0100
+@@ -65,7 +65,7 @@
+ 
+     Qt::HANDLE mutex;
+     if (doCreate) {
+-        QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
++        QT_WA( { mutex = CreateMutexW(NULL, FALSE, (WCHAR*)mname.utf16()); },
+                { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
+         if (!mutex) {
+             qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
+@@ -73,7 +73,7 @@
+         }
+     }
+     else {
+-        QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
++        QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (WCHAR*)mname.utf16()); },
+                { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
+         if (!mutex) {
+             if (GetLastError() != ERROR_FILE_NOT_FOUND)
+diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp qtsingleapplication/qtsingleapplication.cpp
+--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp	2009-12-16 10:43:33.000000000 +0000
++++ qtsingleapplication/qtsingleapplication.cpp	2010-07-10 16:23:53.000000000 +0100
+@@ -144,6 +144,7 @@
+     actWin = 0;
+     peer = new QtLocalPeer(this, appId);
+     connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
++    connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
+ }
+ 
+ 
+@@ -265,6 +266,11 @@
+     return peer->sendMessage(message, timeout);
+ }
+ 
++bool QtSingleApplication::sendMessage(const QByteArray &message, int timeout)
++{
++    return peer->sendMessage(message, timeout);
++}
++
+ 
+ /*!
+     Returns the application identifier. Two processes with the same
+@@ -291,10 +297,14 @@
+ void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
+ {
+     actWin = aw;
+-    if (activateOnMessage)
++    if (activateOnMessage) {
+         connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
+-    else
++        connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
++    }
++    else {
+         disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
++        disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
++    }
+ }
+ 
+ 
+diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h qtsingleapplication/qtsingleapplication.h
+--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h	2009-12-16 10:43:33.000000000 +0000
++++ qtsingleapplication/qtsingleapplication.h	2010-07-10 16:23:53.000000000 +0100
+@@ -91,11 +91,13 @@
+ 
+ public Q_SLOTS:
+     bool sendMessage(const QString &message, int timeout = 5000);
++    bool sendMessage(const QByteArray &message, int timeout = 5000);
+     void activateWindow();
+ 
+ 
+ Q_SIGNALS:
+     void messageReceived(const QString &message);
++    void messageReceived(const QByteArray &message);
+ 
+ 
+ private:
+diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp qtsingleapplication/qtsinglecoreapplication.cpp
+--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp	2009-12-16 10:43:33.000000000 +0000
++++ qtsingleapplication/qtsinglecoreapplication.cpp	2010-07-10 16:32:33.000000000 +0100
+@@ -81,6 +81,7 @@
+ {
+     peer = new QtLocalPeer(this);
+     connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
++    connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
+ }
+ 
+ 
+@@ -94,6 +95,7 @@
+ {
+     peer = new QtLocalPeer(this, appId);
+     connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
++    connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
+ }
+ 
+ 
+@@ -133,6 +135,11 @@
+     return peer->sendMessage(message, timeout);
+ }
+ 
++bool QtSingleCoreApplication::sendMessage(const QByteArray &message, int timeout)
++{
++    return peer->sendMessage(message, timeout);
++}
++
+ 
+ /*!
+     Returns the application identifier. Two processes with the same
+diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h qtsingleapplication/qtsinglecoreapplication.h
+--- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h	2009-12-16 10:43:33.000000000 +0000
++++ qtsingleapplication/qtsinglecoreapplication.h	2010-07-10 16:32:33.000000000 +0100
+@@ -62,10 +62,12 @@
+ 
+ public Q_SLOTS:
+     bool sendMessage(const QString &message, int timeout = 5000);
++    bool sendMessage(const QByteArray &message, int timeout = 5000);
+ 
+ 
+ Q_SIGNALS:
+     void messageReceived(const QString &message);
++    void messageReceived(const QByteArray &message);
+ 
+ 
+ private:
================================================================


More information about the pld-cvs-commit mailing list