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