[evolution-ews] Make e_ews_connection_get_oal_detail_start generic enough to fetch differential file details as well
- From: Chenthill Palanisamy <pchen src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Make e_ews_connection_get_oal_detail_start generic enough to fetch differential file details as well
- Date: Tue, 28 Jun 2011 12:37:07 +0000 (UTC)
commit 4a33e0e112074f6e0e426fa36582b2889658348b
Author: Chenthill Palanisamy <pchenthill novell com>
Date: Tue Jun 28 15:35:07 2011 +0530
Make e_ews_connection_get_oal_detail_start generic enough to
fetch differential file details as well.
src/server/e-ews-connection.c | 82 ++++++++++++++++++++--------------------
src/server/e-ews-connection.h | 12 +++--
2 files changed, 48 insertions(+), 46 deletions(-)
---
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index ef75f7c..4cbde22 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -1227,6 +1227,7 @@ struct _oal_req_data {
GCancellable *cancellable;
gulong cancel_handler_id;
gchar *oal_id;
+ gchar *oal_element;
/* for dowloading oal file */
gchar *cache_filename;
@@ -1277,14 +1278,14 @@ get_content (xmlNodePtr node_ptr)
return s;
}
-static EwsOALDetails *
-parse_oal_full_details (xmlNode *node)
+static GSList *
+parse_oal_full_details (xmlNode *node, const gchar *element)
{
- EwsOALDetails *det = NULL;
+ GSList *elements = NULL;
for (node = node->children; node; node = node->next) {
- if (node->type == XML_ELEMENT_NODE && !strcmp((char *)node->name, "Full")) {
- det = g_new0 (EwsOALDetails, 1);
+ if (node->type == XML_ELEMENT_NODE && !strcmp((char *)node->name, element)) {
+ EwsOALDetails *det = g_new0 (EwsOALDetails, 1);
det->seq = get_property_as_int (node, "seq");
det->ver = get_property_as_int (node, "ver");
@@ -1292,12 +1293,14 @@ parse_oal_full_details (xmlNode *node)
det->uncompressed_size = get_property_as_int (node, "uncompressedsize");
det->sha = get_property (node, "uncompressedsize");
det->filename = g_strstrip (get_content (node));
-
- break;
+
+ elements = g_slist_prepend (elements, det);
+ if (!strcmp (element, "Full"))
+ break;
}
}
- return det;
+ return elements;
}
static void
@@ -1308,7 +1311,6 @@ oal_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data)
xmlDoc *doc;
xmlNode *node;
struct _oal_req_data *data = (struct _oal_req_data *) user_data;
- EwsOALDetails *oal_det = NULL;
GSList *oals = NULL;
if (status != 200) {
@@ -1349,7 +1351,7 @@ oal_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data)
if (!strcmp (id, data->oal_id)) {
/* parse details of full_details file */
- oal_det = parse_oal_full_details (node);
+ oals = parse_oal_full_details (node, data->oal_element);
g_free (id);
break;
@@ -1360,11 +1362,8 @@ oal_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data)
}
}
- if (!data->oal_id) {
- oals = g_slist_reverse (oals);
- g_simple_async_result_set_op_res_gpointer (data->simple, oals, NULL);
- } else
- g_simple_async_result_set_op_res_gpointer (data->simple, oal_det, NULL);
+ oals = g_slist_reverse (oals);
+ g_simple_async_result_set_op_res_gpointer (data->simple, oals, NULL);
exit:
if (data->cancellable)
@@ -1377,6 +1376,7 @@ exit:
g_simple_async_result_complete_in_idle (data->simple);
g_free (data->oal_id);
+ g_free (data->oal_element);
g_free (data);
}
@@ -1443,12 +1443,13 @@ e_ews_connection_get_oal_list_finish (EEwsConnection *cnc,
}
void
-e_ews_connection_get_oal_full_detail_start (EEwsConnection *cnc,
- const gchar *oab_url,
- const gchar *oal_id,
- GAsyncReadyCallback cb,
- GCancellable *cancellable,
- gpointer user_data)
+e_ews_connection_get_oal_detail_start (EEwsConnection *cnc,
+ const gchar *oab_url,
+ const gchar *oal_id,
+ const gchar *oal_element,
+ GAsyncReadyCallback cb,
+ GCancellable *cancellable,
+ gpointer user_data)
{
GSimpleAsyncResult *simple;
SoupMessage *msg;
@@ -1459,15 +1460,14 @@ e_ews_connection_get_oal_full_detail_start (EEwsConnection *cnc,
simple = g_simple_async_result_new (G_OBJECT (cnc),
cb,
user_data,
- e_ews_connection_get_oal_full_detail_start);
+ e_ews_connection_get_oal_detail_start);
data = g_new0 (struct _oal_req_data, 1);
data->cnc = cnc;
data->simple = simple;
data->cancellable = cancellable;
data->msg = msg;
-
- if (oal_id)
- data->oal_id = g_strdup (oal_id);
+ data->oal_id = g_strdup (oal_id);
+ data->oal_element = g_strdup (oal_element);
if (cancellable)
data->cancel_handler_id = g_cancellable_connect (cancellable,
@@ -1478,16 +1478,16 @@ e_ews_connection_get_oal_full_detail_start (EEwsConnection *cnc,
}
gboolean
-e_ews_connection_get_oal_full_detail_finish (EEwsConnection *cnc,
- GAsyncResult *result,
- EwsOALDetails **oal_det,
- GError **error)
+e_ews_connection_get_oal_detail_finish (EEwsConnection *cnc,
+ GAsyncResult *result,
+ GSList **elements,
+ GError **error)
{
GSimpleAsyncResult *simple;
g_return_val_if_fail (
g_simple_async_result_is_valid (
- result, G_OBJECT (cnc), e_ews_connection_get_oal_full_detail_start),
+ result, G_OBJECT (cnc), e_ews_connection_get_oal_detail_start),
FALSE);
simple = G_SIMPLE_ASYNC_RESULT (result);
@@ -1495,19 +1495,20 @@ e_ews_connection_get_oal_full_detail_finish (EEwsConnection *cnc,
if (g_simple_async_result_propagate_error (simple, error))
return FALSE;
- *oal_det= g_simple_async_result_get_op_res_gpointer (simple);
+ *elements = g_simple_async_result_get_op_res_gpointer (simple);
return TRUE;
}
gboolean
-e_ews_connection_get_oal_full_detail (EEwsConnection *cnc,
- const gchar *oab_url,
- const gchar *oal_id,
- EwsOALDetails **oal_det,
- GCancellable *cancellable,
- GError **error)
+e_ews_connection_get_oal_detail (EEwsConnection *cnc,
+ const gchar *oab_url,
+ const gchar *oal_id,
+ const gchar *oal_element,
+ GSList **elements,
+ GCancellable *cancellable,
+ GError **error)
{
EwsSyncData *sync_data;
gboolean result;
@@ -1515,17 +1516,16 @@ e_ews_connection_get_oal_full_detail (EEwsConnection *cnc,
sync_data = g_new0 (EwsSyncData, 1);
sync_data->eflag = e_flag_new ();
- e_ews_connection_get_oal_full_detail_start
- (cnc, oab_url, oal_id,
+ e_ews_connection_get_oal_detail_start (cnc, oab_url, oal_id, oal_element,
ews_sync_reply_cb,
cancellable,
(gpointer) sync_data);
e_flag_wait (sync_data->eflag);
- result = e_ews_connection_get_oal_full_detail_finish
+ result = e_ews_connection_get_oal_detail_finish
(cnc, sync_data->res,
- oal_det, error);
+ elements, error);
e_flag_free (sync_data->eflag);
g_object_unref (sync_data->res);
diff --git a/src/server/e-ews-connection.h b/src/server/e-ews-connection.h
index b9a4969..29b4239 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -568,23 +568,25 @@ gboolean e_ews_connection_get_oal_list_finish
GAsyncResult *result,
GSList **oals,
GError **error);
-void e_ews_connection_get_oal_full_detail_start
+void e_ews_connection_get_oal_detail_start
(EEwsConnection *cnc,
const gchar *oab_url,
const gchar *oal_id,
+ const gchar *oal_element,
GAsyncReadyCallback cb,
GCancellable *cancellable,
gpointer user_data);
-gboolean e_ews_connection_get_oal_full_detail_finish
+gboolean e_ews_connection_get_oal_detail_finish
(EEwsConnection *cnc,
GAsyncResult *result,
- EwsOALDetails **oal_det,
+ GSList **elements,
GError **error);
-gboolean e_ews_connection_get_oal_full_detail
+gboolean e_ews_connection_get_oal_detail
(EEwsConnection *cnc,
const gchar *oab_url,
const gchar *oal_id,
- EwsOALDetails **oal_det,
+ const gchar *oal_element,
+ GSList **elements,
GCancellable *cancellable,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]