Messagelib

attachmentfromurlutils.cpp
1 /*
2  SPDX-FileCopyrightText: 2014-2023 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 }
QMimeType mimeTypeForUrl(const QUrl &url) const const
A job to load an attachment from an url.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Mar 22 2023 04:07:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.