Commit 482e340d authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to autotest resource too

parent 93bc60d3
......@@ -37,7 +37,7 @@ protected:
void convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey) override;
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource();
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
private:
void slotWriteNextArchiveResource();
void slotAddressbookJobTerminated();
......
......@@ -36,7 +36,7 @@ protected:
virtual void exportArchiveResource() = 0;
void slotCheckBackupConfig();
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
private:
void slotCheckBackupResource();
......
......@@ -19,8 +19,6 @@
#include "exportalarmjobinterfaceimpl.h"
#include <AkonadiCore/AgentManager>
#include <KLocalizedString>
#include <MailCommon/MailUtil>
......@@ -43,6 +41,11 @@ ExportAlarmJobInterfaceImpl::~ExportAlarmJobInterfaceImpl()
{
}
QVector<Utils::AkonadiInstanceInfo> ExportAlarmJobInterfaceImpl::listOfResource()
{
return Utils::listOfResource();
}
void ExportAlarmJobInterfaceImpl::slotAlarmJobTerminated()
{
if (wasCanceled()) {
......@@ -55,11 +58,9 @@ void ExportAlarmJobInterfaceImpl::slotAlarmJobTerminated()
void ExportAlarmJobInterfaceImpl::slotWriteNextArchiveResource()
{
Akonadi::AgentManager *manager = Akonadi::AgentManager::self();
const Akonadi::AgentInstance::List list = manager->instances();
if (mIndexIdentifier < list.count()) {
const Akonadi::AgentInstance agent = list.at(mIndexIdentifier);
const QString identifier = agent.identifier();
if (mIndexIdentifier < mAkonadiInstanceInfo.count()) {
const Utils::AkonadiInstanceInfo agent = mAkonadiInstanceInfo.at(mIndexIdentifier);
const QString identifier = agent.identifier;
if (identifier.contains(QLatin1String("akonadi_kalarm_dir_resource_"))) {
const QString archivePath = Utils::alarmPath() + identifier + QLatin1Char('/');
......@@ -99,6 +100,7 @@ void ExportAlarmJobInterfaceImpl::slotWriteNextArchiveResource()
void ExportAlarmJobInterfaceImpl::exportArchiveResource()
{
mAkonadiInstanceInfo = listOfResource();
QTimer::singleShot(0, this, &ExportAlarmJobInterfaceImpl::slotWriteNextArchiveResource);
}
......
......@@ -36,6 +36,7 @@ protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
private:
void slotAlarmJobTerminated();
void slotWriteNextArchiveResource();
......
......@@ -41,6 +41,12 @@ void ExportAlarmJobInterfaceTestImpl::exportArchiveResource()
qDebug() << " not implement yet";
}
QVector<Utils::AkonadiInstanceInfo> ExportAlarmJobInterfaceTestImpl::listOfResource()
{
//TODO
return {};
}
Akonadi::Collection::Id ExportAlarmJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path)
{
ResourceConverterTest resourceConverterTest;
......@@ -74,3 +80,5 @@ void ExportAlarmJobInterfaceTest::exportAlarmConfig()
file->start();
delete exportNote;
}
......@@ -35,6 +35,7 @@ protected:
void exportArchiveResource() override;
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
};
class ExportAlarmJobInterfaceTest : public QObject
......
......@@ -57,6 +57,12 @@ void ExportCalendarsJobInterfaceTestImpl::exportResourceToArchive(const QString
//TODO implement it
}
QVector<Utils::AkonadiInstanceInfo> ExportCalendarsJobInterfaceTestImpl::listOfResource()
{
//TODO
return {};
}
void ExportCalendarsJobInterfaceTestImpl::convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey)
{
ResourceConverterTest converter;
......@@ -86,3 +92,5 @@ void ExportCalendarsJobInterfaceTest::exportCalendarConfig()
delete exportNote;
}
......@@ -37,6 +37,7 @@ protected:
Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) override;
void convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
};
class ExportCalendarsJobInterfaceTest : public QObject
......
......@@ -82,6 +82,12 @@ void ExportMailJobInterfaceTestImpl::exportResourceToArchive(const QString &arch
qDebug() << " not implement yet";
}
QVector<Utils::AkonadiInstanceInfo> ExportMailJobInterfaceTestImpl::listOfResource()
{
//TODO
return {};
}
ExportMailJobInterfaceTest::ExportMailJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......@@ -113,3 +119,5 @@ QString ExportMailJobInterfaceTestImpl::convertToFullCollectionPath(const qlongl
return converter.convertToFullCollectionPath(collectionValue);
}
......@@ -47,6 +47,7 @@ protected:
Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
};
class ExportMailJobInterfaceTest : public QObject
......
......@@ -46,6 +46,11 @@ void ExportNotesJobInterfaceTestImpl::exportArchiveResource()
qDebug() << " not implement yet";
}
QVector<Utils::AkonadiInstanceInfo> ExportNotesJobInterfaceTestImpl::listOfResource()
{
//TODO
return {};
}
void ExportNotesJobInterfaceTestImpl::exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier)
{
......@@ -82,3 +87,4 @@ void ExportNotesJobInterfaceTest::exportNoteConfig()
delete exportNote;
}
......@@ -36,6 +36,7 @@ protected:
void convertCollectionIdsToRealPath(KConfigGroup &selectFolderNoteGroup, const QString &selectFolderNoteGroupStr) override;
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
};
class ExportNotesJobInterfaceTest : public QObject
......
......@@ -39,6 +39,7 @@ protected:
virtual Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) = 0;
virtual void convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey) = 0;
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() =0;
private:
void slotCheckBackupResource();
......
......@@ -19,7 +19,6 @@
#include "exportcalendarjobinterfaceimpl.h"
#include <MailCommon/MailUtil>
#include <AkonadiCore/AgentManager>
#include <KLocalizedString>
......@@ -44,8 +43,14 @@ ExportCalendarJobInterfaceImpl::~ExportCalendarJobInterfaceImpl()
{
}
QVector<Utils::AkonadiInstanceInfo> ExportCalendarJobInterfaceImpl::listOfResource()
{
return Utils::listOfResource();
}
void ExportCalendarJobInterfaceImpl::exportArchiveResource()
{
mAkonadiInstanceInfo = listOfResource();
QTimer::singleShot(0, this, &ExportCalendarJobInterfaceImpl::slotWriteNextArchiveResource);
}
......@@ -73,11 +78,9 @@ void ExportCalendarJobInterfaceImpl::slotCalendarJobTerminated()
void ExportCalendarJobInterfaceImpl::slotWriteNextArchiveResource()
{
Akonadi::AgentManager *manager = Akonadi::AgentManager::self();
const Akonadi::AgentInstance::List list = manager->instances();
if (mIndexIdentifier < list.count()) {
const Akonadi::AgentInstance agent = list.at(mIndexIdentifier);
const QString identifier = agent.identifier();
if (mIndexIdentifier < mAkonadiInstanceInfo.count()) {
const Utils::AkonadiInstanceInfo agent = mAkonadiInstanceInfo.at(mIndexIdentifier);
const QString identifier = agent.identifier;
if (identifier.contains(QLatin1String("akonadi_icaldir_resource_"))) {
const QString archivePath = Utils::calendarPath() + identifier + QLatin1Char('/');
......
......@@ -37,6 +37,7 @@ protected:
Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) override;
void convertCollectionListToRealPath(KConfigGroup &group, const QString &currentKey) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
private:
void slotCalendarJobTerminated();
void slotWriteNextArchiveResource();
......
......@@ -115,6 +115,7 @@ void ExportMailJobInterface::slotCheckBackupConfig()
void ExportMailJobInterface::slotCheckBackupMails()
{
mAkonadiInstanceInfo = listOfResource();
if (checkBackupType(Utils::Mails)) {
increaseProgressDialog();
setProgressDialogLabel(i18n("Backing up Mails..."));
......
......@@ -52,6 +52,7 @@ protected:
virtual Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) = 0;
void slotCheckBackupResources();
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
private:
void slotCheckBackupIdentity();
void slotCheckBackupMailTransport();
......
......@@ -25,7 +25,6 @@
#include <KMime/Message>
#include "importexportprogressindicatorbase.h"
#include <AkonadiCore/AgentManager>
#include <AkonadiCore/Collection>
#include <MailTransport/TransportManager>
......@@ -73,16 +72,14 @@ void ExportMailJobInterfaceImpl::exportArchiveResource()
void ExportMailJobInterfaceImpl::slotWriteNextArchiveResource()
{
Akonadi::AgentManager *manager = Akonadi::AgentManager::self();
const Akonadi::AgentInstance::List list = manager->instances();
if (mIndexIdentifier < list.count()) {
const Akonadi::AgentInstance agent = list.at(mIndexIdentifier);
const QStringList capabilities(agent.type().capabilities());
if (agent.type().mimeTypes().contains(KMime::Message::mimeType())) {
if (mIndexIdentifier < mAkonadiInstanceInfo.count()) {
const Utils::AkonadiInstanceInfo agent = mAkonadiInstanceInfo.at(mIndexIdentifier);
const QStringList capabilities(agent.capabilities);
if (agent.mimeTypes.contains(KMime::Message::mimeType())) {
if (capabilities.contains(QLatin1String("Resource"))
&& !capabilities.contains(QLatin1String("Virtual"))
&& !capabilities.contains(QLatin1String("MailTransport"))) {
const QString identifier = agent.identifier();
const QString identifier = agent.identifier;
if (identifier.contains(QLatin1String("akonadi_maildir_resource_"))
|| identifier.contains(QLatin1String("akonadi_mixedmaildir_resource_"))) {
const QString archivePath = Utils::mailsPath() + identifier + QLatin1Char('/');
......@@ -135,15 +132,13 @@ void ExportMailJobInterfaceImpl::backupResources()
{
setProgressDialogLabel(i18n("Backing up resources..."));
Akonadi::AgentManager *manager = Akonadi::AgentManager::self();
const Akonadi::AgentInstance::List list = manager->instances();
for (const Akonadi::AgentInstance &agent : list) {
const QStringList capabilities(agent.type().capabilities());
if (agent.type().mimeTypes().contains(KMime::Message::mimeType())) {
for (const Utils::AkonadiInstanceInfo &agent : qAsConst(mAkonadiInstanceInfo)) {
const QStringList capabilities(agent.capabilities);
if (agent.mimeTypes.contains(KMime::Message::mimeType())) {
if (capabilities.contains(QLatin1String("Resource"))
&& !capabilities.contains(QLatin1String("Virtual"))
&& !capabilities.contains(QLatin1String("MailTransport"))) {
const QString identifier = agent.identifier();
const QString identifier = agent.identifier;
//Store just pop3/imap/kolab/gmail account. Store other config when we copy data.
if (identifier.contains(QLatin1String("pop3")) || identifier.contains(QLatin1String("imap"))
|| identifier.contains(QLatin1String("_kolab_")) || identifier.contains(QLatin1String("_gmail_"))) {
......@@ -196,3 +191,9 @@ QString ExportMailJobInterfaceImpl::convertToFullCollectionPath(const qlonglong
ResourceConverterImpl converter;
return converter.convertToFullCollectionPath(collectionValue);
}
QVector<Utils::AkonadiInstanceInfo> ExportMailJobInterfaceImpl::listOfResource()
{
return Utils::listOfResource();
}
......@@ -44,6 +44,7 @@ protected:
Q_REQUIRED_RESULT QVector<MailCommon::MailFilter *> filters() override;
Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
private:
void slotCheckBackupMails();
void slotWriteNextArchiveResource();
......@@ -51,6 +52,7 @@ private:
QDateTime mArchiveTime = QDateTime::currentDateTime();
int mIndexIdentifier = 0;
};
#endif // ExportMailJob_H
......@@ -39,6 +39,7 @@ protected:
virtual void exportArchiveResource() = 0;
virtual void convertCollectionIdsToRealPath(KConfigGroup &selectFolderNoteGroup, const QString &selectFolderNoteGroupStr) = 0;
virtual void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) = 0;
virtual Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() = 0;
private:
void slotCheckBackupResource();
......
......@@ -21,7 +21,6 @@
#include "exportresourcearchivejob.h"
#include "resourceconverterimpl.h"
#include <AkonadiCore/AgentManager>
#include <MailCommon/MailUtil>
#include <KLocalizedString>
#include <KZip>
......@@ -41,6 +40,11 @@ ExportNotesJobInterfaceImpl::~ExportNotesJobInterfaceImpl()
{
}
QVector<Utils::AkonadiInstanceInfo> ExportNotesJobInterfaceImpl::listOfResource()
{
return Utils::listOfResource();
}
void ExportNotesJobInterfaceImpl::slotNoteJobTerminated()
{
if (wasCanceled()) {
......@@ -53,11 +57,9 @@ void ExportNotesJobInterfaceImpl::slotNoteJobTerminated()
void ExportNotesJobInterfaceImpl::slotWriteNextArchiveResource()
{
Akonadi::AgentManager *manager = Akonadi::AgentManager::self();
const Akonadi::AgentInstance::List list = manager->instances();
if (mIndexIdentifier < list.count()) {
const Akonadi::AgentInstance agent = list.at(mIndexIdentifier);
const QString identifier = agent.identifier();
if (mIndexIdentifier < mAkonadiInstanceInfo.count()) {
const Utils::AkonadiInstanceInfo agent = mAkonadiInstanceInfo.at(mIndexIdentifier);
const QString identifier = agent.identifier;
if (identifier.contains(QLatin1String("akonadi_akonotes_resource_"))) {
const QString archivePath = Utils::notePath() + identifier + QLatin1Char('/');
......@@ -85,7 +87,8 @@ void ExportNotesJobInterfaceImpl::slotWriteNextArchiveResource()
void ExportNotesJobInterfaceImpl::exportArchiveResource()
{
slotNoteJobTerminated();
mAkonadiInstanceInfo = listOfResource();
QTimer::singleShot(0, this, &ExportNotesJobInterfaceImpl::slotWriteNextArchiveResource);
}
void ExportNotesJobInterfaceImpl::convertCollectionIdsToRealPath(KConfigGroup &selectFolderNoteGroup, const QString &selectFolderNoteGroupStr)
......
......@@ -36,6 +36,7 @@ protected:
void convertCollectionIdsToRealPath(KConfigGroup &selectFolderNoteGroup, const QString &selectFolderNoteGroupStr) override;
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
void exportResourceToArchive(const QString &archivePath, const QString &url, const QString &identifier) override;
Q_REQUIRED_RESULT QVector<Utils::AkonadiInstanceInfo> listOfResource() override;
private:
void slotNoteJobTerminated();
void slotWriteNextArchiveResource();
......
......@@ -262,6 +262,7 @@ QVector<Utils::AkonadiInstanceInfo> Utils::listOfResource()
Utils::AkonadiInstanceInfo info;
info.identifier = agent.identifier();
info.mimeTypes = agent.type().mimeTypes();
info.capabilities = agent.type().capabilities();
instanceInfoList.append(info);
}
return instanceInfoList;
......
......@@ -40,6 +40,7 @@ namespace Utils {
struct AkonadiInstanceInfo {
QString identifier;
QStringList mimeTypes;
QStringList capabilities;
};
enum StoredType {
None = 0,
......
Markdown is supported
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