File indexing completed on 2024-04-28 15:22:05
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 AVAHI_PUBLICSERVICE_P_H 0010 #define AVAHI_PUBLICSERVICE_P_H 0011 0012 #include "avahi_entrygroup_interface.h" 0013 #include "avahi_listener_p.h" 0014 #include "avahi_server_interface.h" 0015 #include "publicservice.h" 0016 #include "servicebase_p.h" 0017 #include <QStringList> 0018 #include <avahi-common/defs.h> 0019 0020 #define KDNSSD_D PublicServicePrivate *d = static_cast<PublicServicePrivate *>(this->d.operator->()) 0021 0022 namespace KDNSSD 0023 { 0024 class PublicServicePrivate : public QObject, public ServiceBasePrivate, public AvahiListener 0025 { 0026 Q_OBJECT 0027 public: 0028 PublicServicePrivate(PublicService *parent, const QString &name, const QString &type, const QString &domain, unsigned int port) 0029 : QObject() 0030 , ServiceBasePrivate(name, type, domain, QString(), port) 0031 , m_published(false) 0032 , m_running(false) 0033 , m_group(nullptr) 0034 , m_server(nullptr) 0035 , m_collision(false) 0036 , m_parent(parent) 0037 { 0038 } 0039 ~PublicServicePrivate() override 0040 { 0041 if (m_group) { 0042 m_group->Free(); 0043 } 0044 delete m_group; 0045 delete m_server; 0046 } 0047 0048 bool m_published; 0049 bool m_running; 0050 org::freedesktop::Avahi::EntryGroup *m_group; 0051 org::freedesktop::Avahi::Server *m_server; 0052 bool m_collision; 0053 QStringList m_subtypes; 0054 PublicService *m_parent; 0055 0056 void commit() 0057 { 0058 if (!m_collision) { 0059 m_group->Commit(); 0060 } 0061 } 0062 void stop(); 0063 bool fillEntryGroup(); 0064 void tryApply(); 0065 0066 public Q_SLOTS: 0067 // NB: The global slots are runtime connected! If their signature changes 0068 // make sure the SLOT() signature gets updated! 0069 void gotGlobalStateChanged(int state, const QString &error, QDBusMessage msg); 0070 0071 void serverStateChanged(int, const QString &); 0072 void groupStateChanged(int, const QString &); 0073 }; 0074 0075 } 0076 0077 #endif