mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
Forward declare types as much as possible
This commit is contained in:
parent
7ab3479a34
commit
5c015d573b
@ -1,4 +1,31 @@
|
|||||||
/****************************************************************************
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2019 Mike Tzou (Chocobo1)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*
|
||||||
|
****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
@ -36,28 +63,34 @@
|
|||||||
**
|
**
|
||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
#include "qtlocalpeer.h"
|
#include "qtlocalpeer.h"
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QDataStream>
|
|
||||||
#include <QTime>
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
#include <QLibrary>
|
|
||||||
#include <qt_windows.h>
|
|
||||||
typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
|
|
||||||
static PProcessIdToSessionId pProcessIdToSessionId = 0;
|
|
||||||
#endif
|
|
||||||
#if defined(Q_OS_UNIX)
|
#if defined(Q_OS_UNIX)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace QtLP_Private {
|
#include <QCoreApplication>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QLocalServer>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#include <QLibrary>
|
||||||
|
|
||||||
|
typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
|
||||||
|
static PProcessIdToSessionId pProcessIdToSessionId = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace QtLP_Private
|
||||||
|
{
|
||||||
#include "qtlockedfile.cpp"
|
#include "qtlockedfile.cpp"
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
#include "qtlockedfile_win.cpp"
|
#include "qtlockedfile_win.cpp"
|
||||||
#else
|
#else
|
||||||
@ -68,7 +101,8 @@ namespace QtLP_Private {
|
|||||||
const char* QtLocalPeer::ack = "ack";
|
const char* QtLocalPeer::ack = "ack";
|
||||||
|
|
||||||
QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
|
QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
|
||||||
: QObject(parent), id(appId)
|
: QObject(parent)
|
||||||
|
, id(appId)
|
||||||
{
|
{
|
||||||
QString prefix = id;
|
QString prefix = id;
|
||||||
if (id.isEmpty()) {
|
if (id.isEmpty()) {
|
||||||
@ -109,8 +143,6 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
|
|||||||
lockFile.open(QIODevice::ReadWrite);
|
lockFile.open(QIODevice::ReadWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool QtLocalPeer::isClient()
|
bool QtLocalPeer::isClient()
|
||||||
{
|
{
|
||||||
if (lockFile.isLocked())
|
if (lockFile.isLocked())
|
||||||
@ -120,7 +152,7 @@ bool QtLocalPeer::isClient()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool res = server->listen(socketName);
|
bool res = server->listen(socketName);
|
||||||
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
|
#if defined(Q_OS_UNIX)
|
||||||
// ### Workaround
|
// ### Workaround
|
||||||
if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
|
if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
|
||||||
QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
|
QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
|
||||||
@ -133,8 +165,7 @@ bool QtLocalPeer::isClient()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QtLocalPeer::sendMessage(const QString &message, const int timeout)
|
||||||
bool QtLocalPeer::sendMessage(const QString &message, int timeout)
|
|
||||||
{
|
{
|
||||||
if (!isClient())
|
if (!isClient())
|
||||||
return false;
|
return false;
|
||||||
@ -170,6 +201,10 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString QtLocalPeer::applicationId() const
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
void QtLocalPeer::receiveConnection()
|
void QtLocalPeer::receiveConnection()
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,31 @@
|
|||||||
/****************************************************************************
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2019 Mike Tzou (Chocobo1)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*
|
||||||
|
****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
@ -36,38 +63,37 @@
|
|||||||
**
|
**
|
||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef QTLOCALPEER_H
|
#ifndef QTLOCALPEER_H
|
||||||
#define QTLOCALPEER_H
|
#define QTLOCALPEER_H
|
||||||
|
|
||||||
#include <QLocalServer>
|
|
||||||
#include <QLocalSocket>
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#include "qtlockedfile.h"
|
#include "qtlockedfile.h"
|
||||||
|
|
||||||
|
class QLocalServer;
|
||||||
|
|
||||||
class QtLocalPeer : public QObject
|
class QtLocalPeer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
|
QtLocalPeer(QObject *parent = nullptr, const QString &appId = QString());
|
||||||
|
|
||||||
bool isClient();
|
bool isClient();
|
||||||
bool sendMessage(const QString &message, int timeout);
|
bool sendMessage(const QString &message, int timeout);
|
||||||
QString applicationId() const
|
QString applicationId() const;
|
||||||
{ return id; }
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
signals:
|
||||||
void messageReceived(const QString &message);
|
void messageReceived(const QString &message);
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected slots:
|
||||||
void receiveConnection();
|
void receiveConnection();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString id;
|
QString id;
|
||||||
QString socketName;
|
QString socketName;
|
||||||
QLocalServer* server;
|
QLocalServer *server = nullptr;
|
||||||
QtLP_Private::QtLockedFile lockFile;
|
QtLP_Private::QtLockedFile lockFile;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1,4 +1,31 @@
|
|||||||
/****************************************************************************
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2019 Mike Tzou (Chocobo1)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*
|
||||||
|
****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
@ -36,7 +63,8 @@
|
|||||||
**
|
**
|
||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
#include "qtlockedfile.h"
|
#include "qtlockedfile.h"
|
||||||
|
|
||||||
@ -120,7 +148,7 @@ QtLockedFile::QtLockedFile(const QString &name)
|
|||||||
|
|
||||||
\sa QFile::open(), QFile::resize()
|
\sa QFile::open(), QFile::resize()
|
||||||
*/
|
*/
|
||||||
bool QtLockedFile::open(OpenMode mode)
|
bool QtLockedFile::open(const OpenMode mode)
|
||||||
{
|
{
|
||||||
if (mode & QIODevice::Truncate) {
|
if (mode & QIODevice::Truncate) {
|
||||||
qWarning("QtLockedFile::open(): Truncate mode not allowed.");
|
qWarning("QtLockedFile::open(): Truncate mode not allowed.");
|
||||||
|
@ -1,4 +1,31 @@
|
|||||||
/****************************************************************************
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2019 Mike Tzou (Chocobo1)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*
|
||||||
|
****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
@ -36,22 +63,29 @@
|
|||||||
**
|
**
|
||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef QTLOCKEDFILE_H
|
#ifndef QTLOCKEDFILE_H
|
||||||
#define QTLOCKEDFILE_H
|
#define QTLOCKEDFILE_H
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace QtLP_Private {
|
namespace QtLP_Private
|
||||||
|
|
||||||
class QtLockedFile : public QFile
|
|
||||||
{
|
{
|
||||||
public:
|
class QtLockedFile : public QFile
|
||||||
enum LockMode { NoLock = 0, ReadLock, WriteLock };
|
{
|
||||||
|
public:
|
||||||
|
enum LockMode
|
||||||
|
{
|
||||||
|
NoLock = 0,
|
||||||
|
ReadLock,
|
||||||
|
WriteLock
|
||||||
|
};
|
||||||
|
|
||||||
QtLockedFile();
|
QtLockedFile();
|
||||||
QtLockedFile(const QString &name);
|
QtLockedFile(const QString &name);
|
||||||
@ -64,18 +98,19 @@ public:
|
|||||||
bool isLocked() const;
|
bool isLocked() const;
|
||||||
LockMode lockMode() const;
|
LockMode lockMode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
Qt::HANDLE getMutexHandle(int idx, bool doCreate);
|
||||||
|
bool waitMutex(Qt::HANDLE mutex, bool doBlock);
|
||||||
|
|
||||||
Qt::HANDLE wmutex;
|
Qt::HANDLE wmutex;
|
||||||
Qt::HANDLE rmutex;
|
Qt::HANDLE rmutex;
|
||||||
QVector<Qt::HANDLE> rmutexes;
|
QVector<Qt::HANDLE> rmutexes;
|
||||||
QString mutexname;
|
QString mutexname;
|
||||||
|
|
||||||
Qt::HANDLE getMutexHandle(int idx, bool doCreate);
|
|
||||||
bool waitMutex(Qt::HANDLE mutex, bool doBlock);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LockMode m_lock_mode;
|
LockMode m_lock_mode;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,31 @@
|
|||||||
/****************************************************************************
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2019 Mike Tzou (Chocobo1)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*
|
||||||
|
****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
@ -36,15 +63,16 @@
|
|||||||
**
|
**
|
||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************
|
||||||
|
*/
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#include "qtlockedfile.h"
|
#include "qtlockedfile.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
bool QtLockedFile::lock(LockMode mode, bool block)
|
bool QtLockedFile::lock(LockMode mode, bool block)
|
||||||
{
|
{
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
@ -75,12 +103,10 @@ bool QtLockedFile::lock(LockMode mode, bool block)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_lock_mode = mode;
|
m_lock_mode = mode;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool QtLockedFile::unlock()
|
bool QtLockedFile::unlock()
|
||||||
{
|
{
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
@ -112,4 +138,3 @@ QtLockedFile::~QtLockedFile()
|
|||||||
if (isOpen())
|
if (isOpen())
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,31 @@
|
|||||||
/****************************************************************************
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2019 Mike Tzou (Chocobo1)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give permission to
|
||||||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||||||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||||||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
* exception statement from your version.
|
||||||
|
*
|
||||||
|
****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
@ -36,19 +63,18 @@
|
|||||||
**
|
**
|
||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
#include "qtlockedfile.h"
|
#include "qtlockedfile.h"
|
||||||
#include <qt_windows.h>
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
#define MUTEX_PREFIX "QtLockedFile mutex "
|
#define MUTEX_PREFIX "QtLockedFile mutex "
|
||||||
// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS
|
// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS
|
||||||
#define MAX_READERS MAXIMUM_WAIT_OBJECTS
|
#define MAX_READERS MAXIMUM_WAIT_OBJECTS
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
#define QT_WA(unicode, ansi) unicode
|
#define QT_WA(unicode, ansi) unicode
|
||||||
#endif
|
|
||||||
|
|
||||||
Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
|
Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
|
||||||
{
|
{
|
||||||
@ -99,8 +125,6 @@ bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool QtLockedFile::lock(LockMode mode, bool block)
|
bool QtLockedFile::lock(LockMode mode, bool block)
|
||||||
{
|
{
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user