diff --git a/src/core/notification/icon.cpp b/src/core/notification/icon.cpp index 60acdca..2a7b216 100644 --- a/src/core/notification/icon.cpp +++ b/src/core/notification/icon.cpp @@ -24,9 +24,8 @@ #include namespace Snore{ -class SnoreIcon::SnoreIconData : public QObject +class SnoreIcon::SnoreIconData { - Q_OBJECT public: SnoreIconData(): m_isLocalFile(false) @@ -108,7 +107,7 @@ SnoreIcon &SnoreIcon::operator=(const SnoreIcon &other) { if(d && !d->m_ref.deref()) { - d->deleteLater(); + delete d; } other.d->m_ref.ref(); d = other.d; @@ -119,7 +118,7 @@ SnoreIcon::~SnoreIcon() { if(d && !d->m_ref.deref()) { - d->deleteLater(); + delete d; } } @@ -178,6 +177,3 @@ const QString &SnoreIcon::url() const } } - - -#include "icon.moc" diff --git a/src/core/notification/notification.cpp b/src/core/notification/notification.cpp index dd8caf8..183356c 100644 --- a/src/core/notification/notification.cpp +++ b/src/core/notification/notification.cpp @@ -36,9 +36,8 @@ int Notification::notificationCount = 0; uint Notification::m_idCount = 1; -class Notification::NotificationData : public QObject +class Notification::NotificationData { - Q_OBJECT public: NotificationData ( const QString &application,const QString &alert,const QString &title,const QString &text,const SnoreIcon &icon,int timeout,uint id,NotificationEnums::Prioritys::prioritys priority ): m_id ( id == 0 ?m_idCount++:id), @@ -117,7 +116,7 @@ Notification::~Notification() { if(d && !d->m_ref.deref()) { - d->deleteLater(); + delete d; } } @@ -125,7 +124,7 @@ Notification &Notification::operator=(const Notification& other) { if(d && !d->m_ref.deref()) { - d->deleteLater(); + delete d; } other.d->m_ref.ref(); d = other.d; @@ -246,22 +245,17 @@ bool Notification::isValid() const return d != NULL; } -const QObject *Notification::data() const -{ - return d; -} - -QDataStream & operator<< ( QDataStream &stream, const Notification ¬i ) +QDataStream &operator<< ( QDataStream &stream, const Notification ¬i ) { stream << "Title: " << noti.title() << " Text: " << noti.text() << " ID: " << noti.id() ; return stream; } -QDataStream & operator<< ( QDataStream &stream, const Notification::Action &a) + +QDataStream &operator<< ( QDataStream &stream, const Notification::Action &a) { stream< +#include + namespace Snore{ class SNORE_EXPORT Notification @@ -74,8 +76,6 @@ public: bool isValid() const; - const QObject *data() const; - //protected://TODO::make only accesable from a backend void setActionInvoked ( Action *action ); void setActionInvoked ( const int &actionID); @@ -94,6 +94,13 @@ private: Q_DECLARE_METATYPE(Snore::Notification) -QDataStream & operator<< ( QDataStream & stream, const Snore::Notification & noti ); -QDataStream & operator<< ( QDataStream & stream, const Snore::Notification::Action & action); +QDataStream &operator<< ( QDataStream & stream, const Snore::Notification & noti ); + +inline QDebug operator<< ( QDebug debug, const Snore::Notification ¬i ) +{ + debug << "Snore::Notification(" << noti.title() << ", " << noti.text() << "," << noti.id() << ")" ; + return debug.maybeSpace(); +} + +QDataStream &operator<< ( QDataStream & stream, const Snore::Notification::Action & action); #endif // NOTIFICATION_H diff --git a/src/core/plugins/snorebackend.cpp b/src/core/plugins/snorebackend.cpp index 93aca61..03c25b2 100644 --- a/src/core/plugins/snorebackend.cpp +++ b/src/core/plugins/snorebackend.cpp @@ -68,8 +68,12 @@ bool SnoreBackend::requestCloseNotification ( Notification notification,Notifica void SnoreBackend::closeNotification(Notification n, NotificationEnums::CloseReasons::closeReasons reason) { - m_activeNotifications.remove(n.id()); + if(m_activeNotifications.contains(n.id())) + { + m_activeNotifications.remove(n.id()); + } n.setCloseReason(reason); + slotCloseNotification(n); emit closeNotification(n); } diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index f73e440..89aa900 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -61,9 +61,18 @@ public: }else if(msg->message == SNORENOTIFIER_MESSAGE_ID){ int action = msg->wParam & 0xffff; int data = (msg->wParam & 0xffffffff) >> 16; - uint notificationID = msg->lParam; + uint notificationID = 0; + for(QHash::iterator it = m_snarl->m_idMap.begin();it != m_snarl->m_idMap.end();++it) + { + if(it.value() == msg->lParam) + { + notificationID = it.key(); + break; + } + } + Notification notification = m_snarl->snore()->getActiveNotificationByID(notificationID); - qDebug()<<"recived a Snarl callback id:"<lParam <<"action:"<Hide(m_idMap.remove(notification.id())); +bool SnarlBackend::slotCloseNotification(Notification notification) +{ + m_defautSnarlinetrface->Hide(m_idMap.take(notification.id())); return true; } diff --git a/src/plugins/backends/snoretoast/snoretoast.cpp b/src/plugins/backends/snoretoast/snoretoast.cpp index eda42e3..e373bb2 100644 --- a/src/plugins/backends/snoretoast/snoretoast.cpp +++ b/src/plugins/backends/snoretoast/snoretoast.cpp @@ -65,7 +65,6 @@ void SnoreToast::slotNotify(Notification notification) connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus))); connect(qApp,SIGNAL(aboutToQuit()),p,SLOT(kill())); - connect(notification.data(),SIGNAL(destroyed()),p,SLOT(kill())); QStringList arguements; arguements << "-t"