| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
#ifndef SERVICEBROWSER_H |
| 34 |
#define SERVICEBROWSER_H |
| 35 |
|
| 36 |
#include "zeroconf_global.h" |
| 37 |
|
| 38 |
#include <QtCore/QHash> |
| 39 |
#include <QtCore/QObject> |
| 40 |
#include <QtCore/QSharedPointer> |
| 41 |
#include <QtCore/QStringList> |
| 42 |
|
| 43 |
QT_FORWARD_DECLARE_CLASS(QHostInfo) |
| 44 |
|
| 45 |
namespace ZeroConf { |
| 46 |
|
| 47 |
namespace Internal { |
| 48 |
class ServiceGatherer; |
| 49 |
class MainConnection; |
| 50 |
class ServiceBrowserPrivate; |
| 51 |
} |
| 52 |
|
| 53 |
typedef QSharedPointer<Internal::MainConnection> MainConnectionPtr; |
| 54 |
|
| 55 |
typedef QHash<QString, QString> ServiceTxtRecord; |
| 56 |
|
| 57 |
class ZEROCONFSHARED_EXPORT Service |
| 58 |
{ |
| 59 |
friend class Internal::ServiceGatherer; |
| 60 |
|
| 61 |
public: |
| 62 |
typedef QSharedPointer<const Service> ConstPtr; |
| 63 |
typedef QSharedPointer<Service> Ptr; |
| 64 |
|
| 65 |
Service(const Service &o); |
| 66 |
Service(); |
| 67 |
~Service(); |
| 68 |
|
| 69 |
bool outdated() const { return m_outdated; } |
| 70 |
|
| 71 |
QString name() const { return m_name; } |
| 72 |
QString type() const { return m_type; } |
| 73 |
QString domain() const { return m_domain; } |
| 74 |
QString fullName() const { return m_fullName; } |
| 75 |
QString port() const { return m_port; } |
| 76 |
const ServiceTxtRecord &txtRecord() const { return m_txtRecord; } |
| 77 |
const QHostInfo *host() const { return m_host; } |
| 78 |
int interfaceNr() const { return m_interfaceNr; } |
| 79 |
|
| 80 |
bool invalidate() { bool res = m_outdated; m_outdated = true; return res; } |
| 81 |
private: |
| 82 |
QString m_name; |
| 83 |
QString m_type; |
| 84 |
QString m_domain; |
| 85 |
QString m_fullName; |
| 86 |
QString m_port; |
| 87 |
ServiceTxtRecord m_txtRecord; |
| 88 |
QHostInfo *m_host; |
| 89 |
int m_interfaceNr; |
| 90 |
bool m_outdated; |
| 91 |
}; |
| 92 |
|
| 93 |
QDebug operator<<(QDebug dbg, const Service &service); |
| 94 |
|
| 95 |
class ZEROCONFSHARED_EXPORT ServiceBrowser : public QObject |
| 96 |
{ |
| 97 |
Q_OBJECT |
| 98 |
friend class Internal::ServiceBrowserPrivate; |
| 99 |
public: |
| 100 |
enum AddressesSetting { RequireAddresses, DoNotRequireAddresses }; |
| 101 |
|
| 102 |
ServiceBrowser(const QString &serviceType, const QString &domain = QLatin1String("local."), |
| 103 |
AddressesSetting addressesSetting = RequireAddresses, QObject *parent = 0); |
| 104 |
ServiceBrowser(const MainConnectionPtr &mainConnection, const QString &serviceType, |
| 105 |
const QString &domain = QLatin1String("local."), |
| 106 |
AddressesSetting addressesSetting = RequireAddresses, QObject *parent = 0); |
| 107 |
~ServiceBrowser(); |
| 108 |
|
| 109 |
MainConnectionPtr mainConnection() const; |
| 110 |
|
| 111 |
bool startBrowsing(qint32 interfaceIndex = 0); |
| 112 |
void stopBrowsing(); |
| 113 |
bool isBrowsing() const; |
| 114 |
bool didFail() const; |
| 115 |
|
| 116 |
const QString& serviceType() const; |
| 117 |
const QString& domain() const; |
| 118 |
|
| 119 |
bool adressesAutoResolved() const; |
| 120 |
bool addressesRequired() const; |
| 121 |
|
| 122 |
QList<Service::ConstPtr> services() const; |
| 123 |
void reconfirmService(Service::ConstPtr service); |
| 124 |
signals: |
| 125 |
void serviceChanged(const ZeroConf::Service::ConstPtr &oldService, |
| 126 |
const ZeroConf::Service::ConstPtr &newService, ZeroConf::ServiceBrowser *browser); |
| 127 |
void serviceAdded(const ZeroConf::Service::ConstPtr &service, |
| 128 |
ZeroConf::ServiceBrowser *browser); |
| 129 |
void serviceRemoved(const ZeroConf::Service::ConstPtr &service, |
| 130 |
ZeroConf::ServiceBrowser *browser); |
| 131 |
void servicesUpdated(ZeroConf::ServiceBrowser *browser); |
| 132 |
void hadError(QStringList errorMsgs, bool completeFailure); |
| 133 |
private: |
| 134 |
Internal::ServiceBrowserPrivate *d; |
| 135 |
}; |
| 136 |
|
| 137 |
enum LibUsage { |
| 138 |
UseNativeOnly = 1, |
| 139 |
UseEmbeddedOnly, |
| 140 |
UseNativeOrEmbedded |
| 141 |
}; |
| 142 |
|
| 143 |
void initLib(LibUsage usage, const QString &libName, const QString & daemonPaths); |
| 144 |
|
| 145 |
} |
| 146 |
|
| 147 |
#endif |