]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/mimetmac.cpp
Fix memory leak by letting the base class version handle the
[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>
77ffb593 9// Licence: wxWidgets licence (part of wxExtra library)
7dc3cc31
VS
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
f040060e
GD
49bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
50{
51 return FALSE;
52}
53
54bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
55{
56 return FALSE;
57}
7dc3cc31 58
7dc3cc31
VS
59bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
60{
61 return FALSE;
62}
63
64// @@ this function is half implemented
65bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
66{
67 return FALSE;
68}
69
70bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
71{
72 if ( m_strFileType.Length() > 0 )
73 {
74 *mimeType = m_strFileType ;
75 return TRUE ;
76 }
77 else
78 return FALSE;
79}
80
4d2976ad
VS
81bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
82{
83 wxString s;
84
85 if (GetMimeType(&s))
86 {
87 mimeTypes.Clear();
88 mimeTypes.Add(s);
89 return TRUE;
90 }
91 else
92 return FALSE;
93}
94
da0766ab 95bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
7dc3cc31
VS
96{
97 // no such file type or no value or incorrect icon entry
98 return FALSE;
99}
100
101bool wxFileTypeImpl::GetDescription(wxString *desc) const
102{
103 return FALSE;
104}
105
f040060e
GD
106size_t
107wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
e40298d5 108 const wxFileType::MessageParameters& params) const
007ae8d0 109{
0fe3b231 110 wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
f040060e
GD
111 return 0;
112}
113
114void
115wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
116{
0fe3b231 117 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
f040060e
GD
118}
119
120void
121wxMimeTypesManagerImpl::ClearData()
122{
0fe3b231 123 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
007ae8d0
GD
124}
125
7dc3cc31
VS
126// extension -> file type
127wxFileType *
128wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
129{
130 wxString ext = e ;
131 ext = ext.Lower() ;
427ff662 132 if ( ext == wxT("txt") )
7dc3cc31
VS
133 {
134 wxFileType *fileType = new wxFileType;
427ff662 135 fileType->m_impl->SetFileType(wxT("text/text"));
7dc3cc31
VS
136 fileType->m_impl->SetExt(ext);
137 return fileType;
138 }
427ff662 139 else if ( ext == wxT("htm") || ext == wxT("html") )
7dc3cc31
VS
140 {
141 wxFileType *fileType = new wxFileType;
427ff662 142 fileType->m_impl->SetFileType(wxT("text/html"));
7dc3cc31
VS
143 fileType->m_impl->SetExt(ext);
144 return fileType;
145 }
427ff662 146 else if ( ext == wxT("gif") )
7dc3cc31
VS
147 {
148 wxFileType *fileType = new wxFileType;
427ff662 149 fileType->m_impl->SetFileType(wxT("image/gif"));
7dc3cc31
VS
150 fileType->m_impl->SetExt(ext);
151 return fileType;
152 }
427ff662 153 else if ( ext == wxT("png" ))
7dc3cc31
VS
154 {
155 wxFileType *fileType = new wxFileType;
427ff662 156 fileType->m_impl->SetFileType(wxT("image/png"));
7dc3cc31
VS
157 fileType->m_impl->SetExt(ext);
158 return fileType;
159 }
427ff662 160 else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") )
7dc3cc31
VS
161 {
162 wxFileType *fileType = new wxFileType;
427ff662 163 fileType->m_impl->SetFileType(wxT("image/jpeg"));
7dc3cc31
VS
164 fileType->m_impl->SetExt(ext);
165 return fileType;
166 }
427ff662 167 else if ( ext == wxT("bmp") )
7dc3cc31
VS
168 {
169 wxFileType *fileType = new wxFileType;
427ff662 170 fileType->m_impl->SetFileType(wxT("image/bmp"));
7dc3cc31
VS
171 fileType->m_impl->SetExt(ext);
172 return fileType;
173 }
427ff662 174 else if ( ext == wxT("tif") || ext == wxT("tiff") )
7dc3cc31
VS
175 {
176 wxFileType *fileType = new wxFileType;
427ff662 177 fileType->m_impl->SetFileType(wxT("image/tiff"));
7dc3cc31
VS
178 fileType->m_impl->SetExt(ext);
179 return fileType;
180 }
427ff662 181 else if ( ext == wxT("xpm") )
7dc3cc31
VS
182 {
183 wxFileType *fileType = new wxFileType;
427ff662 184 fileType->m_impl->SetFileType(wxT("image/xpm"));
7dc3cc31
VS
185 fileType->m_impl->SetExt(ext);
186 return fileType;
187 }
427ff662 188 else if ( ext == wxT("xbm") )
7dc3cc31
VS
189 {
190 wxFileType *fileType = new wxFileType;
427ff662 191 fileType->m_impl->SetFileType(wxT("image/xbm"));
7dc3cc31
VS
192 fileType->m_impl->SetExt(ext);
193 return fileType;
194 }
195
196 // unknown extension
197 return NULL;
198}
199
200// MIME type -> extension -> file type
201wxFileType *
202wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
203{
204 return NULL;
205}
206
207size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
208{
0fe3b231
GD
209 // VZ: don't know anything about this for Mac
210 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::EnumAllFileTypes() not yet implemented") );
7dc3cc31
VS
211
212 return 0;
213}
214
007ae8d0
GD
215wxFileType *
216wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
217{
0fe3b231 218 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
007ae8d0
GD
219
220 return NULL;
221}
f040060e
GD
222
223bool
224wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
225{
226 return FALSE;
227}
228