File indexing completed on 2024-05-12 05:11:13
0001 /* 0002 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com> 0003 SPDX-FileCopyrightText: 2010 Andras Mantia <andras@kdab.com> 0004 0005 SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #include "imapsettings.h" 0009 #include "util_p.h" 0010 0011 #include <Akonadi/ServerManager> 0012 #include <QDBusConnection> 0013 0014 #include "akonadi_mime_debug.h" 0015 #include <KIO/Job> 0016 #include <KJobUiDelegate> 0017 #include <cassert> 0018 0019 namespace Util 0020 { 0021 /// Helper to sanely show an error message for a job 0022 void showJobError(KJob *job) 0023 { 0024 assert(job); 0025 // we can be called from the KJob::kill, where we are no longer a KIO::Job 0026 // so better safe than sorry 0027 auto kiojob = qobject_cast<KIO::Job *>(job); 0028 if (kiojob && kiojob->uiDelegate()) { 0029 kiojob->uiDelegate()->showErrorMessage(); 0030 } else { 0031 qCWarning(AKONADIMIME_LOG) << "Job: " << job << "There is no GUI delegate set for a kjob, and it failed with error:" << job->errorString(); 0032 } 0033 } 0034 0035 OrgKdeAkonadiImapSettingsInterface *createImapSettingsInterface(const QString &ident) 0036 { 0037 // NOTE(Andras): from kmail/util.cpp 0038 return new OrgKdeAkonadiImapSettingsInterface(Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Resource, ident), 0039 QStringLiteral("/Settings"), 0040 QDBusConnection::sessionBus()); 0041 } 0042 }