| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kmimetype.h

    00001 /*  This file is part of the KDE libraries
    00002  *  Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
    00003  *                     David Faure   <faure@kde.org>
    00004  *
    00005  *  This library is free software; you can redistribute it and/or
    00006  *  modify it under the terms of the GNU Library General Public
    00007  *  License version 2 as published by the Free Software Foundation;
    00008  *
    00009  *  This library is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  *  Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this library; see the file COPYING.LIB.  If not, write to
    00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  **/
    00019
    00020 #ifndef __kmimetype_h__
    00021 #define __kmimetype_h__
    00022
    00023 #include <sys/types.h>
    00024 #include <sys/stat.h>
    00025
    00026 #include <qstringlist.h>
    00027 #include <qvaluelist.h>
    00028 #include <qpixmap.h>
    00029 #include <kicontheme.h>
    00030
    00031 #include <kurl.h>
    00032
    00033 #include "ksycocatype.h"
    00034 #include "kservicetype.h"
    00035
    00036 class KSimpleConfig;
    00043 class KMimeType : public KServiceType
    00044 {
    00045   K_SYCOCATYPE( KST_KMimeType, KServiceType )
    00046
    00047 public:
    00048   typedef KSharedPtr<KMimeType> Ptr;
    00049   typedef QValueList<Ptr> List;
    00050 public:
    00057   KMimeType( const QString & _fullpath, const QString& _type, const QString& _icon,
    00058              const QString& _comment, const QStringList& _patterns );
    00059
    00063   KMimeType( const QString & _fullpath );
    00064
    00068   KMimeType( KDesktopFile *config );
    00069
    00075   KMimeType( QDataStream& _str, int offset );
    00076
    00077   virtual ~KMimeType();
    00078
    00087   virtual QString icon( const QString& , bool ) const { return m_strIcon; }
    00088
    00093   virtual QString icon( const KURL& , bool ) const { return m_strIcon; }
    00094
    00109   virtual QPixmap pixmap( KIcon::Group _group, int _force_size = 0, int _state = 0,
    00110                           QString * _path = 0L ) const;
    00111
    00125   virtual QPixmap pixmap( const KURL& _url, KIcon::Group _group, int _force_size = 0,
    00126             int _state = 0, QString * _path = 0L ) const;
    00127
    00140   static QPixmap pixmapForURL( const KURL & _url, mode_t _mode = 0, KIcon::Group _group = KIcon::Desktop,
    00141                                int _force_size = 0, int _state = 0, QString * _path = 0L );
    00142
    00143
    00150   static QString iconForURL( const KURL & _url, mode_t _mode = 0 );
    00151
    00159   static QString favIconForURL( const KURL& url );
    00160
    00164   QString comment() const { return m_strComment; }
    00165
    00172   virtual QString comment( const QString&, bool ) const { return m_strComment; }
    00173
    00178   virtual QString comment( const KURL&, bool ) const { return m_strComment; }
    00179
    00183   const QStringList& patterns() const { return m_lstPatterns; }
    00184
    00188   virtual void load( QDataStream& );
    00189
    00193   virtual void save( QDataStream& );
    00194
    00195   virtual QVariant property( const QString& _name ) const;
    00196   virtual QStringList propertyNames() const;
    00197
    00208   static Ptr mimeType( const QString& _name );
    00209
    00236   static Ptr findByURL( const KURL& _url, mode_t _mode = 0,
    00237                         bool _is_local_file = false, bool _fast_mode = false );
    00243   static Ptr findByPath( const QString& path, mode_t mode = 0, bool fast_mode = false );
    00244
    00253   static Ptr findByContent( const QByteArray &data, int *accuracy=0 );
    00263   static Ptr findByFileContent( const QString &fileName, int *accuracy=0 );
    00264
    00273   static List allMimeTypes();
    00274
    00280   static const QString & defaultMimeType();
    00281
    00282 protected:
    00283   void loadInternal( QDataStream& );
    00284   void init( KDesktopFile * );
    00285
    00289   static void errorMissingMimeType( const QString& _type );
    00290
    00294   static void buildDefaultType();
    00295
    00299   static void checkEssentialMimeTypes();
    00303   static bool s_bChecked;
    00304
    00305   QStringList m_lstPatterns;
    00306
    00307   static Ptr s_pDefaultType;
    00308 protected:
    00309   virtual void virtual_hook( int id, void* data );
    00310 };
    00311
    00316 class KFolderType : public KMimeType
    00317 {
    00318   K_SYCOCATYPE( KST_KFolderType, KMimeType )
    00319
    00320 public:
    00321 //  KFolderType( const QString & _fullpath, const QString& _type, const QString& _icon, const QString& _comment,
    00322 //             const QStringList& _patterns );
    00323 //  KFolderType( const QString & _fullpath ) : KMimeType( _fullpath ) { }
    00324   KFolderType( KDesktopFile *config) : KMimeType( config ) { }
    00325   KFolderType( QDataStream& _str, int offset ) : KMimeType( _str, offset ) { }
    00326
    00327   virtual QString icon( const QString& _url, bool _is_local ) const;
    00328   virtual QString icon( const KURL& _url, bool _is_local ) const;
    00329   virtual QString comment( const QString& _url, bool _is_local ) const;
    00330   virtual QString comment( const KURL& _url, bool _is_local ) const;
    00331 protected:
    00332   virtual void virtual_hook( int id, void* data );
    00333 };
    00334
    00339 class KDEDesktopMimeType : public KMimeType
    00340 {
    00341   K_SYCOCATYPE( KST_KDEDesktopMimeType, KMimeType )
    00342
    00343 public:
    00344   enum ServiceType { ST_MOUNT, ST_UNMOUNT, /* ST_PROPERTIES, */ ST_USER_DEFINED };
    00345
    00350   struct Service
    00351   {
    00352     Service() { m_display = true; }
    00353     QString m_strName;
    00354     QString m_strIcon;
    00355     QString m_strExec;
    00356     ServiceType m_type;
    00357     bool m_display;
    00358   };
    00359   // KDEDesktopMimeType( const QString & _fullpath, const QString& _type, const QString& _icon,
    00360   //                     const QString& _comment, const QStringList& _patterns );
    00361   // KDEDesktopMimeType( const QString & _fullpath ) : KMimeType( _fullpath ) { }
    00362   KDEDesktopMimeType( KDesktopFile *config) : KMimeType( config ) { }
    00363   KDEDesktopMimeType( QDataStream& _str, int offset ) : KMimeType( _str, offset ) { }
    00364
    00365   virtual QString icon( const QString& _url, bool _is_local ) const;
    00366   virtual QString icon( const KURL& _url, bool _is_local ) const;
    00367   virtual QPixmap pixmap( const KURL& _url, KIcon::Group _group, int _force_size = 0,
    00368                           int _state = 0, QString * _path = 0L ) const;
    00369   virtual QString comment( const QString& _url, bool _is_local ) const;
    00370   virtual QString comment( const KURL& _url, bool _is_local ) const;
    00371
    00376   static QValueList<Service> builtinServices( const KURL& _url );
    00384   static QValueList<Service> userDefinedServices( const QString& path, bool bLocalFiles );
    00385
    00390   static void executeService( const QString& _path, KDEDesktopMimeType::Service& _service );
    00391
    00395   static void executeService( const KURL::List& urls, KDEDesktopMimeType::Service& service );
    00396
    00408   static pid_t run( const KURL& _url, bool _is_local );
    00409
    00410 protected:
    00411   virtual QPixmap pixmap(KIcon::Group a, int b, int c, QString *d) const
    00412      { return KMimeType::pixmap(a, b, c, d); }
    00413
    00414   static pid_t runFSDevice( const KURL& _url, const KSimpleConfig &cfg );
    00415   static pid_t runApplication( const KURL& _url, const QString & _serviceFile );
    00416   static pid_t runLink( const KURL& _url, const KSimpleConfig &cfg );
    00417   static pid_t runMimeType( const KURL& _url, const KSimpleConfig &cfg );
    00418 protected:
    00419   virtual void virtual_hook( int id, void* data );
    00420 };
    00421
    00425 class KExecMimeType : public KMimeType
    00426 {
    00427   K_SYCOCATYPE( KST_KExecMimeType, KMimeType )
    00428
    00429 public:
    00430   // KExecMimeType( const QString & _fullpath, const QString& _type, const QString& _icon,
    00431   //                 const QString& _comment, const QStringList& _patterns );
    00432   // KExecMimeType( const QString & _fullpath ) : KMimeType( _fullpath ) { }
    00433   KExecMimeType( KDesktopFile *config) : KMimeType( config ) { }
    00434   KExecMimeType( QDataStream& _str, int offset ) : KMimeType( _str, offset ) { }
    00435 protected:
    00436   virtual void virtual_hook( int id, void* data );
    00437 };
    00438
    00439 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:13:43 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001