| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KService Class Reference

Represent a service, i.e. More...

`#include <kservice.h>`

Inheritance diagram for KService:

[legend]
Collaboration diagram for KService:

[legend]
List of all members.

## Public Types
typedef KSharedPtr< KService > | Ptr
typedef QValueList< Ptr > | List
enum | DCOPServiceType_t { DCOP_None = 0, DCOP_Unique, DCOP_Multi, DCOP_Wait }
| None - This service has no DCOP support Unique - This service provides a unique DCOP service. More...
## Public Member Functions
| KService (const QString &_name, const QString &_exec, const QString &_icon)
| Construct a temporary service with a given name, exec-line and icon.
| KService (const QString &_fullpath)
| Construct a service and take all information from a config file.
| KService (KDesktopFile *config)
| Construct a service and take all information from a desktop file.
| KService (QDataStream &_str, int offset)
virtual QString | type () const
virtual QString | name () const
QString | exec () const
QString | library () const
QString | init () const
QString | icon () const
QPixmap | pixmap (KIcon::Group _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
QString | genericName () const
QStringList | keywords () const
QStringList | categories () const
QStringList | serviceTypes () const
bool | hasServiceType (const QString &_service) const
bool | allowAsDefault () const
bool | allowMultipleFiles () const
int | 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.
void | setInitialPreference (int i)
bool | noDisplay () const
| Whether the entry should be suppressed in menus.
QString | parentApp () const
| Name of the application this service belongs to.
virtual QVariant | property (const QString &_name) const
virtual QStringList | propertyNames () const
bool | isValid () const
virtual void | load (QDataStream &)
virtual void | save (QDataStream &)
## Static Public Member Functions
Ptr | serviceByName (const QString &_name)
| Find a service by name, i.e.
Ptr | serviceByDesktopPath (const QString &_name)
| Find a service by its relative path to the applnk or services directory, for instance "Internet/konqbrowser.desktop".
Ptr | serviceByDesktopName (const QString &_name)
| 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).
List | allServices ()
List | allInitServices ()
## Protected Member Functions
void | init (KDesktopFile *config)
QStringList & | accessServiceTypes ()
virtual void | virtual_hook (int id, void *data)
## Friends
class | KBuildSycoca

## 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.

Author:
  Torben Weis <weis@kde.org>

Definition at line 43 of file kservice.h.

## Member Enumeration Documentation

enum KService::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. Definition at line 162 of file kservice.h. Referenced by DCOPServiceType().

## Constructor & Destructor Documentation

KService::KService | ( | const QString & | _name,
|  | const QString & | _exec,
|  | const QString & | _icon
| ) |

| Construct a temporary service with a given name, exec-line and icon. Definition at line 58 of file kservice.cpp. References KSycocaEntry::m_bDeleted.

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

  | Construct a service and take all information from a config file. Parameters:
  _fullpath | Full path to the config file.
Definition at line 74 of file kservice.cpp. References init().

KService::KService | ( | KDesktopFile * | config | ) |

| Construct a service and take all information from a desktop file. Definition at line 82 of file kservice.cpp. References init().

## Member Function Documentation

virtual QString KService::type | ( |  | ) | const`[inline, virtual]`

| Returns: the type of the service ("Application" or "Service"). Definition at line 85 of file kservice.h.

virtual QString KService::name | ( |  | ) | const`[inline, virtual]`

| Returns: the name of the service. Implements KSycocaEntry. Definition at line 89 of file kservice.h.

QString KService::exec | ( |  | ) | const`[inline]`

| Returns: the command that the service executes. Definition at line 93 of file kservice.h. Referenced by KRun::processDesktopExec().

QString KService::library | ( |  | ) | const`[inline]`

| Returns: the name of the library that contains the services implementation. Definition at line 98 of file kservice.h.

QString KService::init | ( |  | ) | const`[inline]`

| Returns: the name of the init function to call in this service during startup of KDE. (KControl modules only) Definition at line 103 of file kservice.h. Referenced by KService().

QString KService::icon | ( |  | ) | const`[inline]`

| Returns: the icon associated with the service. Definition at line 108 of file kservice.h.

QPixmap KService::pixmap | ( | KIcon::Group | _group,
|  | int | _force_size = 0,
|  | int | _state = 0,
|  | QString * | _path = 0L
| ) | const

| Returns: a pixmap for this service (finds and loads icon()) Definition at line 260 of file kservice.cpp. References KIconLoader::addExtraDesktopThemes(), KIconLoader::extraDesktopThemesAdded(), KGlobal::iconLoader(), QPixmap::isNull(), KIconLoader::loadIcon(), and pixmap(). Referenced by pixmap().

bool KService::terminal | ( |  | ) | const`[inline]`

| Returns: true if the service is to be run in a terminal. Definition at line 117 of file kservice.h. Referenced by KRun::processDesktopExec().

QString KService::terminalOptions | ( |  | ) | const`[inline]`

| Returns: any options associated with the terminal the service runs in, if it requires a terminal. The service must be a tty-oriented program. Definition at line 124 of file kservice.h. Referenced by KRun::processDesktopExec().

bool KService::substituteUid | ( |  | ) | const

| Returns: true if the service has to be run under a different uid. Definition at line 528 of file kservice.cpp. References QVariant::isValid(), property(), and QVariant::toBool(). Referenced by KRun::processDesktopExec().

QString KService::username | ( |  | ) | const

| Returns: the username under which the service has to be run. Definition at line 533 of file kservice.cpp. References QString::isEmpty(), QVariant::isValid(), property(), and QVariant::toString(). Referenced by KRun::processDesktopExec().

QString KService::desktopEntryPath | ( |  | ) | const`[inline]`

| 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. Definition at line 143 of file kservice.h. References KSycocaEntry::entryPath(). Referenced by KRun::run().

QString KService::desktopEntryName | ( |  | ) | const`[inline]`

| Returns: the filename of the service desktop entry without any extension. E.g. "kppp" Definition at line 149 of file kservice.h. Referenced by KRun::run().

DCOPServiceType_t KService::DCOPServiceType | ( |  | ) | const`[inline]`

| Returns: The DCOPServiceType supported by this service. Definition at line 167 of file kservice.h. References DCOPServiceType_t.

QString KService::path | ( |  | ) | const`[inline]`

| Returns: the working directory to run the program in. Definition at line 172 of file kservice.h.

QString KService::comment | ( |  | ) | const`[inline]`

| Returns: the descriptive comment for the service, if there is one. Definition at line 177 of file kservice.h.

QString KService::genericName | ( |  | ) | const`[inline]`

| Returns: the generic name for the service, if there is one. (e.g. "Mail Client") Definition at line 183 of file kservice.h.

QStringList KService::keywords | ( |  | ) | const`[inline]`

| Returns: a list of descriptive keywords the service, if there are any. Definition at line 188 of file kservice.h.

QStringList KService::categories | ( |  | ) | const

| Returns: a list of VFolder categories. Since: 3.1 Definition at line 578 of file kservice.cpp.

QStringList KService::serviceTypes | ( |  | ) | const`[inline]`

| Returns: the service types that this service supports. Definition at line 199 of file kservice.h.

bool KService::hasServiceType | ( | const QString & | _service | ) | 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`. Definition at line 333 of file kservice.cpp. References KServiceType::serviceType().

bool KService::allowAsDefault | ( |  | ) | const`[inline]`

| 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. Definition at line 215 of file kservice.h.

bool KService::allowMultipleFiles | ( |  | ) | const

| Returns: true if multiple files may be passed to this service at startup. False if only one file at a time may be passed. Definition at line 569 of file kservice.cpp. References QString::find().

int KService::initialPreference | ( |  | ) | const`[inline]`

| 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. Definition at line 228 of file kservice.h.

bool KService::noDisplay | ( |  | ) | const

| Whether the entry should be suppressed in menus. Definition at line 545 of file kservice.cpp. References QMap< QString, QVariant >::end(), and QMap< QString, QVariant >::find(). Referenced by KServiceGroup::childCount(), and KServiceGroup::entries().

QString KService::parentApp | ( |  | ) | const

| Name of the application this service belongs to. (Usefull for e.g. plugins) Since: 3.1 Definition at line 559 of file kservice.cpp. References QMap< QString, QVariant >::end(), and QMap< QString, QVariant >::find().

QVariant KService::property | ( | const QString & | _name | ) | 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 Definition at line 380 of file kservice.cpp. References QMap< QString, QVariant >::end(), KSycocaEntry::entryPath(), QMap< QString, QVariant >::find(), and QString::toInt(). Referenced by substituteUid(), and username().

QStringList KService::propertyNames | ( |  | ) | const`[virtual]`

| Returns: the list of all properties that this service can have. That means, that some properties may be empty. Definition at line 471 of file kservice.cpp. References QMap< QString, QVariant >::begin(), and QMap< QString, QVariant >::end().

bool KService::isValid | ( |  | ) | const`[inline, virtual]`

| Returns: true if the service is valid (e.g. name is not empty) Implements KSycocaEntry. Definition at line 267 of file kservice.h.

KService::Ptr KService::serviceByName | ( | const QString & | _name | ) | `[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* ! Definition at line 505 of file kservice.cpp. References KSycocaEntry::Ptr.

KService::Ptr KService::serviceByDesktopPath | ( | const QString & | _name | ) | `[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* ! Definition at line 511 of file kservice.cpp. References KSycocaEntry::Ptr.

KService::Ptr KService::serviceByDesktopName | ( | const QString & | _name | ) | `[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* ! Definition at line 517 of file kservice.cpp. References KSycocaEntry::Ptr. Referenced by KRun::foundMimeType(), KURIFilterData::iconName(), and KRun::runCommand().

KService::List KService::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. Definition at line 500 of file kservice.cpp.

KService::List KService::allInitServices | ( |  | ) | `[static]`

| Returns: all services that require initialisation. Only needed by "kcminit" Definition at line 523 of file kservice.cpp.

The documentation for this class was generated from the following files:

- kservice.h
- kservice.cpp

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:22:17 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001