File indexing completed on 2024-04-14 14:20:05

0001 /*  This file is part of the KDE libraries
0002  *  Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
0003  *  Copyright (C) 2006-2007 David Faure <faure@kde.org>
0004  *
0005  *  This library is free software; you can redistribute it and/or
0006  *  modify it under the terms of the GNU Library General Public
0007  *  License as published by the Free Software Foundation; either
0008  *  version 2 of the License, or (at your option) any later version.
0009  *
0010  *  This library is distributed in the hope that it will be useful,
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  *  Library General Public License for more details.
0014  *
0015  *  You should have received a copy of the GNU Library General Public License
0016  *  along with this library; see the file COPYING.LIB.  If not, write to
0017  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  *  Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef KMIMETYPEREPOSITORY_H
0022 #define KMIMETYPEREPOSITORY_H
0023 
0024 #include "kmimetype.h"
0025 #include "qmimedatabase.h"
0026 #include <QReadWriteLock>
0027 
0028 /**
0029  * @internal  - this header is not installed
0030  * Can create KMimeTypes and holds all the extra information about mimetypes
0031  * (aliases, parents, etc.)
0032  *
0033  * Exported for kbuildsycoca, for now
0034  */
0035 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KMimeTypeRepository
0036 {
0037 public:
0038     /**
0039      * @return the unique mimetype factory, creating it if necessary
0040      */
0041     static KMimeTypeRepository *self();
0042 
0043     /**
0044      * Return the patterns (globs) for a given mimetype
0045      * TEMPORARY method, it will go away once we can require shared-mime-info >= 0.70.
0046      */
0047     QStringList patternsForMimetype(const QString &mimeType);
0048 
0049     KMimeType::Ptr defaultMimeTypePtr();
0050 
0051     /**
0052      * Returns true if KMimeType::favIconForUrl should talk to kded's favicons module.
0053      */
0054     bool useFavIcons();
0055 
0056     int sharedMimeInfoVersion();
0057 
0058     /**
0059      * @internal
0060      */
0061     static bool matchFileName(const QString &filename, const QString &pattern);
0062 
0063 private:
0064     KMimeTypeRepository();
0065     ~KMimeTypeRepository();
0066 
0067     QMimeDatabase m_mimeDb;
0068 
0069     bool m_useFavIcons;
0070     bool m_useFavIconsChecked;
0071     int m_sharedMimeInfoVersion;
0072     KMimeType::Ptr m_defaultMimeType;
0073 
0074     QReadWriteLock m_mutex;
0075 
0076     friend class KMimeTypeRepositorySingleton;
0077 };
0078 
0079 #endif /* KMIMETYPEREPOSITORY_H */
0080