]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/mimetype.tex
added the script used to add libraries to the documentation files (see patch 1756715)
[wxWidgets.git] / docs / latex / wx / mimetype.tex
CommitLineData
b13d92d1
VZ
1\section{\class{wxMimeTypesManager}}\label{wxmimetypesmanager}
2
3This class allows the application to retrieve the information about all known
4MIME types from a system-specific location and the filename extensions to the
5MIME types and vice versa. After initialization the functions
6\helpref{wxMimeTypesManager::GetFileTypeFromMimeType}{wxmimetypesmanagergetfiletypefrommimetype}
7and \helpref{wxMimeTypesManager::GetFileTypeFromExtension}{wxmimetypesmanagergetfiletypefromextension}
8may be called: they will return a \helpref{wxFileType}{wxfiletype} object which
9may be further queried for file description, icon and other attributes.
10
11{\bf Windows:} MIME type information is stored in the registry and no additional
12initialization is needed.
13
14{\bf Unix:} MIME type information is stored in the files mailcap and mime.types
15(system-wide) and .mailcap and .mime.types in the current user's home directory:
16all of these files are searched for and loaded if found by default. However,
17additional functions
cc385968 18\helpref{wxMimeTypesManager::ReadMailcap}{wxmimetypesmanagerreadmailcap} and
b13d92d1
VZ
19\helpref{wxMimeTypesManager::ReadMimeTypes}{wxmimetypesmanagerreadmimetypes} are
20provided to load additional files.
21
cdf339c9
VS
22If GNOME or KDE desktop environment is installed, then wxMimeTypesManager
23gathers MIME information from respective files (e.g. .kdelnk files under KDE).
24
b13d92d1 25NB: Currently, wxMimeTypesManager is limited to reading MIME type information
43e8916f 26but it will support modifying it as well in future versions.
b13d92d1 27
d2a190fe
VS
28\wxheading{Global objects}
29
30Global instance of wxMimeTypesManager is always available. It is defined
31as follows:
32
33\begin{verbatim}
34wxMimeTypesManager *wxTheMimeTypesManager;
35\end{verbatim}
36
37It is recommended to use this instance instead of creating your own because
08890e27 38gathering MIME information may take quite a long time on Unix systems.
d2a190fe 39
b13d92d1
VZ
40\wxheading{Derived from}
41
42No base class.
43
954b8ae6
JS
44\wxheading{Include files}
45
46<wx/mimetype.h>
47
b13d92d1
VZ
48\wxheading{See also}
49
50\helpref{wxFileType}{wxfiletype}
51
52\latexignore{\rtfignore{\wxheading{Function groups}}}
53
e16916ea 54
dcbd177f 55\membersection{Helper functions}\label{mimehelperfunctions}
a5a19b83
VZ
56
57All of these functions are static (i.e. don't need a wxMimeTypesManager object
58to call them) and provide some useful operations for string representations of
59MIME types. Their usage is recommended instead of directly working with MIME
60types using wxString functions.
61
62\helpref{IsOfType}{wxmimetypesmanagerisoftype}
63
e16916ea 64
dcbd177f 65\membersection{Constructor and destructor}\label{mimeconstructordestructor}
b13d92d1
VZ
66
67NB: You won't normally need to use more than one wxMimeTypesManager object in a
68program.
69
70\helpref{wxMimeTypesManager}{wxmimetypesmanagerctor}\\
71\helpref{\destruct{wxMimeTypesManager}}{wxmimetypesmanagerdtor}
72
e16916ea 73
dcbd177f 74\membersection{Query database}\label{mimequerydatabase}
b13d92d1 75
2432b92d
JS
76These functions are the heart of this class: they allow to find a \helpref{file type}{wxfiletype} object
77from either file extension or MIME type.
b13d92d1 78If the function is successful, it returns a pointer to the wxFileType object
e16916ea 79which {\bf must} be deleted by the caller, otherwise \NULL will be returned.
b13d92d1
VZ
80
81\helpref{GetFileTypeFromMimeType}{wxmimetypesmanagergetfiletypefrommimetype}\\
82\helpref{GetFileTypeFromExtension}{wxmimetypesmanagergetfiletypefromextension}
83
e16916ea 84
2432b92d 85\membersection{Initialization functions}\label{wxmimetypesmanagerinit}
b13d92d1 86
2432b92d
JS
87{\bf Unix:} These functions may be used to load additional files (except for the
88default ones which are loaded automatically) containing MIME
b13d92d1
VZ
89information in either mailcap(5) or mime.types(5) format.
90
91\helpref{ReadMailcap}{wxmimetypesmanagerreadmailcap}\\
8e124873
VZ
92\helpref{ReadMimeTypes}{wxmimetypesmanagerreadmimetypes}\\
93\helpref{AddFallbacks}{wxmimetypesmanageraddfallbacks}
b13d92d1
VZ
94
95%%%%% MEMBERS HERE %%%%%
96\helponly{\insertatlevel{2}{
97
98\wxheading{Members}
99
100}}
101
e16916ea 102
b13d92d1 103\membersection{wxMimeTypesManager::wxMimeTypesManager}\label{wxmimetypesmanagerctor}
2432b92d 104
b13d92d1
VZ
105\func{}{wxMimeTypesManager}{\void}
106
107Constructor puts the object in the "working" state, no additional initialization
108are needed - but \helpref{ReadXXX}{wxmimetypesmanagerinit} may be used to load
109additional mailcap/mime.types files.
110
e16916ea 111
b13d92d1 112\membersection{wxMimeTypesManager::\destruct{wxMimeTypesManager}}\label{wxmimetypesmanagerdtor}
2432b92d
JS
113
114\func{}{\destruct{wxMimeTypesManager}}{\void}
b13d92d1
VZ
115
116Destructor is not virtual, so this class should not be derived from.
117
e16916ea 118
8e124873
VZ
119\membersection{wxMimeTypesManager::AddFallbacks}\label{wxmimetypesmanageraddfallbacks}
120
121\func{void}{AddFallbacks}{\param{const wxFileTypeInfo *}{fallbacks}}
122
2edb0bde 123This function may be used to provide hard-wired fallbacks for the MIME types
8e124873
VZ
124and extensions that might not be present in the system MIME database.
125
126% TODO
127
128Please see the typetest sample for an example of using it.
129
e16916ea 130
b13d92d1 131\membersection{wxMimeTypesManager::GetFileTypeFromExtension}\label{wxmimetypesmanagergetfiletypefromextension}
2432b92d
JS
132
133\func{wxFileType*}{GetFileTypeFromExtension}{\param{const wxString\&}{ extension}}
b13d92d1
VZ
134
135Gather information about the files with given extension and return the
e16916ea 136corresponding \helpref{wxFileType}{wxfiletype} object or \NULL if the extension
b13d92d1
VZ
137is unknown.
138
e16916ea
VZ
139The \arg{extension} parameter may have, or not, the leading dot, if it has it,
140it is stripped automatically. It must not however be empty.
141
142
b13d92d1 143\membersection{wxMimeTypesManager::GetFileTypeFromMimeType}\label{wxmimetypesmanagergetfiletypefrommimetype}
2432b92d
JS
144
145\func{wxFileType*}{GetFileTypeFromMimeType}{\param{const wxString\&}{ mimeType}}
b13d92d1
VZ
146
147Gather information about the files with given MIME type and return the
e16916ea 148corresponding \helpref{wxFileType}{wxfiletype} object or \NULL if the MIME type
b13d92d1
VZ
149is unknown.
150
e16916ea 151
a5a19b83
VZ
152\membersection{wxMimeTypesManager::IsOfType}\label{wxmimetypesmanagerisoftype}
153
154\func{bool}{IsOfType}{\param{const wxString\&}{ mimeType}, \param{const wxString\&}{ wildcard}}
155
cc81d32f 156This function returns true if either the given {\it mimeType} is exactly the
a5a19b83
VZ
157same as {\it wildcard} or if it has the same category and the subtype of
158{\it wildcard} is '*'. Note that the '*' wildcard is not allowed in
159{\it mimeType} itself.
160
2edb0bde 161The comparison don by this function is case insensitive so it is not
a5a19b83
VZ
162necessary to convert the strings to the same case before calling it.
163
e16916ea 164
b13d92d1 165\membersection{wxMimeTypesManager::ReadMailcap}\label{wxmimetypesmanagerreadmailcap}
2432b92d 166
cc81d32f 167\func{bool}{ReadMailcap}{\param{const wxString\&}{ filename}, \param{bool}{ fallback = false}}
b13d92d1
VZ
168
169Load additional file containing information about MIME types and associated
170information in mailcap format. See metamail(1) and mailcap(5) for more
171information.
172
cc385968
VZ
173{\it fallback} parameter may be used to load additional mailcap files without
174overriding the settings found in the standard files: normally, entries from
175files loaded with ReadMailcap will override the entries from files loaded
176previously (and the standard ones are loaded in the very beginning), but this
cc81d32f 177will not happen if this parameter is set to true (default is false).
cc385968 178
cc81d32f 179The return value is true if there were no errors in the file or false
cc385968
VZ
180otherwise.
181
e16916ea 182
b13d92d1 183\membersection{wxMimeTypesManager::ReadMimeTypes}\label{wxmimetypesmanagerreadmimetypes}
2432b92d 184
cc385968 185\func{bool}{ReadMimeTypes}{\param{const wxString\&}{ filename}}
b13d92d1
VZ
186
187Load additional file containing information about MIME types and associated
188information in mime.types file format. See metamail(1) and mailcap(5) for more
189information.
2432b92d 190
cc81d32f 191The return value is true if there were no errors in the file or false
cc385968
VZ
192otherwise.
193