• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kmimetypefactory.h

Go to the documentation of this file.
00001 /*  This file is part of the KDE libraries
00002  *  Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
00003  *  Copyright (C) 2006-2007 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., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef KMIMETYPEFACTORY_H
00021 #define KMIMETYPEFACTORY_H
00022 
00023 #include <assert.h>
00024 
00025 #include <QtCore/QStringList>
00026 
00027 #include "ksycocafactory.h"
00028 #include "kmimetype.h"
00029 #include "kmimemagicrule_p.h"
00030 
00031 class KSycoca;
00032 
00041 class KDECORE_EXPORT KMimeTypeFactory : public KSycocaFactory
00042 {
00043     K_SYCOCAFACTORY( KST_KMimeTypeFactory )
00044 public:
00048     KMimeTypeFactory();
00049 
00050     virtual ~KMimeTypeFactory();
00051 
00055     virtual KSycocaEntry *createEntry(const QString &, const char *) const
00056     { assert(0); return 0; }
00057 
00062     virtual KMimeType::Ptr findMimeTypeByName(const QString &_name, KMimeType::FindByNameOption options = KMimeType::DontResolveAlias);
00063 
00064 private: // only for KMimeType
00065     friend class KMimeType;
00069     QString resolveAlias(const QString& mime);
00070 
00078     QList<KMimeType::Ptr> findFromFileName(const QString &filename, QString *matchingExtension = 0);
00079 
00080     enum WhichPriority { LowPriorityRules, HighPriorityRules, AllRules };
00090     KMimeType::Ptr findFromContent(QIODevice* device, WhichPriority whichPriority, int* accuracy, QByteArray& beginning);
00091 
00096     bool checkMimeTypes();
00097 
00098 protected:
00102     QMap<QString, QString>& aliases();
00103 
00104 public:
00109     KMimeType::List allMimeTypes();
00110 
00114     static KMimeTypeFactory * self();
00115 
00119     QList<KMimeMagicRule> parseMagicFile(QIODevice* file, const QString& fileName) const;
00120 
00121 protected:
00122     virtual KMimeType *createEntry(int offset) const;
00123 
00124 protected: // accessed by KBuildMimeTypeFactory
00126     int m_fastPatternOffset;
00128     int m_otherPatternOffset;
00129 
00130     KSycocaDict* m_fastPatternDict;
00131 
00132 private:
00133     // Read magic files
00134     void parseMagic();
00135 
00136     QList<KMimeType::Ptr> findFromFileNameHelper(const QString &filename, QString *matchingExtension);
00137     QList<KMimeType::Ptr> findFromFastPatternDict(const QString &extension);
00138 
00139     // TODO combine both lists into a single QList<QPair<QString,qint32> >.
00140     QStringList m_otherPatterns;
00141     QList<qint32> m_otherPatterns_offsets;
00142 
00143     QMap<QString, QString> m_aliases; // alias -> canonicalName
00144 
00145     bool m_magicFilesParsed;
00146     QList<KMimeMagicRule> m_magicRules;
00147 
00148     static KMimeTypeFactory *_self;
00149 
00150 protected:
00151     virtual void virtual_hook( int id, void* data );
00152 private:
00153     // d pointer: useless since this header is not installed
00154     class KMimeTypeFactoryPrivate* d;
00155 };
00156 
00157 #endif

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal