LCOV - code coverage report
Current view: top level - lang/qt/src - qgpgmenewcryptoconfig.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 4 0.0 %
Date: 2016-09-12 13:07:23 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*
       2             :     qgpgmenewcryptoconfig.h
       3             : 
       4             :     This file is part of qgpgme, the Qt API binding for gpgme
       5             :     Copyright (c) 2010 Klarälvdalens Datakonsult AB
       6             :     Copyright (c) 2016 Intevation GmbH
       7             : 
       8             :     QGpgME is free software; you can redistribute it and/or
       9             :     modify it under the terms of the GNU General Public License as
      10             :     published by the Free Software Foundation; either version 2 of the
      11             :     License, or (at your option) any later version.
      12             : 
      13             :     QGpgME is distributed in the hope that it will be useful,
      14             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16             :     General Public License for more details.
      17             : 
      18             :     You should have received a copy of the GNU General Public License
      19             :     along with this program; if not, write to the Free Software
      20             :     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
      21             : 
      22             :     In addition, as a special exception, the copyright holders give
      23             :     permission to link the code of this program with any edition of
      24             :     the Qt library by Trolltech AS, Norway (or with modified versions
      25             :     of Qt that use the same license as Qt), and distribute linked
      26             :     combinations including the two.  You must obey the GNU General
      27             :     Public License in all respects for all of the code used other than
      28             :     Qt.  If you modify this file, you may extend this exception to
      29             :     your version of the file, but you are not obligated to do so.  If
      30             :     you do not wish to do so, delete this exception statement from
      31             :     your version.
      32             : */
      33             : 
      34             : #ifndef QGPGME_QGPGMENEWCRYPTOCONFIG_H
      35             : #define QGPGME_QGPGMENEWCRYPTOCONFIG_H
      36             : 
      37             : #include "qgpgme_export.h"
      38             : #include "cryptoconfig.h"
      39             : 
      40             : #include <QHash>
      41             : #include <QStringList>
      42             : #include <QVariant>
      43             : 
      44             : #ifdef BUILDING_QGPGME
      45             : # include "configuration.h"
      46             : #else
      47             : # include <gpgme++/configuration.h>
      48             : #endif
      49             : 
      50             : 
      51             : #include <vector>
      52             : #include <utility>
      53             : 
      54             : class QGpgMENewCryptoConfig;
      55             : class QGpgMENewCryptoConfigComponent;
      56             : class QGpgMENewCryptoConfigGroup;
      57             : class QGpgMENewCryptoConfigEntry;
      58             : 
      59             : class QGpgMENewCryptoConfigEntry : public QGpgME::CryptoConfigEntry
      60             : {
      61             : public:
      62             :     QGpgMENewCryptoConfigEntry(const std::shared_ptr<QGpgMENewCryptoConfigGroup> &group, const GpgME::Configuration::Option &option);
      63             :     ~QGpgMENewCryptoConfigEntry();
      64             : 
      65             :     QString name() const Q_DECL_OVERRIDE;
      66             :     QString description() const Q_DECL_OVERRIDE;
      67             :     QString path() const Q_DECL_OVERRIDE;
      68             :     bool isOptional() const Q_DECL_OVERRIDE;
      69             :     bool isReadOnly() const Q_DECL_OVERRIDE;
      70             :     bool isList() const Q_DECL_OVERRIDE;
      71             :     bool isRuntime() const Q_DECL_OVERRIDE;
      72             :     Level level() const Q_DECL_OVERRIDE;
      73             :     ArgType argType() const Q_DECL_OVERRIDE;
      74             :     bool isSet() const Q_DECL_OVERRIDE;
      75             :     bool boolValue() const Q_DECL_OVERRIDE;
      76             :     QString stringValue() const Q_DECL_OVERRIDE;
      77             :     int intValue() const Q_DECL_OVERRIDE;
      78             :     unsigned int uintValue() const Q_DECL_OVERRIDE;
      79             :     QUrl urlValue() const Q_DECL_OVERRIDE;
      80             :     unsigned int numberOfTimesSet() const Q_DECL_OVERRIDE;
      81             :     std::vector<int> intValueList() const Q_DECL_OVERRIDE;
      82             :     std::vector<unsigned int> uintValueList() const Q_DECL_OVERRIDE;
      83             :     QList<QUrl> urlValueList() const Q_DECL_OVERRIDE;
      84             :     void resetToDefault() Q_DECL_OVERRIDE;
      85             :     void setBoolValue(bool) Q_DECL_OVERRIDE;
      86             :     void setStringValue(const QString &) Q_DECL_OVERRIDE;
      87             :     void setIntValue(int) Q_DECL_OVERRIDE;
      88             :     void setUIntValue(unsigned int) Q_DECL_OVERRIDE;
      89             :     void setURLValue(const QUrl &) Q_DECL_OVERRIDE;
      90             :     void setNumberOfTimesSet(unsigned int) Q_DECL_OVERRIDE;
      91             :     void setIntValueList(const std::vector<int> &) Q_DECL_OVERRIDE;
      92             :     void setUIntValueList(const std::vector<unsigned int> &) Q_DECL_OVERRIDE;
      93             :     void setURLValueList(const QList<QUrl> &) Q_DECL_OVERRIDE;
      94             :     bool isDirty() const Q_DECL_OVERRIDE;
      95             : 
      96             : #if 0
      97             :     void setDirty(bool b);
      98             :     QString outputString() const;
      99             : 
     100             : protected:
     101             :     bool isStringType() const;
     102             :     QVariant stringToValue(const QString &value, bool unescape) const;
     103             :     QString toString(bool escape) const;
     104             : #endif
     105             : private:
     106             :     std::weak_ptr<QGpgMENewCryptoConfigGroup> m_group;
     107             :     GpgME::Configuration::Option m_option;
     108             : };
     109             : 
     110             : class QGpgMENewCryptoConfigGroup : public QGpgME::CryptoConfigGroup
     111             : {
     112             : public:
     113             :     QGpgMENewCryptoConfigGroup(const std::shared_ptr<QGpgMENewCryptoConfigComponent> &parent, const GpgME::Configuration::Option &option);
     114             :     ~QGpgMENewCryptoConfigGroup();
     115             : 
     116             :     QString name() const Q_DECL_OVERRIDE;
     117           0 :     QString iconName() const Q_DECL_OVERRIDE
     118             :     {
     119           0 :         return QString();
     120             :     }
     121             :     QString description() const Q_DECL_OVERRIDE;
     122             :     QString path() const Q_DECL_OVERRIDE;
     123             :     QGpgME::CryptoConfigEntry::Level level() const Q_DECL_OVERRIDE;
     124             :     QStringList entryList() const Q_DECL_OVERRIDE;
     125             :     QGpgMENewCryptoConfigEntry *entry(const QString &name) const Q_DECL_OVERRIDE;
     126             : 
     127             : private:
     128             :     friend class QGpgMENewCryptoConfigComponent; // it adds the entries
     129             :     std::weak_ptr<QGpgMENewCryptoConfigComponent> m_component;
     130             :     GpgME::Configuration::Option m_option;
     131             :     QStringList m_entryNames;
     132             :     QHash< QString, std::shared_ptr<QGpgMENewCryptoConfigEntry> > m_entriesByName;
     133             : };
     134             : 
     135             : /// For docu, see kleo/cryptoconfig.h
     136             : class QGpgMENewCryptoConfigComponent : public QGpgME::CryptoConfigComponent, public std::enable_shared_from_this<QGpgMENewCryptoConfigComponent>
     137             : {
     138             : public:
     139             :     QGpgMENewCryptoConfigComponent();
     140             :     ~QGpgMENewCryptoConfigComponent();
     141             : 
     142             :     void setComponent(const GpgME::Configuration::Component &component);
     143             : 
     144             :     QString name() const Q_DECL_OVERRIDE;
     145           0 :     QString iconName() const Q_DECL_OVERRIDE
     146             :     {
     147           0 :         return name();
     148             :     }
     149             :     QString description() const Q_DECL_OVERRIDE;
     150             :     QStringList groupList() const Q_DECL_OVERRIDE;
     151             :     QGpgMENewCryptoConfigGroup *group(const QString &name) const Q_DECL_OVERRIDE;
     152             : 
     153             :     void sync(bool runtime);
     154             : 
     155             : private:
     156             :     GpgME::Configuration::Component m_component;
     157             :     QHash< QString, std::shared_ptr<QGpgMENewCryptoConfigGroup> > m_groupsByName;
     158             : };
     159             : 
     160             : /**
     161             :  * CryptoConfig implementation around the gpgconf command-line tool
     162             :  * For method docu, see kleo/cryptoconfig.h
     163             :  */
     164             : class QGPGME_EXPORT QGpgMENewCryptoConfig : public QGpgME::CryptoConfig
     165             : {
     166             : public:
     167             :     /**
     168             :      * Constructor
     169             :      */
     170             :     QGpgMENewCryptoConfig();
     171             :     ~QGpgMENewCryptoConfig();
     172             : 
     173             :     QStringList componentList() const Q_DECL_OVERRIDE;
     174             : 
     175             :     QGpgMENewCryptoConfigComponent *component(const QString &name) const Q_DECL_OVERRIDE;
     176             : 
     177             :     void clear() Q_DECL_OVERRIDE;
     178             :     void sync(bool runtime) Q_DECL_OVERRIDE;
     179             : 
     180             : private:
     181             :     /// @param showErrors if true, a messagebox will be shown if e.g. gpgconf wasn't found
     182             :     void reloadConfiguration(bool showErrors);
     183             : 
     184             : private:
     185             :     QHash< QString, std::shared_ptr<QGpgMENewCryptoConfigComponent> > m_componentsByName;
     186             :     bool m_parsed;
     187             : };
     188             : 
     189             : #endif /* QGPGME_QGPGMENEWCRYPTOCONFIG_H */

Generated by: LCOV version 1.11