]> git.saurik.com Git - wxWidgets.git/blob - src/msdos/mimetype.cpp
XRC spec: relax requirements on some commonly omitted properties.
[wxWidgets.git] / src / msdos / mimetype.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msdos/mimetype.cpp
3 // Purpose: classes and functions to manage MIME types
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 23.09.98
7 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
8 // Licence: wxWindows licence (part of wxExtra library)
9 /////////////////////////////////////////////////////////////////////////////
10
11 // for compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #if wxUSE_MIMETYPE
19
20 #include "wx/msdos/mimetype.h"
21
22 #ifndef WX_PRECOMP
23 #include "wx/dynarray.h"
24 #include "wx/string.h"
25 #include "wx/intl.h"
26 #include "wx/log.h"
27 #if wxUSE_GUI
28 #include "wx/icon.h"
29 #endif
30 #endif //WX_PRECOMP
31
32 #include "wx/file.h"
33 #include "wx/confbase.h"
34
35 // other standard headers
36 #include <ctype.h>
37
38 // in case we're compiling in non-GUI mode
39 class WXDLLEXPORT wxIcon;
40
41 bool wxFileTypeImpl::SetCommand(const wxString& WXUNUSED(cmd),
42 const wxString& WXUNUSED(verb),
43 bool WXUNUSED(overwriteprompt))
44 {
45 return false;
46 }
47
48 bool wxFileTypeImpl::SetDefaultIcon(const wxString& WXUNUSED(strIcon),
49 int WXUNUSED(index))
50 {
51 return false;
52 }
53
54 bool wxFileTypeImpl::GetCommand(wxString *WXUNUSED(command),
55 const char *WXUNUSED(verb)) const
56 {
57 return false;
58 }
59
60 bool wxFileTypeImpl::GetExtensions(wxArrayString& WXUNUSED(extensions))
61 {
62 return false;
63 }
64
65 bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
66 {
67 if ( !m_strFileType.empty() )
68 {
69 *mimeType = m_strFileType ;
70 return true ;
71 }
72 else
73 return false;
74 }
75
76 bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
77 {
78 wxString s;
79
80 if (GetMimeType(&s))
81 {
82 mimeTypes.Clear();
83 mimeTypes.Add(s);
84 return true;
85 }
86 else
87 return false;
88 }
89
90 bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
91 {
92 // no such file type or no value or incorrect icon entry
93 return false;
94 }
95
96 bool wxFileTypeImpl::GetDescription(wxString *WXUNUSED(desc)) const
97 {
98 return false;
99 }
100
101 size_t
102 wxFileTypeImpl::GetAllCommands(wxArrayString * WXUNUSED(verbs),
103 wxArrayString * WXUNUSED(commands),
104 const wxFileType::MessageParameters& WXUNUSED(params)) const
105 {
106 wxFAIL_MSG( wxT("wxFileTypeImpl::GetAllCommands() not yet implemented") );
107 return 0;
108 }
109
110 void
111 wxMimeTypesManagerImpl::Initialize(int WXUNUSED(mailcapStyles),
112 const wxString& WXUNUSED(extraDir))
113 {
114 wxFAIL_MSG( wxT("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
115 }
116
117 void
118 wxMimeTypesManagerImpl::ClearData()
119 {
120 wxFAIL_MSG( wxT("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
121 }
122
123 // extension -> file type
124 wxFileType *
125 wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
126 {
127 wxString ext = e ;
128 ext = ext.Lower() ;
129 if ( ext == wxT("txt") )
130 {
131 wxFileType *fileType = new wxFileType;
132 fileType->m_impl->SetFileType(wxT("text/text"));
133 fileType->m_impl->SetExt(ext);
134 return fileType;
135 }
136 else if ( ext == wxT("htm") || ext == wxT("html") )
137 {
138 wxFileType *fileType = new wxFileType;
139 fileType->m_impl->SetFileType(wxT("text/html"));
140 fileType->m_impl->SetExt(ext);
141 return fileType;
142 }
143 else if ( ext == wxT("gif") )
144 {
145 wxFileType *fileType = new wxFileType;
146 fileType->m_impl->SetFileType(wxT("image/gif"));
147 fileType->m_impl->SetExt(ext);
148 return fileType;
149 }
150 else if ( ext == wxT("png" ))
151 {
152 wxFileType *fileType = new wxFileType;
153 fileType->m_impl->SetFileType(wxT("image/png"));
154 fileType->m_impl->SetExt(ext);
155 return fileType;
156 }
157 else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") )
158 {
159 wxFileType *fileType = new wxFileType;
160 fileType->m_impl->SetFileType(wxT("image/jpeg"));
161 fileType->m_impl->SetExt(ext);
162 return fileType;
163 }
164 else if ( ext == wxT("bmp") )
165 {
166 wxFileType *fileType = new wxFileType;
167 fileType->m_impl->SetFileType(wxT("image/bmp"));
168 fileType->m_impl->SetExt(ext);
169 return fileType;
170 }
171 else if ( ext == wxT("tif") || ext == wxT("tiff") )
172 {
173 wxFileType *fileType = new wxFileType;
174 fileType->m_impl->SetFileType(wxT("image/tiff"));
175 fileType->m_impl->SetExt(ext);
176 return fileType;
177 }
178 else if ( ext == wxT("xpm") )
179 {
180 wxFileType *fileType = new wxFileType;
181 fileType->m_impl->SetFileType(wxT("image/xpm"));
182 fileType->m_impl->SetExt(ext);
183 return fileType;
184 }
185 else if ( ext == wxT("xbm") )
186 {
187 wxFileType *fileType = new wxFileType;
188 fileType->m_impl->SetFileType(wxT("image/xbm"));
189 fileType->m_impl->SetExt(ext);
190 return fileType;
191 }
192
193 // unknown extension
194 return NULL;
195 }
196
197 // MIME type -> extension -> file type
198 wxFileType *
199 wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& WXUNUSED(mimeType))
200 {
201 return NULL;
202 }
203
204 size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& WXUNUSED(mimetypes))
205 {
206 // VZ: don't know anything about this for Mac
207 wxFAIL_MSG( wxT("wxMimeTypesManagerImpl::EnumAllFileTypes() not yet implemented") );
208
209 return 0;
210 }
211
212 wxFileType *
213 wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& WXUNUSED(ftInfo))
214 {
215 wxFAIL_MSG( wxT("wxMimeTypesManagerImpl::Associate() not yet implemented") );
216
217 return NULL;
218 }
219
220 bool
221 wxMimeTypesManagerImpl::Unassociate(wxFileType *WXUNUSED(ft))
222 {
223 return false;
224 }
225
226 #endif // wxUSE_MIMETYPE