1 /* This file is part of the KDE project
3 * Copyright (C) 2004, 2005 Jakub Stachowski <qbast@go2.pl>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef DNSSDREMOTESERVICE_H
22 #define DNSSDREMOTESERVICE_H
24 #include <QtCore/QObject>
25 #include <QtCore/QMetaType>
26 #include <dnssd/servicebase.h>
30 class RemoteServicePrivate
;
33 * @class RemoteService remoteservice.h DNSSD/RemoteService
34 * @short Describes a service published over DNS-SD,
35 * typically on a remote machine
37 * This class allows delayed or asynchronous resolution of
38 * services. As the name suggests, the service is normally
39 * on a remote machine, but the service could just as easily
40 * be published on the local machine.
42 * RemoteService instances are normally provided by ServiceBrowser,
43 * but can be used to resolve any service if you know the name, type
46 * @author Jakub Stachowski
50 class KDNSSD_EXPORT RemoteService
: public QObject
, public ServiceBase
55 typedef KSharedPtr
<RemoteService
> Ptr
;
58 * Creates an unresolved RemoteService representing the service with
59 * the given name, type and domain
61 * @param name the name of the service
62 * @param type the type of the service (see ServiceBrowser::ServiceBrowser())
63 * @param domain the domain of the service
65 * @see ServiceBrowser::isAvailable()
67 RemoteService(const QString
& name
, const QString
& type
, const QString
& domain
);
69 virtual ~RemoteService();
72 * Resolves the host name and port of service asynchronously
74 * The host name is not resolved into an IP address - use KResolver
77 * The resolved(bool) signal will be emitted when the
78 * resolution is complete, or when it fails.
80 * Note that resolved(bool) may be emitted before this function
81 * returns in case of immediate failure.
83 * RemoteService will keep monitoring the service for
84 * changes in hostname and port, and re-emit resolved(bool)
85 * when either changes.
87 * @see resolve(), hostName(), port()
92 * Resolves the host name and port of service synchronously
94 * The host name is not resolved into an IP address - use KResolver
97 * resolved(bool) is emitted before this function is returned.
99 * resolve() will not cause RemoteService to monitor for changes
100 * in the hostname or port of the service.
102 * @return @c true if successful, @c false on failure
104 * @see resolveAsync(), hostName(), port()
109 * Whether the service has been successfully resolved
111 * @return @c true if hostName() and port() will return
112 * valid values, @c false otherwise
114 bool isResolved() const;
118 * Emitted when resolving is complete
120 * If operating in asynchronous mode this signal can be
121 * emitted several times (when the hostName or port of
122 * the service changes).
124 * @param successful @c true if the hostName and port were
125 * successfully resolved, @c false otherwise
127 void resolved(bool successful
);
130 virtual void virtual_hook(int id
, void *data
);
132 friend class RemoteServicePrivate
;
138 Q_DECLARE_METATYPE(DNSSD::RemoteService::Ptr
)