Blame lang/qt/src/hierarchicalkeylistjob.h

Packit d7e8d0
/*
Packit d7e8d0
    hierarchicalkeylistjob.h
Packit d7e8d0
Packit d7e8d0
    This file is part of qgpgme, the Qt API binding for gpgme
Packit d7e8d0
    Copyright (c) 2004 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
Packit d7e8d0
#ifndef __KLEO_HIERARCHICALKEYLISTJOB_H__
Packit d7e8d0
#define __KLEO_HIERARCHICALKEYLISTJOB_H__
Packit d7e8d0
Packit d7e8d0
#include "qgpgme_export.h"
Packit d7e8d0
#include "keylistjob.h"
Packit d7e8d0
#include "cryptobackend.h"
Packit d7e8d0
Packit d7e8d0
#ifdef BUILDING_QGPGME
Packit d7e8d0
# include "keylistresult.h"
Packit d7e8d0
#else
Packit d7e8d0
#include <gpgme++/keylistresult.h>
Packit d7e8d0
#endif
Packit d7e8d0
Packit d7e8d0
#include <QPointer>
Packit d7e8d0
Packit d7e8d0
#include <set>
Packit d7e8d0
Packit d7e8d0
namespace GpgME
Packit d7e8d0
{
Packit d7e8d0
class Error;
Packit d7e8d0
class Key;
Packit d7e8d0
}
Packit d7e8d0
Packit d7e8d0
namespace QGpgME
Packit d7e8d0
{
Packit d7e8d0
class KeyListJob;
Packit d7e8d0
}
Packit d7e8d0
Packit d7e8d0
namespace QGpgME
Packit d7e8d0
{
Packit d7e8d0
Packit d7e8d0
/**
Packit d7e8d0
   @short A convenience job that additionally fetches all available issuers.
Packit d7e8d0
Packit d7e8d0
   To use a HierarchicalKeyListJob, pass it a CryptoBackend
Packit d7e8d0
   implementation, connect the progress() and result() signals to
Packit d7e8d0
   suitable slots and then start the keylisting with a call to
Packit d7e8d0
   start(). This call might fail, in which case the
Packit d7e8d0
   HierarchicalKeyListJob instance will have scheduled it's own
Packit d7e8d0
   destruction with a call to QObject::deleteLater().
Packit d7e8d0
Packit d7e8d0
   After result() is emitted, the HierarchicalKeyListJob will
Packit d7e8d0
   schedule its own destruction by calling QObject::deleteLater().
Packit d7e8d0
*/
Packit d7e8d0
class QGPGME_EXPORT HierarchicalKeyListJob : public KeyListJob
Packit d7e8d0
{
Packit d7e8d0
    Q_OBJECT
Packit d7e8d0
public:
Packit d7e8d0
    explicit HierarchicalKeyListJob(const Protocol *protocol,
Packit d7e8d0
                                    bool remote = false, bool includeSigs = false,
Packit d7e8d0
                                    bool validating = false);
Packit d7e8d0
    ~HierarchicalKeyListJob();
Packit d7e8d0
Packit d7e8d0
    /**
Packit d7e8d0
       Starts the keylist operation. \a patterns is a list of patterns
Packit d7e8d0
       used to restrict the list of keys returned. Empty patterns are
Packit d7e8d0
       ignored. \a patterns must not be empty or contain only empty
Packit d7e8d0
       patterns; use the normal KeyListJob for a full listing.
Packit d7e8d0
Packit d7e8d0
       The \a secretOnly parameter is ignored by
Packit d7e8d0
       HierarchicalKeyListJob and must be set to false.
Packit d7e8d0
    */
Packit d7e8d0
    GpgME::Error start(const QStringList &patterns, bool secretOnly = false) Q_DECL_OVERRIDE;
Packit d7e8d0
Packit d7e8d0
    GpgME::KeyListResult exec(const QStringList &patterns, bool secretOnly,
Packit d7e8d0
                              std::vector<GpgME::Key> &keys) Q_DECL_OVERRIDE;
Packit d7e8d0
Packit d7e8d0
private Q_SLOTS:
Packit d7e8d0
    void slotResult(const GpgME::KeyListResult &);
Packit d7e8d0
    void slotNextKey(const GpgME::Key &key);
Packit d7e8d0
    /* from Job */
Packit d7e8d0
    void slotCancel() Q_DECL_OVERRIDE;
Packit d7e8d0
Packit d7e8d0
private:
Packit d7e8d0
    GpgME::Error startAJob();
Packit d7e8d0
Packit d7e8d0
private:
Packit d7e8d0
    const Protocol *const mProtocol;
Packit d7e8d0
    const bool mRemote;
Packit d7e8d0
    const bool mIncludeSigs;
Packit d7e8d0
    const bool mValidating;
Packit d7e8d0
    bool mTruncated;
Packit d7e8d0
    std::set<QString> mSentSet; // keys already sent (prevent duplicates even if the backend should return them)
Packit d7e8d0
    std::set<QString> mScheduledSet; // keys already scheduled (by starting a job for them)
Packit d7e8d0
    std::set<QString> mNextSet; // keys to schedule for the next iteraton
Packit d7e8d0
    GpgME::KeyListResult mIntermediateResult;
Packit d7e8d0
    QPointer<KeyListJob> mJob;
Packit d7e8d0
};
Packit d7e8d0
Packit d7e8d0
}
Packit d7e8d0
Packit d7e8d0
#endif // __KLEO_HIERARCHICALKEYLISTJOB_H__