Skip to content

Commit

Permalink
Merge pull request #16 from special/master
Browse files Browse the repository at this point in the history
[commhistory-daemon] Use NGF to play sounds instead of notifications on active conversations
  • Loading branch information
special committed Aug 20, 2013
2 parents e286ee7 + 79dbd7e commit 22c5188
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions rpm/commhistory-daemon.spec
Expand Up @@ -16,6 +16,7 @@ BuildRequires: pkgconfig(TelepathyQt5)
BuildRequires: pkgconfig(mlite5)
BuildRequires: pkgconfig(mlocale5)
BuildRequires: pkgconfig(qmsystem2-qt5)
BuildRequires: pkgconfig(ngf-qt5)
BuildRequires: qt5-qttools
BuildRequires: qt5-qttools-linguist
BuildRequires: python
Expand Down
26 changes: 26 additions & 0 deletions src/notificationmanager.cpp
Expand Up @@ -51,6 +51,9 @@
// Telepathy includes
#include <TelepathyQt/Constants>

// NGF-Qt includes
#include <NgfClient>

// Our includes
#include "notificationmanager.h"
#include "locstrings.h"
Expand Down Expand Up @@ -160,6 +163,8 @@ NotificationManager::NotificationManager(QObject* parent)
, m_pContactManager(0)
, m_GroupModel(0)
, m_pDisplayState(0)
, m_ngfClient(0)
, m_ngfEvent(0)
{
qRegisterMetaType<RTComLogger::NotificationGroup>("RTComLogger::NotificationGroup");
qRegisterMetaTypeStreamOperators<RTComLogger::NotificationGroup>("RTComLogger::NotificationGroup");
Expand Down Expand Up @@ -188,6 +193,10 @@ void NotificationManager::init()
return;
}

m_ngfClient = new Ngf::Client(this);
connect(m_ngfClient, SIGNAL(eventFailed(quint32)), SLOT(slotNgfEventFinished(quint32)));
connect(m_ngfClient, SIGNAL(eventCompleted(quint32)), SLOT(slotNgfEventFinished(quint32)));

// creates data directory
createDataDir();
// Loads old state
Expand Down Expand Up @@ -361,6 +370,16 @@ void NotificationManager::showNotification(const CommHistory::Event& event,
event.type() == CommHistory::Event::MMSEvent) {
undimScreen();
}
} else {
if (!m_ngfClient->isConnected())
m_ngfClient->connect();

if (!m_ngfEvent) {
if (event.type() == CommHistory::Event::SMSEvent || event.type() == CommHistory::Event::MMSEvent)
m_ngfEvent = m_ngfClient->play(QLatin1Literal("sms_fg"));
else
m_ngfEvent = m_ngfClient->play(QLatin1Literal("chat_fg"));
}
}
}

Expand Down Expand Up @@ -1633,3 +1652,10 @@ void NotificationManager::slotGroupDataChanged(const QModelIndex &topLeft, const
}
}
}

void NotificationManager::slotNgfEventFinished(quint32 id)
{
if (id == m_ngfEvent)
m_ngfEvent = 0;
}

7 changes: 7 additions & 0 deletions src/notificationmanager.h
Expand Up @@ -57,6 +57,10 @@ namespace CommHistory {
class GroupModel;
}

namespace Ngf {
class Client;
}

namespace RTComLogger {

class MWIListener;
Expand Down Expand Up @@ -144,6 +148,7 @@ private Q_SLOTS:
void slotMWICountChanged(int count);
void slotContactRequestTimeout();
void slotGroupDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void slotNgfEventFinished(quint32 id);

private:

Expand Down Expand Up @@ -244,6 +249,8 @@ private Q_SLOTS:

MWIListener *m_pMWIListener;
MeeGo::QmDisplayState *m_pDisplayState;
Ngf::Client *m_ngfClient;
quint32 m_ngfEvent;

#ifdef UNIT_TEST
friend class Ut_NotificationManager;
Expand Down
2 changes: 1 addition & 1 deletion src/src.pro
Expand Up @@ -35,7 +35,7 @@ QT += dbus contacts versit

CONFIG += debug

PKGCONFIG += qmsystem2-qt5
PKGCONFIG += qmsystem2-qt5 ngf-qt5
PKGCONFIG += TelepathyQt5 commhistory-qt5 mlite5 mlocale5
# clock_gettime
LIBS += -lrt
Expand Down
2 changes: 1 addition & 1 deletion tests/ut_notificationmanager/ut_notificationmanager.pro
Expand Up @@ -34,7 +34,7 @@
#-----------------------------------------------------------------------------
TARGET = ut_notificationmanager

PKGCONFIG += mlocale5 qmsystem2-qt5 TelepathyQt5
PKGCONFIG += mlocale5 qmsystem2-qt5 TelepathyQt5 ngf-qt5

TEST_SOURCES += $$COMMHISTORYDSRCDIR/notificationmanager.cpp \
$$COMMHISTORYDSRCDIR/notificationgroup.cpp \
Expand Down

0 comments on commit 22c5188

Please sign in to comment.