Commit 0954c9bd authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to QVector

parent 19bda5fe
......@@ -193,7 +193,7 @@ void ComposerTestUtil::verifySignatureAndEncryption(KMime::Content *content, con
otp.parseObjectTree(resultMessage.data());
QCOMPARE(nh->encryptionState(resultMessage.data()), MimeTreeParser::KMMsgFullyEncrypted);
QList< KMime::Content * > extra = nh->extraContents(resultMessage.data());
QVector< KMime::Content * > extra = nh->extraContents(resultMessage.data());
QCOMPARE(extra.size(), 1);
QCOMPARE(nh->signatureState(extra[ 0 ]), MimeTreeParser::KMMsgFullySigned);
} else if (f & Kleo::InlineOpenPGPFormat) {
......@@ -214,7 +214,7 @@ void ComposerTestUtil::verifySignatureAndEncryption(KMime::Content *content, con
otp.parseObjectTree(resultMessage.data());
QCOMPARE(nh->encryptionState(resultMessage.data()), MimeTreeParser::KMMsgFullyEncrypted);
QList< KMime::Content * > extra = nh->extraContents(resultMessage.data());
QVector< KMime::Content * > extra = nh->extraContents(resultMessage.data());
QCOMPARE(extra.size(), 1);
QCOMPARE(nh->signatureState(extra[ 0 ]), MimeTreeParser::KMMsgFullySigned);
}
......
......@@ -52,7 +52,7 @@ public:
~Private();
AttachmentPart::List parts;
QList<QTemporaryDir *> tempDirs;
QVector<QTemporaryDir *> tempDirs;
AttachmentModel *const q;
bool modified = false;
bool encryptEnabled = false;
......
......@@ -69,7 +69,7 @@ public:
// attachments with different sign/encrypt settings from
// main message body. added at the end of the process
AttachmentPart::List lateAttachmentParts;
QList<KMime::Message::Ptr> resultMessages;
QVector<KMime::Message::Ptr> resultMessages;
Kleo::CryptoMessageFormat format;
......@@ -456,12 +456,12 @@ Composer::~Composer()
{
}
QList<KMime::Message::Ptr> Composer::resultMessages() const
QVector<KMime::Message::Ptr> Composer::resultMessages() const
{
Q_D(const Composer);
Q_ASSERT(d->finished);
Q_ASSERT(!error());
QList<KMime::Message::Ptr> results = d->resultMessages;
QVector<KMime::Message::Ptr> results = d->resultMessages;
return results;
}
......
......@@ -25,6 +25,7 @@
#include "messagecomposer_export.h"
#include <QStringList>
#include <QVector>
#include <kmime/kmime_message.h>
......@@ -50,7 +51,7 @@ public:
explicit Composer(QObject *parent = nullptr);
~Composer() override;
QList<KMime::Message::Ptr> resultMessages() const;
QVector<KMime::Message::Ptr> resultMessages() const;
Q_REQUIRED_RESULT GlobalPart *globalPart() const;
Q_REQUIRED_RESULT InfoPart *infoPart() const;
......
......@@ -621,7 +621,7 @@ inline bool showKeyApprovalDialog()
}
} // nameless namespace
QList< MessageComposer::Composer * > ComposerViewBase::generateCryptoMessages(bool &wasCanceled)
QVector< MessageComposer::Composer * > ComposerViewBase::generateCryptoMessages(bool &wasCanceled)
{
const KIdentityManagement::Identity &id = m_identMan->identityForUoidOrDefault(m_identityCombo->currentIdentity());
......@@ -655,7 +655,7 @@ QList< MessageComposer::Composer * > ComposerViewBase::generateCryptoMessages(bo
}
if (keyResolver->setEncryptToSelfKeys(encryptToSelfKeys) != Kleo::Ok) {
qCDebug(MESSAGECOMPOSER_LOG) << "Failed to set encryptoToSelf keys!";
return QList< MessageComposer::Composer * >();
return QVector< MessageComposer::Composer * >();
}
//Add signingkeys from id to keyResolver
......@@ -667,7 +667,7 @@ QList< MessageComposer::Composer * > ComposerViewBase::generateCryptoMessages(bo
}
if (keyResolver->setSigningKeys(signKeys) != Kleo::Ok) {
qCDebug(MESSAGECOMPOSER_LOG) << "Failed to set signing keys!";
return QList< MessageComposer::Composer * >();
return QVector< MessageComposer::Composer * >();
}
if (m_attachmentModel) {
......@@ -703,7 +703,7 @@ QList< MessageComposer::Composer * > ComposerViewBase::generateCryptoMessages(bo
Q_EMIT failed(QString());
}
wasCanceled = canceled;
return QList< MessageComposer::Composer *>();
return QVector< MessageComposer::Composer *>();
}
canceled = false;
......@@ -718,27 +718,27 @@ QList< MessageComposer::Composer * > ComposerViewBase::generateCryptoMessages(bo
}
wasCanceled = canceled;
return QList< MessageComposer::Composer *>();
return QVector< MessageComposer::Composer *>();
}
//No encryption or signing is needed
if (!signSomething && !encryptSomething) {
return QList< MessageComposer::Composer * >() << new MessageComposer::Composer();
return QVector< MessageComposer::Composer * >() << new MessageComposer::Composer();
}
const Kleo::Result kpgpResult = keyResolver->resolveAllKeys(signSomething, encryptSomething);
if (kpgpResult == Kleo::Canceled) {
qCDebug(MESSAGECOMPOSER_LOG) << "resolveAllKeys: one key resolution canceled by user";
return QList< MessageComposer::Composer *>();
return QVector< MessageComposer::Composer *>();
} else if (kpgpResult != Kleo::Ok) {
// TODO handle failure
qCDebug(MESSAGECOMPOSER_LOG) << "resolveAllKeys: failed to resolve keys! oh noes";
Q_EMIT failed(i18n("Failed to resolve keys. Please report a bug."));
return QList< MessageComposer::Composer *>();
return QVector< MessageComposer::Composer *>();
}
qCDebug(MESSAGECOMPOSER_LOG) << "done resolving keys:";
QList< MessageComposer::Composer * > composers;
QVector< MessageComposer::Composer * > composers;
if (encryptSomething || signSomething) {
Kleo::CryptoMessageFormat concreteFormat = Kleo::AutoFormat;
......
......@@ -29,6 +29,7 @@
#include <KMime/Message>
#include <QObject>
#include <QVector>
#include <QUrl>
#include <Libkleo/Enum>
......@@ -293,7 +294,7 @@ private:
enum RecipientExpansion {
UseExpandedRecipients, UseUnExpandedRecipients
};
QList< MessageComposer::Composer * > generateCryptoMessages(bool &wasCanceled);
QVector< MessageComposer::Composer * > generateCryptoMessages(bool &wasCanceled);
void fillGlobalPart(MessageComposer::GlobalPart *globalPart);
void fillInfoPart(MessageComposer::InfoPart *part, RecipientExpansion expansion);
void queueMessage(const KMime::Message::Ptr &message, MessageComposer::Composer *composer);
......@@ -343,7 +344,7 @@ private:
// List of active composer jobs. For example, saving as draft, autosaving and printing
// all create a composer, which is added to this list as long as it is active.
// Used mainly to prevent closing the window if a composer is active
QList< MessageComposer::Composer * > m_composers;
QVector< MessageComposer::Composer * > m_composers;
bool m_sign = false;
bool m_encrypt = false;
......
......@@ -22,7 +22,7 @@
#define MESSAGEVIEWER_TESTS_SETUPENV_H
#include <gpgme++/key.h>
#include <QVector>
#include <MimeTreeParser/BodyPartFormatterFactory>
#include <MimeTreeParser/ObjectTreeSource>
......
......@@ -133,7 +133,7 @@ public:
}
}
QList<QTemporaryDir *> tempDirs;
QVector<QTemporaryDir *> tempDirs;
KMime::Content *root = nullptr;
QMimeDatabase m_mimeDb;
};
......
......@@ -22,6 +22,7 @@
#include <MimeTreeParser/ObjectTreeSource>
#include "messageviewer_export.h"
#include <QVector>
class QString;
namespace MessageViewer {
......
......@@ -21,7 +21,7 @@
#define MAILVIEWER_OBJECTTREEVIEWERSOURCE_H
#include "objecttreeemptysource.h"
#include <QVector>
class QString;
namespace MessageViewer {
......
......@@ -365,7 +365,7 @@ bool ViewerPrivate::deleteAttachment(KMime::Content *node, bool showWarning)
return true;
}
const QList<KMime::Content *> extraNodes = mNodeHelper->extraContents(mMessage.data());
const QVector<KMime::Content *> extraNodes = mNodeHelper->extraContents(mMessage.data());
if (extraNodes.contains(node->topLevel())) {
KMessageBox::error(mMainWindow,
i18n(
......
......@@ -35,7 +35,7 @@
#include <MimeTreeParser/Util>
#include "messageviewer/messageviewerutil.h"
#include <QVector>
#include <QLabel>
class QMouseEvent;
......
......@@ -24,7 +24,7 @@
#include <MimeTreeParser/Util>
#include <KMime/Message>
#include <QVector>
#include <QSharedPointer>
class QTextCodec;
......
......@@ -108,7 +108,7 @@ void NodeHelper::setNodeUnprocessed(KMime::Content *node, bool recurse)
mProcessedNodes.removeAll(node);
//avoid double addition of extra nodes, eg. encrypted attachments
const QMap<KMime::Content *, QList<KMime::Content *> >::iterator it = mExtraContents.find(node);
const QMap<KMime::Content *, QVector<KMime::Content *> >::iterator it = mExtraContents.find(node);
if (it != mExtraContents.end()) {
Q_FOREACH (KMime::Content *c, it.value()) {
KMime::Content *p = c->parent();
......@@ -159,9 +159,9 @@ void NodeHelper::clear()
std::for_each(mBodyPartMementoMap.begin(), mBodyPartMementoMap.end(),
&clearBodyPartMemento);
mBodyPartMementoMap.clear();
QMap<KMime::Content *, QList<KMime::Content *> >::ConstIterator end(mExtraContents.constEnd());
QMap<KMime::Content *, QVector<KMime::Content *> >::ConstIterator end(mExtraContents.constEnd());
for (QMap<KMime::Content *, QList<KMime::Content *> >::ConstIterator it = mExtraContents.constBegin(); it != end; ++it) {
for (QMap<KMime::Content *, QVector<KMime::Content *> >::ConstIterator it = mExtraContents.constBegin(); it != end; ++it) {
Q_FOREACH (KMime::Content *c, it.value()) {
KMime::Content *p = c->parent();
if (p) {
......@@ -690,7 +690,7 @@ QString NodeHelper::persistentIndex(const KMime::Content *node) const
QString indexStr = node->index().toString();
if (indexStr.isEmpty()) {
QMapIterator<KMime::Message::Content *, QList<KMime::Content *> > it(mExtraContents);
QMapIterator<KMime::Message::Content *, QVector<KMime::Content *> > it(mExtraContents);
while (it.hasNext()) {
it.next();
const auto &extraNodes = it.value();
......@@ -708,10 +708,10 @@ QString NodeHelper::persistentIndex(const KMime::Content *node) const
} else {
const KMime::Content *const topLevel = node->topLevel();
//if the node is an extra node, prepend the index of the extra node to the url
QMapIterator<KMime::Message::Content *, QList<KMime::Content *> > it(mExtraContents);
QMapIterator<KMime::Message::Content *, QVector<KMime::Content *> > it(mExtraContents);
while (it.hasNext()) {
it.next();
const QList<KMime::Content *> &extraNodes = extraContents(it.key());
const QVector<KMime::Content *> &extraNodes = extraContents(it.key());
for (int i = 0; i < extraNodes.size(); ++i) {
KMime::Content *const extraNode = extraNodes[i];
if (topLevel == extraNode) {
......@@ -738,7 +738,7 @@ KMime::Content *NodeHelper::contentFromIndex(KMime::Content *node, const QString
for (int i = 0; i < pathPartsSize; ++i) {
const QString &path = pathParts[i];
if (path.startsWith(QLatin1Char('e'))) {
const QList<KMime::Content *> &extraParts = mExtraContents.value(c);
const QVector<KMime::Content *> &extraParts = mExtraContents.value(c);
const int idx = path.midRef(1, -1).toInt();
c = (idx < extraParts.size()) ? extraParts[idx] : nullptr;
} else {
......@@ -829,7 +829,7 @@ QString NodeHelper::fromAsString(KMime::Content *node) const
return topLevel->from()->asUnicodeString();
} else {
auto realNode = std::find_if(mExtraContents.cbegin(), mExtraContents.cend(),
[node](const QList<KMime::Content *> &nodes) {
[node](const QVector<KMime::Content *> &nodes) {
return nodes.contains(node);
});
if (realNode != mExtraContents.cend()) {
......@@ -852,7 +852,7 @@ void NodeHelper::cleanExtraContent(KMime::Content *topLevelNode)
mExtraContents[topLevelNode].clear();
}
QList< KMime::Content * > NodeHelper::extraContents(KMime::Content *topLevelnode) const
QVector< KMime::Content * > NodeHelper::extraContents(KMime::Content *topLevelnode) const
{
return mExtraContents.value(topLevelnode);
}
......@@ -863,7 +863,7 @@ void NodeHelper::mergeExtraNodes(KMime::Content *node)
return;
}
const QList<KMime::Content * > extraNodes = extraContents(node);
const QVector<KMime::Content * > extraNodes = extraContents(node);
for (KMime::Content *extra : extraNodes) {
if (node->bodyIsMessage()) {
qCWarning(MIMETREEPARSER_LOG) << "Asked to attach extra content to a kmime::message, this does not make sense. Attaching to:" << node
......@@ -886,7 +886,7 @@ void NodeHelper::cleanFromExtraNodes(KMime::Content *node)
if (!node) {
return;
}
const QList<KMime::Content * > extraNodes = extraContents(node);
const QVector<KMime::Content * > extraNodes = extraContents(node);
for (KMime::Content *extra : extraNodes) {
QByteArray s = extra->encodedContent();
const auto children = node->contents();
......@@ -929,7 +929,7 @@ KMime::Message *NodeHelper::messageWithExtraContent(KMime::Content *topLevelNode
KMime::Content *NodeHelper::decryptedNodeForContent(KMime::Content *content) const
{
const QList<KMime::Content *> xc = extraContents(content);
const QVector<KMime::Content *> xc = extraContents(content);
if (!xc.empty()) {
if (xc.size() == 1) {
return xc.front();
......
......@@ -31,6 +31,7 @@
#include <QList>
#include <QMap>
#include <QSet>
#include <QVector>
class QUrl;
class QTextCodec;
......@@ -94,7 +95,7 @@ public:
void cleanExtraContent(KMime::Content *topLevelNode);
/** Get the extra nodes attached to the @param topLevelNode and all sub-nodes of @param topLevelNode */
QList<KMime::Content *> extraContents(KMime::Content *topLevelNode) const;
QVector<KMime::Content *> extraContents(KMime::Content *topLevelNode) const;
/** Return a modified message (node tree) starting from @param topLevelNode that has the original nodes and the extra nodes.
The caller has the responsibility to delete the new message.
......@@ -262,7 +263,7 @@ private:
QMap<KMime::Content *, const QTextCodec *> mOverrideCodecs;
QMap<QString, QMap<QByteArray, Interface::BodyPartMemento *> > mBodyPartMementoMap;
QMap<KMime::Content *, PartMetaData> mPartMetaDatas;
QMap<KMime::Message::Content *, QList<KMime::Content *> > mExtraContents;
QMap<KMime::Message::Content *, QVector<KMime::Content *> > mExtraContents;
AttachmentTemporaryFilesDirs *mAttachmentFilesDir = nullptr;
QMap<const KMime::Content *, QVector<MessagePartPtr> > mHeaderOverwrite;
......
......@@ -21,7 +21,7 @@
#define MIMETREEPARSER_SIMPLEOBJECTTREESOURCE_H
#include "mimetreeparser/objecttreesource.h"
#include <QVector>
#include <memory>
namespace MimeTreeParser {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment