org.kde.koala

Class KService

public class KService extends KSycocaEntry

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

Author: Torben Weis

See Also: KServiceType KServiceGroup

UNKNOWN: Represent a service, i.

Field Summary
static intDCOP_Multi
static intDCOP_None
Describes the DCOP type of the service.
static intDCOP_Unique
static intDCOP_Wait
Constructor Summary
protected KService(Class dummy)
KService(String _name, String _exec, String _icon)
Construct a temporary service with a given name, exec-line and icon.
KService(String _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)
Construct a service from a stream.
Method Summary
protected ArrayListaccessServiceTypes()
booleanallowAsDefault()
Checks whether a service is used as a default setting, for example as plugin in a file manager.
booleanallowMultipleFiles()
Checks whether this service can handle several files as startup arguments.
ArrayListcategories()
Returns a list of VFolder categories.
Stringcomment()
Returns the descriptive comment for the service, if there is one.
StringdesktopEntryName()
Returns the filename of the service desktop entry without any extension.
StringdesktopEntryPath()
Returns the path to the location where the service desktop entry is stored.
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
intDCOPServiceType()
Returns the DCOPServiceType supported by this service.
Stringexec()
Returns the executable.
protected voidfinalize()
Deletes the wrapped C++ instance
StringgenericName()
Returns the generic name for the service, if there is one (e.g.
booleanhasServiceType(String _service)
Checks whether the service supports this service type
Stringicon()
Returns the name of the icon.
Stringinit()
Returns the name of the init function to call (KControl modules).
protected voidinit(KDesktopFile config)
intinitialPreference()
What preference to associate with this service initially (before the user has had any chance to define a profile for it).
intinitialPreferenceForMimeType(String mimeType)
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).
booleanisDisposed()
Has the wrapped C++ instance been deleted?
booleanisValid()
Checks whether the service is valid.
ArrayListkeywords()
Returns a list of descriptive keywords the service, if there are any.
Stringlibrary()
Returns the name of the service's library.
voidload(QDataStream arg1)
Load the service from a stream.
StringlocateLocal()
Returns a path that can be used for saving changes to this service
StringmenuId()
Returns the menu ID of the service desktop entry.
Stringname()
Returns the name of the service.
static StringnewServicePath(boolean showInMenu, String suggestedName, StringBuffer menuId, String[] reservedMenuIds)
Returns a path that can be used to create a new KService based on suggestedName.
static StringnewServicePath(boolean showInMenu, String suggestedName, StringBuffer menuId)
static StringnewServicePath(boolean showInMenu, String suggestedName)
booleannoDisplay()
Whether the entry should be suppressed in menus.
StringparentApp()
Name of the application this service belongs to.
Stringpath()
Returns the working directory to run the program in.
QPixmappixmap(int _group, int _force_size, int _state, StringBuffer _path)
Returns the pixmap that represents the icon.
QPixmappixmap(int _group, int _force_size, int _state)
QPixmappixmap(int _group, int _force_size)
QPixmappixmap(int _group)
QVariantproperty(String _name)
Returns the requested property.
QVariantproperty(String _name, int t)
Returns the requested property.
ArrayListpropertyNames()
Returns the list of all properties that this service can have.
static voidrebuildKSycoca(QWidget parent)
Rebuild KSycoca and show a progress dialog while doing so.
voidsave(QDataStream arg1)
Save the service to a stream.
ArrayListserviceTypes()
Returns the service types that this service supports.
voidsetInitialPreference(int i)
voidsetMenuId(String menuId)
Set the menu id
voidsetTerminal(boolean b)
Sets whether to use a terminal or not
voidsetTerminalOptions(String options)
Sets the terminal options to use
StringstorageId()
Returns a normalized ID suitable for storing in configuration files.
booleansubstituteUid()
Checks whether the service runs with a different user id.
booleanterminal()
Checks whethe the service should be run in a terminal.
StringterminalOptions()
Returns any options associated with the terminal the service runs in, if it requires a terminal.
Stringtype()
Returns the type of the service.
StringuntranslatedGenericName()
Returns the untranslated (US English) generic name for the service, if there is one (e.g.
Stringusername()
Returns the user name, if the service runs with a different user id.

Field Detail

DCOP_Multi

public static final int DCOP_Multi

DCOP_None

public static final int DCOP_None
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.
  • @short Describes the DCOP type of the service.

    DCOP_Unique

    public static final int DCOP_Unique

    DCOP_Wait

    public static final int DCOP_Wait

    Constructor Detail

    KService

    protected KService(Class dummy)

    KService

    public KService(String _name, String _exec, String _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

    UNKNOWN: Construct a temporary service with a given name, exec-line and icon.

    KService

    public KService(String _fullpath)
    Construct a service and take all information from a config file.

    Parameters: _fullpath Full path to the config file.

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

    KService

    public KService(KDesktopFile config)
    Construct a service and take all information from a desktop file.

    Parameters: config the desktop file to read

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

    KService

    public KService(QDataStream _str, int offset)
    Construct a service from a stream. The stream must already be positionned at the correct offset.

    UNKNOWN:

    Method Detail

    accessServiceTypes

    protected ArrayList accessServiceTypes()

    allowAsDefault

    public boolean allowAsDefault()
    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

    UNKNOWN: Checks whether a service is used as a default setting, for example as plugin in a file manager.

    allowMultipleFiles

    public boolean allowMultipleFiles()
    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.

    UNKNOWN: Checks whether this service can handle several files as startup arguments.

    categories

    public ArrayList categories()
    Returns a list of VFolder categories.

    Returns: the list of VFolder categories

    UNKNOWN: Returns a list of VFolder categories.

    comment

    public String comment()
    Returns the descriptive comment for the service, if there is one.

    Returns: the descriptive comment for the service, or null if not set

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

    desktopEntryName

    public String desktopEntryName()
    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 null if not set

    UNKNOWN: Returns the filename of the service desktop entry without any extension.

    desktopEntryPath

    public String desktopEntryPath()
    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 null if not set

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

    dispose

    public void dispose()
    Delete the wrapped C++ instance ahead of finalize()

    DCOPServiceType

    public int DCOPServiceType()
    Returns the DCOPServiceType supported by this service.

    Returns: the DCOPServiceType supported by this service

    UNKNOWN: Returns the DCOPServiceType supported by this service.

    exec

    public String exec()
    Returns the executable.

    Returns: the command that the service executes, or null if not set

    UNKNOWN: Returns the executable.

    finalize

    protected void finalize()
    Deletes the wrapped C++ instance

    genericName

    public String genericName()
    Returns the generic name for the service, if there is one (e.g. "Mail Client").

    Returns: the generic name, or null if not set

    UNKNOWN: Returns the generic name for the service, if there is one (e.

    hasServiceType

    public boolean hasServiceType(String _service)
    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.

    UNKNOWN: Checks whether the service supports this service type

    icon

    public String icon()
    Returns the name of the icon.

    Returns: the icon associated with the service, or "unknown" if not set

    UNKNOWN: Returns the name of the icon.

    init

    public String init()
    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 null if not set

    UNKNOWN: Returns the name of the init function to call (KControl modules).

    init

    protected void init(KDesktopFile config)

    initialPreference

    public int initialPreference()
    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

    UNKNOWN: What preference to associate with this service initially (before the user has had any chance to define a profile for it).

    initialPreferenceForMimeType

    public int initialPreferenceForMimeType(String mimeType)
    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

    UNKNOWN: What preference to associate with this service initially for handling the specified mimetype.

    isDisposed

    public boolean isDisposed()
    Has the wrapped C++ instance been deleted?

    isValid

    public boolean isValid()
    Checks whether the service is valid.

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

    UNKNOWN: Checks whether the service is valid.

    keywords

    public ArrayList keywords()
    Returns a list of descriptive keywords the service, if there are any.

    Returns: the list of keywords

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

    library

    public String library()
    Returns the name of the service's library.

    Returns: the name of the library that contains the services implementation, or null if not set

    UNKNOWN: Returns the name of the service's library.

    load

    public void load(QDataStream arg1)
    Load the service from a stream.

    UNKNOWN:

    locateLocal

    public String 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

    UNKNOWN: Returns a path that can be used for saving changes to this service

    menuId

    public String menuId()
    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

    UNKNOWN: Returns the menu ID of the service desktop entry.

    name

    public String name()
    Returns the name of the service.

    Returns: the name of the service, or null if not set

    UNKNOWN: Returns the name of the service.

    newServicePath

    public static String newServicePath(boolean showInMenu, String suggestedName, StringBuffer menuId, String[] reservedMenuIds)
    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.

    UNKNOWN: Returns a path that can be used to create a new KService based on suggestedName.

    newServicePath

    public static String newServicePath(boolean showInMenu, String suggestedName, StringBuffer menuId)

    newServicePath

    public static String newServicePath(boolean showInMenu, String suggestedName)

    noDisplay

    public boolean noDisplay()
    Whether the entry should be suppressed in menus.

    Returns: true to suppress this service

    UNKNOWN: Whether the entry should be suppressed in menus.

    parentApp

    public String parentApp()
    Name of the application this service belongs to. (Useful for e.g. plugins)

    Returns: the parent application, or null if not set

    UNKNOWN: Name of the application this service belongs to.

    path

    public String path()
    Returns the working directory to run the program in.

    Returns: the working directory to run the program in, or null if not set

    UNKNOWN: Returns the working directory to run the program in.

    pixmap

    public QPixmap pixmap(int _group, int _force_size, int _state, StringBuffer _path)
    Returns the pixmap that represents the icon.

    Returns: a pixmap for this service (finds and loads icon()), null if not set

    See Also: KService

    UNKNOWN: Returns the pixmap that represents the icon.

    pixmap

    public QPixmap pixmap(int _group, int _force_size, int _state)

    pixmap

    public QPixmap pixmap(int _group, int _force_size)

    pixmap

    public QPixmap pixmap(int _group)

    property

    public QVariant property(String _name)
    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

    UNKNOWN: Returns the requested property.

    property

    public QVariant property(String _name, int t)
    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

    UNKNOWN: Returns the requested property.

    propertyNames

    public ArrayList propertyNames()
    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

    UNKNOWN: Returns the list of all properties that this service can have.

    rebuildKSycoca

    public static void rebuildKSycoca(QWidget parent)
    Rebuild KSycoca and show a progress dialog while doing so.

    Parameters: parent Parent widget for the progress dialog

    UNKNOWN: Rebuild KSycoca and show a progress dialog while doing so.

    save

    public void save(QDataStream arg1)
    Save the service to a stream.

    UNKNOWN:

    serviceTypes

    public ArrayList serviceTypes()
    Returns the service types that this service supports.

    Returns: the list of service types that are supported

    UNKNOWN: Returns the service types that this service supports.

    setInitialPreference

    public void setInitialPreference(int i)

    UNKNOWN:

    setMenuId

    public void setMenuId(String menuId)
    Set the menu id

    UNKNOWN:

    setTerminal

    public void setTerminal(boolean b)
    Sets whether to use a terminal or not

    UNKNOWN:

    setTerminalOptions

    public void setTerminalOptions(String options)
    Sets the terminal options to use

    UNKNOWN:

    storageId

    public String storageId()
    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

    UNKNOWN: Returns a normalized ID suitable for storing in configuration files.

    substituteUid

    public boolean substituteUid()
    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: KService

    UNKNOWN: Checks whether the service runs with a different user id.

    terminal

    public boolean terminal()
    Checks whethe the service should be run in a terminal.

    Returns: true if the service is to be run in a terminal.

    UNKNOWN: Checks whethe the service should be run in a terminal.

    terminalOptions

    public String terminalOptions()
    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 null if not set

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

    type

    public String type()
    Returns the type of the service.

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

    UNKNOWN: Returns the type of the service.

    untranslatedGenericName

    public String untranslatedGenericName()
    Returns the untranslated (US English) generic name for the service, if there is one (e.g. "Mail Client").

    Returns: the generic name, or null if not set

    UNKNOWN: Returns the untranslated (US English) generic name for the service, if there is one (e.

    username

    public String username()
    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 null if not set

    See Also: KService

    UNKNOWN: Returns the user name, if the service runs with a different user id.