Commit 81407585 authored by Volker Krause's avatar Volker Krause
Browse files

make sure only one instance tries the config file to wallet migration

svn path=/trunk/KDE/kdepim/mailtransport/; revision=619883
parent c15172d6
......@@ -19,7 +19,6 @@ TransportManager
(create a copy for edit?)
- load passwords if another instance opens the wallet
- add job scheduler (see knode) for async wallet loading during sending
- migrate passwords to wallet only in one instance
TransportComboBox
-----------------
......
/*
Copyright (c) 2006 Volker Krause <vkrause@kde.org>
Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
......@@ -27,6 +27,7 @@
#define WALLET_FOLDER "mailtransports"
#define DBUS_SERVICE_NAME "org.kde.pim.TransportManager"
#define DBUS_INTERFACE_NAME "org.kde.pim.TransportManager"
#define DBUS_OBJECT_PATH "/TransportManager"
......
......@@ -34,6 +34,7 @@
#include <QApplication>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QRegExp>
#include <QStringList>
......@@ -58,6 +59,10 @@ TransportManager::TransportManager() :
QDBusConnection::sessionBus().connect( QString(), QString(), DBUS_INTERFACE_NAME, "changesCommitted",
this, SLOT(slotTransportsChanged()) );
mIsMainInstance = QDBusConnection::sessionBus().registerService( DBUS_SERVICE_NAME );
connect( QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
SLOT(dbusServiceOwnerChanged(QString,QString,QString)) );
}
TransportManager::~TransportManager()
......@@ -391,7 +396,9 @@ void TransportManager::migrateToWallet()
return;
firstRun = false;
// TODO: check if we are the first instance
// check if we are the main instance
if ( !mIsMainInstance )
return;
// check if migration is needed
QStringList names;
......@@ -416,4 +423,10 @@ void TransportManager::migrateToWallet()
t->migrateToWallet();
}
void TransportManager::dbusServiceOwnerChanged(const QString & service, const QString & oldOwner, const QString & newOwner)
{
if ( service == DBUS_SERVICE_NAME && newOwner.isEmpty() )
QDBusConnection::sessionBus().registerService( DBUS_SERVICE_NAME );
}
#include "transportmanager.moc"
......@@ -192,6 +192,7 @@ class MAILTRANSPORT_EXPORT TransportManager : public QObject
private slots:
void slotTransportsChanged();
void slotWalletOpened( bool success );
void dbusServiceOwnerChanged( const QString &service, const QString &oldOwner, const QString &newOwner );
private:
static TransportManager* mInstance;
......@@ -202,6 +203,7 @@ class MAILTRANSPORT_EXPORT TransportManager : public QObject
bool mWalletOpenFailed;
bool mWalletAsyncOpen;
int mDefaultTransportId;
bool mIsMainInstance;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment