~untrusted-ci-dev-bot/hud/hud-ubuntu-yakkety-landing-000

« back to all changes in this revision

Viewing changes to service/VoiceImpl.cpp

  • Committer: CI Train Bot
  • Author(s): Pete Woods
  • Date: 2015-08-20 13:45:56 UTC
  • mfrom: (398.1.21 14.10)
  • Revision ID: ci-train-bot@canonical.com-20150820134556-j0jje7kanocxo7dl
Remove unity-voice Fixes: #1483210

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
using namespace hud::service;
22
22
 
23
 
VoiceImpl::VoiceImpl(
24
 
                QSharedPointer<ComCanonicalUnityVoiceInterface> voiceInterface) :
25
 
                m_voiceInterface(voiceInterface), m_isListening(false) {
26
 
 
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,
33
 
                        SIGNAL( Loading() ));
 
23
VoiceImpl::VoiceImpl() {
34
24
}
35
25
 
36
26
VoiceImpl::~VoiceImpl() {
37
27
}
38
28
 
39
 
QString VoiceImpl::listen(const QList<QStringList>& commands) {
40
 
        // return immediately if no commands were supplied
41
 
        if (commands.isEmpty() || m_isListening) {
42
 
                return QString();
43
 
        }
44
 
 
45
 
        // call voice interface listen() asynchronously
46
 
        m_isListening = true;
47
 
        QDBusPendingCall listen_async = m_voiceInterface->asyncCall("listen",
48
 
                        QVariant::fromValue(commands));
49
 
 
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*)));
54
 
 
55
 
        // wait for async call to complete
56
 
        m_listenWait.exec();
57
 
        m_isListening = false;
58
 
 
59
 
        // return query set by listenFinished
60
 
        return m_query;
61
 
}
62
 
 
63
 
void VoiceImpl::listenFinished(QDBusPendingCallWatcher *call) {
64
 
        QDBusPendingReply<QString> query = *call;
65
 
 
66
 
        // set m_query accordingly
67
 
        if (query.isError()) {
68
 
                qWarning() << query.error();
69
 
                m_query = "";
70
 
        } else {
71
 
                m_query = query;
72
 
        }
73
 
 
74
 
        // notify listen() that the async call is complete
75
 
        m_listenWait.quit();
 
29
QString VoiceImpl::listen(const QList<QStringList>&) {
 
30
        return QString();
76
31
}