From 54acce9084d52eb176496a24c6a35fcc6e4e3598 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Dec 1999 15:18:22 +0000 Subject: [PATCH] wxMimeTypeManager::EnumAll() seems to work, couple of minor corrections to the MIME code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4858 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/console/console.cpp | 3 +- src/common/mimetype.cpp | 56 ++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 9bd6269738..eaaf0a945e 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -82,7 +82,8 @@ static void TestMimeEnum() extsAll += exts[e]; } - printf("\t%s: %s (%s)\n", mimetypes[n], desc, extsAll); + printf("\t%s: %s (%s)\n", + mimetypes[n].c_str(), desc.c_str(), extsAll.c_str()); } } diff --git a/src/common/mimetype.cpp b/src/common/mimetype.cpp index f3a4c6bd64..98e014e94c 100644 --- a/src/common/mimetype.cpp +++ b/src/common/mimetype.cpp @@ -1401,8 +1401,8 @@ bool wxMimeTypesManagerImpl::ReadMimeTypes(const wxString& strFileName) while ( wxIsspace(*pc) ) pc++; - // comment? - if ( *pc == wxT('#') ) { + // comment or blank line? + if ( *pc == wxT('#') || !*pc ) { // skip the whole line pc = NULL; continue; @@ -1681,21 +1681,27 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, if ( !ok ) { - // don't flood the user with error messages - // if we don't understand something in his - // mailcap, but give them in debug mode - // because this might be useful for the - // programmer - wxLogDebug - ( - wxT("Mailcap file %s, line %d: unknown " - "field '%s' for the MIME type " - "'%s' ignored."), - strFileName.c_str(), - nLine + 1, - curField.c_str(), - strType.c_str() - ); + // we don't understand this field, but + // Netscape stores info in it, so don't warn + // about it + if ( curField.Left(16u) != "x-mozilla-flags=" ) + { + // don't flood the user with error + // messages if we don't understand + // something in his mailcap, but give + // them in debug mode because this might + // be useful for the programmer + wxLogDebug + ( + wxT("Mailcap file %s, line %d: " + "unknown field '%s' for the " + "MIME type '%s' ignored."), + strFileName.c_str(), + nLine + 1, + curField.c_str(), + strType.c_str() + ); + } } } @@ -1801,9 +1807,21 @@ bool wxMimeTypesManagerImpl::ReadMailcap(const wxString& strFileName, size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes) { - mimetypes = m_aTypes; + mimetypes.Empty(); + + wxString type; + size_t count = m_aTypes.GetCount(); + for ( size_t n = 0; n < count; n++ ) + { + // don't return template types from here (i.e. anything containg '*') + type = m_aTypes[n]; + if ( type.Find(_T('*')) == wxNOT_FOUND ) + { + mimetypes.Add(type); + } + } - return m_aTypes.GetCount(); + return mimetypes.GetCount(); } #endif -- 2.47.2