Blame lang/qt/src/protocol.h

Packit d7e8d0
/*
Packit d7e8d0
    protocol.h
Packit d7e8d0
Packit d7e8d0
    This file is part of qgpgme, the Qt API binding for gpgme
Packit d7e8d0
    Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB
Packit d7e8d0
    Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Packit d7e8d0
    Software engineering by Intevation GmbH
Packit d7e8d0
Packit d7e8d0
    QGpgME is free software; you can redistribute it and/or
Packit d7e8d0
    modify it under the terms of the GNU General Public License as
Packit d7e8d0
    published by the Free Software Foundation; either version 2 of the
Packit d7e8d0
    License, or (at your option) any later version.
Packit d7e8d0
Packit d7e8d0
    QGpgME is distributed in the hope that it will be useful,
Packit d7e8d0
    but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit d7e8d0
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit d7e8d0
    General Public License for more details.
Packit d7e8d0
Packit d7e8d0
    You should have received a copy of the GNU General Public License
Packit d7e8d0
    along with this program; if not, write to the Free Software
Packit d7e8d0
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit d7e8d0
Packit d7e8d0
    In addition, as a special exception, the copyright holders give
Packit d7e8d0
    permission to link the code of this program with any edition of
Packit d7e8d0
    the Qt library by Trolltech AS, Norway (or with modified versions
Packit d7e8d0
    of Qt that use the same license as Qt), and distribute linked
Packit d7e8d0
    combinations including the two.  You must obey the GNU General
Packit d7e8d0
    Public License in all respects for all of the code used other than
Packit d7e8d0
    Qt.  If you modify this file, you may extend this exception to
Packit d7e8d0
    your version of the file, but you are not obligated to do so.  If
Packit d7e8d0
    you do not wish to do so, delete this exception statement from
Packit d7e8d0
    your version.
Packit d7e8d0
*/
Packit d7e8d0
#ifndef __QGPGME_PROTOCOL_H__
Packit d7e8d0
#define __QGPGME_PROTOCOL_H__
Packit d7e8d0
Packit d7e8d0
#include <QString>
Packit d7e8d0
#include <QVariant>
Packit d7e8d0
Packit d7e8d0
#include "qgpgme_export.h"
Packit d7e8d0
Packit d7e8d0
namespace QGpgME {
Packit d7e8d0
class CryptoConfig;
Packit d7e8d0
class KeyListJob;
Packit d7e8d0
class ListAllKeysJob;
Packit d7e8d0
class KeyGenerationJob;
Packit d7e8d0
class ImportJob;
Packit d7e8d0
class ImportFromKeyserverJob;
Packit d7e8d0
class ExportJob;
Packit d7e8d0
class DownloadJob;
Packit d7e8d0
class DeleteJob;
Packit d7e8d0
class EncryptJob;
Packit d7e8d0
class DecryptJob;
Packit d7e8d0
class SignJob;
Packit d7e8d0
class SignKeyJob;
Packit d7e8d0
class VerifyDetachedJob;
Packit d7e8d0
class VerifyOpaqueJob;
Packit d7e8d0
class SignEncryptJob;
Packit d7e8d0
class DecryptVerifyJob;
Packit d7e8d0
class RefreshKeysJob;
Packit d7e8d0
class ChangeExpiryJob;
Packit d7e8d0
class ChangeOwnerTrustJob;
Packit d7e8d0
class ChangePasswdJob;
Packit d7e8d0
class AddUserIDJob;
Packit d7e8d0
class SpecialJob;
Packit d7e8d0
class KeyForMailboxJob;
Packit d7e8d0
class WKSPublishJob;
Packit d7e8d0
class TofuPolicyJob;
Packit d7e8d0
class QuickJob;
Packit d7e8d0
Packit d7e8d0
/** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors.
Packit d7e8d0
 *
Packit d7e8d0
 * Use the proctocol class to obtain an instance of a job. Jobs
Packit d7e8d0
 * provide async API for GnuPG that can be connected to signals / slots.
Packit d7e8d0
 *
Packit d7e8d0
 * A job is usually started with start() and emits a result signal.
Packit d7e8d0
 * The parameters of the result signal depend on the job but the last
Packit d7e8d0
 * two are always a QString for the auditlog and an GpgME::Error for
Packit d7e8d0
 * an eventual error.
Packit d7e8d0
 *
Packit d7e8d0
 * In case async API is used and the result signal is emitted a
Packit d7e8d0
 * job schedules its own deletion.
Packit d7e8d0
 *
Packit d7e8d0
 * Most jobs also provide a synchronous call exec in which case
Packit d7e8d0
 * you have to explicitly delete the job if you don't need it anymore.
Packit d7e8d0
 *
Packit d7e8d0
 * \code
Packit d7e8d0
 * // Async example:
Packit d7e8d0
 * KeyListJob *job = openpgp()->keyListJob();
Packit d7e8d0
 * connect(job, &KeyListJob::result, job, [this, job](KeyListResult, std::vector<Key> keys, QString, Error)
Packit d7e8d0
 * {
Packit d7e8d0
 *    // keys and resuls can now be used.
Packit d7e8d0
 * });
Packit d7e8d0
 * \endcode
Packit d7e8d0
 *
Packit d7e8d0
 * \code
Packit d7e8d0
 * // Sync eaxmple:
Packit d7e8d0
 * KeyListJob *job = openpgp()->keyListJob(false, false, false);
Packit d7e8d0
 * std::vector<GpgME::Key> keys;
Packit d7e8d0
 * GpgME::KeyListResult result = job->exec(QStringList() <<
Packit d7e8d0
 *                                         QStringLiteral("alfa@example.net"),
Packit d7e8d0
 *                                         false, keys);
Packit d7e8d0
 * delete job;
Packit d7e8d0
 * \endcode
Packit d7e8d0
 */
Packit d7e8d0
class QGPGME_EXPORT Protocol
Packit d7e8d0
{
Packit d7e8d0
public:
Packit d7e8d0
    virtual ~Protocol() {}
Packit d7e8d0
Packit d7e8d0
    virtual QString name() const = 0;
Packit d7e8d0
Packit d7e8d0
    virtual QString displayName() const = 0;
Packit d7e8d0
Packit d7e8d0
    virtual KeyListJob           *keyListJob(bool remote = false, bool includeSigs = false, bool validate = false) const = 0;
Packit d7e8d0
    virtual ListAllKeysJob       *listAllKeysJob(bool includeSigs = false, bool validate = false) const = 0;
Packit d7e8d0
    virtual EncryptJob           *encryptJob(bool armor = false, bool textmode = false) const = 0;
Packit d7e8d0
    virtual DecryptJob           *decryptJob() const = 0;
Packit d7e8d0
    virtual SignJob              *signJob(bool armor = false, bool textMode = false) const = 0;
Packit d7e8d0
    virtual VerifyDetachedJob    *verifyDetachedJob(bool textmode = false) const = 0;
Packit d7e8d0
    virtual VerifyOpaqueJob      *verifyOpaqueJob(bool textmode = false) const = 0;
Packit d7e8d0
    virtual KeyGenerationJob     *keyGenerationJob() const = 0;
Packit d7e8d0
    virtual ImportJob            *importJob() const = 0;
Packit d7e8d0
    virtual ImportFromKeyserverJob *importFromKeyserverJob() const = 0;
Packit d7e8d0
    virtual ExportJob            *publicKeyExportJob(bool armor = false) const = 0;
Packit d7e8d0
    // @param charset the encoding of the passphrase in the exported file
Packit d7e8d0
    virtual ExportJob            *secretKeyExportJob(bool armor = false, const QString &charset = QString()) const = 0;
Packit d7e8d0
    virtual DownloadJob          *downloadJob(bool armor = false) const = 0;
Packit d7e8d0
    virtual DeleteJob            *deleteJob() const = 0;
Packit d7e8d0
    virtual SignEncryptJob       *signEncryptJob(bool armor = false, bool textMode = false) const = 0;
Packit d7e8d0
    virtual DecryptVerifyJob     *decryptVerifyJob(bool textmode = false) const = 0;
Packit d7e8d0
    virtual RefreshKeysJob       *refreshKeysJob() const = 0;
Packit d7e8d0
    virtual ChangeExpiryJob      *changeExpiryJob() const = 0;
Packit d7e8d0
    virtual SignKeyJob           *signKeyJob() const = 0;
Packit d7e8d0
    virtual ChangePasswdJob      *changePasswdJob() const = 0;
Packit d7e8d0
    virtual ChangeOwnerTrustJob  *changeOwnerTrustJob() const = 0;
Packit d7e8d0
    virtual AddUserIDJob         *addUserIDJob() const = 0;
Packit d7e8d0
    virtual SpecialJob           *specialJob(const char *type, const QMap<QString, QVariant> &args) const = 0;
Packit d7e8d0
Packit d7e8d0
    /** A key locate job.
Packit d7e8d0
     *
Packit d7e8d0
     * This tries to find a key in local
Packit d7e8d0
     * and remote sources, if the key was remote it is imported
Packit d7e8d0
     * by GnuPG. Same as KeyListJob but intended to be used
Packit d7e8d0
     * to locate keys automatically. This ends up calling --locate-keys.
Packit d7e8d0
     *
Packit d7e8d0
     * Only available for OpenPGP
Packit d7e8d0
     *
Packit d7e8d0
     * Results are validated. As if keyListJob was called
Packit d7e8d0
     * with both includeSigs and validate options.
Packit d7e8d0
     */
Packit d7e8d0
    virtual KeyListJob *locateKeysJob() const = 0;
Packit d7e8d0
    /** Find the best key to use for a mailbox. */
Packit d7e8d0
    virtual KeyForMailboxJob *keyForMailboxJob() const = 0;
Packit d7e8d0
Packit d7e8d0
    /** A Job for interacting with gnupg's wks tools. */
Packit d7e8d0
    virtual WKSPublishJob *wksPublishJob() const = 0;
Packit d7e8d0
Packit d7e8d0
    /** A Job to set tofu policy */
Packit d7e8d0
    virtual TofuPolicyJob *tofuPolicyJob() const = 0;
Packit d7e8d0
Packit d7e8d0
    /** A Job for the quick commands */
Packit d7e8d0
    virtual QuickJob *quickJob() const = 0;
Packit d7e8d0
};
Packit d7e8d0
Packit d7e8d0
/** Obtain a reference to the OpenPGP Protocol.
Packit d7e8d0
 *
Packit d7e8d0
 * The reference is to a static object.
Packit d7e8d0
 * @returns Reference to the OpenPGP Protocol.
Packit d7e8d0
 */
Packit d7e8d0
QGPGME_EXPORT Protocol *openpgp();
Packit d7e8d0
Packit d7e8d0
/** Obtain a reference to the smime Protocol.
Packit d7e8d0
 *
Packit d7e8d0
 * The reference is to a static object.
Packit d7e8d0
 * @returns Reference to the smime Protocol.
Packit d7e8d0
 */
Packit d7e8d0
QGPGME_EXPORT Protocol *smime();
Packit d7e8d0
Packit d7e8d0
/** Obtain a reference to a cryptoConfig object.
Packit d7e8d0
 *
Packit d7e8d0
 * The reference is to a static object.
Packit d7e8d0
 * @returns reference to cryptoConfig object.
Packit d7e8d0
 */
Packit d7e8d0
QGPGME_EXPORT CryptoConfig *cryptoConfig();
Packit d7e8d0
Packit d7e8d0
}
Packit d7e8d0
#endif