1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msdos/mimetype.h
3 // Purpose: classes and functions to manage MIME types
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
8 // Licence: wxWindows licence (part of wxExtra library)
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _MIMETYPE_IMPL_H
12 #define _MIMETYPE_IMPL_H
15 #include "wx/mimetype.h"
18 class wxMimeTypesManagerImpl
21 wxMimeTypesManagerImpl() { }
23 // load all data into memory - done when it is needed for the first time
24 void Initialize(int mailcapStyles
= wxMAILCAP_STANDARD
,
25 const wxString
& extraDir
= wxEmptyString
);
27 // and delete the data here
30 // implement containing class functions
31 wxFileType
*GetFileTypeFromExtension(const wxString
& ext
);
32 wxFileType
*GetOrAllocateFileTypeFromExtension(const wxString
& ext
) ;
33 wxFileType
*GetFileTypeFromMimeType(const wxString
& mimeType
);
35 size_t EnumAllFileTypes(wxArrayString
& mimetypes
);
37 void AddFallback(const wxFileTypeInfo
& ft
) { m_fallbacks
.Add(ft
); }
39 // create a new filetype association
40 wxFileType
*Associate(const wxFileTypeInfo
& ftInfo
);
42 bool Unassociate(wxFileType
*ft
);
44 // create a new filetype with the given name and extension
45 wxFileType
*CreateFileType(const wxString
& filetype
, const wxString
& ext
);
48 wxArrayFileTypeInfo m_fallbacks
;
54 // initialization functions
55 // this is used to construct a list of mimetypes which match;
56 // if built with GetFileTypeFromMimetype index 0 has the exact match and
57 // index 1 the type / * match
58 // if built with GetFileTypeFromExtension, index 0 has the mimetype for
59 // the first extension found, index 1 for the second and so on
61 void Init(wxMimeTypesManagerImpl
*manager
, size_t index
)
62 { m_manager
= manager
; m_index
.Add(index
); }
64 // initialize us with our file type name
65 void SetFileType(const wxString
& strFileType
)
66 { m_strFileType
= strFileType
; }
67 void SetExt(const wxString
& ext
)
70 // implement accessor functions
71 bool GetExtensions(wxArrayString
& extensions
);
72 bool GetMimeType(wxString
*mimeType
) const;
73 bool GetMimeTypes(wxArrayString
& mimeTypes
) const;
74 bool GetIcon(wxIconLocation
*iconLoc
) const;
75 bool GetDescription(wxString
*desc
) const;
76 bool GetOpenCommand(wxString
*openCmd
,
77 const wxFileType::MessageParameters
&) const
78 { return GetCommand(openCmd
, "open"); }
79 bool GetPrintCommand(wxString
*printCmd
,
80 const wxFileType::MessageParameters
&) const
81 { return GetCommand(printCmd
, "print"); }
83 size_t GetAllCommands(wxArrayString
* verbs
, wxArrayString
* commands
,
84 const wxFileType::MessageParameters
& params
) const;
86 // remove the record for this file type
87 // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
88 bool Unassociate(wxFileType
*ft
)
90 return m_manager
->Unassociate(ft
);
93 // set an arbitrary command, ask confirmation if it already exists and
94 // overwriteprompt is TRUE
95 bool SetCommand(const wxString
& cmd
, const wxString
& verb
, bool overwriteprompt
= TRUE
);
96 bool SetDefaultIcon(const wxString
& strIcon
= wxEmptyString
, int index
= 0);
100 bool GetCommand(wxString
*command
, const char *verb
) const;
102 wxMimeTypesManagerImpl
*m_manager
;
103 wxArrayInt m_index
; // in the wxMimeTypesManagerImpl arrays
104 wxString m_strFileType
, m_ext
;
110 /* vi: set cin tw=80 ts=4 sw=4: */