MythTV  master
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
MythMimeDatabase Class Reference

A wrapper around QMimeDatabase that supports additional mime types. More...

#include <libmythbase/http/mythmimedatabase.h>

Collaboration diagram for MythMimeDatabase:
[legend]

Public Member Functions

 MythMimeDatabase ()
 

Static Public Member Functions

static MythMimeTypes AllTypes ()
 Return a vector containing all of the known types (both Qt and MythTV) More...
 
static MythMimeType MimeTypeForName (const QString &Name)
 Return a mime type that matches the given name. More...
 
static QString SuffixForFileName (const QString &FileName)
 Return the preferred suffix for the given filename. More...
 
static MythMimeTypes MimeTypesForFileName (const QString &FileName)
 Return a vector of mime types that match the given filename. More...
 
static MythMimeType MimeTypeForFileNameAndData (const QString &FileName, const QByteArray &Data)
 Return a mime type for the given FileName and data. More...
 
static MythMimeType MimeTypeForFileNameAndData (const QString &FileName, QIODevice *Device)
 

Private Attributes

MythMimeDatabasePrivm_priv
 

Detailed Description

A wrapper around QMimeDatabase that supports additional mime types.

QMimeDatabase by default uses a list of MIME types provided by Freedesktop.org. Unfortunately it does not include a few MIME types (most notably the Apple plist types) and we cannot inherit from either QMimeDatabase or QMimeType to add new types. Qt does have a mechanism for adding additional types by extending the search path it uses. So for example, on unix systems, we could add our custom types to /usr/local/share/mythtv/mime/packages and add that path to XDG_DATA_DIRS (and this does work). It is not clear however how this would work on other platforms. On Android, for example, the 'GenericDataLocation' in QStandardPaths defaults to the USER directory.

Definition at line 10 of file mythmimedatabase.h.

Constructor & Destructor Documentation

◆ MythMimeDatabase()

MythMimeDatabase::MythMimeDatabase ( )

Definition at line 158 of file mythmimedatabase.cpp.

Member Function Documentation

◆ AllTypes()

MythMimeTypes MythMimeDatabase::AllTypes ( )
static

Return a vector containing all of the known types (both Qt and MythTV)

Definition at line 165 of file mythmimedatabase.cpp.

◆ MimeTypeForName()

MythMimeType MythMimeDatabase::MimeTypeForName ( const QString &  Name)
static

Return a mime type that matches the given name.

Note
We prioritise internal types over Qt types as our internal types are either non-ambiguous (e.g. cbor) or are generated internally (and we thus know their type).
If a suitable mime type is not found, an invalid type is returned.

Definition at line 201 of file mythmimedatabase.cpp.

Referenced by MythHTTPEncoding::GetContentType(), MythHTTPEncoding::GetMimeType(), MythWSDL::GetWSDL(), MythXSD::GetXSD(), and MythSerialiser::Serialise().

◆ SuffixForFileName()

QString MythMimeDatabase::SuffixForFileName ( const QString &  FileName)
static

Return the preferred suffix for the given filename.

Note
The suffix does not include any 'dots' and is always lower case.

Definition at line 187 of file mythmimedatabase.cpp.

Referenced by MythHTTPEncoding::GetMimeType().

◆ MimeTypesForFileName()

MythMimeTypes MythMimeDatabase::MimeTypesForFileName ( const QString &  FileName)
static

Return a vector of mime types that match the given filename.

Definition at line 175 of file mythmimedatabase.cpp.

Referenced by MythHTTPEncoding::GetMimeType().

◆ MimeTypeForFileNameAndData() [1/2]

MythMimeType MythMimeDatabase::MimeTypeForFileNameAndData ( const QString &  FileName,
const QByteArray &  Data 
)
static

Return a mime type for the given FileName and data.

As for QMimeDatabase, this method will default to using the file name where it is unambiguous and only probe the given data when further help is needed.

MythTV types are probed first.

Note
A valid mimetype is always returned (the default being 'application/octet-stream')

Definition at line 217 of file mythmimedatabase.cpp.

Referenced by MythHTTPEncoding::GetMimeType().

◆ MimeTypeForFileNameAndData() [2/2]

MythMimeType MythMimeDatabase::MimeTypeForFileNameAndData ( const QString &  FileName,
QIODevice *  Device 
)
static

Definition at line 225 of file mythmimedatabase.cpp.

Member Data Documentation

◆ m_priv

MythMimeDatabasePriv* MythMimeDatabase::m_priv
private

Definition at line 23 of file mythmimedatabase.h.


The documentation for this class was generated from the following files: