[evolution-data-server/evolution-data-server-3-12] Bug 721128 - Make Evolution-Data-Server build under Win32
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/evolution-data-server-3-12] Bug 721128 - Make Evolution-Data-Server build under Win32
- Date: Sun, 1 Jun 2014 19:19:40 +0000 (UTC)
commit 9e0801382b1c8ec48c74bf58cfb24fc696b1aea7
Author: Tarnyko <tarnyko tarnyko net>
Date: Sun Jun 1 21:15:11 2014 +0200
Bug 721128 - Make Evolution-Data-Server build under Win32
addressbook/backends/file/e-book-backend-file.c | 20 ++++++++++
addressbook/libebook-contacts/e-contact.c | 2 +-
camel/camel-mime-utils.c | 22 +++++++++++
camel/camel-win32.c | 47 ++++++++++++++++++----
configure.ac | 3 +-
tests/libedataserver/e-source-test.c | 12 +++++-
6 files changed, 94 insertions(+), 12 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index 7838947..4d221c9 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -381,7 +381,27 @@ hard_link_photo (EBookBackendFile *bf,
i++;
+ #ifdef G_OS_WIN32
+ {
+ GFile *src_file = g_file_new_for_path (src_filename);
+ GFile *dst_file = g_file_new_for_path (fullname);
+ GError *copy_error = NULL;
+
+ g_file_copy (src_file, dst_file, G_FILE_COPY_NONE,
+ NULL, NULL, NULL, ©_error);
+
+ if (copy_error != NULL) {
+ g_error_free (copy_error);
+ ret = -1;
+ } else
+ ret = 0;
+
+ g_object_unref (src_file);
+ g_object_unref (dst_file);
+ }
+ #else
ret = link (src_filename, fullname);
+ #endif
} while (ret < 0 && errno == EEXIST);
diff --git a/addressbook/libebook-contacts/e-contact.c b/addressbook/libebook-contacts/e-contact.c
index a2a5ac4..dce1e0e 100644
--- a/addressbook/libebook-contacts/e-contact.c
+++ b/addressbook/libebook-contacts/e-contact.c
@@ -44,7 +44,7 @@
#include "e-name-western.h"
#ifdef G_OS_WIN32
-#include "libedataserver/e-data-server-util.h"
+#include "libedataserver/libedataserver.h"
#undef LOCALEDIR
#define LOCALEDIR e_util_get_localedir ()
#endif
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 185e562..88b3fa7 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -61,6 +61,28 @@
#define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
#endif
+#if !defined HAVE_LOCALTIME_R && !defined localtime_r
+# ifdef _LIBC
+# define localtime_r __localtime_r
+# else
+/* Approximate localtime_r as best we can in its absence. */
+# define localtime_r my_localtime_r
+static struct tm *localtime_r (const time_t *, struct tm *);
+static struct tm *
+localtime_r (t,
+ tp)
+ const time_t *t;
+ struct tm *tp;
+{
+ struct tm *l = localtime (t);
+ if (!l)
+ return 0;
+ *tp = *l;
+ return tp;
+}
+# endif /* !_LIBC */
+#endif /* HAVE_LOCALTIME_R && !defined (localtime_r) */
+
/* for all non-essential warnings ... */
#define w(x)
diff --git a/camel/camel-win32.c b/camel/camel-win32.c
index 89738fb..b45104c 100644
--- a/camel/camel-win32.c
+++ b/camel/camel-win32.c
@@ -30,6 +30,7 @@
#include "camel.h"
+static HMODULE hmodule;
G_LOCK_DEFINE_STATIC (mutex);
/* localedir uses system codepage as it is passed to the non-UTF8ified
@@ -38,14 +39,11 @@ G_LOCK_DEFINE_STATIC (mutex);
static const gchar *localedir = NULL;
/* The others are in UTF-8 */
+static const gchar *prefix = NULL;
+static const gchar *cp_prefix;
static const gchar *libexecdir;
static const gchar *providerdir;
-/* XXX Where do these get defined? e-data-server-util.h just has
- * declarations for e_util_get_prefix() and e_util_get_cp_prefix(). */
-static const gchar * get_prefix (void) G_GNUC_CONST;
-static const gchar * get_cp_prefix (void) G_GNUC_CONST;
-
static gchar *
replace_prefix (const gchar *configure_time_prefix,
const gchar *runtime_prefix,
@@ -73,19 +71,31 @@ replace_prefix (const gchar *configure_time_prefix,
static void
setup (void)
{
+ gchar *full_pfx;
+ gchar *cp_pfx;
+
G_LOCK (mutex);
- if (localedir != NULL) {
+ if (prefix != NULL) {
G_UNLOCK (mutex);
return;
}
+ /* This requires that the libedataserver DLL is installed in $bindir */
+ 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);
+
+ g_free (full_pfx);
+ g_free (cp_pfx);
localedir = replace_prefix (
- E_DATA_SERVER_PREFIX, get_cp_prefix (), LOCALEDIR);
+ E_DATA_SERVER_PREFIX, cp_prefix, LOCALEDIR);
libexecdir = replace_prefix (
- E_DATA_SERVER_PREFIX, get_prefix (), CAMEL_LIBEXECDIR);
+ E_DATA_SERVER_PREFIX, prefix, CAMEL_LIBEXECDIR);
providerdir = replace_prefix (
- E_DATA_SERVER_PREFIX, get_prefix (), CAMEL_PROVIDERDIR);
+ E_DATA_SERVER_PREFIX, prefix, CAMEL_PROVIDERDIR);
G_UNLOCK (mutex);
}
@@ -103,3 +113,22 @@ _camel_get_##varbl (void) \
GETTER(localedir)
GETTER(libexecdir)
GETTER(providerdir)
+
+/* Silence gcc with a prototype. Yes, this is silly. */
+BOOL WINAPI DllMain (HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved);
+
+/* Minimal DllMain that just tucks away the DLL's HMODULE */
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved)
+{
+ switch (fdwReason) {
+ case DLL_PROCESS_ATTACH:
+ hmodule = hinstDLL;
+ break;
+ }
+ return TRUE;
+}
diff --git a/configure.ac b/configure.ac
index bc76405..f938bce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -337,7 +337,6 @@ case "$host" in
DL_LIB=''
LIBEXECDIR_IN_SERVER_FILE='../../../libexec'
AC_CACHE_VAL(ac_cv_have_addrinfo, [ac_cv_have_addrinfo=yes])
- AC_DEFINE(_WIN32_WINNT, 0x501, [To get getaddrinfo etc declarations])
;;
*openbsd*|*freebsd*)
os_win32='no'
@@ -386,6 +385,8 @@ PKG_CHECK_MODULES(GNOME_PLATFORM,
if test x$os_win32 = xno; then
PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0])
+else
+ PKG_CHECK_MODULES(GIO_UNIX, [gio-windows-2.0])
fi
dnl ******************************
diff --git a/tests/libedataserver/e-source-test.c b/tests/libedataserver/e-source-test.c
index 90998ab..ea082f8 100644
--- a/tests/libedataserver/e-source-test.c
+++ b/tests/libedataserver/e-source-test.c
@@ -16,10 +16,13 @@
*/
#include <string.h>
-#include <gio/gunixoutputstream.h>
#include <libedataserver/libedataserver.h>
+#ifndef G_OS_WIN32
+#include <gio/gunixoutputstream.h>
+#endif
+
#define SIMPLE_KEY_FILE \
"[Data Source]\n" \
"DisplayName=Simple Test Case\n" \
@@ -53,7 +56,9 @@ static void
setup_test_source (TestESource *test,
const gchar *content)
{
+#ifndef G_OS_WIN32
GOutputStream *stream;
+#endif
gchar *filename;
gint fd;
GError *error = NULL;
@@ -63,11 +68,16 @@ setup_test_source (TestESource *test,
g_assert_no_error (error);
/* Write the given content to the temporary key file. */
+#ifdef G_OS_WIN32
+ close (fd);
+ g_file_set_contents (filename, content, strlen (content), &error);
+#else
stream = g_unix_output_stream_new (fd, TRUE);
g_output_stream_write_all (
stream, content, strlen (content), NULL, NULL, &error);
g_object_unref (stream);
g_assert_no_error (error);
+#endif
/* Create a GFile that points to the temporary key file. */
test->file = g_file_new_for_path (filename);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]