X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7dc3cc31af71522b8fc55b7f97bcba7f5ef9eac5..7e99520bd3fc092bbbcbc38bb699a0236618ea40:/src/common/mimecmn.cpp?ds=sidebyside diff --git a/src/common/mimecmn.cpp b/src/common/mimecmn.cpp index 9dedb8ec86..7a773543f0 100644 --- a/src/common/mimecmn.cpp +++ b/src/common/mimecmn.cpp @@ -15,6 +15,7 @@ // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#include "wx/module.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -68,6 +69,8 @@ class WXDLLEXPORT wxIcon; #include "wx/msw/mimetype.h" #elif defined (__WXMAC__) #include "wx/mac/mimetype.h" +#elif defined (__WXPM__) +#include "wx/os2/mimetype.h" #else #include "wx/unix/mimetype.h" #endif @@ -155,8 +158,7 @@ wxString wxFileType::ExpandCommand(const wxString& command, const wxChar *pEnd = wxStrchr(pc, wxT('}')); if ( pEnd == NULL ) { wxString mimetype; - wxLogWarning(_("Unmatched '{' in an entry for " - "mime type %s."), + wxLogWarning(_("Unmatched '{' in an entry for mime type %s."), params.GetMimeType().c_str()); str << wxT("%{"); } @@ -187,8 +189,16 @@ wxString wxFileType::ExpandCommand(const wxString& command, } // metamail(1) man page states that if the mailcap entry doesn't have '%s' - // the program will accept the data on stdin: so give it to it! - if ( !hasFilename && !str.IsEmpty() ) { + // the program will accept the data on stdin so normally we should append + // "< %s" to the end of the command in such case, but not all commands + // behave like this, in particular a common test is 'test -n "$DISPLAY"' + // and appending "< %s" to this command makes the test fail... I don't + // know of the correct solution, try to guess what we have to do. + if ( !hasFilename && !str.IsEmpty() +#ifdef __UNIX__ + && !str.StartsWith(_T("test ")) +#endif // Unix + ) { str << wxT(" < '") << params.GetFileName() << wxT('\''); } @@ -215,6 +225,11 @@ bool wxFileType::GetMimeType(wxString *mimeType) const return m_impl->GetMimeType(mimeType); } +bool wxFileType::GetMimeTypes(wxArrayString& mimeTypes) const +{ + return m_impl->GetMimeTypes(mimeTypes); +} + bool wxFileType::GetIcon(wxIcon *icon) const { return m_impl->GetIcon(icon); @@ -334,6 +349,29 @@ static wxMimeTypesManager gs_mimeTypesManager; wxMimeTypesManager * wxTheMimeTypesManager = &gs_mimeTypesManager; + + + +class wxMimeTypeCmnModule: public wxModule +{ +DECLARE_DYNAMIC_CLASS(wxMimeTypeCmnModule) +public: + wxMimeTypeCmnModule() : wxModule() {} + bool OnInit() { return TRUE; } + void OnExit() + { // this avoids false memory leak allerts: + if (gs_mimeTypesManager.m_impl != NULL) + { + delete gs_mimeTypesManager.m_impl; + gs_mimeTypesManager.m_impl = NULL; + } + } +}; + +IMPLEMENT_DYNAMIC_CLASS(wxMimeTypeCmnModule, wxModule) + + + #endif // wxUSE_FILE && wxUSE_TEXTFILE