Messagelib

attachmentfromurlutils.cpp
1/*
2 SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "attachmentfromurlutils.h"
8#include "MessageCore/MessageCoreSettings"
9#include "attachmentfromfolderjob.h"
10#include "attachmentfromurljob.h"
11#include "messagecore_debug.h"
12
13#include <QMimeDatabase>
14
15namespace MessageCore
16{
17MessageCore::AttachmentFromUrlBaseJob *AttachmentFromUrlUtils::createAttachmentJob(const QUrl &url, QObject *parent)
18{
19 MessageCore::AttachmentFromUrlBaseJob *ajob = nullptr;
21 if (db.mimeTypeForUrl(url).name() == QLatin1StringView("inode/directory")) {
22 qCDebug(MESSAGECORE_LOG) << "Creating attachment from folder";
23 ajob = new MessageCore::AttachmentFromFolderJob(url, parent);
24 } else {
25 ajob = new MessageCore::AttachmentFromUrlJob(url, parent);
26 qCDebug(MESSAGECORE_LOG) << "Creating attachment from file";
27 }
28 if (MessageCore::MessageCoreSettings::maximumAttachmentSize() > 0) {
29 ajob->setMaximumAllowedSize(MessageCore::MessageCoreSettings::maximumAttachmentSize());
30 }
31 return ajob;
32}
33}
A job to load an attachment from an url.
QMimeType mimeTypeForUrl(const QUrl &url) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.