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

kleopatra

classify.h

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset:4 -*-
00002     utils/classify.h
00003 
00004     This file is part of Kleopatra, the KDE keymanager
00005     Copyright (c) 2007 Klarälvdalens Datakonsult AB
00006 
00007     Kleopatra is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     Kleopatra is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021     In addition, as a special exception, the copyright holders give
00022     permission to link the code of this program with any edition of
00023     the Qt library by Trolltech AS, Norway (or with modified versions
00024     of Qt that use the same license as Qt), and distribute linked
00025     combinations including the two.  You must obey the GNU General
00026     Public License in all respects for all of the code used other than
00027     Qt.  If you modify this file, you may extend this exception to
00028     your version of the file, but you are not obligated to do so.  If
00029     you do not wish to do so, delete this exception statement from
00030     your version.
00031 */
00032 
00033 #include <gpgme++/global.h>
00034 
00035 #ifndef __KLEOPATRA_UISERVER_CLASSIFY_H__
00036 #define __KLEOPATRA_UISERVER_CLASSIFY_H__
00037 
00038 class QString;
00039 class QStringList;
00040 
00041 namespace Kleo {
00042 
00043     namespace Class {
00044         enum {
00045             NoClass = 0,
00046 
00047             // protocol:
00048             CMS          = 0x01,
00049             OpenPGP      = 0x02,
00050 
00051             AnyProtocol  = OpenPGP|CMS,
00052             ProtocolMask = AnyProtocol,
00053 
00054             // format:
00055             Binary     = 0x04,
00056             Ascii      = 0x08,
00057 
00058             AnyFormat  = Binary|Ascii,
00059             FormatMask = AnyFormat,
00060         
00061             // type:
00062             DetachedSignature  = 0x010,
00063             OpaqueSignature    = 0x020,
00064             ClearsignedMessage = 0x040,
00065 
00066             AnySignature       = DetachedSignature|OpaqueSignature|ClearsignedMessage,
00067 
00068             CipherText         = 0x080,
00069 
00070             AnyMessageType     = AnySignature|CipherText,
00071 
00072             Certificate        = 0x100,
00073             ExportedPSM        = 0x200,
00074 
00075             AnyCertStoreType   = Certificate|ExportedPSM,
00076 
00077             CertificateRequest = 0x400,
00078 
00079             AnyType            = AnyMessageType|AnyCertStoreType|CertificateRequest,
00080             TypeMask           = AnyType
00081         };
00082     }
00083 
00084     unsigned int classify( const QString & filename );
00085     unsigned int classifyContent( const QByteArray & data );
00086 
00087     QString findSignedData( const QString & signatureFileName );
00088     QStringList findSignatures( const QString & signedDataFileName );
00089     QString outputFileName( const QString & input );
00090 
00091     const char * outputFileExtension( unsigned int classification );
00092 
00093     QString printableClassification( unsigned int classification );
00094 
00095 #define make_convenience( What, Mask )                                  \
00096     inline bool is##What( const QString & filename ) {                  \
00097         return ( classify( filename ) & Class::Mask ) == Class::What ;  \
00098     }                                                                   \
00099     inline bool is##What( const unsigned int classifcation ) {          \
00100         return ( classifcation & Class::Mask ) == Class::What ;         \
00101     }                                                                   \
00102     inline bool mayBe##What( const QString & filename ) {               \
00103         return classify( filename ) & Class::What ;                     \
00104     }                                                                   \
00105     inline bool mayBe##What( const unsigned int classifcation ) {       \
00106         return classifcation & Class::What ;                            \
00107     }
00108 
00109     make_convenience( CMS,     ProtocolMask )
00110     make_convenience( OpenPGP, ProtocolMask )
00111 
00112     make_convenience( Binary, FormatMask )
00113     make_convenience( Ascii,  FormatMask )
00114 
00115     make_convenience( DetachedSignature, TypeMask )
00116     make_convenience( OpaqueSignature,   TypeMask )
00117     make_convenience( CipherText,        TypeMask )
00118     make_convenience( AnyMessageType,    TypeMask )
00119 #undef make_convenience
00120 
00121     inline GpgME::Protocol findProtocol( const unsigned int classifcation ) {
00122         if ( isOpenPGP( classifcation ) )
00123             return GpgME::OpenPGP;
00124         else if ( isCMS( classifcation ) )
00125             return GpgME::CMS;
00126         else
00127             return GpgME::UnknownProtocol;
00128     }
00129     inline GpgME::Protocol findProtocol( const QString & filename ) {
00130         return findProtocol( classify( filename ) );
00131     }
00132 
00133 }
00134 
00135 #endif /* __KLEOPATRA_UISERVER_CLASSIFY_H__ */

kleopatra

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

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal