mirror of https://github.com/nymea/nymea.git
Add a helper function to more easily access ZeroConf txt records
parent
9af820b696
commit
17eb0fc697
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public:
|
|||
quint16 port() const;
|
||||
QAbstractSocket::NetworkLayerProtocol protocol() const;
|
||||
QStringList txt() const;
|
||||
QString txt(const QString &key) const;
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue