2007-06-30 22:10:14 -07:00
|
|
|
#ifndef EFREET_MIME_H
|
|
|
|
#define EFREET_MIME_H
|
|
|
|
|
|
|
|
/**
|
2007-09-06 09:15:10 -07:00
|
|
|
* @file Efreet_Mime.h
|
2007-06-30 22:10:14 -07:00
|
|
|
* @brief The file that must be included by any project wishing to use
|
2008-08-02 14:48:44 -07:00
|
|
|
* @addtogroup Efreet_Mime Efreet_Mime: The XDG Shared Mime Info standard
|
2007-09-06 09:15:10 -07:00
|
|
|
* Efreet Mime is a library designed to help apps work with the
|
2007-06-30 22:10:14 -07:00
|
|
|
* Freedesktop.org Shared Mime Info standard.
|
2008-08-02 14:48:44 -07:00
|
|
|
* Efreet_Mime.h provides all of the necessary headers and
|
|
|
|
* includes to work with Efreet_Mime.
|
|
|
|
* @{
|
2007-06-30 22:10:14 -07:00
|
|
|
*/
|
|
|
|
|
2007-11-04 03:19:55 -08:00
|
|
|
#ifdef EAPI
|
2009-04-20 16:20:40 -07:00
|
|
|
# undef EAPI
|
2007-11-04 03:19:55 -08:00
|
|
|
#endif
|
2009-04-20 16:20:40 -07:00
|
|
|
|
|
|
|
#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)
|
2009-04-20 16:20:40 -07:00
|
|
|
# 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
|
|
|
|
|
2007-06-30 22:10:14 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-07-01 09:32:34 -07:00
|
|
|
|
2011-04-08 04:01:08 -07:00
|
|
|
/**
|
2012-06-18 03:06:17 -07:00
|
|
|
* @return @c 1 on success or @c 0 on failure.
|
2011-04-08 04:01:08 -07:00
|
|
|
* @brief Initializes the efreet mime settings
|
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI int efreet_mime_init(void);
|
2011-04-08 04:01:08 -07:00
|
|
|
|
|
|
|
/**
|
2012-09-20 17:03:23 -07:00
|
|
|
* @return The number of times the init function has been called minus the
|
|
|
|
* corresponding init call.
|
|
|
|
* @brief Shuts down Efreet mime settings system if a balanced number of
|
|
|
|
* init/shutdown calls have been made
|
2011-04-08 04:01:08 -07:00
|
|
|
*/
|
2009-10-09 23:19:13 -07:00
|
|
|
EAPI int efreet_mime_shutdown(void);
|
2007-07-01 09:32:34 -07:00
|
|
|
|
2011-04-08 04:01:08 -07:00
|
|
|
/**
|
|
|
|
* @param file The file to find the mime type
|
2012-06-18 03:06:17 -07:00
|
|
|
* @return Mime type as a string.
|
|
|
|
* @brief Retrieve the mime type of a file
|
2011-04-08 04:01:08 -07:00
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI const char *efreet_mime_type_get(const char *file);
|
2011-04-08 04:01:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param file The file to check the mime type
|
2012-06-18 03:06:17 -07:00
|
|
|
* @return Mime type as a string.
|
|
|
|
* @brief Retrieve the mime type of a file using magic
|
2011-04-08 04:01:08 -07:00
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI const char *efreet_mime_magic_type_get(const char *file);
|
2011-04-08 04:01:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param file The file to check the mime type
|
2012-06-18 03:06:17 -07:00
|
|
|
* @return Mime type as a string.
|
|
|
|
* @brief Retrieve the mime type of a file using globs
|
2011-04-08 04:01:08 -07:00
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI const char *efreet_mime_globs_type_get(const char *file);
|
2011-04-08 04:01:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param file The file to check the mime type
|
2012-06-18 03:06:17 -07:00
|
|
|
* @return Mime type as a string.
|
|
|
|
* @brief Retrieve the special mime type of a file
|
2011-04-08 04:01:08 -07:00
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI const char *efreet_mime_special_type_get(const char *file);
|
2011-04-08 04:01:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param file The file to check the mime type
|
2012-06-18 03:06:17 -07:00
|
|
|
* @return Mime type as a string.
|
|
|
|
* @brief Retrieve the fallback mime type of a file.
|
2011-04-08 04:01:08 -07:00
|
|
|
*/
|
2007-11-04 01:32:35 -08:00
|
|
|
EAPI const char *efreet_mime_fallback_type_get(const char *file);
|
2007-09-06 09:15:10 -07:00
|
|
|
|
2011-04-08 04:01:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mime The name of the mime type
|
|
|
|
* @param theme The name of the theme to search icons in
|
|
|
|
* @param size The wanted size of the icon
|
2012-06-18 03:06:17 -07:00
|
|
|
* @return Mime type icon path as a string.
|
|
|
|
* @brief Retrieve the mime type icon for a file.
|
2011-04-08 04:01:08 -07:00
|
|
|
*/
|
2010-11-09 12:15:55 -08:00
|
|
|
EAPI const char *efreet_mime_type_icon_get(const char *mime, const char *theme,
|
2011-04-08 04:01:08 -07:00
|
|
|
unsigned int size);
|
2007-06-30 22:10:14 -07:00
|
|
|
|
2011-04-08 04:01:08 -07:00
|
|
|
/**
|
|
|
|
* @brief Clear mime icons mapping cache
|
|
|
|
*/
|
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);
|
2011-04-08 04:01:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Flush mime icons mapping cache
|
|
|
|
*
|
|
|
|
* Flush timeout is defined at compile time by
|
|
|
|
* EFREET_MIME_ICONS_FLUSH_TIMEOUT
|
|
|
|
*/
|
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_flush(void);
|
|
|
|
|
2007-06-30 22:10:14 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|