# class KService | Represent a service, i. More...
Definition | `#include <kservice.h>`
Inherits | KSycocaEntry [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- typedef KSharedPtr<KService> Ptr
- typedef QValueList<Ptr> List
- enum DCOPServiceType_t { DCOP_None = 0, DCOP_Unique, DCOP_Multi, DCOP_Wait }

#### Public Methods

- KService ( const QString & _fullpath )
- KService ( KDesktopFile *config )
- KService ( QDataStream& _str, int offset )
- virtual ~KService ()
- virtual QString type () const
- virtual QString name () const
- QString exec () const
- QString library () const
- QString init () const
- int libraryMajor () const
- int libraryMinor () const
- QStringList libraryDependencies () const
- QString icon () const
- QPixmap pixmap ( int _group, int _force_size = 0, int _state = 0, QString * _path = 0L ) const
- bool terminal () const
- QString terminalOptions () const
- bool substituteUid () const
- QString username () const
- QString desktopEntryPath () const
- QString desktopEntryName () const
- DCOPServiceType_t DCOPServiceType () const
- QString path () const
- QString comment () const
- QStringList keywords () const
- bool mapNotify () const
- QStringList serviceTypes () const
- bool hasServiceType ( const QString& _service ) const
- bool allowAsDefault () const
- int initialPreference () const
- virtual QVariant property ( const QString& _name ) const
- virtual QStringList propertyNames () const
- bool isValid () const
- virtual void load ( QDataStream& )
- virtual void save ( QDataStream& )

#### Public Static Methods

- static Ptr serviceByName ( const QString& _name )
- static Ptr serviceByDesktopPath ( const QString& _name )
- static Ptr serviceByDesktopName ( const QString& _name )
- static List allServices ()
- static List allInitServices ()

#### Protected Methods

- void init (KDesktopFile *config)

## Detailed Description

Represent a service, i.e. an application bound to one or several mimetypes (or servicetypes) as written in its desktop entry file.

A service may be a library, too. The starting point you need is often the static methods.

typedef KSharedPtr<KService> Ptr | ### Ptr

typedef QValueList<Ptr> List | ### List

KService ( const QString & _fullpath ) | ### KService

Construct a service and take all information from a config file.

Parameters:

_fullpath | Full path to the config file.
_relpath | Relative path wrt to $KDEDIRS/+resource.

KService ( KDesktopFile *config ) | ### KService

Construct a service and take all information from a desktop file.

KService ( QDataStream& _str, int offset ) | ### KService

Construct a service from a stream. The stream must already be positionned at the correct offset.

~KService () | ### ~KService

[virtual]

QString type () | ### type

[const virtual]

Returns the type of the service ("Application" or "Service").

QString name () | ### name

[const virtual]

Returns the name of the service.

Reimplemented from KSycocaEntry.

QString exec () | ### exec

[const]

Returns the command that the service executes.

QString library () | ### library

[const]

Returns the name of the library that contains the services implementation.

QString init () | ### init

[const]

Returns the name of the init function to call in this service during startup of KDE. (KControl modules only)

int libraryMajor () | ### libraryMajor

[const]

Returns the major number of the library.

See also: library(), libraryMinor()

int libraryMinor () | ### libraryMinor

[const]

Returns the minor number of the library.

See also: library(), libraryMajor()

QStringList libraryDependencies () | ### libraryDependencies

[const]

Returns the libraries on which this service depends. That is only of interest if the service itelf is a library.

QString icon () | ### icon

[const]

Returns the icon associated with the service.

QPixmap pixmap ( int _group, int _force_size = 0, int _state = 0, QString * _path = 0L ) | ### pixmap

[const]

Returns a pixmap for this service (finds and loads icon())

bool terminal () | ### terminal

[const]

Returns `true` is the service is run in a terminal.

QString terminalOptions () | ### terminalOptions

[const]

Returns any options associated with the terminal the service runs in, if it requires a terminal.

The service must be a tty-oriented program.

bool substituteUid () | ### substituteUid

[const]

Returns `true` if the service has to be run under a different uid.

QString username () | ### username

[const]

Returns the username under which the service has to be run.

QString desktopEntryPath () | ### desktopEntryPath

[const]

Returns the path to the location where the service desktop entry is stored.

This is a relative path if the desktop entry was found in any of the locations pointed to by $KDEDIRS (e.g. "Internet/kppp.desktop") It is a full path if the desktop entry originates from another location.

QString desktopEntryName () | ### desktopEntryName

[const]

Returns the filename of the service desktop entry without any extension. E.g. "kppp"

enum DCOPServiceType_t { DCOP_None = 0, DCOP_Unique, DCOP_Multi, DCOP_Wait } | ### DCOPServiceType_t

- None - This service has no DCOP support
- Unique - This service provides a unique DCOP service. The service name is equal to the desktopEntryName.
- Multi - This service provides a DCOP service which can be run with multiple instances in parallel. The service name of an instance is equal to the desktopEntryName + "-" + the PID of the process.
- Wait - This service has no DCOP support, the launcher will wait till it is finished.

DCOPServiceType_t DCOPServiceType () | ### DCOPServiceType

[const]

Returns The DCOPServiceType supported by this service.

QString path () | ### path

[const]

Returns the working directory to run the program in.

QString comment () | ### comment

[const]

Returns the descriptive comment for the service, if there is one.

QStringList keywords () | ### keywords

[const]

Returns a list of descriptive keywords the service, if there are any.

bool mapNotify () | ### mapNotify

[const]

Returns whether map notification should be used with this service.

QStringList serviceTypes () | ### serviceTypes

[const]

Returns the service types that this service supports.

bool hasServiceType ( const QString& _service ) | ### hasServiceType

[const]

Parameters:

_service | The name of the service type you are interested in determining whether this services supports.

Returns: `true` if the service you specified is supported, otherwise `false`.

bool allowAsDefault () | ### allowAsDefault

[const]

Returns `true` if the service may be used as a default setting, for example in a file manager. Usually that is the case, but some services may only be started when the user selected them. This kind of services returns `false` here.

int initialPreference () | ### initialPreference

[const]

What preference to associate with this service initially (before the user has had any chance to define a profile for it) The bigger the value, the most preferred the service is.

QVariant property ( const QString& _name ) | ### property

[const virtual]

Returns the requested properties. Some often used properties have convenience access functions like exec(), serviceTypes etc.

It depends upon the serviceTypes() of this service which properties a service can have.

See also: KServiceType

QStringList propertyNames () | ### propertyNames

[const virtual]

Returns the list of all properties that this service can have. That means, that some properties may be empty.

bool isValid () | ### isValid

[const]

Returns `true` if the service is valid (e.g. name is not empty)

Reimplemented from KSycocaEntry.

void load ( QDataStream& ) | ### load

[virtual]

Load the service from a stream.

Reimplemented from KSycocaEntry.

void save ( QDataStream& ) | ### save

[virtual]

Save the service to a stream.

Reimplemented from KSycocaEntry.

Ptr serviceByName ( const QString& _name ) | ### serviceByName

[static]

Find a service by name, i.e. the translated Name field. You should really not use this method, since the name is translated.

Returns a pointer to the requested service or 0 if the service is unknown. Very important: Don't store the result in a KService * !

Ptr serviceByDesktopPath ( const QString& _name ) | ### serviceByDesktopPath

[static]

Find a service by its relative path to the applnk or services directory, for instance "Internet/konqbrowser.desktop". Better not use it for menu entries though, since the user can move them. It's ok to use it for services though (e.g. "http_cache_cleaner.desktop")

Returns a pointer to the requested service or 0 if the service is unknown. Very important: Don't store the result in a KService * !

Ptr serviceByDesktopName ( const QString& _name ) | ### serviceByDesktopName

[static]

Find a service by the name of its desktop file, not depending on its actual location (as long as it's under the applnk or service directories). For instance "konqbrowser" or "kcookiejar". Note that the ".desktop" extension is implicit.

This is the recommended method (safe even if the user moves stuff) but note that it assumes that no two entries have the same filename.

Returns a pointer to the requested service or 0 if the service is unknown. Very important: Don't store the result in a KService * !

List allServices () | ### allServices

[static]

Returns the whole list of services.

Useful for being able to to display them in a list box, for example. More memory consuming than the ones above, don't use unless really necessary.

List allInitServices () | ### allInitServices

[static]

Returns all services that require initialisation.

Only needed by "kcminit"

void init (KDesktopFile *config) | ### init

[protected]

- Author: Torben Weis <weis@kde.org>
- Generated: root@sparc.ports.openbsd.org on Wed May 2 09:40:40 2001, using kdoc 2.0a53.