]>
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> | |
371a5b4e | 9 | // Licence: wxWindows licence (part of wxExtra library) |
7dc3cc31 VS |
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 | ||
1e6feb95 VZ |
21 | #if wxUSE_MIMETYPE |
22 | ||
7dc3cc31 VS |
23 | #include "wx/mimetype.h" |
24 | ||
a6c65e88 VZ |
25 | // ---------------------------------------------------------------------------- |
26 | // wxFileTypeImpl is the MSW version of wxFileType, this is a private class | |
27 | // and is never used directly by the application | |
28 | // ---------------------------------------------------------------------------- | |
7dc3cc31 VS |
29 | |
30 | class WXDLLEXPORT wxFileTypeImpl | |
31 | { | |
32 | public: | |
33 | // ctor | |
a6c65e88 | 34 | wxFileTypeImpl() { } |
7dc3cc31 VS |
35 | |
36 | // one of these Init() function must be called (ctor can't take any | |
37 | // arguments because it's common) | |
38 | ||
39 | // initialize us with our file type name and extension - in this case | |
40 | // we will read all other data from the registry | |
c7ce8392 | 41 | void Init(const wxString& strFileType, const wxString& ext); |
7dc3cc31 | 42 | |
7dc3cc31 VS |
43 | // implement accessor functions |
44 | bool GetExtensions(wxArrayString& extensions); | |
45 | bool GetMimeType(wxString *mimeType) const; | |
4d2976ad | 46 | bool GetMimeTypes(wxArrayString& mimeTypes) const; |
5c5428f9 JS |
47 | bool GetIcon(wxIcon *icon, wxString *sCommand = NULL, int *iIndex = NULL, |
48 | int iconSize = wxICON_LARGE) const; | |
7dc3cc31 VS |
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; | |
54 | ||
c7ce8392 VZ |
55 | size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands, |
56 | const wxFileType::MessageParameters& params) const; | |
57 | ||
a6c65e88 VZ |
58 | bool Unassociate(); |
59 | ||
2b813b73 VZ |
60 | // set an arbitrary command, ask confirmation if it already exists and |
61 | // overwriteprompt is TRUE | |
62 | bool SetCommand(const wxString& cmd, | |
63 | const wxString& verb, | |
64 | bool overwriteprompt = TRUE); | |
65 | ||
c7ce8392 VZ |
66 | bool SetDefaultIcon(const wxString& cmd = wxEmptyString, int index = 0); |
67 | ||
2b813b73 VZ |
68 | // this is called by Associate |
69 | bool SetDescription (const wxString& desc); | |
c7ce8392 | 70 | |
7dc3cc31 VS |
71 | private: |
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; | |
75 | ||
c7ce8392 VZ |
76 | // get the registry path for the given verb |
77 | wxString GetVerbPath(const wxString& verb) const; | |
78 | ||
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(); | |
82 | ||
7dc3cc31 VS |
83 | wxString m_strFileType, // may be empty |
84 | m_ext; | |
2b813b73 VZ |
85 | |
86 | // these methods are not publicly accessible (as wxMimeTypesManager | |
87 | // doesn't know about them), and should only be called by Unassociate | |
88 | ||
89 | bool RemoveOpenCommand(); | |
90 | bool RemoveCommand(const wxString& verb); | |
91 | bool RemoveMimeType(); | |
92 | bool RemoveDefaultIcon(); | |
93 | bool RemoveDescription(); | |
7dc3cc31 VS |
94 | }; |
95 | ||
7dc3cc31 VS |
96 | class WXDLLEXPORT wxMimeTypesManagerImpl |
97 | { | |
98 | public: | |
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() { } | |
102 | ||
103 | // implement containing class functions | |
104 | wxFileType *GetFileTypeFromExtension(const wxString& ext); | |
2b813b73 | 105 | wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext); |
7dc3cc31 VS |
106 | wxFileType *GetFileTypeFromMimeType(const wxString& mimeType); |
107 | ||
108 | size_t EnumAllFileTypes(wxArrayString& mimetypes); | |
109 | ||
33ac7e6f KB |
110 | // this are NOPs under Windows |
111 | bool ReadMailcap(const wxString& WXUNUSED(filename), bool WXUNUSED(fallback) = TRUE) | |
7dc3cc31 | 112 | { return TRUE; } |
33ac7e6f | 113 | bool ReadMimeTypes(const wxString& WXUNUSED(filename)) |
7dc3cc31 VS |
114 | { return TRUE; } |
115 | ||
a6c65e88 VZ |
116 | // create a new filetype association |
117 | wxFileType *Associate(const wxFileTypeInfo& ftInfo); | |
7dc3cc31 | 118 | |
c7ce8392 VZ |
119 | // create a new filetype with the given name and extension |
120 | wxFileType *CreateFileType(const wxString& filetype, const wxString& ext); | |
7dc3cc31 VS |
121 | }; |
122 | ||
1e6feb95 | 123 | #endif // wxUSE_MIMETYPE |
7dc3cc31 VS |
124 | |
125 | #endif | |
126 | //_MIMETYPE_IMPL_H | |
127 |