|
Packit |
d7e8d0 |
/*
|
|
Packit |
d7e8d0 |
dn.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 |
#ifndef QGPGME_DN_H
|
|
Packit |
d7e8d0 |
#define QGPGME_DN_H
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include "qgpgme_export.h"
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <QString>
|
|
Packit |
d7e8d0 |
#include <QStringList>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <QVector>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
namespace QGpgME
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/**
|
|
Packit |
d7e8d0 |
@short DN parser and reorderer
|
|
Packit |
d7e8d0 |
*/
|
|
Packit |
d7e8d0 |
class QGPGME_EXPORT DN
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
public:
|
|
Packit |
d7e8d0 |
class Attribute;
|
|
Packit |
d7e8d0 |
typedef QVector<Attribute> AttributeList;
|
|
Packit |
d7e8d0 |
typedef AttributeList::const_iterator const_iterator;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
DN();
|
|
Packit |
d7e8d0 |
explicit DN(const QString &dn;;
|
|
Packit |
d7e8d0 |
explicit DN(const char *utf8DN);
|
|
Packit |
d7e8d0 |
DN(const DN &other);
|
|
Packit |
d7e8d0 |
~DN();
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
const DN &operator=(const DN &other);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/** @return the value in rfc-2253-escaped form */
|
|
Packit |
d7e8d0 |
static QString escape(const QString &value);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/** @return the DN in a reordered form, according to the settings in
|
|
Packit |
d7e8d0 |
the [DN] group of the application's config file */
|
|
Packit |
d7e8d0 |
QString prettyDN() const;
|
|
Packit |
d7e8d0 |
/** @return the DN in the original form */
|
|
Packit |
d7e8d0 |
QString dn() const;
|
|
Packit |
d7e8d0 |
/**
|
|
Packit |
d7e8d0 |
\overload
|
|
Packit |
d7e8d0 |
Uses \a sep as separator (default: ,)
|
|
Packit |
d7e8d0 |
*/
|
|
Packit |
d7e8d0 |
QString dn(const QString &sep) const;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
QString operator[](const QString &attr) const;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
void append(const Attribute &attr);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
const_iterator begin() const;
|
|
Packit |
d7e8d0 |
const_iterator end() const;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/** Set the order in which prettyDN will reorder the Attirbutes. */
|
|
Packit |
d7e8d0 |
void setAttributeOrder(const QStringList &order) const;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/** Get the used attribute order. */
|
|
Packit |
d7e8d0 |
const QStringList & attributeOrder() const;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
private:
|
|
Packit |
d7e8d0 |
void detach();
|
|
Packit |
d7e8d0 |
private:
|
|
Packit |
d7e8d0 |
class Private;
|
|
Packit |
d7e8d0 |
Private *d;
|
|
Packit |
d7e8d0 |
};
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
class QGPGME_EXPORT DN::Attribute
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
public:
|
|
Packit |
d7e8d0 |
typedef DN::AttributeList List;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
explicit Attribute(const QString &name = QString(), const QString &value = QString())
|
|
Packit |
d7e8d0 |
: mName(name.toUpper()), mValue(value) {}
|
|
Packit |
d7e8d0 |
Attribute(const Attribute &other)
|
|
Packit |
d7e8d0 |
: mName(other.name()), mValue(other.value()) {}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
const Attribute &operator=(const Attribute &other)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
if (this != &other) {
|
|
Packit |
d7e8d0 |
mName = other.name();
|
|
Packit |
d7e8d0 |
mValue = other.value();
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
return *this;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
const QString &name() const
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return mName;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
const QString &value() const
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return mValue;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
void setValue(const QString &value)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
mValue = value;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
private:
|
|
Packit |
d7e8d0 |
QString mName;
|
|
Packit |
d7e8d0 |
QString mValue;
|
|
Packit |
d7e8d0 |
};
|
|
Packit |
d7e8d0 |
} // namespace QGpgME
|
|
Packit |
d7e8d0 |
#endif // QGPGME_DN_H
|