Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #98 from matthewvogt/mer-1106
[commhistory-daemon] Ensure closed notifications are removed. Contributes to MER#1106
  • Loading branch information
matthewvogt committed Jun 17, 2015
2 parents d0d32e1 + 89eaa01 commit 500724b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
20 changes: 16 additions & 4 deletions src/notificationgroup.cpp
Expand Up @@ -140,8 +140,10 @@ void NotificationGroup::updateGroup()
}

// Publish group notification, not including preview banners/sounds.
if (!mGroup)
if (!mGroup) {
mGroup = new Notification(this);
connect(mGroup, SIGNAL(closed(uint)), SLOT(onClosed(uint)));
}

mGroup->setAppName(groupName(m_collection));
mGroup->setCategory(groupCategory(m_collection));
Expand Down Expand Up @@ -171,7 +173,6 @@ void NotificationGroup::updateGroup()

mGroup->setTimestamp(groupTimestamp);
mGroup->publish();

}

void NotificationGroup::updateGroupLater()
Expand Down Expand Up @@ -242,7 +243,7 @@ void NotificationGroup::removeGroup()
{
if (mGroup) {
mGroup->close();
delete mGroup;
mGroup->deleteLater();
mGroup = 0;
}

Expand All @@ -257,6 +258,7 @@ void NotificationGroup::addNotification(PersonalNotification *notification)

// If notification->hasPendingEvents, the updateGroup slot will also publish the notification
connect(notification, SIGNAL(hasPendingEventsChanged(bool)), SLOT(onNotificationChanged()));
connect(notification, SIGNAL(notificationClosed(PersonalNotification*)), SLOT(onNotificationClosed(PersonalNotification*)));
mNotifications.append(notification);

// Only missed call and voicemail notifications are grouped
Expand All @@ -281,7 +283,7 @@ bool NotificationGroup::removeNotification(PersonalNotification *&notification)
{
if (mNotifications.removeOne(notification)) {
notification->removeNotification();
delete notification;
notification->deleteLater();
notification = 0;

if (m_collection == PersonalNotification::Voice ||
Expand Down Expand Up @@ -309,3 +311,13 @@ void NotificationGroup::onNotificationChanged()
emit changed();
}

void NotificationGroup::onNotificationClosed(PersonalNotification *notification)
{
removeNotification(notification);
}

void NotificationGroup::onClosed(uint /*reason*/)
{
removeGroup();
}

2 changes: 2 additions & 0 deletions src/notificationgroup.h
Expand Up @@ -90,6 +90,8 @@ public slots:

private slots:
void onNotificationChanged();
void onNotificationClosed(PersonalNotification *);
void onClosed(uint);

private:
PersonalNotification::EventCollection m_collection;
Expand Down
15 changes: 12 additions & 3 deletions src/personalnotification.cpp
Expand Up @@ -87,6 +87,7 @@ bool PersonalNotification::restore(Notification *n)
return false;

m_notification = n;
connect(m_notification, SIGNAL(closed(uint)), SLOT(onClosed(uint)));
return true;
}

Expand All @@ -111,6 +112,8 @@ void PersonalNotification::publishNotification()

if (!m_notification) {
m_notification = new Notification(this);
connect(m_notification, SIGNAL(closed(uint)), SLOT(onClosed(uint)));

m_notification->setTimestamp(QDateTime::currentDateTimeUtc());
}

Expand Down Expand Up @@ -143,10 +146,11 @@ void PersonalNotification::publishNotification()
void PersonalNotification::removeNotification()
{
DEBUG() << "removing notification" << m_notification;
if (m_notification)
if (m_notification) {
m_notification->close();
delete m_notification;
m_notification = 0;
m_notification->deleteLater();
m_notification = 0;
}

setHasPendingEvents(false);
}
Expand Down Expand Up @@ -358,6 +362,11 @@ void PersonalNotification::setHidden(bool hide)
}
}

void PersonalNotification::onClosed(uint /*reason*/)
{
emit notificationClosed(this);
}

QDataStream& operator<<(QDataStream &out, const RTComLogger::PersonalNotification &key)
{
key.serialize(out, key);
Expand Down
4 changes: 4 additions & 0 deletions src/personalnotification.h
Expand Up @@ -128,6 +128,10 @@ class PersonalNotification : public QObject, public Serialisable

signals:
void hasPendingEventsChanged(bool hasPendingEvents);
void notificationClosed(PersonalNotification *);

private slots:
void onClosed(uint);

private:
QString m_remoteUid;
Expand Down

0 comments on commit 500724b

Please sign in to comment.