diff --git a/src/core/plugins/plugins.cpp b/src/core/plugins/plugins.cpp index 9c95018..ea10dad 100644 --- a/src/core/plugins/plugins.cpp +++ b/src/core/plugins/plugins.cpp @@ -91,4 +91,9 @@ void SnorePlugin::notificationTimedOut(){ } } +void SnorePlugin::deinit() +{ + m_initialized = false; +} + } diff --git a/src/core/plugins/plugins.h b/src/core/plugins/plugins.h index 826cf33..e4764e1 100644 --- a/src/core/plugins/plugins.h +++ b/src/core/plugins/plugins.h @@ -47,6 +47,7 @@ public: SnorePlugin ( const QString &name); virtual ~SnorePlugin(); virtual bool init( SnoreCore *snore ); + virtual void deinit(); bool isInitialized(); SnoreCore* snore(); const QString &name() const; diff --git a/src/core/plugins/snorebackend.cpp b/src/core/plugins/snorebackend.cpp index 7fca9d7..2159e9c 100644 --- a/src/core/plugins/snorebackend.cpp +++ b/src/core/plugins/snorebackend.cpp @@ -42,11 +42,6 @@ SnoreBackend::SnoreBackend (const QString &name , bool canCloseNotification, boo SnoreBackend::~SnoreBackend() { qDebug()<<"Deleting"<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(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()) { this->slotRegisterApplication(a); @@ -110,7 +108,6 @@ SnoreSecondaryBackend::~SnoreSecondaryBackend() bool SnoreSecondaryBackend::init(SnoreCore *snore) { - connect( snore->d() ,SIGNAL( slotNotify(SnoreCore::Notification) ),this,SLOT( slotNotify( SnoreCore::Notification ) ) ); return SnoreBackend::init(snore); } @@ -143,3 +140,22 @@ void SnoreBackend::addActiveNotification(Notification 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(); + } +} diff --git a/src/core/plugins/snorebackend.h b/src/core/plugins/snorebackend.h index 504c788..5aa4aa6 100644 --- a/src/core/plugins/snorebackend.h +++ b/src/core/plugins/snorebackend.h @@ -37,6 +37,7 @@ public: SnoreBackend(const QString &name, bool canCloseNotification, bool supportsRichtext ); virtual ~SnoreBackend(); virtual bool init(SnoreCore *snore); + virtual void deinit(); void requestCloseNotification( Snore::Notification notification,NotificationEnums::CloseReasons::closeReasons reason ); diff --git a/src/core/snore.cpp b/src/core/snore.cpp index 96c4637..50f3c5a 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -178,14 +178,12 @@ bool SnoreCore::setPrimaryNotificationBackend ( const QString &backend ) qDebug() << "Failed to initialize" << b->name(); return false; } - if(d->m_notificationBackend) - { - disconnect(d->m_notificationBackend, SIGNAL(notificationClosed(Snore::Notification))); - 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))); } + if(d->m_notificationBackend) + { + d->m_notificationBackend->deinit(); + } + d->m_notificationBackend = b; return true; }