diff --git a/src/core/notification/notification.cpp b/src/core/notification/notification.cpp index 1491083..ee84815 100644 --- a/src/core/notification/notification.cpp +++ b/src/core/notification/notification.cpp @@ -27,10 +27,26 @@ using namespace Snore; -int Notification::DefaultTimeout = 10; +int Notification::m_defaultTimeout = 10; int NotificationData::notificationMetaID = qRegisterMetaType(); +Notification::Action::Action(int id, QString name): + m_id(id), + m_name(name) +{ + +} +QString Notification::Action::name() const +{ + return m_name; +} + +int Notification::Action::id() const +{ + return m_id; +} + Notification::Notification () : d(NULL) { @@ -132,8 +148,7 @@ const NotificationEnums::Prioritys::prioritys &Notification::priority() const void Notification::addAction(Notification::Action *a) { - qDebug()<<"Added notification"<id<name; - d->m_actions.insert(a->id,a); + d->m_actions.insert(a->id(),a); } @@ -169,6 +184,16 @@ NotificationData *Notification::data() { return d.data(); } +int Notification::defaultTimeout() +{ + return m_defaultTimeout; +} + +void Notification::setDefaultTimeout(int defaultTimeout) +{ + m_defaultTimeout = defaultTimeout; +} + QDataStream &operator<< ( QDataStream &stream, const Notification ¬i ) { @@ -179,7 +204,7 @@ QDataStream &operator<< ( QDataStream &stream, const Notification ¬i ) QDataStream &operator<< ( QDataStream &stream, const Notification::Action &a) { - stream< d; + static int m_defaultTimeout; + }; diff --git a/src/core/notification/notification_p.h b/src/core/notification/notification_p.h index 9774bbb..21af26d 100644 --- a/src/core/notification/notification_p.h +++ b/src/core/notification/notification_p.h @@ -32,7 +32,7 @@ namespace Snore{ class SNORE_EXPORT NotificationData : public QSharedData { - +friend class Notification; public: NotificationData ( const QString &application,const QString &alert,const QString &title,const QString &text,const Icon &icon, int timeout,NotificationEnums::Prioritys::prioritys priority ); @@ -41,6 +41,8 @@ public: void setActionInvoked ( Notification::Action *action ); void setActionInvoked ( const int &actionID); +private: + Q_DISABLE_COPY(NotificationData) uint m_id; uint m_updateID; @@ -61,9 +63,6 @@ public: static uint m_idCount; static int notificationMetaID; -private: - Q_DISABLE_COPY(NotificationData) - }; } diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index 31e4352..3418f28 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -226,7 +226,7 @@ void SnarlBackend::slotNotify(Notification notification){ priority); foreach(const Notification::Action *a, notification.actions()){ - snarlInterface->AddAction(id,a->name.toUtf8().constData(),QString("@").append(QString::number(a->id)).toUtf8().constData()); + snarlInterface->AddAction(id,a->name().toUtf8().constData(),QString("@").append(QString::number(a->id())).toUtf8().constData()); } m_idMap[notification.id()] = id; qDebug() << "snarl" << id << notification.id(); diff --git a/src/plugins/backends/trayicon/trayiconnotifer.cpp b/src/plugins/backends/trayicon/trayiconnotifer.cpp index 6436602..02ee74d 100644 --- a/src/plugins/backends/trayicon/trayiconnotifer.cpp +++ b/src/plugins/backends/trayicon/trayiconnotifer.cpp @@ -32,7 +32,7 @@ bool TrayIconNotifer::init(SnoreCore *snore){ void TrayIconNotifer::slotNotify( Notification notification ) { m_notificationQue.append(notification); - if(m_lastNotify.elapsed()> Notification::DefaultTimeout * 1000){ + if(m_lastNotify.elapsed()> Notification::defaultTimeout() * 1000){ displayNotification(); } } diff --git a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp index 6024b4e..c094ff9 100644 --- a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp +++ b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp @@ -57,7 +57,7 @@ bool FreedesktopFrontend::init(SnoreCore *snore){ void FreedesktopFrontend::actionInvoked(Notification notification) { if(notification.actionInvoked()) { - emit ActionInvoked(notification.id(),QString::number(notification.actionInvoked()->id)); + emit ActionInvoked(notification.id(),QString::number(notification.actionInvoked()->id())); } } @@ -99,7 +99,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id, priotity = NotificationEnums::Prioritys::prioritys(hints["urgency"].toInt()-1); } - Notification noti(app_name,"DBus Alert",summary,body,icon,timeout==-1?Notification::DefaultTimeout:timeout/1000,priotity); + Notification noti(app_name,"DBus Alert",summary,body,icon,timeout==-1?Notification::defaultTimeout():timeout/1000,priotity); if(replaces_id != 0) { noti.setUpdateID(replaces_id); diff --git a/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp b/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp index ccad25c..d32f45d 100644 --- a/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp +++ b/src/plugins/frontends/snarlnetwork/snarlnetwork.cpp @@ -56,9 +56,9 @@ bool SnarlNetworkFrontend::init(SnoreCore *snore){ void SnarlNetworkFrontend::actionInvoked(Notification notification){ //TODO:fix callback SnarlNotification sn=notifications.value(notification.id()); - if(notification.actionInvoked()->id == 1 ) + if(notification.actionInvoked()->id() == 1 ) callback(sn,"SNP/1.1/304/Notification acknowledged/"); - else if(notification.actionInvoked()->id == 2) + else if(notification.actionInvoked()->id() == 2) callback(sn,"SNP/1.1/302/Notification cancelled/"); } void SnarlNetworkFrontend::notificationClosed(Notification notification){