]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/mimetype.h
Committing in .
[wxWidgets.git] / include / wx / msw / mimetype.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/mimetype.h
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 licence (part of wxExtra library)
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _MIMETYPE_IMPL_H
13 #define _MIMETYPE_IMPL_H
14
15 #ifdef __GNUG__
16 #pragma interface "mimetype.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_MIMETYPE
22
23 #include "wx/mimetype.h"
24
25 // ----------------------------------------------------------------------------
26 // wxFileTypeImpl is the MSW version of wxFileType, this is a private class
27 // and is never used directly by the application
28 // ----------------------------------------------------------------------------
29
30 class WXDLLEXPORT wxFileTypeImpl
31 {
32 public:
33 // ctor
34 wxFileTypeImpl() { }
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
41 void Init(const wxString& strFileType, const wxString& ext);
42
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;
54
55 size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
56 const wxFileType::MessageParameters& params) const;
57
58 bool Unassociate();
59
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
66 bool SetDefaultIcon(const wxString& cmd = wxEmptyString, int index = 0);
67
68 // this is called by Associate
69 bool SetDescription (const wxString& desc);
70
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
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
83 wxString m_strFileType, // may be empty
84 m_ext;
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();
94 };
95
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);
105 wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext);
106 wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
107
108 size_t EnumAllFileTypes(wxArrayString& mimetypes);
109
110 // this are NOPs under Windows
111 bool ReadMailcap(const wxString& WXUNUSED(filename), bool WXUNUSED(fallback) = TRUE)
112 { return TRUE; }
113 bool ReadMimeTypes(const wxString& WXUNUSED(filename))
114 { return TRUE; }
115
116 // create a new filetype association
117 wxFileType *Associate(const wxFileTypeInfo& ftInfo);
118
119 // create a new filetype with the given name and extension
120 wxFileType *CreateFileType(const wxString& filetype, const wxString& ext);
121 };
122
123 #endif // wxUSE_MIMETYPE
124
125 #endif
126 //_MIMETYPE_IMPL_H
127