]>
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 | ||
49 | ||
50 | ||
51 | ||
52 | ||
53 | ||
54 | bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const | |
55 | { | |
56 | return FALSE; | |
57 | } | |
58 | ||
59 | // @@ this function is half implemented | |
60 | bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions) | |
61 | { | |
62 | return FALSE; | |
63 | } | |
64 | ||
65 | bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const | |
66 | { | |
67 | if ( m_strFileType.Length() > 0 ) | |
68 | { | |
69 | *mimeType = m_strFileType ; | |
70 | return TRUE ; | |
71 | } | |
72 | else | |
73 | return FALSE; | |
74 | } | |
75 | ||
76 | bool wxFileTypeImpl::GetIcon(wxIcon *icon) const | |
77 | { | |
78 | // no such file type or no value or incorrect icon entry | |
79 | return FALSE; | |
80 | } | |
81 | ||
82 | bool wxFileTypeImpl::GetDescription(wxString *desc) const | |
83 | { | |
84 | return FALSE; | |
85 | } | |
86 | ||
87 | // extension -> file type | |
88 | wxFileType * | |
89 | wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e) | |
90 | { | |
91 | wxString ext = e ; | |
92 | ext = ext.Lower() ; | |
93 | if ( ext == "txt" ) | |
94 | { | |
95 | wxFileType *fileType = new wxFileType; | |
96 | fileType->m_impl->SetFileType("text/text"); | |
97 | fileType->m_impl->SetExt(ext); | |
98 | return fileType; | |
99 | } | |
100 | else if ( ext == "htm" || ext == "html" ) | |
101 | { | |
102 | wxFileType *fileType = new wxFileType; | |
103 | fileType->m_impl->SetFileType("text/html"); | |
104 | fileType->m_impl->SetExt(ext); | |
105 | return fileType; | |
106 | } | |
107 | else if ( ext == "gif" ) | |
108 | { | |
109 | wxFileType *fileType = new wxFileType; | |
110 | fileType->m_impl->SetFileType("image/gif"); | |
111 | fileType->m_impl->SetExt(ext); | |
112 | return fileType; | |
113 | } | |
114 | else if ( ext == "png" ) | |
115 | { | |
116 | wxFileType *fileType = new wxFileType; | |
117 | fileType->m_impl->SetFileType("image/png"); | |
118 | fileType->m_impl->SetExt(ext); | |
119 | return fileType; | |
120 | } | |
121 | else if ( ext == "jpg" || ext == "jpeg" ) | |
122 | { | |
123 | wxFileType *fileType = new wxFileType; | |
124 | fileType->m_impl->SetFileType("image/jpeg"); | |
125 | fileType->m_impl->SetExt(ext); | |
126 | return fileType; | |
127 | } | |
128 | else if ( ext == "bmp" ) | |
129 | { | |
130 | wxFileType *fileType = new wxFileType; | |
131 | fileType->m_impl->SetFileType("image/bmp"); | |
132 | fileType->m_impl->SetExt(ext); | |
133 | return fileType; | |
134 | } | |
135 | else if ( ext == "tif" || ext == "tiff" ) | |
136 | { | |
137 | wxFileType *fileType = new wxFileType; | |
138 | fileType->m_impl->SetFileType("image/tiff"); | |
139 | fileType->m_impl->SetExt(ext); | |
140 | return fileType; | |
141 | } | |
142 | else if ( ext == "xpm" ) | |
143 | { | |
144 | wxFileType *fileType = new wxFileType; | |
145 | fileType->m_impl->SetFileType("image/xpm"); | |
146 | fileType->m_impl->SetExt(ext); | |
147 | return fileType; | |
148 | } | |
149 | else if ( ext == "xbm" ) | |
150 | { | |
151 | wxFileType *fileType = new wxFileType; | |
152 | fileType->m_impl->SetFileType("image/xbm"); | |
153 | fileType->m_impl->SetExt(ext); | |
154 | return fileType; | |
155 | } | |
156 | ||
157 | // unknown extension | |
158 | return NULL; | |
159 | } | |
160 | ||
161 | // MIME type -> extension -> file type | |
162 | wxFileType * | |
163 | wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType) | |
164 | { | |
165 | return NULL; | |
166 | } | |
167 | ||
168 | size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes) | |
169 | { | |
170 | wxFAIL_MSG( _T("TODO") ); // VZ: don't know anything about this for Mac | |
171 | ||
172 | return 0; | |
173 | } | |
174 |