diff --git a/avahiclient.cpp b/avahiclient.cpp index 4e20035..8c68f88 100644 --- a/avahiclient.cpp +++ b/avahiclient.cpp @@ -150,19 +150,23 @@ class QZeroConfPrivate zcs->m_host = host_name; zcs->m_interfaceIndex = interface; zcs->m_port = port; - while (txt) // get txt records - { - QByteArray avahiText((const char *)txt->text, txt->size); - const ssize_t pos = avahiText.indexOf('='); - if (pos < 0) - zcs->m_txt[avahiText] = ""; - else - zcs->m_txt[avahiText.left(pos)] = avahiText.mid(pos + 1, -1); - txt = txt->next; - } + ref->pub->services.insert(key, zcs); } + // Update TXT records anyway + zcs->m_txt.clear(); + while (txt) + { + QByteArray avahiText((const char *)txt->text, txt->size); + const ssize_t pos = avahiText.indexOf('='); + if (pos < 0) + zcs->m_txt[avahiText] = ""; + else + zcs->m_txt[avahiText.left(pos)] = avahiText.mid(pos + 1, -1); + txt = txt->next; + } + char a[AVAHI_ADDRESS_STR_MAX]; avahi_address_snprint(a, sizeof(a), address); QHostAddress addr(a); diff --git a/avahicore.cpp b/avahicore.cpp index b9dd1ca..2d19804 100644 --- a/avahicore.cpp +++ b/avahicore.cpp @@ -180,19 +180,23 @@ class QZeroConfPrivate zcs->m_host = host_name; zcs->m_interfaceIndex = interface; zcs->m_port = port; - while (txt) // get txt records - { - QByteArray avahiText((const char *)txt->text, txt->size); - const int pos = avahiText.indexOf('='); - if (pos < 0) - zcs->m_txt[avahiText] = ""; - else - zcs->m_txt[avahiText.left(pos)] = avahiText.mid(pos + 1, -1); - txt = txt->next; - } + ref->pub->services.insert(key, zcs); } + // Update TXT records anyway + zcs->m_txt.clear(); + while (txt) + { + QByteArray avahiText((const char *)txt->text, txt->size); + const int pos = avahiText.indexOf('='); + if (pos < 0) + zcs->m_txt[avahiText] = ""; + else + zcs->m_txt[avahiText.left(pos)] = avahiText.mid(pos + 1, -1); + txt = txt->next; + } + char a[AVAHI_ADDRESS_STR_MAX]; avahi_address_snprint(a, sizeof(a), address); QHostAddress addr(a);