]>
Commit | Line | Data |
---|---|---|
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 | |
47 | class WXDLLEXPORT wxIcon; | |
48 | ||
f040060e GD |
49 | bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt) |
50 | { | |
51 | return FALSE; | |
52 | } | |
53 | ||
54 | bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index) | |
55 | { | |
56 | return FALSE; | |
57 | } | |
7dc3cc31 | 58 | |
7dc3cc31 VS |
59 | bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const |
60 | { | |
61 | return FALSE; | |
62 | } | |
63 | ||
64 | // @@ this function is half implemented | |
65 | bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions) | |
66 | { | |
67 | return FALSE; | |
68 | } | |
69 | ||
70 | bool 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 |
81 | bool 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 | ||
f040060e | 95 | bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString *sCommand, int *iIndex) const |
7dc3cc31 VS |
96 | { |
97 | // no such file type or no value or incorrect icon entry | |
98 | return FALSE; | |
99 | } | |
100 | ||
101 | bool wxFileTypeImpl::GetDescription(wxString *desc) const | |
102 | { | |
103 | return FALSE; | |
104 | } | |
105 | ||
f040060e GD |
106 | size_t |
107 | wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands, | |
108 | const wxFileType::MessageParameters& params) const | |
007ae8d0 | 109 | { |
f040060e GD |
110 | wxFAIL_MSG( _T("TODO") ); |
111 | return 0; | |
112 | } | |
113 | ||
114 | void | |
115 | wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir) | |
116 | { | |
117 | wxFAIL_MSG( _T("TODO") ); | |
118 | } | |
119 | ||
120 | void | |
121 | wxMimeTypesManagerImpl::ClearData() | |
122 | { | |
123 | wxFAIL_MSG( _T("TODO") ); | |
007ae8d0 GD |
124 | } |
125 | ||
7dc3cc31 VS |
126 | // extension -> file type |
127 | wxFileType * | |
128 | wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e) | |
129 | { | |
130 | wxString ext = e ; | |
131 | ext = ext.Lower() ; | |
132 | if ( ext == "txt" ) | |
133 | { | |
134 | wxFileType *fileType = new wxFileType; | |
135 | fileType->m_impl->SetFileType("text/text"); | |
136 | fileType->m_impl->SetExt(ext); | |
137 | return fileType; | |
138 | } | |
139 | else if ( ext == "htm" || ext == "html" ) | |
140 | { | |
141 | wxFileType *fileType = new wxFileType; | |
142 | fileType->m_impl->SetFileType("text/html"); | |
143 | fileType->m_impl->SetExt(ext); | |
144 | return fileType; | |
145 | } | |
146 | else if ( ext == "gif" ) | |
147 | { | |
148 | wxFileType *fileType = new wxFileType; | |
149 | fileType->m_impl->SetFileType("image/gif"); | |
150 | fileType->m_impl->SetExt(ext); | |
151 | return fileType; | |
152 | } | |
153 | else if ( ext == "png" ) | |
154 | { | |
155 | wxFileType *fileType = new wxFileType; | |
156 | fileType->m_impl->SetFileType("image/png"); | |
157 | fileType->m_impl->SetExt(ext); | |
158 | return fileType; | |
159 | } | |
160 | else if ( ext == "jpg" || ext == "jpeg" ) | |
161 | { | |
162 | wxFileType *fileType = new wxFileType; | |
163 | fileType->m_impl->SetFileType("image/jpeg"); | |
164 | fileType->m_impl->SetExt(ext); | |
165 | return fileType; | |
166 | } | |
167 | else if ( ext == "bmp" ) | |
168 | { | |
169 | wxFileType *fileType = new wxFileType; | |
170 | fileType->m_impl->SetFileType("image/bmp"); | |
171 | fileType->m_impl->SetExt(ext); | |
172 | return fileType; | |
173 | } | |
174 | else if ( ext == "tif" || ext == "tiff" ) | |
175 | { | |
176 | wxFileType *fileType = new wxFileType; | |
177 | fileType->m_impl->SetFileType("image/tiff"); | |
178 | fileType->m_impl->SetExt(ext); | |
179 | return fileType; | |
180 | } | |
181 | else if ( ext == "xpm" ) | |
182 | { | |
183 | wxFileType *fileType = new wxFileType; | |
184 | fileType->m_impl->SetFileType("image/xpm"); | |
185 | fileType->m_impl->SetExt(ext); | |
186 | return fileType; | |
187 | } | |
188 | else if ( ext == "xbm" ) | |
189 | { | |
190 | wxFileType *fileType = new wxFileType; | |
191 | fileType->m_impl->SetFileType("image/xbm"); | |
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 | |
201 | wxFileType * | |
202 | wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType) | |
203 | { | |
204 | return NULL; | |
205 | } | |
206 | ||
207 | size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes) | |
208 | { | |
209 | wxFAIL_MSG( _T("TODO") ); // VZ: don't know anything about this for Mac | |
210 | ||
211 | return 0; | |
212 | } | |
213 | ||
007ae8d0 GD |
214 | wxFileType * |
215 | wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo) | |
216 | { | |
217 | wxFAIL_MSG( _T("TODO") ); | |
218 | ||
219 | return NULL; | |
220 | } | |
f040060e GD |
221 | |
222 | bool | |
223 | wxMimeTypesManagerImpl::Unassociate(wxFileType *ft) | |
224 | { | |
225 | return FALSE; | |
226 | } | |
227 |