12#include "kleo_export.h"
16#include <gpgme++/global.h>
41 AnyFormat =
Binary | Ascii,
42 FormatMask = AnyFormat,
45 DetachedSignature = 0x010,
46 OpaqueSignature = 0x020,
47 ClearsignedMessage = 0x040,
49 AnySignature = DetachedSignature | OpaqueSignature | ClearsignedMessage,
53 AnyMessageType = AnySignature | CipherText,
57 ExportedPSM = 0x400 | Importable,
61 CertificateRequest = 0x800,
63 CertificateRevocationList = 0x1000,
67 AnyType = AnyMessageType | AnyCertStoreType | CertificateRequest | CertificateRevocationList,
68 TypeMask = AnyType | MimeFile
73KLEO_EXPORT
unsigned int classify(
const QString &filename);
74KLEO_EXPORT
unsigned int classify(
const QStringList &fileNames);
75KLEO_EXPORT
unsigned int classifyContent(
const QByteArray &data);
77KLEO_EXPORT
QString findSignedData(
const QString &signatureFileName);
82KLEO_EXPORT
bool isFingerprint(
const QString &fpr);
85KLEO_EXPORT
bool isChecksumFile(
const QString &file);
87KLEO_EXPORT
QString outputFileExtension(
unsigned int classification,
bool usePGPFileExt);
89KLEO_EXPORT
QString printableClassification(
unsigned int classification);
91inline bool isCMS(
const QString &filename)
93 return (classify(filename) & Class::ProtocolMask) == Class::CMS;
95inline bool isCMS(
const unsigned int classification)
97 return (classification & Class::ProtocolMask) == Class::CMS;
99inline bool mayBeCMS(
const QString &filename)
101 return classify(filename) & Class::CMS;
103inline bool mayBeCMS(
const unsigned int classification)
105 return classification & Class::CMS;
108inline bool isOpenPGP(
const QString &filename)
110 return (classify(filename) & Class::ProtocolMask) == Class::OpenPGP;
112inline bool isOpenPGP(
const unsigned int classification)
114 return (classification & Class::ProtocolMask) == Class::OpenPGP;
116inline bool mayBeOpenPGP(
const QString &filename)
118 return classify(filename) & Class::OpenPGP;
120inline bool mayBeOpenPGP(
const unsigned int classification)
122 return classification & Class::OpenPGP;
125inline bool isBinary(
const QString &filename)
127 return (classify(filename) & Class::FormatMask) == Class::Binary;
129inline bool isBinary(
const unsigned int classification)
131 return (classification & Class::FormatMask) == Class::Binary;
133inline bool mayBeBinary(
const QString &filename)
135 return classify(filename) & Class::Binary;
137inline bool mayBeBinary(
const unsigned int classification)
139 return classification & Class::Binary;
142inline bool isAscii(
const QString &filename)
144 return (classify(filename) & Class::FormatMask) == Class::Ascii;
146inline bool isAscii(
const unsigned int classification)
148 return (classification & Class::FormatMask) == Class::Ascii;
150inline bool mayBeAscii(
const QString &filename)
152 return classify(filename) & Class::Ascii;
154inline bool mayBeAscii(
const unsigned int classification)
156 return classification & Class::Ascii;
159inline bool isDetachedSignature(
const QString &filename)
161 return (classify(filename) & Class::TypeMask) == Class::DetachedSignature;
163inline bool isDetachedSignature(
const unsigned int classification)
165 return (classification & Class::TypeMask) == Class::DetachedSignature;
167inline bool mayBeDetachedSignature(
const QString &filename)
169 return classify(filename) & Class::DetachedSignature;
171inline bool mayBeDetachedSignature(
const unsigned int classification)
173 return classification & Class::DetachedSignature;
176inline bool isOpaqueSignature(
const QString &filename)
178 return (classify(filename) & Class::TypeMask) == Class::OpaqueSignature;
180inline bool isOpaqueSignature(
const unsigned int classification)
182 return (classification & Class::TypeMask) == Class::OpaqueSignature;
184inline bool mayBeOpaqueSignature(
const QString &filename)
186 return classify(filename) & Class::OpaqueSignature;
188inline bool mayBeOpaqueSignature(
const unsigned int classification)
190 return classification & Class::OpaqueSignature;
193inline bool isCipherText(
const QString &filename)
195 return (classify(filename) & Class::TypeMask) == Class::CipherText;
197inline bool isCipherText(
const unsigned int classification)
199 return (classification & Class::TypeMask) == Class::CipherText;
201inline bool mayBeCipherText(
const QString &filename)
203 return classify(filename) & Class::CipherText;
205inline bool mayBeCipherText(
const unsigned int classification)
207 return classification & Class::CipherText;
210inline bool isAnyMessageType(
const QString &filename)
212 return (classify(filename) & Class::TypeMask) == Class::AnyMessageType;
214inline bool isAnyMessageType(
const unsigned int classification)
216 return (classification & Class::TypeMask) == Class::AnyMessageType;
218inline bool mayBeAnyMessageType(
const QString &filename)
220 return classify(filename) & Class::AnyMessageType;
222inline bool mayBeAnyMessageType(
const unsigned int classification)
224 return classification & Class::AnyMessageType;
227inline bool isCertificateRevocationList(
const QString &filename)
229 return (classify(filename) & Class::TypeMask) == Class::CertificateRevocationList;
231inline bool isCertificateRevocationList(
const unsigned int classification)
233 return (classification & Class::TypeMask) == Class::CertificateRevocationList;
235inline bool mayBeCertificateRevocationList(
const QString &filename)
237 return classify(filename) & Class::CertificateRevocationList;
239inline bool mayBeCertificateRevocationList(
const unsigned int classification)
241 return classification & Class::CertificateRevocationList;
244inline bool isAnyCertStoreType(
const QString &filename)
246 return (classify(filename) & Class::TypeMask) == Class::AnyCertStoreType;
248inline bool isAnyCertStoreType(
const unsigned int classification)
250 return (classification & Class::TypeMask) == Class::AnyCertStoreType;
252inline bool mayBeAnyCertStoreType(
const QString &filename)
254 return classify(filename) & Class::AnyCertStoreType;
256inline bool mayBeAnyCertStoreType(
const unsigned int classification)
258 return classification & Class::AnyCertStoreType;
261inline bool isMimeFile(
const unsigned int classification)
263 return (classification & Class::TypeMask) == Class::MimeFile;
266inline bool isMimeFile(
const QString &filename)
268 return (classify(filename) & Class::TypeMask) == Class::MimeFile;
271inline bool mayBeMimeFile(
const QString &filename)
273 return classify(filename) & Class::MimeFile;
275inline bool mayBeMimeFile(
const unsigned int classification)
277 return classification & Class::MimeFile;
280inline GpgME::Protocol findProtocol(
const unsigned int classification)
282 if (isOpenPGP(classification)) {
283 return GpgME::OpenPGP;
284 }
else if (isCMS(classification)) {
287 return GpgME::UnknownProtocol;
290inline GpgME::Protocol findProtocol(
const QString &filename)
292 return findProtocol(classify(filename));