Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/config.h.mingw b/config.h.mingw
- --- a/config.h.mingw
- +++ b/config.h.mingw
- @@ -406,10 +406,10 @@
- */
- #define HAVE_VSNPRINTF 1
- -#define FINCH_LIBDIR wpurple_lib_dir()
- -#define PIDGIN_LIBDIR wpurple_lib_dir()
- +#define FINCH_LIBDIR wpurple_lib_dir(NULL)
- +#define PIDGIN_LIBDIR wpurple_lib_dir(NULL)
- #define PURPLE_DATADIR wpurple_install_dir()
- -#define PURPLE_LIBDIR wpurple_lib_dir()
- +#define PURPLE_LIBDIR wpurple_lib_dir(NULL)
- #define PURPLE_LOCALEDIR wpurple_locale_dir()
- #define PURPLE_SYSCONFDIR wpurple_sysconf_dir()
- diff --git a/configure.ac b/configure.ac
- --- a/configure.ac
- +++ b/configure.ac
- @@ -177,12 +177,46 @@
- AC_C_BIGENDIAN
- +AC_ARG_WITH(win32-dirs, [AS_HELP_STRING([--with-win32-dirs=<classic|fhs>],
- + [use win32 classic (Program Files-like) or FHS (unix-like) directory structure (default: classic)])], [
- + if test "x$withval" != "xclassic" -a "x$withval" != "xfhs" ; then
- + AC_MSG_ERROR([Unsupported win32-dirs option. Please choose "classic" or "fhs".])
- + fi
- + with_win32_dirs="$withval"
- + ], with_win32_dirs="classic")
- +if test "x$is_win32" = "xyes" -a "x$with_win32_dirs" = "xfhs" ; then
- + AC_DEFINE(USE_WIN32_FHS, 1, [Define to 1, to use FHS on win32.])
- +fi
- +
- dnl Check for directories
- if test "x$is_win32" = "xyes" ; then
- - purple_datadir="wpurple_install_dir()"
- - purple_libdir="wpurple_lib_dir()"
- - pidgin_libdir="wpurple_lib_dir()"
- - finch_libdir="wpurple_lib_dir()"
- + if test "x$with_win32_dirs" = "xfhs" ; then
- + AS_AC_EXPAND(win32_fhs_bindir, "$bindir")
- + AC_DEFINE_UNQUOTED([WIN32_FHS_BINDIR], ["$win32_fhs_bindir"],
- + [bindir, as defined by configure])
- + AS_AC_EXPAND(win32_fhs_libdir, "$libdir")
- + AC_DEFINE_UNQUOTED([WIN32_FHS_LIBDIR], ["$win32_fhs_libdir"],
- + [libdir, as defined by configure])
- + AS_AC_EXPAND(win32_fhs_datadir, "$datadir")
- + AC_DEFINE_UNQUOTED([WIN32_FHS_DATADIR], ["$win32_fhs_datadir"],
- + [datadir, as defined by configure])
- + AS_AC_EXPAND(win32_fhs_sysconfdir, "$sysconfdir")
- + AC_DEFINE_UNQUOTED([WIN32_FHS_SYSCONFDIR], ["$win32_fhs_sysconfdir"],
- + [sysconfdir, as defined by configure])
- + AS_AC_EXPAND(win32_fhs_localedir, "$localedir")
- + AC_DEFINE_UNQUOTED([WIN32_FHS_LOCALEDIR], ["$win32_fhs_localedir"],
- + [localedir, as defined by configure])
- +
- + purple_libdir="wpurple_lib_dir(\"purple-$PURPLE_MAJOR_VERSION\")"
- + pidgin_libdir="wpurple_lib_dir(\"pidgin-$PURPLE_MAJOR_VERSION\")"
- + finch_libdir="wpurple_lib_dir(\"finch-$PURPLE_MAJOR_VERSION\")"
- + else
- + purple_libdir="wpurple_lib_dir(NULL)"
- + pidgin_libdir="wpurple_lib_dir(NULL)"
- + finch_libdir="wpurple_lib_dir(NULL)"
- + fi
- +
- + purple_datadir="wpurple_data_dir()"
- purple_sysconfdir="wpurple_sysconf_dir()"
- purple_localedir="wpurple_locale_dir()"
- else
- diff --git a/libpurple/certificate.c b/libpurple/certificate.c
- --- a/libpurple/certificate.c
- +++ b/libpurple/certificate.c
- @@ -922,7 +922,7 @@
- x509_ca_paths = g_list_append(x509_ca_paths,
- g_strdup(SSL_CERTIFICATES_DIR));
- #endif
- -#ifdef _WIN32
- +#if defined(_WIN32) && !defined(USE_WIN32_FHS)
- x509_ca_paths = g_list_append(x509_ca_paths, g_build_filename(
- PURPLE_DATADIR, "ca-certs", NULL));
- #else
- diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
- --- a/libpurple/protocols/jabber/jabber.c
- +++ b/libpurple/protocols/jabber/jabber.c
- @@ -3814,7 +3814,7 @@
- if (!sasl_initialized) {
- sasl_initialized = TRUE;
- #ifdef _WIN32
- - sasldir = g_build_filename(wpurple_install_dir(), "sasl2", NULL);
- + sasldir = g_build_filename(wpurple_bin_dir(), "sasl2", NULL);
- sasl_set_path(SASL_PATH_TYPE_PLUGIN, sasldir);
- g_free(sasldir);
- /* Suppress error popups for failing to load sasl plugins */
- diff --git a/libpurple/win32/win32dep.c b/libpurple/win32/win32dep.c
- --- a/libpurple/win32/win32dep.c
- +++ b/libpurple/win32/win32dep.c
- @@ -29,10 +29,12 @@
- #include "glibcompat.h"
- #include "notify.h"
- +#define MAX_PATH_LEN 2048
- +
- /*
- * LOCALS
- */
- -static char *app_data_dir = NULL, *install_dir = NULL,
- +static char *app_data_dir = NULL, *bin_dir = NULL, *data_dir = NULL,
- *lib_dir = NULL, *locale_dir = NULL, *sysconf_dir = NULL;
- static HINSTANCE libpurpledll_hInstance = NULL;
- @@ -128,12 +130,17 @@
- return retval;
- }
- -const char *wpurple_install_dir(void) {
- +const char *wpurple_bin_dir(void) {
- static gboolean initialized = FALSE;
- if (!initialized) {
- char *tmp = NULL;
- wchar_t winstall_dir[MAXPATHLEN];
- +
- + /* We might use g_win32_get_package_installation_directory_of_module
- + * here, but we won't because this routine strips bin or lib
- + * part of the path.
- + */
- if (GetModuleFileNameW(libpurpledll_hInstance, winstall_dir,
- MAXPATHLEN) > 0) {
- tmp = g_utf16_to_utf8(winstall_dir, -1,
- @@ -147,42 +154,138 @@
- g_free(tmp);
- return NULL;
- } else {
- - install_dir = g_path_get_dirname(tmp);
- + bin_dir = g_path_get_dirname(tmp);
- g_free(tmp);
- initialized = TRUE;
- }
- }
- - return install_dir;
- + return bin_dir;
- }
- -const char *wpurple_lib_dir(void) {
- +#ifdef USE_WIN32_FHS
- +static gchar *
- +wpurple_install_relative_path(const gchar *abspath)
- +{
- + const gchar *bindir = WIN32_FHS_BINDIR;
- + const gchar *relpath;
- + int i, last_dirsep = -1, bin_esc_cnt;
- + gchar *ret;
- + GString *bin_esc;
- +
- + g_return_val_if_fail(bindir != NULL, NULL);
- + g_return_val_if_fail(bindir[0] != '\0', NULL);
- + g_return_val_if_fail(abspath != NULL, NULL);
- + g_return_val_if_fail(abspath[0] != '\0', NULL);
- +
- + /* let's find the common prefix of those paths */
- + for (i = 0; bindir[i] == abspath[i]; i++) {
- + if (bindir[i] == '\0')
- + break;
- + if (bindir[i] == '\\' || bindir[i] == '/')
- + last_dirsep = i;
- + }
- + if (bindir[i] == '\0' && (abspath[i] == '\\' || abspath[i] == '/'))
- + last_dirsep = i;
- + if (abspath[i] == '\0' && (bindir[i] == '\\' || bindir[i] == '/'))
- + last_dirsep = i;
- +
- + /* there is no common prefix, return absolute path */
- + if (last_dirsep == -1)
- + return g_strdup(abspath);
- +
- + /* let's check, how many dirs we need to go up to the common prefix */
- + bin_esc_cnt = 0;
- + for (i = last_dirsep; bindir[i]; i++) {
- + if (bindir[i] != '\\' && bindir[i] != '/')
- + continue;
- + if (bindir[i + 1] == '\0') /* trailing dir separator */
- + break;
- + bin_esc_cnt++;
- + }
- + bin_esc = g_string_new("");
- + for (i = 0; i < bin_esc_cnt; i++)
- + g_string_append(bin_esc, ".." G_DIR_SEPARATOR_S);
- +
- + /* now, we need to go back deeper into the directory tree */
- + relpath = &abspath[last_dirsep];
- + if (relpath[0] != '\0')
- + relpath++;
- +
- + /* - enter bin dir
- + * - escape it to the common prefix
- + * - dive into the abspath dir
- + */
- + ret = g_build_filename(wpurple_bin_dir(), bin_esc, relpath, NULL);
- + g_string_free(bin_esc, TRUE);
- +
- + purple_debug_misc("wpurple", "wpurple_install_relative_path(%s) = %s",
- + abspath, ret);
- +
- + return ret;
- +}
- +#endif
- +
- +const char *
- +wpurple_data_dir(void) {
- +#ifdef USE_WIN32_FHS
- static gboolean initialized = FALSE;
- + if (initialized)
- + return data_dir;
- + data_dir = wpurple_install_relative_path(WIN32_FHS_DATADIR);
- + initialized = TRUE;
- +
- + return data_dir;
- +#else
- + return wpurple_bin_dir();
- +#endif
- +}
- +
- +
- +const char *wpurple_lib_dir(const char *subdir)
- +{
- + static gboolean initialized = FALSE;
- + static gchar subpath[MAX_PATH_LEN];
- if (!initialized) {
- - const char *inst_dir = wpurple_install_dir();
- +#ifdef USE_WIN32_FHS
- + lib_dir = wpurple_install_relative_path(WIN32_FHS_LIBDIR);
- + initialized = TRUE;
- +#else
- + const char *inst_dir = wpurple_bin_dir();
- if (inst_dir != NULL) {
- lib_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "plugins", inst_dir);
- initialized = TRUE;
- } else {
- return NULL;
- }
- +#endif
- }
- - return lib_dir;
- + if (subdir == NULL)
- + return lib_dir;
- +
- + g_snprintf(subpath, sizeof(subpath),
- + "%s" G_DIR_SEPARATOR_S "%s", lib_dir, subdir);
- + return subpath;
- }
- const char *wpurple_locale_dir(void) {
- static gboolean initialized = FALSE;
- if (!initialized) {
- - const char *inst_dir = wpurple_install_dir();
- +#ifdef USE_WIN32_FHS
- + locale_dir = wpurple_install_relative_path(WIN32_FHS_LOCALEDIR);
- + initialized = TRUE;
- +#else
- + const char *inst_dir = wpurple_bin_dir();
- if (inst_dir != NULL) {
- locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", inst_dir);
- initialized = TRUE;
- } else {
- return NULL;
- }
- +#endif
- }
- return locale_dir;
- @@ -212,7 +315,11 @@
- static gboolean initialized = FALSE;
- if (!initialized) {
- +#ifdef USE_WIN32_FHS
- + sysconf_dir = wpurple_install_relative_path(WIN32_FHS_SYSCONFDIR);
- +#else
- sysconf_dir = wpurple_get_special_folder(CSIDL_COMMON_APPDATA);
- +#endif
- initialized = TRUE;
- }
- @@ -540,13 +647,15 @@
- WSACleanup();
- g_free(app_data_dir);
- - g_free(install_dir);
- + g_free(bin_dir);
- + g_free(data_dir);
- g_free(lib_dir);
- g_free(locale_dir);
- g_free(sysconf_dir);
- app_data_dir = NULL;
- - install_dir = NULL;
- + bin_dir = NULL;
- + data_dir = NULL;
- lib_dir = NULL;
- locale_dir = NULL;
- sysconf_dir = NULL;
- diff --git a/libpurple/win32/win32dep.h b/libpurple/win32/win32dep.h
- --- a/libpurple/win32/win32dep.h
- +++ b/libpurple/win32/win32dep.h
- @@ -69,8 +69,9 @@
- /* Determine Purple paths */
- gchar *wpurple_get_special_folder(int folder_type); /* needs to be g_free'd */
- -const char *wpurple_install_dir(void);
- -const char *wpurple_lib_dir(void);
- +const char *wpurple_bin_dir(void);
- +const char *wpurple_data_dir(void);
- +const char *wpurple_lib_dir(const char *subdir);
- const char *wpurple_locale_dir(void);
- const char *wpurple_home_dir(void);
- const char *wpurple_sysconf_dir(void);
- diff --git a/pidgin/gtkconv-theme.c b/pidgin/gtkconv-theme.c
- --- a/pidgin/gtkconv-theme.c
- +++ b/pidgin/gtkconv-theme.c
- @@ -125,7 +125,7 @@
- if (!g_file_test(file, G_FILE_TEST_EXISTS)) {
- g_free(file);
- -#ifdef _WIN32
- +#if defined(_WIN32) && !defined(USE_WIN32_FHS)
- file = g_build_filename(PURPLE_DATADIR,
- "theme", "Template.html", NULL);
- #else
- diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
- --- a/pidgin/gtkconv.c
- +++ b/pidgin/gtkconv.c
- @@ -8940,7 +8940,7 @@
- PURPLE_CALLBACK(wrote_msg_update_unseen_cb), NULL);
- purple_theme_manager_register_type(g_object_new(PIDGIN_TYPE_CONV_THEME_LOADER, "type", "conversation", NULL));
- -#ifdef _WIN32
- +#if defined(_WIN32) && !defined(USE_WIN32_FHS)
- theme_dir = g_build_filename(PURPLE_DATADIR, "theme", NULL);
- #else
- theme_dir = g_build_filename(PURPLE_DATADIR, "pidgin", "theme", NULL);
- diff --git a/pidgin/plugins/win32/winprefs/winprefs.c b/pidgin/plugins/win32/winprefs/winprefs.c
- --- a/pidgin/plugins/win32/winprefs/winprefs.c
- +++ b/pidgin/plugins/win32/winprefs/winprefs.c
- @@ -190,7 +190,7 @@
- char *runval = NULL;
- if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)))
- - runval = g_strdup_printf("\"%s" G_DIR_SEPARATOR_S "pidgin.exe\"", wpurple_install_dir());
- + runval = g_strdup_printf("\"%s" G_DIR_SEPARATOR_S "pidgin.exe\"", wpurple_bin_dir());
- if(!wpurple_write_reg_string(HKEY_CURRENT_USER, RUNKEY, "Pidgin", runval)
- /* For Win98 */
- diff --git a/pidgin/win32/gtkwin32dep.c b/pidgin/win32/gtkwin32dep.c
- --- a/pidgin/win32/gtkwin32dep.c
- +++ b/pidgin/win32/gtkwin32dep.c
- @@ -396,7 +396,7 @@
- if (purple_debug_is_verbose())
- purple_debug_misc("winpidgin", "winpidgin_init start\n");
- - exchndl_dll_path = g_build_filename(wpurple_install_dir(), "exchndl.dll", NULL);
- + exchndl_dll_path = g_build_filename(wpurple_bin_dir(), "exchndl.dll", NULL);
- MySetLogFile = (LPFNSETLOGFILE) wpurple_find_and_loadproc(exchndl_dll_path, "SetLogFile");
- g_free(exchndl_dll_path);
- exchndl_dll_path = NULL;
- diff --git a/pidgin/win32/wspell.c b/pidgin/win32/wspell.c
- --- a/pidgin/win32/wspell.c
- +++ b/pidgin/win32/wspell.c
- @@ -79,7 +79,7 @@
- gchar *tmp, *tmp2;
- const char *path = g_getenv("PATH");
- - tmp = g_build_filename(wpurple_install_dir(), "spellcheck", NULL);
- + tmp = g_build_filename(wpurple_bin_dir(), "spellcheck", NULL);
- tmp2 = g_strdup_printf("%s%s%s", tmp,
- (path ? G_SEARCHPATH_SEPARATOR_S : ""),
- (path ? path : ""));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement