]> git.saurik.com Git - wxWidgets.git/commitdiff
wxMimeTypeManager::EnumAll() seems to work, couple of minor corrections to the MIME...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 7 Dec 1999 15:18:22 +0000 (15:18 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 7 Dec 1999 15:18:22 +0000 (15:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4858 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/console/console.cpp
src/common/mimetype.cpp

index 9bd6269738d3eee68b9f3200e2ee4ac538c3f043..eaaf0a945eeff1c537b72b4b8b89b7dde674ace7 100644 (file)
@@ -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());
     }
 }
 
index f3a4c6bd6455a7152b0b27d2b66b155a6bbf97b1..98e014e94cb85d3b351b20e9b58e86be11a9eaca 100644 (file)
@@ -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