kio Library: KService Class Reference (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | 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 }
## Public Member Functions
| KService (const QString &_name, const QString &_exec, const QString &_icon)
| KService (const QString &_fullpath)
| KService (KDesktopFile *config)
| 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
QString | menuId () const
QString | storageId () const
DCOPServiceType_t | DCOPServiceType () const
QString | path () const
QString | comment () const
QString | genericName () const
QString | untranslatedGenericName () 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
int | initialPreferenceForMimeType (const QString &mimeType) const
void | setInitialPreference (int i)
bool | noDisplay () const
QString | parentApp () const
virtual QVariant | property (const QString &_name) const
QVariant | property (const QString &_name, QVariant::Type t) const
virtual QStringList | propertyNames () const
bool | isValid () const
QString | locateLocal ()
virtual void | load (QDataStream &)
virtual void | save (QDataStream &)
void | setMenuId (const QString &menuId)
void | setTerminal (bool b)
void | setTerminalOptions (const QString &options)
## Static Public Member Functions
static Ptr | serviceByName (const QString &_name)
static Ptr | serviceByDesktopPath (const QString &_path)
static Ptr | serviceByDesktopName (const QString &_name)
static Ptr | serviceByMenuId (const QString &_menuId)
static Ptr | serviceByStorageId (const QString &_storageId)
static List | allServices ()
static List | allInitServices ()
static QString | newServicePath (bool showInMenu, const QString &suggestedName, QString *menuId=0, const QStringList *reservedMenuIds=0)
static void | rebuildKSycoca (QWidget *parent)
## 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. Service types are stored as desktop files in the "service" resource..

See also:
  KServiceType

  KServiceGroup

Author:
  Torben Weis <weis@kde.org>

Definition at line 48 of file kservice.h.

## Member Enumeration Documentation

enum KService::DCOPServiceType_t

| Describes the DCOP type of the service. 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 213 of file kservice.h.

## 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. Parameters:
  | _name | the name of the service
  | _exec | the executable
  | _icon | the name of the icon
Definition at line 63 of file kservice.cpp. Referenced by serviceByStorageId().

KService::KService | ( | const QString & | _fullpath | ) | `[explicit]`

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

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

  | Construct a service and take all information from a desktop file. Parameters:
  | config | the desktop file to read
Definition at line 87 of file kservice.cpp. References init().

## Member Function Documentation

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

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

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

| Returns the name of the service. Returns: the name of the service, or QString::null if not set Implements KSycocaEntry. Definition at line 98 of file kservice.h.

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

| Returns the executable. Returns: the command that the service executes, or QString::null if not set Definition at line 104 of file kservice.h.

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

| Returns the name of the service's library. Returns: the name of the library that contains the services implementation, or QString::null if not set Definition at line 111 of file kservice.h.

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

| Returns the name of the init function to call (KControl modules). Returns: the name of the init function to call in this service during startup of KDE. (KControl modules only), or QString::null if not set Definition at line 118 of file kservice.h. Referenced by KService().

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

| Returns the name of the icon. Returns: the icon associated with the service, or QString::null if not set Definition at line 125 of file kservice.h.

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

| Returns the pixmap that represents the icon. Returns: a pixmap for this service (finds and loads icon()), null if not set See also: icon() Definition at line 274 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]`

| Checks whethe the service should be run in a terminal. Returns: true if the service is to be run in a terminal. Definition at line 138 of file kservice.h.

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. Returns: the terminal options, or QString::null if not set Definition at line 147 of file kservice.h.

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

| Checks whether the service runs with a different user id. Returns: true if the service has to be run under a different uid. See also: username() Definition at line 666 of file kservice.cpp. References QVariant::isValid(), property(), and QVariant::toBool().

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

| Returns the user name, if the service runs with a different user id. Returns: the username under which the service has to be run, or QString::null if not set See also: substututeUid()a Definition at line 671 of file kservice.cpp. References QString::isEmpty(), QVariant::isValid(), property(), and QVariant::toString().

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. Returns: the path of the service's desktop file, or QString::null if not set Definition at line 174 of file kservice.h. References KSycocaEntry::entryPath(). Referenced by locateLocal().

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

| Returns the filename of the service desktop entry without any extension. E.g. "kppp" Returns: the name of the desktop entry without path or extension, or QString::null if not set Definition at line 182 of file kservice.h.

QString KService::menuId | ( |  | ) | const

| Returns the menu ID of the service desktop entry. The menu ID is used to add or remove the entry to a menu. Returns: the menu ID Since: 3.2 Definition at line 745 of file kservice.cpp. Referenced by KServiceGroup::entries(), and newServicePath().

QString KService::storageId | ( |  | ) | const

| Returns a normalized ID suitable for storing in configuration files. It will be based on the menu-id when available and otherwise falls back to desktopEntryPath() Returns: the storage ID Since: 3.2 Definition at line 755 of file kservice.cpp. References KSycocaEntry::entryPath().

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

| Returns the DCOPServiceType supported by this service. Returns: the DCOPServiceType supported by this service Definition at line 219 of file kservice.h.

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

| Returns the working directory to run the program in. Returns: the working directory to run the program in, or QString::null if not set Definition at line 226 of file kservice.h.

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

| Returns the descriptive comment for the service, if there is one. Returns: the descriptive comment for the service, or QString::null if not set Definition at line 233 of file kservice.h.

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

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

QString KService::untranslatedGenericName | ( |  | ) | const

| Returns the untranslated (US English) generic name for the service, if there is one (e.g. "Mail Client"). Returns: the generic name, or QString::null if not set Since: 3.2 Definition at line 716 of file kservice.cpp. References QVariant::isValid(), property(), and QVariant::toString().

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

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

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

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

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

| Returns the service types that this service supports. Returns: the list of service types that are supported Definition at line 270 of file kservice.h.

bool KService::hasServiceType | ( | const QString & | _service | ) | const

  | Checks whether the service supports this service type. 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 347 of file kservice.cpp. References KMimeType::mimeType(), and KServiceType::serviceType().

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

| Checks whether a service is used as a default setting, for example as plugin 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. Returns: true if the service may be used as a default setting Definition at line 288 of file kservice.h.

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

| Checks whether this service can handle several files as startup arguments. 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 731 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. Returns: the service preference level of the service Definition at line 304 of file kservice.h.

int KService::initialPreferenceForMimeType | ( | const QString & | mimeType | ) | const

| What preference to associate with this service initially for handling the specified mimetype. (before the user has had any chance to define a profile for it). The bigger the value, the most preferred the service is. Returns: the service preference level of the service for this mimetype Definition at line 380 of file kservice.cpp. References KMimeType::mimeType(), and KServiceType::serviceType().

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

| Whether the entry should be suppressed in menus. Returns: true to suppress this service Definition at line 683 of file kservice.cpp. References QMap::end(), QMap::find(), and QStringList::split(). Referenced by KServiceGroup::childCount(), and KServiceGroup::entries().

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

| Name of the application this service belongs to. (Useful for e.g. plugins) Returns: the parent application, or QString::null if not set Since: 3.1 Definition at line 721 of file kservice.cpp. References QMap::end(), and QMap::find().

QVariant KService::property | ( | const QString & | _name | ) | const`[virtual]`

  | Returns the requested property. 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. Parameters:
  | _name | the name of the property
Returns: the property, or invalid if not found See also: KServiceType Definition at line 468 of file kservice.cpp. Referenced by substituteUid(), untranslatedGenericName(), and username().

QVariant KService::property | ( | const QString & | _name,
|  | QVariant::Type | t
| ) | const

  | Returns the requested property. Parameters:
  | _name | the name of the property
  | t | the assumed type of the property
Returns: the property, or invalid if not found See also: KServiceType Since: 3.2 Definition at line 483 of file kservice.cpp. References QMap::end(), KSycocaEntry::entryPath(), QMap::find(), kdDebug(), and QString::toInt().

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

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

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

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

QString KService::locateLocal | ( |  | ) |

| Returns a path that can be used for saving changes to this service. Returns: path that can be used for saving changes to this service Since: 3.2 Definition at line 762 of file kservice.cpp. References desktopEntryPath(), QDir::isRelativePath(), locateLocal(), KDesktopFile::locateLocal(), and QString::startsWith().

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. Parameters:
  | _name | the name to search
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 608 of file kservice.cpp. Referenced by KServiceTypeProfile::allowAsDefault().

KService::Ptr KService::serviceByDesktopPath | ( | const QString & | _path | ) | `[static]`

  | Find a service based on its path as returned by desktopEntryPath(). It's usually better to use serviceByStorageId() instead. Parameters:
  | _path | the path of the configuration file
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 614 of file kservice.cpp. Referenced by serviceByStorageId().

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. Parameters:
  | _name | the name of the configuration file
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 620 of file kservice.cpp. Referenced by KRun::foundMimeType(), KURIFilterData::iconName(), KRun::runCommand(), and serviceByStorageId().

KService::Ptr KService::serviceByMenuId | ( | const QString & | _menuId | ) | `[static]`

  | Find a service by its menu-id. Parameters:
  | _menuId | the menu id of the service
Returns: a pointer to the requested service or 0 if the service is unknown. Very important: Don't store the result in a KService* ! Since: 3.2 Definition at line 628 of file kservice.cpp. Referenced by newServicePath(), and serviceByStorageId().

KService::Ptr KService::serviceByStorageId | ( | const QString & | _storageId | ) | `[static]`

  | Find a service by its storage-id or desktop-file path. This function will try very hard to find a matching service. Parameters:
  | _storageId | the storage id or desktop-file path of the service
Returns: a pointer to the requested service or 0 if the service is unknown. Very important: Don't store the result in a KService* ! Since: 3.2 Definition at line 634 of file kservice.cpp. References QString::endsWith(), QString::findRev(), KService(), QString::length(), QString::mid(), serviceByDesktopName(), serviceByDesktopPath(), serviceByMenuId(), and QString::truncate().

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. Returns: the list of all services Definition at line 603 of file kservice.cpp.

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

| Returns all services that require initialisation. Only needed by "kcminit" Returns: the list of all services that need to be initialized Definition at line 661 of file kservice.cpp.

QString KService::newServicePath | ( | bool | showInMenu,
|  | const QString & | suggestedName,
|  | QString * | menuId = `0`,
|  | const QStringList * | reservedMenuIds = `0`
| ) | `[static]`

  | Returns a path that can be used to create a new KService based on `suggestedName`. Parameters:
  | showInMenu | true, if the service should be shown in the KDE menu false, if the service should be hidden from the menu
  | suggestedName | name to base the file on, if a service with such name already exists, a prefix will be added to make it unique.
  | menuId | If provided, menuId will be set to the menu id to use for the KService
  | reservedMenuIds | If provided, the path and menu id will be chosen in such a way that the new menu id does not conflict with any of the reservedMenuIds
Returns: The path to use for the new KService. Since: 3.2 Definition at line 771 of file kservice.cpp. References QString::arg(), locate(), locateLocal(), menuId(), QString::mid(), QString::prepend(), and serviceByMenuId().

void KService::rebuildKSycoca | ( | QWidget * | parent | ) | `[static]`

  | Rebuild KSycoca and show a progress dialog while doing so. Parameters:
  | parent | Parent widget for the progress dialog
Since: 3.2 Definition at line 827 of file kservice.cpp. References DCOPClient::callAsync(). Referenced by KDesktopPropsPlugin::applyChanges().

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

- kservice.h
- kservice.cpp

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:25:17 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003