Commit 306b28dd authored by Eike Ziller's avatar Eike Ziller
Browse files

MimeDatabase: Restrict to using XML mime provider



Change-Id: I335a675d24cd319a5d1d47bb8e8e1ab154d10cef
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 15d748b4
......@@ -75,13 +75,13 @@ MimeDatabasePrivate::~MimeDatabasePrivate()
MimeProviderBase *MimeDatabasePrivate::provider()
{
if (!m_provider) {
MimeProviderBase *binaryProvider = new MimeBinaryProvider(this);
if (binaryProvider->isValid()) {
m_provider = binaryProvider;
} else {
delete binaryProvider;
m_provider = new MimeXMLProvider(this);
}
// MimeProviderBase *binaryProvider = new MimeBinaryProvider(this);
// if (binaryProvider->isValid()) {
// m_provider = binaryProvider;
// } else {
// delete binaryProvider;
m_provider = new MimeXMLProvider(this);
// }
}
return m_provider;
}
......
This diff is collapsed.
......@@ -79,48 +79,48 @@ protected:
QDateTime m_lastCheck;
};
/*
Parses the files 'mime.cache' and 'types' on demand
*/
class MimeBinaryProvider : public MimeProviderBase
{
public:
MimeBinaryProvider(MimeDatabasePrivate *db);
virtual ~MimeBinaryProvider();
virtual bool isValid();
virtual MimeType mimeTypeForName(const QString &name);
virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix);
virtual QStringList parents(const QString &mime);
virtual QString resolveAlias(const QString &name);
virtual QStringList listAliases(const QString &name);
virtual MimeType findByMagic(const QByteArray &data, int *accuracyPtr);
virtual QList<MimeType> allMimeTypes();
virtual void loadMimeTypePrivate(MimeTypePrivate &);
virtual void loadIcon(MimeTypePrivate &);
virtual void loadGenericIcon(MimeTypePrivate &);
private:
struct CacheFile;
void matchGlobList(MimeGlobMatchResult &result, CacheFile *cacheFile, int offset, const QString &fileName);
bool matchSuffixTree(MimeGlobMatchResult &result, CacheFile *cacheFile, int numEntries, int firstOffset, const QString &fileName, int charPos, bool caseSensitiveCheck);
bool matchMagicRule(CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data);
QString iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime);
void loadMimeTypeList();
void checkCache();
class CacheFileList : public QList<CacheFile *>
{
public:
CacheFile *findCacheFile(const QString &fileName) const;
bool checkCacheChanged();
};
CacheFileList m_cacheFiles;
QStringList m_cacheFileNames;
QSet<QString> m_mimetypeNames;
bool m_mimetypeListLoaded;
};
///*
// Parses the files 'mime.cache' and 'types' on demand
// */
//class MimeBinaryProvider : public MimeProviderBase
//{
//public:
// MimeBinaryProvider(MimeDatabasePrivate *db);
// virtual ~MimeBinaryProvider();
// virtual bool isValid();
// virtual MimeType mimeTypeForName(const QString &name);
// virtual QStringList findByFileName(const QString &fileName, QString *foundSuffix);
// virtual QStringList parents(const QString &mime);
// virtual QString resolveAlias(const QString &name);
// virtual QStringList listAliases(const QString &name);
// virtual MimeType findByMagic(const QByteArray &data, int *accuracyPtr);
// virtual QList<MimeType> allMimeTypes();
// virtual void loadMimeTypePrivate(MimeTypePrivate &);
// virtual void loadIcon(MimeTypePrivate &);
// virtual void loadGenericIcon(MimeTypePrivate &);
//private:
// struct CacheFile;
// void matchGlobList(MimeGlobMatchResult &result, CacheFile *cacheFile, int offset, const QString &fileName);
// bool matchSuffixTree(MimeGlobMatchResult &result, CacheFile *cacheFile, int numEntries, int firstOffset, const QString &fileName, int charPos, bool caseSensitiveCheck);
// bool matchMagicRule(CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data);
// QString iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime);
// void loadMimeTypeList();
// void checkCache();
// class CacheFileList : public QList<CacheFile *>
// {
// public:
// CacheFile *findCacheFile(const QString &fileName) const;
// bool checkCacheChanged();
// };
// CacheFileList m_cacheFiles;
// QStringList m_cacheFileNames;
// QSet<QString> m_mimetypeNames;
// bool m_mimetypeListLoaded;
//};
/*
Parses the raw XML files (slower)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment