Commit 0b983809 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

implement akonadidatabasetoolsjob

parent 156c232c
Pipeline #200747 canceled with stage
in 6 minutes and 32 seconds
......@@ -13,6 +13,8 @@ target_sources(akonadidatasetools PRIVATE
akonadidatabasetoolsplugininterface.h
akonadidatabasetoolsjob.h
akonadidatabasetoolsjob.cpp
akonadidatabasetoolsutils.cpp
akonadidatabasetoolsutils.h
)
generate_export_header(akonadidatasetools BASE_NAME akonadidatasetools)
if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
......
......@@ -4,6 +4,8 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "akonadidatabasetoolsjob.h"
#include "akonadidatasetools_debug.h"
#include <QStandardPaths>
AkonadiDatabaseToolsJob::AkonadiDatabaseToolsJob(QObject *parent)
: QObject{parent}
......@@ -14,8 +16,17 @@ AkonadiDatabaseToolsJob::~AkonadiDatabaseToolsJob() = default;
bool AkonadiDatabaseToolsJob::canStart() const
{
// TODO
return false;
return processExist().isEmpty() && (mTool != AkonadiDatabaseToolsUtils::AkonadiDatabaseTool::Unknown);
}
QString AkonadiDatabaseToolsJob::processExist() const
{
return QStandardPaths::findExecutable(QStringLiteral("akonadictl"));
}
void AkonadiDatabaseToolsJob::setTool(AkonadiDatabaseToolsUtils::AkonadiDatabaseTool newTool)
{
mTool = newTool;
}
void AkonadiDatabaseToolsJob::start()
......@@ -24,5 +35,15 @@ void AkonadiDatabaseToolsJob::start()
deleteLater();
return;
}
// TODO
switch (mTool) {
case AkonadiDatabaseToolsUtils::Unknown:
qCWarning(AKONADIDATABASETOOLS_LOG) << "mTool is unknown it's a bug! ";
break;
case AkonadiDatabaseToolsUtils::Vaccum:
break;
case AkonadiDatabaseToolsUtils::Fsck:
break;
}
deleteLater();
}
......@@ -6,6 +6,7 @@
#pragma once
#include "akonadidatabasetoolsutils.h"
#include "akonadidatasetools_export.h"
#include <QObject>
......@@ -19,4 +20,9 @@ public:
Q_REQUIRED_RESULT bool canStart() const;
void start();
void setTool(AkonadiDatabaseToolsUtils::AkonadiDatabaseTool newTool);
private:
Q_REQUIRED_RESULT QString processExist() const;
AkonadiDatabaseToolsUtils::AkonadiDatabaseTool mTool = AkonadiDatabaseToolsUtils::AkonadiDatabaseTool::Unknown;
};
......@@ -5,6 +5,7 @@
*/
#include "akonadidatabasetoolsplugininterface.h"
#include "akonadidatabasetoolsjob.h"
#include "akonadidatasetools_debug.h"
#include <KActionCollection>
#include <KLocalizedString>
......@@ -23,7 +24,7 @@ void AkonadiDatabaseToolsPluginInterface::createAction(KActionCollection *ac)
auto action = new QAction(i18n("&Akonadi Vaccum..."), this);
ac->addAction(QStringLiteral("akonadivaccum"), action);
connect(action, &QAction::triggered, this, [this]() {
mTool = AkonadiDatabaseTool::Vaccum;
mTool = AkonadiDatabaseToolsUtils::AkonadiDatabaseTool::Vaccum;
slotActivated();
});
......@@ -34,7 +35,7 @@ void AkonadiDatabaseToolsPluginInterface::createAction(KActionCollection *ac)
auto action = new QAction(i18n("&Akonadi Fsck..."), this);
ac->addAction(QStringLiteral("akonadifsck"), action);
connect(action, &QAction::triggered, this, [this]() {
mTool = AkonadiDatabaseTool::Fsck;
mTool = AkonadiDatabaseToolsUtils::AkonadiDatabaseTool::Fsck;
slotActivated();
});
......@@ -50,13 +51,7 @@ void AkonadiDatabaseToolsPluginInterface::slotActivated()
void AkonadiDatabaseToolsPluginInterface::exec()
{
switch (mTool) {
case Unknown:
qCWarning(AKONADIDATABASETOOLS_LOG) << "mTool is unknown it's a bug! ";
break;
case Vaccum:
break;
case Fsck:
break;
}
AkonadiDatabaseToolsJob *job = new AkonadiDatabaseToolsJob(this);
job->setTool(mTool);
job->start();
}
......@@ -6,16 +6,12 @@
#pragma once
#include "akonadidatabasetoolsutils.h"
#include "akonadidatasetools_export.h"
#include <PimCommonAkonadi/GenericPluginInterface>
class AKONADIDATASETOOLS_EXPORT AkonadiDatabaseToolsPluginInterface : public PimCommon::GenericPluginInterface
{
public:
enum AkonadiDatabaseTool {
Unknown = 0,
Vaccum = 1,
Fsck = 2,
};
explicit AkonadiDatabaseToolsPluginInterface(QObject *parent = nullptr);
~AkonadiDatabaseToolsPluginInterface() override;
......@@ -24,5 +20,5 @@ public:
private:
void slotActivated();
AkonadiDatabaseTool mTool = AkonadiDatabaseTool::Unknown;
AkonadiDatabaseToolsUtils::AkonadiDatabaseTool mTool = AkonadiDatabaseToolsUtils::AkonadiDatabaseTool::Unknown;
};
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "akonadidatabasetoolsutils.h"
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
namespace AkonadiDatabaseToolsUtils
{
enum AkonadiDatabaseTool {
Unknown = 0,
Vaccum = 1,
Fsck = 2,
};
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment