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