diff --git a/core/abstractimportexportjob.h b/core/abstractimportexportjob.h index d009984..25ee348 100644 --- a/core/abstractimportexportjob.h +++ b/core/abstractimportexportjob.h @@ -1,138 +1,137 @@ /* Copyright (C) 2012-2019 Montel Laurent 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 ABSTRACTIMPORTEXPORTJOB_H #define ABSTRACTIMPORTEXPORTJOB_H #include #include "utils.h" #include #include "pimdataexporter_export.h" #include -#include class ArchiveStorage; class KArchiveDirectory; class QTemporaryDir; class KZip; class KArchiveFile; class KArchiveEntry; namespace KIdentityManagement { class Identity; class IdentityManager; } namespace PimCommon { class CreateResource; } class ImportExportProgressIndicatorBase; class PIMDATAEXPORTER_EXPORT AbstractImportExportJob : public QObject { Q_OBJECT public: explicit AbstractImportExportJob(QObject *parent, ArchiveStorage *archiveStorage, Utils::StoredTypes typeSelected, int numberOfStep); ~AbstractImportExportJob(); virtual void start() = 0; bool wasCanceled() const; static int archiveVersion(); static void setArchiveVersion(int version); void setImportExportProgressIndicator(ImportExportProgressIndicatorBase *importExportProgressIndicator); ImportExportProgressIndicatorBase *importExportProgressIndicator() const; Q_SIGNALS: void info(const QString &); void error(const QString &); void title(const QString &); void endLine(); void needSynchronizeResource(const QString &name, const QString &identifier); void jobFinished(); protected: virtual void slotNextStep(); protected: void initializeListStep(); void startSynchronizeResources(const QStringList &listResourceToSync); void infoAboutNewResource(const QString &resourceName); void copyToDirectory(const KArchiveEntry *entry, const QString &dest); void extractZipFile(const KArchiveFile *file, const QString &source, const QString &destination, bool isStoredAsZippedArchive = true); qint64 convertRealPathToCollection(KConfigGroup &group, const QString ¤tKey, bool addCollectionPrefix = false); void convertRealPathToCollectionList(KConfigGroup &group, const QString ¤tKey, bool addCollectionPrefix = true); void copyToFile(const KArchiveFile *archivefile, const QString &dest, const QString &filename, const QString &prefix); void initializeImportJob(); void backupFile(const QString &filename, const QString &path, const QString &storedName); void backupConfigFile(const QString &configFileName); void backupUiRcFile(const QString &configFileName, const QString &applicationName); void restoreUiRcFile(const QString &configNameStr, const QString &applicationName); int mergeConfigMessageBox(const QString &configName) const; bool overwriteConfigMessageBox(const QString &configName) const; Akonadi::Collection::Id convertPathToId(const QString &path); void backupResourceFile(const Akonadi::AgentInstance &agent, const QString &defaultPath); QStringList restoreResourceFile(const QString &resourceName, const QString &defaultPath, const QString &storePath, bool overwriteResources = false); virtual void addSpecificResourceSettings(const KSharedConfig::Ptr &resourceConfig, const QString &resourceName, QMap &settings); void restoreConfigFile(const QString &configNameStr); bool overwriteDirectoryMessageBox(const QString &directory) const; void overwriteDirectory(const QString &path, const KArchiveEntry *entry); virtual bool isAConfigFile(const QString &name) const; void searchAllFiles(const KArchiveDirectory *dir, const QString &prefix, const QString &searchEntryName); void storeArchiveInfoResources(const KArchiveDirectory *dir, const QString &prefix); KZip *archive() const; void increaseProgressDialog(); void createProgressDialog(const QString &title = QString()); void setProgressDialogLabel(const QString &text); void storeDirectory(const QString &subDirectory); void importDataSubdirectory(const QString &subdirectoryRelativePath); QHash mHashConvertPathCollectionId; QVector mListResourceFile; QString mTempDirName; Utils::StoredTypes mTypeSelected; ArchiveStorage *mArchiveStorage = nullptr; KIdentityManagement::IdentityManager *mIdentityManager = nullptr; QTemporaryDir *mTempDir = nullptr; const KArchiveDirectory *mArchiveDirectory = nullptr; int mNumberOfStep = -1; PimCommon::CreateResource *mCreateResource = nullptr; QStringList mAgentPaths; QVector mListStep; int mIndex = -1; static int sArchiveVersion; private: void slotAllResourceSynchronized(); void slotSynchronizeInstanceDone(const QString &, const QString &identifier); void slotSynchronizeInstanceFailed(const QString &instance); void slotTaskCanceled(); ImportExportProgressIndicatorBase *mImportExportProgressIndicator = nullptr; }; #endif // ABSTRACTIMPORTEXPORTJOB_H diff --git a/core/utils.h b/core/utils.h index 135dfdc..95d2619 100644 --- a/core/utils.h +++ b/core/utils.h @@ -1,116 +1,115 @@ /* Copyright (C) 2012-2019 Montel Laurent 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 UTILS_H #define UTILS_H #include "pimdataexporter_export.h" #include -#include #include #include "pimdataexportcore_debug.h" class KZip; namespace Akonadi { class AgentInstance; } struct resourceFiles { QString akonadiConfigFile; QString akonadiResources; QString akonadiAgentConfigFile; void debug() const { qCDebug(PIMDATAEXPORTERCORE_LOG) << " akonadiconfigfile :" << akonadiConfigFile << " akonadiResources:" << akonadiResources << " akonadiAgentConfigFile:" << akonadiAgentConfigFile; } }; namespace Utils { enum StoredType { None = 0, Identity = 1, Mails = 2, MailTransport = 4, Resources = 8, Config = 16, Data = 32 //TODO add more type to import/export }; Q_DECLARE_FLAGS(StoredTypes, StoredType) enum AppsType { Unknown = 0, KMail, KAddressBook, KAlarm, KOrganizer, KNotes, Akregator }; struct importExportParameters { importExportParameters() : numberSteps(0) , types(None) { } bool isEmpty() const { return types == None; } int numberSteps; Utils::StoredTypes types; }; QString resourcePath(const KSharedConfigPtr &resourceConfig, const QString &defaultPath = QString()); PIMDATAEXPORTER_EXPORT QString transportsPath(); PIMDATAEXPORTER_EXPORT QString resourcesPath(); PIMDATAEXPORTER_EXPORT QString identitiesPath(); PIMDATAEXPORTER_EXPORT QString mailsPath(); PIMDATAEXPORTER_EXPORT QString configsPath(); PIMDATAEXPORTER_EXPORT QString akonadiPath(); PIMDATAEXPORTER_EXPORT QString dataPath(); PIMDATAEXPORTER_EXPORT QString calendarPath(); PIMDATAEXPORTER_EXPORT QString addressbookPath(); PIMDATAEXPORTER_EXPORT QString alarmPath(); PIMDATAEXPORTER_EXPORT QString jotPath(); PIMDATAEXPORTER_EXPORT QString infoPath(); PIMDATAEXPORTER_EXPORT QString notePath(); PIMDATAEXPORTER_EXPORT QString prefixAkonadiConfigFile(); PIMDATAEXPORTER_EXPORT QString exportDataTypeFileName(); QString akonadiAgentName(const QString &configPath); void convertCollectionListToRealPath(KConfigGroup &group, const QString ¤tKey); void convertCollectionToRealPath(KConfigGroup &group, const QString ¤tKey); void convertCollectionIdsToRealPath(KConfigGroup &group, const QString ¤tKey, const QString &prefixCollection = QString()); QString resourcePath(const Akonadi::AgentInstance &agent, const QString &defaultPath = QString()); QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData); QString storeResources(KZip *archive, const QString &identifier, const QString &path); KZip *openZip(const QString &filename, QString &errorMsg); void storeDataExportInfo(const QString &filename, KZip *archive); void addVersion(KZip *archive); int archiveVersion(KZip *archive); int currentArchiveVersion(); PIMDATAEXPORTER_EXPORT QString appTypeToI18n(AppsType type); PIMDATAEXPORTER_EXPORT QString storedTypeToI18n(StoredType type); } #endif // UTILS_H