kio Library: kmimetype.h Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | 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
    00030 #include <kicontheme.h>
    00031 #include <kurl.h>
    00032 #include <ksycocatype.h>
    00033 #include <kservicetype.h>
    00034
    00035 class KSimpleConfig;
    00047 class KIO_EXPORT KMimeType : public KServiceType
    00048 {
    00049   K_SYCOCATYPE( KST_KMimeType, KServiceType )
    00050
    00051 public:
    00052   typedef KSharedPtr<KMimeType> Ptr;
    00053   typedef QValueList<Ptr> List;
    00054 public:
    00068   KMimeType( const QString & _fullpath, const QString& _type, const QString& _icon,
    00069          const QString& _comment, const QStringList& _patterns );
    00070
    00075   KMimeType( const QString & _fullpath );
    00076
    00081   KMimeType( KDesktopFile *config );
    00082
    00088   KMimeType( QDataStream& _str, int offset );
    00089
    00090   virtual ~KMimeType();
    00091
    00100   virtual QString icon( const QString& , bool ) const { return m_strIcon; }
    00101
    00110   virtual QString icon( const KURL& , bool ) const { return m_strIcon; }
    00111
    00129   virtual QPixmap pixmap( KIcon::Group group, int force_size = 0, int state = 0,
    00130                           QString * path = 0L ) const;
    00131
    00148   virtual QPixmap pixmap( const KURL& _url, KIcon::Group _group, int _force_size = 0,
    00149         int _state = 0, QString * _path = 0L ) const;
    00150
    00169   static QPixmap pixmapForURL( const KURL & _url, mode_t _mode = 0, KIcon::Group _group = KIcon::Desktop,
    00170                                int _force_size = 0, int _state = 0, QString * _path = 0L );
    00171
    00172
    00185   static QString iconForURL( const KURL & _url, mode_t _mode = 0 );
    00186
    00196   static QString favIconForURL( const KURL& url );
    00197
    00202   QString comment() const { return m_strComment; }
    00203
    00211   virtual QString comment( const QString&, bool ) const { return m_strComment; }
    00212
    00220   virtual QString comment( const KURL&, bool ) const { return m_strComment; }
    00221
    00227   const QStringList& patterns() const { return m_lstPatterns; }
    00228
    00233   virtual void load( QDataStream &qs );
    00234
    00239   virtual void save( QDataStream &qs );
    00240
    00247   virtual QVariant property( const QString& _name ) const;
    00248
    00255   virtual QStringList propertyNames() const;
    00256
    00271   static Ptr mimeType( const QString& _name );
    00272
    00301   static Ptr findByURL( const KURL& _url, mode_t _mode = 0,
    00302                         bool _is_local_file = false, bool _fast_mode = false );
    00303
    00304   static Ptr findByURL( const KURL& _url, mode_t _mode,
    00305                         bool _is_local_file, bool _fast_mode,
    00306             bool *accurate);
    00333   static Ptr findByPath( const QString& path, mode_t mode = 0, bool fast_mode = false );
    00334
    00345   static Ptr findByContent( const QByteArray &data, int *accuracy=0 );
    00346
    00360   static Ptr findByFileContent( const QString &fileName, int *accuracy=0 );
    00361
    00362   struct Format{
    00363      bool text : 1;
    00364      enum { NoCompression=0, GZipCompression } compression : 4;
    00365      unsigned dummy : 27;
    00366   };
    00367
    00373   static Format findFormatByFileContent( const QString &fileName );
    00374
    00384   static List allMimeTypes();
    00385
    00393   static const QString & defaultMimeType();
    00394
    00402   static KMimeType::Ptr defaultMimeTypePtr();
    00403
    00420   QString parentMimeType() const;
    00421
    00428   bool is( const QString& mimeTypeName ) const;
    00429
    00435   static KMimeType::Ptr diagnoseFileName(const QString &file, QString &pattern);
    00436
    00437 protected:
    00438   void loadInternal( QDataStream& );
    00439   void init( KDesktopFile * );
    00440
    00445   static void errorMissingMimeType( const QString& _type );
    00446
    00450   static void buildDefaultType();
    00451
    00455   static void checkEssentialMimeTypes();
    00459   static bool s_bChecked;
    00460
    00461   QStringList m_lstPatterns;
    00462
    00463   static Ptr s_pDefaultType;
    00464
    00465 protected:
    00466   friend class KServiceTypeFactory;
    00467   int patternsAccuracy() const;
    00468
    00469 protected:
    00470   virtual void virtual_hook( int id, void* data );
    00471 };
    00472
    00477 class KIO_EXPORT KFolderType : public KMimeType
    00478 {
    00479   K_SYCOCATYPE( KST_KFolderType, KMimeType )
    00480
    00481 public:
    00482 //  KFolderType( const QString & _fullpath, const QString& _type, const QString& _icon, const QString& _comment,
    00483 //             const QStringList& _patterns );
    00484 //  KFolderType( const QString & _fullpath ) : KMimeType( _fullpath ) { }
    00489   KFolderType( KDesktopFile *config) : KMimeType( config ) { }
    00491   KFolderType( QDataStream& _str, int offset ) : KMimeType( _str, offset ) { }
    00492
    00493   virtual QString icon( const QString& _url, bool _is_local ) const;
    00494   virtual QString icon( const KURL& _url, bool _is_local ) const;
    00495   virtual QString comment( const QString& _url, bool _is_local ) const;
    00496   virtual QString comment( const KURL& _url, bool _is_local ) const;
    00497 protected:
    00498   virtual void virtual_hook( int id, void* data );
    00499 };
    00500
    00506 class KIO_EXPORT KDEDesktopMimeType : public KMimeType
    00507 {
    00508   K_SYCOCATYPE( KST_KDEDesktopMimeType, KMimeType )
    00509
    00510 public:
    00511   enum ServiceType { ST_MOUNT, ST_UNMOUNT, /* ST_PROPERTIES, */ ST_USER_DEFINED };
    00512
    00517   struct Service
    00518   {
    00519     Service() { m_display = true; }
    00520     bool isEmpty() const { return m_strName.isEmpty(); }
    00521     QString m_strName;
    00522     QString m_strIcon;
    00523     QString m_strExec;
    00524     ServiceType m_type;
    00525     bool m_display;
    00526   };
    00527   // KDEDesktopMimeType( const QString & _fullpath, const QString& _type, const QString& _icon,
    00528   //                     const QString& _comment, const QStringList& _patterns );
    00529   // KDEDesktopMimeType( const QString & _fullpath ) : KMimeType( _fullpath ) { }
    00534   KDEDesktopMimeType( KDesktopFile *config) : KMimeType( config ) { }
    00536   KDEDesktopMimeType( QDataStream& _str, int offset ) : KMimeType( _str, offset ) { }
    00537
    00538   virtual QString icon( const QString& _url, bool _is_local ) const;
    00539   virtual QString icon( const KURL& _url, bool _is_local ) const;
    00540   virtual QPixmap pixmap( const KURL& _url, KIcon::Group _group, int _force_size = 0,
    00541                           int _state = 0, QString * _path = 0L ) const;
    00542   virtual QString comment( const QString& _url, bool _is_local ) const;
    00543   virtual QString comment( const KURL& _url, bool _is_local ) const;
    00544
    00550   static QValueList<Service> builtinServices( const KURL& _url );
    00561   static QValueList<Service> userDefinedServices( const QString& path, bool bLocalFiles );
    00562
    00568   static QValueList<Service> userDefinedServices( const QString& path, KConfig& config, bool bLocalFiles );
    00569
    00575   static void executeService( const QString& _path, KDEDesktopMimeType::Service& _service ) KDE_DEPRECATED;
    00576
    00582   static void executeService( const KURL::List& urls, KDEDesktopMimeType::Service& service );
    00583
    00595   static pid_t run( const KURL& _url, bool _is_local );
    00596
    00597 protected:
    00598   virtual QPixmap pixmap(KIcon::Group a, int b, int c, QString *d) const
    00599      { return KMimeType::pixmap(a, b, c, d); }
    00600
    00601   static pid_t runFSDevice( const KURL& _url, const KSimpleConfig &cfg );
    00602   static pid_t runApplication( const KURL& _url, const QString & _serviceFile );
    00603   static pid_t runLink( const KURL& _url, const KSimpleConfig &cfg );
    00604   static pid_t runMimeType( const KURL& _url, const KSimpleConfig &cfg );
    00605 protected:
    00606   virtual void virtual_hook( int id, void* data );
    00607 };
    00608
    00613 class KIO_EXPORT KExecMimeType : public KMimeType
    00614 {
    00615   K_SYCOCATYPE( KST_KExecMimeType, KMimeType )
    00616
    00617 public:
    00618   // KExecMimeType( const QString & _fullpath, const QString& _type, const QString& _icon,
    00619   //                 const QString& _comment, const QStringList& _patterns );
    00620   // KExecMimeType( const QString & _fullpath ) : KMimeType( _fullpath ) { }
    00625   KExecMimeType( KDesktopFile *config) : KMimeType( config ) { }
    00627   KExecMimeType( QDataStream& _str, int offset ) : KMimeType( _str, offset ) { }
    00628 protected:
    00629   virtual void virtual_hook( int id, void* data );
    00630 };
    00631
    00632 #endif

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:00 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003