QString EmailMessageListModel::bodyPlainText(const QMailMessage &mailMsg) const { QMailMessagePartContainer *container = (QMailMessagePartContainer *)&mailMsg; QMailMessageContentType contentType = container->contentType(); if (container->hasBody() && contentType.type().toLower() == "text" && contentType.subType().toLower() == "plain") { return container->body().data(); } QString text(""); for ( uint i = 0; i < container->partCount(); i++ ) { QMailMessagePart messagePart = container->partAt(i); contentType = messagePart.contentType(); if (messagePart.hasBody() && contentType.type().toLower() == "text" && contentType.subType().toLower() == "plain") { text += messagePart.body().data() + "\n"; } QMailMessagePart subPart; for (uint j = 0; j < messagePart.partCount(); j++) { subPart = messagePart.partAt(j); contentType = subPart.contentType(); if (subPart.hasBody() && contentType.type().toLower() == "text" && contentType.subType().toLower() == "plain") text += subPart.body().data() + "\n"; } } return text; }
QMailCryptoFwd::VerificationResult QMailCryptoSMIME::verifySignature(const QMailMessagePartContainer &part) const { if (!partHasSignature(part)) return QMailCryptoFwd::VerificationResult(QMailCryptoFwd::MissingSignature); QMailMessagePart body = part.partAt(0); QMailMessagePart signature = part.partAt(1); if (!body.contentAvailable() || !signature.contentAvailable()) return QMailCryptoFwd::VerificationResult(); QMailCryptoFwd::VerificationResult result; result.engine = QStringLiteral("libsmime.so"); result.summary = verify(signature.body().data(QMailMessageBodyFwd::Decoded), body.undecodedData(), result.keyResults); return result; }
QString EmailMessageListModel::bodyHtmlText(QMailMessagePartContainer *container) const { QMailMessageContentType contentType = container->contentType(); if (container->multipartType() == QMailMessagePartContainerFwd::MultipartNone) { if (contentType.subType().toLower() == "html") { if (container->hasBody() && container->body().data().size() > 1) return container->body().data(); else { connect (m_retrievalAction, SIGNAL(activityChanged(QMailServiceAction::Activity)), this, SLOT(downloadActivityChanged(QMailServiceAction::Activity))); QMailMessage *msg = (QMailMessage *)container; QMailMessageIdList ids; ids << msg->id(); m_retrievalAction->retrieveMessages(ids, QMailRetrievalAction::Content); return " "; // Put a space here as a place holder to notify UI that we do have html body. // Should find a better way. } } return ""; } if (!container->contentAvailable()) { // if content is not available, attempts to downlaod from the server. connect (m_retrievalAction, SIGNAL(activityChanged(QMailServiceAction::Activity)), this, SLOT(downloadActivityChanged(QMailServiceAction::Activity))); QMailMessage *msg = (QMailMessage *)container; QMailMessageIdList ids; ids << msg->id(); m_retrievalAction->retrieveMessages(ids, QMailRetrievalAction::Content); return " "; // Put a space here as a place holder to notify UI that we do have html body. } QString text(""); for ( uint i = 0; i < container->partCount(); i++ ) { QMailMessagePart messagePart = container->partAt(i); contentType = messagePart.contentType(); if (contentType.type().toLower() == "text" && contentType.subType().toLower() == "html") { if (messagePart.hasBody()) { text += messagePart.body().data(); } else { connect (m_retrievalAction, SIGNAL(activityChanged(QMailServiceAction::Activity)), this, SLOT(downloadActivityChanged(QMailServiceAction::Activity))); QMailMessagePart::Location location = messagePart.location(); m_retrievalAction->retrieveMessagePart(location); text = " "; break; } } QMailMessagePart subPart; for (uint j = 0; j < messagePart.partCount(); j++) { subPart = messagePart.partAt(j); contentType = subPart.contentType(); if (contentType.type().toLower() == "text" && contentType.subType().toLower() == "html") { if (subPart.hasBody()) { text += subPart.body().data(); } else { connect (m_retrievalAction, SIGNAL(activityChanged(QMailServiceAction::Activity)), this, SLOT(downloadActivityChanged(QMailServiceAction::Activity))); QMailMessagePart::Location location = subPart.location(); m_retrievalAction->retrieveMessagePart(location); text = " "; break; } } } } return text; }