2010-07-24 16:16:44 +00:00
|
|
|
#ifndef QTAVAHI_P_H
|
|
|
|
#define QTAVAHI_P_H
|
|
|
|
|
2010-07-25 11:09:05 +00:00
|
|
|
#include "libqtavahi_global.h"
|
|
|
|
|
2010-07-24 16:16:44 +00:00
|
|
|
namespace Avahi {
|
2010-07-25 11:09:05 +00:00
|
|
|
class LIBQTAVAHISHARED_EXPORT Service;
|
|
|
|
class LIBQTAVAHISHARED_EXPORT ServiceKey;
|
|
|
|
class LIBQTAVAHISHARED_EXPORT Browse;
|
|
|
|
class LIBQTAVAHISHARED_EXPORT Announce;
|
2010-07-24 16:16:44 +00:00
|
|
|
|
|
|
|
namespace priv {
|
2010-07-25 11:09:05 +00:00
|
|
|
class LIBQTAVAHISHARED_EXPORT ServiceWatch;
|
2010-07-24 16:16:44 +00:00
|
|
|
class LIBQTAVAHISHARED_EXPORT ServiceP;
|
|
|
|
class BrowseP;
|
|
|
|
class AnnounceP;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-07-25 11:09:05 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QHostAddress>
|
|
|
|
|
2010-07-24 16:16:44 +00:00
|
|
|
namespace Avahi {
|
|
|
|
namespace priv {
|
2010-07-25 11:09:05 +00:00
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
2010-07-24 16:16:44 +00:00
|
|
|
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<QString, QString> txt)
|
2010-07-25 11:09:05 +00:00
|
|
|
: 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;
|
|
|
|
}
|
2010-07-24 16:16:44 +00:00
|
|
|
|
|
|
|
Q_DISABLE_COPY(ServiceP);
|
|
|
|
|
|
|
|
inline void ref() { m_ref.ref(); }
|
|
|
|
inline void deref() { if (!m_ref.deref()) { delete this; } }
|
|
|
|
|
2010-07-25 11:09:05 +00:00
|
|
|
inline Avahi::priv::ServiceWatch* watcher() {
|
|
|
|
if (!m_watcher) {
|
|
|
|
m_watcher = new Avahi::priv::ServiceWatch();
|
|
|
|
}
|
|
|
|
return m_watcher;
|
|
|
|
}
|
|
|
|
|
2010-07-24 16:16:44 +00:00
|
|
|
QAtomicInt m_ref;
|
|
|
|
|
|
|
|
QString m_name, m_hostname, m_domain;
|
|
|
|
QHostAddress m_address;
|
|
|
|
int m_interface, m_protocol;
|
|
|
|
quint16 m_port;
|
|
|
|
QHash<QString, QString> m_txt;
|
|
|
|
|
2010-07-25 11:09:05 +00:00
|
|
|
void *m_data;
|
|
|
|
Avahi::priv::ServiceWatch *m_watcher;
|
2010-07-24 16:16:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-25 11:09:05 +00:00
|
|
|
#include "qtavahi.h"
|
|
|
|
|
2010-07-24 16:16:44 +00:00
|
|
|
#endif // QTAVAHI_P_H
|