started work on deinit

This commit is contained in:
Patrick von Reth 2014-01-15 15:35:01 +01:00
parent 4fba46753e
commit 0f38add1cf
5 changed files with 34 additions and 13 deletions

View File

@ -91,4 +91,9 @@ void SnorePlugin::notificationTimedOut(){
} }
} }
void SnorePlugin::deinit()
{
m_initialized = false;
}
} }

View File

@ -47,6 +47,7 @@ public:
SnorePlugin ( const QString &name); SnorePlugin ( const QString &name);
virtual ~SnorePlugin(); virtual ~SnorePlugin();
virtual bool init( SnoreCore *snore ); virtual bool init( SnoreCore *snore );
virtual void deinit();
bool isInitialized(); bool isInitialized();
SnoreCore* snore(); SnoreCore* snore();
const QString &name() const; const QString &name() const;

View File

@ -42,11 +42,6 @@ SnoreBackend::SnoreBackend (const QString &name , bool canCloseNotification, boo
SnoreBackend::~SnoreBackend() SnoreBackend::~SnoreBackend()
{ {
qDebug()<<"Deleting"<<name(); qDebug()<<"Deleting"<<name();
if(snore() != NULL){
foreach(const Application &a,snore()->aplications()){
slotDeregisterApplication(a);
}
}
} }
@ -59,6 +54,9 @@ bool SnoreBackend::init( SnoreCore *snore )
connect( snore->d(), SIGNAL(applicationRegistered(const Snore::Application&)), this, SLOT(slotRegisterApplication(const Snore::Application&))); connect( snore->d(), SIGNAL(applicationRegistered(const Snore::Application&)), this, SLOT(slotRegisterApplication(const Snore::Application&)));
connect( snore->d(), SIGNAL(applicationDeregistered(const Snore::Application&)), this, SLOT(slotDeregisterApplication(const Snore::Application&))); connect( snore->d(), SIGNAL(applicationDeregistered(const Snore::Application&)), this, SLOT(slotDeregisterApplication(const Snore::Application&)));
connect( this, SIGNAL(notificationClosed(Snore::Notification)), snore->d(), SLOT(slotNotificationClosed(Snore::Notification)));
connect( snore->d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification)));
foreach(const Application &a,snore->aplications()) foreach(const Application &a,snore->aplications())
{ {
this->slotRegisterApplication(a); this->slotRegisterApplication(a);
@ -110,7 +108,6 @@ SnoreSecondaryBackend::~SnoreSecondaryBackend()
bool SnoreSecondaryBackend::init(SnoreCore *snore) bool SnoreSecondaryBackend::init(SnoreCore *snore)
{ {
connect( snore->d() ,SIGNAL( slotNotify(SnoreCore::Notification) ),this,SLOT( slotNotify( SnoreCore::Notification ) ) );
return SnoreBackend::init(snore); return SnoreBackend::init(snore);
} }
@ -143,3 +140,22 @@ void SnoreBackend::addActiveNotification(Notification n)
{ {
m_activeNotifications[n.id()] = n; m_activeNotifications[n.id()] = n;
} }
void SnoreBackend::deinit()
{
if(m_initialized)
{
foreach(const Application &a,snore()->aplications())
{
slotDeregisterApplication(a);
}
disconnect( snore()->d(), SIGNAL(applicationRegistered(const Snore::Application&)), this, SLOT(slotRegisterApplication(const Snore::Application&)));
disconnect( snore()->d(), SIGNAL(applicationDeregistered(const Snore::Application&)), this, SLOT(slotDeregisterApplication(const Snore::Application&)));
disconnect( this, SIGNAL(notificationClosed(Snore::Notification)), snore()->d(), SLOT(slotNotificationClosed(Snore::Notification)));
disconnect( snore()->d(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification)));
SnorePlugin::deinit();
}
}

View File

@ -37,6 +37,7 @@ public:
SnoreBackend(const QString &name, bool canCloseNotification, bool supportsRichtext ); SnoreBackend(const QString &name, bool canCloseNotification, bool supportsRichtext );
virtual ~SnoreBackend(); virtual ~SnoreBackend();
virtual bool init(SnoreCore *snore); virtual bool init(SnoreCore *snore);
virtual void deinit();
void requestCloseNotification( Snore::Notification notification,NotificationEnums::CloseReasons::closeReasons reason ); void requestCloseNotification( Snore::Notification notification,NotificationEnums::CloseReasons::closeReasons reason );

View File

@ -178,14 +178,12 @@ bool SnoreCore::setPrimaryNotificationBackend ( const QString &backend )
qDebug() << "Failed to initialize" << b->name(); qDebug() << "Failed to initialize" << b->name();
return false; return false;
} }
}
if(d->m_notificationBackend) if(d->m_notificationBackend)
{ {
disconnect(d->m_notificationBackend, SIGNAL(notificationClosed(Snore::Notification))); d->m_notificationBackend->deinit();
disconnect(d, SIGNAL(notify(Snore::Notification)), d->m_notificationBackend, SLOT(slotNotify(Snore::Notification)));
}
connect(b, SIGNAL(notificationClosed(Snore::Notification)), d, SLOT(slotNotificationClosed(Snore::Notification)));
connect(d, SIGNAL(notify(Snore::Notification)), b, SLOT(slotNotify(Snore::Notification)));
} }
d->m_notificationBackend = b; d->m_notificationBackend = b;
return true; return true;
} }