#ifndef QTAVAHI_P_H #define QTAVAHI_P_H #include "libqtavahi_global.h" namespace Avahi { class LIBQTAVAHISHARED_EXPORT Service; class LIBQTAVAHISHARED_EXPORT ServiceKey; class LIBQTAVAHISHARED_EXPORT Browse; class LIBQTAVAHISHARED_EXPORT Announce; namespace priv { class LIBQTAVAHISHARED_EXPORT ServiceWatch; class LIBQTAVAHISHARED_EXPORT ServiceP; class BrowseP; class AnnounceP; }; } #include #include namespace Avahi { namespace priv { class LIBQTAVAHISHARED_EXPORT ServiceWatch : public QObject { Q_OBJECT private: friend class Avahi::priv::ServiceP; friend class Avahi::Browse; inline ServiceWatch() { } signals: void lost(Avahi::Service s); }; class LIBQTAVAHISHARED_EXPORT ServiceP { private: friend class Avahi::Service; friend class Avahi::ServiceKey; friend class Avahi::Browse; inline ServiceP(QString name, QString hostname, QString domain, QHostAddress address, int interface, int protocol, quint16 port, QHash txt) : m_ref(1), m_name(name), m_hostname(hostname), m_domain(domain), m_address(address), m_interface(interface), m_protocol(protocol), m_port(port), m_txt(txt), m_data(0), m_watcher(0) { } ~ServiceP() { delete m_watcher; } Q_DISABLE_COPY(ServiceP); inline void ref() { m_ref.ref(); } inline void deref() { if (!m_ref.deref()) { delete this; } } inline Avahi::priv::ServiceWatch* watcher() { if (!m_watcher) { m_watcher = new Avahi::priv::ServiceWatch(); } return m_watcher; } QAtomicInt m_ref; QString m_name, m_hostname, m_domain; QHostAddress m_address; int m_interface, m_protocol; quint16 m_port; QHash m_txt; void *m_data; Avahi::priv::ServiceWatch *m_watcher; }; typedef enum { TCP, UDP } Protocol; inline LIBQTAVAHISHARED_EXPORT QString serv_prot2str(QString service, Protocol prot) { switch (prot) { case TCP: return QString("_%1._tcp").arg(service); break; case UDP: return QString("_%1._udp").arg(service); break; default: return service; } } } } #include "qtavahi.h" #endif // QTAVAHI_P_H