1/*
2 global.h - global gpgme functions and enums
3 Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
4
5 This file is part of GPGME++.
6
7 GPGME++ is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 GPGME++ 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
15 GNU Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with GPGME++; see the file COPYING.LIB. If not, write to the
19 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23// -*- c++ -*-
24#ifndef __GPGMEPP_GLOBAL_H__
25#define __GPGMEPP_GLOBAL_H__
26
27#include <gpgme++/gpgmefw.h>
28#include <gpgme++/gpgme++_export.h>
29
30#include <iosfwd>
31
32#include <QByteArray>
33
34namespace GpgME {
35 class Error;
36 class EngineInfo;
37 class Context;
38}
39
40struct _GIOChannel;
41typedef struct _GIOChannel GIOChannel;
42class QIODevice;
43
44namespace GpgME {
45
46 GPGMEPP_EXPORT void initializeLibrary();
47 /*!
48 Initializes the library, returns Error::code() ==
49 GPG_ERR_USER_1 if underlying gpgme is too old.
50 */
51 GPGMEPP_EXPORT Error initializeLibrary(int);
52
53 enum Protocol { OpenPGP, CMS, UnknownProtocol };
54
55 enum Engine { GpgEngine, GpgSMEngine, GpgConfEngine, UnknownEngine, AssuanEngine, G13Engine };
56
57 enum KeyListMode {
58 Local = 0x1,
59 Extern = 0x2,
60 Signatures = 0x4,
61 SignatureNotations = 0x8,
62 Validate = 0x10,
63 Ephemeral = 0x20
64 };
65
66 enum SignatureMode { NormalSignatureMode, Detached, Clearsigned };
67
68 GPGMEPP_EXPORT std::ostream & operator<<( std::ostream & os, Protocol proto );
69 GPGMEPP_EXPORT std::ostream & operator<<( std::ostream & os, Engine eng );
70 GPGMEPP_EXPORT std::ostream & operator<<( std::ostream & os, KeyListMode mode );
71 GPGMEPP_EXPORT std::ostream & operator<<( std::ostream & os, SignatureMode mode );
72
73
74 GPGMEPP_EXPORT Error setDefaultLocale( int category, const char * value );
75
76 GPGMEPP_EXPORT Context * wait( Error & e, bool hang=true );
77 typedef void (*IdleFunction)(void);
78 GPGMEPP_EXPORT IdleFunction registerIdleFunction( IdleFunction idleFunction );
79
80 typedef void (*IOCallback)( void * data, int fd );
81
82 GPGMEPP_EXPORT EngineInfo engineInfo( Protocol proto );
83 GPGMEPP_EXPORT EngineInfo engineInfo( Engine engine );
84
85 GPGMEPP_EXPORT Error checkEngine( Protocol proto );
86 GPGMEPP_EXPORT Error checkEngine( Engine engine );
87
88 GPGMEPP_EXPORT GIOChannel * getGIOChannel( int fd );
89 GPGMEPP_EXPORT QIODevice * getQIODevice( int fd );
90
91 enum Feature {
92 ValidatingKeylistModeFeature = 0x00000001,
93 CancelOperationFeature = 0x00000002,
94 WrongKeyUsageFeature = 0x00000004,
95 DefaultCertificateInclusionFeature = 0x00000008,
96
97 GetSetEngineInfoFeature = 0x00000010,
98 EngineInfoHomeDirFeature = 0x00000020,
99 NoEncryptToEncryptionFlagFeature = 0x00000040,
100 EphemeralKeylistModeFeature = 0x00000080,
101
102 SetDataFileNameFeeature = 0x00000100,
103 VerificationResultFileNameFeature = 0x00000200,
104 DecryptionResultFileNameFeature = 0x00000400,
105 DecryptionResultRecipientsFeature = 0x00000800,
106
107 AuditLogFeature = 0x00001000,
108 GpgConfEngineFeature = 0x00002000,
109 CancelOperationAsyncFeature = 0x00004000,
110 AssuanEngineFeature = 0x00008000,
111
112 ClearAddGetSignatureNotationsFeature = 0x00010000,
113 SignatureNotationsKeylistModeFeature = 0x00020000,
114 KeySignatureNotationsFeature = 0x00040000,
115 SignatureNotationsFlagsFeature = 0x00080000,
116 SignatureNotationsCriticalFlagFeature = 0x00100000,
117 SignatureNotationsHumanReadableFlagFeature = 0x00200000,
118 CardKeyFeature = 0x00400000,
119 ImportFromKeyserverFeature = 0x00800000,
120
121 KeyIsQualifiedFeature = 0x01000200,
122 SubkeyIsQualifiedFeature = 0x02000000,
123 SignaturePkaFieldsFeature = 0x04000000,
124 SignatureAlgorithmFieldsFeature = 0x08000000,
125
126 FdPointerFeature = 0x10000000,
127 G13VFSFeature = 0x20000000,
128 PasswdFeature = 0x40000000, // gpgme >= 1.3.0
129 // unusable (max value)
130
131 FeatureMaxValue = 0x80000000
132 };
133 enum Feature2 {
134 Feature2MaxValue = 0x80000000
135 };
136 // use hasFeature( unsigned long, unsigned long ) instead
137 GPGMEPP_DEPRECATED_EXPORT bool hasFeature( unsigned long feature );
138 GPGMEPP_EXPORT bool hasFeature( unsigned long feature, unsigned long feature2 );
139
140} // namespace GpgME
141
142# ifndef GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION
143# define GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION( Class ) \
144 namespace std { template <> inline void swap< GpgME::Class >( GpgME::Class & lhs, GpgME::Class & rhs ) { lhs.swap( rhs ); } }
145# endif
146
147# ifndef GPGMEPP_MAKE_SAFE_BOOL_OPERATOR
148# define GPGMEPP_MAKE_SAFE_BOOL_OPERATOR( Cond ) \
149 private: \
150 struct __safe_bool_dummy__ { void nonnull() {} }; \
151 typedef void ( __safe_bool_dummy__::*unspecified_bool_type )(); \
152 public: \
153 operator unspecified_bool_type() const { return ( Cond ) ? &__safe_bool_dummy__::nonnull : 0 ; }
154# endif
155
156#endif // __GPGMEPP_GLOBAL_H__
157