Skip to content

Commit 0cf38d1

Browse files
authored
Merge pull request #124 from MycroftAI/feat/qt_version_context
add qt_version context message
2 parents 53fb4a1 + 77fcfb8 commit 0cf38d1

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

import/mycroftcontroller.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "abstractskillview.h"
2424
#include "controllerconfig.h"
2525

26+
#include <QtGlobal>
2627
#include <QJsonObject>
2728
#include <QJsonArray>
2829
#include <QJsonDocument>
@@ -50,6 +51,7 @@ MycroftController::MycroftController(QObject *parent)
5051
: QObject(parent),
5152
m_appSettingObj(new GlobalSettings)
5253
{
54+
m_qt_version_context = QStringLiteral("5");
5355
connect(&m_mainWebSocket, &QWebSocket::connected, this,
5456
[this] () {
5557
m_reconnectTimer.stop();
@@ -61,9 +63,16 @@ MycroftController::MycroftController(QObject *parent)
6163
emit socketStatusChanged();
6264
if (state == QAbstractSocket::ConnectedState) {
6365
qWarning() << "Main Socket connected, trying to connect gui";
66+
#if QT_VERSION >= 0x060000
67+
m_qt_version_context = QStringLiteral("6");
68+
#else
69+
m_qt_version_context = QStringLiteral("5");
70+
#endif
71+
6472
for (const auto &guiId : m_views.keys()) {
6573
sendRequest(QStringLiteral("mycroft.gui.connected"),
66-
QVariantMap({{QStringLiteral("gui_id"), guiId}}));
74+
QVariantMap({{QStringLiteral("gui_id"), guiId}}),
75+
QVariantMap({{QStringLiteral("qt_version"), m_qt_version_context}}));
6776
}
6877
m_reannounceGuiTimer.start();
6978

@@ -93,7 +102,7 @@ MycroftController::MycroftController(QObject *parent)
93102
if (m_views[guiId]->status() != Open) {
94103
qWarning()<<"Retrying to announce gui";
95104
sendRequest(QStringLiteral("mycroft.gui.connected"),
96-
QVariantMap({{QStringLiteral("gui_id"), guiId}}));
105+
QVariantMap({{QStringLiteral("gui_id"), guiId}}), QVariantMap({{QStringLiteral("qt_version"), m_qt_version_context}}));
97106
}
98107
}
99108
});
@@ -339,10 +348,7 @@ void MycroftController::sendRequest(const QString &type, const QVariantMap &data
339348

340349
root[QStringLiteral("type")] = type;
341350
root[QStringLiteral("data")] = QJsonObject::fromVariantMap(data);
342-
343-
if(m_appSettingObj->useHivemindProtocol()){
344-
root[QStringLiteral("context")] = QJsonObject::fromVariantMap(context);
345-
}
351+
root[QStringLiteral("context")] = QJsonObject::fromVariantMap(context);
346352

347353
QJsonDocument doc(root);
348354
m_mainWebSocket.sendTextMessage(QString::fromUtf8(doc.toJson()));
@@ -371,9 +377,9 @@ void MycroftController::sendBinary(const QString &type, const QJsonObject &data,
371377
void MycroftController::sendText(const QString &message)
372378
{
373379
if(!m_appSettingObj->useHivemindProtocol()){
374-
sendRequest(QStringLiteral("recognizer_loop:utterance"), QVariantMap({{QStringLiteral("utterances"), QStringList({message})}}), QVariantMap({{QStringLiteral("source"), QStringLiteral("debug_cli")}, {QStringLiteral("destination"), QStringLiteral("skills")}}));
380+
sendRequest(QStringLiteral("recognizer_loop:utterance"), QVariantMap({{QStringLiteral("utterances"), QStringList({message})}}), QVariantMap({{QStringLiteral("source"), QStringLiteral("debug_cli")}, {QStringLiteral("destination"), QStringLiteral("skills")}, {QStringLiteral("qt_version"), m_qt_version_context}}));
375381
} else {
376-
sendRequest(QStringLiteral("recognizer_loop:utterance"), QVariantMap({{QStringLiteral("utterances"), QStringList({message})}}), QVariantMap({{QStringLiteral("source"), QStringLiteral("mycroft-gui")}, {QStringLiteral("destination"), QStringLiteral("skills")}}));
382+
sendRequest(QStringLiteral("recognizer_loop:utterance"), QVariantMap({{QStringLiteral("utterances"), QStringList({message})}}), QVariantMap({{QStringLiteral("source"), QStringLiteral("mycroft-gui")}, {QStringLiteral("destination"), QStringLiteral("skills")}, {QStringLiteral("qt_version"), m_qt_version_context}}));
377383
}
378384
}
379385

@@ -385,7 +391,7 @@ void MycroftController::registerView(AbstractSkillView *view)
385391
//TODO: manage view destruction
386392
if (m_mainWebSocket.state() == QAbstractSocket::ConnectedState) {
387393
sendRequest(QStringLiteral("mycroft.gui.connected"),
388-
QVariantMap({{QStringLiteral("gui_id"), view->id()}}));
394+
QVariantMap({{QStringLiteral("gui_id"), view->id()}}), QVariantMap({{QStringLiteral("qt_version"), m_qt_version_context}}));
389395
}
390396
}
391397

import/mycroftcontroller.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ public Q_SLOTS:
128128
bool m_isExpectingSpeechResponse = false;
129129
QQueue<QString> ttsqueue;
130130
#endif
131-
131+
132+
QString m_qt_version_context;
132133
bool m_isSpeaking = false;
133134
bool m_isListening = false;
134135
bool m_mycroftLaunched = false;

0 commit comments

Comments
 (0)