kio Library API Documentation

KService Class Reference

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

#include <kservice.h>

Inheritance diagram for KService:

KSycocaEntry KShared List of all members.

Public Types

enum  DCOPServiceType_t
 
  • None - This service has no DCOP support
  • Unique - This service provides a unique DCOP service.
More...



Public Methods

 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.

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.

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

Static Public Methods

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 ()

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 159 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 60 of file kservice.cpp.

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 76 of file kservice.cpp.

References init().

KService::KService KDesktopFile   config
 

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

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

virtual QString KService::name   const [inline, virtual]
 

Returns:
the name of the service.

Definition at line 86 of file kservice.h.

QString KService::exec   const [inline]
 

Returns:
the command that the service executes.

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

Referenced by KService().

QString KService::icon   const [inline]
 

Returns:
the icon associated with the service.

Definition at line 105 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 274 of file kservice.cpp.

References KIconLoader::addExtraDesktopThemes(), KIconLoader::extraDesktopThemesAdded(), KIcon::Group, 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 114 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 121 of file kservice.h.

Referenced by KRun::processDesktopExec().

bool KService::substituteUid  
 

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

Definition at line 542 of file kservice.cpp.

References QVariant::isValid(), property(), and QVariant::toBool().

Referenced by KRun::processDesktopExec().

QString KService::username  
 

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

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

Referenced by KRun::run().

DCOPServiceType_t KService::DCOPServiceType   const [inline]
 

Returns:
The DCOPServiceType supported by this service.

Definition at line 164 of file kservice.h.

References DCOPServiceType_t.

QString KService::path   const [inline]
 

Returns:
the working directory to run the program in.

Definition at line 169 of file kservice.h.

QString KService::comment   const [inline]
 

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

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

QStringList KService::keywords   const [inline]
 

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

Definition at line 185 of file kservice.h.

QStringList KService::categories  
 

Returns:
a list of VFolder categories.
Since:
3.1

Definition at line 592 of file kservice.cpp.

QStringList KService::serviceTypes   const [inline]
 

Returns:
the service types that this service supports.

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

bool KService::allowMultipleFiles  
 

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 583 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 225 of file kservice.h.

bool KService::noDisplay  
 

Whether the entry should be suppressed in menus.

Definition at line 559 of file kservice.cpp.

References QMap< QString, QVariant >::end(), and QMap< QString, QVariant >::find().

Referenced by KServiceGroup::childCount(), and KServiceGroup::entries().

QString KService::parentApp  
 

Name of the application this service belongs to.

(Usefull for e.g. plugins)

Since:
3.1

Definition at line 573 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 394 of file kservice.cpp.

References QMap< QString, QVariant >::end(), KSycocaEntry::entryPath(), QMap< QString, QVariant >::find(), KConfigBase::readPropertyEntry(), and QString::toInt().

Referenced by substituteUid(), and username().

QStringList KService::propertyNames   [virtual]
 

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

Definition at line 485 of file kservice.cpp.

References QMap< QString, QVariant >::begin(), and QMap< QString, QVariant >::end().

bool KService::isValid   const [inline]
 

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

Definition at line 264 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 519 of file kservice.cpp.

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 525 of file kservice.cpp.

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 531 of file kservice.cpp.

Referenced by KRun::foundMimeType(), and KURIFilterData::iconName().

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 514 of file kservice.cpp.

KService::List KService::allInitServices   [static]
 

Returns:
all services that require initialisation.
Only needed by "kcminit"

Definition at line 537 of file kservice.cpp.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:37 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001