Blame lang/qt/src/hierarchicalkeylistjob.h

Packit Service 672cf4
/*
Packit Service 672cf4
    hierarchicalkeylistjob.h
Packit Service 672cf4
Packit Service 672cf4
    This file is part of qgpgme, the Qt API binding for gpgme
Packit Service 672cf4
    Copyright (c) 2004 Klarälvdalens Datakonsult AB
Packit Service 672cf4
    Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
Packit Service 672cf4
    Software engineering by Intevation GmbH
Packit Service 672cf4
Packit Service 672cf4
    QGpgME is free software; you can redistribute it and/or
Packit Service 672cf4
    modify it under the terms of the GNU General Public License as
Packit Service 672cf4
    published by the Free Software Foundation; either version 2 of the
Packit Service 672cf4
    License, or (at your option) any later version.
Packit Service 672cf4
Packit Service 672cf4
    QGpgME is distributed in the hope that it will be useful,
Packit Service 672cf4
    but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 672cf4
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 672cf4
    General Public License for more details.
Packit Service 672cf4
Packit Service 672cf4
    You should have received a copy of the GNU General Public License
Packit Service 672cf4
    along with this program; if not, write to the Free Software
Packit Service 672cf4
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit Service 672cf4
Packit Service 672cf4
    In addition, as a special exception, the copyright holders give
Packit Service 672cf4
    permission to link the code of this program with any edition of
Packit Service 672cf4
    the Qt library by Trolltech AS, Norway (or with modified versions
Packit Service 672cf4
    of Qt that use the same license as Qt), and distribute linked
Packit Service 672cf4
    combinations including the two.  You must obey the GNU General
Packit Service 672cf4
    Public License in all respects for all of the code used other than
Packit Service 672cf4
    Qt.  If you modify this file, you may extend this exception to
Packit Service 672cf4
    your version of the file, but you are not obligated to do so.  If
Packit Service 672cf4
    you do not wish to do so, delete this exception statement from
Packit Service 672cf4
    your version.
Packit Service 672cf4
*/
Packit Service 672cf4
Packit Service 672cf4
#ifndef __KLEO_HIERARCHICALKEYLISTJOB_H__
Packit Service 672cf4
#define __KLEO_HIERARCHICALKEYLISTJOB_H__
Packit Service 672cf4
Packit Service 672cf4
#include "qgpgme_export.h"
Packit Service 672cf4
#include "keylistjob.h"
Packit Service 672cf4
#include "cryptobackend.h"
Packit Service 672cf4
Packit Service 672cf4
#ifdef BUILDING_QGPGME
Packit Service 672cf4
# include "keylistresult.h"
Packit Service 672cf4
#else
Packit Service 672cf4
#include <gpgme++/keylistresult.h>
Packit Service 672cf4
#endif
Packit Service 672cf4
Packit Service 672cf4
#include <QPointer>
Packit Service 672cf4
Packit Service 672cf4
#include <set>
Packit Service 672cf4
Packit Service 672cf4
namespace GpgME
Packit Service 672cf4
{
Packit Service 672cf4
class Error;
Packit Service 672cf4
class Key;
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
namespace QGpgME
Packit Service 672cf4
{
Packit Service 672cf4
class KeyListJob;
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
namespace QGpgME
Packit Service 672cf4
{
Packit Service 672cf4
Packit Service 672cf4
/**
Packit Service 672cf4
   @short A convenience job that additionally fetches all available issuers.
Packit Service 672cf4
Packit Service 672cf4
   To use a HierarchicalKeyListJob, pass it a CryptoBackend
Packit Service 672cf4
   implementation, connect the progress() and result() signals to
Packit Service 672cf4
   suitable slots and then start the keylisting with a call to
Packit Service 672cf4
   start(). This call might fail, in which case the
Packit Service 672cf4
   HierarchicalKeyListJob instance will have scheduled it's own
Packit Service 672cf4
   destruction with a call to QObject::deleteLater().
Packit Service 672cf4
Packit Service 672cf4
   After result() is emitted, the HierarchicalKeyListJob will
Packit Service 672cf4
   schedule its own destruction by calling QObject::deleteLater().
Packit Service 672cf4
*/
Packit Service 672cf4
class QGPGME_EXPORT HierarchicalKeyListJob : public KeyListJob
Packit Service 672cf4
{
Packit Service 672cf4
    Q_OBJECT
Packit Service 672cf4
public:
Packit Service 672cf4
    explicit HierarchicalKeyListJob(const Protocol *protocol,
Packit Service 672cf4
                                    bool remote = false, bool includeSigs = false,
Packit Service 672cf4
                                    bool validating = false);
Packit Service 672cf4
    ~HierarchicalKeyListJob();
Packit Service 672cf4
Packit Service 672cf4
    /**
Packit Service 672cf4
       Starts the keylist operation. \a patterns is a list of patterns
Packit Service 672cf4
       used to restrict the list of keys returned. Empty patterns are
Packit Service 672cf4
       ignored. \a patterns must not be empty or contain only empty
Packit Service 672cf4
       patterns; use the normal KeyListJob for a full listing.
Packit Service 672cf4
Packit Service 672cf4
       The \a secretOnly parameter is ignored by
Packit Service 672cf4
       HierarchicalKeyListJob and must be set to false.
Packit Service 672cf4
    */
Packit Service 672cf4
    GpgME::Error start(const QStringList &patterns, bool secretOnly = false) Q_DECL_OVERRIDE;
Packit Service 672cf4
Packit Service 672cf4
    GpgME::KeyListResult exec(const QStringList &patterns, bool secretOnly,
Packit Service 672cf4
                              std::vector<GpgME::Key> &keys) Q_DECL_OVERRIDE;
Packit Service 672cf4
Packit Service 672cf4
private Q_SLOTS:
Packit Service 672cf4
    void slotResult(const GpgME::KeyListResult &);
Packit Service 672cf4
    void slotNextKey(const GpgME::Key &key);
Packit Service 672cf4
    /* from Job */
Packit Service 672cf4
    void slotCancel() Q_DECL_OVERRIDE;
Packit Service 672cf4
Packit Service 672cf4
private:
Packit Service 672cf4
    GpgME::Error startAJob();
Packit Service 672cf4
Packit Service 672cf4
private:
Packit Service 672cf4
    const Protocol *const mProtocol;
Packit Service 672cf4
    const bool mRemote;
Packit Service 672cf4
    const bool mIncludeSigs;
Packit Service 672cf4
    const bool mValidating;
Packit Service 672cf4
    bool mTruncated;
Packit Service 672cf4
    std::set<QString> mSentSet; // keys already sent (prevent duplicates even if the backend should return them)
Packit Service 672cf4
    std::set<QString> mScheduledSet; // keys already scheduled (by starting a job for them)
Packit Service 672cf4
    std::set<QString> mNextSet; // keys to schedule for the next iteraton
Packit Service 672cf4
    GpgME::KeyListResult mIntermediateResult;
Packit Service 672cf4
    QPointer<KeyListJob> mJob;
Packit Service 672cf4
};
Packit Service 672cf4
Packit Service 672cf4
}
Packit Service 672cf4
Packit Service 672cf4
#endif // __KLEO_HIERARCHICALKEYLISTJOB_H__