[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepimlibs/kresources
From: Volker Krause <vkrause () kde ! org>
Date: 2008-10-31 23:53:28
Message-ID: 1225497208.510011.20372.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 878364 by vkrause:
First try to automatically use the KResource to Akonadi migrator. It
works nicely for applications, but it is also triggered from the backend
bridges, which might be a problem.
Still disabled by default.
M +32 -0 factory.cpp
--- trunk/KDE/kdepimlibs/kresources/factory.cpp #878363:878364
@@ -40,6 +40,8 @@
#include <kdebug.h>
#include <klocale.h>
#include <kconfig.h>
+#include <kconfiggroup.h>
+#include <kprocess.h>
#include <kstandarddirs.h>
#include <kservicetypetrader.h>
#include <kpluginloader.h>
@@ -48,6 +50,9 @@
using namespace KRES;
+static int akonadiMigratorVersion = 1;
+static bool akonadiMigrationEnabled = false; // flip this switch if you dare ;-)
+
class Factory::Private
{
public:
@@ -70,6 +75,33 @@
if ( !factory ) {
factory = new Factory( resourceFamily );
mSelves->insert( resourceFamily, factory );
+
+ // Akonadi migration
+ const QString cfgFileName = KStandardDirs::locateLocal( "config", QString( \
"kres-migratorrc" ) ); + KConfig *config = new KConfig( cfgFileName );
+ KConfigGroup migrationCfg( config, "Migration" );
+ const bool enabled = migrationCfg.readEntry( "Enabled", akonadiMigrationEnabled \
); + const int version = migrationCfg.readEntry( "Version-" + resourceFamily, 0 );
+ if ( enabled && version < akonadiMigratorVersion ) {
+ kDebug() << "Performing Akonadi migration. Good luck!";
+ KProcess proc;
+ proc.setProgram( "kres-migrator", QStringList() << "--interactive-on-change" \
<< "--type" << resourceFamily ); + proc.start();
+ bool result = proc.waitForStarted();
+ if ( result )
+ result = proc.waitForFinished();
+ if ( result && proc.exitCode() == 0 ) {
+ migrationCfg.writeEntry( "Version-" + resourceFamily, akonadiMigratorVersion \
); + migrationCfg.sync();
+ } else if ( !result || proc.exitCode() != 1 ) { // 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();
+ }
+ }
+
}
return factory;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic