File indexing completed on 2024-06-16 05:01:10

0001 /*
0002     cryptohelper.h
0003 
0004     Copyright (C) 2015 Sandro Knauß <knauss@kolabsys.com>
0005     Copyright (C) 2001,2002 the KPGP authors
0006     See file AUTHORS.kpgp for details
0007 
0008     KMail is free software; you can redistribute it and/or modify
0009     it under the terms of the GNU General Public License as published by
0010     the Free Software Foundation; either version 2 of the License, or
0011     (at your option) any later version.
0012 
0013     You should have received a copy of the GNU General Public License
0014     along with this program; if not, write to the Free Software Foundation,
0015     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
0016  */
0017 #pragma once
0018 
0019 #include <QByteArray>
0020 #include <QList>
0021 
0022 namespace MimeTreeParser
0023 {
0024 
0025 enum PGPBlockType {
0026     UnknownBlock = -1,        // BEGIN PGP ???
0027     NoPgpBlock = 0,
0028     PgpMessageBlock = 1,      // BEGIN PGP MESSAGE
0029     MultiPgpMessageBlock = 2, // BEGIN PGP MESSAGE, PART X[/Y]
0030     SignatureBlock = 3,       // BEGIN PGP SIGNATURE
0031     ClearsignedBlock = 4,     // BEGIN PGP SIGNED MESSAGE
0032     PublicKeyBlock = 5,       // BEGIN PGP PUBLIC KEY BLOCK
0033     PrivateKeyBlock = 6       // BEGIN PGP PRIVATE KEY BLOCK (PGP 2.x: ...SECRET...)
0034 };
0035 
0036 class Block
0037 {
0038 public:
0039     Block(const QByteArray &m);
0040 
0041     Block(const QByteArray &m, PGPBlockType t);
0042 
0043     QByteArray text() const;
0044     PGPBlockType type() const;
0045     PGPBlockType determineType() const;
0046 
0047     QByteArray msg;
0048     PGPBlockType mType;
0049 };
0050 
0051 /** Parses the given message and splits it into OpenPGP blocks and
0052     Non-OpenPGP blocks.
0053 */
0054 QList<Block> prepareMessageForDecryption(const QByteArray &msg);
0055 
0056 } // namespace MimeTreeParser
0057 
0058 Q_DECLARE_TYPEINFO(MimeTreeParser::Block, Q_MOVABLE_TYPE);