From: Andrea Zagli Date: Sat, 24 Sep 2016 08:39:55 +0000 (+0200) Subject: PLUGINSDIR relocation. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=aa09ca2745e335589d443b55c7c3e5001a2d22e8;p=zakauthe%2Flibzakauthe PLUGINSDIR relocation. --- diff --git a/src/aute.c b/src/aute.c index 25405a6..0dad63c 100644 --- a/src/aute.c +++ b/src/aute.c @@ -21,8 +21,14 @@ #endif #include + +#include #include +#ifdef G_OS_WIN32 +#include +#endif + #include #ifdef HAVE_LIBZAKCONFI @@ -31,6 +37,8 @@ #include "libzakauthe.h" +static gchar *pluginsdir; + static void zak_authe_class_init (ZakAutheClass *class); static void zak_authe_init (ZakAuthe *form); @@ -64,6 +72,30 @@ struct _ZakAuthePrivate G_DEFINE_TYPE (ZakAuthe, zak_authe, G_TYPE_OBJECT) +#ifdef G_OS_WIN32 +static HMODULE backend_dll = NULL; + +BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved); + +BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + backend_dll = (HMODULE) hinstDLL; + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} +#endif + static void zak_authe_class_init (ZakAutheClass *class) { @@ -99,6 +131,34 @@ ZakAuthe { ZakAuthe *zakauthe; + #ifdef G_OS_WIN32 + + gchar *moddir; + gchar *p; + + moddir = g_win32_get_package_installation_directory_of_module (backend_dll); + + p = g_strrstr (moddir, g_strdup_printf ("%c", G_DIR_SEPARATOR)); + if (p != NULL + && (g_ascii_strcasecmp (p + 1, "src") == 0 + || g_ascii_strcasecmp (p + 1, ".libs") == 0)) + { + pluginsdir = g_strdup (LIB_ZAK_AUTHE_PLUGINS_DIR); + } + else + { + pluginsdir = g_build_filename (moddir, "lib", PACKAGE, "plugins", NULL); + g_warning ("%s",pluginsdir); + } + +#undef PLUGINSDIR + +#else + + pluginsdir = g_strdup (LIB_ZAK_AUTHE_PLUGINS_DIR); + +#endif + zakauthe = ZAK_AUTHE (g_object_new (zak_authe_get_type (), NULL)); return zakauthe; @@ -161,7 +221,7 @@ zak_authe_set_config (ZakAuthe *zakauthe, GSList *parameters) ret = TRUE; - peas_engine_add_search_path (peas_engine, LIB_ZAK_AUTHE_PLUGINS_DIR, NULL); + peas_engine_add_search_path (peas_engine, pluginsdir, NULL); lst_plugins = peas_engine_get_plugin_list (peas_engine); while (lst_plugins)