]> git.saurik.com Git - wxWidgets.git/blame - src/mac/mimetype.cpp
yet another fix in wxHtmlParser::DoParsing
[wxWidgets.git] / src / mac / mimetype.cpp
CommitLineData
7dc3cc31
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: mac/mimetype.cpp
3// Purpose: classes and functions to manage MIME types
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 23.09.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows license (part of wxExtra library)
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "mimetype.h"
14#endif
15
16// for compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20 #pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24 #include "wx/defs.h"
25#endif
26
27#ifndef WX_PRECOMP
28 #include "wx/string.h"
29 #if wxUSE_GUI
30 #include "wx/icon.h"
31 #endif
32#endif //WX_PRECOMP
33
34
35#include "wx/log.h"
36#include "wx/file.h"
37#include "wx/intl.h"
38#include "wx/dynarray.h"
39#include "wx/confbase.h"
40
41#include "wx/mac/mimetype.h"
42
43// other standard headers
44#include <ctype.h>
45
46// in case we're compiling in non-GUI mode
47class WXDLLEXPORT wxIcon;
48
49
50
51
52
53
54bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
55{
56 return FALSE;
57}
58
59// @@ this function is half implemented
60bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
61{
62 return FALSE;
63}
64
65bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
66{
67 if ( m_strFileType.Length() > 0 )
68 {
69 *mimeType = m_strFileType ;
70 return TRUE ;
71 }
72 else
73 return FALSE;
74}
75
4d2976ad
VS
76bool 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
7dc3cc31
VS
90bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
91{
92 // no such file type or no value or incorrect icon entry
93 return FALSE;
94}
95
96bool wxFileTypeImpl::GetDescription(wxString *desc) const
97{
98 return FALSE;
99}
100
101// extension -> file type
102wxFileType *
103wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
104{
105 wxString ext = e ;
106 ext = ext.Lower() ;
107 if ( ext == "txt" )
108 {
109 wxFileType *fileType = new wxFileType;
110 fileType->m_impl->SetFileType("text/text");
111 fileType->m_impl->SetExt(ext);
112 return fileType;
113 }
114 else if ( ext == "htm" || ext == "html" )
115 {
116 wxFileType *fileType = new wxFileType;
117 fileType->m_impl->SetFileType("text/html");
118 fileType->m_impl->SetExt(ext);
119 return fileType;
120 }
121 else if ( ext == "gif" )
122 {
123 wxFileType *fileType = new wxFileType;
124 fileType->m_impl->SetFileType("image/gif");
125 fileType->m_impl->SetExt(ext);
126 return fileType;
127 }
128 else if ( ext == "png" )
129 {
130 wxFileType *fileType = new wxFileType;
131 fileType->m_impl->SetFileType("image/png");
132 fileType->m_impl->SetExt(ext);
133 return fileType;
134 }
135 else if ( ext == "jpg" || ext == "jpeg" )
136 {
137 wxFileType *fileType = new wxFileType;
138 fileType->m_impl->SetFileType("image/jpeg");
139 fileType->m_impl->SetExt(ext);
140 return fileType;
141 }
142 else if ( ext == "bmp" )
143 {
144 wxFileType *fileType = new wxFileType;
145 fileType->m_impl->SetFileType("image/bmp");
146 fileType->m_impl->SetExt(ext);
147 return fileType;
148 }
149 else if ( ext == "tif" || ext == "tiff" )
150 {
151 wxFileType *fileType = new wxFileType;
152 fileType->m_impl->SetFileType("image/tiff");
153 fileType->m_impl->SetExt(ext);
154 return fileType;
155 }
156 else if ( ext == "xpm" )
157 {
158 wxFileType *fileType = new wxFileType;
159 fileType->m_impl->SetFileType("image/xpm");
160 fileType->m_impl->SetExt(ext);
161 return fileType;
162 }
163 else if ( ext == "xbm" )
164 {
165 wxFileType *fileType = new wxFileType;
166 fileType->m_impl->SetFileType("image/xbm");
167 fileType->m_impl->SetExt(ext);
168 return fileType;
169 }
170
171 // unknown extension
172 return NULL;
173}
174
175// MIME type -> extension -> file type
176wxFileType *
177wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
178{
179 return NULL;
180}
181
182size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
183{
184 wxFAIL_MSG( _T("TODO") ); // VZ: don't know anything about this for Mac
185
186 return 0;
187}
188