Commit 0162b5bb authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

start to implement export kmail2rc

parent 38a0ac4a
[Defaults]
Profile=Default
[PROFILE_Default]
EmailAddress=
FullName=laurent
Organization=
ReplyAddr=
ServerType=
[General]
Default Identity=1578759321
[Identity #0]
Default Domain=linux-zym0
Disable Fcc=false
Identity=laurent
Image Location=
Inline Signature=
Name=laurent
Signature Enabled=false
uoid=1578759321
[Network]
KnownHosts=199.168.1.13
NoteHostDialogSize=596,334
Port=12
SenderID=VV
[SelectNoteFolder]
DefaultFolder=31
[$Version]
update_info=noteglobalsettings.upd:initial-noteagent-migration,noteglobalsettings.upd:selectcollection-noteagent-migration
[AgentTypeDialog]
Size=979,637
[Display]
width=260
[DownloadDialog Settings]
Height 1080=522
Width 1920=700
[Editor]
titlefont=Liberation Sans,12,-1,5,50,0,0,0,0,0,Regular
[KFileDialog Settings]
Height 1080=540
Width 1920=960
[KNoteDeleteSelectedNotesDialog]
Size=300,200
[KNoteFindDialog]
Size=461,270
[KNotePrintSelectedNotesDialog]
Size=960,656
[KNoteSimpleConfigDialog]
Size=600,400
[KNotesKeyDialog]
Size=1120,685
[KPimPrintPreviewDialog]
Size=1054,732
[Migratekde4]
Version=1
[Misc]
SystemTrayShowNotes=true
[SelectedNotefolderDialog]
Size=600,400
This diff is collapsed.
configs/globalnotesettings
configs/knotesrc
configs/kmail2rc
information/VERSION_2
information/exportdatatype.xml
......@@ -91,6 +91,7 @@ void ExportMailJobInterfaceTest::exportMailConfig_data()
void ExportMailJobInterfaceTest::exportMailConfig()
{
QFETCH(QByteArray, configpath);
qDebug() << " configpath" << configpath;
TestExportFile *file = new TestExportFile(this);
file->setPathConfig(configpath);
ExportMailJobInterfaceTestImpl *exportNote = new ExportMailJobInterfaceTestImpl(this, {Utils::StoredType::Config}, file->archiveStorage(), 1);
......@@ -98,3 +99,10 @@ void ExportMailJobInterfaceTest::exportMailConfig()
file->start();
delete exportNote;
}
QString ExportMailJobInterfaceTestImpl::convertToFullCollectionPath(const qlonglong collectionValue)
{
ResourceConverterTest converter;
return converter.convertToFullCollectionPath(collectionValue);
}
......@@ -44,6 +44,8 @@ protected:
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
Q_REQUIRED_RESULT QVector<MailCommon::MailFilter *> filters() override;
Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) override;
};
class ExportMailJobInterfaceTest : public QObject
......
......@@ -20,7 +20,6 @@
#include "exportmailjobinterface.h"
#include "importexportmailutil.h"
#include <MailCommon/MailUtil>
#include <MailCommon/FilterImporterExporter>
#include "importexportprogressindicatorbase.h"
#include "exportresourcearchivejob.h"
......@@ -38,7 +37,6 @@
#include <QTimer>
#include <QStandardPaths>
#include <QRegularExpression>
#include "resourceconverterimpl.h"
#include <KIdentityManagement/IdentityManager>
#include <KIdentityManagement/Identity>
......@@ -241,8 +239,7 @@ void ExportMailJobInterface::backupConfig()
KConfigGroup oldGroup = archiveConfig->group(str);
qint64 id = oldGroup.readEntry("topLevelCollectionId", -1);
if (id != -1) {
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(id);
const QString realPath = convertToFullCollectionPath(id);
if (!realPath.isEmpty()) {
oldGroup.writeEntry(QStringLiteral("topLevelCollectionId"), realPath);
}
......@@ -271,8 +268,7 @@ void ExportMailJobInterface::backupConfig()
const int collectionId = str.rightRef(str.length() - archiveGroupPattern.length()).toInt(&found);
if (found) {
KConfigGroup oldGroup = archiveConfig->group(str);
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(collectionId);
const QString realPath = convertToFullCollectionPath(collectionId);
if (!realPath.isEmpty()) {
const QString collectionPath(archiveGroupPattern + realPath);
KConfigGroup newGroup(archiveConfig, collectionPath);
......@@ -304,8 +300,7 @@ void ExportMailJobInterface::backupConfig()
const int collectionId = str.rightRef(str.length() - templateGroupPattern.length()).toInt(&found);
if (found) {
KConfigGroup oldGroup = templateConfig->group(str);
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(collectionId);
const QString realPath = convertToFullCollectionPath(collectionId);
if (!realPath.isEmpty()) {
KConfigGroup newGroup(templateConfig, templateGroupPattern + realPath);
oldGroup.copyTo(&newGroup);
......@@ -361,8 +356,7 @@ void ExportMailJobInterface::backupConfig()
if (found) {
KConfigGroup oldGroup = kmailConfig->group(str);
ImportExportMailUtil::cleanupFolderSettings(oldGroup);
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(collectionId);
const QString realPath = convertToFullCollectionPath(collectionId);
if (!realPath.isEmpty()) {
KConfigGroup newGroup(kmailConfig, folderGroupPattern + realPath);
oldGroup.copyTo(&newGroup);
......@@ -377,8 +371,7 @@ void ExportMailJobInterface::backupConfig()
if (composerGroup.hasKey(previousStr)) {
const int collectionId = composerGroup.readEntry(previousStr, -1);
if (collectionId != -1) {
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(collectionId);
const QString realPath = convertToFullCollectionPath(collectionId);
composerGroup.writeEntry(previousStr, realPath);
}
}
......@@ -391,8 +384,7 @@ void ExportMailJobInterface::backupConfig()
if (generalGroup.hasKey(startupFolderStr)) {
const int collectionId = generalGroup.readEntry(startupFolderStr, -1);
if (collectionId != -1) {
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(collectionId);
const QString realPath = convertToFullCollectionPath(collectionId);
generalGroup.writeEntry(startupFolderStr, realPath);
}
}
......@@ -408,8 +400,7 @@ void ExportMailJobInterface::backupConfig()
const int collectionId = str.rightRef(str.length() - storageModelSelectedPattern.length()).toInt(&found);
const QString oldValue = storageGroup.readEntry(str);
if (found) {
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(collectionId);
const QString realPath = convertToFullCollectionPath(collectionId);
if (!realPath.isEmpty()) {
storageGroup.writeEntry(QStringLiteral("%1%2").arg(storageModelSelectedPattern, realPath), oldValue);
storageGroup.deleteEntry(str);
......@@ -548,20 +539,17 @@ void ExportMailJobInterface::backupIdentity()
KConfigGroup group = identityConfig->group(account);
const QString fcc = QStringLiteral("Fcc");
if (group.hasKey(fcc)) {
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(group.readEntry(fcc).toLongLong());
const QString realPath = convertToFullCollectionPath(group.readEntry(fcc).toLongLong());
group.writeEntry(fcc, realPath);
}
const QString draft = QStringLiteral("Drafts");
if (group.hasKey(draft)) {
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(group.readEntry(draft).toLongLong());
const QString realPath = convertToFullCollectionPath(group.readEntry(draft).toLongLong());
group.writeEntry(draft, realPath);
}
const QString templates = QStringLiteral("Templates");
if (group.hasKey(templates)) {
ResourceConverterImpl resourceConverter;
const QString realPath = resourceConverter.convertToFullCollectionPath(group.readEntry(templates).toLongLong());
const QString realPath = convertToFullCollectionPath(group.readEntry(templates).toLongLong());
group.writeEntry(templates, realPath);
}
const QString vcard = QStringLiteral("VCardFile");
......
......@@ -49,6 +49,7 @@ protected:
virtual void exportArchiveResource() = 0;
virtual void backupResources() = 0;
virtual QVector<MailCommon::MailFilter *> filters() = 0;
virtual Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) = 0;
void slotCheckBackupResources();
private:
void slotCheckBackupIdentity();
......
......@@ -184,3 +184,10 @@ QVector<MailCommon::MailFilter *> ExportMailJobInterfaceImpl::filters()
{
return MailCommon::FilterManager::instance()->filters();
}
QString ExportMailJobInterfaceImpl::convertToFullCollectionPath(const qlonglong collectionValue)
{
ResourceConverterImpl converter;
return converter.convertToFullCollectionPath(collectionValue);
}
......@@ -42,6 +42,7 @@ protected:
void backupResources() override;
Q_REQUIRED_RESULT Akonadi::Collection::Id convertFolderPathToCollectionId(const QString &path) override;
Q_REQUIRED_RESULT QVector<MailCommon::MailFilter *> filters() override;
Q_REQUIRED_RESULT QString convertToFullCollectionPath(const qlonglong collectionValue) override;
private:
void slotCheckBackupMails();
void slotWriteNextArchiveResource();
......
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