]> git.saurik.com Git - wxWidgets.git/blob - src/msdos/mimetype.cpp
set error to GSOCK_TIMEOUT if the socket timed out (modified and extended patch 1303554)
[wxWidgets.git] / src / msdos / mimetype.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 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/defs.h"
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 #if wxUSE_MIMETYPE
31
32 #include "wx/log.h"
33 #include "wx/file.h"
34 #include "wx/intl.h"
35 #include "wx/dynarray.h"
36 #include "wx/confbase.h"
37
38 #include "wx/msdos/mimetype.h"
39
40 // other standard headers
41 #include <ctype.h>
42
43 // in case we're compiling in non-GUI mode
44 class WXDLLEXPORT wxIcon;
45
46 bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
47 {
48 return FALSE;
49 }
50
51 bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
52 {
53 return FALSE;
54 }
55
56 bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
57 {
58 return FALSE;
59 }
60
61 // @@ this function is half implemented
62 bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
63 {
64 return FALSE;
65 }
66
67 bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
68 {
69 if ( m_strFileType.Length() > 0 )
70 {
71 *mimeType = m_strFileType ;
72 return TRUE ;
73 }
74 else
75 return FALSE;
76 }
77
78 bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
79 {
80 wxString s;
81
82 if (GetMimeType(&s))
83 {
84 mimeTypes.Clear();
85 mimeTypes.Add(s);
86 return TRUE;
87 }
88 else
89 return FALSE;
90 }
91
92 bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
93 {
94 // no such file type or no value or incorrect icon entry
95 return FALSE;
96 }
97
98 bool wxFileTypeImpl::GetDescription(wxString *desc) const
99 {
100 return FALSE;
101 }
102
103 size_t
104 wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
105 const wxFileType::MessageParameters& params) const
106 {
107 wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
108 return 0;
109 }
110
111 void
112 wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
113 {
114 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
115 }
116
117 void
118 wxMimeTypesManagerImpl::ClearData()
119 {
120 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
121 }
122
123 // extension -> file type
124 wxFileType *
125 wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
126 {
127 wxString ext = e ;
128 ext = ext.Lower() ;
129 if ( ext == wxT("txt") )
130 {
131 wxFileType *fileType = new wxFileType;
132 fileType->m_impl->SetFileType(wxT("text/text"));
133 fileType->m_impl->SetExt(ext);
134 return fileType;
135 }
136 else if ( ext == wxT("htm") || ext == wxT("html") )
137 {
138 wxFileType *fileType = new wxFileType;
139 fileType->m_impl->SetFileType(wxT("text/html"));
140 fileType->m_impl->SetExt(ext);
141 return fileType;
142 }
143 else if ( ext == wxT("gif") )
144 {
145 wxFileType *fileType = new wxFileType;
146 fileType->m_impl->SetFileType(wxT("image/gif"));
147 fileType->m_impl->SetExt(ext);
148 return fileType;
149 }
150 else if ( ext == wxT("png" ))
151 {
152 wxFileType *fileType = new wxFileType;
153 fileType->m_impl->SetFileType(wxT("image/png"));
154 fileType->m_impl->SetExt(ext);
155 return fileType;
156 }
157 else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") )
158 {
159 wxFileType *fileType = new wxFileType;
160 fileType->m_impl->SetFileType(wxT("image/jpeg"));
161 fileType->m_impl->SetExt(ext);
162 return fileType;
163 }
164 else if ( ext == wxT("bmp") )
165 {
166 wxFileType *fileType = new wxFileType;
167 fileType->m_impl->SetFileType(wxT("image/bmp"));
168 fileType->m_impl->SetExt(ext);
169 return fileType;
170 }
171 else if ( ext == wxT("tif") || ext == wxT("tiff") )
172 {
173 wxFileType *fileType = new wxFileType;
174 fileType->m_impl->SetFileType(wxT("image/tiff"));
175 fileType->m_impl->SetExt(ext);
176 return fileType;
177 }
178 else if ( ext == wxT("xpm") )
179 {
180 wxFileType *fileType = new wxFileType;
181 fileType->m_impl->SetFileType(wxT("image/xpm"));
182 fileType->m_impl->SetExt(ext);
183 return fileType;
184 }
185 else if ( ext == wxT("xbm") )
186 {
187 wxFileType *fileType = new wxFileType;
188 fileType->m_impl->SetFileType(wxT("image/xbm"));
189 fileType->m_impl->SetExt(ext);
190 return fileType;
191 }
192
193 // unknown extension
194 return NULL;
195 }
196
197 // MIME type -> extension -> file type
198 wxFileType *
199 wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
200 {
201 return NULL;
202 }
203
204 size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
205 {
206 // VZ: don't know anything about this for Mac
207 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::EnumAllFileTypes() not yet implemented") );
208
209 return 0;
210 }
211
212 wxFileType *
213 wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
214 {
215 wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
216
217 return NULL;
218 }
219
220 bool
221 wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
222 {
223 return FALSE;
224 }
225
226 #endif // wxUSE_MIMETYPE