X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/525d858363f08a3d774b494bd8df19e4ab7c9dc0..82df62ef8e55adf38221afc82439edeed4fe3368:/src/common/mimecmn.cpp diff --git a/src/common/mimecmn.cpp b/src/common/mimecmn.cpp index 4d251a8dc5..db1cf082f3 100644 --- a/src/common/mimecmn.cpp +++ b/src/common/mimecmn.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: common/mimecmn.cpp +// Name: src/common/mimecmn.cpp // Purpose: classes and functions to manage MIME types // Author: Vadim Zeitlin // Modified by: @@ -18,10 +18,6 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ - #pragma implementation "mimetypebase.h" -#endif - // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -31,20 +27,20 @@ #if wxUSE_MIMETYPE +#include "wx/mimetype.h" + #ifndef WX_PRECOMP - #include "wx/string.h" + #include "wx/dynarray.h" + #include "wx/string.h" + #include "wx/intl.h" + #include "wx/log.h" + #include "wx/module.h" #endif //WX_PRECOMP -#include "wx/module.h" -#include "wx/log.h" #include "wx/file.h" #include "wx/iconloc.h" -#include "wx/intl.h" -#include "wx/dynarray.h" #include "wx/confbase.h" -#include "wx/mimetype.h" - // other standard headers #include @@ -56,6 +52,8 @@ #elif defined(__WXPM__) || defined (__EMX__) #include "wx/os2/mimetype.h" #undef __UNIX__ +#elif defined(__DOS__) + #include "wx/msdos/mimetype.h" #else // Unix #include "wx/unix/mimetype.h" #endif @@ -83,7 +81,17 @@ wxFileTypeInfo::wxFileTypeInfo(const wxChar *mimeType, for ( ;; ) { + // icc gives this warning in its own va_arg() macro, argh +#ifdef __INTELC__ + #pragma warning(push) + #pragma warning(disable: 1684) +#endif + const wxChar *ext = va_arg(argptr, const wxChar *); + +#ifdef __INTELC__ + #pragma warning(pop) +#endif if ( !ext ) { // NULL terminates the list @@ -112,7 +120,7 @@ wxFileTypeInfo::wxFileTypeInfo(const wxArrayString& sArray) } #include "wx/arrimpl.cpp" -WX_DEFINE_OBJARRAY(wxArrayFileTypeInfo); +WX_DEFINE_OBJARRAY(wxArrayFileTypeInfo) // ============================================================================ // implementation of the wrapper classes @@ -410,12 +418,16 @@ bool wxFileType::Unassociate() #endif } -bool wxFileType::SetCommand(const wxString& cmd, const wxString& verb, -bool overwriteprompt) +bool wxFileType::SetCommand(const wxString& cmd, + const wxString& verb, + bool overwriteprompt) { #if defined (__WXMSW__) || defined(__UNIX__) return m_impl->SetCommand(cmd, verb, overwriteprompt); #else + wxUnusedVar(cmd); + wxUnusedVar(verb); + wxUnusedVar(overwriteprompt); wxFAIL_MSG(_T("not implemented")); return false; #endif @@ -435,12 +447,39 @@ bool wxFileType::SetDefaultIcon(const wxString& cmd, int index) #if defined (__WXMSW__) || defined(__UNIX__) return m_impl->SetDefaultIcon (cmd, index); #else + wxUnusedVar(index); wxFAIL_MSG(_T("not implemented")); - return false; #endif } +// ---------------------------------------------------------------------------- +// wxMimeTypesManagerFactory +// ---------------------------------------------------------------------------- + +wxMimeTypesManagerFactory *wxMimeTypesManagerFactory::m_factory = NULL; + +/* static */ +void wxMimeTypesManagerFactory::Set(wxMimeTypesManagerFactory *factory) +{ + delete m_factory; + + m_factory = factory; +} + +/* static */ +wxMimeTypesManagerFactory *wxMimeTypesManagerFactory::Get() +{ + if ( !m_factory ) + m_factory = new wxMimeTypesManagerFactory; + + return m_factory; +} + +wxMimeTypesManagerImpl *wxMimeTypesManagerFactory::CreateMimeTypesManagerImpl() +{ + return new wxMimeTypesManagerImpl; +} // ---------------------------------------------------------------------------- // wxMimeTypesManager @@ -449,7 +488,7 @@ bool wxFileType::SetDefaultIcon(const wxString& cmd, int index) void wxMimeTypesManager::EnsureImpl() { if ( !m_impl ) - m_impl = new wxMimeTypesManagerImpl; + m_impl = wxMimeTypesManagerFactory::Get()->CreateMimeTypesManagerImpl(); } bool wxMimeTypesManager::IsOfType(const wxString& mimeType, @@ -488,6 +527,8 @@ wxMimeTypesManager::~wxMimeTypesManager() bool wxMimeTypesManager::Unassociate(wxFileType *ft) { + EnsureImpl(); + #if defined(__UNIX__) && !defined(__CYGWIN__) && !defined(__WINE__) return m_impl->Unassociate(ft); #else @@ -504,6 +545,7 @@ wxMimeTypesManager::Associate(const wxFileTypeInfo& ftInfo) #if defined(__WXMSW__) || defined(__UNIX__) return m_impl->Associate(ftInfo); #else // other platforms + wxUnusedVar(ftInfo); wxFAIL_MSG( _T("not implemented") ); // TODO return NULL; #endif // platforms @@ -632,10 +674,12 @@ class wxMimeTypeCmnModule: public wxModule { public: wxMimeTypeCmnModule() : wxModule() { } + virtual bool OnInit() { return true; } virtual void OnExit() { - // this avoids false memory leak allerts: + wxMimeTypesManagerFactory::Set(NULL); + if ( gs_mimeTypesManager.m_impl != NULL ) { delete gs_mimeTypesManager.m_impl;