org.kde.koala
Class KService

java.lang.Object
  extended by org.kde.koala.KShared
      extended by org.kde.koala.KSycocaEntry
          extended by org.kde.koala.KService
All Implemented Interfaces:
org.kde.qt.QtSupport

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

Field Summary
static int DCOP_Multi
           
static int DCOP_None
          Describes the DCOP type of the service.
static int DCOP_Unique
           
static int DCOP_Wait
           
 
Constructor Summary
protected KService(java.lang.Class dummy)
           
  KService(KDesktopFile config)
          Construct a service and take all information from a desktop file.
  KService(org.kde.qt.QDataStream _str, int offset)
          Construct a service from a stream.
  KService(java.lang.String _fullpath)
          Construct a service and take all information from a config file.
  KService(java.lang.String _name, java.lang.String _exec, java.lang.String _icon)
          Construct a temporary service with a given name, exec-line and icon.
 
Method Summary
protected  java.util.ArrayList accessServiceTypes()
           
 boolean allowAsDefault()
          Checks whether a service is used as a default setting, for example as plugin in a file manager.
 boolean allowMultipleFiles()
          Checks whether this service can handle several files as startup arguments.
 java.util.ArrayList categories()
          Returns a list of VFolder categories.
 java.lang.String comment()
          Returns the descriptive comment for the service, if there is one.
 int DCOPServiceType()
          Returns the DCOPServiceType supported by this service.
 java.lang.String desktopEntryName()
          Returns the filename of the service desktop entry without any extension.
 java.lang.String desktopEntryPath()
          Returns the path to the location where the service desktop entry is stored.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
 java.lang.String exec()
          Returns the executable.
protected  void finalize()
          Deletes the wrapped C++ instance
 java.lang.String genericName()
          Returns the generic name for the service, if there is one (e.g.
 boolean hasServiceType(java.lang.String _service)
          Checks whether the service supports this service type
 java.lang.String icon()
          Returns the name of the icon.
 java.lang.String init()
          Returns the name of the init function to call (KControl modules).
protected  void init(KDesktopFile config)
           
 int initialPreference()
          What preference to associate with this service initially (before the user has had any chance to define a profile for it).
 int initialPreferenceForMimeType(java.lang.String mimeType)
          What preference to associate with this service initially for handling the specified mimetype.
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 boolean isValid()
          Checks whether the service is valid.
 java.util.ArrayList keywords()
          Returns a list of descriptive keywords the service, if there are any.
 java.lang.String library()
          Returns the name of the service's library.
 void load(org.kde.qt.QDataStream arg1)
          Load the service from a stream.
 java.lang.String locateLocal()
          Returns a path that can be used for saving changes to this service
 java.lang.String menuId()
          Returns the menu ID of the service desktop entry.
 java.lang.String name()
          Returns the name of the service.
static java.lang.String newServicePath(boolean showInMenu, java.lang.String suggestedName)
           
static java.lang.String newServicePath(boolean showInMenu, java.lang.String suggestedName, java.lang.StringBuffer menuId)
           
static java.lang.String newServicePath(boolean showInMenu, java.lang.String suggestedName, java.lang.StringBuffer menuId, java.lang.String[] reservedMenuIds)
          Returns a path that can be used to create a new KService based on suggestedName.
 boolean noDisplay()
          Whether the entry should be suppressed in menus.
 java.lang.String parentApp()
          Name of the application this service belongs to.
 java.lang.String path()
          Returns the working directory to run the program in.
 org.kde.qt.QPixmap pixmap(int _group)
           
 org.kde.qt.QPixmap pixmap(int _group, int _force_size)
           
 org.kde.qt.QPixmap pixmap(int _group, int _force_size, int _state)
           
 org.kde.qt.QPixmap pixmap(int _group, int _force_size, int _state, java.lang.StringBuffer _path)
          Returns the pixmap that represents the icon.
 org.kde.qt.QVariant property(java.lang.String _name)
          Returns the requested property.
 org.kde.qt.QVariant property(java.lang.String _name, int t)
          Returns the requested property.
 java.util.ArrayList propertyNames()
          Returns the list of all properties that this service can have.
static void rebuildKSycoca(org.kde.qt.QWidget parent)
          Rebuild KSycoca and show a progress dialog while doing so.
 void save(org.kde.qt.QDataStream arg1)
          Save the service to a stream.
 java.util.ArrayList serviceTypes()
          Returns the service types that this service supports.
 void setInitialPreference(int i)
           
 void setMenuId(java.lang.String menuId)
          Set the menu id
 void setTerminal(boolean b)
          Sets whether to use a terminal or not
 void setTerminalOptions(java.lang.String options)
          Sets the terminal options to use
 java.lang.String storageId()
          Returns a normalized ID suitable for storing in configuration files.
 boolean substituteUid()
          Checks whether the service runs with a different user id.
 boolean terminal()
          Checks whethe the service should be run in a terminal.
 java.lang.String terminalOptions()
          Returns any options associated with the terminal the service runs in, if it requires a terminal.
 java.lang.String type()
          Returns the type of the service.
 java.lang.String untranslatedGenericName()
          Returns the untranslated (US English) generic name for the service, if there is one (e.g.
 java.lang.String username()
          Returns the user name, if the service runs with a different user id.
 
Methods inherited from class org.kde.koala.KSycocaEntry
entryPath, isDeleted, isType, offset, read, read, sycocaType
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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.

    See Also:
    Constant Field Values

    DCOP_Unique

    public static final int DCOP_Unique
    See Also:
    Constant Field Values

    DCOP_Multi

    public static final int DCOP_Multi
    See Also:
    Constant Field Values

    DCOP_Wait

    public static final int DCOP_Wait
    See Also:
    Constant Field Values
    Constructor Detail

    KService

    protected KService(java.lang.Class dummy)

    KService

    public KService(java.lang.String _name,
                    java.lang.String _exec,
                    java.lang.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

    KService

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

    Parameters:
    _fullpath - Full path to the 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

    KService

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

    Method Detail

    type

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

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

    name

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

    Overrides:
    name in class KSycocaEntry
    Returns:
    the name of the service, or null if not set

    exec

    public java.lang.String exec()
    Returns the executable.

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

    library

    public java.lang.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

    init

    public java.lang.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

    icon

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

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

    pixmap

    public org.kde.qt.QPixmap pixmap(int _group,
                                     int _force_size,
                                     int _state,
                                     java.lang.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:
    icon()

    pixmap

    public org.kde.qt.QPixmap pixmap(int _group,
                                     int _force_size,
                                     int _state)

    pixmap

    public org.kde.qt.QPixmap pixmap(int _group,
                                     int _force_size)

    pixmap

    public org.kde.qt.QPixmap pixmap(int _group)

    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.

    terminalOptions

    public java.lang.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

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

    username

    public java.lang.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:
    #substututeUida

    desktopEntryPath

    public java.lang.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

    desktopEntryName

    public java.lang.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

    menuId

    public java.lang.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

    storageId

    public java.lang.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

    DCOPServiceType

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

    Returns:
    the DCOPServiceType supported by this service

    path

    public java.lang.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

    comment

    public java.lang.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

    genericName

    public java.lang.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

    untranslatedGenericName

    public java.lang.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

    keywords

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

    Returns:
    the list of keywords

    categories

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

    Returns:
    the list of VFolder categories

    serviceTypes

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

    Returns:
    the list of service types that are supported

    hasServiceType

    public boolean hasServiceType(java.lang.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.

    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

    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.

    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

    initialPreferenceForMimeType

    public int initialPreferenceForMimeType(java.lang.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

    setInitialPreference

    public void setInitialPreference(int i)

    noDisplay

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

    Returns:
    true to suppress this service

    parentApp

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

    Returns:
    the parent application, or null if not set

    property

    public org.kde.qt.QVariant property(java.lang.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

    property

    public org.kde.qt.QVariant property(java.lang.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

    propertyNames

    public java.util.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

    isValid

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

    Overrides:
    isValid in class KSycocaEntry
    Returns:
    true if the service is valid (e.g. name is not empty)

    locateLocal

    public java.lang.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

    load

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

    Overrides:
    load in class KSycocaEntry

    save

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

    Overrides:
    save in class KSycocaEntry

    setMenuId

    public void setMenuId(java.lang.String menuId)
    Set the menu id


    setTerminal

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


    setTerminalOptions

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


    newServicePath

    public static java.lang.String newServicePath(boolean showInMenu,
                                                  java.lang.String suggestedName,
                                                  java.lang.StringBuffer menuId,
                                                  java.lang.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.

    newServicePath

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

    newServicePath

    public static java.lang.String newServicePath(boolean showInMenu,
                                                  java.lang.String suggestedName)

    rebuildKSycoca

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

    Parameters:
    parent - Parent widget for the progress dialog

    init

    protected void init(KDesktopFile config)

    accessServiceTypes

    protected java.util.ArrayList accessServiceTypes()

    finalize

    protected void finalize()
                     throws java.lang.InternalError
    Deletes the wrapped C++ instance

    Overrides:
    finalize in class java.lang.Object
    Throws:
    java.lang.InternalError

    dispose

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


    isDisposed

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