diff --git a/libnymea/network/zeroconf/zeroconfserviceentry.cpp b/libnymea/network/zeroconf/zeroconfserviceentry.cpp index 28225506..8506d17a 100644 --- a/libnymea/network/zeroconf/zeroconfserviceentry.cpp +++ b/libnymea/network/zeroconf/zeroconfserviceentry.cpp @@ -116,6 +116,18 @@ QStringList ZeroConfServiceEntry::txt() const return m_txt; } +/*! Returns the txt entry of the given \a key of this \l{ZeroConfServiceEntry}.*/ +QString ZeroConfServiceEntry::txt(const QString &key) const +{ + foreach (const QString &txtEntry, m_txt) { + QStringList parts = txtEntry.split('='); + if (parts.length() == 2 && parts.first() == key) { + return parts.last(); + } + } + return QString(); +} + /*! Returns true if this \l{ZeroConfServiceEntry} is valid.*/ bool ZeroConfServiceEntry::isValid() const { diff --git a/libnymea/network/zeroconf/zeroconfserviceentry.h b/libnymea/network/zeroconf/zeroconfserviceentry.h index 75544694..08dbbc44 100644 --- a/libnymea/network/zeroconf/zeroconfserviceentry.h +++ b/libnymea/network/zeroconf/zeroconfserviceentry.h @@ -52,6 +52,7 @@ public: quint16 port() const; QAbstractSocket::NetworkLayerProtocol protocol() const; QStringList txt() const; + QString txt(const QString &key) const; bool isValid() const;