Skip to content

Commit

Permalink
Merge pull request #94 from matthewvogt/mer-1086
Browse files Browse the repository at this point in the history
[commhistory-daemon] Report initial voicemail waiting state. Contributes to MER#1086
  • Loading branch information
matthewvogt committed Jun 9, 2015
2 parents 2a5001b + 70882bf commit d8faf38
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions src/notificationmanager.cpp
Expand Up @@ -92,11 +92,15 @@ void NotificationManager::init()
connect(m_ngfClient, SIGNAL(eventCompleted(quint32)), SLOT(slotNgfEventFinished(quint32)));

m_messageWaiting = new QOfonoMessageWaiting(this);
connect(m_messageWaiting, SIGNAL(voicemailWaitingChanged(bool)), SLOT(slotVoicemailWaitingChanged(bool)));
connect(m_messageWaiting, SIGNAL(voicemailWaitingChanged(bool)), SLOT(slotVoicemailWaitingChanged()));
connect(m_messageWaiting, SIGNAL(voicemailMessageCountChanged(int)), SLOT(slotVoicemailWaitingChanged()));

// Loads old state
syncNotifications();

// Update the voicemail state
slotVoicemailWaitingChanged();

CommHistoryService *service = CommHistoryService::instance();
connect(service, SIGNAL(inboxObservedChanged(bool,QString)), SLOT(slotInboxObservedChanged()));
connect(service, SIGNAL(callHistoryObservedChanged(bool)), SLOT(slotCallHistoryObservedChanged(bool)));
Expand Down Expand Up @@ -760,8 +764,13 @@ void NotificationManager::slotNgfEventFinished(quint32 id)
m_ngfEvent = 0;
}

void NotificationManager::slotVoicemailWaitingChanged(bool waiting)
void NotificationManager::slotVoicemailWaitingChanged()
{
const bool waiting(m_messageWaiting->voicemailWaiting());
const int messageCount(m_messageWaiting->voicemailMessageCount());

DEBUG() << Q_FUNC_INFO << waiting << messageCount;

uint currentId = 0;

// See if there is a current notification for voicemail waiting
Expand All @@ -772,17 +781,18 @@ void NotificationManager::slotVoicemailWaitingChanged(bool waiting)
if (waiting) {
// The notification is already present; do nothing
currentId = n->replacesId();
DEBUG() << "Extant voicemail waiting notification:" << n->replacesId();
} else {
// Close this notification
DEBUG() << "Closing voicemail waiting notification:" << n->replacesId();
n->close();
}
}
}
qDeleteAll(notifications);
notifications.clear();

if (waiting && (currentId == 0)) {
const int messageCount(m_messageWaiting->voicemailMessageCount());
if (waiting) {
const QString voicemailNumber(m_messageWaiting->voicemailMailboxNumber());

// Publish a new voicemail-waiting notification
Expand Down Expand Up @@ -821,7 +831,9 @@ void NotificationManager::slotVoicemailWaitingChanged(bool waiting)
voicemailNotification.setRemoteActions(QVariantList() << dbusAction("default", service, path, iface, method, args)
<< dbusAction("app", service, path, iface, method, args));

voicemailNotification.setReplacesId(currentId);
voicemailNotification.publish();
DEBUG() << (currentId ? "Updated" : "Created") << "voicemail waiting notification:" << voicemailNotification.replacesId();
}
}

2 changes: 1 addition & 1 deletion src/notificationmanager.h
Expand Up @@ -147,7 +147,7 @@ private Q_SLOTS:
void slotContactRemoved(quint32 localId);
void slotContactUnknown(const QPair<QString,QString> &address);
void slotClassZeroError(const QDBusError &error);
void slotVoicemailWaitingChanged(bool waiting);
void slotVoicemailWaitingChanged();

private:
NotificationManager( QObject* parent = 0);
Expand Down

0 comments on commit d8faf38

Please sign in to comment.