1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/core/mimetype.h
3 // Purpose: Mac implementation for wx mime-related classes
4 // Author: Neil Perkins
8 // Copyright: (C) 2010 Neil Perkins
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _MIMETYPE_IMPL_H
13 #define _MIMETYPE_IMPL_H
19 #include "wx/mimetype.h"
20 #include "wx/hashmap.h"
21 #include "wx/iconloc.h"
24 // This class implements mime type functionality for Mac OS X using UTIs and Launch Services
25 // Currently only the GetFileTypeFromXXXX public functions have been implemented
26 class WXDLLIMPEXP_BASE wxMimeTypesManagerImpl
30 wxMimeTypesManagerImpl();
31 virtual ~wxMimeTypesManagerImpl();
33 // These functions are not needed on Mac OS X and have no-op implementations
34 void Initialize(int mailcapStyles
= wxMAILCAP_STANDARD
, const wxString
& extraDir
= wxEmptyString
);
37 // Functions to look up types by ext, mime or UTI
38 wxFileType
*GetFileTypeFromExtension(const wxString
& ext
);
39 wxFileType
*GetFileTypeFromMimeType(const wxString
& mimeType
);
40 wxFileType
*GetFileTypeFromUti(const wxString
& uti
);
42 // These functions are only stubs on Mac OS X
43 size_t EnumAllFileTypes(wxArrayString
& mimetypes
);
44 wxFileType
*Associate(const wxFileTypeInfo
& ftInfo
);
45 bool Unassociate(wxFileType
*ft
);
49 // The work of querying the OS for type data is done in these two functions
50 void LoadTypeDataForUti(const wxString
& uti
);
51 void LoadDisplayDataForUti(const wxString
& uti
);
53 // These functions are pass-throughs from wxFileTypeImpl
54 bool GetExtensions(const wxString
& uti
, wxArrayString
& extensions
);
55 bool GetMimeType(const wxString
& uti
, wxString
*mimeType
);
56 bool GetMimeTypes(const wxString
& uti
, wxArrayString
& mimeTypes
);
57 bool GetIcon(const wxString
& uti
, wxIconLocation
*iconLoc
);
58 bool GetDescription(const wxString
& uti
, wxString
*desc
);
59 bool GetApplication(const wxString
& uti
, wxString
*command
);
61 // Structure to represent file types
62 typedef struct FileTypeData
64 wxArrayString extensions
;
65 wxArrayString mimeTypes
;
66 wxIconLocation iconLoc
;
73 WX_DECLARE_STRING_HASH_MAP( wxString
, TagMap
);
74 WX_DECLARE_STRING_HASH_MAP( FileTypeData
, UtiMap
);
81 friend class wxFileTypeImpl
;
85 // This class provides the interface between wxFileType and wxMimeTypesManagerImple for Mac OS X
86 // Currently only extension, mimetype, description and icon information is available
87 // All other methods have no-op implementation
88 class WXDLLIMPEXP_BASE wxFileTypeImpl
93 virtual ~wxFileTypeImpl();
95 bool GetExtensions(wxArrayString
& extensions
) const ;
96 bool GetMimeType(wxString
*mimeType
) const ;
97 bool GetMimeTypes(wxArrayString
& mimeTypes
) const ;
98 bool GetIcon(wxIconLocation
*iconLoc
) const ;
99 bool GetDescription(wxString
*desc
) const ;
100 bool GetOpenCommand(wxString
*openCmd
, const wxFileType::MessageParameters
& params
) const;
102 // These functions are only stubs on Mac OS X
103 bool GetPrintCommand(wxString
*printCmd
, const wxFileType::MessageParameters
& params
) const;
104 size_t GetAllCommands(wxArrayString
*verbs
, wxArrayString
*commands
, const wxFileType::MessageParameters
& params
) const;
105 bool SetCommand(const wxString
& cmd
, const wxString
& verb
, bool overwriteprompt
= TRUE
);
106 bool SetDefaultIcon(const wxString
& strIcon
= wxEmptyString
, int index
= 0);
107 bool Unassociate(wxFileType
*ft
);
111 // All that is needed to query type info - UTI and pointer to the manager
113 wxMimeTypesManagerImpl
* m_manager
;
115 friend class wxMimeTypesManagerImpl
;
118 #endif // wxUSE_MIMETYPE
119 #endif //_MIMETYPE_IMPL_H