Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/viewer/objecttreeparser.cpp
Show First 20 Lines • Show All 1162 Lines • ▼ Show 20 Line(s) | 1162 | { | |||
---|---|---|---|---|---|
1163 | return processMultiPartMixedSubtype(node, result); | 1163 | return processMultiPartMixedSubtype(node, result); | ||
1164 | } | 1164 | } | ||
1165 | 1165 | | |||
1166 | bool ObjectTreeParser::processMultiPartParallelSubtype(KMime::Content *node, ProcessResult &result) | 1166 | bool ObjectTreeParser::processMultiPartParallelSubtype(KMime::Content *node, ProcessResult &result) | ||
1167 | { | 1167 | { | ||
1168 | return processMultiPartMixedSubtype(node, result); | 1168 | return processMultiPartMixedSubtype(node, result); | ||
1169 | } | 1169 | } | ||
1170 | 1170 | | |||
1171 | bool ObjectTreeParser::processMultiPartSignedSubtype(KMime::Content *node, ProcessResult &) | 1171 | MessagePart::Ptr ObjectTreeParser::processMultiPartSignedSubtype(KMime::Content *node, ProcessResult &) | ||
1172 | { | 1172 | { | ||
1173 | KMime::Content *child = MessageCore::NodeHelper::firstChild(node); | 1173 | KMime::Content *child = MessageCore::NodeHelper::firstChild(node); | ||
1174 | if (node->contents().size() != 2) { | 1174 | if (node->contents().size() != 2) { | ||
1175 | qCDebug(MESSAGEVIEWER_LOG) << "mulitpart/signed must have exactly two child parts!" << endl | 1175 | qCDebug(MESSAGEVIEWER_LOG) << "mulitpart/signed must have exactly two child parts!" << endl | ||
1176 | << "processing as multipart/mixed"; | 1176 | << "processing as multipart/mixed"; | ||
1177 | if (child) { | 1177 | | ||
1178 | standardChildHandling(child); | 1178 | return MessagePart::Ptr(new MimeMessagePart(this, child, false)); | ||
1179 | } | | |||
1180 | return child; | | |||
1181 | } | 1179 | } | ||
1182 | 1180 | | |||
1183 | KMime::Content *signedData = child; | 1181 | KMime::Content *signedData = child; | ||
1184 | assert(signedData); | 1182 | assert(signedData); | ||
1185 | 1183 | | |||
1186 | KMime::Content *signature = node->contents().at(1); | 1184 | KMime::Content *signature = node->contents().at(1); | ||
1187 | assert(signature); | 1185 | assert(signature); | ||
1188 | 1186 | | |||
1189 | mNodeHelper->setNodeProcessed(signature, true); | 1187 | mNodeHelper->setNodeProcessed(signature, true); | ||
1190 | 1188 | | |||
1191 | if (!includeSignatures()) { | 1189 | if (!includeSignatures()) { | ||
1192 | standardChildHandling(signedData); | 1190 | return MessagePart::Ptr(new MimeMessagePart(this, signedData, false)); | ||
1193 | return true; | | |||
1194 | } | 1191 | } | ||
1195 | 1192 | | |||
1196 | QString protocolContentType = node->contentType()->parameter(QStringLiteral("protocol")).toLower(); | 1193 | QString protocolContentType = node->contentType()->parameter(QStringLiteral("protocol")).toLower(); | ||
1197 | const QString signatureContentType = QLatin1String(signature->contentType()->mimeType().toLower()); | 1194 | const QString signatureContentType = QLatin1String(signature->contentType()->mimeType().toLower()); | ||
1198 | if (protocolContentType.isEmpty()) { | 1195 | if (protocolContentType.isEmpty()) { | ||
1199 | qCWarning(MESSAGEVIEWER_LOG) << "Message doesn't set the protocol for the multipart/signed content-type, " | 1196 | qCWarning(MESSAGEVIEWER_LOG) << "Message doesn't set the protocol for the multipart/signed content-type, " | ||
1200 | "using content-type of the signature:" << signatureContentType; | 1197 | "using content-type of the signature:" << signatureContentType; | ||
1201 | protocolContentType = signatureContentType; | 1198 | protocolContentType = signatureContentType; | ||
1202 | } | 1199 | } | ||
1203 | 1200 | | |||
1204 | const Kleo::CryptoBackend::Protocol *protocol = 0; | 1201 | const Kleo::CryptoBackend::Protocol *protocol = 0; | ||
1205 | if (protocolContentType == QLatin1String("application/pkcs7-signature") || | 1202 | if (protocolContentType == QLatin1String("application/pkcs7-signature") || | ||
1206 | protocolContentType == QLatin1String("application/x-pkcs7-signature")) { | 1203 | protocolContentType == QLatin1String("application/x-pkcs7-signature")) { | ||
1207 | protocol = Kleo::CryptoBackendFactory::instance()->smime(); | 1204 | protocol = Kleo::CryptoBackendFactory::instance()->smime(); | ||
1208 | } else if (protocolContentType == QLatin1String("application/pgp-signature") || | 1205 | } else if (protocolContentType == QLatin1String("application/pgp-signature") || | ||
1209 | protocolContentType == QLatin1String("application/x-pgp-signature")) { | 1206 | protocolContentType == QLatin1String("application/x-pgp-signature")) { | ||
1210 | protocol = Kleo::CryptoBackendFactory::instance()->openpgp(); | 1207 | protocol = Kleo::CryptoBackendFactory::instance()->openpgp(); | ||
1211 | } | 1208 | } | ||
1212 | 1209 | | |||
1213 | if (!protocol) { | 1210 | if (!protocol) { | ||
1214 | mNodeHelper->setNodeProcessed(signature, true); | 1211 | mNodeHelper->setNodeProcessed(signature, true); | ||
1215 | standardChildHandling(signedData); | 1212 | return MessagePart::Ptr(new MimeMessagePart(this, signedData, false)); | ||
1216 | return true; | | |||
1217 | } | 1213 | } | ||
1218 | 1214 | | |||
1219 | CryptoProtocolSaver saver(this, protocol); | 1215 | CryptoProtocolSaver saver(this, protocol); | ||
1220 | mNodeHelper->setSignatureState(node, KMMsgFullySigned); | 1216 | mNodeHelper->setSignatureState(node, KMMsgFullySigned); | ||
1221 | 1217 | | |||
1222 | const QByteArray cleartext = KMime::LFtoCRLF(signedData->encodedContent()); | 1218 | const QByteArray cleartext = KMime::LFtoCRLF(signedData->encodedContent()); | ||
1223 | const QTextCodec *aCodec(codecFor(signedData)); | 1219 | const QTextCodec *aCodec(codecFor(signedData)); | ||
1224 | 1220 | | |||
1225 | CryptoMessagePart mp(this, &messagePart, | 1221 | CryptoMessagePart::Ptr mp(new CryptoMessagePart(this, | ||
1226 | aCodec->toUnicode(cleartext), cryptoProtocol(), | 1222 | aCodec->toUnicode(cleartext), cryptoProtocol(), | ||
1227 | NodeHelper::fromAsString(node), signature); | 1223 | NodeHelper::fromAsString(node), signature)); | ||
1228 | messagePart.isSigned = true; | 1224 | PartMetaData *messagePart(mp->partMetaData()); | ||
1225 | messagePart->isSigned = true; | ||||
1229 | 1226 | | |||
1230 | if (cryptoProtocol()) { | 1227 | if (cryptoProtocol()) { | ||
1231 | mp.startVerificationDetached(cleartext, signedData, signature->decodedContent()); | 1228 | mp->startVerificationDetached(cleartext, signedData, signature->decodedContent()); | ||
1232 | } else { | 1229 | } else { | ||
1233 | messagePart->auditLogError = GpgME::Error(GPG_ERR_NOT_IMPLEMENTED); | 1230 | messagePart->auditLogError = GpgME::Error(GPG_ERR_NOT_IMPLEMENTED); | ||
1234 | } | 1231 | } | ||
1235 | 1232 | | |||
1236 | mp.html(false); | 1233 | return mp; | ||
1237 | | ||||
1238 | return true; | | |||
1239 | } | 1234 | } | ||
1240 | 1235 | | |||
1241 | bool ObjectTreeParser::processMultiPartEncryptedSubtype(KMime::Content *node, ProcessResult &result) | 1236 | bool ObjectTreeParser::processMultiPartEncryptedSubtype(KMime::Content *node, ProcessResult &result) | ||
1242 | { | 1237 | { | ||
1243 | KMime::Content *child = MessageCore::NodeHelper::firstChild(node); | 1238 | KMime::Content *child = MessageCore::NodeHelper::firstChild(node); | ||
1244 | if (!child) { | 1239 | if (!child) { | ||
1245 | return false; | 1240 | return false; | ||
1246 | } | 1241 | } | ||
▲ Show 20 Lines • Show All 1825 Lines • Show Last 20 Lines |