|
Packit |
d7e8d0 |
/*
|
|
Packit |
d7e8d0 |
qgpgmenewcryptoconfig.h
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
This file is part of qgpgme, the Qt API binding for gpgme
|
|
Packit |
d7e8d0 |
Copyright (c) 2010 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 QGPGME_QGPGMENEWCRYPTOCONFIG_H
|
|
Packit |
d7e8d0 |
#define QGPGME_QGPGMENEWCRYPTOCONFIG_H
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include "qgpgme_export.h"
|
|
Packit |
d7e8d0 |
#include "cryptoconfig.h"
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <QHash>
|
|
Packit |
d7e8d0 |
#include <QStringList>
|
|
Packit |
d7e8d0 |
#include <QVariant>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#ifdef BUILDING_QGPGME
|
|
Packit |
d7e8d0 |
# include "configuration.h"
|
|
Packit |
d7e8d0 |
#else
|
|
Packit |
d7e8d0 |
# include <gpgme++/configuration.h>
|
|
Packit |
d7e8d0 |
#endif
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <vector>
|
|
Packit |
d7e8d0 |
#include <utility>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
class QGpgMENewCryptoConfig;
|
|
Packit |
d7e8d0 |
class QGpgMENewCryptoConfigComponent;
|
|
Packit |
d7e8d0 |
class QGpgMENewCryptoConfigGroup;
|
|
Packit |
d7e8d0 |
class QGpgMENewCryptoConfigEntry;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
class QGpgMENewCryptoConfigEntry : public QGpgME::CryptoConfigEntry
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
public:
|
|
Packit |
d7e8d0 |
QGpgMENewCryptoConfigEntry(const std::shared_ptr<QGpgMENewCryptoConfigGroup> &group, const GpgME::Configuration::Option &option);
|
|
Packit |
d7e8d0 |
~QGpgMENewCryptoConfigEntry();
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
QString name() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QString description() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QString path() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
bool isOptional() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
bool isReadOnly() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
bool isList() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
bool isRuntime() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
Level level() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
ArgType argType() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
bool isSet() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
bool boolValue() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QString stringValue() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
int intValue() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
unsigned int uintValue() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QUrl urlValue() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
unsigned int numberOfTimesSet() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
std::vector<int> intValueList() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
std::vector<unsigned int> uintValueList() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QList<QUrl> urlValueList() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void resetToDefault() Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void setBoolValue(bool) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void setStringValue(const QString &) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void setIntValue(int) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void setUIntValue(unsigned int) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void setURLValue(const QUrl &) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void setNumberOfTimesSet(unsigned int) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void setIntValueList(const std::vector<int> &) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void setUIntValueList(const std::vector<unsigned int> &) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void setURLValueList(const QList<QUrl> &) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
bool isDirty() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
QStringList stringValueList() const;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#if 0
|
|
Packit |
d7e8d0 |
void setDirty(bool b);
|
|
Packit |
d7e8d0 |
QString outputString() const;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
protected:
|
|
Packit |
d7e8d0 |
bool isStringType() const;
|
|
Packit |
d7e8d0 |
QVariant stringToValue(const QString &value, bool unescape) const;
|
|
Packit |
d7e8d0 |
QString toString(bool escape) const;
|
|
Packit |
d7e8d0 |
#endif
|
|
Packit |
d7e8d0 |
private:
|
|
Packit |
d7e8d0 |
std::weak_ptr<QGpgMENewCryptoConfigGroup> m_group;
|
|
Packit |
d7e8d0 |
GpgME::Configuration::Option m_option;
|
|
Packit |
d7e8d0 |
};
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
class QGpgMENewCryptoConfigGroup : public QGpgME::CryptoConfigGroup
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
public:
|
|
Packit |
d7e8d0 |
QGpgMENewCryptoConfigGroup(const std::shared_ptr<QGpgMENewCryptoConfigComponent> &parent, const GpgME::Configuration::Option &option);
|
|
Packit |
d7e8d0 |
~QGpgMENewCryptoConfigGroup();
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
QString name() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QString iconName() const Q_DECL_OVERRIDE
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return QString();
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
QString description() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QString path() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QGpgME::CryptoConfigEntry::Level level() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QStringList entryList() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QGpgMENewCryptoConfigEntry *entry(const QString &name) const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
private:
|
|
Packit |
d7e8d0 |
friend class QGpgMENewCryptoConfigComponent; // it adds the entries
|
|
Packit |
d7e8d0 |
std::weak_ptr<QGpgMENewCryptoConfigComponent> m_component;
|
|
Packit |
d7e8d0 |
GpgME::Configuration::Option m_option;
|
|
Packit |
d7e8d0 |
QStringList m_entryNames;
|
|
Packit |
d7e8d0 |
QHash< QString, std::shared_ptr<QGpgMENewCryptoConfigEntry> > m_entriesByName;
|
|
Packit |
d7e8d0 |
};
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/// For docu, see kleo/cryptoconfig.h
|
|
Packit |
d7e8d0 |
class QGpgMENewCryptoConfigComponent : public QGpgME::CryptoConfigComponent, public std::enable_shared_from_this<QGpgMENewCryptoConfigComponent>
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
public:
|
|
Packit |
d7e8d0 |
QGpgMENewCryptoConfigComponent();
|
|
Packit |
d7e8d0 |
~QGpgMENewCryptoConfigComponent();
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
void setComponent(const GpgME::Configuration::Component &component);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
QString name() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QString iconName() const Q_DECL_OVERRIDE
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return name();
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
QString description() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QStringList groupList() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
QGpgMENewCryptoConfigGroup *group(const QString &name) const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
void sync(bool runtime);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
private:
|
|
Packit |
d7e8d0 |
GpgME::Configuration::Component m_component;
|
|
Packit |
d7e8d0 |
QHash< QString, std::shared_ptr<QGpgMENewCryptoConfigGroup> > m_groupsByName;
|
|
Packit |
d7e8d0 |
};
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/**
|
|
Packit |
d7e8d0 |
* CryptoConfig implementation around the gpgconf command-line tool
|
|
Packit |
d7e8d0 |
* For method docu, see kleo/cryptoconfig.h
|
|
Packit |
d7e8d0 |
*/
|
|
Packit |
d7e8d0 |
class QGPGME_EXPORT QGpgMENewCryptoConfig : public QGpgME::CryptoConfig
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
public:
|
|
Packit |
d7e8d0 |
/**
|
|
Packit |
d7e8d0 |
* Constructor
|
|
Packit |
d7e8d0 |
*/
|
|
Packit |
d7e8d0 |
QGpgMENewCryptoConfig();
|
|
Packit |
d7e8d0 |
~QGpgMENewCryptoConfig();
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
QStringList componentList() const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
QGpgMENewCryptoConfigComponent *component(const QString &name) const Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
void clear() Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
void sync(bool runtime) Q_DECL_OVERRIDE;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
private:
|
|
Packit |
d7e8d0 |
/// @param showErrors if true, a messagebox will be shown if e.g. gpgconf wasn't found
|
|
Packit |
d7e8d0 |
void reloadConfiguration(bool showErrors);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
private:
|
|
Packit |
d7e8d0 |
QHash< QString, std::shared_ptr<QGpgMENewCryptoConfigComponent> > m_componentsByName;
|
|
Packit |
d7e8d0 |
bool m_parsed;
|
|
Packit |
d7e8d0 |
};
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#endif /* QGPGME_QGPGMENEWCRYPTOCONFIG_H */
|