From 179fd31b77cf5e4bb7f5a2de99bde2f2b44c8848 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Wed, 13 Feb 2013 11:35:46 +0000 Subject: [PATCH] add api and lets test it - i'll document it later, but need to test first. SVN revision: 83867 --- src/lib/evas/Evas.h | 14 +++++++++ src/lib/evas/cserve2/evas_cs2_client.c | 8 ++--- src/lib/evas/file/evas_module.c | 43 ++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/lib/evas/Evas.h b/src/lib/evas/Evas.h index c1f418b1e9..c7ccfb4225 100644 --- a/src/lib/evas/Evas.h +++ b/src/lib/evas/Evas.h @@ -1244,6 +1244,20 @@ typedef void (*Evas_Async_Events_Put_Cb)(void *target, Evas_Callback_Type t * Functions that affect Evas as a whole. */ +/** + * Get the path for the cserve binary to execute + * + * There is little need for anyone except a desktop nevironment to call this. + * This can be called before evas_init() has been called. It will try and find + * the full path to the to the cserve binary to run to provide cserve image + * and font caching services for evas. + * + * @return NULL if error, or a string with the full path to the cserve binary. + * + * @since 1.8 + */ +EAPI const char *evas_cserve_path_get(void); + /** * Initialize Evas * diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c index 73bbcf1de7..3cb12d4f89 100644 --- a/src/lib/evas/cserve2/evas_cs2_client.c +++ b/src/lib/evas/cserve2/evas_cs2_client.c @@ -106,11 +106,11 @@ _server_connect(void) remote.sun_family = AF_UNIX; _socket_path_set(remote.sun_path); len = strlen(remote.sun_path) + sizeof(remote.sun_family); - if (connect(s, (struct sockaddr *)&remote, len) == -1) + for (;;) { - ERR("connect"); - close(s); - return EINA_FALSE; + if (connect(s, (struct sockaddr *)&remote, len) != -1) break; + ERR("cserve connect failed. retrying."); + usleep(1000); } fcntl(s, F_SETFL, O_NONBLOCK); diff --git a/src/lib/evas/file/evas_module.c b/src/lib/evas/file/evas_module.c index 0378423a6a..0a5e302a22 100644 --- a/src/lib/evas/file/evas_module.c +++ b/src/lib/evas/file/evas_module.c @@ -615,3 +615,46 @@ _evas_module_libdir_get(void) if (!pfx) return NULL; return eina_prefix_lib_get(pfx); } + +EAPI const char * +evas_cserve_path_get(void) +{ + static char buf[PATH_MAX]; + const char *lib; + Eina_Bool shutdown = EINA_FALSE; + + if (!pfx) + { + shutdown = EINA_TRUE; + eina_init(); + pfx = eina_prefix_new + (NULL, _evas_module_libdir_get, "EVAS", "evas", "checkme", + PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, + PACKAGE_DATA_DIR, PACKAGE_DATA_DIR); + if (!pfx) + { + eina_shutdown(); + return NULL; + } + } + lib = eina_prefix_lib_get(pfx); + if (!lib) + { + if (shutdown) + { + eina_prefix_free(pfx); + pfx = NULL; + eina_shutdown(); + } + return NULL; + } + snprintf(buf, sizeof(buf), "%s/evas/cserve2/bin/%s/evas_cserve2", + lib, MODULE_ARCH); + if (shutdown) + { + eina_prefix_free(pfx); + pfx = NULL; + eina_shutdown(); + } + return buf; +}