~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to libkleo/backends/qgpgme/qgpgmenewcryptoconfig.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

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