AusweisApp2/src/card/drivers/ReaderDetector.h

82 lines
1.5 KiB
C
Raw Normal View History

2017-07-03 09:30:10 +02:00
/*!
* \brief Interface specifying classes that can detect the attached card reader
* devices on a specific platform.
*
2018-03-28 15:10:51 +02:00
* \copyright Copyright (c) 2015-2018 Governikus GmbH & Co. KG, Germany
2017-07-03 09:30:10 +02:00
*/
#pragma once
2017-12-20 14:54:05 +01:00
#include "ReaderConfiguration.h"
#include "UsbId.h"
2017-07-03 09:30:10 +02:00
2017-12-20 14:54:05 +01:00
#ifdef Q_OS_MACOS
2017-07-03 09:30:10 +02:00
#include <IOKit/IOKitLib.h>
#endif
#ifdef Q_OS_LINUX
#include <QThread>
class DeviceListener;
#endif
#ifdef Q_OS_WIN
#include <QAbstractNativeEventFilter>
#endif
#include <QSharedPointer>
#include <QVector>
namespace governikus
{
2017-12-20 14:54:05 +01:00
2017-07-03 09:30:10 +02:00
class ReaderDetector
: public QObject
#ifdef Q_OS_WIN
, QAbstractNativeEventFilter
#endif
{
Q_OBJECT
private:
2017-12-20 14:54:05 +01:00
#ifdef Q_OS_MACOS
2017-07-03 09:30:10 +02:00
io_iterator_t mIteratorPublish;
io_iterator_t mIteratorTerminated;
#endif
#ifdef Q_OS_LINUX
2018-07-10 14:24:10 +02:00
DeviceListener* mDeviceListener;
2017-07-03 09:30:10 +02:00
#endif
bool initNativeEvents();
bool terminateNativeEvents();
public:
2017-12-20 14:54:05 +01:00
static ReaderDetector& getInstance();
ReaderDetector();
2017-07-03 09:30:10 +02:00
virtual ~ReaderDetector();
2017-12-20 14:54:05 +01:00
virtual QVector<UsbId> attachedDevIds() const;
2017-07-03 09:30:10 +02:00
#ifdef Q_OS_WIN
bool nativeEventFilter(const QByteArray& pEventType, void* pMessage, long* pResult) override;
#endif
/*!
* \brief getAttachedDevices produce a list of supported devices that are
* attached to the system
*/
2017-12-20 14:54:05 +01:00
QVector<ReaderConfigurationInfo> getAttachedSupportedDevices() const;
ReaderConfigurationInfo getReaderConfigurationInfo(const QString& pReaderName);
2017-07-03 09:30:10 +02:00
Q_SIGNALS:
void fireReaderChangeDetected();
};
} /* namespace governikus */