corrections for modifications made to common mimetype code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9910 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Gilles Depeyrot
2001-04-28 13:31:46 +00:00
parent 6523de8a56
commit f040060e2f
3 changed files with 103 additions and 12 deletions

View File

@@ -28,6 +28,13 @@ public :
~wxMimeTypesManagerImpl() { } ~wxMimeTypesManagerImpl() { }
#endif #endif
// load all data into memory - done when it is needed for the first time
void Initialize(int mailcapStyles = wxMAILCAP_STANDARD,
const wxString& extraDir = wxEmptyString);
// and delete the data here
void ClearData();
// implement containing class functions // implement containing class functions
wxFileType *GetFileTypeFromExtension(const wxString& ext); wxFileType *GetFileTypeFromExtension(const wxString& ext);
wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ; wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
@@ -43,6 +50,8 @@ public :
// create a new filetype association // create a new filetype association
wxFileType *Associate(const wxFileTypeInfo& ftInfo); wxFileType *Associate(const wxFileTypeInfo& ftInfo);
// remove association
bool Unassociate(wxFileType *ft);
// create a new filetype with the given name and extension // create a new filetype with the given name and extension
wxFileType *CreateFileType(const wxString& filetype, const wxString& ext); wxFileType *CreateFileType(const wxString& filetype, const wxString& ext);
@@ -54,6 +63,16 @@ private:
class wxFileTypeImpl class wxFileTypeImpl
{ {
public: public:
// initialization functions
// this is used to construct a list of mimetypes which match;
// if built with GetFileTypeFromMimetype index 0 has the exact match and
// index 1 the type / * match
// if built with GetFileTypeFromExtension, index 0 has the mimetype for
// the first extension found, index 1 for the second and so on
void Init(wxMimeTypesManagerImpl *manager, size_t index)
{ m_manager = manager; m_index.Add(index); }
// initialize us with our file type name // initialize us with our file type name
void SetFileType(const wxString& strFileType) void SetFileType(const wxString& strFileType)
{ m_strFileType = strFileType; } { m_strFileType = strFileType; }
@@ -64,7 +83,7 @@ public:
bool GetExtensions(wxArrayString& extensions); bool GetExtensions(wxArrayString& extensions);
bool GetMimeType(wxString *mimeType) const; bool GetMimeType(wxString *mimeType) const;
bool GetMimeTypes(wxArrayString& mimeTypes) const; bool GetMimeTypes(wxArrayString& mimeTypes) const;
bool GetIcon(wxIcon *icon) const; bool GetIcon(wxIcon *icon, wxString *sCommand = NULL, int *iIndex = NULL) const;
bool GetDescription(wxString *desc) const; bool GetDescription(wxString *desc) const;
bool GetOpenCommand(wxString *openCmd, bool GetOpenCommand(wxString *openCmd,
const wxFileType::MessageParameters&) const const wxFileType::MessageParameters&) const
@@ -76,17 +95,27 @@ public:
size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands, size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
const wxFileType::MessageParameters& params) const; const wxFileType::MessageParameters& params) const;
bool Unassociate(); // remove the record for this file type
// probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
bool Unassociate(wxFileType *ft)
{
return m_manager->Unassociate(ft);
}
// set an arbitrary command, ask confirmation if it already exists and
// overwriteprompt is TRUE
bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
private: private:
// helper function // helper function
bool GetCommand(wxString *command, const char *verb) const; bool GetCommand(wxString *command, const char *verb) const;
wxMimeTypesManagerImpl *m_manager;
wxArrayInt m_index; // in the wxMimeTypesManagerImpl arrays
wxString m_strFileType, m_ext; wxString m_strFileType, m_ext;
}; };
#endif #endif
//_MIMETYPE_H //_MIMETYPE_H

View File

@@ -46,6 +46,15 @@
// in case we're compiling in non-GUI mode // in case we're compiling in non-GUI mode
class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxIcon;
bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
{
return FALSE;
}
bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
{
return FALSE;
}
bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
{ {
@@ -83,7 +92,7 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
return FALSE; return FALSE;
} }
bool wxFileTypeImpl::GetIcon(wxIcon *icon) const bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString *sCommand, int *iIndex) const
{ {
// no such file type or no value or incorrect icon entry // no such file type or no value or incorrect icon entry
return FALSE; return FALSE;
@@ -94,9 +103,24 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const
return FALSE; return FALSE;
} }
bool wxFileTypeImpl::Unassociate() size_t
wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
const wxFileType::MessageParameters& params) const
{ {
return FALSE; wxFAIL_MSG( _T("TODO") );
return 0;
}
void
wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
{
wxFAIL_MSG( _T("TODO") );
}
void
wxMimeTypesManagerImpl::ClearData()
{
wxFAIL_MSG( _T("TODO") );
} }
// extension -> file type // extension -> file type
@@ -194,3 +218,10 @@ wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
return NULL; return NULL;
} }
bool
wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
{
return FALSE;
}

View File

@@ -46,6 +46,15 @@
// in case we're compiling in non-GUI mode // in case we're compiling in non-GUI mode
class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxIcon;
bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
{
return FALSE;
}
bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
{
return FALSE;
}
bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
{ {
@@ -83,7 +92,7 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
return FALSE; return FALSE;
} }
bool wxFileTypeImpl::GetIcon(wxIcon *icon) const bool wxFileTypeImpl::GetIcon(wxIcon *icon, wxString *sCommand, int *iIndex) const
{ {
// no such file type or no value or incorrect icon entry // no such file type or no value or incorrect icon entry
return FALSE; return FALSE;
@@ -94,9 +103,24 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const
return FALSE; return FALSE;
} }
bool wxFileTypeImpl::Unassociate() size_t
wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
const wxFileType::MessageParameters& params) const
{ {
return FALSE; wxFAIL_MSG( _T("TODO") );
return 0;
}
void
wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
{
wxFAIL_MSG( _T("TODO") );
}
void
wxMimeTypesManagerImpl::ClearData()
{
wxFAIL_MSG( _T("TODO") );
} }
// extension -> file type // extension -> file type
@@ -194,3 +218,10 @@ wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
return NULL; return NULL;
} }
bool
wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
{
return FALSE;
}