[evolution-data-server] Instead of duplicating libgnome function, use corresponding glib functions



commit 0abe312f6cede627402ea6264f608bc280857a07
Author: Fridrich Strba <fstrba strbadell localdomain>
Date:   Wed Jun 3 15:01:48 2009 +0200

    Instead of duplicating libgnome function, use corresponding glib functions
---
 libedataserver/e-data-server-util.c |   85 +----------------------------------
 1 files changed, 2 insertions(+), 83 deletions(-)

diff --git a/libedataserver/e-data-server-util.c b/libedataserver/e-data-server-util.c
index 45bf506..c5a3b19 100644
--- a/libedataserver/e-data-server-util.c
+++ b/libedataserver/e-data-server-util.c
@@ -517,88 +517,6 @@ e_filename_make_safe (gchar *string)
 
 #include <windows.h>
 
-/* The following function is lifted from libgnome. We don't want
- * libedataserver to depend on libgnome, especially as libgnome is
- * being deprecated. This function will move to GLib, presumably, but
- * isn't there yet.
- */
-
-/**
- * gnome_win32_get_prefixes:
- * @hmodule: The handle to a DLL (a HMODULE).
- * @full_prefix: Where the full UTF-8 path to the DLL's installation folder
- *               will be returned.
- * @cp_prefix: Where a system codepage version of
- *             the installation folder will be returned.
- *
- * This function looks up the installation prefix of the DLL (or EXE)
- * with handle @hmodule. The prefix using long filenames and in UTF-8
- * form is returned in @full_prefix. The prefix using short file names
- * (if present in the file system) and in the system codepage is
- * returned in @cp_prefix. To determine the installation prefix, the
- * full path to the DLL or EXE is first fetched. If the last folder
- * component in that path is called "bin", its parent folder is used,
- * otherwise the folder itself.
- *
- * If either can't be obtained, %NULL is stored. The caller should be
- * prepared to handle that.
- *
- * The returned character pointers are newly allocated and should be
- * freed with g_free when not longer needed.
- */
-static void
-get_prefixes (gpointer  hmodule,
-	      gchar    **full_prefix,
-	      gchar    **cp_prefix)
-{
-        wchar_t wcbfr[1000];
-        gchar cpbfr[1000];
-
-        g_return_if_fail (full_prefix != NULL);
-        g_return_if_fail (cp_prefix != NULL);
-
-        *full_prefix = NULL;
-        *cp_prefix = NULL;
-
-	if (GetModuleFileNameW ((HMODULE) hmodule, wcbfr, G_N_ELEMENTS (wcbfr))) {
-		*full_prefix = g_utf16_to_utf8 (wcbfr, -1,
-						NULL, NULL, NULL);
-		if (GetShortPathNameW (wcbfr, wcbfr, G_N_ELEMENTS (wcbfr)) &&
-		    /* Short pathnames always contain only
-		     * ASCII, I think, but just in case, be
-		     * prepared.
-		     */
-		    WideCharToMultiByte (CP_ACP, 0, wcbfr, -1,
-					 cpbfr, G_N_ELEMENTS (cpbfr),
-					 NULL, NULL))
-			*cp_prefix = g_strdup (cpbfr);
-		else if (*full_prefix)
-			*cp_prefix = g_locale_from_utf8 (*full_prefix, -1,
-							 NULL, NULL, NULL);
-	}
-
-        if (*full_prefix != NULL) {
-                gchar *p = strrchr (*full_prefix, '\\');
-                if (p != NULL)
-                        *p = '\0';
-
-                p = strrchr (*full_prefix, '\\');
-                if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0))
-                        *p = '\0';
-        }
-
-        /* cp_prefix is in system codepage */
-        if (*cp_prefix != NULL) {
-                gchar *p = _mbsrchr (*cp_prefix, '\\');
-                if (p != NULL)
-                        *p = '\0';
-
-                p = _mbsrchr (*cp_prefix, '\\');
-                if (p && (g_ascii_strcasecmp (p + 1, "bin") == 0))
-                        *p = '\0';
-        }
-}
-
 static const gchar *prefix = NULL;
 static const gchar *cp_prefix;
 
@@ -673,7 +591,8 @@ setup (void)
         }
 
 	/* This requires that the libedataserver DLL is installed in $bindir */
-        get_prefixes (hmodule, &full_pfx, &cp_pfx);
+	full_pfx = g_win32_get_package_installation_directory_of_module(hmodule);
+	cp_pfx = g_win32_locale_filename_from_utf8(full_pfx);
 
 	prefix = g_strdup (full_pfx);
 	cp_prefix = g_strdup (cp_pfx);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]