X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b813b73cd79cfb4d275e9628811f379e8c5ee39..4a9dba0e561d2485d9235eab7b51aac8729f1b10:/src/common/mimecmn.cpp diff --git a/src/common/mimecmn.cpp b/src/common/mimecmn.cpp index 89b0ab281d..6523cce382 100644 --- a/src/common/mimecmn.cpp +++ b/src/common/mimecmn.cpp @@ -7,7 +7,7 @@ // Created: 23.09.98 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows license (part of wxExtra library) +// Licence: wxWindows licence (part of wxExtra library) ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -24,15 +24,18 @@ // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#include "wx/module.h" #ifdef __BORLANDC__ - #pragma hdrstop + #pragma hdrstop #endif +#if wxUSE_MIMETYPE + #ifndef WX_PRECOMP - #include "wx/defs.h" + #include "wx/module.h" #endif +// this one is needed for MSVC5 +#include "wx/module.h" #ifndef WX_PRECOMP #include "wx/string.h" @@ -71,10 +74,10 @@ // wxFileTypeInfo // ---------------------------------------------------------------------------- -wxFileTypeInfo::wxFileTypeInfo(const char *mimeType, - const char *openCmd, - const char *printCmd, - const char *desc, +wxFileTypeInfo::wxFileTypeInfo(const wxChar *mimeType, + const wxChar *openCmd, + const wxChar *printCmd, + const wxChar *desc, ...) : m_mimeType(mimeType), m_openCmd(openCmd), @@ -86,7 +89,7 @@ wxFileTypeInfo::wxFileTypeInfo(const char *mimeType, for ( ;; ) { - const char *ext = va_arg(argptr, const char *); + const wxChar *ext = va_arg(argptr, const wxChar *); if ( !ext ) { // NULL terminates the list @@ -325,6 +328,18 @@ wxFileType::GetOpenCommand(wxString *openCmd, return m_impl->GetOpenCommand(openCmd, params); } +wxString wxFileType::GetOpenCommand(const wxString& filename) const +{ + wxString cmd; + if ( !GetOpenCommand(&cmd, filename) ) + { + // return empty string to indicate an error + cmd.clear(); + } + + return cmd; +} + bool wxFileType::GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const @@ -351,7 +366,7 @@ size_t wxFileType::GetAllCommands(wxArrayString *verbs, if ( commands ) commands->Clear(); -#if defined (__WXMSW__) || (__UNIX__) +#if defined (__WXMSW__) || defined(__UNIX__) return m_impl->GetAllCommands(verbs, commands, params); #else // !__WXMSW__ || Unix // we don't know how to retrieve all commands, so just try the 2 we know @@ -385,25 +400,21 @@ bool wxFileType::Unassociate() { #if defined(__WXMSW__) return m_impl->Unassociate(); -#endif - -#if defined(__UNIX__) +#elif defined(__UNIX__) && !defined(__WXPM__) return m_impl->Unassociate(this); -#endif - +#else wxFAIL_MSG( _T("not implemented") ); // TODO return FALSE; - +#endif } bool wxFileType::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt) { -#if defined (__WXMSW__) || (__UNIX__) +#if defined (__WXMSW__) || defined(__UNIX__) return m_impl->SetCommand(cmd, verb, overwriteprompt); #else wxFAIL_MSG(_T("not implemented")); - return FALSE; #endif } @@ -415,11 +426,11 @@ bool wxFileType::SetDefaultIcon(const wxString& cmd, int index) // VZ: should we do this? // chris elliott : only makes sense in MS windows if ( sTmp.empty() ) - GetOpenCommand(&sTmp, wxFileType::MessageParameters("", "")); + GetOpenCommand(&sTmp, wxFileType::MessageParameters(wxT(""), wxT(""))); #endif wxCHECK_MSG( !sTmp.empty(), FALSE, _T("need the icon file") ); -#if defined (__WXMSW__) || (__UNIX__) +#if defined (__WXMSW__) || defined(__UNIX__) return m_impl->SetDefaultIcon (cmd, index); #else wxFAIL_MSG(_T("not implemented")); @@ -475,7 +486,7 @@ wxMimeTypesManager::~wxMimeTypesManager() bool wxMimeTypesManager::Unassociate(wxFileType *ft) { -#if defined(__UNIX__) +#if defined(__UNIX__) && !defined(__WXPM__) && !defined(__CYGWIN__) && !defined(__WINE__) return m_impl->Unassociate(ft); #else return ft->Unassociate(); @@ -488,7 +499,7 @@ wxMimeTypesManager::Associate(const wxFileTypeInfo& ftInfo) { EnsureImpl(); -#if defined(__WXMSW__) || defined(__UNIX__) +#if defined(__WXMSW__) || (defined(__UNIX__) && !defined(__WXPM__)) return m_impl->Associate(ftInfo); #else // other platforms wxFAIL_MSG( _T("not implemented") ); // TODO @@ -585,17 +596,20 @@ size_t wxMimeTypesManager::EnumAllFileTypes(wxArrayString& mimetypes) void wxMimeTypesManager::Initialize(int mcapStyle, const wxString& sExtraDir) { -#ifdef __UNIX__ +#if defined(__UNIX__) && !defined(__WXPM__) && !defined(__CYGWIN__) && !defined(__WINE__) EnsureImpl(); m_impl->Initialize(mcapStyle, sExtraDir); +#else + (void)mcapStyle; + (void)sExtraDir; #endif // Unix } // and this function clears all the data from the manager void wxMimeTypesManager::ClearData() { -#ifdef __UNIX__ +#if defined(__UNIX__) && !defined(__WXPM__) && !defined(__CYGWIN__) && !defined(__WINE__) EnsureImpl(); m_impl->ClearData(); @@ -624,6 +638,7 @@ public: { delete gs_mimeTypesManager.m_impl; gs_mimeTypesManager.m_impl = NULL; + gs_mimeTypesManager.m_fallbacks.Clear(); } } @@ -631,3 +646,5 @@ public: }; IMPLEMENT_DYNAMIC_CLASS(wxMimeTypeCmnModule, wxModule) + +#endif // wxUSE_MIMETYPE