Kleo::KeyListJob *CryptPlugWrapper::keyListJob(bool remote, bool includeSigs, bool validate) const
{
    if(!_cp)
        return 0;

    GpgME::Context *context = GpgME::Context::createForProtocol(_cp->mProtocol);
    if(!context)
        return 0;

    unsigned int mode = context->keyListMode();
    if(remote)
    {
        mode |= GpgME::Context::Extern;
        mode &= ~GpgME::Context::Local;
    }
    else
    {
        mode |= GpgME::Context::Local;
        mode &= ~GpgME::Context::Extern;
    }
    if(includeSigs) mode |= GpgME::Context::Signatures;
    if(validate) mode |= GpgME::Context::Validate;
    context->setKeyListMode(mode);
    return new Kleo::QGpgMEKeyListJob(context);
}
Kleo::DownloadJob *CryptPlugWrapper::downloadJob(bool armor) const
{
    if(!_cp)
        return 0;

    GpgME::Context *context = GpgME::Context::createForProtocol(_cp->mProtocol);
    if(!context)
        return 0;

    context->setArmor(armor);
    // this is the hackish interface for downloading from keyserers currently:
    context->setKeyListMode(GpgME::Context::Extern);

    return new Kleo::QGpgMEDownloadJob(context);
}