[evolution-data-server] Bug 681321 - Support both old and new-buf libxml2 APIs
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 681321 - Support both old and new-buf libxml2 APIs
- Date: Mon, 13 Aug 2012 14:54:23 +0000 (UTC)
commit 679b10d75730e81fa268e11cfda289a27fd3e306
Author: Colin Walters <walters verbum org>
Date: Mon Aug 13 09:50:50 2012 -0400
Bug 681321 - Support both old and new-buf libxml2 APIs
libxml2 changed the API for xmlOutputBuffer incompatibly.
See https://mail.gnome.org/archives/desktop-devel-list/2012-August/msg00004.html
calendar/backends/caldav/e-cal-backend-caldav.c | 39 +++++++++++++++++------
modules/online-accounts/goaewsclient.c | 25 ++++++++++++--
2 files changed, 50 insertions(+), 14 deletions(-)
---
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 0219b34..f96907e 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -1188,6 +1188,19 @@ caldav_authenticate (ECalBackendCalDAV *cbdav,
return success;
}
+static gconstpointer
+compat_libxml_output_buffer_get_content (xmlOutputBufferPtr buf,
+ gsize *out_len)
+{
+#ifdef LIBXML2_NEW_BUFFER
+ *out_len = xmlOutputBufferGetSize (buf);
+ return xmlOutputBufferGetContent (buf);
+#else
+ *out_len = buf->buffer->use;
+ return buf->buffer->content;
+#endif
+}
+
/* Returns whether calendar changed on the server. This works only when server
* supports 'getctag' extension. */
static gboolean
@@ -1198,6 +1211,8 @@ check_calendar_changed_on_server (ECalBackendCalDAV *cbdav)
xmlDocPtr doc;
xmlNodePtr root, node;
xmlNsPtr ns, nsdav;
+ gconstpointer buf_content;
+ gsize buf_size;
gboolean result = TRUE;
g_return_val_if_fail (cbdav != NULL, TRUE);
@@ -1230,11 +1245,11 @@ check_calendar_changed_on_server (ECalBackendCalDAV *cbdav)
soup_message_headers_append (message->request_headers,
"Depth", "0");
+ buf_content = compat_libxml_output_buffer_get_content (buf, &buf_size);
soup_message_set_request (message,
"application/xml",
SOUP_MEMORY_COPY,
- (gchar *) buf->buffer->content,
- buf->buffer->use);
+ buf_content, buf_size);
/* Send the request now */
send_and_handle_redirection (cbdav->priv->session, message, NULL);
@@ -1299,6 +1314,8 @@ caldav_server_list_objects (ECalBackendCalDAV *cbdav,
xmlDocPtr doc;
xmlNsPtr nsdav;
xmlNsPtr nscd;
+ gconstpointer buf_content;
+ gsize buf_size;
gboolean result;
/* Allocate the soup message */
@@ -1378,11 +1395,11 @@ caldav_server_list_objects (ECalBackendCalDAV *cbdav,
soup_message_headers_append (message->request_headers,
"Depth", "1");
+ buf_content = compat_libxml_output_buffer_get_content (buf, &buf_size);
soup_message_set_request (message,
"application/xml",
SOUP_MEMORY_COPY,
- (gchar *) buf->buffer->content,
- buf->buffer->use);
+ buf_content, buf_size);
/* Send the request now */
send_and_handle_redirection (cbdav->priv->session, message, NULL);
@@ -1795,6 +1812,8 @@ caldav_receive_schedule_outbox_url (ECalBackendCalDAV *cbdav)
xmlDocPtr doc;
xmlNodePtr root, node;
xmlNsPtr nsdav;
+ gconstpointer buf_content;
+ gsize buf_size;
gchar *owner = NULL;
g_return_val_if_fail (E_IS_CAL_BACKEND_CALDAV (cbdav), FALSE);
@@ -1820,11 +1839,11 @@ caldav_receive_schedule_outbox_url (ECalBackendCalDAV *cbdav)
soup_message_headers_append (message->request_headers, "User-Agent", "Evolution/" VERSION);
soup_message_headers_append (message->request_headers, "Depth", "0");
+ buf_content = compat_libxml_output_buffer_get_content (buf, &buf_size);
soup_message_set_request (message,
"application/xml",
SOUP_MEMORY_COPY,
- (gchar *) buf->buffer->content,
- buf->buffer->use);
+ buf_content, buf_size);
/* Send the request now */
send_and_handle_redirection (cbdav->priv->session, message, NULL);
@@ -1870,11 +1889,11 @@ caldav_receive_schedule_outbox_url (ECalBackendCalDAV *cbdav)
soup_message_headers_append (message->request_headers, "User-Agent", "Evolution/" VERSION);
soup_message_headers_append (message->request_headers, "Depth", "0");
+ buf_content = compat_libxml_output_buffer_get_content (buf, &buf_size);
soup_message_set_request (message,
- "application/xml",
- SOUP_MEMORY_COPY,
- (gchar *) buf->buffer->content,
- buf->buffer->use);
+ "application/xml",
+ SOUP_MEMORY_COPY,
+ buf_content, buf_size);
/* Send the request now */
send_and_handle_redirection (cbdav->priv->session, message, NULL);
diff --git a/modules/online-accounts/goaewsclient.c b/modules/online-accounts/goaewsclient.c
index 84374b9..ab18a1d 100644
--- a/modules/online-accounts/goaewsclient.c
+++ b/modules/online-accounts/goaewsclient.c
@@ -309,22 +309,37 @@ ews_create_autodiscover_xml (const gchar *email)
return doc;
}
+static gconstpointer
+compat_libxml_output_buffer_get_content (xmlOutputBufferPtr buf,
+ gsize *out_len)
+{
+#ifdef LIBXML2_NEW_BUFFER
+ *out_len = xmlOutputBufferGetSize (buf);
+ return xmlOutputBufferGetContent (buf);
+#else
+ *out_len = buf->buffer->use;
+ return buf->buffer->content;
+#endif
+}
+
static void
ews_post_restarted_cb (SoupMessage *msg,
gpointer data)
{
xmlOutputBuffer *buf = data;
+ gconstpointer buf_content;
+ gsize buf_size;
/* In violation of RFC2616, libsoup will change a
* POST request to a GET on receiving a 302 redirect. */
g_debug ("Working around libsoup bug with redirect");
g_object_set (msg, SOUP_MESSAGE_METHOD, "POST", NULL);
+ buf_content = compat_libxml_output_buffer_get_content (buf, &buf_size);
soup_message_set_request (
msg, "text/xml; charset=utf-8",
SOUP_MEMORY_COPY,
- (gchar *) buf->buffer->content,
- buf->buffer->use);
+ buf_content, buf_size);
}
static SoupMessage *
@@ -332,17 +347,19 @@ ews_create_msg_for_url (const gchar *url,
xmlOutputBuffer *buf)
{
SoupMessage *msg;
+ gconstpointer buf_content;
+ gsize buf_size;
msg = soup_message_new (buf != NULL ? "POST" : "GET", url);
soup_message_headers_append (
msg->request_headers, "User-Agent", "libews/0.1");
if (buf != NULL) {
+ buf_content = compat_libxml_output_buffer_get_content (buf, &buf_size);
soup_message_set_request (
msg, "text/xml; charset=utf-8",
SOUP_MEMORY_COPY,
- (gchar *) buf->buffer->content,
- buf->buffer->use);
+ buf_content, buf_size);
g_signal_connect (
msg, "restarted",
G_CALLBACK (ews_post_restarted_cb), buf);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]