2014-01-15 03:19:29 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// MediaInfoXP
|
2020-04-04 15:49:22 +02:00
|
|
|
// Copyright (C) 2004-2020 LoRd_MuldeR <MuldeR2@GMX.de>
|
2014-01-15 03:19:29 +01:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-01-16 02:09:48 +01:00
|
|
|
#include <QThread>
|
2014-01-15 03:19:29 +01:00
|
|
|
|
2015-05-02 21:04:23 +02:00
|
|
|
namespace MUtils
|
2014-01-15 03:19:29 +01:00
|
|
|
{
|
2015-05-02 21:04:23 +02:00
|
|
|
class IPCChannel;
|
|
|
|
}
|
2014-01-16 02:09:48 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class IPCSendThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2015-05-02 21:04:23 +02:00
|
|
|
public:
|
|
|
|
IPCSendThread(MUtils::IPCChannel *const ipc, const quint32 &command, const QString &message);
|
2014-01-16 02:09:48 +01:00
|
|
|
inline bool result(void) { return m_result; }
|
|
|
|
|
|
|
|
virtual void run(void);
|
|
|
|
|
|
|
|
private:
|
2017-04-20 22:59:57 +02:00
|
|
|
QAtomicInt m_result;
|
2015-05-02 21:04:23 +02:00
|
|
|
MUtils::IPCChannel *const m_ipc;
|
|
|
|
const quint32 m_command;
|
|
|
|
const QString m_message;
|
2014-01-16 02:09:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class IPCReceiveThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2015-05-02 21:04:23 +02:00
|
|
|
public:
|
|
|
|
IPCReceiveThread(MUtils::IPCChannel *const ipc);
|
|
|
|
void stop(void);
|
2014-01-16 02:09:48 +01:00
|
|
|
|
2015-05-02 21:04:23 +02:00
|
|
|
protected:
|
2014-01-16 02:09:48 +01:00
|
|
|
virtual void run(void);
|
|
|
|
|
|
|
|
signals:
|
2015-05-02 21:04:23 +02:00
|
|
|
void received(const quint32 &command, const QString &message);
|
2014-01-16 02:09:48 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void receiveLoop(void);
|
2017-04-20 22:59:57 +02:00
|
|
|
QAtomicInt m_stopped;
|
2015-05-02 21:04:23 +02:00
|
|
|
MUtils::IPCChannel *const m_ipc;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IPC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
COMMAND_NONE = 0,
|
|
|
|
COMMAND_PING = 1,
|
|
|
|
COMMAND_OPEN = 2
|
|
|
|
}
|
|
|
|
ipc_command_t;
|
|
|
|
|
|
|
|
static bool sendAsync(MUtils::IPCChannel *const ipc, const quint32 &command, const QString &message, const quint32 &timeout = 5000);
|
|
|
|
|
|
|
|
private:
|
|
|
|
IPC(void) { throw 666; }
|
2014-01-15 03:19:29 +01:00
|
|
|
};
|