1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/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 #pragma interface "mimetype.h"
23 #include "wx/mimetype.h"
25 // ----------------------------------------------------------------------------
26 // wxFileTypeImpl is the MSW version of wxFileType, this is a private class
27 // and is never used directly by the application
28 // ----------------------------------------------------------------------------
30 class WXDLLEXPORT wxFileTypeImpl
36 // one of these Init() function must be called (ctor can't take any
37 // arguments because it's common)
39 // initialize us with our file type name and extension - in this case
40 // we will read all other data from the registry
41 void Init(const wxString
& strFileType
, const wxString
& ext
);
43 // implement accessor functions
44 bool GetExtensions(wxArrayString
& extensions
);
45 bool GetMimeType(wxString
*mimeType
) const;
46 bool GetMimeTypes(wxArrayString
& mimeTypes
) const;
47 bool GetIcon(wxIcon
*icon
, wxString
*sCommand
= NULL
, int *iIndex
= NULL
,
48 int iconSize
= wxICON_LARGE
) const;
49 bool GetDescription(wxString
*desc
) const;
50 bool GetOpenCommand(wxString
*openCmd
,
51 const wxFileType::MessageParameters
& params
) const;
52 bool GetPrintCommand(wxString
*printCmd
,
53 const wxFileType::MessageParameters
& params
) const;
55 size_t GetAllCommands(wxArrayString
* verbs
, wxArrayString
* commands
,
56 const wxFileType::MessageParameters
& params
) const;
60 // set an arbitrary command, ask confirmation if it already exists and
61 // overwriteprompt is TRUE
62 bool SetCommand(const wxString
& cmd
,
64 bool overwriteprompt
= TRUE
);
66 bool SetDefaultIcon(const wxString
& cmd
= wxEmptyString
, int index
= 0);
68 // this is called by Associate
69 bool SetDescription (const wxString
& desc
);
72 // helper function: reads the command corresponding to the specified verb
73 // from the registry (returns an empty string if not found)
74 wxString
GetCommand(const wxChar
*verb
) const;
76 // get the registry path for the given verb
77 wxString
GetVerbPath(const wxString
& verb
) const;
79 // check that the registry key for our extension exists, create it if it
80 // doesn't, return FALSE if this failed
81 bool EnsureExtKeyExists();
83 wxString m_strFileType
, // may be empty
86 // these methods are not publicly accessible (as wxMimeTypesManager
87 // doesn't know about them), and should only be called by Unassociate
89 bool RemoveOpenCommand();
90 bool RemoveCommand(const wxString
& verb
);
91 bool RemoveMimeType();
92 bool RemoveDefaultIcon();
93 bool RemoveDescription();
96 class WXDLLEXPORT wxMimeTypesManagerImpl
99 // nothing to do here, we don't load any data but just go and fetch it from
100 // the registry when asked for
101 wxMimeTypesManagerImpl() { }
103 // implement containing class functions
104 wxFileType
*GetFileTypeFromExtension(const wxString
& ext
);
105 wxFileType
*GetOrAllocateFileTypeFromExtension(const wxString
& ext
);
106 wxFileType
*GetFileTypeFromMimeType(const wxString
& mimeType
);
108 size_t EnumAllFileTypes(wxArrayString
& mimetypes
);
110 // this are NOPs under Windows
111 bool ReadMailcap(const wxString
& WXUNUSED(filename
), bool WXUNUSED(fallback
) = TRUE
)
113 bool ReadMimeTypes(const wxString
& WXUNUSED(filename
))
116 // create a new filetype association
117 wxFileType
*Associate(const wxFileTypeInfo
& ftInfo
);
119 // create a new filetype with the given name and extension
120 wxFileType
*CreateFileType(const wxString
& filetype
, const wxString
& ext
);
123 #endif // wxUSE_MIMETYPE