+void wxMimeTypesManagerImpl::AddFallback(const wxFileTypeInfo& filetype)
+{
+ wxString extensions;
+ const wxArrayString& exts = filetype.GetExtensions();
+ size_t nExts = exts.GetCount();
+ for ( size_t nExt = 0; nExt < nExts; nExt++ ) {
+ if ( nExt > 0 ) {
+ extensions += T(' ');
+ }
+ extensions += exts[nExt];
+ }
+
+ AddMimeTypeInfo(filetype.GetMimeType(),
+ extensions,
+ filetype.GetDescription());
+
+ AddMailcapInfo(filetype.GetMimeType(),
+ filetype.GetOpenCommand(),
+ filetype.GetPrintCommand(),
+ T(""),
+ filetype.GetDescription());
+}
+
+void wxMimeTypesManagerImpl::AddMimeTypeInfo(const wxString& strMimeType,
+ const wxString& strExtensions,
+ const wxString& strDesc)
+{
+ int index = m_aTypes.Index(strMimeType);
+ if ( index == wxNOT_FOUND ) {
+ // add a new entry
+ m_aTypes.Add(strMimeType);
+ m_aEntries.Add(NULL);
+ m_aExtensions.Add(strExtensions);
+ m_aDescriptions.Add(strDesc);
+ }
+ else {
+ // modify an existing one
+ if ( !strDesc.IsEmpty() ) {
+ m_aDescriptions[index] = strDesc; // replace old value
+ }
+ m_aExtensions[index] += ' ' + strExtensions;
+ }
+}
+
+void wxMimeTypesManagerImpl::AddMailcapInfo(const wxString& strType,
+ const wxString& strOpenCmd,
+ const wxString& strPrintCmd,
+ const wxString& strTest,
+ const wxString& strDesc)
+{
+ MailCapEntry *entry = new MailCapEntry(strOpenCmd, strPrintCmd, strTest);
+
+ int nIndex = m_aTypes.Index(strType);
+ if ( nIndex == wxNOT_FOUND ) {
+ // new file type
+ m_aTypes.Add(strType);
+
+ m_aEntries.Add(entry);
+ m_aExtensions.Add(T(""));
+ m_aDescriptions.Add(strDesc);
+ }
+ else {
+ // always append the entry in the tail of the list - info added with
+ // this function can only come from AddFallbacks()
+ MailCapEntry *entryOld = m_aEntries[nIndex];
+ if ( entryOld )
+ entry->Append(entryOld);
+ else
+ m_aEntries[nIndex] = entry;
+ }
+}
+