Use QSharedPointer instead of cloning YkChallengeResponseKey and make it a QObject to allow emitting signals

This commit is contained in:
Janek Bevendorff
2017-02-23 23:52:36 +01:00
parent e93e4a9931
commit 093fe5c7ef
9 changed files with 78 additions and 66 deletions

View File

@@ -22,20 +22,34 @@
#include "keys/ChallengeResponseKey.h"
#include "keys/drivers/YubiKey.h"
class YkChallengeResponseKey : public ChallengeResponseKey
#include <QObject>
class YkChallengeResponseKey : public QObject, public ChallengeResponseKey
{
Q_OBJECT
public:
YkChallengeResponseKey(int slot = -1,
bool blocking = false);
YkChallengeResponseKey(int slot = -1, bool blocking = false);
QByteArray rawKey() const;
YkChallengeResponseKey* clone() const;
bool challenge(const QByteArray& chal);
bool challenge(const QByteArray& chal, int retries);
bool challenge(const QByteArray& chal, unsigned retries);
QString getName() const;
bool isBlocking() const;
signals:
/**
* Emitted whenever user interaction is required to proceed with the challenge-response protocol.
* You can use this to show a helpful dialog informing the user that his assistance is required.
*/
void userInteractionRequired();
/**
* Emitted when the user has provided their required input.
*/
void userConfirmed();
private:
QByteArray m_key;
int m_slot;