-class MailCapEntry
-{
-public:
- // ctor
- MailCapEntry(const wxString& openCmd,
- const wxString& printCmd,
- const wxString& testCmd)
- : m_openCmd(openCmd), m_printCmd(printCmd), m_testCmd(testCmd)
- {
- m_next = NULL;
- }
-
- // accessors
- const wxString& GetOpenCmd() const { return m_openCmd; }
- const wxString& GetPrintCmd() const { return m_printCmd; }
- const wxString& GetTestCmd() const { return m_testCmd; }
-
- MailCapEntry *GetNext() const { return m_next; }
-
- // operations
- // prepend this element to the list
- void Prepend(MailCapEntry *next) { m_next = next; }
- // insert into the list at given position
- void Insert(MailCapEntry *next, size_t pos)
- {
- // FIXME slooow...
- MailCapEntry *cur;
- size_t n = 0;
- for ( cur = next; cur != NULL; cur = cur->m_next, n++ ) {
- if ( n == pos )
- break;
- }
-
- wxASSERT_MSG( n == pos, wxT("invalid position in MailCapEntry::Insert") );
-
- m_next = cur->m_next;
- cur->m_next = this;
- }
- // append this element to the list
- void Append(MailCapEntry *next)
- {
- wxCHECK_RET( next != NULL, wxT("Append()ing to what?") );
-
- // FIXME slooow...
- MailCapEntry *cur;
- for ( cur = next; cur->m_next != NULL; cur = cur->m_next )
- ;
-
- cur->m_next = this;
-
- wxASSERT_MSG( !m_next, wxT("Append()ing element already in the list?") );
- }
-
-private:
- wxString m_openCmd, // command to use to open/view the file
- m_printCmd, // print
- m_testCmd; // only apply this entry if test yields
- // true (i.e. the command returns 0)
-
- MailCapEntry *m_next; // in the linked list
-};
-
-
-// the base class which may be used to find an icon for the MIME type
-class wxMimeTypeIconHandler
-{
-public:
- virtual bool GetIcon(const wxString& mimetype, wxIcon *icon) = 0;
-
- // this function fills manager with MIME types information gathered
- // (as side effect) when searching for icons. This may be particularly
- // useful if mime.types is incomplete (e.g. RedHat distributions).
- virtual void GetMimeInfoRecords(wxMimeTypesManagerImpl *manager) = 0;
-};
-
-
-// the icon handler which uses GNOME MIME database
-class wxGNOMEIconHandler : public wxMimeTypeIconHandler
-{
-public:
- virtual bool GetIcon(const wxString& mimetype, wxIcon *icon);
- virtual void GetMimeInfoRecords(wxMimeTypesManagerImpl *manager);
-
-private:
- void Init();
- void LoadIconsFromKeyFile(const wxString& filename);
- void LoadKeyFilesFromDir(const wxString& dirbase);
-
- void LoadMimeTypesFromMimeFile(const wxString& filename, wxMimeTypesManagerImpl *manager);
- void LoadMimeFilesFromDir(const wxString& dirbase, wxMimeTypesManagerImpl *manager);
-
- static bool m_inited;
-
- static wxSortedArrayString ms_mimetypes;
- static wxArrayString ms_icons;
-};
-
-// the icon handler which uses KDE MIME database
-class wxKDEIconHandler : public wxMimeTypeIconHandler
-{
-public:
- virtual bool GetIcon(const wxString& mimetype, wxIcon *icon);
- virtual void GetMimeInfoRecords(wxMimeTypesManagerImpl *manager);
-
-private:
- void LoadLinksForMimeSubtype(const wxString& dirbase,
- const wxString& subdir,
- const wxString& filename,
- const wxArrayString& icondirs);
- void LoadLinksForMimeType(const wxString& dirbase,
- const wxString& subdir,
- const wxArrayString& icondirs);
- void LoadLinkFilesFromDir(const wxString& dirbase,
- const wxArrayString& icondirs);
- void Init();
-
- static bool m_inited;
-
- static wxSortedArrayString ms_mimetypes;
- static wxArrayString ms_icons;
-
- static wxArrayString ms_infoTypes;
- static wxArrayString ms_infoDescriptions;
- static wxArrayString ms_infoExtensions;
-};
-
-
-
-// ----------------------------------------------------------------------------
-// various statics
-// ----------------------------------------------------------------------------
-
-static wxGNOMEIconHandler gs_iconHandlerGNOME;
-static wxKDEIconHandler gs_iconHandlerKDE;
-
-bool wxGNOMEIconHandler::m_inited = FALSE;
-wxSortedArrayString wxGNOMEIconHandler::ms_mimetypes;
-wxArrayString wxGNOMEIconHandler::ms_icons;
-
-bool wxKDEIconHandler::m_inited = FALSE;
-wxSortedArrayString wxKDEIconHandler::ms_mimetypes;
-wxArrayString wxKDEIconHandler::ms_icons;
-
-wxArrayString wxKDEIconHandler::ms_infoTypes;
-wxArrayString wxKDEIconHandler::ms_infoDescriptions;
-wxArrayString wxKDEIconHandler::ms_infoExtensions;
-
-
-ArrayIconHandlers wxMimeTypesManagerImpl::ms_iconHandlers;