1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/mimetype.h
3 // Purpose: Mac Carbon implementation for wx mime-related classes
8 // Copyright: (c) 2005 Ryan Norton (<wxprojects@comcast.net>)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _MIMETYPE_IMPL_H
13 #define _MIMETYPE_IMPL_H
16 #include "wx/mimetype.h"
19 class wxMimeTypesManagerImpl
22 //kinda kooky but in wxMimeTypesManager::EnsureImpl it doesn't call
23 //intialize, so we do it ourselves
24 wxMimeTypesManagerImpl() : m_hIC(NULL
) { Initialize(); }
25 ~wxMimeTypesManagerImpl() { ClearData(); }
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
);
53 wxArrayFileTypeInfo m_fallbacks
;
65 friend class wxFileTypeImpl
;
71 //kind of nutty, but mimecmn.cpp creates one with an empty new
72 wxFileTypeImpl() : m_manager(NULL
) {}
73 ~wxFileTypeImpl() {} //for those broken compilers
75 // implement accessor functions
76 bool GetExtensions(wxArrayString
& extensions
);
77 bool GetMimeType(wxString
*mimeType
) const;
78 bool GetMimeTypes(wxArrayString
& mimeTypes
) const;
79 bool GetIcon(wxIconLocation
*iconLoc
) const;
80 bool GetDescription(wxString
*desc
) const;
81 bool GetOpenCommand(wxString
*openCmd
,
82 const wxFileType::MessageParameters
&) const;
83 bool GetPrintCommand(wxString
*printCmd
,
84 const wxFileType::MessageParameters
&) const;
86 size_t GetAllCommands(wxArrayString
* verbs
, wxArrayString
* commands
,
87 const wxFileType::MessageParameters
& params
) const;
89 // remove the record for this file type
90 // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
91 bool Unassociate(wxFileType
*ft
)
93 return m_manager
->Unassociate(ft
);
96 // set an arbitrary command, ask confirmation if it already exists and
97 // overwriteprompt is TRUE
98 bool SetCommand(const wxString
& cmd
, const wxString
& verb
, bool overwriteprompt
= TRUE
);
99 bool SetDefaultIcon(const wxString
& strIcon
= wxEmptyString
, int index
= 0);
102 void Init(wxMimeTypesManagerImpl
*manager
, long lIndex
)
103 { m_manager
=(manager
); m_lIndex
=(lIndex
); }
106 wxString
GetCommand(const wxString
& verb
) const;
108 wxMimeTypesManagerImpl
*m_manager
;
118 friend class wxMimeTypesManagerImpl
;