]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/mimetype.tex
Prep for wxPython 2.1b3 release
[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
22NB: Currently, wxMimeTypesManager is limited to reading MIME type information
23but it will support modifying it as well in the future versions.
24
b13d92d1
VZ
25\wxheading{Derived from}
26
27No base class.
28
954b8ae6
JS
29\wxheading{Include files}
30
31<wx/mimetype.h>
32
b13d92d1
VZ
33\wxheading{See also}
34
35\helpref{wxFileType}{wxfiletype}
36
37\latexignore{\rtfignore{\wxheading{Function groups}}}
38
a5a19b83
VZ
39\membersection{Helper functions}
40
41All of these functions are static (i.e. don't need a wxMimeTypesManager object
42to call them) and provide some useful operations for string representations of
43MIME types. Their usage is recommended instead of directly working with MIME
44types using wxString functions.
45
46\helpref{IsOfType}{wxmimetypesmanagerisoftype}
47
b13d92d1
VZ
48\membersection{Constructor and destructor}
49
50NB: You won't normally need to use more than one wxMimeTypesManager object in a
51program.
52
53\helpref{wxMimeTypesManager}{wxmimetypesmanagerctor}\\
54\helpref{\destruct{wxMimeTypesManager}}{wxmimetypesmanagerdtor}
55
56\membersection{Query database}
57
2432b92d
JS
58These functions are the heart of this class: they allow to find a \helpref{file type}{wxfiletype} object
59from either file extension or MIME type.
b13d92d1 60If the function is successful, it returns a pointer to the wxFileType object
2432b92d 61which {\bf must} be deleted by the caller, otherwise NULL will be returned.
b13d92d1
VZ
62
63\helpref{GetFileTypeFromMimeType}{wxmimetypesmanagergetfiletypefrommimetype}\\
64\helpref{GetFileTypeFromExtension}{wxmimetypesmanagergetfiletypefromextension}
65
2432b92d 66\membersection{Initialization functions}\label{wxmimetypesmanagerinit}
b13d92d1 67
2432b92d
JS
68{\bf Unix:} These functions may be used to load additional files (except for the
69default ones which are loaded automatically) containing MIME
b13d92d1
VZ
70information in either mailcap(5) or mime.types(5) format.
71
72\helpref{ReadMailcap}{wxmimetypesmanagerreadmailcap}\\
8e124873
VZ
73\helpref{ReadMimeTypes}{wxmimetypesmanagerreadmimetypes}\\
74\helpref{AddFallbacks}{wxmimetypesmanageraddfallbacks}
b13d92d1
VZ
75
76%%%%% MEMBERS HERE %%%%%
77\helponly{\insertatlevel{2}{
78
79\wxheading{Members}
80
81}}
82
83\membersection{wxMimeTypesManager::wxMimeTypesManager}\label{wxmimetypesmanagerctor}
2432b92d 84
b13d92d1
VZ
85\func{}{wxMimeTypesManager}{\void}
86
87Constructor puts the object in the "working" state, no additional initialization
88are needed - but \helpref{ReadXXX}{wxmimetypesmanagerinit} may be used to load
89additional mailcap/mime.types files.
90
91\membersection{wxMimeTypesManager::\destruct{wxMimeTypesManager}}\label{wxmimetypesmanagerdtor}
2432b92d
JS
92
93\func{}{\destruct{wxMimeTypesManager}}{\void}
b13d92d1
VZ
94
95Destructor is not virtual, so this class should not be derived from.
96
8e124873
VZ
97\membersection{wxMimeTypesManager::AddFallbacks}\label{wxmimetypesmanageraddfallbacks}
98
99\func{void}{AddFallbacks}{\param{const wxFileTypeInfo *}{fallbacks}}
100
101This function may be used to provdie hard-wired fallbacks for the MIME types
102and extensions that might not be present in the system MIME database.
103
104% TODO
105
106Please see the typetest sample for an example of using it.
107
b13d92d1 108\membersection{wxMimeTypesManager::GetFileTypeFromExtension}\label{wxmimetypesmanagergetfiletypefromextension}
2432b92d
JS
109
110\func{wxFileType*}{GetFileTypeFromExtension}{\param{const wxString\&}{ extension}}
b13d92d1
VZ
111
112Gather information about the files with given extension and return the
113corresponding \helpref{wxFileType}{wxfiletype} object or NULL if the extension
114is unknown.
115
116\membersection{wxMimeTypesManager::GetFileTypeFromMimeType}\label{wxmimetypesmanagergetfiletypefrommimetype}
2432b92d
JS
117
118\func{wxFileType*}{GetFileTypeFromMimeType}{\param{const wxString\&}{ mimeType}}
b13d92d1
VZ
119
120Gather information about the files with given MIME type and return the
121corresponding \helpref{wxFileType}{wxfiletype} object or NULL if the MIME type
122is unknown.
123
a5a19b83
VZ
124\membersection{wxMimeTypesManager::IsOfType}\label{wxmimetypesmanagerisoftype}
125
126\func{bool}{IsOfType}{\param{const wxString\&}{ mimeType}, \param{const wxString\&}{ wildcard}}
127
128This function returns TRUE if either the given {\it mimeType} is exactly the
129same as {\it wildcard} or if it has the same category and the subtype of
130{\it wildcard} is '*'. Note that the '*' wildcard is not allowed in
131{\it mimeType} itself.
132
133The comparaison don by this function is case insensitive so it is not
134necessary to convert the strings to the same case before calling it.
135
b13d92d1 136\membersection{wxMimeTypesManager::ReadMailcap}\label{wxmimetypesmanagerreadmailcap}
2432b92d 137
cc385968 138\func{bool}{ReadMailcap}{\param{const wxString\&}{ filename}, \param{bool}{ fallback = FALSE}}
b13d92d1
VZ
139
140Load additional file containing information about MIME types and associated
141information in mailcap format. See metamail(1) and mailcap(5) for more
142information.
143
cc385968
VZ
144{\it fallback} parameter may be used to load additional mailcap files without
145overriding the settings found in the standard files: normally, entries from
146files loaded with ReadMailcap will override the entries from files loaded
147previously (and the standard ones are loaded in the very beginning), but this
148will not happen if this parameter is set to TRUE (default is FALSE).
149
150The return value is TRUE if there were no errors in the file or FALSE
151otherwise.
152
b13d92d1 153\membersection{wxMimeTypesManager::ReadMimeTypes}\label{wxmimetypesmanagerreadmimetypes}
2432b92d 154
cc385968 155\func{bool}{ReadMimeTypes}{\param{const wxString\&}{ filename}}
b13d92d1
VZ
156
157Load additional file containing information about MIME types and associated
158information in mime.types file format. See metamail(1) and mailcap(5) for more
159information.
2432b92d 160
cc385968
VZ
161The return value is TRUE if there were no errors in the file or FALSE
162otherwise.
163