Commit 5d8cbcc2 authored by Laurent Montel's avatar Laurent Montel 😁

Remove akonadidatabase import/export as it was never implemented and not really possible to do it

parent fed9a47f
......@@ -56,7 +56,6 @@ set(pimsettingexporter_LIB_SRCS
abstractimportexportjob.cpp
pimsettingexporterkernel.cpp
utils.cpp
akonadidatabase.cpp
archivestorage.cpp
synchronizeresourcejob.cpp
pimsettingsbackuprestore.cpp
......
......@@ -579,9 +579,6 @@ void AbstractImportExportJob::initializeListStep()
if (mTypeSelected & Utils::Config) {
mListStep << Utils::Config;
}
if (mTypeSelected & Utils::AkonadiDb) {
mListStep << Utils::AkonadiDb;
}
if (mTypeSelected & Utils::Data) {
mListStep << Utils::Data;
}
......
/*
Copyright (C) 2012-2017 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "akonadidatabase.h"
#include <AkonadiCore/ServerManager>
#include <QSettings>
AkonadiDataBase::AkonadiDataBase()
{
init();
}
AkonadiDataBase::~AkonadiDataBase()
{
}
QStringList AkonadiDataBase::options() const
{
return m_dboptions;
}
QString AkonadiDataBase::driver() const
{
return m_dbdriver;
}
QString AkonadiDataBase::name() const
{
return m_dbname;
}
void AkonadiDataBase::init()
{
const QString serverConfigFile = Akonadi::ServerManager::serverConfigFilePath(Akonadi::ServerManager::ReadWrite);
QSettings settings(serverConfigFile, QSettings::IniFormat);
m_dbdriver = settings.value(QStringLiteral("General/Driver"), QStringLiteral("QMYSQL")).toString();
settings.beginGroup(m_dbdriver);
if (m_dbdriver == QLatin1String("QPSQL")) {
m_dbname = settings.value(QStringLiteral("Name"), QStringLiteral("akonadi")).toString();
m_dboptions.append(QLatin1String("--host=") + settings.value(QStringLiteral("Host"), QString()).toString());
// If the server is started by the user, we don't need to know the username/password.
bool startServer = settings.value(QStringLiteral("StartServer"), QStringLiteral("true")).toBool();
if (!startServer) {
// TODO: postgres will always ask for the user password ! implement .pgpass
m_dboptions.append(QLatin1String("--username=") + settings.value(QStringLiteral("User"), QString()).toString());
}
settings.endGroup();
} else if (m_dbdriver == QLatin1String("QMYSQL")) {
m_dbname = settings.value(QStringLiteral("Name"), QStringLiteral("akonadi")).toString();
// If the server is started by the user, we don't need to know the username/password.
bool startServer = settings.value(QStringLiteral("StartServer"), QString()).toBool();
if (!startServer) {
m_dboptions.append(QLatin1String("--host=") + settings.value(QStringLiteral("Host"), QString()).toString());
m_dboptions.append(QLatin1String("--user=") + settings.value(QStringLiteral("User"), QString()).toString());
m_dboptions.append(QLatin1String("--password=") + settings.value(QStringLiteral("Password"), QString()).toString());
} else {
const QString options = settings.value(QStringLiteral("Options"), QString()).toString();
const QStringList list = options.split(QLatin1Char('='));
m_dboptions.append(QLatin1String("--socket=") + list.at(1));
}
settings.endGroup();
}
}
/*
Copyright (C) 2012-2017 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef AKONADIDATABASE_H
#define AKONADIDATABASE_H
#include <QString>
#include <QStringList>
class AkonadiDataBase
{
public:
AkonadiDataBase();
~AkonadiDataBase();
QStringList options() const;
QString driver() const;
QString name() const;
private:
void init();
QStringList m_dboptions;
QString m_dbdriver;
QString m_dbname;
};
#endif // AKONADIDATABASE_H
......@@ -18,7 +18,6 @@
*/
#include "exportmailjob.h"
#include "akonadidatabase.h"
#include "MailCommon/MailUtil"
#include "MailCommon/FilterManager"
......
......@@ -18,7 +18,6 @@
*/
#include "importmailjob.h"
#include "akonadidatabase.h"
#include "archivestorage.h"
#include "MailCommon/FilterManager"
......@@ -99,8 +98,6 @@ void ImportMailJob::slotNextStep()
restoreIdentity();
} else if (type == Utils::Config) {
restoreConfig();
} else if (type == Utils::AkonadiDb) {
restoreAkonadiDb();
} else {
qCDebug(PIMSETTINGEXPORTERCORE_LOG) << Q_FUNC_INFO << " not supported type " << type;
slotNextStep();
......@@ -968,72 +965,6 @@ QString ImportMailJob::uniqueIdentityName(const QString &name)
return newName;
}
void ImportMailJob::restoreAkonadiDb()
{
const QString akonadiDbPath(Utils::akonadiPath() + QLatin1String("akonadidatabase.sql"));
if (!mFileList.contains(akonadiDbPath)) {
Q_EMIT error(i18n("Akonadi database file could not be found in the archive."));
} else {
Q_EMIT info(i18n("Restore Akonadi Database..."));
const KArchiveEntry *akonadiDataBaseEntry = mArchiveDirectory->entry(akonadiDbPath);
if (akonadiDataBaseEntry && akonadiDataBaseEntry->isFile()) {
const KArchiveFile *akonadiDataBaseFile = static_cast<const KArchiveFile *>(akonadiDataBaseEntry);
QTemporaryFile tmp;
tmp.open();
akonadiDataBaseFile->copyTo(tmp.fileName());
/* Restore the database */
AkonadiDataBase akonadiDataBase;
const QString dbDriver(akonadiDataBase.driver());
QStringList params;
QString dbRestoreAppName;
if (dbDriver == QLatin1String("QPSQL")) {
dbRestoreAppName = QStringLiteral("pg_restore");
params << akonadiDataBase.options()
<< QStringLiteral("--dbname=") + akonadiDataBase.name()
<< QStringLiteral("--format=custom")
<< QStringLiteral("--clean")
<< QStringLiteral("--no-owner")
<< QStringLiteral("--no-privileges")
<< tmp.fileName();
} else if (dbDriver == QLatin1String("QMYSQL")) {
dbRestoreAppName = QStringLiteral("mysql");
params << akonadiDataBase.options()
<< QStringLiteral("--database=") + akonadiDataBase.name();
} else {
Q_EMIT error(i18n("Database driver \"%1\" not supported.", dbDriver));
slotNextStep();
return;
}
const QString dbRestoreApp = QStandardPaths::findExecutable(dbRestoreAppName);
if (dbRestoreApp.isEmpty()) {
Q_EMIT error(i18n("Could not find \"%1\" necessary to restore database.", dbRestoreAppName));
slotNextStep();
return;
}
KProcess *proc = new KProcess(this);
proc->setProgram(QStandardPaths::findExecutable(dbRestoreApp), params);
proc->setStandardInputFile(tmp.fileName());
const int result = proc->execute();
delete proc;
if (result != 0) {
Q_EMIT error(i18n("Failed to restore Akonadi Database."));
slotNextStep();
return;
}
}
Q_EMIT info(i18n("Akonadi Database restored."));
}
slotNextStep();
}
void ImportMailJob::importArchiveConfig(const KArchiveFile *archiveconfiguration, const QString &archiveconfigurationrc, const QString &filename, const QString &prefix)
{
copyToFile(archiveconfiguration, archiveconfigurationrc, filename, prefix);
......
......@@ -47,7 +47,6 @@ private:
void restoreMails();
void restoreConfig();
void restoreIdentity();
void restoreAkonadiDb();
void importTemplatesConfig(const KArchiveFile *templatesconfiguration, const QString &templatesconfigurationrc, const QString &filename, const QString &prefix);
void importKmailConfig(const KArchiveFile *kmailsnippet, const QString &kmail2rc, const QString &filename, const QString &prefix);
......
......@@ -369,8 +369,6 @@ QString Utils::storedTypeToI18n(StoredType type)
return i18n("Resources");
case Config:
return i18n("Config");
case AkonadiDb:
return i18n("Akonadi Database");
case Data:
return i18n("Data");
}
......
......@@ -49,8 +49,7 @@ enum StoredType {
MailTransport = 4,
Resources = 8,
Config = 16,
AkonadiDb = 32,
Data = 64
Data = 32
//TODO add more type to import/export
};
Q_DECLARE_FLAGS(StoredTypes, StoredType)
......
......@@ -74,9 +74,6 @@ Utils::StoredTypes TemplateSelection::loadStoredTypes(const QDomElement &element
} else if (tagName == QLatin1String("data")) {
types |= Utils::Data;
numberOfStep++;
} else if (tagName == QLatin1String("akonadidb")) {
types |= Utils::AkonadiDb;
numberOfStep++;
}
}
n = n.nextSibling();
......@@ -155,11 +152,6 @@ void TemplateSelection::saveParameters(Utils::StoredTypes type, QDomElement &ele
QDomElement tag = mDocument.createElement(QStringLiteral("data"));
elem.appendChild(tag);
}
if (type & Utils::AkonadiDb) {
QDomElement tag = mDocument.createElement(QStringLiteral("akonadidb"));
elem.appendChild(tag);
}
}
void TemplateSelection::createTemplate(const QHash<Utils::AppsType, Utils::importExportParameters> &stored)
......
......@@ -102,7 +102,6 @@ bool ShowArchiveStructureDialog::fillTree()
searchArchiveElement(Utils::configsPath(), topDirectory, Utils::storedTypeToI18n(Utils::Config));
searchArchiveElement(Utils::transportsPath(), topDirectory, Utils::storedTypeToI18n(Utils::MailTransport));
searchArchiveElement(Utils::dataPath(), topDirectory, Utils::storedTypeToI18n(Utils::Data));
searchArchiveElement(Utils::akonadiPath(), topDirectory, Utils::storedTypeToI18n(Utils::AkonadiDb));
}
delete zip;
return result;
......
......@@ -235,13 +235,6 @@ void SelectionTypeTreeWidget::createSubItem(QTreeWidgetItem *parent, Utils::Stor
item->setData(0, action, type);
break;
}
case Utils::AkonadiDb: {
QTreeWidgetItem *item = new QTreeWidgetItem(parent);
item->setText(0, Utils::storedTypeToI18n(Utils::AkonadiDb));
item->setCheckState(0, Qt::Checked);
item->setData(0, action, type);
break;
}
case Utils::Data: {
QTreeWidgetItem *item = new QTreeWidgetItem(parent);
item->setText(0, Utils::storedTypeToI18n(Utils::Data));
......
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