org.kde.koala
Class KMimeType

java.lang.Object
  extended by org.kde.koala.KShared
      extended by org.kde.koala.KSycocaEntry
          extended by org.kde.koala.KServiceType
              extended by org.kde.koala.KMimeType
All Implemented Interfaces:
org.kde.qt.QtSupport
Direct Known Subclasses:
KDEDesktopMimeType, KExecMimeType, KFolderType

public class KMimeType
extends KServiceType

Represent a mime type, like "text/plain", and the data that is associated with it. The starting point you need is often the static methods. KMimeType inherits KServiceType because "text/plain" can be used to find services (apps and components) "which can open text/plain".

See Also:
KServiceType

Constructor Summary
protected KMimeType(java.lang.Class dummy)
           
  KMimeType(KDesktopFile config)
          Construct a mimetype and take all information from a desktop file.
  KMimeType(org.kde.qt.QDataStream _str, int offset)
          The stream must already be positionned at the correct offset
  KMimeType(java.lang.String _fullpath)
          Construct a mimetype and take all information from a config file.
  KMimeType(java.lang.String _fullpath, java.lang.String _type, java.lang.String _icon, java.lang.String _comment, java.lang.String[] _patterns)
          Constructor.
 
Method Summary
protected static void buildDefaultType()
          This function makes sure that the default mime type exists.
protected static void checkEssentialMimeTypes()
          This function makes sure that vital mime types are installed.
 java.lang.String comment()
          Returns the descriptive comment associated with the MIME type.
 java.lang.String comment(KURL arg1, boolean arg2)
          Returns the descriptive comment associated with the MIME type.
 java.lang.String comment(java.lang.String arg1, boolean arg2)
          Returns the descriptive comment associated with the MIME type.
static java.lang.String defaultMimeType()
          Returns the name of the default mimetype.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
protected static void errorMissingMimeType(java.lang.String _type)
          Signal a missing mime type.
static java.lang.String favIconForURL(KURL url)
          Return the "favicon" (see http://www.favicon.com) for the given url, if available.
protected  void finalize()
          Deletes the wrapped C++ instance
 java.lang.String icon(KURL arg1, boolean arg2)
          Return the filename of the icon associated with the mimetype.
 java.lang.String icon(java.lang.String arg1, boolean arg2)
          Return the filename of the icon associated with the mimetype.
static java.lang.String iconForURL(KURL _url)
           
static java.lang.String iconForURL(KURL _url, long _mode)
          The same functionality as pixmapForURL(), but this method returns the name of the icon to load.
protected  void init(KDesktopFile arg1)
          Returns a list of all the supported servicetypes.
 boolean is(java.lang.String mimeTypeName)
          Do not use name()=="somename" anymore, to check for a given mimetype.
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 void load(org.kde.qt.QDataStream qs)
          Load the mimetype from a stream.
protected  void loadInternal(org.kde.qt.QDataStream arg1)
          Determines the mimetype of file based on it's name and returns the matching pattern if any.
 java.lang.String parentMimeType()
          If this mimetype inherits from ("is also") another mimetype, return the name of the parent.
 java.util.ArrayList patterns()
          Retrieve the list of patterns associated with the MIME Type.
protected  int patternsAccuracy()
           
 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)
          Use this function only if you don't have a special URL for which you search a pixmap.
 org.kde.qt.QPixmap pixmap(KURL _url, int _group)
           
 org.kde.qt.QPixmap pixmap(KURL _url, int _group, int _force_size)
           
 org.kde.qt.QPixmap pixmap(KURL _url, int _group, int _force_size, int _state)
           
 org.kde.qt.QPixmap pixmap(KURL _url, int _group, int _force_size, int _state, java.lang.StringBuffer _path)
          Find the pixmap for a given file of this mimetype.
static org.kde.qt.QPixmap pixmapForURL(KURL _url)
           
static org.kde.qt.QPixmap pixmapForURL(KURL _url, long _mode)
           
static org.kde.qt.QPixmap pixmapForURL(KURL _url, long _mode, int _group)
           
static org.kde.qt.QPixmap pixmapForURL(KURL _url, long _mode, int _group, int _force_size)
           
static org.kde.qt.QPixmap pixmapForURL(KURL _url, long _mode, int _group, int _force_size, int _state)
           
static org.kde.qt.QPixmap pixmapForURL(KURL _url, long _mode, int _group, int _force_size, int _state, java.lang.StringBuffer _path)
          Convenience method to find the pixmap for a URL.
 org.kde.qt.QVariant property(java.lang.String _name)
          Returns the property with the given _name.
 java.util.ArrayList propertyNames()
          Retrieves a list of all properties associated with this KMimeType.
 void save(org.kde.qt.QDataStream qs)
          Save the mimetype to a stream.
 
Methods inherited from class org.kde.koala.KServiceType
desktopEntryPath, icon, inherits, isDerived, isValid, name, parentServiceType, propertyDef, propertyDefNames
 
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
 

Constructor Detail

KMimeType

protected KMimeType(java.lang.Class dummy)

KMimeType

public KMimeType(java.lang.String _fullpath,
                 java.lang.String _type,
                 java.lang.String _icon,
                 java.lang.String _comment,
                 java.lang.String[] _patterns)
Constructor. You may pass in arguments to create a mimetype with specific properties.

Parameters:
_fullpath - the path to the configuration file (.desktop)
_type - the mime type itself
_icon - the name of the icon that represens the mime type
_comment - a comment describing the mime type
_patterns - a list of file globs that describes the names (or extensions) of the files with this mime type

KMimeType

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

Parameters:
_fullpath - the path to the configuration file (.desktop)

KMimeType

public KMimeType(KDesktopFile config)
Construct a mimetype and take all information from a desktop file.

Parameters:
config - the desktop configuration file that describes the mime type

KMimeType

public KMimeType(org.kde.qt.QDataStream _str,
                 int offset)
The stream must already be positionned at the correct offset

Method Detail

icon

public java.lang.String icon(java.lang.String arg1,
                             boolean arg2)
Return the filename of the icon associated with the mimetype. The arguments are unused, but provided so that KMimeType-derived classes can use them (e.g. KFolderType uses the URL to return one out of 2 icons)

Returns:
The path to the icon associated with this MIME type.

icon

public java.lang.String icon(KURL arg1,
                             boolean arg2)
Return the filename of the icon associated with the mimetype. The arguments are unused, but provided so that KMimeType-derived classes can use them (e.g. KFolderType uses the URL to return one out of 2 icons)

Returns:
The path to the icon associated with this MIME type.

pixmap

public org.kde.qt.QPixmap pixmap(int group,
                                 int force_size,
                                 int state,
                                 java.lang.StringBuffer path)
Use this function only if you don't have a special URL for which you search a pixmap. This function is useful to find out, which icon is usually chosen for a certain mime type. Since no URL is passed, it is impossible to obey icon hints in desktop entries for example.

Parameters:
group - The icon group where the icon is going to be used.
force_size - Override globallly configured icon size. Use 0 for the default size
state - The icon state, one of: KIcon.DefaultState, KIcon.ActiveState or KIcon.DisabledState.
path - Output parameter to get the full path. Seldom needed. Ignored if 0
Returns:
the pixmap of the mime type, can be a default icon if not found

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)

pixmap

public org.kde.qt.QPixmap pixmap(KURL _url,
                                 int _group,
                                 int _force_size,
                                 int _state,
                                 java.lang.StringBuffer _path)
Find the pixmap for a given file of this mimetype. Convenience method that uses icon(), but also locates and load the pixmap.

Parameters:
_url - URL for the file.
_group - The icon group where the icon is going to be used.
_force_size - Override globallly configured icon size. Use 0 for the default size
_state - The icon state, one of: KIcon.DefaultState, KIcon.ActiveState or KIcon.DisabledState.
_path - Output parameter to get the full path. Seldom needed. Ignored if 0
Returns:
the pixmap of the URL, can be a default icon if not found

pixmap

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

pixmap

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

pixmap

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

comment

public java.lang.String comment()
Returns the descriptive comment associated with the MIME type.

Overrides:
comment in class KServiceType
Returns:
the descriptive comment associated with the MIME type

comment

public java.lang.String comment(java.lang.String arg1,
                                boolean arg2)
Returns the descriptive comment associated with the MIME type. The arguments are unused, but provided so that KMimeType derived classes can use them.

Returns:
The descriptive comment associated with the MIME type, if any.

comment

public java.lang.String comment(KURL arg1,
                                boolean arg2)
Returns the descriptive comment associated with the MIME type. The arguments are unused, but provided so that KMimeType derived classes can use them.

Returns:
The descriptive comment associated with the MIME type, if any.

patterns

public java.util.ArrayList patterns()
Retrieve the list of patterns associated with the MIME Type.

Returns:
a list of file globs that describe the file names (or, usually, the extensions) of files with this mime type

load

public void load(org.kde.qt.QDataStream qs)
Load the mimetype from a stream.

Overrides:
load in class KServiceType
Parameters:
qs - the stream to load from

save

public void save(org.kde.qt.QDataStream qs)
Save the mimetype to a stream.

Overrides:
save in class KServiceType
Parameters:
qs - the stream to save to

property

public org.kde.qt.QVariant property(java.lang.String _name)
Returns the property with the given _name.

Overrides:
property in class KServiceType
Parameters:
_name - the name of the property
Returns:
the value of the property
See Also:
propertyNames()

propertyNames

public java.util.ArrayList propertyNames()
Retrieves a list of all properties associated with this KMimeType.

Overrides:
propertyNames in class KServiceType
Returns:
a list of all property names
See Also:
property(java.lang.String)

parentMimeType

public java.lang.String parentMimeType()
If this mimetype inherits from ("is also") another mimetype, return the name of the parent. For instance a text/x-log is a special kind of text/plain, so the definition of text/x-log can say "X-KDE-IsAlso=text/plain". Or an smb-workgroup is a special kind of inode/directory, etc. This mechanism can also be used to rename mimetypes and preserve compat. Note that this notion doesn't map to the servicetype inheritance mechanism, since an application that handles the specific type doesn't necessarily handle the base type. The opposite is true though.

Returns:
the parent mime type, or null if not set

is

public boolean is(java.lang.String mimeTypeName)
Do not use name()=="somename" anymore, to check for a given mimetype. For mimetype inheritance to work, use is("somename") instead. Warning, do not use inherits(), that's the servicetype inheritance concept!


pixmapForURL

public static org.kde.qt.QPixmap pixmapForURL(KURL _url,
                                              long _mode,
                                              int _group,
                                              int _force_size,
                                              int _state,
                                              java.lang.StringBuffer _path)
Convenience method to find the pixmap for a URL. Call this one when you don't know the mimetype.

Parameters:
_url - URL for the file.
_mode - the mode of the file. The mode may modify the icon with overlays that show special properties of the icon. Use 0 for default
_group - The icon group where the icon is going to be used.
_force_size - Override globally configured icon size. Use 0 for the default size
_state - The icon state, one of: KIcon.DefaultState, KIcon.ActiveState or KIcon.DisabledState.
_path - Output parameter to get the full path. Seldom needed. Ignored if 0
Returns:
the pixmap of the URL, can be a default icon if not found

pixmapForURL

public static org.kde.qt.QPixmap pixmapForURL(KURL _url,
                                              long _mode,
                                              int _group,
                                              int _force_size,
                                              int _state)

pixmapForURL

public static org.kde.qt.QPixmap pixmapForURL(KURL _url,
                                              long _mode,
                                              int _group,
                                              int _force_size)

pixmapForURL

public static org.kde.qt.QPixmap pixmapForURL(KURL _url,
                                              long _mode,
                                              int _group)

pixmapForURL

public static org.kde.qt.QPixmap pixmapForURL(KURL _url,
                                              long _mode)

pixmapForURL

public static org.kde.qt.QPixmap pixmapForURL(KURL _url)

iconForURL

public static java.lang.String iconForURL(KURL _url,
                                          long _mode)
The same functionality as pixmapForURL(), but this method returns the name of the icon to load. You'll have to use KIconLoader to load the pixmap for it. The advantage of this method is that you can store the result, and then use it later on for any kind of size.

Parameters:
_url - URL for the file
_mode - the mode of the file. The mode may modify the icon with overlays that show special properties of the icon. Use 0 for default
Returns:
the name of the icon. The name of a default icon if there is no icon for the mime type

iconForURL

public static java.lang.String iconForURL(KURL _url)

favIconForURL

public static java.lang.String favIconForURL(KURL url)
Return the "favicon" (see http://www.favicon.com) for the given url, if available. Does NOT attempt to download the favicon, it only returns one that is already available. If unavailable, returns null.

Parameters:
url - the URL of the favicon
Returns:
the name of the favicon, or null

defaultMimeType

public static java.lang.String defaultMimeType()
Returns the name of the default mimetype. Always application/octet-stream, but this method exists for performance purposes.

Returns:
the name of the default mime type, always "application/octet-stream"

loadInternal

protected void loadInternal(org.kde.qt.QDataStream arg1)
Determines the mimetype of file based on it's name and returns the matching pattern if any.


init

protected void init(KDesktopFile arg1)
Description copied from class: KServiceType
Returns a list of all the supported servicetypes. Useful for showing the list of available servicetypes in a listbox, for example. More memory consuming than the ones above, don't use unless really necessary.

Overrides:
init in class KServiceType

patternsAccuracy

protected int patternsAccuracy()

errorMissingMimeType

protected static void errorMissingMimeType(java.lang.String _type)
Signal a missing mime type.

Parameters:
_type - the missinf mime type

buildDefaultType

protected static void buildDefaultType()
This function makes sure that the default mime type exists.


checkEssentialMimeTypes

protected static void checkEssentialMimeTypes()
This function makes sure that vital mime types are installed.


finalize

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

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

dispose

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

Overrides:
dispose in class KServiceType

isDisposed

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

Overrides:
isDisposed in class KServiceType