]>
Commit | Line | Data |
---|---|---|
7dc3cc31 | 1 | ///////////////////////////////////////////////////////////////////////////// |
4d2976ad | 2 | // Name: wx/msw/mimetype.h |
7dc3cc31 VS |
3 | // Purpose: classes and functions to manage MIME types |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 23.09.98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
9 | // Licence: wxWindows license (part of wxExtra library) | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _MIMETYPE_IMPL_H | |
13 | #define _MIMETYPE_IMPL_H | |
14 | ||
15 | #ifdef __GNUG__ | |
a6c65e88 | 16 | #pragma interface "mimetype.h" |
7dc3cc31 VS |
17 | #endif |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
21 | #include "wx/mimetype.h" | |
22 | ||
a6c65e88 VZ |
23 | // ---------------------------------------------------------------------------- |
24 | // wxFileTypeImpl is the MSW version of wxFileType, this is a private class | |
25 | // and is never used directly by the application | |
26 | // ---------------------------------------------------------------------------- | |
7dc3cc31 VS |
27 | |
28 | class WXDLLEXPORT wxFileTypeImpl | |
29 | { | |
30 | public: | |
31 | // ctor | |
a6c65e88 | 32 | wxFileTypeImpl() { } |
7dc3cc31 VS |
33 | |
34 | // one of these Init() function must be called (ctor can't take any | |
35 | // arguments because it's common) | |
36 | ||
37 | // initialize us with our file type name and extension - in this case | |
38 | // we will read all other data from the registry | |
c7ce8392 | 39 | void Init(const wxString& strFileType, const wxString& ext); |
7dc3cc31 | 40 | |
7dc3cc31 VS |
41 | // implement accessor functions |
42 | bool GetExtensions(wxArrayString& extensions); | |
43 | bool GetMimeType(wxString *mimeType) const; | |
4d2976ad | 44 | bool GetMimeTypes(wxArrayString& mimeTypes) const; |
c7ce8392 | 45 | bool GetIcon(wxIcon *icon, wxString *sCommand = NULL, int *iIndex = NULL) const; |
7dc3cc31 VS |
46 | bool GetDescription(wxString *desc) const; |
47 | bool GetOpenCommand(wxString *openCmd, | |
48 | const wxFileType::MessageParameters& params) const; | |
49 | bool GetPrintCommand(wxString *printCmd, | |
50 | const wxFileType::MessageParameters& params) const; | |
51 | ||
c7ce8392 VZ |
52 | size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands, |
53 | const wxFileType::MessageParameters& params) const; | |
54 | ||
a6c65e88 VZ |
55 | bool Unassociate(); |
56 | ||
2b813b73 VZ |
57 | // set an arbitrary command, ask confirmation if it already exists and |
58 | // overwriteprompt is TRUE | |
59 | bool SetCommand(const wxString& cmd, | |
60 | const wxString& verb, | |
61 | bool overwriteprompt = TRUE); | |
62 | ||
c7ce8392 VZ |
63 | bool SetDefaultIcon(const wxString& cmd = wxEmptyString, int index = 0); |
64 | ||
2b813b73 VZ |
65 | // this is called by Associate |
66 | bool SetDescription (const wxString& desc); | |
c7ce8392 | 67 | |
7dc3cc31 VS |
68 | private: |
69 | // helper function: reads the command corresponding to the specified verb | |
70 | // from the registry (returns an empty string if not found) | |
71 | wxString GetCommand(const wxChar *verb) const; | |
72 | ||
c7ce8392 VZ |
73 | // get the registry path for the given verb |
74 | wxString GetVerbPath(const wxString& verb) const; | |
75 | ||
76 | // check that the registry key for our extension exists, create it if it | |
77 | // doesn't, return FALSE if this failed | |
78 | bool EnsureExtKeyExists(); | |
79 | ||
7dc3cc31 VS |
80 | wxString m_strFileType, // may be empty |
81 | m_ext; | |
2b813b73 VZ |
82 | |
83 | // these methods are not publicly accessible (as wxMimeTypesManager | |
84 | // doesn't know about them), and should only be called by Unassociate | |
85 | ||
86 | bool RemoveOpenCommand(); | |
87 | bool RemoveCommand(const wxString& verb); | |
88 | bool RemoveMimeType(); | |
89 | bool RemoveDefaultIcon(); | |
90 | bool RemoveDescription(); | |
7dc3cc31 VS |
91 | }; |
92 | ||
7dc3cc31 VS |
93 | class WXDLLEXPORT wxMimeTypesManagerImpl |
94 | { | |
95 | public: | |
96 | // nothing to do here, we don't load any data but just go and fetch it from | |
97 | // the registry when asked for | |
98 | wxMimeTypesManagerImpl() { } | |
99 | ||
100 | // implement containing class functions | |
101 | wxFileType *GetFileTypeFromExtension(const wxString& ext); | |
2b813b73 | 102 | wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext); |
7dc3cc31 VS |
103 | wxFileType *GetFileTypeFromMimeType(const wxString& mimeType); |
104 | ||
105 | size_t EnumAllFileTypes(wxArrayString& mimetypes); | |
106 | ||
33ac7e6f KB |
107 | // this are NOPs under Windows |
108 | bool ReadMailcap(const wxString& WXUNUSED(filename), bool WXUNUSED(fallback) = TRUE) | |
7dc3cc31 | 109 | { return TRUE; } |
33ac7e6f | 110 | bool ReadMimeTypes(const wxString& WXUNUSED(filename)) |
7dc3cc31 VS |
111 | { return TRUE; } |
112 | ||
a6c65e88 VZ |
113 | // create a new filetype association |
114 | wxFileType *Associate(const wxFileTypeInfo& ftInfo); | |
7dc3cc31 | 115 | |
c7ce8392 VZ |
116 | // create a new filetype with the given name and extension |
117 | wxFileType *CreateFileType(const wxString& filetype, const wxString& ext); | |
7dc3cc31 VS |
118 | }; |
119 | ||
120 | ||
121 | #endif | |
122 | //_MIMETYPE_IMPL_H | |
123 |