|
|
|
|
@ -126,7 +126,7 @@ KMKernel::KMKernel (QObject *parent, const char *name) : |
|
|
|
|
{ |
|
|
|
|
Akonadi::AttributeFactory::registerAttribute<Akonadi::SearchDescriptionAttribute>(); |
|
|
|
|
QDBusConnection::sessionBus().registerService(QLatin1String("org.kde.kmail")); |
|
|
|
|
migrateFromKMail1(); |
|
|
|
|
KMail::Util::migrateFromKMail1(); |
|
|
|
|
kDebug() << "Starting up..."; |
|
|
|
|
|
|
|
|
|
mySelf = this; |
|
|
|
|
@ -246,85 +246,6 @@ KMKernel::~KMKernel () |
|
|
|
|
kDebug(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void KMKernel::migrateFromKMail1() |
|
|
|
|
{ |
|
|
|
|
// Akonadi migration
|
|
|
|
|
// check if there is something to migrate at all
|
|
|
|
|
bool needMigration = true; |
|
|
|
|
KConfig oldKMailConfig( QLatin1String("kmailrc"), KConfig::NoGlobals ); |
|
|
|
|
if ( oldKMailConfig.hasGroup("General") || |
|
|
|
|
( oldKMailConfig.groupList().count() == 1 && |
|
|
|
|
oldKMailConfig.groupList().first() == QLatin1String("$Version") ) ) { |
|
|
|
|
const QFileInfo oldDataDirFileInfo( KStandardDirs::locateLocal( "data", QLatin1String("kmail") ) ); |
|
|
|
|
if ( !oldDataDirFileInfo.exists() || !oldDataDirFileInfo.isDir() ) { |
|
|
|
|
// neither config or data, the migrator cannot do anything useful anyways
|
|
|
|
|
needMigration = false; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
needMigration = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
KConfig config( QLatin1String("kmail-migratorrc") ); |
|
|
|
|
KConfigGroup migrationCfg( &config, "Migration" ); |
|
|
|
|
if ( needMigration ) { |
|
|
|
|
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 ) { |
|
|
|
|
const int choice = KMessageBox::questionYesNoCancel( 0, i18n( |
|
|
|
|
"<b>Thanks for using KMail2!</b>" |
|
|
|
|
"<p>KMail2 uses a new storage technology that requires migration of your current KMail data and configuration.</p>\n" |
|
|
|
|
"<p>The conversion process can take a lot of time (depending on the amount of email you have) and it <em>must not be interrupted</em>.</p>\n" |
|
|
|
|
"<p>You can:</p><ul>" |
|
|
|
|
"<li>Migrate now (be prepared to wait)</li>" |
|
|
|
|
"<li>Skip the migration and start with fresh data and configuration</li>" |
|
|
|
|
"<li>Cancel and exit KMail2.</li>" |
|
|
|
|
"</ul>" |
|
|
|
|
"<p><a href=\"http://userbase.kde.org/Akonadi\">More Information...</a></p>" |
|
|
|
|
), i18n( "KMail Migration" ), KGuiItem(i18n( "Migrate Now" )), KGuiItem(i18n( "Skip Migration" )), KStandardGuiItem::cancel(), |
|
|
|
|
QString(), KMessageBox::Notify | KMessageBox::Dangerous | KMessageBox::AllowLink ); |
|
|
|
|
if ( choice == KMessageBox::Cancel ) |
|
|
|
|
exit( 1 ); |
|
|
|
|
|
|
|
|
|
if ( choice != KMessageBox::Yes ) { // user skipped migration
|
|
|
|
|
// we only will make one attempt at this
|
|
|
|
|
migrationCfg.writeEntry( "Version", targetVersion ); |
|
|
|
|
migrationCfg.sync(); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
kDebug() << "Performing Akonadi migration. Good luck!"; |
|
|
|
|
KProcess proc; |
|
|
|
|
QStringList args = QStringList() << QLatin1String("--interactive-on-change"); |
|
|
|
|
const QString path = KStandardDirs::findExe( QLatin1String("kmail-migrator" ) ); |
|
|
|
|
proc.setProgram( path, args ); |
|
|
|
|
proc.start(); |
|
|
|
|
bool result = proc.waitForStarted(); |
|
|
|
|
if ( result ) { |
|
|
|
|
result = proc.waitForFinished( -1 ); |
|
|
|
|
} |
|
|
|
|
if ( result && proc.exitCode() == 0 ) { |
|
|
|
|
kDebug() << "Akonadi migration has been successful"; |
|
|
|
|
} 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(); |
|
|
|
|
|
|
|
|
|
KMessageBox::error( 0, i18n("Migration to KMail 2 failed. In case you want to try again, run 'kmail-migrator --interactive' manually."), |
|
|
|
|
i18n( "Migration Failed" ) ); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
migrationCfg.writeEntry( "Enabled", false ); |
|
|
|
|
migrationCfg.sync(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Akonadi::ChangeRecorder * KMKernel::folderCollectionMonitor() const |
|
|
|
|
{ |
|
|
|
|
return mFolderCollectionMonitor->monitor(); |
|
|
|
|
|