X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6aa89a22b8e47000c98bff05c6f545f331f1c353..e733c4ce1e24cf7e4b0b0d8362fc59aaa7a7641c:/src/os2/mimetype.cpp diff --git a/src/os2/mimetype.cpp b/src/os2/mimetype.cpp index 215229c4a3..16bedac9d3 100644 --- a/src/os2/mimetype.cpp +++ b/src/os2/mimetype.cpp @@ -1,36 +1,39 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: common/mimetype.cpp +// Name: src/os2/mimetype.cpp // Purpose: classes and functions to manage MIME types // Author: David Webster // Modified by: // Created: 01.21.00 -// RCS-ID: $Id$ // Copyright: Adopted from msw port --(c) 1998 Vadim Zeitlin // Licence: wxWindows licence (part of wxExtra library) ///////////////////////////////////////////////////////////////////////////// +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#if wxUSE_MIMETYPE + +#include "wx/os2/mimetype.h" + +#ifndef WX_PRECOMP + #include "wx/dynarray.h" + #include "wx/string.h" + #include "wx/intl.h" + #include "wx/log.h" + #if wxUSE_GUI + #include "wx/icon.h" + #endif +#endif //WX_PRECOMP + #define INCL_DOS #define INCL_GPI #define INCL_WIN #include -#ifndef WX_PRECOMP - #include "wx/string.h" - #if wxUSE_GUI - #include "wx/icon.h" - #endif -#endif //WX_PRECOMP - -#include "wx/log.h" #include "wx/file.h" -#include "wx/intl.h" -#include "wx/dynarray.h" +#include "wx/iconloc.h" #include "wx/confbase.h" -#if wxUSE_FILE - -#include "wx/os2/mimetype.h" - // other standard headers #include @@ -61,7 +64,7 @@ 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 +wxString wxFileTypeImpl::GetCommand(const wxChar *WXUNUSED(verb)) const { // TODO: OS/2 doesn't have a registry but uses Prf /* @@ -69,9 +72,9 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const wxLogNull nolog; wxString strKey; - if ( wxRegKey(wxRegKey::HKCR, m_ext + _T("\\shell")).Exists() ) + if ( wxRegKey(wxRegKey::HKCR, m_ext + wxT("\\shell")).Exists() ) strKey = m_ext; - if ( wxRegKey(wxRegKey::HKCR, m_strFileType + _T("\\shell")).Exists() ) + if ( wxRegKey(wxRegKey::HKCR, m_strFileType + wxT("\\shell")).Exists() ) strKey = m_strFileType; if ( !strKey ) @@ -81,7 +84,7 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const } strKey << wxT("\\shell\\") << verb; - wxRegKey key(wxRegKey::HKCR, strKey + _T("\\command")); + wxRegKey key(wxRegKey::HKCR, strKey + wxT("\\command")); wxString command; if ( key.Open() ) { // it's the default value of the key @@ -93,7 +96,7 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const // NB: we don't make any attempt to verify that the string is valid, // i.e. doesn't contain %2, or second %1 or .... But we do make // sure that we return a string with _exactly_ one '%s'! - bool foundFilename = FALSE; + bool foundFilename = false; size_t len = command.Len(); for ( size_t n = 0; (n < len) && !foundFilename; n++ ) { if ( command[n] == wxT('%') && @@ -103,32 +106,32 @@ wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const // replace it with '%s' command[n + 1] = wxT('s'); - foundFilename = TRUE; + foundFilename = true; } } #if wxUSE_DDE // look whether we must issue some DDE requests to the application // (and not just launch it) - strKey += _T("\\DDEExec"); + strKey += wxT("\\DDEExec"); wxRegKey keyDDE(wxRegKey::HKCR, strKey); if ( keyDDE.Open() ) { wxString ddeCommand, ddeServer, ddeTopic; - keyDDE.QueryValue(_T(""), ddeCommand); - ddeCommand.Replace(_T("%1"), _T("%s")); + keyDDE.QueryValue(wxT(""), ddeCommand); + ddeCommand.Replace(wxT("%1"), wxT("%s")); - wxRegKey(wxRegKey::HKCR, strKey + _T("\\Application")). - QueryValue(_T(""), ddeServer); - wxRegKey(wxRegKey::HKCR, strKey + _T("\\Topic")). - QueryValue(_T(""), ddeTopic); + wxRegKey(wxRegKey::HKCR, strKey + wxT("\\Application")). + QueryValue(wxT(""), ddeServer); + wxRegKey(wxRegKey::HKCR, strKey + wxT("\\Topic")). + QueryValue(wxT(""), ddeTopic); // HACK: we use a special feature of wxExecute which exists // just because we need it here: it will establish DDE // conversation with the program it just launched - command.Prepend(_T("WX_DDE#")); - command << _T('#') << ddeServer - << _T('#') << ddeTopic - << _T('#') << ddeCommand; + command.Prepend(wxT("WX_DDE#")); + command << wxT('#') << ddeServer + << wxT('#') << ddeTopic + << wxT('#') << ddeCommand; } else #endif // wxUSE_DDE @@ -164,7 +167,7 @@ wxFileTypeImpl::GetOpenCommand(wxString *openCmd, *openCmd = wxFileType::ExpandCommand(cmd, params); - return !openCmd->IsEmpty(); + return !openCmd->empty(); } bool @@ -182,7 +185,7 @@ wxFileTypeImpl::GetPrintCommand(wxString *printCmd, *printCmd = wxFileType::ExpandCommand(cmd, params); - return !printCmd->IsEmpty(); + return !printCmd->empty(); } // TODO this function is half implemented @@ -191,19 +194,19 @@ bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions) if ( m_info ) { extensions = m_info->GetExtensions(); - return TRUE; + return true; } - else if ( m_ext.IsEmpty() ) { + else if ( m_ext.empty() ) { // the only way to get the list of extensions from the file type is to // scan through all extensions in the registry - too slow... - return FALSE; + return false; } else { extensions.Empty(); extensions.Add(m_ext); // it's a lie too, we don't return _all_ extensions... - return TRUE; + return true; } } @@ -213,7 +216,7 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const // we already have it *mimeType = m_info->GetMimeType(); - return TRUE; + return true; } // suppress possible error messages @@ -222,13 +225,13 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const /* wxRegKey key(wxRegKey::HKCR, wxT(".") + m_ext); if ( key.Open() && key.QueryValue(wxT("Content Type"), *mimeType) ) { - return TRUE; + return true; } else { - return FALSE; + return false; } */ - return FALSE; + return false; } bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const @@ -239,18 +242,17 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const { mimeTypes.Clear(); mimeTypes.Add(s); - return TRUE; + return true; } else - return FALSE; + return false; } -bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString* psCommand, int* pnIndex) const +bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(iconLoc)) const { -#if wxUSE_GUI if ( m_info ) { // we don't have icons in the fallback resources - return FALSE; + return false; } wxString strIconKey; @@ -265,7 +267,7 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString* psCommand, int* pnIndex) co if ( key.Open() ) { wxString strIcon; // it's the default value of the key - if ( key.QueryValue(wxT(""), strIcon) ) { + if ( key.QueryValue(wxEmptyString, strIcon) ) { // the format is the following: , // NB: icon index may be negative as well as positive and the full // path may contain the environment variables inside '%' @@ -274,33 +276,25 @@ bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString* psCommand, int* pnIndex) co // index may be omitted, in which case BeforeLast(',') is empty and // AfterLast(',') is the whole string - if ( strFullPath.IsEmpty() ) { + if ( strFullPath.empty() ) { strFullPath = strIndex; strIndex = wxT("0"); } - wxString strExpPath = wxExpandEnvVars(strFullPath); - int nIndex = wxAtoi(strIndex); - - HICON hIcon = ExtractIcon(GetModuleHandle(NULL), strExpPath, nIndex); - switch ( (int)hIcon ) { - case 0: // means no icons were found - case 1: // means no such file or it wasn't a DLL/EXE/OCX/ICO/... - wxLogDebug(wxT("incorrect registry entry '%s': no such icon."), - key.GetName().c_str()); - break; + if ( iconLoc ) + { + iconLoc->SetFileName(wxExpandEnvVars(strFullPath)); - default: - icon->SetHICON((WXHICON)hIcon); - return TRUE; + iconLoc->SetIndex(wxAtoi(strIndex)); } + + return true; } } // no such file type or no value or incorrect icon entry */ -#endif // wxUSE_GUI - return FALSE; + return false; } bool wxFileTypeImpl::GetDescription(wxString *desc) const @@ -309,7 +303,7 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const // we already have it *desc = m_info->GetDescription(); - return TRUE; + return true; } // suppress possible error messages @@ -321,11 +315,11 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const if ( key.Open() ) { // it's the default value of the key if ( key.QueryValue(wxT(""), *desc) ) { - return TRUE; + return true; } } */ - return FALSE; + return false; } // extension -> file type @@ -342,7 +336,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext) // suppress possible error messages wxLogNull nolog; - bool knownExtension = FALSE; + bool knownExtension = false; wxString strFileType; // TODO: @@ -361,7 +355,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext) // this extension doesn't have a filetype, but it's known to the // system and may be has some other useful keys (open command or // content-type), so still return a file type object for it - knownExtension = TRUE; + knownExtension = true; } } */ @@ -430,7 +424,7 @@ wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType) return NULL; } -size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes) +size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& WXUNUSED(mimetypes)) { // enumerate all keys under MIME_DATABASE_KEY // TODO: @@ -452,4 +446,4 @@ size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes) return 0; } -#endif //wxUSE_FILE +#endif //wxUSE_MIMETYPE