Main Page   Class Hierarchy   Compound List   File List   Compound Members  

KDE::SLP::Registry Class Reference

#include <registry.h>

List of all members.

Signals

void foundServiceTypes (QString token, QStringList serviceTypes)
void foundService (QString token, Service service, int lifetime)
void foundAttributes (QString token, Service service)
void foundScopes (QString token, QStringList scopeList)
void operationFinished (QString token, bool success, QString msg)

Public Methods

 Registry (const QString &language=QString::null, bool allowAnyLanguage=true)
virtual ~Registry ()
 Registry (const Registry &other)
Registry & operator= (const Registry &other)
bool available () const
bool supportsAutoAddress () const
bool registerService (const Service &service, bool autoAddress, bool autoDeregister=true, const QStringList &scopes=DefaultScopes, unsigned short lifetime=RecommendedLifetime, bool autoLifetimeExtension=true)
bool deregister (const QString &serviceURL)
bool deregister (const Service &service)
bool findServiceTypes (const QString &token=QString::null, const QString &namingAuthority=AllAuthorities, const QStringList &scopeList=DefaultScopes)
bool findServiceTypesAsync (const QString &token=QString::null, const QString &namingAuthority=AllAuthorities, const QStringList &scopeList=DefaultScopes)
bool findServices (const QString &token, const QString &srvtype, bool fetchAttributes=true, const Filter::List &filters=Filter::List(), const QString &scopeList=QString::null)
bool findServicesAsync (const QString &token, const QString &srvtype, bool fetchAttributes=true, const Filter::List &filters=Filter::List(), const QString &scopeList=QString::null)
bool findAttributes (const QString &token, const QString &serviceUrl, const QStringList &attributeIds=QStringList())
bool findAttributesAsync (const QString &token, const QString &serviceUrl, const QStringList &attributeIds=QStringList())
bool findScopes (const QString &token)
bool findScopesAsync (const QString &token)

Static Public Attributes

const unsigned short UnlimitedLifetime = 65535
const unsigned short RecommendedLifetime = 900
const QStringList DefaultScopes
const QString DefaultAuthority
const QString AllAuthorities


Detailed Description

Registry allows you to find and register SLP Services.

Registry represents the connection to the SLP daemon. You can use it to find services or to register your own.

Registration example:

 // register a new SLP service
 Service s("service:http://www.kde.org");
 s.setString("description", "KDE Web Site");
 Registry r();
 r.registerService(s, false);
 

Query example:

 // query for HTTP servers that contain "www" in the description
 Registry r();
 connect(&r, SIGNAL(foundService(Service,QString)),
         yourHandler, SLOT(foundService(Service,QString)));
 connect(&r, SIGNAL(operationFinished(Service,QString)),
         yourHandler, SLOT(operationFinished(bool,QString)));
 r.findServices(QString::null,
                "service:http",
		  true,
		  Filter::List() << new PredicateFilter("(description=*kde*)"));
 

Author:
Tim Jansen, tim@tjansen.de


Constructor & Destructor Documentation

KDE::SLP::Registry::Registry const QString &    language = QString::null,
bool    allowAnyLanguage = true
 

Creates a new service registration instance for the given language. There can be more than one instance, they will share the connection to the daemon.

Parameters:
language  the language as two letter code, or QString::null for the system default
allowAnyLanguage  if true and the daemon allows, it will only use language as preferred language, but return any language

virtual KDE::SLP::Registry::~Registry   [virtual]
 

Closes the service registration instance. When the last instance has been closed all services that have been registered with the "autoDeregister" feature will be deregistered automatically.

KDE::SLP::Registry::Registry const Registry &    other
 

Copies this registry. Both will share the connection and language configuration, but not signals (if you start an operation on one registry, the other will not emit its signals).

Parameters:
other  the other registry to copy


Member Function Documentation

bool KDE::SLP::Registry::available  
 

Returns true if service registration and searching is generally possible. Reasons for a failure could be that the SLP libraries are not installed or no SLP daemon (knotd or slpd) is running.

Returns:
true if the daemon seems to be available

bool KDE::SLP::Registry::deregister const Service   service
 

Deregisters the given service in all languages.

Parameters:
service  the service to deregister (the attributes of the Service object will be ignored)
Returns:
true if successful, false otherwise. False usually means that no SLP daemon is running. Deregistering a non-existing service does not result in false
See also:
registerService()

bool KDE::SLP::Registry::deregister const QString &    serviceURL
 

Deregisters the given service in all languages.

Parameters:
serviceURL  the service URL to deregister
Returns:
true if successful, false otherwise. False usually means that no SLP daemon is running. Deregistering a non-existing service does not result in false
See also:
registerService()

bool KDE::SLP::Registry::findAttributes const QString &    token,
const QString &    serviceUrl,
const QStringList &    attributeIds = QStringList()
 

Finds the attributes of the service with the given URL. The function emits the signal foundAttributes() if the service has been found, followed by operationFinished(). The function will not return before it finished searching, but the event loop will be running while the function blocks.

Parameters:
token  a string that will be given as arguments to the emitted signals. This allows you to identify signals when you have several operations running
serviceUrl  the URL of the service to search
attributeIds  a list of attributes to retrieve, or an empty list to retrieve all attributes
Returns:
true if the operation was successful

bool KDE::SLP::Registry::findAttributesAsync const QString &    token,
const QString &    serviceUrl,
const QStringList &    attributeIds = QStringList()
 

Finds the attributes of the service with the given URL. The function emits the signal foundAttributes() if the service has been found, followed by operationFinished(). The function will return immediately.

Parameters:
token  a string that will be given as arguments to the emitted signals. This allows you to identify signals when you have several operations running
serviceUrl  the URL of the service to search
attributeIds  a list of attributes to retrieve, or an empty list to retrieve all attributes
Returns:
true if the operation was successful

bool KDE::SLP::Registry::findScopes const QString &    token
 

Finds all scopes that can be searched. Always finds at least one scope (the default scope). The function emits the signal foundScopes() every time new scopes have been found, and a operationFinished() when finished. The function will not return before it finished searching, but the event loop will be running while the function blocks.

Parameters:
token  a string that will be given as arguments to the emitted signals. This allows you to identify signals when you have several operations running
Returns:
true if the operation was successful

bool KDE::SLP::Registry::findScopesAsync const QString &    token
 

Finds all scopes that can be searched. Always finds at least one scope (the default scope). The function emits the signal foundScopes() every time new scopes have been found, and a operationFinished() when finished. The function will return immediately.

Parameters:
token  a string that will be given as arguments to the emitted signals. This allows you to identify signals when you have several operations running
Returns:
true if the operation was successful

bool KDE::SLP::Registry::findServices const QString &    token,
const QString &    srvtype,
bool    fetchAttributes = true,
const Filter::List   filters = Filter::List(),
const QString &    scopeList = QString::null
 

Finds all services in the given scope with the given service type. Examples for service types are "service:ftp" to find all ftp servers or "service:remotedesktop" to find all remote desktop services. You can also specify a list of Filter s to limit the query and modify the list of returned services. The function emits the signal foundService() each time it discovered a service types. When the last service has been found operationFinished() will be emitted. The function will not return before it finished searching, but the event loop will be running while the function blocks.

Parameters:
token  a string that will be given as arguments to the emitted signals. This allows you to identify signals when you have several operations running
srvtype  the type of the service to search.
fetchAttributes  if true the attributes will be returned as well. if servers do not support this it can require an extra request per service
filters  a list of Filter objects to narrow down the query. Note that the order can be important, depending the the Filter's type.
scopeList  a list of all scopes that will be searched, DefaultScopes or an empty list for the daemon's default scopes
Returns:
true if the operation was successful

bool KDE::SLP::Registry::findServicesAsync const QString &    token,
const QString &    srvtype,
bool    fetchAttributes = true,
const Filter::List   filters = Filter::List(),
const QString &    scopeList = QString::null
 

Finds all services in the given scope with the given service type. Examples for service types are "service:ftp" to find all ftp servers or "service:remotedesktop" to find all remote desktop services. You can also specify a list of Filter s to limit the query and modify the list of returned services. The function emits the signal foundService() each time it discovered a service types. When the last service has been found operationFinished() will be emitted. The function will return immediately.

Parameters:
token  a string that will be given as arguments to the emitted signals. This allows you to identify signals when you have several operations running
srvtype  the type of the service to search.
fetchAttributes  if true the attributes will be returned as well. if servers do not support this it can require an extra request per service
filters  a list of Filter objects to narrow down the query. Note that the order can be important, depending the the Filter's type.
scopeList  a list of all scopes that will be searched, DefaultScopes or an empty list for the daemon's default scopes
Returns:
true if the operation was successful

bool KDE::SLP::Registry::findServiceTypes const QString &    token = QString::null,
const QString &    namingAuthority = AllAuthorities,
const QStringList &    scopeList = DefaultScopes
 

Finds all service types in the given scopes with the given naming authority. This function emits the signal foundServiceTypes() each time it discovered one or more service types. When the last service type has been found operationFinished() will be emitted. The function will not return before it finished searching, but the event loop will be running while the function blocks.

Parameters:
token  a string that will be given as arguments to the emitted signals. This allows you to identify signals when you have several operations running.
namingAuthority  the naming authorities of the service types to be found. If DefaultAuthority only IANA service types will be returned, if it is AllAuthorities all service types will be returned
scopeList  a list of all scopes that will be searched, either DefaultScopes or an empty list for the daemon's default scopes
Returns:
true if the operation was successful
See also:
findServiceTypesAsync

bool KDE::SLP::Registry::findServiceTypesAsync const QString &    token = QString::null,
const QString &    namingAuthority = AllAuthorities,
const QStringList &    scopeList = DefaultScopes
 

Finds all service types in the given scopes with the given naming authority. This function emits the signal foundServiceTypes() each time it discovered one or more service types. When the last service type has been found operationFinished() will be emitted. The function will return immediately.

Parameters:
token  a string that will be given as arguments to the emitted signals. This allows you to identify signals when you have several operations running.
namingAuthority  the naming authorities of the service types to be found. If DefaultAuthority only IANA service types will be returned, if it is AllAuthorities all service types will be returned
scopeList  a list of all scopes that will be searched, either DefaultScopes or an empty list for the daemon's default scopes
Returns:
true if the operation was successful
See also:
findServiceTypes

void KDE::SLP::Registry::foundAttributes QString    token,
Service    service
[signal]
 

Called by findAttributes() when the service's attributes have been found.

Parameters:
token  the token that you specified when starting the operation
service  the service with attributes set

void KDE::SLP::Registry::foundScopes QString    token,
QStringList    scopeList
[signal]
 

Called by findScopes() when the scopes have been discovered.

Parameters:
token  the token that you specified when starting the operation
scopeList  a list of valid scopes

void KDE::SLP::Registry::foundService QString    token,
Service    service,
int    lifetime
[signal]
 

Called by findServices() each time a service has been found.

Parameters:
token  the token that you specified when starting the operation
service  the service.
lifetime  the lifetime of the service in seconds

void KDE::SLP::Registry::foundServiceTypes QString    token,
QStringList    serviceTypes
[signal]
 

Called by findServiceTypes() each time one or more service types have been discovered.

Parameters:
token  the token that you specified when starting the operation
serviceTypes  a list of service types

void KDE::SLP::Registry::operationFinished QString    token,
bool    success,
QString    msg
[signal]
 

Emitted when a operation finished.

Parameters:
token  the token that you specified when starting the operation
success  true if all items have been found, false when an error occurred during the operation
msg  a programmer-readable error message, or QString::null on success

Registry& KDE::SLP::Registry::operator= const Registry &    other
 

Makes a copy of the registry. Both will share the connection and language configuration.

Parameters:
other  the other registry to copy
Returns:
this registry

bool KDE::SLP::Registry::registerService const Service   service,
bool    autoAddress,
bool    autoDeregister = true,
const QStringList &    scopes = DefaultScopes,
unsigned short    lifetime = RecommendedLifetime,
bool    autoLifetimeExtension = true
 

Registers the given service.

Registers the given service with the daemon. The daemon will do the rest, like announcing it at DAs and so on. You can safely call register for an existing service - there is no need to deregister() it before. registerService() can do several tasks for you that you would otherwise would have to implement manually.

AutoAddress allows you to register a single instance of the service for all interfaces. The SLP daemon will automatically take care that it is announced for each address of this system, even when the interfaces change. This option should only be used for local services that listen to every address using the wildcard. It is required that when this option is activated you use a "service:" type URL with host set to "localhost". On daemons that do not support this feature, "localhost" will be replaced with the host name. Use supportsAutoAddress() to check whether a daemon supports it.

AutoDeregister unregisters the service when the last Registry object has been deleted. When the daemon supports it, it will also unregister the service when the connection gets interrupted, for example when this application crashes.

AutoLifetimeExtension re-registers a service automatically at the daemon before it expires. It is supported on all servers.

When you register a service that is provided by your application you are almost always fine with the default values for all arguments, you only need service and autoAddress.

Parameters:
service  the service to register
autoAddress  if true the AutoAddress feature will be used
autoDeregister  if true the service will be registered automatically when the last Registry instance has been deleted or the connection has been interrupted
scopes  the list of scopes that the service will be registered. Use DefaultScopes or an empty list to use the daemon's default scopes
lifetime  the lifetime of the service in seconds, RecommendedLifetime for the recommended value (15 minutes) or UnlimitedLifetime for inifinite. It is recommended to have not more than 30 minutes as lifetime, so the service does not live forever when the system crashes or is disconnected from the network. Do not use a value less than a minute, most servers limit the frequency of the updates.
autoLifetimeExtension  if true, the service will be automatically renewed when its lifetime expires, as long as a Registry object lives
Returns:
true if successful, false otherwise. False usually means that no SLP daemon is running
See also:
deregister()

bool KDE::SLP::Registry::supportsAutoAddress  
 

Checks whether this connection supports the AutoAddress option.

Returns:
true if AutoAddress is supported
See also:
registerService()


Member Data Documentation

const QString KDE::SLP::Registry::AllAuthorities [static]
 

Use this constant for findServiceTypes()'s namingAuthority argument to get all services,

const QString KDE::SLP::Registry::DefaultAuthority [static]
 

Use this constant for findServiceTypes()'s namingAuthority argument to get only services from the default (IANA) naming authority.

const QStringList KDE::SLP::Registry::DefaultScopes [static]
 

Use this value in registerService() to register a service with the default scopes. In most cases this is what you want.

const unsigned short KDE::SLP::Registry::RecommendedLifetime = 900 [static]
 

The recommended lifetime of a service (15 minutes).

const unsigned short KDE::SLP::Registry::UnlimitedLifetime = 65535 [static]
 

Use this lifetime in registerService() to let a service live forever. This is not recommended in most cases, only do this when you register a service you have no control over and the service will live longer than the application that registers it.


The documentation for this class was generated from the following file:
Generated on Tue Jun 24 20:14:35 2003 for KDE::SLP by doxygen1.2.18