Messagelib

attachmentfromurlutils.cpp
1 /*
2  SPDX-FileCopyrightText: 2014-2021 Laurent Montel <[email protected]>
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 
15 namespace MessageCore
16 {
17 MessageCore::AttachmentFromUrlBaseJob *AttachmentFromUrlUtils::createAttachmentJob(const QUrl &url, QObject *parent)
18 {
19  MessageCore::AttachmentFromUrlBaseJob *ajob = nullptr;
20  QMimeDatabase db;
21  if (db.mimeTypeForUrl(url).name() == QLatin1String("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-2021 The KDE developers.
Generated on Tue Nov 30 2021 23:05:45 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.