Messagelib
9 #include "cryptohelper.h"
11 using namespace MimeTreeParser;
13 PGPBlockType Block::determineType()
const
16 if (data.
startsWith(
"-----BEGIN PGP PUBLIC KEY BLOCK-----")) {
18 }
else if (data.
startsWith(
"-----BEGIN PGP SIGNED")) {
19 return ClearsignedBlock;
20 }
else if (data.
startsWith(
"-----BEGIN PGP SIGNATURE")) {
21 return SignatureBlock;
22 }
else if (data.
startsWith(
"-----BEGIN PGP PUBLIC")) {
23 return PublicKeyBlock;
24 }
else if (data.
startsWith(
"-----BEGIN PGP PRIVATE") || data.
startsWith(
"-----BEGIN PGP SECRET")) {
25 return PrivateKeyBlock;
26 }
else if (data.
startsWith(
"-----BEGIN PGP MESSAGE")) {
27 if (data.
startsWith(
"-----BEGIN PGP MESSAGE PART")) {
28 return MultiPgpMessageBlock;
30 return PgpMessageBlock;
32 }
else if (data.
startsWith(
"-----BEGIN PGP ARMORED FILE")) {
33 return PgpMessageBlock;
34 }
else if (data.
startsWith(
"-----BEGIN PGP ")) {
43 PGPBlockType pgpBlock = NoPgpBlock;
47 const int length = msg.
length();
52 if (msg.
startsWith(
"-----BEGIN PGP PUBLIC KEY BLOCK-----")) {
72 pgpBlock = ClearsignedBlock;
74 pgpBlock = UnknownBlock;
78 nextStart = msg.
indexOf(
"\n-----BEGIN PGP ",
start + 15);
89 if ((nextStart == -1) || (nextEnd < nextStart) || (pgpBlock == ClearsignedBlock)) {
93 if (
start - lastEnd - 1 > 0) {
97 lastEnd = msg.
indexOf(
"\n", nextEnd + 14);
105 if ((nextStart != -1) && (nextEnd > nextStart)) {
106 nextStart = msg.
indexOf(
"\n-----BEGIN PGP ", lastEnd + 1);
114 if (lastEnd + 1 < length) {
127 Block::Block() =
default;
132 mType = determineType();
135 Block::Block(
const QByteArray &m, PGPBlockType t)
141 QByteArray MimeTreeParser::Block::text()
const
146 PGPBlockType Block::type()
const
int indexOf(char ch, int from) const const
void append(const T &value)
Q_SCRIPTABLE Q_NOREPLY void start()
QByteArray mid(int pos, int len) const const
bool startsWith(const QByteArray &ba) const const
bool isEmpty() const const
const char * constData() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:08:10 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.