|
Packit Service |
672cf4 |
/*
|
|
Packit Service |
672cf4 |
global.h - global gpgme functions and enums
|
|
Packit Service |
672cf4 |
Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
|
|
Packit Service |
672cf4 |
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
Packit Service |
672cf4 |
Software engineering by Intevation GmbH
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
This file is part of GPGME++.
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GPGME++ is free software; you can redistribute it and/or
|
|
Packit Service |
672cf4 |
modify it under the terms of the GNU Library General Public
|
|
Packit Service |
672cf4 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
672cf4 |
version 2 of the License, or (at your option) any later version.
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GPGME++ 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
|
|
Packit Service |
672cf4 |
GNU Library General Public License for more details.
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
You should have received a copy of the GNU Library General Public License
|
|
Packit Service |
672cf4 |
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
Packit Service |
672cf4 |
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Packit Service |
672cf4 |
Boston, MA 02110-1301, USA.
|
|
Packit Service |
672cf4 |
*/
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
// -*- c++ -*-
|
|
Packit Service |
672cf4 |
#ifndef __GPGMEPP_GLOBAL_H__
|
|
Packit Service |
672cf4 |
#define __GPGMEPP_GLOBAL_H__
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
#include "gpgmefw.h"
|
|
Packit Service |
672cf4 |
#include "gpgmepp_export.h"
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
#include <iosfwd>
|
|
Packit Service |
672cf4 |
#include <cstring>
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
namespace GpgME
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
class Error;
|
|
Packit Service |
672cf4 |
class EngineInfo;
|
|
Packit Service |
672cf4 |
class Context;
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
struct _GIOChannel;
|
|
Packit Service |
672cf4 |
typedef struct _GIOChannel GIOChannel;
|
|
Packit Service |
672cf4 |
class QIODevice;
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
namespace GpgME
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT void initializeLibrary();
|
|
Packit Service |
672cf4 |
/*!
|
|
Packit Service |
672cf4 |
Initializes the library, returns Error::code() ==
|
|
Packit Service |
672cf4 |
GPG_ERR_USER_1 if underlying gpgme is too old.
|
|
Packit Service |
672cf4 |
*/
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT Error initializeLibrary(int);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
enum Protocol { OpenPGP, CMS, UnknownProtocol };
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
enum Engine { GpgEngine, GpgSMEngine, GpgConfEngine, UnknownEngine, AssuanEngine, G13Engine, SpawnEngine };
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
enum KeyListMode {
|
|
Packit Service |
672cf4 |
Local = 0x1,
|
|
Packit Service |
672cf4 |
Extern = 0x2,
|
|
Packit Service |
672cf4 |
Signatures = 0x4,
|
|
Packit Service |
672cf4 |
SignatureNotations = 0x8,
|
|
Packit Service |
672cf4 |
Validate = 0x10,
|
|
Packit Service |
672cf4 |
Ephemeral = 0x20,
|
|
Packit Service |
672cf4 |
WithTofu = 0x40
|
|
Packit Service |
672cf4 |
};
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
enum SignatureMode { NormalSignatureMode, Detached, Clearsigned };
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Protocol proto);
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Engine eng);
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, KeyListMode mode);
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, SignatureMode mode);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT Error setDefaultLocale(int category, const char *value);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT Context *wait(Error &e, bool hang = true);
|
|
Packit Service |
672cf4 |
typedef void (*IdleFunction)(void);
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT IdleFunction registerIdleFunction(IdleFunction idleFunction);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
typedef void (*IOCallback)(void *data, int fd);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT EngineInfo engineInfo(Protocol proto);
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT EngineInfo engineInfo(Engine engine);
|
|
Packit Service |
672cf4 |
/** Wrapper around gpgme_get_dirinfo. What can be:
|
|
Packit Service |
672cf4 |
homedir, sysconfdir, bindir, libexecdir, libdir,
|
|
Packit Service |
672cf4 |
datadir, localedir, agent-socket, agent-ssh-socket,
|
|
Packit Service |
672cf4 |
dirmngr-socket, uiserver-socket, gpgconf-name, gpg-name,
|
|
Packit Service |
672cf4 |
gpgsm-name, g13-name
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
This may be extended in the future.
|
|
Packit Service |
672cf4 |
*/
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT const char *dirInfo(const char *what);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT Error checkEngine(Protocol proto);
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT Error checkEngine(Engine engine);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT GIOChannel *getGIOChannel(int fd);
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT QIODevice *getQIODevice(int fd);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
enum Feature {
|
|
Packit Service |
672cf4 |
ValidatingKeylistModeFeature = 0x00000001,
|
|
Packit Service |
672cf4 |
CancelOperationFeature = 0x00000002,
|
|
Packit Service |
672cf4 |
WrongKeyUsageFeature = 0x00000004,
|
|
Packit Service |
672cf4 |
DefaultCertificateInclusionFeature = 0x00000008,
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
GetSetEngineInfoFeature = 0x00000010,
|
|
Packit Service |
672cf4 |
EngineInfoHomeDirFeature = 0x00000020,
|
|
Packit Service |
672cf4 |
NoEncryptToEncryptionFlagFeature = 0x00000040,
|
|
Packit Service |
672cf4 |
EphemeralKeylistModeFeature = 0x00000080,
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
SetDataFileNameFeeature = 0x00000100,
|
|
Packit Service |
672cf4 |
VerificationResultFileNameFeature = 0x00000200,
|
|
Packit Service |
672cf4 |
DecryptionResultFileNameFeature = 0x00000400,
|
|
Packit Service |
672cf4 |
DecryptionResultRecipientsFeature = 0x00000800,
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
AuditLogFeature = 0x00001000,
|
|
Packit Service |
672cf4 |
GpgConfEngineFeature = 0x00002000,
|
|
Packit Service |
672cf4 |
CancelOperationAsyncFeature = 0x00004000,
|
|
Packit Service |
672cf4 |
AssuanEngineFeature = 0x00008000,
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
ClearAddGetSignatureNotationsFeature = 0x00010000,
|
|
Packit Service |
672cf4 |
SignatureNotationsKeylistModeFeature = 0x00020000,
|
|
Packit Service |
672cf4 |
KeySignatureNotationsFeature = 0x00040000,
|
|
Packit Service |
672cf4 |
SignatureNotationsFlagsFeature = 0x00080000,
|
|
Packit Service |
672cf4 |
SignatureNotationsCriticalFlagFeature = 0x00100000,
|
|
Packit Service |
672cf4 |
SignatureNotationsHumanReadableFlagFeature = 0x00200000,
|
|
Packit Service |
672cf4 |
CardKeyFeature = 0x00400000,
|
|
Packit Service |
672cf4 |
ImportFromKeyserverFeature = 0x00800000,
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
KeyIsQualifiedFeature = 0x01000200,
|
|
Packit Service |
672cf4 |
SubkeyIsQualifiedFeature = 0x02000000,
|
|
Packit Service |
672cf4 |
SignaturePkaFieldsFeature = 0x04000000,
|
|
Packit Service |
672cf4 |
SignatureAlgorithmFieldsFeature = 0x08000000,
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
FdPointerFeature = 0x10000000,
|
|
Packit Service |
672cf4 |
G13VFSFeature = 0x20000000,
|
|
Packit Service |
672cf4 |
PasswdFeature = 0x40000000, // gpgme >= 1.3.0
|
|
Packit Service |
672cf4 |
// unusable (max value)
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
FeatureMaxValue = 0x80000000
|
|
Packit Service |
672cf4 |
};
|
|
Packit Service |
672cf4 |
enum Feature2 {
|
|
Packit Service |
672cf4 |
BinaryAndFineGrainedIdentify = 0x00000001, // gpgme >= 1.7.0
|
|
Packit Service |
672cf4 |
Feature2MaxValue = 0x80000000
|
|
Packit Service |
672cf4 |
};
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
// use hasFeature( unsigned long, unsigned long ) instead
|
|
Packit Service |
672cf4 |
GPGMEPP_DEPRECATED_EXPORT bool hasFeature(unsigned long feature);
|
|
Packit Service |
672cf4 |
GPGMEPP_EXPORT bool hasFeature(unsigned long feature, unsigned long feature2);
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
} // namespace GpgME
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
# ifndef GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION
|
|
Packit Service |
672cf4 |
# define GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION( Class ) \
|
|
Packit Service |
672cf4 |
namespace std { template <> inline void swap< GpgME::Class >( GpgME::Class & lhs, GpgME::Class & rhs ) { lhs.swap( rhs ); } }
|
|
Packit Service |
672cf4 |
# endif
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
# ifndef GPGMEPP_MAKE_SAFE_BOOL_OPERATOR
|
|
Packit Service |
672cf4 |
# define GPGMEPP_MAKE_SAFE_BOOL_OPERATOR( Cond ) \
|
|
Packit Service |
672cf4 |
private: \
|
|
Packit Service |
672cf4 |
struct __safe_bool_dummy__ { void nonnull() {} }; \
|
|
Packit Service |
672cf4 |
typedef void ( __safe_bool_dummy__::*unspecified_bool_type )(); \
|
|
Packit Service |
672cf4 |
public: \
|
|
Packit Service |
6c01f9 |
operator unspecified_bool_type() const { return ( Cond ) ? &__safe_bool_dummy__::nonnull : 0 ; }
|
|
Packit Service |
672cf4 |
# endif
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
inline int _gpgmepp_strcmp(const char *s1, const char *s2)
|
|
Packit Service |
672cf4 |
{
|
|
Packit Service |
672cf4 |
return s1 ? s2 ? std::strcmp(s1, s2) : 1 : s2 ? -1 : 0;
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
#define _GPGMEPP_MAKE_STRCMP( Name, expr, cmp ) \
|
|
Packit Service |
672cf4 |
template <template <typename U> class Op> \
|
|
Packit Service |
672cf4 |
struct Name { \
|
|
Packit Service |
672cf4 |
typedef bool result_type; \
|
|
Packit Service |
672cf4 |
\
|
|
Packit Service |
672cf4 |
bool operator()( const char * lhs, const char * rhs ) const { \
|
|
Packit Service |
672cf4 |
return Op<int>()( cmp, 0 ); \
|
|
Packit Service |
672cf4 |
} \
|
|
Packit Service |
672cf4 |
\
|
|
Packit Service |
672cf4 |
bool operator()( const std::string & lhs, const std::string & rhs ) const { \
|
|
Packit Service |
672cf4 |
return operator()( lhs.c_str(), rhs.c_str() ); \
|
|
Packit Service |
672cf4 |
} \
|
|
Packit Service |
672cf4 |
bool operator()( const char * lhs, const std::string & rhs ) const { \
|
|
Packit Service |
672cf4 |
return operator()( lhs, rhs.c_str() ); \
|
|
Packit Service |
672cf4 |
} \
|
|
Packit Service |
672cf4 |
bool operator()( const std::string & lhs, const char * rhs ) const { \
|
|
Packit Service |
672cf4 |
return operator()( lhs.c_str(), rhs ); \
|
|
Packit Service |
672cf4 |
} \
|
|
Packit Service |
672cf4 |
\
|
|
Packit Service |
672cf4 |
template <typename T> \
|
|
Packit Service |
672cf4 |
bool operator()( const T & lhs, const T & rhs ) const { \
|
|
Packit Service |
672cf4 |
return operator()( (lhs expr), (rhs expr) ); \
|
|
Packit Service |
672cf4 |
} \
|
|
Packit Service |
672cf4 |
template <typename T> \
|
|
Packit Service |
672cf4 |
bool operator()( const T & lhs, const char * rhs ) const { \
|
|
Packit Service |
672cf4 |
return operator()( (lhs expr), rhs ); \
|
|
Packit Service |
672cf4 |
} \
|
|
Packit Service |
672cf4 |
template <typename T> \
|
|
Packit Service |
672cf4 |
bool operator()( const char * lhs, const T & rhs ) const { \
|
|
Packit Service |
672cf4 |
return operator()( lhs, (rhs expr) ); \
|
|
Packit Service |
672cf4 |
} \
|
|
Packit Service |
672cf4 |
template <typename T> \
|
|
Packit Service |
672cf4 |
bool operator()( const T & lhs, const std::string & rhs ) const { \
|
|
Packit Service |
672cf4 |
return operator()( (lhs expr), rhs ); \
|
|
Packit Service |
672cf4 |
} \
|
|
Packit Service |
672cf4 |
template <typename T> \
|
|
Packit Service |
672cf4 |
bool operator()( const std::string & lhs, const T & rhs ) const { \
|
|
Packit Service |
672cf4 |
return operator()( lhs, (rhs expr) ); \
|
|
Packit Service |
672cf4 |
} \
|
|
Packit Service |
672cf4 |
}
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
#define GPGMEPP_MAKE_STRCMP( Name, expr ) \
|
|
Packit Service |
672cf4 |
_GPGMEPP_MAKE_STRCMP( Name, expr, _gpgmepp_strcmp( lhs, rhs ) )
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
|
|
Packit Service |
672cf4 |
#endif // __GPGMEPP_GLOBAL_H__
|