X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7dc3cc31af71522b8fc55b7f97bcba7f5ef9eac5..c13cace12594b37706e9520a6fbd602c949f8127:/src/msw/mimetype.cpp diff --git a/src/msw/mimetype.cpp b/src/msw/mimetype.cpp index 7d09acec8b..4ca0315ec2 100644 --- a/src/msw/mimetype.cpp +++ b/src/msw/mimetype.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: common/mimetype.cpp +// Name: msw/mimetype.cpp // Purpose: classes and functions to manage MIME types // Author: Vadim Zeitlin // Modified by: @@ -20,11 +20,8 @@ #pragma hdrstop #endif -#ifndef WX_PRECOMP - #include "wx/defs.h" -#endif - -#if (wxUSE_FILE && wxUSE_TEXTFILE) || defined(__WXMSW__) +// Doesn't compile in WIN16 mode +#ifndef __WIN16__ #ifndef WX_PRECOMP #include "wx/string.h" @@ -33,9 +30,6 @@ #endif #endif //WX_PRECOMP -// Doesn't compile in WIN16 mode -#ifndef __WIN16__ - #include "wx/log.h" #include "wx/file.h" #include "wx/intl.h" @@ -45,12 +39,6 @@ #ifdef __WXMSW__ #include "wx/msw/registry.h" #include "windows.h" -#elif defined(__UNIX__) || defined(__WXPM__) - #include "wx/ffile.h" - #include "wx/textfile.h" - #include "wx/dir.h" - #include "wx/utils.h" - #include "wx/tokenzr.h" #endif // OS #include "wx/msw/mimetype.h" @@ -61,7 +49,6 @@ // in case we're compiling in non-GUI mode class WXDLLEXPORT wxIcon; - // These classes use Windows registry to retrieve the required information. // // Keys used (not all of them are documented, so it might actually stop working @@ -86,9 +73,6 @@ class WXDLLEXPORT wxIcon; // location, uses it, so it isn't likely to change static const wxChar *MIME_DATABASE_KEY = wxT("MIME\\Database\\Content Type\\"); - - - wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const { // suppress possible error messages @@ -133,6 +117,7 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const } } +#if wxUSE_IPC // look whether we must issue some DDE requests to the application // (and not just launch it) strKey += _T("\\DDEExec"); @@ -155,7 +140,9 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const << _T('#') << ddeTopic << _T('#') << ddeCommand; } - else if ( !foundFilename ) { + else +#endif // wxUSE_IPC + if ( !foundFilename ) { // we didn't find any '%1' - the application doesn't know which // file to open (note that we only do it if there is no DDEExec // subkey) @@ -240,14 +227,26 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const // suppress possible error messages wxLogNull nolog; wxRegKey key(wxRegKey::HKCR, wxT(".") + m_ext); - if ( key.Open() && key.QueryValue(wxT("Content Type"), *mimeType) ) { - return TRUE; - } - else { + + return key.Open() && key.QueryValue(wxT("Content Type"), *mimeType); +} + + +bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const +{ + wxString s; + + if ( !GetMimeType(&s) ) + { return FALSE; } + + mimeTypes.Clear(); + mimeTypes.Add(s); + return TRUE; } + bool wxFileTypeImpl::GetIcon(wxIcon *icon) const { #if wxUSE_GUI @@ -375,18 +374,16 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext) } } - if ( knownExtension ) - { - wxFileType *fileType = new wxFileType; - fileType->m_impl->Init(wxEmptyString, ext); - - return fileType; - } - else + if ( !knownExtension ) { // unknown extension return NULL; } + + wxFileType *fileType = new wxFileType; + fileType->m_impl->Init(wxEmptyString, ext); + + return fileType; } // MIME type -> extension -> file type @@ -444,8 +441,5 @@ size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes) } -#endif - // wxUSE_FILE && wxUSE_TEXTFILE - #endif // __WIN16__