efl/legacy/efreet/src/lib/Efreet_Mime.h

71 lines
1.6 KiB
C
Raw Normal View History

/* vim: set sw=4 ts=4 sts=4 et: */
#ifndef EFREET_MIME_H
#define EFREET_MIME_H
/**
* @file Efreet_Mime.h
* @brief The file that must be included by any project wishing to use
* @addtogroup Efreet_Mime Efreet_Mime: The XDG Shared Mime Info standard
* Efreet Mime is a library designed to help apps work with the
* Freedesktop.org Shared Mime Info standard.
* Efreet_Mime.h provides all of the necessary headers and
* includes to work with Efreet_Mime.
* @{
*/
2007-11-04 03:19:55 -08:00
#ifdef EAPI
# undef EAPI
2007-11-04 03:19:55 -08:00
#endif
#ifdef _WIN32
# ifdef EFL_EFREET_MIME_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
2007-11-04 03:19:55 -08:00
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_EFREET_MIME_BUILD */
2007-11-04 03:19:55 -08:00
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
2007-07-01 09:32:34 -07:00
2007-11-04 01:32:35 -08:00
EAPI int efreet_mime_init(void);
EAPI int efreet_mime_shutdown(void);
2007-07-01 09:32:34 -07:00
2007-11-04 01:32:35 -08:00
EAPI const char *efreet_mime_type_get(const char *file);
EAPI const char *efreet_mime_magic_type_get(const char *file);
EAPI const char *efreet_mime_globs_type_get(const char *file);
EAPI const char *efreet_mime_special_type_get(const char *file);
EAPI const char *efreet_mime_fallback_type_get(const char *file);
2007-11-04 01:32:35 -08:00
EAPI char *efreet_mime_type_icon_get(const char *mime, const char *theme,
unsigned int size);
efreet mime types icon cache. This cache is very simple and should work fine when system does not change, it keeps a direct association of mime-types and found icons, remembering theme and icon size. Search is very fast since it uses stringshared strings and thus direct pointer comparison in hash search. We could optimize it even more if we assumed stringshared strings to come in, so no need to eina_stringshare_add() (which is a hash per se), using just eina_stringshare_ref(). Cache population is limited to compile-time value and just values older than a given threshold are deleted. I do not keep a LRU explicit list, so you might have some old but unused items always alive. I don't find this too bad, sure it will consume more memory, but will not hurt performance. We can change this to purge all expired items by not checking for number of items to remove, removing all that match. Next I plan to find out a good way to cache and speed up file->mime discovery. I plan to do auto-generated state-machine to match extensions, so you don't need to check the same extension character more than once. Example: Input: bla.edc Extensions: edc edj eps png bmp It would first try to match against 'e', 'p' and 'b'. It will match 'e' and then check for 'd' (edc or edj) or 'p' (eps). It will match 'd' and then check for 'c' or 'j'. This will reduce number of comparisons considerably. As I'm running out of time (4am, not much time left on this month), I could use some help here. SVN revision: 39343
2009-03-02 23:20:21 -08:00
EAPI void efreet_mime_type_cache_clear(void);
EAPI void efreet_mime_type_cache_flush(void);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif