File indexing completed on 2024-04-28 15:22:06

0001 /*
0002     This file is part of the KDE project
0003 
0004     SPDX-FileCopyrightText: 2004 Jakub Stachowski <qbast@go2.pl>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef MDNSD_RESPONDER_H
0010 #define MDNSD_RESPONDER_H
0011 
0012 #include <QObject>
0013 #include <QSocketNotifier>
0014 #include <dns_sd.h>
0015 
0016 namespace KDNSSD
0017 {
0018 /**
0019 This class should not be used directly.
0020 
0021 @author Jakub Stachowski
0022 @short Internal class wrapping dns_sd.h interface
0023  */
0024 class Responder : public QObject
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     explicit Responder(DNSServiceRef ref = 0, QObject *parent = nullptr);
0030 
0031     ~Responder();
0032 
0033     /**
0034     Returns true if it is possible to use mDNS service publishing and discovery.
0035     It needs mDNSResponder running.
0036      */
0037     bool isRunning() const;
0038     void setRef(DNSServiceRef ref);
0039     void stop();
0040 public Q_SLOTS:
0041     void process();
0042 
0043 protected:
0044     DNSServiceRef m_ref;
0045     bool m_running;
0046     QSocketNotifier *m_socket;
0047 };
0048 
0049 /* Utils functions */
0050 
0051 // Encodes domain name using utf8() or IDN
0052 QByteArray domainToDNS(const QString &domain);
0053 QString DNSToDomain(const char *domain);
0054 
0055 }
0056 
0057 #endif