]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/mimetmac.cpp
revamping classic MLTE implementation
[wxWidgets.git] / src / mac / carbon / mimetmac.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>
65571936 9// Licence: wxWindows licence (part of wxExtra library)
7dc3cc31
VS
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
7dc3cc31
VS
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
7dc3cc31
VS
23#ifndef WX_PRECOMP
24 #include "wx/string.h"
25 #if wxUSE_GUI
26 #include "wx/icon.h"
27 #endif
28#endif //WX_PRECOMP
29
30
4b8f9d46
RN
31#if wxUSE_MIMETYPE
32
7dc3cc31
VS
33#include "wx/log.h"
34#include "wx/file.h"
35#include "wx/intl.h"
36#include "wx/dynarray.h"
37#include "wx/confbase.h"
38
39#include "wx/mac/mimetype.h"
40
41// other standard headers
42#include <ctype.h>
43
44// in case we're compiling in non-GUI mode
45class WXDLLEXPORT wxIcon;
46
f040060e
GD
47bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
48{
49 return FALSE;
50}
51
52bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
53{
54 return FALSE;
55}
7dc3cc31 56
7dc3cc31
VS
57bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
58{
59 return FALSE;
60}
61
62// @@ this function is half implemented
63bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
64{
65 return FALSE;
66}
67
68bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
69{
70 if ( m_strFileType.Length() > 0 )
71 {
72 *mimeType = m_strFileType ;
73 return TRUE ;
74 }
75 else
76 return FALSE;
77}
78
4d2976ad
VS
79bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
80{
81 wxString s;
82
83 if (GetMimeType(&s))
84 {
85 mimeTypes.Clear();
86 mimeTypes.Add(s);
87 return TRUE;
88 }
89 else
90 return FALSE;
91}
92
da0766ab 93bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
7dc3cc31
VS
94{
95 // no such file type or no value or incorrect icon entry
96 return FALSE;
97}
98
99bool wxFileTypeImpl::GetDescription(wxString *desc) const
100{
101 return FALSE;
102}
103
f040060e
GD
104size_t
105wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
e40298d5 106 const wxFileType::MessageParameters& params) const
007ae8d0 107{
0fe3b231 108 wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
f040060e
GD
109 return 0;
110}
111
112void
113wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
114{
0fe3b231 115 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
f040060e
GD
116}
117
118void
119wxMimeTypesManagerImpl::ClearData()
120{
0fe3b231 121 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
007ae8d0
GD
122}
123
7dc3cc31
VS
124// extension -> file type
125wxFileType *
126wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
127{
128 wxString ext = e ;
129 ext = ext.Lower() ;
427ff662 130 if ( ext == wxT("txt") )
7dc3cc31
VS
131 {
132 wxFileType *fileType = new wxFileType;
427ff662 133 fileType->m_impl->SetFileType(wxT("text/text"));
7dc3cc31
VS
134 fileType->m_impl->SetExt(ext);
135 return fileType;
136 }
427ff662 137 else if ( ext == wxT("htm") || ext == wxT("html") )
7dc3cc31
VS
138 {
139 wxFileType *fileType = new wxFileType;
427ff662 140 fileType->m_impl->SetFileType(wxT("text/html"));
7dc3cc31
VS
141 fileType->m_impl->SetExt(ext);
142 return fileType;
143 }
427ff662 144 else if ( ext == wxT("gif") )
7dc3cc31
VS
145 {
146 wxFileType *fileType = new wxFileType;
427ff662 147 fileType->m_impl->SetFileType(wxT("image/gif"));
7dc3cc31
VS
148 fileType->m_impl->SetExt(ext);
149 return fileType;
150 }
427ff662 151 else if ( ext == wxT("png" ))
7dc3cc31
VS
152 {
153 wxFileType *fileType = new wxFileType;
427ff662 154 fileType->m_impl->SetFileType(wxT("image/png"));
7dc3cc31
VS
155 fileType->m_impl->SetExt(ext);
156 return fileType;
157 }
427ff662 158 else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") )
7dc3cc31
VS
159 {
160 wxFileType *fileType = new wxFileType;
427ff662 161 fileType->m_impl->SetFileType(wxT("image/jpeg"));
7dc3cc31
VS
162 fileType->m_impl->SetExt(ext);
163 return fileType;
164 }
427ff662 165 else if ( ext == wxT("bmp") )
7dc3cc31
VS
166 {
167 wxFileType *fileType = new wxFileType;
427ff662 168 fileType->m_impl->SetFileType(wxT("image/bmp"));
7dc3cc31
VS
169 fileType->m_impl->SetExt(ext);
170 return fileType;
171 }
427ff662 172 else if ( ext == wxT("tif") || ext == wxT("tiff") )
7dc3cc31
VS
173 {
174 wxFileType *fileType = new wxFileType;
427ff662 175 fileType->m_impl->SetFileType(wxT("image/tiff"));
7dc3cc31
VS
176 fileType->m_impl->SetExt(ext);
177 return fileType;
178 }
427ff662 179 else if ( ext == wxT("xpm") )
7dc3cc31
VS
180 {
181 wxFileType *fileType = new wxFileType;
427ff662 182 fileType->m_impl->SetFileType(wxT("image/xpm"));
7dc3cc31
VS
183 fileType->m_impl->SetExt(ext);
184 return fileType;
185 }
427ff662 186 else if ( ext == wxT("xbm") )
7dc3cc31
VS
187 {
188 wxFileType *fileType = new wxFileType;
427ff662 189 fileType->m_impl->SetFileType(wxT("image/xbm"));
7dc3cc31
VS
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 *
200wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
201{
202 return NULL;
203}
204
205size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
206{
0fe3b231
GD
207 // VZ: don't know anything about this for Mac
208 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::EnumAllFileTypes() not yet implemented") );
7dc3cc31
VS
209
210 return 0;
211}
212
007ae8d0
GD
213wxFileType *
214wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
215{
0fe3b231 216 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
007ae8d0
GD
217
218 return NULL;
219}
f040060e
GD
220
221bool
222wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
223{
224 return FALSE;
225}
226
4b8f9d46 227#endif //wxUSE_MIMETYPE