Debian Codegraph @

interfaces/zeroconf/servicebrowser.h

raw symbols SCIP
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation ([email protected])
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at [email protected].
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 // SERVICEBROWSER_H