Run the migrator if needed.

svn path=/branches/work/akonadi-ports/kdepim/; revision=1075120
wilder-work
Volker Krause 16 years ago
parent 54ee07cac8
commit 387339db44
  1. 32
      kmkernel.cpp

@ -60,6 +60,7 @@ using KMail::TemplateParser;
#include <kdebug.h>
#include <kio/jobuidelegate.h>
#include <kio/netaccess.h>
#include <kprocess.h>
#include <kmime/kmime_message.h>
#include <kmime/kmime_util.h>
@ -109,6 +110,37 @@ KMKernel::KMKernel (QObject *parent, const char *name) :
mIdentityManager(0), mConfigureDialog(0), mMailService(0),
mContextMenuShown( false )
{
// Akonadi migration
KConfig config( "kmail-migratorrc" );
KConfigGroup migrationCfg( &config, "Migration" );
const bool enabled = migrationCfg.readEntry( "Enabled", false );
const int currentVersion = migrationCfg.readEntry( "Version", 0 );
const int targetVersion = migrationCfg.readEntry( "TargetVersion", 1 );
if ( enabled && currentVersion < targetVersion ) {
kDebug() << "Performing Akonadi migration. Good luck!";
KProcess proc;
QStringList args = QStringList() << "--interactive-on-change";
proc.setProgram( "kmail-migrator", args );
proc.start();
bool result = proc.waitForStarted();
if ( result ) {
result = proc.waitForFinished();
}
if ( result && proc.exitCode() == 0 ) {
kDebug() << "Akonadi migration has been successful";
migrationCfg.writeEntry( "Version", targetVersion );
migrationCfg.sync();
} else {
// exit code 1 means it is already running, so we are probably called by a migrator instance
kError() << "Akonadi migration failed!";
kError() << "command was: " << proc.program();
kError() << "exit code: " << proc.exitCode();
kError() << "stdout: " << proc.readAllStandardOutput();
kError() << "stderr: " << proc.readAllStandardError();
exit( 42 );
}
}
#ifdef __GNUC__
#warning Remove before the 4.5 release
#endif

Loading…
Cancel
Save