kmimetype.h
/* This file is part of the KDE libraries
* Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
* David Faure <faure@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation;
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
**/
#ifndef __kmimetype_h__
#define __kmimetype_h__
#include <sys/types.h>
#include <sys/stat.h>
#include <qstringlist.h>
#include <qvaluelist.h>
#include <qpixmap.h>
#include <kicontheme.h>
#include <kurl.h>
#include <ksycocatype.h>
#include <kservicetype.h>
class KSimpleConfig;
class KIO_EXPORT KMimeType : public KServiceType
{
K_SYCOCATYPE( KST_KMimeType, KServiceType )
public:
typedef KSharedPtr<KMimeType> Ptr;
typedef QValueList<Ptr> List;
public:
KMimeType( const QString & _fullpath, const QString& _type, const QString& _icon,
const QString& _comment, const QStringList& _patterns );
KMimeType( const QString & _fullpath );
KMimeType( KDesktopFile *config );
KMimeType( QDataStream& _str, int offset );
virtual ~KMimeType();
virtual QString icon( const QString& , bool ) const { return m_strIcon; }
virtual QString icon( const KURL& , bool ) const { return m_strIcon; }
virtual QPixmap pixmap( KIcon::Group group, int force_size = 0, int state = 0,
QString * path = 0L ) const;
virtual QPixmap pixmap( const KURL& _url, KIcon::Group _group, int _force_size = 0,
int _state = 0, QString * _path = 0L ) const;
static QPixmap pixmapForURL( const KURL & _url, mode_t _mode = 0, KIcon::Group _group = KIcon::Desktop,
int _force_size = 0, int _state = 0, QString * _path = 0L );
static QString iconForURL( const KURL & _url, mode_t _mode = 0 );
static QString favIconForURL( const KURL& url );
QString comment() const { return m_strComment; }
virtual QString comment( const QString&, bool ) const { return m_strComment; }
virtual QString comment( const KURL&, bool ) const { return m_strComment; }
const QStringList& patterns() const { return m_lstPatterns; }
virtual void load( QDataStream &qs );
virtual void save( QDataStream &qs );
virtual QVariant property( const QString& _name ) const;
virtual QStringList propertyNames() const;
static Ptr mimeType( const QString& _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 QString& path, mode_t mode = 0, bool fast_mode = false );
static Ptr findByContent( const QByteArray &data, int *accuracy=0 );
static Ptr findByFileContent( const QString &fileName, int *accuracy=0 );
struct Format{
bool text : 1;
enum { NoCompression=0, GZipCompression } compression : 4;
unsigned dummy : 27;
};
static Format findFormatByFileContent( const QString &fileName );
static List allMimeTypes();
static const QString & defaultMimeType();
static KMimeType::Ptr defaultMimeTypePtr();
QString parentMimeType() const;
bool is( const QString& mimeTypeName ) const;
static KMimeType::Ptr diagnoseFileName(const QString &file, QString &pattern);
protected:
void loadInternal( QDataStream& );
void init( KDesktopFile * );
static void errorMissingMimeType( const QString& _type );
static void buildDefaultType();
static void checkEssentialMimeTypes();
static bool s_bChecked;
QStringList m_lstPatterns;
static Ptr s_pDefaultType;
protected:
friend class KServiceTypeFactory;
int patternsAccuracy() const;
protected:
virtual void virtual_hook( int id, void* data );
};
class KIO_EXPORT KFolderType : public KMimeType
{
K_SYCOCATYPE( KST_KFolderType, KMimeType )
public:
// KFolderType( const QString & _fullpath, const QString& _type, const QString& _icon, const QString& _comment,
// const QStringList& _patterns );
// KFolderType( const QString & _fullpath ) : KMimeType( _fullpath ) { }
KFolderType( KDesktopFile *config) : KMimeType( config ) { }
KFolderType( QDataStream& _str, int offset ) : KMimeType( _str, offset ) { }
virtual QString icon( const QString& _url, bool _is_local ) const;
virtual QString icon( const KURL& _url, bool _is_local ) const;
virtual QString comment( const QString& _url, bool _is_local ) const;
virtual QString comment( const KURL& _url, bool _is_local ) const;
protected:
virtual void virtual_hook( int id, void* data );
};
class KIO_EXPORT KDEDesktopMimeType : public KMimeType
{
K_SYCOCATYPE( KST_KDEDesktopMimeType, KMimeType )
public:
enum ServiceType { ST_MOUNT, ST_UNMOUNT, /* ST_PROPERTIES, */ ST_USER_DEFINED };
struct Service
{
Service() { m_display = true; }
bool isEmpty() const { return m_strName.isEmpty(); }
QString m_strName;
QString m_strIcon;
QString m_strExec;
ServiceType m_type;
bool m_display;
};
// KDEDesktopMimeType( const QString & _fullpath, const QString& _type, const QString& _icon,
// const QString& _comment, const QStringList& _patterns );
// KDEDesktopMimeType( const QString & _fullpath ) : KMimeType( _fullpath ) { }
KDEDesktopMimeType( KDesktopFile *config) : KMimeType( config ) { }
KDEDesktopMimeType( QDataStream& _str, int offset ) : KMimeType( _str, offset ) { }
virtual QString icon( const QString& _url, bool _is_local ) const;
virtual QString icon( const KURL& _url, bool _is_local ) const;
virtual QPixmap pixmap( const KURL& _url, KIcon::Group _group, int _force_size = 0,
int _state = 0, QString * _path = 0L ) const;
virtual QString comment( const QString& _url, bool _is_local ) const;
virtual QString comment( const KURL& _url, bool _is_local ) const;
static QValueList<Service> builtinServices( const KURL& _url );
static QValueList<Service> userDefinedServices( const QString& path, bool bLocalFiles );
static QValueList<Service> userDefinedServices( const QString& path, KConfig& config, bool bLocalFiles );
static QValueList<Service> userDefinedServices( const QString& path, KConfig& config, bool bLocalFiles, const KURL::List & file_list);
static void executeService( const QString& path, KDEDesktopMimeType::Service& service ) KDE_DEPRECATED;
static void executeService( const KURL::List& urls, KDEDesktopMimeType::Service& service );
static pid_t run( const KURL& _url, bool _is_local );
protected:
virtual QPixmap pixmap( KIcon::Group group, int force_size = 0, int state = 0,
QString * path = 0L ) const
{ return KMimeType::pixmap( group, force_size, state, path ); }
static pid_t runFSDevice( const KURL& _url, const KSimpleConfig &cfg );
static pid_t runApplication( const KURL& _url, const QString & _serviceFile );
static pid_t runLink( const KURL& _url, const KSimpleConfig &cfg );
static pid_t runMimeType( const KURL& _url, const KSimpleConfig &cfg );
protected:
virtual void virtual_hook( int id, void* data );
};
class KIO_EXPORT KExecMimeType : public KMimeType
{
K_SYCOCATYPE( KST_KExecMimeType, KMimeType )
public:
// KExecMimeType( const QString & _fullpath, const QString& _type, const QString& _icon,
// const QString& _comment, const QStringList& _patterns );
// KExecMimeType( const QString & _fullpath ) : KMimeType( _fullpath ) { }
KExecMimeType( KDesktopFile *config) : KMimeType( config ) { }
KExecMimeType( QDataStream& _str, int offset ) : KMimeType( _str, offset ) { }
protected:
virtual void virtual_hook( int id, void* data );
};
#endif
KMimeType::s_bChecked
static bool s_bChecked
true if check for vital mime types has been done.
Definition: kmimetype.h:459
KServiceType::icon
QString icon() const
Returns the icon associated with this service type.
Definition: kservicetype.h:94
KMimeType::patterns
const QStringList & patterns() const
Retrieve the list of patterns associated with the MIME Type.
Definition: kmimetype.h:227
KDEDesktopMimeType::pixmap
virtual QPixmap pixmap(KIcon::Group group, int force_size=0, int state=0, QString *path=0L) const
Use this function only if you don't have a special URL for which you search a pixmap.
Definition: kmimetype.h:606
KServiceType::property
virtual QVariant property(const QString &_name) const
Returns the requested property.
Definition: kservicetype.cpp:174
KMimeType
Represent a mime type, like "text/plain", and the data that is associated with it.
Definition: kmimetype.h:47
KMimeType::icon
virtual QString icon(const KURL &, bool) const
Return the filename of the icon associated with the mimetype.
Definition: kmimetype.h:110
KExecMimeType::KExecMimeType
KExecMimeType(KDesktopFile *config)
Construct a executable mimetype and take all information from a desktop file.
Definition: kmimetype.h:634
KServiceType
A service type is the generic notion for a mimetype, a type of service instead of a type of file...
Definition: kservicetype.h:45
KMimeType::comment
QString comment() const
Returns the descriptive comment associated with the MIME type.
Definition: kmimetype.h:202
KFolderType::KFolderType
KFolderType(KDesktopFile *config)
Construct a folder mimetype and take all information from a desktop file.
Definition: kmimetype.h:489
KMimeType::comment
virtual QString comment(const KURL &, bool) const
Returns the descriptive comment associated with the MIME type.
Definition: kmimetype.h:220
KDEDesktopMimeType
Mime type for desktop files.
Definition: kmimetype.h:506
KFolderType
Folder mime type.
Definition: kmimetype.h:477
KDEDesktopMimeType::KDEDesktopMimeType
KDEDesktopMimeType(KDesktopFile *config)
Construct a desktop mimetype and take all information from a desktop file.
Definition: kmimetype.h:534
KMimeType::comment
virtual QString comment(const QString &, bool) const
Returns the descriptive comment associated with the MIME type.
Definition: kmimetype.h:211
KServiceType::propertyNames
virtual QStringList propertyNames() const
Returns the list of all properties of this service type.
Definition: kservicetype.cpp:194
KMimeType::icon
virtual QString icon(const QString &, bool) const
Return the filename of the icon associated with the mimetype.
Definition: kmimetype.h:100
KExecMimeType
The mime type for executable files.
Definition: kmimetype.h:622
KDEDesktopMimeType::Service
Structure representing a service, in the list of services returned by builtinServices and userDefined...
Definition: kmimetype.h:517
KMimeType::pixmap
virtual QPixmap pixmap(KIcon::Group group, int force_size=0, int state=0, QString *path=0L) const
Use this function only if you don't have a special URL for which you search a pixmap.
Definition: kmimetype.cpp:453

KDE Home | KDE Accessibility Home | Description of Access Keys