Main Page   Class Hierarchy   Compound List   File List   Compound Members  

KDE::SLP::Service Class Reference

#include <service.h>

List of all members.

Public Methods

 Service (const QString &url, const QString &attributes=QString::null)
 Service (const Service &service)
Service & operator= (const Service &other)
bool operator== (const Service &other)
QString url () const
QString serviceType () const
QString abstractServiceType () const
bool areAttributesSet () const
QString serializedAttributes () const
void setSerializedAttributes (const QString &attributes)
QString serializedAttributeValue (const QString &name) const
bool hasAttribute (const QString &attributeName) const
bool isList (const QString &attributeName) const
bool isTag (const QString &attributeName) const
QString getString (const QString &attributeName) const
bool getBool (const QString &attributeName) const
int getInt (const QString &attributeName) const
QByteArray getBlob (const QString &attributeName) const
QStringList getStringList (const QString &attributeName) const
QValueVector< bool > getBoolList (const QString &attributeName) const
QValueVector< int > getIntList (const QString &attributeName) const
QValueVector< QByteArray > getBlobList (const QString &attributeName) const
void remove (const QString &attributeName)
void setTag (const QString &attributeName)
void setString (const QString &attributeName, const QString &value)
void setBool (const QString &attributeName, bool value)
void setInt (const QString &attributeName, int value)
void setBlob (const QString &attributeName, const QByteArray &value)
void setStringList (const QString &attributeName, const QStringList &values)
void setBoolList (const QString &attributeName, const QValueVector< bool > &values)
void setIntList (const QString &attributeName, const QValueVector< int > &values)
void setBlob (const QString &attributeName, const QValueVector< QByteArray > &values)


Detailed Description

Service describes a SLP (RFC 2608) service.

A service will be described using a Service URL and an optional list of attributes. Any valid URL can be used to describe the service, but usually the "service:" URL scheme is used. The syntax for such a simple Service URL is

   service:srvtype://addrspec
 
where "srvtype" specifies the protocol and "addrspec" the address. Examples of valid Service URLs are "service:http://www.kde.org", "service:lpr://printer.example.org/myqueue" and "service:http://your.server.org:8080". To provide more information about your service than just the protocol, port and address you can use abstract service types. A Service URL that uses an abstract service type has the form
   service:abstract-type:concrete-type
 
where "abstract-type" describes the kind of service and "concrete-type" specifies the protocol and address. Examples are "service:printer:lpr://printer.example.com/lp0" and "service:printer:ipp://printer.example.com/". Note that you cannot invent you own types but only take those that are registered at IANA. To create your own service type you must become a naming authority. Then you can use service types of the form "srvtype.naming-authority". Assuming that "kde" is the id of a IANA-registered naming authority, a valid Service URL would be "service:weatherp.kde://weather.example.com". You can find more information about Service URLs in the IETF RFCs 2608 and 3224.

Each service can have one or more attributes to carry additional information about the service. Attributes are name/value pairs. The name is a simple strings, the value can have several types: strings, binary objects (blobs), integers and boleans. It is possible to have a list of values in an attribute, but all list members must have the same type. Attributes can be used, for example, to describe the type of a printer or the email address of an administrator.

Service templates can be used to describe an abstract type, including the syntax of the concrete type and the attributes. The use of service templates is described in RFC 2609, you can find the existing service templates at http://www.iana.org/assignments/svrloc-templates.htm .

See also:
KDE::SLP::Registry
Author:
Tim Jansen, tim@tjansen.de


Constructor & Destructor Documentation

KDE::SLP::Service::Service const QString &    url,
const QString &    attributes = QString::null
 

Creates a new Service with the given url and optionally the given attributes.

Parameters:
url  the URL of the service
attributes  the attributes in the serialized RFC 2608 format, or QString::null to have no attribute set

KDE::SLP::Service::Service const Service &    service
 

Makes a deep copy of the given service.

Parameters:
service  the other service to copy


Member Function Documentation

QString KDE::SLP::Service::abstractServiceType  
 

Returns the abstract service type of the service. It is extracted from the URL. If the service does not use a abstract service scheme, it will return the same value as serviceType(). Otherwise it will return only the abstract part, e.g. "service:printer" for the URL "service:printer:ipp://printer.example.com/".

Returns:
abstract service type of the service, QString::null if unparsable
See also:
serviceType

bool KDE::SLP::Service::areAttributesSet  
 

Checks whether attributes have been set in this Service object. When you do a query you will only get the attributes when you ask for them and the other server supports this, otherwise the flag will be false.

Returns:
true if attributes are available, false otherwise

QByteArray KDE::SLP::Service::getBlob const QString &    attributeName const
 

Returns the first blob value of the attribute with the given attributeName.

Parameters:
attributeName  the name of the attribute
Returns:
the value of the attribute, or a null array if there is no blob
See also:
getBlobList() , setBlob()

QValueVector<QByteArray> KDE::SLP::Service::getBlobList const QString &    attributeName const
 

Returns the blob values of the attribute with the given attributeName.

Parameters:
attributeName  the name of the attribute
Returns:
the values of the attribute, or an empty list if there is no blob list
See also:
getStringList() , getBlob() , setBlobList()

bool KDE::SLP::Service::getBool const QString &    attributeName const
 

Returns the first boolean value of the attribute with the given attributeName. The boolean parser is very tolerant, every string that does not equal "true" is taken as a false.

Parameters:
attributeName  the name of the attribute
Returns:
the value of the attribute, or false if there is no boolean
See also:
getBoolList() , getString() , setBool()

QValueVector<bool> KDE::SLP::Service::getBoolList const QString &    attributeName const
 

Returns the boolean values of the attribute with the given attributeName. The boolean parser is very tolerant, every string that does not equal "true" is taken as a false.

Parameters:
attributeName  the name of the attribute
Returns:
the values of the attribute
See also:
getStringList() , getBool() , setBoolList()

int KDE::SLP::Service::getInt const QString &    attributeName const
 

Returns the first integer value of the attribute with the given attributeName.

Parameters:
attributeName  the name of the attribute
Returns:
the value of the attribute, or -1 if there is no number
See also:
getIntList() , getString() , setInt()

QValueVector<int> KDE::SLP::Service::getIntList const QString &    attributeName const
 

Returns the int values of the attribute with the given attributeName.

Parameters:
attributeName  the name of the attribute
Returns:
the values of the attribute, or an empty list if there is no integer list
See also:
getStringList() , getInt() , setIntList()

QString KDE::SLP::Service::getString const QString &    attributeName const
 

Returns the first string of the attribute with the given attributeName. This function can also be used to read boolean and integer attributes. The returned string has been unescaped.

Parameters:
attributeName  the name of the attribute
Returns:
the value of the attribute, or QString::null if there is none. A simple tag without value returns the empty string.
See also:
getStringList() , setString()

QStringList KDE::SLP::Service::getStringList const QString &    attributeName const
 

Returns the values of the attribute with the given attributeName. This function can also be used to read boolean and integer attributes. The returned strings have been unescaped.

Parameters:
attributeName  the name of the attribute
Returns:
the values of the attribute, or an empty list if there are none
See also:
getString() , setStringList()

bool KDE::SLP::Service::hasAttribute const QString &    attributeName const
 

Returns true if the attribute with the given attributeName does exist.

Parameters:
attributeName  the name of the attribute
Returns:
true if the given attribute exists
See also:
isTag() , isList()

bool KDE::SLP::Service::isList const QString &    attributeName const
 

Returns true if the attribute with the given attributeName does exist and has more than one value.

Parameters:
attributeName  the name of the attribute
Returns:
true if the given attribute exists and has more than one value
See also:
getStringList() , getBoolList() , getIntList() , getBlobList()

bool KDE::SLP::Service::isTag const QString &    attributeName const
 

Returns true if the attribute with the given attributeName does exist and is a tag (has no value).

Parameters:
attributeName  the name of the attribute
Returns:
true if the given attribute is a tag, false if not
See also:
hasAttribute()

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

Makes a deep copy of the given service.

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

bool KDE::SLP::Service::operator== const Service &    other
 

Compares the two services. Two services are equal when they have the same URL. The attributes will not be compared.

Parameters:
other  the other service to compare
Returns:
true if both services have the same URL

void KDE::SLP::Service::remove const QString &    attributeName
 

Removes the attribute attributeName.

Parameters:
attributeName  the name of the attribute to remove
See also:
setString()

QString KDE::SLP::Service::serializedAttributes  
 

Returns the raw, encoded string with the attributes. It has the form

 (name=value,value,..),(name=value),...
 
Reserved characters in the attribute name and values will be escaped. The exact format is described in RFC 2608.
Returns:
the attributes in the RFC 2608 format, an empty string if no attributes have been set
See also:
setSerializedAttributes()

QString KDE::SLP::Service::serializedAttributeValue const QString &    name const
 

Returns the value of the attribute name in the RFC 2608 serialized and encoded format. It has the form

 value,value,..
 
Reserved characters will be escaped.
Returns:
the attribute values in the RFC 2608 format, or QString::null if the attribute does not exist or is a tag without value

QString KDE::SLP::Service::serviceType  
 

Returns the service type of the service. It is extracted from the URL. If the URL does not use the "service:" URL scheme, the URL scheme is used, e.g. "http" will be returned for "http://www.kde.org". If the "service:" URL scheme is used, the complete service description will be returned, e.g. "service:printer:ipp" for the URL "service:printer:ipp://printer.example.com/".

Returns:
the service type of the service, QString::null if unparsable
See also:
abstractServiceType

void KDE::SLP::Service::setBlob const QString &    attributeName,
const QValueVector< QByteArray > &    values
 

Sets the value of the attribute to the given blob list. It is not recommended to set a blob list that is larger than a couple of hundred bytes. While the SLP standard allows it, a server is likely to limit the size of SLP messages and thus will no be able to return a blob of that size. Also note that because of the encoding the transmitted size will be three times as large as the binary.

Parameters:
attributeName  the name of the attribute to set
values  the values to set
See also:
setBlob() , getBlobList()

void KDE::SLP::Service::setBlob const QString &    attributeName,
const QByteArray &    value
 

Sets the value of the attribute to the given blob. It is not recommended to set a blob that is larger than a couple of hundred bytes. While the SLP standard allows it, a server is likely to limit the size of SLP messages and thus will no be able to return a blob of that size. Also note that because of the encoding the transmitted size will be three times as large as the binary.

Parameters:
attributeName  the name of the attribute to set
value  the value to set
See also:
getBlob() , setBlobList()

void KDE::SLP::Service::setBool const QString &    attributeName,
bool    value
 

Sets the value of the attribute to the given boolean.

Parameters:
attributeName  the name of the attribute to set
value  the value to set
See also:
getBool() , setBoolList()

void KDE::SLP::Service::setBoolList const QString &    attributeName,
const QValueVector< bool > &    values
 

Sets the value of the attribute to the given boolean list.

Parameters:
attributeName  the name of the attribute to set
values  the values to set
See also:
setBool() , getBoolList()

void KDE::SLP::Service::setInt const QString &    attributeName,
int    value
 

Sets the value of the attribute to the given integer.

Parameters:
attributeName  the name of the attribute to set
value  the value to set
See also:
getInt() , setIntList()

void KDE::SLP::Service::setIntList const QString &    attributeName,
const QValueVector< int > &    values
 

Sets the value of the attribute to the given integer list.

Parameters:
attributeName  the name of the attribute to set
values  the values to set
See also:
setInt() , getIntList()

void KDE::SLP::Service::setSerializedAttributes const QString &    attributes
 

Sets the raw, encoded attribute string. Replaces all existing attributes. The exact format is described in RFC 2608.

Parameters:
attributes  the attributes of the service

void KDE::SLP::Service::setString const QString &    attributeName,
const QString &    value
 

Sets the value of the attribute to the given string. Note that SLP attributes do not have real types, so you can also set an integer or boolean using setString() as long as they have the right syntax.

Parameters:
attributeName  the name of the attribute to set
value  the value to set. If the string is empty, a simple tag without value will be created. QString::null to remove a tag
See also:
getString() , setStringList() , setTag()

void KDE::SLP::Service::setStringList const QString &    attributeName,
const QStringList &    values
 

Sets the value of the attribute to the given string list.

Parameters:
attributeName  the name of the attribute to set
values  the values to set. Note that the strings must not be empty or null
See also:
setString() , getStringList()

void KDE::SLP::Service::setTag const QString &    attributeName
 

Makes attributeName a simple tag without value.

Parameters:
attributeName  the name of the attribute to set
See also:
setString() , isTag()

QString KDE::SLP::Service::url  
 

Returns the URL of the service.

Returns:
the URL of the service


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