Commit ce91e46e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Time to improve backupmail rename it to pimsettingexporter.

We will export setting from all pim apps
parents
project(pimsettingexporter)
include_directories(${AKONADI_INCLUDE_DIR}
${SOPRANO_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/libkdepim
${NEPOMUK_CORE_INCLUDE_DIR}
)
########### next target ###############
set(pimsettingexporter_SRCS
main.cpp
abstractimportexportjob.cpp
backupmailwindow.cpp
backupmailwidget.cpp
exportmailjob.cpp
importmailjob.cpp
backupmailkernel.cpp
backupmailutil.cpp
selecttypewidget.cpp
selectiontypedialog.cpp
akonadidatabase.cpp
exportcalendarjob.cpp
importcalendarjob.cpp
archivestorage.cpp
)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}" )
kde4_add_ui_files(pimsettingexporter_SRCS ui/selecttypewidget.ui )
kde4_add_executable(pimsettingexporter ${pimsettingexporter_SRCS})
target_link_libraries(pimsettingexporter
${KDE4_KIO_LIBS}
${KDEPIMLIBS_AKONADI_LIBS}
${KDEPIMLIBS_AKONADI_KMIME_LIBS}
${KDEPIMLIBS_KMIME_LIBS}
${KDEPIMLIBS_KPIMUTILS_LIBS}
${KDEPIMLIBS_MAILTRANSPORT_LIBS}
${AKONADI_COMMON_LIBRARIES}
mailimporter
mailcommon
pimcommon
kdepim
messagecomposer
)
install(TARGETS pimsettingexporter ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(FILES
pimsettingexporter.rc
DESTINATION ${DATA_INSTALL_DIR}/pimsettingexporter
)
########### install files ###############
kde4_install_icons( ${ICON_INSTALL_DIR} )
#! /bin/sh
$EXTRACTRC ui/*.ui >> rc.cpp
$XGETTEXT `find -name '*.cpp'` -o $podir/pimsettingexporter.pot
rm -f rc.cpp
TODO 4.10:
----------
- Allow to merge ldap config (DONE)
- Allow to merge KMail Snippet config
- Allow to merge akonadi_archivemail_agentrc config (DONE)
- Import/Export KAddressBook config
- Import/Export KOrganizer config
- Rename it.
- Add export mode
/*
Copyright (c) 2012 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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "abstractimportexportjob.h"
#include "archivestorage.h"
#include <kpimidentities/identitymanager.h>
#include <KZip>
#include <KLocale>
#include <QWidget>
#include <QProgressDialog>
AbstractImportExportJob::AbstractImportExportJob(QWidget *parent, ArchiveStorage *archiveStorage, BackupMailUtil::BackupTypes typeSelected, int numberOfStep)
: QObject(parent),
mTypeSelected(typeSelected),
mArchiveStorage(archiveStorage),
mIdentityManager(new KPIMIdentities::IdentityManager( false, this, "mIdentityManager" )),
mParent(parent),
mProgressDialog(0),
mNumberOfStep(numberOfStep)
{
}
AbstractImportExportJob::~AbstractImportExportJob()
{
delete mIdentityManager;
}
QProgressDialog *AbstractImportExportJob::progressDialog()
{
return mProgressDialog;
}
void AbstractImportExportJob::createProgressDialog()
{
if(!mProgressDialog) {
mProgressDialog = new QProgressDialog(mParent);
mProgressDialog->setWindowModality(Qt::WindowModal);
mProgressDialog->setMinimum(0);
mProgressDialog->setMaximum(mNumberOfStep);
}
mProgressDialog->show();
mProgressDialog->setValue(0);
}
bool AbstractImportExportJob::wasCanceled() const
{
if(mProgressDialog)
return mProgressDialog->wasCanceled();
return false;
}
void AbstractImportExportJob::increaseProgressDialog()
{
if(mProgressDialog) {
mProgressDialog->setValue(mProgressDialog->value()+1);
}
}
void AbstractImportExportJob::showInfo(const QString&text)
{
if(mProgressDialog) {
mProgressDialog->setLabelText(text);
}
Q_EMIT info(text);
}
KZip *AbstractImportExportJob::archive()
{
return mArchiveStorage->archive();
}
#include "abstractimportexportjob.moc"
/*
Copyright (c) 2012 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, version 2, as
published by the Free Software Foundation.
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; 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 "backupmailutil.h"
class KZip;
class QWidget;
class QProgressDialog;
class ArchiveStorage;
namespace KPIMIdentities {
class Identity;
class IdentityManager;
}
class AbstractImportExportJob : public QObject
{
Q_OBJECT
public:
explicit AbstractImportExportJob(QWidget *parent, ArchiveStorage *archiveStorage, BackupMailUtil::BackupTypes typeSelected, int numberOfStep);
~AbstractImportExportJob();
virtual void start() = 0;
bool wasCanceled() const;
Q_SIGNALS:
void info(const QString&);
void error(const QString&);
protected:
KZip *archive();
QProgressDialog *progressDialog();
void increaseProgressDialog();
void createProgressDialog();
void showInfo(const QString&text);
BackupMailUtil::BackupTypes mTypeSelected;
ArchiveStorage *mArchiveStorage;
KPIMIdentities::IdentityManager *mIdentityManager;
QWidget *mParent;
QProgressDialog *mProgressDialog;
int mNumberOfStep;
};
#endif // ABSTRACTIMPORTEXPORTJOB_H
/*
Copyright (c) 2012 Montel Laurent <montel@kde.org>
based on code from kdepim-runtime/tray/global.cpp
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "akonadidatabase.h"
#include <akonadi/private/xdgbasedirs_p.h>
#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::XdgBaseDirs::akonadiServerConfigFile( Akonadi::XdgBaseDirs::ReadWrite );
QSettings settings( serverConfigFile, QSettings::IniFormat );
m_dbdriver = settings.value( "General/Driver", "QMYSQL" ).toString();
settings.beginGroup( m_dbdriver );
if( m_dbdriver == QLatin1String("QPSQL") ) {
m_dbname = settings.value( "Name", "akonadi" ).toString();
m_dboptions.append( "--host=" + settings.value( "Host", "" ).toString() );
// If the server is started by the user, we don't need to know the username/password.
bool startServer = settings.value( "StartServer", "true" ).toBool();
if( !startServer ) {
// TODO: postgres will always ask for the user password ! implement .pgpass
m_dboptions.append( "--username=" + settings.value( "User", "" ).toString() );
}
settings.endGroup();
}
else if( m_dbdriver == QLatin1String("QMYSQL") ) {
m_dbname = settings.value( "Name", "akonadi" ).toString();
// If the server is started by the user, we don't need to know the username/password.
bool startServer = settings.value( "StartServer", "" ).toBool();
if( !startServer ) {
m_dboptions.append( "--host=" + settings.value( "Host", "" ).toString() );
m_dboptions.append( "--user=" + settings.value( "User", "" ).toString() );
m_dboptions.append( "--password=" + settings.value( "Password", "" ).toString() );
}
else {
const QString options = settings.value( "Options", "" ).toString();
const QStringList list = options.split( QLatin1Char('=') );
m_dboptions.append( "--socket=" + list.at( 1 ) );
}
settings.endGroup();
}
}
/*
Copyright (c) 2012 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, version 2, as
published by the Free Software Foundation.
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; 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:
explicit 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
/*
Copyright (c) 2012 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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "archivestorage.h"
#include <KZip>
#include <KLocale>
ArchiveStorage::ArchiveStorage(const QString& filename, QObject *parent)
:QObject(parent), mArchive(new KZip(filename))
{
}
ArchiveStorage::~ArchiveStorage()
{
closeArchive();
delete mArchive;
}
void ArchiveStorage::closeArchive()
{
if(mArchive && mArchive->isOpen()) {
mArchive->close();
}
}
bool ArchiveStorage::openArchive(bool write)
{
bool result = mArchive->open(write ? QIODevice::WriteOnly : QIODevice::ReadOnly);
if(!result) {
if(write) {
Q_EMIT error(i18n("Archive cannot be opened in write mode."));
} else {
Q_EMIT error(i18n("Archive cannot be opened in read mode."));
}
}
return result;
}
KZip *ArchiveStorage::archive()
{
return mArchive;
}
#include "archivestorage.moc"
/*
Copyright (c) 2012 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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ARCHIVESTORAGE_H
#define ARCHIVESTORAGE_H
#include <QObject>
class KZip;
class ArchiveStorage : public QObject
{
Q_OBJECT
public:
explicit ArchiveStorage(const QString &filename, QObject*parent = 0);
~ArchiveStorage();
void closeArchive();
bool openArchive(bool write);
KZip *archive();
Q_SIGNALS:
void error(const QString&);
private:
KZip *mArchive;
};
#endif // ARCHIVESTORAGE_H
2012-05-14:
-----------
Zip structure is :
Root
|-----transports
| |---------mailtransports
|
|-----identities
| |---------emailidentities
| |---------uoid-identity
| |--------- vcard file
|
|-----resources
| |---------<resource name> (just pop3/imap4)
|
|-----mails
| |---------<resource name>
| |---------<resource config file>
| |---------<archive resource>
|
|-----configs
| |---------filters
| |---------kmail2rc
|
|-----akonadi
| |---------<archive akonadi>
|-----nepomuk
| |---------<archive nepomuk>
/*
Copyright (c) 2012 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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "backupmailkernel.h"
#include <kglobal.h>
#include <kpimidentities/identitymanager.h>
#include <messagecomposer/akonadisender.h>
#include <mailcommon/foldercollectionmonitor.h>
#include <akonadi/session.h>
#include <akonadi/entitytreemodel.h>
#include <akonadi/entitymimetypefiltermodel.h>
#include <akonadi/changerecorder.h>
BackupMailKernel::BackupMailKernel( QObject *parent )
: QObject( parent )
{
mMessageSender = new AkonadiSender( this );
mIdentityManager = new KPIMIdentities::IdentityManager( false, this );
mFolderCollectionMonitor = new MailCommon::FolderCollectionMonitor( this );
Akonadi::Session *session = new Akonadi::Session( "Backup Mail Kernel ETM", this );
folderCollectionMonitor()->setSession( session );
mEntityTreeModel = new Akonadi::EntityTreeModel( folderCollectionMonitor(), this );
mEntityTreeModel->setIncludeUnsubscribed( false );
mEntityTreeModel->setItemPopulationStrategy( Akonadi::EntityTreeModel::LazyPopulation );
mCollectionModel = new Akonadi::EntityMimeTypeFilterModel( this );
mCollectionModel->setSourceModel( mEntityTreeModel );
mCollectionModel->addMimeTypeInclusionFilter( Akonadi::Collection::mimeType() );
mCollectionModel->setHeaderGroup( Akonadi::EntityTreeModel::CollectionTreeHeaders );
mCollectionModel->setDynamicSortFilter( true );
mCollectionModel->setSortCaseSensitivity( Qt::CaseInsensitive );
}
KPIMIdentities::IdentityManager *BackupMailKernel::identityManager()
{
return mIdentityManager;
}
MessageSender *BackupMailKernel::msgSender()
{
return mMessageSender;
}
Akonadi::EntityMimeTypeFilterModel *BackupMailKernel::collectionModel() const
{
return mCollectionModel;
}
KSharedConfig::Ptr BackupMailKernel::config()
{
return KGlobal::config();
}
void BackupMailKernel::syncConfig()
{
Q_ASSERT( false );
}
MailCommon::JobScheduler* BackupMailKernel::jobScheduler() const
{
Q_ASSERT( false );
return 0;
}
Akonadi::ChangeRecorder *BackupMailKernel::folderCollectionMonitor() const
{
return mFolderCollectionMonitor->monitor();
}
void BackupMailKernel::updateSystemTray()
{
Q_ASSERT( false );
}
bool BackupMailKernel::showPopupAfterDnD()
{
return false;
}
qreal BackupMailKernel::closeToQuotaThreshold()
{
return 80;
}
QStringList BackupMailKernel::customTemplates()
{
Q_ASSERT( false );
return QStringList();
}
bool BackupMailKernel::excludeImportantMailFromExpiry()
{
Q_ASSERT( false );
return true;
}
Akonadi::Entity::Id BackupMailKernel::lastSelectedFolder()
{
Q_ASSERT( false );
return Akonadi::Entity::Id();
}
void BackupMailKernel::setLastSelectedFolder(const Akonadi::Entity::Id& col)
{
Q_UNUSED(col);
}
/*
Copyright (c) 2012 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, version 2, as
published by the Free Software Foundation.