21
21
using namespace hud::service;
24
QSharedPointer<ComCanonicalUnityVoiceInterface> voiceInterface) :
25
m_voiceInterface(voiceInterface), m_isListening(false) {
27
// connect voice interface signals to local signals
28
connect(m_voiceInterface.data(), SIGNAL( HeardSomething() ), this,
29
SIGNAL( HeardSomething() ));
30
connect(m_voiceInterface.data(), SIGNAL( Listening() ), this,
31
SIGNAL( Listening() ));
32
connect(m_voiceInterface.data(), SIGNAL( Loading() ), this,
23
VoiceImpl::VoiceImpl() {
36
26
VoiceImpl::~VoiceImpl() {
39
QString VoiceImpl::listen(const QList<QStringList>& commands) {
40
// return immediately if no commands were supplied
41
if (commands.isEmpty() || m_isListening) {
45
// call voice interface listen() asynchronously
47
QDBusPendingCall listen_async = m_voiceInterface->asyncCall("listen",
48
QVariant::fromValue(commands));
50
// connect a call watcher to the async call
51
QDBusPendingCallWatcher watcher(listen_async, this);
52
connect(&watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this,
53
SLOT(listenFinished(QDBusPendingCallWatcher*)));
55
// wait for async call to complete
57
m_isListening = false;
59
// return query set by listenFinished
63
void VoiceImpl::listenFinished(QDBusPendingCallWatcher *call) {
64
QDBusPendingReply<QString> query = *call;
66
// set m_query accordingly
67
if (query.isError()) {
68
qWarning() << query.error();
74
// notify listen() that the async call is complete
29
QString VoiceImpl::listen(const QList<QStringList>&) {