• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kleopatra

  • sources
  • kde-4.12
  • kdepim
  • kleopatra
  • utils
classify.h
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  utils/classify.h
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2007 Klarälvdalens Datakonsult AB
6 
7  Kleopatra is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  Kleopatra 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 #include <gpgme++/global.h>
34 
35 #ifndef __KLEOPATRA_UISERVER_CLASSIFY_H__
36 #define __KLEOPATRA_UISERVER_CLASSIFY_H__
37 
38 class QString;
39 class QStringList;
40 
41 namespace Kleo {
42 
43  namespace Class {
44  enum {
45  NoClass = 0,
46 
47  // protocol:
48  CMS = 0x01,
49  OpenPGP = 0x02,
50 
51  AnyProtocol = OpenPGP|CMS,
52  ProtocolMask = AnyProtocol,
53 
54  // format:
55  Binary = 0x04,
56  Ascii = 0x08,
57 
58  AnyFormat = Binary|Ascii,
59  FormatMask = AnyFormat,
60 
61  // type:
62  DetachedSignature = 0x010,
63  OpaqueSignature = 0x020,
64  ClearsignedMessage = 0x040,
65 
66  AnySignature = DetachedSignature|OpaqueSignature|ClearsignedMessage,
67 
68  CipherText = 0x080,
69 
70  AnyMessageType = AnySignature|CipherText,
71 
72  Importable = 0x100,
73  Certificate = 0x200|Importable,
74  ExportedPSM = 0x400|Importable,
75 
76  AnyCertStoreType = Certificate|ExportedPSM,
77 
78  CertificateRequest = 0x800,
79 
80  CertificateRevocationList = 0x1000,
81 
82  AnyType = AnyMessageType|AnyCertStoreType|CertificateRequest|CertificateRevocationList,
83  TypeMask = AnyType
84  };
85  }
86 
87  unsigned int classify( const QString & filename );
88  unsigned int classify( const QStringList & fileNames );
89  unsigned int classifyContent( const QByteArray & data );
90 
91  QString findSignedData( const QString & signatureFileName );
92  QStringList findSignatures( const QString & signedDataFileName );
93  QString outputFileName( const QString & input );
94 
95  const char * outputFileExtension( unsigned int classification );
96 
97  QString printableClassification( unsigned int classification );
98 
99 #define make_convenience( What, Mask ) \
100  inline bool is##What( const QString & filename ) { \
101  return ( classify( filename ) & Class::Mask ) == Class::What ; \
102  } \
103  inline bool is##What( const unsigned int classifcation ) { \
104  return ( classifcation & Class::Mask ) == Class::What ; \
105  } \
106  inline bool mayBe##What( const QString & filename ) { \
107  return classify( filename ) & Class::What ; \
108  } \
109  inline bool mayBe##What( const unsigned int classifcation ) { \
110  return classifcation & Class::What ; \
111  }
112 
113  make_convenience( CMS, ProtocolMask )
114  make_convenience( OpenPGP, ProtocolMask )
115 
116  make_convenience( Binary, FormatMask )
117  make_convenience( Ascii, FormatMask )
118 
119  make_convenience( DetachedSignature, TypeMask )
120  make_convenience( OpaqueSignature, TypeMask )
121  make_convenience( CipherText, TypeMask )
122  make_convenience( AnyMessageType, TypeMask )
123  make_convenience( CertificateRevocationList, TypeMask )
124  make_convenience( AnyCertStoreType, TypeMask )
125 #undef make_convenience
126 
127  inline GpgME::Protocol findProtocol( const unsigned int classifcation ) {
128  if ( isOpenPGP( classifcation ) )
129  return GpgME::OpenPGP;
130  else if ( isCMS( classifcation ) )
131  return GpgME::CMS;
132  else
133  return GpgME::UnknownProtocol;
134  }
135  inline GpgME::Protocol findProtocol( const QString & filename ) {
136  return findProtocol( classify( filename ) );
137  }
138 
139 }
140 
141 #endif /* __KLEOPATRA_UISERVER_CLASSIFY_H__ */
Kleo::outputFileExtension
const char * outputFileExtension(unsigned int classification)
Definition: classify.cpp:292
Kleo::Class::ProtocolMask
Definition: classify.h:52
Kleo::Class::AnySignature
Definition: classify.h:66
Kleo::Class::NoClass
Definition: classify.h:45
Kleo::Class::AnyMessageType
Definition: classify.h:70
Kleo::findSignedData
QString findSignedData(const QString &signatureFileName)
Definition: classify.cpp:249
Kleo::Class::CertificateRevocationList
Definition: classify.h:80
Kleo::Class::DetachedSignature
Definition: classify.h:62
Kleo::Class::ExportedPSM
Definition: classify.h:74
Kleo::printableClassification
QString printableClassification(unsigned int classification)
Definition: classify.cpp:213
Kleo::Class::CipherText
Definition: classify.h:68
Kleo::Class::FormatMask
Definition: classify.h:59
Kleo::Class::Ascii
Definition: classify.h:56
Kleo::Class::AnyCertStoreType
Definition: classify.h:76
Kleo::Class::OpenPGP
Definition: classify.h:49
Kleo::Class::CMS
Definition: classify.h:48
Kleo::make_convenience
make_convenience(CMS, ProtocolMask) make_convenience(OpenPGP
Kleo::Class::OpaqueSignature
Definition: classify.h:63
Kleo::outputFileName
QString outputFileName(const QString &input)
Definition: classify.cpp:277
Kleo::Class::CertificateRequest
Definition: classify.h:78
Kleo::Class::TypeMask
Definition: classify.h:83
Kleo::Class::Binary
Definition: classify.h:55
Kleo::Class::AnyType
Definition: classify.h:82
Kleo::Class::Importable
Definition: classify.h:72
Kleo::findSignatures
QStringList findSignatures(const QString &signedDataFileName)
Definition: classify.cpp:262
Kleo::classify
unsigned int classify(const QString &filename)
Definition: classify.cpp:154
Kleo::Class::Certificate
Definition: classify.h:73
Kleo::Class::AnyProtocol
Definition: classify.h:51
Kleo::classifyContent
unsigned int classifyContent(const QByteArray &data)
Definition: classify.cpp:183
Kleo::Class::AnyFormat
Definition: classify.h:58
Kleo::findProtocol
ProtocolMask FormatMask TypeMask TypeMask TypeMask GpgME::Protocol findProtocol(const unsigned int classifcation)
Definition: classify.h:127
Kleo::Class::ClearsignedMessage
Definition: classify.h:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kleopatra

Skip menu "kleopatra"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal