24#include <QAbstractSocket>
26#include <QLoggingCategory>
28#include <QJsonDocument>
33#define TP_CLIENT_VERSION_STR "1.0.0"
38#if !defined(TPCLIENT_LIB_EXPORT)
39 #if defined(TPCLIENT_BUILD_DLL)
40 #define TPCLIENT_LIB_EXPORT Q_DECL_EXPORT
41 #elif defined(TPCLIENT_USE_DLL)
42 #define TPCLIENT_LIB_EXPORT Q_DECL_IMPORT
44 #define TPCLIENT_LIB_EXPORT
48Q_DECLARE_LOGGING_CATEGORY(lcTPC);
98 shortConnectorIdNotification,
101 notificationOptionClicked,
111 uint16_t sdkVersion = 0;
112 uint32_t tpVersionCode = 0;
113 uint32_t pluginVersion = 0;
129 explicit TPClientQt(
const char *pluginId, QObject *parent =
nullptr);
136 bool isConnected()
const;
138 QAbstractSocket::SocketState socketState()
const;
140 QAbstractSocket::SocketError socketError()
const;
142 QString errorString()
const;
148 QString pluginId()
const;
150 bool setPluginId(
const char *pluginId);
153 QString hostName()
const;
155 uint16_t hostPort()
const;
159 void setHostProperties(
const QString &nameOrAddress = QStringLiteral(
"127.0.0.1"), uint16_t port = 12136);
162 int connectionTimeout()
const;
166 void setConnectionTimeout(
int timeoutMs = 10000);
184 void error(QAbstractSocket::SocketError error);
195 inline void stateUpdate(
const char *
id,
const char *value)
const;
197 inline void createState(
const char *
id,
const char *parentGroup,
const char *desc,
const char *defaultValue)
const;
199 inline void createState(
const std::string &
id,
const std::string &parentGroup,
const std::string &desc,
const std::string &defaultValue =
"")
const {
createState(
id.c_str(), parentGroup.c_str(), desc.c_str(), defaultValue.c_str()); }
201 inline void createState(
const char *
id,
const char *desc,
const char *defaultValue)
const {
createState(
id,
nullptr, desc, defaultValue); }
203 inline void createState(
const std::string &
id,
const std::string &desc,
const std::string &defaultValue =
"")
const {
createState(
id.c_str(),
nullptr, desc.c_str(), defaultValue.c_str()); }
205 inline void removeState(
const char *
id)
const;
210 inline void choiceUpdate(
const char *
id,
const QJsonArray &values)
const;
212 inline void choiceUpdate(
const char *
id,
const QVector<const char *> &values)
const {
choiceUpdate(
id, stringContainerToJsonArray(values)); }
214 inline void choiceUpdate(
const char *
id,
const QStringList &values)
const {
choiceUpdate(
id, QJsonArray::fromStringList(values)); }
216 inline void choiceUpdate(
const std::string &
id,
const std::vector<std::string> &values)
const {
choiceUpdate(
id.c_str(), stringContainerToJsonArray(values)); }
218 inline void choiceUpdate(
const char *
id,
const char *instanceId,
const QJsonArray &values)
const;
220 inline void choiceUpdate(
const char *
id,
const char *instanceId,
const QVector<const char *> &values)
const {
choiceUpdate(
id, instanceId, stringContainerToJsonArray(values)); }
222 inline void choiceUpdate(
const char *
id,
const char *instanceId,
const QStringList &values)
const {
choiceUpdate(
id, instanceId, QJsonArray::fromStringList(values)); }
224 inline void choiceUpdate(
const std::string &
id,
const std::string &instanceId,
const std::vector<std::string> &values)
const {
choiceUpdate(
id.c_str(), instanceId.c_str(), stringContainerToJsonArray(values)); }
227 inline void connectorUpdate(
const char *shortId, uint8_t value)
const;
233 inline void connectorUpdate(
const char *connectortId, uint8_t value,
bool addPrefix)
const;
240 inline void connectorUpdate(
const char *connectortId,
const QMap<const char*, const char*> &nvPairs, uint8_t value,
bool addPrefix =
true)
const;
243 inline void settingUpdate(
const char *name,
const char *value)
const;
249 inline void showNotification(
const char *notificationId,
const char *title,
const char *msg,
const QJsonArray &options)
const;
252 inline void showNotification(
const char *notificationId,
const char *title,
const char *msg,
const QVariantList &options)
const {
showNotification(notificationId, title, msg, QJsonArray::fromVariantList(options)); }
254 inline void showNotification(
const char *notificationId,
const char *title,
const char *msg,
const QVector<QPair<const char*, const char *>> &options)
const;
256 inline void showNotification(
const char *notificationId,
const char *title,
const char *msg,
const std::vector<std::pair<const char*, const char *>> &options)
const;
258 inline void showNotification(
const std::string ¬ificationId,
const std::string &title,
const std::string &msg,
const std::vector<std::pair<std::string, std::string>> &options)
const;
265 QByteArray
encode(
const QJsonObject &
object)
const {
return QJsonDocument(
object).toJson(QJsonDocument::Compact); }
269#define qsvPrintable(SV) (SV).toUtf8().constData()
285 inline void connect(
int timeout,
const QString &host = QString(), uint16_t port = 0);
289 void disconnect()
const;
298 inline void send(
const QJsonObject &
object)
const { write(encode(
object)); }
300 inline void sendMap(
const QVariantMap &map)
const { write(encode(QJsonObject::fromVariantMap(map))); }
303 void write(
const QByteArray &data)
const;
311 inline void stateUpdate(
const QByteArray &
id,
const QByteArray &value)
const {
stateUpdate(
id.constData(), value.constData()); }
316 inline void createState(
const QByteArray &
id,
const QByteArray &parentGroup,
const QByteArray &desc,
const QByteArray &defaultValue)
const {
createState(
id.constData(), parentGroup.constData(), desc.constData(), defaultValue.constData()); }
318 inline void createState(QStringView
id, QStringView parentGroup, QStringView desc, QStringView defaultValue)
const {
createState(qsvPrintable(
id), qsvPrintable(parentGroup), qsvPrintable(desc), qsvPrintable(defaultValue)); }
320 inline void createState(
const QByteArray &
id,
const QByteArray &desc,
const QByteArray &defaultValue)
const {
createState(
id.constData(),
nullptr, desc.constData(), defaultValue.constData()); }
322 inline void createState(QStringView
id, QStringView desc, QStringView defaultValue)
const {
createState(qsvPrintable(
id),
nullptr, qsvPrintable(desc), qsvPrintable(defaultValue)); }
332 inline void choiceUpdate(
const QByteArray &
id,
const QVector<QByteArray> &values)
const {
choiceUpdate(
id.constData(), stringContainerToJsonArray(values)); }
334 inline void choiceUpdate(
const QByteArray &
id,
const QStringList &values)
const {
choiceUpdate(
id.constData(), QJsonArray::fromStringList(values)); }
335#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) || defined(DOXYGEN)
338 inline void choiceUpdate(
const QByteArray &
id,
const QByteArrayList &values)
const {
choiceUpdate(
id.constData(), stringContainerToJsonArray(values)); }
343 inline void choiceUpdate(QStringView
id,
const QVector<QStringView> &values)
const {
choiceUpdate(qsvPrintable(
id), stringContainerToJsonArray(values)); }
345 inline void choiceUpdate(QStringView
id,
const QStringList &values)
const {
choiceUpdate(qsvPrintable(
id), QJsonArray::fromStringList(values)); }
347 inline void choiceUpdate(QStringView
id,
const QByteArrayList &values)
const {
choiceUpdate(qsvPrintable(
id), stringContainerToJsonArray(values)); }
350 inline void choiceUpdate(
const QByteArray &
id,
const QByteArray &instanceId,
const QJsonArray &values)
const {
choiceUpdate(
id.constData(), instanceId.constData(), values); }
352 inline void choiceUpdate(
const QByteArray &
id,
const QByteArray &instanceId,
const QVector<QByteArray> &values)
const {
choiceUpdate(
id.constData(), instanceId.constData(), stringContainerToJsonArray(values)); }
354 inline void choiceUpdate(
const QByteArray &
id,
const QByteArray &instanceId,
const QStringList &values)
const {
choiceUpdate(
id.constData(), instanceId.constData(), QJsonArray::fromStringList(values)); }
355#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) || defined(DOXYGEN)
358 inline void choiceUpdate(
const QByteArray &
id,
const QByteArray &instanceId,
const QByteArrayList &values)
const {
choiceUpdate(
id.constData(), instanceId.constData(), stringContainerToJsonArray(values)); }
361 inline void choiceUpdate(QStringView
id, QStringView instanceId,
const QJsonArray &values)
const {
choiceUpdate(qsvPrintable(
id), qsvPrintable(instanceId), values); }
363 inline void choiceUpdate(QStringView
id, QStringView instanceId,
const QVector<QStringView> &values)
const {
choiceUpdate(qsvPrintable(
id), qsvPrintable(instanceId), stringContainerToJsonArray(values)); }
365 inline void choiceUpdate(QStringView
id, QStringView instanceId,
const QStringList &values)
const {
choiceUpdate(qsvPrintable(
id), qsvPrintable(instanceId), QJsonArray::fromStringList(values)); }
367 inline void choiceUpdate(QStringView
id, QStringView instanceId,
const QByteArrayList &values)
const {
choiceUpdate(qsvPrintable(
id), qsvPrintable(instanceId), stringContainerToJsonArray(values)); }
376 inline void connectorUpdate(
const QByteArray &connectortId, uint8_t value,
bool addPrefix)
const {
connectorUpdate(connectortId.constData(), value, addPrefix); }
383 inline void connectorUpdate(
const QByteArray &connectortId,
const QMap<const QByteArray, const QByteArray> &nvPairs, uint8_t value,
bool addPrefix =
true)
const;
387 inline void connectorUpdate(QStringView connectortId,
const QMap<QStringView, QStringView> &nvPairs, uint8_t value,
bool addPrefix =
true)
const;
396 inline void showNotification(
const QByteArray ¬ificationId,
const QByteArray &title,
const QByteArray &msg,
const QJsonArray &options)
const {
showNotification(notificationId.constData(), title.constData(), msg.constData(), options); }
399 inline void showNotification(
const QByteArray ¬ificationId,
const QByteArray &title,
const QByteArray &msg,
const QVariantList &options)
const {
showNotification(notificationId.constData(), title.constData(), msg.constData(), QJsonArray::fromVariantList(options)); }
402 inline void showNotification(QStringView notificationId, QStringView title, QStringView msg,
const QVariantList &options)
const {
showNotification(qsvPrintable(notificationId), qsvPrintable(title), qsvPrintable(msg), options); }
404 inline void showNotification(
const QByteArray ¬ificationId,
const QByteArray &title,
const QByteArray &msg,
const QVector<QPair<QLatin1String, QStringView>> &options)
const;
406 inline void showNotification(QStringView notificationId, QStringView title, QStringView msg,
const QVector<QPair<QStringView, QStringView> > &options)
const;
416 static inline ActionDataItem actionDataItem(
int index,
const QJsonArray &data,
const ActionDataItem &defaultItem = ActionDataItem());
419 static inline QString actionDataValue(
int index,
const QJsonArray &data,
const QString &defaultValue = QLatin1String(
""));
424 static inline QString actionDataValue(
const char *
id,
const QJsonArray &data,
const QString &defaultValue = QLatin1String(
""));
427 static inline QVector<ActionDataItem> actionDataToItemArray(
const QJsonArray &data,
char separator = 0);
431 static inline QMap<QString, QString> actionDataToMap(
const QJsonArray &data,
char separator = 0);
440 friend struct Private;
443 template <
typename Vect,
typename T =
typename Vect::value_type>
444 QJsonArray stringContainerToJsonArray(
const Vect &list)
const
447 for (
typename Vect::const_iterator it = list.cbegin(); it != list.cend(); ++it) {
448 const T &val =
static_cast<T
>(* it);
449 if constexpr (std::is_same_v<T, QStringView>)
450 ret.append(val.toString());
451 else if constexpr (std::is_same_v<T, QByteArray>)
452 ret.append(QString(val));
453 else if constexpr (std::is_same_v<T, std::string>)
454 ret.append(val.c_str());
455 else if constexpr (std::is_same_v<T, std::wstring>)
456 ret.append(QString::fromStdWString(val));
458 ret.append(QJsonValue(val));
463 template <
typename Vect,
464 typename Pair =
typename Vect::value_type,
465 typename Key = std::remove_const_t<typename Pair::first_type>,
466 typename Val = std::remove_const_t<typename Pair::second_type> >
467 QJsonArray arrayOfObjectsToJsonArray(
const Vect &list)
const
470 for (
typename Vect::const_iterator it = list.cbegin(); it != list.cend(); ++it) {
471 const Key &key =
static_cast<Key
>(it->first);
472 const Val &val =
static_cast<Val
>(it->second);
474 if constexpr (std::is_same_v<Val, QStringView>)
475 jval = val.toString();
476 else if constexpr (std::is_same_v<Val, QByteArray>)
478 else if constexpr (std::is_same_v<Val, std::string>)
480 else if constexpr (std::is_same_v<Val, std::wstring>)
481 jval = QString::fromStdWString(val);
485 if constexpr (std::is_same_v<Key, QStringView>)
486 ret.append({ {key.toString(), jval} });
487 else if constexpr (std::is_same_v<Key, std::string>)
488 ret.append({ {QString::fromStdString(key), jval} });
490 ret.append({ {QString(key), jval} });
509 {
"type",
"stateUpdate"},
519 {
"type",
"createState"},
521 {
"desc", desc ? desc :
""},
522 {
"defaultValue", defaultValue ? defaultValue :
""},
523 {
"parentGroup", parentGroup ? parentGroup :
""}
531 {
"type",
"removeState"},
540 {
"type",
"choiceUpdate"},
550 {
"type",
"choiceUpdate"},
552 {
"instanceId", instanceId},
561 {
"type",
"connectorUpdate"},
562 {
"shortId", shortId},
571 {
"type",
"connectorUpdate"},
572 {
"connectorId", addPrefix ? qsvPrintable(
"pc_" +
pluginId() +
'_' + connectortId) : connectortId},
580 QString fullId(connectortId);
581 for (
auto nvp = nvPairs.cbegin(), en = nvPairs.cend(); nvp != en; ++nvp)
582 fullId +=
'|' + QByteArray(nvp.key()) +
'=' + QByteArray(nvp.value());
587void TPClientQt::connectorUpdate(
const QByteArray &connectortId,
const QMap<const QByteArray, const QByteArray> &nvPairs, uint8_t value,
bool addPrefix)
const
589 QString fullId(connectortId);
590 for (
auto nvp = nvPairs.cbegin(), en = nvPairs.cend(); nvp != en; ++nvp)
591 fullId +=
'|' + nvp.key() +
'=' + nvp.value();
598 QString fullId(connectortId.toString());
599 for (
auto nvp = nvPairs.cbegin(), en = nvPairs.cend(); nvp != en; ++nvp)
600 fullId +=
'|' + nvp.key() +
'=' + nvp.value();
608 {
"type",
"settingUpdate"},
618 {
"type",
"showNotification"},
619 {
"notificationId", notificationId},
627void TPClientQt::showNotification(
const char *notificationId,
const char *title,
const char *msg,
const QVector<QPair<const char *, const char *> > &options)
const
629 showNotification(notificationId, title, msg, arrayOfObjectsToJsonArray(options));
633void TPClientQt::showNotification(
const char *notificationId,
const char *title,
const char *msg,
const std::vector<std::pair<const char *, const char *> > &options)
const
635 showNotification(notificationId, title, msg, arrayOfObjectsToJsonArray(options));
638inline void TPClientQt::showNotification(
const std::string ¬ificationId,
const std::string &title,
const std::string &msg,
const std::vector<std::pair<std::string, std::string> > &options)
const
640 showNotification(notificationId.c_str(), title.c_str(), msg.c_str(), arrayOfObjectsToJsonArray(options));
644void TPClientQt::showNotification(
const QByteArray ¬ificationId,
const QByteArray &title,
const QByteArray &msg,
const QVector<QPair<QLatin1String, QStringView> > &options)
const
646 showNotification(notificationId.constData(), title.constData(), msg.constData(), arrayOfObjectsToJsonArray(options));
650void TPClientQt::showNotification(QStringView notificationId, QStringView title, QStringView msg,
const QVector<QPair<QStringView, QStringView> > &options)
const
652 showNotification(notificationId.toUtf8(), title.toUtf8(), msg.toUtf8(), arrayOfObjectsToJsonArray(options));
661 if (data.at(index).isObject()) {
662 const QJsonObject &o = data.at(index).toObject();
663 return { o.
value(QLatin1String(
"id")).toString(), o.value(QLatin1String(
"value")).toString() };
679 for (
const QJsonValue &v : data) {
680 const QJsonObject o = v.toObject();
681 if (o.value(QLatin1String(
"id")).toString() == QString(
id))
682 return o.value(QLatin1String(
"value")).toString(defaultValue);
687#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
688#define QtSkipEmptyParts QString::SkipEmptyParts
690#define QtSkipEmptyParts Qt::SkipEmptyParts
697 QVector<ActionDataItem> ret;
698 ret.reserve(data.size());
699 for (
const QJsonValue &v : data) {
700 const QJsonObject &vObj = v.toObject();
701 if (!vObj.isEmpty() && vObj.contains(QLatin1String(
"id"))) {
702 QString key = vObj.value(QLatin1String(
"id")).toString();
704 key = key.split(separator, QtSkipEmptyParts).last();
705 ret <<
ActionDataItem({ key, vObj.value(QLatin1String(
"value")).toString() });
715 QMap<QString, QString> ret;
716 for (
const QJsonValue &v : data) {
717 const QJsonObject vObj = v.toObject();
718 if (!vObj.isEmpty() && vObj.contains(QLatin1String(
"id"))) {
719 QString key = vObj.value(QLatin1String(
"id")).toString();
721 key = key.split(separator, QtSkipEmptyParts).last();
722 ret.insert(key, vObj.value(QLatin1String(
"value")).toString());
728#undef QtSkipEmptyParts
The TPClientQt class is a simple TCP/IP network client for usage in Touch Portal plugins which wish t...
static ActionDataItem actionDataItem(int index, const QJsonArray &data, const ActionDataItem &defaultItem=ActionDataItem())
Returns the action data object (id and value as ActionDataItem struct) at given index in the given ar...
QString tpVersionString
Touch Portal version number as text.
void stateUpdate(QStringView id, QStringView value) const
Send a state update with given id and value strings.
void choiceUpdate(QStringView id, const QJsonArray &values) const
Update a list of action data choices for action data with given id using a vector of QJsonArray of st...
QString value
Current value of the data member.
void choiceUpdate(const char *id, const char *instanceId, const QStringList &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void connect()
Initiate a connection to Touch Portal. The plugin ID (set in constructor or with setPluginId() must b...
void connectorUpdate(QStringView shortId, uint8_t value) const
Update a Connector value with given shortId as reported by TP. Valid value range is 0-100.
void choiceUpdate(const QByteArray &id, const QByteArray &instanceId, const QJsonArray &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void choiceUpdate(const QByteArray &id, const QByteArray &instanceId, const QVector< QByteArray > &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void removeState(const char *id) const
Delete (remove) a dynamic state with given id string.
static QVector< ActionDataItem > actionDataToItemArray(const QJsonArray &data, char separator=0)
Convert JSON array of action data objects: [ { 'id': id, 'value': value }, ... ] to a vector of Actio...
void choiceUpdate(QStringView id, const QStringList &values) const
Update a list of action data choices for action data with given id using a list of QStrings.
void send(const QJsonObject &object) const
Low-level API: Send JSON message data to Touch Portal. object should contain one TP message....
void choiceUpdate(QStringView id, const QVector< QStringView > &values) const
Update a list of action data choices for action data with given id using a vector of QStringView-comp...
void connectorUpdate(const std::string &connectortId, uint8_t value, bool addPrefix) const
Update a Connector value with given full connectortId (see TP API docs for details)....
void settingUpdate(const char *name, const char *value) const
Update a plugin setting value with given name to value.
void sendMap(const QVariantMap &map) const
Low-level API: Send a JSON representation of a variant map to Touch Portal. map should contain one TP...
void choiceUpdate(const QByteArray &id, const QByteArray &instanceId, const QStringList &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void choiceUpdate(const QByteArray &id, const QJsonArray &values) const
Update a list of action data choices for action data with given id using a QJsonArray of strings....
void createState(QStringView id, QStringView parentGroup, QStringView desc, QStringView defaultValue) const
Create a new dynamic state with given id, parentGroup, description and defaultValue strings.
void choiceUpdate(QStringView id, QStringView instanceId, const QVector< QStringView > &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void createState(const QByteArray &id, const QByteArray &desc, const QByteArray &defaultValue) const
Create a new dynamic state with given id, description and defaultValue strings.
void choiceUpdate(const QByteArray &id, const QStringList &values) const
Update a list of action data choices for action data with given id using a list of QStrings.
void createState(const std::string &id, const std::string &parentGroup, const std::string &desc, const std::string &defaultValue="") const
Create a new dynamic state with given id, parentGroup, description and default value strings.
void choiceUpdate(const char *id, const char *instanceId, const QVector< const char * > &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void showNotification(const QByteArray ¬ificationId, const QByteArray &title, const QByteArray &msg, const QVariantList &options) const
Send a notification message to TP. See TP SDK documentation for details on each field....
void stateUpdate(const char *id, const char *value) const
Send a state update with given id and value strings.
void choiceUpdate(const std::string &id, const std::vector< std::string > &values) const
Update a list of action data choices for action data with given id using a std::vector of std::string...
void choiceUpdate(const std::string &id, const std::string &instanceId, const std::vector< std::string > &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void connectorUpdate(const char *shortId, uint8_t value) const
Update a Connector value with given shortId as reported by TP. Valid value range is 0-100.
void stateUpdate(const QByteArray &id, const QByteArray &value) const
Send a state update with given id and value strings.
void connectorUpdate(const QByteArray &connectortId, uint8_t value, bool addPrefix) const
Update a Connector value with given full connectortId (see TP API docs for details)....
void settingUpdate(const QByteArray &name, const QByteArray &value) const
Update a plugin setting value with given name to value.
void disconnected()
Emitted upon disconnection from Touch Portal, either from an explicit call to close() or if the conne...
void choiceUpdate(QStringView id, QStringView instanceId, const QByteArrayList &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void settingUpdate(QStringView name, QStringView value) const
Update a plugin setting value with given name to value.
void error(QAbstractSocket::SocketError error)
Emitted in case of error upon initial connection or unexpected termination. This would typically be w...
void connectorUpdate(const QByteArray &shortId, uint8_t value) const
Update a Connector value with given shortId as reported by TP. Valid value range is 0-100.
void createState(const std::string &id, const std::string &desc, const std::string &defaultValue="") const
Create a new dynamic state with given id, description and default value strings.
void removeState(QStringView id) const
Delete (remove) a dynamic state with given id string.
void choiceUpdate(const QByteArray &id, const QByteArrayList &values) const
Update a list of action data choices for action data with given id using a QByteArray list.
void createState(QStringView id, QStringView desc, QStringView defaultValue) const
Create a new dynamic state with given id, description and defaultValue strings.
void connected(const TPClientQt::TPInfo &tpInfo, const QJsonObject &settings)
Emitted upon successful connection and pairing with Touch Portal. Data from the initial pairing 'info...
void choiceUpdate(const char *id, const QStringList &values) const
Update a list of action data choices for action data with given id using a list of QStrings.
void setHostProperties(const QString &nameOrAddress=QStringLiteral("127.0.0.1"), uint16_t port=12136)
Set the Touch Portal host name/address and port number for connection. nameOrAddress can be a IPv4 do...
void choiceUpdate(QStringView id, QStringView instanceId, const QJsonArray &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void removeState(const QByteArray &id) const
Delete (remove) a dynamic state with given id string.
QString id
ID of the action data member.
void choiceUpdate(const QByteArray &id, const QVector< QByteArray > &values) const
Update a list of action data choices for action data with given id using a vector of QByteArray types...
QString pluginId() const
Returns the plugin ID set in constructor or with setPluginId().
void createState(const QByteArray &id, const QByteArray &parentGroup, const QByteArray &desc, const QByteArray &defaultValue) const
Create a new dynamic state with given id, parentGroup, description and defaultValue strings.
void connectorUpdate(QStringView connectortId, uint8_t value, bool addPrefix) const
Update a Connector value with given full connectortId (see TP API docs for details)....
void showNotification(const char *notificationId, const char *title, const char *msg, const QVariantList &options) const
Send a notification message to TP. See TP SDK documentation for details on each field....
MessageType
This enumeration is used in the message() signal to indicate message type. The names match the Touch ...
void removeState(const std::string &id) const
Delete (remove) a dynamic state with given id string.
void settingUpdate(const std::string &name, const std::string &value) const
Update a plugin setting value with given name to value.
QString status
The 'status' property from initial 'info' message (typically "paired"); This does not get changed aft...
static QString actionDataValue(int index, const QJsonArray &data, const QString &defaultValue=QLatin1String(""))
Returns the 'value' member of the action data object at given index in the given array of action/conn...
void choiceUpdate(QStringView id, const QByteArrayList &values) const
Update a list of action data choices for action data with given id using a QByteArray list.
void choiceUpdate(const char *id, const QJsonArray &values) const
Update a list of action data choices for action data with given id using a QJsonArray of strings....
void choiceUpdate(const QByteArray &id, const QByteArray &instanceId, const QByteArrayList &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void createState(const char *id, const char *desc, const char *defaultValue) const
Create a new dynamic state with given id, description and default value strings. Passing nullptr to d...
void connectorUpdate(const std::string &shortId, uint8_t value) const
Update a Connector value with given shortId as reported by TP. Valid value range is 0-100.
void choiceUpdate(QStringView id, QStringView instanceId, const QStringList &values) const
Update a list of action data choices for action data with given id and specific instanceId reported b...
void message(TPClientQt::MessageType type, const QJsonObject &message)
Emitted when any message is received from Touch Portal. Refer to the TP API for specifics of each mes...
QByteArray encode(const QJsonObject &object) const
Low-level API: Serializes a JSON object to UTF8 bytes. object should contain one TP message....
void showNotification(QStringView notificationId, QStringView title, QStringView msg, const QVariantList &options) const
Send a notification message to TP. See TP SDK documentation for details on each field....
void createState(const char *id, const char *parentGroup, const char *desc, const char *defaultValue) const
Create a new dynamic state with given id, parentGroup, description and default value strings....
void showNotification(const char *notificationId, const char *title, const char *msg, const QJsonArray &options) const
Send a notification message to TP. See TP SDK documentation for details on each field....
void choiceUpdate(const char *id, const QVector< const char * > &values) const
Update a list of action data choices for action data with given id using a vector of const char strin...
static QMap< QString, QString > actionDataToMap(const QJsonArray &data, char separator=0)
Flattens array of objects: [ { 'id': id, 'value': value }, ... ] to a single mapping of { {id,...
void showNotification(const QByteArray ¬ificationId, const QByteArray &title, const QByteArray &msg, const QJsonArray &options) const
Send a notification message to TP. See TP SDK documentation for details on each field....
void setConnectionTimeout(int timeoutMs=10000)
Sets the timeout value for the initial pairing 'info' message to be received from Touch Portal,...
Structure for action/connector data id = value pairs sent from TP. Each action/connector sends an arr...
Structure to hold information about current Touch Portal session. Populated from the initial 'info' m...