From c09bc39ed67fa1065e4c88b46cdad1f4827f4ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Wa=C3=9Fmuth?= Date: Thu, 27 Aug 2020 12:03:41 +0200 Subject: [PATCH] Allow changing the host name --- avahicore.cpp | 11 +++++++++++ qzeroconf.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/avahicore.cpp b/avahicore.cpp index 3f47013..a85ab5b 100644 --- a/avahicore.cpp +++ b/avahicore.cpp @@ -290,6 +290,17 @@ QZeroConf::~QZeroConf() delete pri; } +void QZeroConf::setHostName(QString hostName) +{ + avahi_server_set_host_name(pri->server, hostName.toLatin1().constData()); +} + +QString QZeroConf::hostName() const +{ + QString name = QString::fromLatin1(avahi_server_get_host_name(pri->server)); + return name; +} + void QZeroConf::startServicePublish(const char *name, const char *type, const char *domain, quint16 port) { if (pri->group) { diff --git a/qzeroconf.h b/qzeroconf.h index 4597591..51e91b3 100644 --- a/qzeroconf.h +++ b/qzeroconf.h @@ -50,6 +50,8 @@ friend class QZeroConfPrivate; }; QZeroConf(QObject *parent = Q_NULLPTR); ~QZeroConf(); + void setHostName(QString hostName); + QString hostName() const; void startServicePublish(const char *name, const char *type, const char *domain, quint16 port); void stopServicePublish(void); bool publishExists(void);