dnssd Library API Documentation

DNSSD::PublicService Class Reference

This class is most important for application that wants to announce its service on network.This class represents local service being published. More...

#include <publicservice.h>

Inheritance diagram for DNSSD::PublicService:

QObject DNSSD::ServiceBase List of all members.

Signals

void published (bool)

Public Member Functions

 PublicService (const QString &name=QString::null, const QString &type=QString::null, unsigned int port=0, const QString &domain=QString::null)
 ~PublicService ()
void stop ()
bool publish ()
bool isPublished () const
void publishAsync ()
void setTextData (const QMap< QString, QString > &textData)
void setServiceName (const QString &serviceName)
void setType (const QString &type)
void setPort (unsigned short port)
void setDomain (const QString &domain)

Protected Member Functions

virtual void customEvent (QCustomEvent *event)
virtual void virtual_hook (int, void *)

Detailed Description

This class is most important for application that wants to announce its service on network.This class represents local service being published.

Suppose that you want to make your web server public - this is simplest way:

DNSSD::PublicService *service = new DNSSD::PublicService("My files","_http._tcp",80);
bool isOK = service->publish();

In this example publish() is synchronous - it will not return until publishing is complete. This is usually not too long but it can freeze application's GUI for a moment. Asynchronous publishing is better for responsiveness. Example:

DNSSD::PublicService *service = new DNSSD::PublicService("My files","_http._tcp",80);
connect(service,SIGNAL(published(bool)),this,SLOT(wasPublished(bool)));
service->publishAsync();

Author:
Jakub Stachowski

Definition at line 55 of file publicservice.h.


Constructor & Destructor Documentation

DNSSD::PublicService::PublicService const QString name = QString::null,
const QString type = QString::null,
unsigned int  port = 0,
const QString domain = QString::null
 

Parameters:
name Service name. If set to QString::null, computer name will be used and will be available via serviceName() after successful registration
type Service type. Has to be in form _sometype._udp or _sometype._tcp
port Port number. Set to 0 to "reserve" service name.
domain Domain name. If left as QString:null, user configuration will be used. "local." means local LAN

Definition at line 47 of file publicservice.cpp.

References QString::isNull(), DNSSD::ServiceBase::m_domain, DNSSD::Configuration::publishDomain(), and DNSSD::Configuration::publishType().


Member Function Documentation

void DNSSD::PublicService::stop  ) 
 

Stops publishing or abort incomplete publish request.

Useful when you want to disable service for some time.

Definition at line 122 of file publicservice.cpp.

Referenced by customEvent(), publishAsync(), setDomain(), setPort(), setServiceName(), setTextData(), setType(), and ~PublicService().

bool DNSSD::PublicService::publish  ) 
 

Synchrounous publish.

Application will be freezed until publishing is complete.

Returns:
true if successfull.

Definition at line 115 of file publicservice.cpp.

References publishAsync().

bool DNSSD::PublicService::isPublished  )  const
 

Returns true is currently published.

Definition at line 101 of file publicservice.cpp.

void DNSSD::PublicService::publishAsync  ) 
 

Asynchronous version of publish().

It return immediately and emits signal published(bool) when completed. Note that in case of early detected error (like bad service type) signal may be emitted before return of this function.

Definition at line 128 of file publicservice.cpp.

References QString::ascii(), QMap::begin(), DNSSD::domainToDNS(), QMap::end(), QCString::length(), DNSSD::ServiceBase::m_domain, DNSSD::ServiceBase::m_port, DNSSD::ServiceBase::m_serviceName, DNSSD::ServiceBase::m_textData, DNSSD::ServiceBase::m_type, published(), stop(), and QString::utf8().

Referenced by publish(), setDomain(), setPort(), setServiceName(), setTextData(), and setType().

void DNSSD::PublicService::setTextData const QMap< QString, QString > &  textData  ) 
 

Sets new text properties.

If services is already published, it will be re-announced with new data.

Definition at line 106 of file publicservice.cpp.

References DNSSD::ServiceBase::m_textData, publishAsync(), and stop().

void DNSSD::PublicService::setServiceName const QString serviceName  ) 
 

Sets name of the service.

If service is currently published, it will be re-announced with new data.

Definition at line 64 of file publicservice.cpp.

References DNSSD::ServiceBase::m_serviceName, publishAsync(), and stop().

void DNSSD::PublicService::setType const QString type  ) 
 

Sets type of service.

It has to in form of _type._udp or _type._tcp. If service is currently published, it will be re-announced with new data.

Definition at line 83 of file publicservice.cpp.

References DNSSD::ServiceBase::m_type, publishAsync(), and stop().

void DNSSD::PublicService::setPort unsigned short  port  ) 
 

Sets port.

If service is currently published, it will be re-announced with new data.

Definition at line 92 of file publicservice.cpp.

References DNSSD::ServiceBase::m_port, publishAsync(), and stop().

void DNSSD::PublicService::setDomain const QString domain  ) 
 

Sets domain where service is published.

"local." means local LAN. If service is currently published, it will be re-announced with new data.

Definition at line 73 of file publicservice.cpp.

References DNSSD::ServiceBase::m_domain, publishAsync(), and stop().

void DNSSD::PublicService::published bool   )  [signal]
 

Emitted when publishing is complete - parameter is set to true if it was successfull.

It will also emitted when name, port or type of already published service is changed.

Referenced by customEvent(), and publishAsync().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for dnssd Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Nov 1 10:33:46 2005 by doxygen 1.4.3 written by Dimitri van Heesch, © 1997-2003