1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/mimetype.h
3 // Purpose: classes and functions to manage MIME types
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence (part of wxExtra library)
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _MIMETYPE_IMPL_H
13 #define _MIMETYPE_IMPL_H
16 #include "wx/mimetype.h"
19 class wxMimeTypesManagerImpl
22 wxMimeTypesManagerImpl() { }
24 ~wxMimeTypesManagerImpl() { }
27 // load all data into memory - done when it is needed for the first time
28 void Initialize(int mailcapStyles
= wxMAILCAP_STANDARD
,
29 const wxString
& extraDir
= wxEmptyString
);
31 // and delete the data here
34 // implement containing class functions
35 wxFileType
*GetFileTypeFromExtension(const wxString
& ext
);
36 wxFileType
*GetOrAllocateFileTypeFromExtension(const wxString
& ext
) ;
37 wxFileType
*GetFileTypeFromMimeType(const wxString
& mimeType
);
39 size_t EnumAllFileTypes(wxArrayString
& mimetypes
);
41 // this are NOPs under MacOS
42 bool ReadMailcap(const wxString
& WXUNUSED(filename
), bool WXUNUSED(fallback
) = TRUE
) { return TRUE
; }
43 bool ReadMimeTypes(const wxString
& WXUNUSED(filename
)) { return TRUE
; }
45 void AddFallback(const wxFileTypeInfo
& ft
) { m_fallbacks
.Add(ft
); }
47 // create a new filetype association
48 wxFileType
*Associate(const wxFileTypeInfo
& ftInfo
);
50 bool Unassociate(wxFileType
*ft
);
52 // create a new filetype with the given name and extension
53 wxFileType
*CreateFileType(const wxString
& filetype
, const wxString
& ext
);
56 wxArrayFileTypeInfo m_fallbacks
;
62 // initialization functions
63 // this is used to construct a list of mimetypes which match;
64 // if built with GetFileTypeFromMimetype index 0 has the exact match and
65 // index 1 the type / * match
66 // if built with GetFileTypeFromExtension, index 0 has the mimetype for
67 // the first extension found, index 1 for the second and so on
69 void Init(wxMimeTypesManagerImpl
*manager
, size_t index
)
70 { m_manager
= manager
; m_index
.Add(index
); }
72 // initialize us with our file type name
73 void SetFileType(const wxString
& strFileType
)
74 { m_strFileType
= strFileType
; }
75 void SetExt(const wxString
& ext
)
78 // implement accessor functions
79 bool GetExtensions(wxArrayString
& extensions
);
80 bool GetMimeType(wxString
*mimeType
) const;
81 bool GetMimeTypes(wxArrayString
& mimeTypes
) const;
82 bool GetIcon(wxIconLocation
*iconLoc
) const;
83 bool GetDescription(wxString
*desc
) const;
84 bool GetOpenCommand(wxString
*openCmd
,
85 const wxFileType::MessageParameters
&) const
86 { return GetCommand(openCmd
, "open"); }
87 bool GetPrintCommand(wxString
*printCmd
,
88 const wxFileType::MessageParameters
&) const
89 { return GetCommand(printCmd
, "print"); }
91 size_t GetAllCommands(wxArrayString
* verbs
, wxArrayString
* commands
,
92 const wxFileType::MessageParameters
& params
) const;
94 // remove the record for this file type
95 // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
96 bool Unassociate(wxFileType
*ft
)
98 return m_manager
->Unassociate(ft
);
101 // set an arbitrary command, ask confirmation if it already exists and
102 // overwriteprompt is TRUE
103 bool SetCommand(const wxString
& cmd
, const wxString
& verb
, bool overwriteprompt
= TRUE
);
104 bool SetDefaultIcon(const wxString
& strIcon
= wxEmptyString
, int index
= 0);
108 bool GetCommand(wxString
*command
, const char *verb
) const;
110 wxMimeTypesManagerImpl
*m_manager
;
111 wxArrayInt m_index
; // in the wxMimeTypesManagerImpl arrays
112 wxString m_strFileType
, m_ext
;
118 /* vi: set cin tw=80 ts=4 sw=4: */