ServiceBrowser Class Reference
from PyKDE4.dnssd import *
Inherits: QObject
Namespace: DNSSD
Detailed Description
\class ServiceBrowser servicebrowser.h DNSSD/ServiceBrowser
Most important class for applications that want to discover specific services on network. Suppose that you need list of web servers running. Example:
DNSSD.ServiceBrowser* browser = new DNSSD.ServiceBrowser("_http._tcp"); connect(browser,SIGNAL(serviceAdded(RemoteService.Ptr)),this,SLOT(addService(RemoteService.Ptr))); connect(browser,SIGNAL(serviceRemoved(RemoteService.Ptr)),this,SLOT(delService(RemoteService.Ptr))); browser->startBrowse();
In above example addService will be called for every web server already running or just appearing on network and delService will be called when server is stopped. Because no domain was passed to constructor, default domain will be searched.
Browsing for specific type of services or all available service types
Enumerations | |
State | { Working, Stopped, Unsupported } |
Signals | |
finished () | |
serviceAdded (DNSSD.RemoteService.Ptr a0) | |
serviceRemoved (DNSSD.RemoteService.Ptr a0) | |
Methods | |
__init__ (self, QString type, bool autoResolve=0, QString domain=QString(), QString subtype=QString()) | |
finished (self) | |
bool | isAutoResolving (self) |
serviceAdded (self, DNSSD.RemoteService.Ptr a0) | |
serviceRemoved (self, DNSSD.RemoteService.Ptr a0) | |
[DNSSD::RemoteService::Ptr] | services (self) |
DNSSD.RemoteService.List | services (self) |
startBrowse (self) | |
virtual_hook (self, int a0, void a1) | |
Static Methods | |
DNSSD.ServiceBrowser.State | isAvailable () |
Method Documentation
__init__ | ( | self, | ||
QString | type, | |||
bool | autoResolve=0, | |||
QString | domain=QString(), | |||
QString | subtype=QString() | |||
) |
ServiceBrowser constructor.
- Parameters:
-
type Service types to browse for (example: "_http._tcp"). autoResolve - after disovering new service it will be resolved and then reported with serviceAdded() signal. It raises network usage by resolving all services, so use it only when necessary. domain Domain name. Can be left as null string to use default domain subtypes Set it to browse only for specific subtype
finished | ( | self ) |
Emitted when all services has been reported. This signal can be used by application that just want to get list of currently available services (similar to directory listing) and do not care about dynamic adding/removing services later. This signal can be emitted many time: for example if new host has been connected to network and is announcing some services interesting to this ServiceBrowser, they will be reported by several serviceAdded() signals and whole batch will be concluded by finished().
- Signal syntax:
QObject.connect(source, SIGNAL("finished()"), target_slot)
bool isAutoResolving | ( | self ) |
Returns true if newly discovered services are resolved before being reported with serviceAdded()
- Since:
- 4.1
DNSSD.ServiceBrowser.State isAvailable | ( | ) |
Checks availability of DNS-SD services (this also covers publishing).
If you use this function to report an error to the user, below is a suggestion on how to word the errors:
switch(DNSSD.ServiceBrowser.isAvailable()) { case DNSSD.ServiceBrowser.Working: return ""; case DNSSD.ServiceBrowser.Stopped: return i18n("<p>The Zeroconf daemon is not running. See the Service Discovery Handbook" " for more information.<br/>" "Other users will not see this system when browsing" " the network via zeroconf, but normal access will still work.</p>"); case DNSSD.ServiceBrowser.Unsupported: return i18n("<p>Zeroconf support is not available in this version of KDE." " See the Service Discovery Handbook for more information.<br/>" "Other users will not see this system when browsing" " the network via zeroconf, but normal access will still work.</p>"); default: return i18n("<p>Unknown error with Zeroconf.<br/>" "Other users will not see this system when browsing" " the network via zeroconf, but normal access will still work.</p>"); }
serviceAdded | ( | self, | ||
DNSSD.RemoteService.Ptr | a0 | |||
) |
Emitted when new service is discovered (or resolved if autoresolve is set
- Signal syntax:
QObject.connect(source, SIGNAL("serviceAdded(Ptr)"), target_slot)
serviceRemoved | ( | self, | ||
DNSSD.RemoteService.Ptr | a0 | |||
) |
Emitted when service is no longer announced. RemoteService object is deleted from services list and destroyed immediately after this signal returns.
- Signal syntax:
QObject.connect(source, SIGNAL("serviceRemoved(Ptr)"), target_slot)
[DNSSD::RemoteService::Ptr] services | ( | self ) |
Returns list of services
DNSSD.RemoteService.List services | ( | self ) |
startBrowse | ( | self ) |
Starts browsing for services. To stop it just destroy the object.
virtual_hook | ( | self, | ||
int | a0, | |||
void | a1 | |||
) |
Enumeration Documentation
State |
Availability of DNS-SD services.
- Enumerator:
-
Working Stopped Unsupported