• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
KMimeType Class Reference

#include <kmimetype.h>

Inheritance diagram for KMimeType:
KServiceType KDEDesktopMimeType KExecMimeType KFolderType

Public Types

typedef TDESharedPtr< KMimeType > Ptr
 
typedef TQValueList< Ptr > List
 
- Public Types inherited from KServiceType
typedef TDESharedPtr< KServiceType > Ptr
 
typedef TQValueList< Ptr > List
 

Public Member Functions

 KMimeType (const TQString &_fullpath, const TQString &_type, const TQString &_icon, const TQString &_comment, const TQStringList &_patterns)
 
 KMimeType (const TQString &_fullpath)
 
 KMimeType (KDesktopFile *config)
 
 KMimeType (TQDataStream &_str, int offset)
 
virtual TQString icon (const TQString &, bool) const
 
virtual TQString icon (const KURL &, bool) const
 
virtual TQPixmap pixmap (TDEIcon::Group group, int force_size=0, int state=0, TQString *path=0L) const
 
virtual TQPixmap pixmap (const KURL &_url, TDEIcon::Group _group, int _force_size=0, int _state=0, TQString *_path=0L) const
 
TQString comment () const
 
virtual TQString comment (const TQString &, bool) const
 
virtual TQString comment (const KURL &, bool) const
 
const TQStringList & patterns () const
 
virtual void load (TQDataStream &qs)
 
virtual void save (TQDataStream &qs)
 
virtual TQVariant property (const TQString &_name) const
 
virtual TQStringList propertyNames () const
 
TQString parentMimeType () const
 
bool is (const TQString &mimeTypeName) const
 
- Public Member Functions inherited from KServiceType
 KServiceType (const TQString &_fullpath, const TQString &_name, const TQString &_icon, const TQString &_comment)
 
 KServiceType (const TQString &_fullpath)
 
 KServiceType (KDesktopFile *config)
 
 KServiceType (TQDataStream &_str, int offset)
 
TQString icon () const
 
TQString comment () const
 
TQString name () const
 
TQString desktopEntryPath () const
 
bool isDerived () const
 
TQString parentServiceType () const
 
bool inherits (const TQString &servTypeName) const
 
virtual TQVariant property (const TQString &_name) const
 
virtual TQStringList propertyNames () const
 
bool isValid () const
 
virtual TQVariant::Type propertyDef (const TQString &_name) const
 
virtual TQStringList propertyDefNames () const
 
virtual const TQMap< TQString, TQVariant::Type > & propertyDefs () const
 
virtual void save (TQDataStream &)
 
virtual void load (TQDataStream &)
 
Ptr parentType ()
 
void addService (KService::Ptr service)
 
KService::List services ()
 

Static Public Member Functions

static TQPixmap pixmapForURL (const KURL &_url, mode_t _mode=0, TDEIcon::Group _group=TDEIcon::Desktop, int _force_size=0, int _state=0, TQString *_path=0L)
 
static TQString iconForURL (const KURL &_url, mode_t _mode=0)
 
static TQString favIconForURL (const KURL &url)
 
static Ptr mimeType (const TQString &_name)
 
static Ptr findByURL (const KURL &_url, mode_t _mode=0, bool _is_local_file=false, bool _fast_mode=false)
 
static Ptr findByURL (const KURL &_url, mode_t _mode, bool _is_local_file, bool _fast_mode, bool *accurate)
 
static Ptr findByPath (const TQString &path, mode_t mode=0, bool fast_mode=false)
 
static Ptr findByContent (const TQByteArray &data, int *accuracy=0)
 
static Ptr findByFileContent (const TQString &fileName, int *accuracy=0)
 
static Format findFormatByFileContent (const TQString &fileName)
 
static List allMimeTypes ()
 
static const TQString & defaultMimeType ()
 
static KMimeType::Ptr defaultMimeTypePtr ()
 
static KMimeType::Ptr diagnoseFileName (const TQString &file, TQString &pattern)
 
- Static Public Member Functions inherited from KServiceType
static Ptr serviceType (const TQString &_name)
 
static KService::List offers (const TQString &_servicetype)
 
static List allServiceTypes ()
 

Protected Member Functions

void loadInternal (TQDataStream &)
 
void init (KDesktopFile *)
 
int patternsAccuracy () const
 
virtual void virtual_hook (int id, void *data)
 
- Protected Member Functions inherited from KServiceType
void init (KDesktopFile *config)
 
virtual void virtual_hook (int id, void *data)
 

Static Protected Member Functions

static void errorMissingMimeType (const TQString &_type)
 
static void buildDefaultType ()
 
static void checkEssentialMimeTypes ()
 

Protected Attributes

TQStringList m_lstPatterns
 
- Protected Attributes inherited from KServiceType
TQString m_strName
 
TQString m_strIcon
 
TQString m_strComment
 
TQStringVariantMap m_mapProps
 
TQMap< TQString, TQVariant::Type > m_mapPropDefs
 
bool m_bValid:1
 
bool m_bDerived:1
 

Static Protected Attributes

static bool s_bChecked = false
 
static Ptr s_pDefaultType = 0L
 

Friends

class KServiceTypeFactory
 

Detailed Description

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

Definition at line 47 of file kmimetype.h.

Member Typedef Documentation

◆ List

typedef TQValueList<Ptr> KMimeType::List

Definition at line 53 of file kmimetype.h.

◆ Ptr

typedef TDESharedPtr<KMimeType> KMimeType::Ptr

Definition at line 52 of file kmimetype.h.

Constructor & Destructor Documentation

◆ KMimeType() [1/4]

KMimeType::KMimeType ( const TQString &  _fullpath,
const TQString &  _type,
const TQString &  _icon,
const TQString &  _comment,
const TQStringList &  _patterns 
)

Constructor.

You may pass in arguments to create a mimetype with specific properties.

Parameters
_fullpaththe path to the configuration file (.desktop)
_typethe mime type itself
_iconthe name of the icon that represens the mime type
_commenta comment describing the mime type
_patternsa list of file globs that describes the names (or extensions) of the files with this mime type

Definition at line 359 of file kmimetype.cpp.

◆ KMimeType() [2/4]

KMimeType::KMimeType ( const TQString &  _fullpath)

Construct a mimetype and take all information from a config file.

Parameters
_fullpaththe path to the configuration file (.desktop)

Definition at line 366 of file kmimetype.cpp.

◆ KMimeType() [3/4]

KMimeType::KMimeType ( KDesktopFile *  config)

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

Parameters
configthe desktop configuration file that describes the mime type

Definition at line 375 of file kmimetype.cpp.

◆ KMimeType() [4/4]

KMimeType::KMimeType ( TQDataStream &  _str,
int  offset 
)

Definition at line 412 of file kmimetype.cpp.

◆ ~KMimeType()

KMimeType::~KMimeType ( )
virtual

Definition at line 453 of file kmimetype.cpp.

Member Function Documentation

◆ allMimeTypes()

KMimeType::List KMimeType::allMimeTypes ( )
static

Get all the mimetypes.

Useful for showing the list of available mimetypes. More memory consuming than the ones above, don't use unless really necessary.

Returns
the list of all existing KMimeTypes

Definition at line 160 of file kmimetype.cpp.

◆ buildDefaultType()

void KMimeType::buildDefaultType ( )
staticprotected

This function makes sure that the default mime type exists.

Definition at line 68 of file kmimetype.cpp.

◆ checkEssentialMimeTypes()

void KMimeType::checkEssentialMimeTypes ( )
staticprotected

This function makes sure that vital mime types are installed.

Definition at line 97 of file kmimetype.cpp.

◆ comment() [1/3]

TQString KMimeType::comment ( ) const
inline

Returns the descriptive comment associated with the MIME type.

Returns
the descriptive comment associated with the MIME type

Definition at line 202 of file kmimetype.h.

◆ comment() [2/3]

virtual TQString KMimeType::comment ( const KURL &  ,
bool   
) const
inlinevirtual

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.

Reimplemented in KFolderType, and KDEDesktopMimeType.

Definition at line 220 of file kmimetype.h.

◆ comment() [3/3]

virtual TQString KMimeType::comment ( const TQString &  ,
bool   
) const
inlinevirtual

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.

Reimplemented in KFolderType, and KDEDesktopMimeType.

Definition at line 211 of file kmimetype.h.

◆ defaultMimeType()

const TQString & KMimeType::defaultMimeType ( )
static

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"

Definition at line 1160 of file kmimetype.cpp.

◆ defaultMimeTypePtr()

KMimeType::Ptr KMimeType::defaultMimeTypePtr ( )
static

Returns the default mimetype.

Always application/octet-stream. This can be used to check the result of mimeType(name).

Returns
the "application/octet-stream" mimetype pointer.
Since
3.2

Definition at line 89 of file kmimetype.cpp.

◆ diagnoseFileName()

KMimeType::Ptr KMimeType::diagnoseFileName ( const TQString &  file,
TQString &  pattern 
)
static

Definition at line 303 of file kmimetype.cpp.

◆ errorMissingMimeType()

void KMimeType::errorMissingMimeType ( const TQString &  _type)
staticprotected

Signal a missing mime type.

Parameters
_typethe missinf mime type

Definition at line 134 of file kmimetype.cpp.

◆ favIconForURL()

TQString KMimeType::favIconForURL ( const KURL &  url)
static

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 TQString::null.

Parameters
urlthe URL of the favicon
Returns
the name of the favicon, or TQString::null

Definition at line 536 of file kmimetype.cpp.

◆ findByContent()

KMimeType::Ptr KMimeType::findByContent ( const TQByteArray &  data,
int *  accuracy = 0 
)
static

Tries to find out the MIME type of a data chunk by looking for certain magic numbers and characteristic strings in it.

Parameters
datathe data to examine
accuracyIf not a null pointer, *accuracy is set to the accuracy of the match (which is in the range 0..100)
Returns
a pointer to the KMimeType. application/octet-stream's KMimeType of the type can not be found this way.

Definition at line 315 of file kmimetype.cpp.

◆ findByFileContent()

KMimeType::Ptr KMimeType::findByFileContent ( const TQString &  fileName,
int *  accuracy = 0 
)
static

Tries to find out the MIME type of a file by looking for certain magic numbers and characteristic strings in it.

This function is similar to the previous one. Note that the file name is not used for determining the file type, it is just used for loading the file's contents.

Parameters
fileNamethe path to the file
accuracyIf not a null pointer, *accuracy is set to the accuracy of the match (which is in the range 0..100)
Returns
a pointer to the KMimeType. application/octet-stream's KMimeType of the type can not be found this way.

Definition at line 323 of file kmimetype.cpp.

◆ findByPath()

KMimeType::Ptr KMimeType::findByPath ( const TQString &  path,
mode_t  mode = 0,
bool  fast_mode = false 
)
static

Finds a KMimeType with the given _url.

This function looks at mode_t first. If that does not help it looks at the extension. This is fine for FTP, FILE, TAR and friends, but is not for HTTP ( cgi scripts! ). You should use KRun instead, but this function returns immediately while KRun is async. If no extension matches, then the file will be examined if the URL a local file or "application/octet-stream" is returned otherwise.

Equivalent to

KURL u;
u.setPath(path);
return findByURL( u, mode, true, fast_mode );
KMimeType::findByURL
static Ptr findByURL(const KURL &_url, mode_t _mode=0, bool _is_local_file=false, bool _fast_mode=false)
Finds a KMimeType with the given _url.
Definition: kmimetype.cpp:165
Parameters
paththe path to the file
modethe mode of the file (used, for example, to identify executables)
fast_modeIf set to true no disk access is allowed to find out the mimetype. The result may be suboptimal, but it is fast.
Returns
A pointer to the matching mimetype. 0L is never returned.

Definition at line 308 of file kmimetype.cpp.

◆ findByURL() [1/2]

KMimeType::Ptr KMimeType::findByURL ( const KURL &  _url,
mode_t  _mode,
bool  _is_local_file,
bool  _fast_mode,
bool *  accurate 
)
static

Definition at line 294 of file kmimetype.cpp.

◆ findByURL() [2/2]

KMimeType::Ptr KMimeType::findByURL ( const KURL &  _url,
mode_t  _mode = 0,
bool  _is_local_file = false,
bool  _fast_mode = false 
)
static

Finds a KMimeType with the given _url.

This function looks at mode_t first. If that does not help it looks at the extension. This is fine for FTP, FILE, TAR and friends, but is not for HTTP ( cgi scripts! ). You should use KRun instead, but this function returns immediately while KRun is async. If no extension matches, then the file will be examined if the URL a local file or "application/octet-stream" is returned otherwise.

Parameters
_urlIs the right most URL with a filesystem protocol. It is up to you to find out about that if you have a nested URL. For example "http://localhost/mist.gz#gzip:/decompress" would have to pass the "http://..." URL part, while "file:/tmp/x.tar#tar:/src/test.gz#gzip:/decompress" would have to pass the "tar:/..." part of the URL, since gzip is a filter protocol and not a filesystem protocol.
_modethe mode of the file (used, for example, to identify executables)
_is_local_filetrue if the file is local
_fast_modeIf set to true no disk access is allowed to find out the mimetype. The result may be suboptimal, but it is fast.
Returns
A pointer to the matching mimetype. 0L is never returned. Very Important: Don't store the result in a KMimeType* !

Definition at line 165 of file kmimetype.cpp.

◆ findFormatByFileContent()

KMimeType::Format KMimeType::findFormatByFileContent ( const TQString &  fileName)
static

Returns whether a file has an internal format that is human readable, or that would be human readable after decompression.

Since
3.2

Definition at line 334 of file kmimetype.cpp.

◆ icon() [1/2]

virtual TQString KMimeType::icon ( const KURL &  ,
bool   
) const
inlinevirtual

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.

Reimplemented in KFolderType, and KDEDesktopMimeType.

Definition at line 110 of file kmimetype.h.

◆ icon() [2/2]

virtual TQString KMimeType::icon ( const TQString &  ,
bool   
) const
inlinevirtual

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.

Reimplemented in KFolderType, and KDEDesktopMimeType.

Definition at line 100 of file kmimetype.h.

◆ iconForURL()

TQString KMimeType::iconForURL ( const KURL &  _url,
mode_t  _mode = 0 
)
static

The same functionality as pixmapForURL(), but this method returns the name of the icon to load.

You'll have to use TDEIconLoader 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
_urlURL for the file
_modethe 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

Definition at line 507 of file kmimetype.cpp.

◆ init()

void KMimeType::init ( KDesktopFile *  config)
protected

Definition at line 383 of file kmimetype.cpp.

◆ is()

bool KMimeType::is ( const TQString &  mimeTypeName) const

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!

Since
3.2

Definition at line 567 of file kmimetype.cpp.

◆ load()

void KMimeType::load ( TQDataStream &  qs)
virtual

Load the mimetype from a stream.

Parameters
qsthe stream to load from

Reimplemented from KServiceType.

Definition at line 417 of file kmimetype.cpp.

◆ loadInternal()

void KMimeType::loadInternal ( TQDataStream &  _str)
protected

Definition at line 423 of file kmimetype.cpp.

◆ mimeType()

KMimeType::Ptr KMimeType::mimeType ( const TQString &  _name)
static

Retrieve a pointer to the mime type _name or a pointer to the default mime type "application/octet-stream".

0L is never returned.

Very important: Don't store the result in a KMimeType* !

Parameters
_namethe name of the mime type
Returns
the pointer to the KMimeType with the given _name, or a pointer to the application/octet-stream KMimeType if not found
See also
KServiceType::serviceType

Definition at line 141 of file kmimetype.cpp.

◆ parentMimeType()

TQString KMimeType::parentMimeType ( ) const

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-TDE-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 TQString::null if not set
Since
3.2

Definition at line 561 of file kmimetype.cpp.

◆ patterns()

const TQStringList & KMimeType::patterns ( ) const
inline

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

Definition at line 227 of file kmimetype.h.

◆ patternsAccuracy()

int KMimeType::patternsAccuracy ( ) const
protected

Definition at line 585 of file kmimetype.cpp.

◆ pixmap() [1/2]

TQPixmap KMimeType::pixmap ( const KURL &  _url,
TDEIcon::Group  _group,
int  _force_size = 0,
int  _state = 0,
TQString *  _path = 0L 
) const
virtual

Find the pixmap for a given file of this mimetype.

Convenience method that uses icon(), but also locates and load the pixmap.

Parameters
_urlURL for the file.
_groupThe icon group where the icon is going to be used.
_force_sizeOverride globallly configured icon size. Use 0 for the default size
_stateThe icon state, one of: TDEIcon::DefaultState, TDEIcon::ActiveState or TDEIcon::DisabledState.
_pathOutput 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

Reimplemented in KDEDesktopMimeType.

Definition at line 473 of file kmimetype.cpp.

◆ pixmap() [2/2]

TQPixmap KMimeType::pixmap ( TDEIcon::Group  group,
int  force_size = 0,
int  state = 0,
TQString *  path = 0L 
) const
virtual

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
groupThe icon group where the icon is going to be used.
force_sizeOverride globallly configured icon size. Use 0 for the default size
stateThe icon state, one of: TDEIcon::DefaultState, TDEIcon::ActiveState or TDEIcon::DisabledState.
pathOutput 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

Reimplemented in KDEDesktopMimeType.

Definition at line 457 of file kmimetype.cpp.

◆ pixmapForURL()

TQPixmap KMimeType::pixmapForURL ( const KURL &  _url,
mode_t  _mode = 0,
TDEIcon::Group  _group = TDEIcon::Desktop,
int  _force_size = 0,
int  _state = 0,
TQString *  _path = 0L 
)
static

Convenience method to find the pixmap for a URL.

Call this one when you don't know the mimetype.

Parameters
_urlURL for the file.
_modethe mode of the file. The mode may modify the icon with overlays that show special properties of the icon. Use 0 for default
_groupThe icon group where the icon is going to be used.
_force_sizeOverride globally configured icon size. Use 0 for the default size
_stateThe icon state, one of: TDEIcon::DefaultState, TDEIcon::ActiveState or TDEIcon::DisabledState.
_pathOutput 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

Definition at line 489 of file kmimetype.cpp.

◆ property()

TQVariant KMimeType::property ( const TQString &  _name) const
virtual

Returns the property with the given _name.

Parameters
_namethe name of the property
Returns
the value of the property
See also
propertyNames()

Reimplemented from KServiceType.

Definition at line 437 of file kmimetype.cpp.

◆ propertyNames()

TQStringList KMimeType::propertyNames ( ) const
virtual

Retrieves a list of all properties associated with this KMimeType.

Returns
a list of all property names
See also
property()

Reimplemented from KServiceType.

Definition at line 445 of file kmimetype.cpp.

◆ save()

void KMimeType::save ( TQDataStream &  qs)
virtual

Save the mimetype to a stream.

Parameters
qsthe stream to save to

Reimplemented from KServiceType.

Definition at line 429 of file kmimetype.cpp.

◆ virtual_hook()

void KMimeType::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

Reimplemented from KServiceType.

Definition at line 1167 of file kmimetype.cpp.

Friends And Related Function Documentation

◆ KServiceTypeFactory

friend class KServiceTypeFactory
friend

Definition at line 466 of file kmimetype.h.

Member Data Documentation

◆ m_lstPatterns

TQStringList KMimeType::m_lstPatterns
protected

Definition at line 461 of file kmimetype.h.

◆ s_bChecked

bool KMimeType::s_bChecked = false
staticprotected

true if check for vital mime types has been done.

Definition at line 459 of file kmimetype.h.

◆ s_pDefaultType

KMimeType::Ptr KMimeType::s_pDefaultType = 0L
staticprotected

Definition at line 463 of file kmimetype.h.


The documentation for this class was generated from the following files:
  • kmimetype.h
  • kmimetype.cpp

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.9.4
This website is maintained by Timothy Pearson.