aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Winter <[email protected]>2017-07-30 09:29:16 -0400
committerAllen Winter <[email protected]>2017-07-30 09:29:16 -0400
commit3924b216bf0cb9321fd5851d94415572a588d6b7 (patch)
treea68cd9dfebc512424c089a99504d308d15375597
parent26d4aeab983d38d43d32a8b658c26ae6bfb054e0 (diff)
src/icalimporter.cpp - add support for akonadi instances
Differential Revision: https://phabricator.kde.org/D6981
-rw-r--r--src/icalimporter.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/icalimporter.cpp b/src/icalimporter.cpp
index bf7a5c5..1be1c17 100644
--- a/src/icalimporter.cpp
+++ b/src/icalimporter.cpp
@@ -22,25 +22,16 @@
#include "icalimporter.h"
#include "icalimporter_p.h"
#include "utils_p.h"
+#include "akonadicalendar_debug.h"
-#include <agentmanager.h>
-#include <agentinstancecreatejob.h>
+#include <AkonadiCore/ServerManager>
+#include <AkonadiCore/AgentInstanceCreateJob>
+#include <AkonadiCore/AgentManager>
-#include <kcalcore/filestorage.h>
-#include <kcalcore/memorycalendar.h>
-#include <kcalcore/event.h>
-#include <kcalcore/todo.h>
-#include <kcalcore/journal.h>
+#include <KCalCore/FileStorage>
-#include <KJob>
-#include <KLocalizedString>
-#include "akonadicalendar_debug.h"
-#include <KDateTime>
-#include <KIO/JobClasses>
-#include <KIO/Scheduler>
+#include <KIO/Job>
-#include <QUrl>
-#include <QFile>
#include <QDBusInterface>
#include <QTemporaryFile>
@@ -61,7 +52,6 @@ ICalImporter::Private::Private(IncidenceChanger *changer,
}
connect(m_changer, &IncidenceChanger::createFinished,
this, &ICalImporter::Private::onIncidenceCreated);
-
}
ICalImporter::Private::~Private()
@@ -101,7 +91,9 @@ void ICalImporter::Private::setErrorMessage(const QString &message)
void ICalImporter::Private::resourceCreated(KJob *job)
{
- Akonadi::AgentInstanceCreateJob *createjob = qobject_cast<Akonadi::AgentInstanceCreateJob *>(job);
+ Akonadi::AgentInstanceCreateJob *createjob =
+ qobject_cast<Akonadi::AgentInstanceCreateJob *>(job);
+
Q_ASSERT(createjob);
m_working = false;
if (createjob->error()) {
@@ -111,8 +103,11 @@ void ICalImporter::Private::resourceCreated(KJob *job)
}
Akonadi::AgentInstance instance = createjob->instance();
- QDBusInterface iface(QStringLiteral("org.freedesktop.Akonadi.Resource.%1").arg(instance.identifier()), QStringLiteral("/Settings"));
+ const QString service =
+ Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Resource,
+ instance.identifier());
+ QDBusInterface iface(service, QStringLiteral("/Settings"));
if (!iface.isValid()) {
setErrorMessage(i18n("Failed to obtain D-Bus interface for remote configuration."));
emit q->importIntoNewFinished(false);
@@ -166,7 +161,9 @@ bool ICalImporter::importIntoNewResource(const QString &filename)
d->m_working = true;
- Akonadi::AgentType type = Akonadi::AgentManager::self()->type(QStringLiteral("akonadi_ical_resource"));
+ Akonadi::AgentType type =
+ Akonadi::AgentManager::self()->type(QStringLiteral("akonadi_ical_resource"));
+
Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob(type, this);
job->setProperty("path", filename);
connect(job, &KJob::result, d, &Private::resourceCreated);
@@ -218,9 +215,11 @@ bool ICalImporter::importIntoExistingResource(const QUrl &url, Akonadi::Collecti
if (!collection.isValid()) {
int dialogCode;
- const QStringList mimeTypes = QStringList() << KCalCore::Event::eventMimeType() << KCalCore::Todo::todoMimeType()
- << KCalCore::Journal::journalMimeType();
- collection = CalendarUtils::selectCollection(nullptr, dialogCode /*by-ref*/, mimeTypes);
+ const QStringList mimeTypes = QStringList()
+ << KCalCore::Event::eventMimeType()
+ << KCalCore::Todo::todoMimeType()
+ << KCalCore::Journal::journalMimeType();
+ collection = CalendarUtils::selectCollection(nullptr, dialogCode/*by-ref*/, mimeTypes);
}
if (!collection.isValid()) {
@@ -250,7 +249,8 @@ bool ICalImporter::importIntoExistingResource(const QUrl &url, Akonadi::Collecti
} else {
d->m_collection = collection;
KIO::StoredTransferJob *job = KIO::storedGet(url);
- connect(job, SIGNAL(data(KIO::Job*,QByteArray)), d, SLOT(remoteDownloadFinished(KIO::Job*,QByteArray)));
+ connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
+ d, SLOT(remoteDownloadFinished(KIO::Job*,QByteArray)));
}
d->m_working = true;