]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/mimetmac.cpp
add version checks instead of symbol checks, so that CW builds do not complain on...
[wxWidgets.git] / src / mac / carbon / mimetmac.cpp
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 licence (part of wxExtra library)
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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/string.h"
25 #if wxUSE_GUI
26 #include "wx/icon.h"
27 #endif
28 #endif //WX_PRECOMP
29
30
31 #if wxUSE_MIMETYPE
32
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
45 class WXDLLEXPORT wxIcon;
46
47 bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
48 {
49 return FALSE;
50 }
51
52 bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
53 {
54 return FALSE;
55 }
56
57 bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
58 {
59 return FALSE;
60 }
61
62 // @@ this function is half implemented
63 bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
64 {
65 return FALSE;
66 }
67
68 bool 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
79 bool 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
93 bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
94 {
95 // no such file type or no value or incorrect icon entry
96 return FALSE;
97 }
98
99 bool wxFileTypeImpl::GetDescription(wxString *desc) const
100 {
101 return FALSE;
102 }
103
104 size_t
105 wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
106 const wxFileType::MessageParameters& params) const
107 {
108 wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
109 return 0;
110 }
111
112 void
113 wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
114 {
115 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
116 }
117
118 void
119 wxMimeTypesManagerImpl::ClearData()
120 {
121 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
122 }
123
124 // extension -> file type
125 wxFileType *
126 wxMimeTypesManagerImpl::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
199 wxFileType *
200 wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
201 {
202 return NULL;
203 }
204
205 size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
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
213 wxFileType *
214 wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
215 {
216 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
217
218 return NULL;
219 }
220
221 bool
222 wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
223 {
224 return FALSE;
225 }
226
227 #endif //wxUSE_MIMETYPE