Commit 6d7374b9 authored by Jarosław Staniek's avatar Jarosław Staniek
Browse files

use K_GLOBAL_STATIC for TransportManager's static data and setup Post Routine

(reviewed)

svn path=/trunk/KDE/kdepimlibs/; revision=810890
parent d3dce150
......@@ -49,9 +49,12 @@ using namespace KWallet;
class TransportManager::Private
{
public:
Private() {}
~Private() {
cleanupTransportManager();
delete config;
qDeleteAll( transports );
}
KConfig *config;
QList<Transport *> transports;
bool myOwnChange;
......@@ -61,19 +64,21 @@ class TransportManager::Private
int defaultTransportId;
bool isMainInstance;
QList<TransportJob *> walletQueue;
};
static TransportManager *sSelf;
static void cleanupTransportManager()
{
delete sSelf;
sSelf = 0;
}
class StaticTransportManager : public TransportManager
{
public:
StaticTransportManager() : TransportManager() {}
};
TransportManager *TransportManager::Private::sSelf = 0;
TransportManager::TransportManager(Private *priv)
: QObject(), d( priv )
K_GLOBAL_STATIC( StaticTransportManager, sSelf )
TransportManager::TransportManager()
: QObject(), d( new Private )
{
qAddPostRoutine( sSelf.destroy );
d->myOwnChange = false;
d->wallet = 0;
d->walletOpenFailed = false;
......@@ -94,22 +99,18 @@ TransportManager::TransportManager(Private *priv)
connect( QDBusConnection::sessionBus().interface(),
SIGNAL(serviceOwnerChanged(QString,QString,QString)),
SLOT(dbusServiceOwnerChanged(QString,QString,QString)) );
readConfig();
}
TransportManager::~TransportManager()
{
delete d->config;
qDeleteAll( d->transports );
qRemovePostRoutine( sSelf.destroy );
delete d;
}
TransportManager *TransportManager::self()
{
static TransportManager::Private p;
if( !p.sSelf ) {
p.sSelf = new TransportManager( &p );
p.sSelf->readConfig();
}
return p.sSelf;
return sSelf;
}
Transport *TransportManager::transportById( int id, bool def ) const
......
......@@ -46,8 +46,11 @@ class MAILTRANSPORT_EXPORT TransportManager : public QObject
Q_CLASSINFO( "D-Bus Interface", "org.kde.pim.TransportManager" )
friend class Transport;
friend class Private;
public:
class Private;
/**
Destructor.
*/
......@@ -221,9 +224,9 @@ class MAILTRANSPORT_EXPORT TransportManager : public QObject
*/
void loadPasswords();
TransportManager();
private:
class Private;
TransportManager(Private *priv);
void readConfig();
void writeConfig();
void emitChangesCommitted();
......
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