]> git.pld-linux.org Git - packages/QtSingleApplication.git/blob - clementine.patch
- from http://clementine-player.googlecode.com/svn/trunk/3rdparty/qtsingleapplication...
[packages/QtSingleApplication.git] / clementine.patch
1 diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.cpp qtsingleapplication/qtlocalpeer.cpp
2 --- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.cpp        2009-12-16 10:43:33.000000000 +0000
3 +++ qtsingleapplication/qtlocalpeer.cpp 2010-07-10 16:26:50.000000000 +0100
4 @@ -48,6 +48,7 @@
5  #include "qtlocalpeer.h"
6  #include <QtCore/QCoreApplication>
7  #include <QtCore/QTime>
8 +#include <QtDebug>
9  
10  #if defined(Q_OS_WIN)
11  #include <QtCore/QLibrary>
12 @@ -59,14 +60,12 @@
13  #include <time.h>
14  #endif
15  
16 -namespace QtLP_Private {
17  #include "qtlockedfile.cpp"
18  #if defined(Q_OS_WIN)
19  #include "qtlockedfile_win.cpp"
20  #else
21  #include "qtlockedfile_unix.cpp"
22  #endif
23 -}
24  
25  const char* QtLocalPeer::ack = "ack";
26  
27 @@ -118,7 +117,7 @@
28      if (lockFile.isLocked())
29          return false;
30  
31 -    if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
32 +    if (!lockFile.lock(QtLockedFile::WriteLock, false))
33          return true;
34  
35      bool res = server->listen(socketName);
36 @@ -138,6 +137,11 @@
37  
38  bool QtLocalPeer::sendMessage(const QString &message, int timeout)
39  {
40 +    return sendMessage(message.toUtf8(), timeout);
41 +}
42 +
43 +bool QtLocalPeer::sendMessage(const QByteArray &message, int timeout)
44 +{
45      if (!isClient())
46          return false;
47  
48 @@ -160,9 +164,8 @@
49      if (!connOk)
50          return false;
51  
52 -    QByteArray uMsg(message.toUtf8());
53      QDataStream ds(&socket);
54 -    ds.writeBytes(uMsg.constData(), uMsg.size());
55 +    ds.writeBytes(message.constData(), message.size());
56      bool res = socket.waitForBytesWritten(timeout);
57      res &= socket.waitForReadyRead(timeout);   // wait for ack
58      res &= (socket.read(qstrlen(ack)) == ack);
59 @@ -195,9 +198,9 @@
60          delete socket;
61          return;
62      }
63 -    QString message(QString::fromUtf8(uMsg));
64      socket->write(ack, qstrlen(ack));
65      socket->waitForBytesWritten(1000);
66      delete socket;
67 -    emit messageReceived(message); //### (might take a long time to return)
68 +    emit messageReceived(uMsg); //### (might take a long time to return)
69 +    emit messageReceived(QString::fromUtf8(uMsg));
70  }
71 diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h qtsingleapplication/qtlocalpeer.h
72 --- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlocalpeer.h  2009-12-16 10:43:33.000000000 +0000
73 +++ qtsingleapplication/qtlocalpeer.h   2010-07-10 16:26:16.000000000 +0100
74 @@ -49,9 +49,7 @@
75  #include <QtNetwork/QLocalSocket>
76  #include <QtCore/QDir>
77  
78 -namespace QtLP_Private {
79  #include "qtlockedfile.h"
80 -}
81  
82  class QtLocalPeer : public QObject
83  {
84 @@ -61,11 +59,13 @@
85      QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
86      bool isClient();
87      bool sendMessage(const QString &message, int timeout);
88 +    bool sendMessage(const QByteArray &message, int timeout);
89      QString applicationId() const
90          { return id; }
91  
92  Q_SIGNALS:
93      void messageReceived(const QString &message);
94 +    void messageReceived(const QByteArray &message);
95  
96  protected Q_SLOTS:
97      void receiveConnection();
98 @@ -74,7 +74,7 @@
99      QString id;
100      QString socketName;
101      QLocalServer* server;
102 -    QtLP_Private::QtLockedFile lockFile;
103 +    QtLockedFile lockFile;
104  
105  private:
106      static const char* ack;
107 diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp qtsingleapplication/qtlockedfile_win.cpp
108 --- /home/david/qtsingleapplication-2.6_1-opensource/src/qtlockedfile_win.cpp   2009-12-16 10:43:33.000000000 +0000
109 +++ qtsingleapplication/qtlockedfile_win.cpp    2010-07-10 16:26:33.000000000 +0100
110 @@ -65,7 +65,7 @@
111  
112      Qt::HANDLE mutex;
113      if (doCreate) {
114 -        QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
115 +        QT_WA( { mutex = CreateMutexW(NULL, FALSE, (WCHAR*)mname.utf16()); },
116                 { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
117          if (!mutex) {
118              qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
119 @@ -73,7 +73,7 @@
120          }
121      }
122      else {
123 -        QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
124 +        QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (WCHAR*)mname.utf16()); },
125                 { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
126          if (!mutex) {
127              if (GetLastError() != ERROR_FILE_NOT_FOUND)
128 diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp qtsingleapplication/qtsingleapplication.cpp
129 --- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.cpp        2009-12-16 10:43:33.000000000 +0000
130 +++ qtsingleapplication/qtsingleapplication.cpp 2010-07-10 16:23:53.000000000 +0100
131 @@ -144,6 +144,7 @@
132      actWin = 0;
133      peer = new QtLocalPeer(this, appId);
134      connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
135 +    connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
136  }
137  
138  
139 @@ -265,6 +266,11 @@
140      return peer->sendMessage(message, timeout);
141  }
142  
143 +bool QtSingleApplication::sendMessage(const QByteArray &message, int timeout)
144 +{
145 +    return peer->sendMessage(message, timeout);
146 +}
147 +
148  
149  /*!
150      Returns the application identifier. Two processes with the same
151 @@ -291,10 +297,14 @@
152  void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage)
153  {
154      actWin = aw;
155 -    if (activateOnMessage)
156 +    if (activateOnMessage) {
157          connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
158 -    else
159 +        connect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
160 +    }
161 +    else {
162          disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
163 +        disconnect(peer, SIGNAL(messageReceived(const QByteArray&)), this, SLOT(activateWindow()));
164 +    }
165  }
166  
167  
168 diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h qtsingleapplication/qtsingleapplication.h
169 --- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsingleapplication.h  2009-12-16 10:43:33.000000000 +0000
170 +++ qtsingleapplication/qtsingleapplication.h   2010-07-10 16:23:53.000000000 +0100
171 @@ -91,11 +91,13 @@
172  
173  public Q_SLOTS:
174      bool sendMessage(const QString &message, int timeout = 5000);
175 +    bool sendMessage(const QByteArray &message, int timeout = 5000);
176      void activateWindow();
177  
178  
179  Q_SIGNALS:
180      void messageReceived(const QString &message);
181 +    void messageReceived(const QByteArray &message);
182  
183  
184  private:
185 diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp qtsingleapplication/qtsinglecoreapplication.cpp
186 --- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.cpp    2009-12-16 10:43:33.000000000 +0000
187 +++ qtsingleapplication/qtsinglecoreapplication.cpp     2010-07-10 16:32:33.000000000 +0100
188 @@ -81,6 +81,7 @@
189  {
190      peer = new QtLocalPeer(this);
191      connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
192 +    connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
193  }
194  
195  
196 @@ -94,6 +95,7 @@
197  {
198      peer = new QtLocalPeer(this, appId);
199      connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
200 +    connect(peer, SIGNAL(messageReceived(const QByteArray&)), SIGNAL(messageReceived(const QByteArray&)));
201  }
202  
203  
204 @@ -133,6 +135,11 @@
205      return peer->sendMessage(message, timeout);
206  }
207  
208 +bool QtSingleCoreApplication::sendMessage(const QByteArray &message, int timeout)
209 +{
210 +    return peer->sendMessage(message, timeout);
211 +}
212 +
213  
214  /*!
215      Returns the application identifier. Two processes with the same
216 diff -ur /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h qtsingleapplication/qtsinglecoreapplication.h
217 --- /home/david/qtsingleapplication-2.6_1-opensource/src/qtsinglecoreapplication.h      2009-12-16 10:43:33.000000000 +0000
218 +++ qtsingleapplication/qtsinglecoreapplication.h       2010-07-10 16:32:33.000000000 +0100
219 @@ -62,10 +62,12 @@
220  
221  public Q_SLOTS:
222      bool sendMessage(const QString &message, int timeout = 5000);
223 +    bool sendMessage(const QByteArray &message, int timeout = 5000);
224  
225  
226  Q_SIGNALS:
227      void messageReceived(const QString &message);
228 +    void messageReceived(const QByteArray &message);
229  
230  
231  private:
This page took 0.331545 seconds and 3 git commands to generate.