2006-07-30 09:58:38 -07:00
|
|
|
#include "e.h"
|
|
|
|
|
2007-10-14 08:17:32 -07:00
|
|
|
/* local types */
|
|
|
|
typedef struct _E_Fm2_Mime_Handler_Tuple E_Fm2_Mime_Handler_Tuple;
|
|
|
|
struct _E_Fm2_Mime_Handler_Tuple
|
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
Eina_List *list;
|
2007-10-14 08:17:32 -07:00
|
|
|
const char *str;
|
|
|
|
};
|
|
|
|
|
2006-07-30 09:58:38 -07:00
|
|
|
/* local subsystem functions */
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool _e_fm2_mime_handler_glob_match_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data, void *fdata);
|
|
|
|
static Eina_Bool _e_fm_mime_icon_foreach(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata);
|
2006-07-30 09:58:38 -07:00
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Hash *icon_map = NULL;
|
|
|
|
static Eina_Hash *_mime_handlers = NULL;
|
|
|
|
static Eina_Hash *_glob_handlers = NULL;
|
2006-07-30 09:58:38 -07:00
|
|
|
|
|
|
|
/* externally accessible functions */
|
|
|
|
EAPI const char *
|
|
|
|
e_fm_mime_filename_get(const char *fname)
|
|
|
|
{
|
2007-07-16 07:33:25 -07:00
|
|
|
return efreet_mime_globs_type_get(fname);
|
2006-07-30 09:58:38 -07:00
|
|
|
}
|
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
/* returns:
|
|
|
|
* NULL == don't know
|
|
|
|
* "THUMB" == generate a thumb
|
|
|
|
* "e/icons/fileman/mime/..." == theme icon
|
|
|
|
* "/path/to/file....edj" = explicit icon edje file
|
|
|
|
* "/path/to/file..." = explicit image file to use
|
|
|
|
*/
|
|
|
|
EAPI const char *
|
|
|
|
e_fm_mime_icon_get(const char *mime)
|
|
|
|
{
|
2006-09-22 12:55:11 -07:00
|
|
|
char buf[4096], buf2[4096], *val;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l = NULL;
|
2006-09-16 04:35:54 -07:00
|
|
|
E_Config_Mime_Icon *mi;
|
2009-04-13 07:56:38 -07:00
|
|
|
size_t len;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2010-09-08 16:59:07 -07:00
|
|
|
/* 0.0 clean out hash cache once it has more than 512 entries in it */
|
2008-12-17 07:33:43 -08:00
|
|
|
if (eina_hash_population(icon_map) > 512) e_fm_mime_icon_cache_flush();
|
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
/* 0. look in mapping cache */
|
2008-12-17 07:33:43 -08:00
|
|
|
val = eina_hash_find(icon_map, mime);
|
2006-09-16 04:35:54 -07:00
|
|
|
if (val) return val;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2010-01-30 14:11:11 -08:00
|
|
|
eina_strlcpy(buf2, mime, sizeof(buf2));
|
2006-09-16 04:35:54 -07:00
|
|
|
val = strchr(buf2, '/');
|
|
|
|
if (val) *val = 0;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
/* 1. look up in mapping to file or thumb (thumb has flag)*/
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(e_config->mime_icons, l, mi)
|
2006-09-16 04:35:54 -07:00
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
if (e_util_glob_match(mi->mime, mime))
|
|
|
|
{
|
|
|
|
eina_strlcpy(buf, mi->icon, sizeof(buf));
|
|
|
|
goto ok;
|
|
|
|
}
|
2006-09-16 04:35:54 -07:00
|
|
|
}
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
/* 2. look up in ~/.e/e/icons */
|
2009-04-13 07:56:38 -07:00
|
|
|
len = e_user_dir_snprintf(buf, sizeof(buf), "icons/%s.edj", mime);
|
|
|
|
if (len >= sizeof(buf))
|
|
|
|
goto try_e_icon_generic;
|
2006-09-22 12:55:11 -07:00
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-18 16:13:33 -07:00
|
|
|
memcpy(buf + len - (sizeof("edj") - 1), "svg", sizeof("svg"));
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-18 16:13:33 -07:00
|
|
|
memcpy(buf + len - (sizeof("edj") - 1), "png", sizeof("png"));
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-13 07:56:38 -07:00
|
|
|
|
2012-08-28 01:19:46 -07:00
|
|
|
try_e_icon_generic:
|
2009-04-13 07:56:38 -07:00
|
|
|
len = e_user_dir_snprintf(buf, sizeof(buf), "icons/%s.edj", buf2);
|
|
|
|
if (len >= sizeof(buf))
|
|
|
|
goto try_theme;
|
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-18 16:13:33 -07:00
|
|
|
memcpy(buf + len - (sizeof("edj") - 1), "svg", sizeof("svg"));
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-18 16:13:33 -07:00
|
|
|
memcpy(buf + len - (sizeof("edj") - 1), "png", sizeof("png"));
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-13 07:56:38 -07:00
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
/* 3. look up icon in theme */
|
2012-08-28 01:19:46 -07:00
|
|
|
try_theme:
|
2009-04-13 07:56:38 -07:00
|
|
|
memcpy(buf, "e/icons/fileman/mime/", sizeof("e/icons/fileman/mime/") - 1);
|
2010-01-30 14:11:11 -08:00
|
|
|
eina_strlcpy(buf + sizeof("e/icons/fileman/mime/") - 1, mime,
|
2012-08-28 01:19:46 -07:00
|
|
|
sizeof(buf) - (sizeof("e/icons/fileman/mime/") - 1));
|
2006-09-16 04:35:54 -07:00
|
|
|
val = (char *)e_theme_edje_file_get("base/theme/fileman", buf);
|
|
|
|
if ((val) && (e_util_edje_collection_exists(val, buf))) goto ok;
|
2009-04-13 07:56:38 -07:00
|
|
|
|
2010-01-30 14:11:11 -08:00
|
|
|
eina_strlcpy(buf + sizeof("e/icons/fileman/mime/") - 1, buf2,
|
2012-08-28 01:19:46 -07:00
|
|
|
sizeof(buf) - (sizeof("e/icons/fileman/mime/") - 1));
|
2006-09-16 04:35:54 -07:00
|
|
|
val = (char *)e_theme_edje_file_get("base/theme/fileman", buf);
|
|
|
|
if ((val) && (e_util_edje_collection_exists(val, buf))) goto ok;
|
2009-04-13 07:56:38 -07:00
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
/* 4. look up icon in PREFIX/share/enlightent/data/icons */
|
2009-04-13 07:56:38 -07:00
|
|
|
len = e_prefix_data_snprintf(buf, sizeof(buf), "data/icons/%s.edj", mime);
|
|
|
|
if (len >= sizeof(buf))
|
|
|
|
goto try_efreet_icon_generic;
|
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-18 16:13:33 -07:00
|
|
|
memcpy(buf + len - (sizeof("edj") - 1), "svg", sizeof("svg"));
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-18 16:13:33 -07:00
|
|
|
memcpy(buf + len - (sizeof("edj") - 1), "png", sizeof("png"));
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-13 07:56:38 -07:00
|
|
|
|
2012-08-28 01:19:46 -07:00
|
|
|
try_efreet_icon_generic:
|
2009-04-13 07:56:38 -07:00
|
|
|
len = e_prefix_data_snprintf(buf, sizeof(buf), "data/icons/%s.edj", buf2);
|
|
|
|
if (len >= sizeof(buf))
|
|
|
|
goto try_efreet_icon_generic;
|
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-18 16:13:33 -07:00
|
|
|
memcpy(buf + len - (sizeof("edj") - 1), "svg", sizeof("svg"));
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2009-04-18 16:13:33 -07:00
|
|
|
memcpy(buf + len - (sizeof("edj") - 1), "png", sizeof("png"));
|
2006-09-16 04:35:54 -07:00
|
|
|
if (ecore_file_exists(buf)) goto ok;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
return NULL;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2012-08-28 01:19:46 -07:00
|
|
|
ok:
|
2008-10-15 08:12:56 -07:00
|
|
|
val = (char *)eina_stringshare_add(buf);
|
2008-12-17 07:33:43 -08:00
|
|
|
if (!icon_map) icon_map = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_add(icon_map, mime, val);
|
2006-09-16 04:35:54 -07:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2006-11-03 18:31:53 -08:00
|
|
|
EAPI void
|
|
|
|
e_fm_mime_icon_cache_flush(void)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *freelist = NULL;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
|
|
|
eina_hash_foreach(icon_map, _e_fm_mime_icon_foreach, &freelist);
|
2009-08-21 08:08:49 -07:00
|
|
|
E_FREE_LIST(freelist, eina_stringshare_del);
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_free(icon_map);
|
2006-11-03 18:31:53 -08:00
|
|
|
icon_map = NULL;
|
|
|
|
}
|
|
|
|
|
2007-10-14 05:22:52 -07:00
|
|
|
/* create (allocate), set properties, and return a new mime handler */
|
2013-01-11 02:34:29 -08:00
|
|
|
EAPI E_Fm2_Mime_Handler *
|
|
|
|
e_fm2_mime_handler_new(const char *label, const char *icon_group, void (*action_func)(void *data, Evas_Object *obj, const char *path), void *action_data, int(test_func) (void *data, Evas_Object * obj, const char *path), void *test_data)
|
2007-10-14 05:22:52 -07:00
|
|
|
{
|
2007-10-14 08:17:32 -07:00
|
|
|
E_Fm2_Mime_Handler *handler;
|
2007-10-14 05:22:52 -07:00
|
|
|
|
2007-10-14 05:36:08 -07:00
|
|
|
if ((!label) || (!action_func)) return NULL;
|
2007-10-14 05:22:52 -07:00
|
|
|
|
2007-10-14 08:17:32 -07:00
|
|
|
handler = E_NEW(E_Fm2_Mime_Handler, 1);
|
2007-10-14 05:36:08 -07:00
|
|
|
if (!handler) return NULL;
|
2007-10-14 05:22:52 -07:00
|
|
|
|
2008-10-15 08:12:56 -07:00
|
|
|
handler->label = eina_stringshare_add(label);
|
|
|
|
handler->icon_group = icon_group ? eina_stringshare_add(icon_group) : NULL;
|
2007-10-14 05:22:52 -07:00
|
|
|
handler->action_func = action_func;
|
2007-10-14 05:59:26 -07:00
|
|
|
handler->action_data = action_data;
|
2007-10-14 05:45:23 -07:00
|
|
|
handler->test_func = test_func;
|
2007-10-14 05:59:26 -07:00
|
|
|
handler->test_data = test_data;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2007-10-14 05:22:52 -07:00
|
|
|
return handler;
|
|
|
|
}
|
|
|
|
|
2007-10-14 05:45:23 -07:00
|
|
|
EAPI void
|
2008-12-17 07:33:43 -08:00
|
|
|
e_fm2_mime_handler_free(E_Fm2_Mime_Handler *handler)
|
2007-10-14 05:45:23 -07:00
|
|
|
{
|
|
|
|
if (!handler) return;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_del(handler->label);
|
|
|
|
if (handler->icon_group) eina_stringshare_del(handler->icon_group);
|
2007-10-14 05:45:23 -07:00
|
|
|
E_FREE(handler);
|
|
|
|
}
|
|
|
|
|
2007-10-14 05:22:52 -07:00
|
|
|
/* associate a certain mime type with a handler */
|
2008-12-17 07:33:43 -08:00
|
|
|
EAPI Eina_Bool
|
2007-10-14 08:17:32 -07:00
|
|
|
e_fm2_mime_handler_mime_add(E_Fm2_Mime_Handler *handler, const char *mime)
|
2007-10-14 05:22:52 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *handlers = NULL;
|
2007-10-14 05:22:52 -07:00
|
|
|
|
2007-10-14 05:36:08 -07:00
|
|
|
if ((!handler) || (!mime)) return 0;
|
2007-10-14 05:22:52 -07:00
|
|
|
|
|
|
|
/* if there's an entry for this mime already, then append to its list */
|
2008-12-17 07:33:43 -08:00
|
|
|
if ((handlers = eina_hash_find(_mime_handlers, mime)))
|
2007-10-14 05:22:52 -07:00
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
handlers = eina_list_append(handlers, handler);
|
|
|
|
eina_hash_modify(_mime_handlers, mime, handlers);
|
2007-10-14 05:22:52 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
/* no previous entry for this mime, lets add one */
|
|
|
|
handlers = eina_list_append(handlers, handler);
|
|
|
|
if (!_mime_handlers) _mime_handlers = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_add(_mime_handlers, mime, handlers);
|
2007-10-14 05:22:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* associate a certain glob with a handler */
|
2008-12-17 07:33:43 -08:00
|
|
|
EAPI Eina_Bool
|
2012-04-15 01:09:56 -07:00
|
|
|
e_fm2_mime_handler_glob_add(E_Fm2_Mime_Handler *handler, const char *glob_)
|
2007-10-14 05:22:52 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *handlers = NULL;
|
2007-10-14 05:22:52 -07:00
|
|
|
|
2012-04-15 01:09:56 -07:00
|
|
|
if ((!handler) || (!glob_)) return 0;
|
2007-10-14 05:22:52 -07:00
|
|
|
|
|
|
|
/* if there's an entry for this glob already, then append to its list */
|
2012-04-15 01:09:56 -07:00
|
|
|
if ((handlers = eina_hash_find(_glob_handlers, glob_)))
|
2007-10-14 05:22:52 -07:00
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
handlers = eina_list_append(handlers, handler);
|
|
|
|
eina_hash_modify(_glob_handlers, glob_, handlers);
|
2007-10-14 05:22:52 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
/* no previous entry for this glob, lets add one */
|
|
|
|
handlers = eina_list_append(handlers, handler);
|
|
|
|
if (!_glob_handlers) _glob_handlers = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_add(_glob_handlers, glob_, handlers);
|
2007-10-14 05:22:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2007-10-14 05:59:26 -07:00
|
|
|
|
2010-09-08 16:59:07 -07:00
|
|
|
/* delete a certain handler for a certain mime */
|
2007-10-14 07:12:03 -07:00
|
|
|
EAPI void
|
2008-12-17 07:33:43 -08:00
|
|
|
e_fm2_mime_handler_mime_del(E_Fm2_Mime_Handler *handler, const char *mime)
|
2007-10-14 07:12:03 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *handlers = NULL;
|
2007-10-14 07:12:03 -07:00
|
|
|
|
|
|
|
if ((!handler) || (!mime)) return;
|
|
|
|
|
2007-10-16 02:11:43 -07:00
|
|
|
/* if there's an entry for this mime already, then remove from list */
|
2008-12-17 07:33:43 -08:00
|
|
|
if ((handlers = eina_hash_find(_mime_handlers, mime)))
|
2007-10-14 07:12:03 -07:00
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
handlers = eina_list_remove(handlers, handler);
|
|
|
|
if (handlers)
|
|
|
|
eina_hash_modify(_mime_handlers, mime, handlers);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eina_hash_del(_mime_handlers, mime, handlers);
|
|
|
|
if (!eina_hash_population(_mime_handlers))
|
|
|
|
{
|
|
|
|
eina_hash_free(_mime_handlers);
|
|
|
|
_mime_handlers = NULL;
|
|
|
|
}
|
|
|
|
}
|
2007-10-14 07:12:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* delete a certain handler for a certain glob */
|
|
|
|
EAPI void
|
2012-04-15 01:09:56 -07:00
|
|
|
e_fm2_mime_handler_glob_del(E_Fm2_Mime_Handler *handler, const char *glob_)
|
2007-10-14 07:12:03 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *handlers = NULL;
|
2007-10-14 07:12:03 -07:00
|
|
|
|
2012-04-15 01:09:56 -07:00
|
|
|
if ((!handler) || (!glob_)) return;
|
2007-10-14 07:12:03 -07:00
|
|
|
|
2007-10-16 02:11:43 -07:00
|
|
|
/* if there's an entry for this glob already, then remove from list */
|
2012-04-15 01:09:56 -07:00
|
|
|
if ((handlers = eina_hash_find(_glob_handlers, glob_)))
|
2007-10-14 07:12:03 -07:00
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
handlers = eina_list_remove(handlers, handler);
|
|
|
|
if (handlers)
|
|
|
|
eina_hash_modify(_glob_handlers, glob_, handlers);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eina_hash_del(_glob_handlers, glob_, handlers);
|
|
|
|
if (!eina_hash_population(_glob_handlers))
|
|
|
|
{
|
|
|
|
eina_hash_free(_glob_handlers);
|
|
|
|
_glob_handlers = NULL;
|
|
|
|
}
|
|
|
|
}
|
2007-10-14 07:12:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-28 01:54:54 -07:00
|
|
|
EAPI const Eina_List *
|
2007-10-14 08:17:32 -07:00
|
|
|
e_fm2_mime_handler_mime_handlers_get(const char *mime)
|
2007-10-14 07:12:03 -07:00
|
|
|
{
|
2007-10-14 11:20:49 -07:00
|
|
|
if ((!mime) || (!_mime_handlers)) return NULL;
|
2008-12-17 07:33:43 -08:00
|
|
|
return eina_hash_find(_mime_handlers, mime);
|
2007-10-14 07:12:03 -07:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
/* get the list of glob handlers for a glob.
|
2012-08-28 01:19:46 -07:00
|
|
|
NOTE: the list should be free()'ed */
|
2008-10-22 04:49:33 -07:00
|
|
|
EAPI Eina_List *
|
2012-04-15 01:09:56 -07:00
|
|
|
e_fm2_mime_handler_glob_handlers_get(const char *glob_)
|
2007-10-14 07:12:03 -07:00
|
|
|
{
|
2007-10-14 11:20:49 -07:00
|
|
|
E_Fm2_Mime_Handler_Tuple *tuple = NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *handlers = NULL;
|
2007-10-14 08:17:32 -07:00
|
|
|
|
2012-04-15 01:09:56 -07:00
|
|
|
if ((!glob_) || (!_glob_handlers)) return NULL;
|
2007-10-14 08:17:32 -07:00
|
|
|
|
|
|
|
tuple = E_NEW(E_Fm2_Mime_Handler_Tuple, 1);
|
|
|
|
tuple->list = NULL;
|
2012-04-15 01:09:56 -07:00
|
|
|
tuple->str = glob_;
|
2008-12-17 07:33:43 -08:00
|
|
|
eina_hash_foreach(_glob_handlers, _e_fm2_mime_handler_glob_match_foreach, tuple);
|
2007-10-14 08:17:32 -07:00
|
|
|
handlers = tuple->list;
|
|
|
|
E_FREE(tuple);
|
|
|
|
return handlers;
|
2007-10-14 07:12:03 -07:00
|
|
|
}
|
|
|
|
|
2007-10-14 05:59:26 -07:00
|
|
|
/* call a certain handler */
|
2008-12-17 07:33:43 -08:00
|
|
|
EAPI Eina_Bool
|
2007-10-14 08:17:32 -07:00
|
|
|
e_fm2_mime_handler_call(E_Fm2_Mime_Handler *handler, Evas_Object *obj, const char *path)
|
2007-10-14 05:59:26 -07:00
|
|
|
{
|
2007-10-14 11:20:49 -07:00
|
|
|
if ((!handler) || (!obj) || (!path) || (!handler->action_func))
|
2007-10-14 05:59:26 -07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (handler->test_func)
|
|
|
|
{
|
2012-09-14 03:52:08 -07:00
|
|
|
if (handler->test_func(handler->test_data, obj, path))
|
2012-08-28 01:19:46 -07:00
|
|
|
{
|
2012-09-14 03:52:08 -07:00
|
|
|
handler->action_func(handler->action_data, obj, path);
|
2012-08-28 01:19:46 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
2007-10-14 05:59:26 -07:00
|
|
|
}
|
|
|
|
|
2012-09-14 03:52:08 -07:00
|
|
|
handler->action_func(handler->action_data, obj, path);
|
2007-10-14 05:59:26 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-10-14 07:12:03 -07:00
|
|
|
/* call all handlers related to a certain mime */
|
2007-10-14 06:39:39 -07:00
|
|
|
EAPI void
|
2007-10-14 08:17:32 -07:00
|
|
|
e_fm2_mime_handler_mime_handlers_call_all(Evas_Object *obj, const char *path, const char *mime)
|
2007-10-14 06:39:39 -07:00
|
|
|
{
|
2012-08-28 01:54:54 -07:00
|
|
|
const Eina_List *l, *handlers;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Fm2_Mime_Handler *handler = NULL;
|
2007-10-14 06:39:39 -07:00
|
|
|
|
2007-10-14 11:20:49 -07:00
|
|
|
if ((!obj) || (!path) || (!mime)) return;
|
2007-10-14 06:39:39 -07:00
|
|
|
|
2007-10-14 08:17:32 -07:00
|
|
|
handlers = e_fm2_mime_handler_mime_handlers_get(mime);
|
2007-10-14 11:20:49 -07:00
|
|
|
if (!handlers) return;
|
2007-10-14 07:12:03 -07:00
|
|
|
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(handlers, l, handler)
|
2007-10-14 06:39:39 -07:00
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
if (!handler) continue;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2012-08-28 01:19:46 -07:00
|
|
|
e_fm2_mime_handler_call(handler, obj, path);
|
2007-10-14 06:39:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-14 07:12:03 -07:00
|
|
|
/* call all handlers related to a certain glob */
|
2007-10-14 06:39:39 -07:00
|
|
|
EAPI void
|
2012-04-15 01:09:56 -07:00
|
|
|
e_fm2_mime_handler_glob_handlers_call_all(Evas_Object *obj, const char *path, const char *glob_)
|
2007-10-14 06:39:39 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *handlers = NULL;
|
|
|
|
Eina_List *l = NULL;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Fm2_Mime_Handler *handler = NULL;
|
2007-10-14 06:39:39 -07:00
|
|
|
|
2012-04-15 01:09:56 -07:00
|
|
|
if ((!obj) || (!path) || (!glob_)) return;
|
2007-10-14 06:39:39 -07:00
|
|
|
|
2012-04-15 01:09:56 -07:00
|
|
|
handlers = e_fm2_mime_handler_glob_handlers_get(glob_);
|
2007-10-14 11:20:49 -07:00
|
|
|
if (!handlers) return;
|
2007-10-14 07:12:03 -07:00
|
|
|
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(handlers, l, handler)
|
2007-10-14 06:39:39 -07:00
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
if (!handler) continue;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2012-08-28 01:19:46 -07:00
|
|
|
e_fm2_mime_handler_call(handler, obj, path);
|
2007-10-14 06:39:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-15 05:35:56 -07:00
|
|
|
/* run a handlers test function */
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EAPI Eina_Bool
|
2007-10-15 05:35:56 -07:00
|
|
|
e_fm2_mime_handler_test(E_Fm2_Mime_Handler *handler, Evas_Object *obj, const char *path)
|
|
|
|
{
|
|
|
|
if ((!handler) || (!obj) || (!path)) return 0;
|
|
|
|
if (!handler->test_func) return 1;
|
|
|
|
|
2012-09-14 03:52:08 -07:00
|
|
|
return handler->test_func(handler->test_data, obj, path);
|
2007-10-15 05:35:56 -07:00
|
|
|
}
|
|
|
|
|
2006-07-30 09:58:38 -07:00
|
|
|
/* local subsystem functions */
|
2007-10-14 08:17:32 -07:00
|
|
|
/* used to loop a glob hash and determine if the glob handler matches the filename */
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_e_fm2_mime_handler_glob_match_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data, void *fdata)
|
2007-10-14 08:17:32 -07:00
|
|
|
{
|
|
|
|
E_Fm2_Mime_Handler_Tuple *tuple;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *handlers = NULL;
|
|
|
|
Eina_List *l = NULL;
|
2009-08-21 08:08:49 -07:00
|
|
|
void *handler = NULL;
|
2007-10-14 08:17:32 -07:00
|
|
|
|
|
|
|
tuple = fdata;
|
2008-12-17 07:33:43 -08:00
|
|
|
if (e_util_glob_match(tuple->str, key))
|
2007-10-14 08:25:57 -07:00
|
|
|
{
|
2012-08-28 01:19:46 -07:00
|
|
|
handlers = data;
|
|
|
|
EINA_LIST_FOREACH(handlers, l, handler)
|
|
|
|
{
|
|
|
|
if (handler)
|
|
|
|
tuple->list = eina_list_append(tuple->list, handler);
|
|
|
|
}
|
2007-10-14 08:25:57 -07:00
|
|
|
}
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2007-10-14 08:17:32 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:33:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_e_fm_mime_icon_foreach(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata)
|
2006-09-16 04:35:54 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List **freelist;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2006-09-16 04:35:54 -07:00
|
|
|
freelist = fdata;
|
2008-10-22 04:49:33 -07:00
|
|
|
*freelist = eina_list_append(*freelist, data);
|
2006-09-16 04:35:54 -07:00
|
|
|
return 1;
|
|
|
|
}
|
2012-08-28 01:19:46 -07:00
|
|
|
|