]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/mimetype.h
cleanup
[wxWidgets.git] / include / wx / mac / carbon / mimetype.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/mimetype.h
3 // Purpose: Mac Carbon implementation for wx mime-related classes
4 // Author: Ryan Norton
5 // Modified by:
6 // Created: 04/16/2005
7 // RCS-ID: $Id$
8 // Copyright: (c) 2005 Ryan Norton (<wxprojects@comcast.net>)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _MIMETYPE_IMPL_H
13 #define _MIMETYPE_IMPL_H
14
15 #include "wx/defs.h"
16 #include "wx/mimetype.h"
17
18
19 class wxMimeTypesManagerImpl
20 {
21 public :
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(); }
26
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);
30
31 // and delete the data here
32 void ClearData();
33
34 // implement containing class functions
35 wxFileType *GetFileTypeFromExtension(const wxString& ext);
36 wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
37 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
38
39 size_t EnumAllFileTypes(wxArrayString& mimetypes);
40
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; }
44
45 void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
46
47 // create a new filetype association
48 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
49 // remove association
50 bool Unassociate(wxFileType *ft);
51
52 private:
53 wxArrayFileTypeInfo m_fallbacks;
54 void* m_hIC;
55 void** m_hDatabase;
56 long m_lCount;
57
58 void* pReserved1;
59 void* pReserved2;
60 void* pReserved3;
61 void* pReserved4;
62 void* pReserved5;
63 void* pReserved6;
64
65 friend class wxFileTypeImpl;
66 };
67
68 class wxFileTypeImpl
69 {
70 public:
71 //kind of nutty, but mimecmn.cpp creates one with an empty new
72 wxFileTypeImpl() : m_manager(NULL) {}
73 ~wxFileTypeImpl() {} //for those broken compilers
74
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;
85
86 size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
87 const wxFileType::MessageParameters& params) const;
88
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)
92 {
93 return m_manager->Unassociate(ft);
94 }
95
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);
100
101 private:
102 void Init(wxMimeTypesManagerImpl *manager, long lIndex)
103 { m_manager=(manager); m_lIndex=(lIndex); }
104
105 // helper function
106 wxString GetCommand(const wxString& verb) const;
107
108 wxMimeTypesManagerImpl *m_manager;
109 long m_lIndex;
110
111 void* pReserved1;
112 void* pReserved2;
113 void* pReserved3;
114 void* pReserved4;
115 void* pReserved5;
116 void* pReserved6;
117
118 friend class wxMimeTypesManagerImpl;
119 };
120
121 #endif
122 //_MIMETYPE_H