Cpp: Add support for pinentry_mode
* lang/cpp/src/context.cpp (Context::pinentryMode): Return mode. (Context::setPinentryMode): Set mode. * lang/cpp/src/context.h (PinentryMode): Add enum.
This commit is contained in:
parent
fbd6ac4655
commit
d75c118aae
@ -1255,6 +1255,46 @@ Error Context::lastError() const
|
|||||||
return Error(d->lasterr);
|
return Error(d->lasterr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context::PinentryMode Context::pinentryMode() const
|
||||||
|
{
|
||||||
|
switch (gpgme_get_pinentry_mode (d->ctx)) {
|
||||||
|
case GPGME_PINENTRY_MODE_ASK:
|
||||||
|
return PinentryAsk;
|
||||||
|
case GPGME_PINENTRY_MODE_CANCEL:
|
||||||
|
return PinentryCancel;
|
||||||
|
case GPGME_PINENTRY_MODE_ERROR:
|
||||||
|
return PinentryError;
|
||||||
|
case GPGME_PINENTRY_MODE_LOOPBACK:
|
||||||
|
return PinentryLoopback;
|
||||||
|
case GPGME_PINENTRY_MODE_DEFAULT:
|
||||||
|
default:
|
||||||
|
return PinentryDefault;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Error Context::setPinentryMode(PinentryMode which)
|
||||||
|
{
|
||||||
|
gpgme_pinentry_mode_t mode;
|
||||||
|
switch (which) {
|
||||||
|
case PinentryAsk:
|
||||||
|
mode = GPGME_PINENTRY_MODE_ASK;
|
||||||
|
break;
|
||||||
|
case PinentryCancel:
|
||||||
|
mode = GPGME_PINENTRY_MODE_CANCEL;
|
||||||
|
break;
|
||||||
|
case PinentryError:
|
||||||
|
mode = GPGME_PINENTRY_MODE_ERROR;
|
||||||
|
break;
|
||||||
|
case PinentryLoopback:
|
||||||
|
mode = GPGME_PINENTRY_MODE_LOOPBACK;
|
||||||
|
break;
|
||||||
|
case PinentryDefault:
|
||||||
|
default:
|
||||||
|
mode = GPGME_PINENTRY_MODE_DEFAULT;
|
||||||
|
}
|
||||||
|
return Error(d->lasterr = gpgme_set_pinentry_mode(d->ctx, mode));
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, Protocol proto)
|
std::ostream &operator<<(std::ostream &os, Protocol proto)
|
||||||
{
|
{
|
||||||
os << "GpgME::Protocol(";
|
os << "GpgME::Protocol(";
|
||||||
|
@ -117,6 +117,16 @@ public:
|
|||||||
GpgME::Error setEngineFileName(const char *filename);
|
GpgME::Error setEngineFileName(const char *filename);
|
||||||
GpgME::Error setEngineHomeDirectory(const char *filename);
|
GpgME::Error setEngineHomeDirectory(const char *filename);
|
||||||
|
|
||||||
|
enum PinentryMode{
|
||||||
|
PinentryDefault = 0,
|
||||||
|
PinentryAsk = 1,
|
||||||
|
PinentryCancel = 2,
|
||||||
|
PinentryError = 3,
|
||||||
|
PinentryLoopback = 4
|
||||||
|
};
|
||||||
|
GpgME::Error setPinentryMode(PinentryMode which);
|
||||||
|
PinentryMode pinentryMode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ::GpgME::EventLoopInteractor;
|
friend class ::GpgME::EventLoopInteractor;
|
||||||
void installIOCallbacks(gpgme_io_cbs *iocbs);
|
void installIOCallbacks(gpgme_io_cbs *iocbs);
|
||||||
|
Loading…
Reference in New Issue
Block a user