[evolution-ews] Move ews_get_response_status() to ews-errors.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Move ews_get_response_status() to ews-errors.
- Date: Fri, 13 Jul 2012 12:34:28 +0000 (UTC)
commit 1a5b6e3ee23cc04633234eacfa62e9125e6d9340
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Jul 12 22:58:14 2012 -0400
Move ews_get_response_status() to ews-errors.
src/server/e-ews-connection.c | 51 --------------------------------
src/server/ews-errors.c | 64 +++++++++++++++++++++++++++++++++++++++++
src/server/ews-errors.h | 8 +++--
3 files changed, 69 insertions(+), 54 deletions(-)
---
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index ca5b3da..3765fdf 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -220,57 +220,6 @@ ews_parse_soap_fault (ESoapResponse *response,
}
static gboolean
-ews_get_response_status (ESoapParameter *param,
- GError **error)
-{
- ESoapParameter *subparam;
- gchar *value;
- gboolean ret = TRUE;
-
- value = e_soap_parameter_get_property (param, "ResponseClass");
-
- if (!g_ascii_strcasecmp (value, "Error")) {
- gchar *desc, *res;
- gint error_code = EWS_CONNECTION_ERROR_UNKNOWN;
-
- subparam = e_soap_parameter_get_first_child_by_name (param, "MessageText");
- desc = e_soap_parameter_get_string_value (subparam);
-
- subparam = e_soap_parameter_get_first_child_by_name (param, "ResponseCode");
- res = e_soap_parameter_get_string_value (subparam);
-
- error_code = ews_get_error_code ((const gchar *) res);
-
- /* FIXME: This happens because of a bug in the Exchange server,
- * which doesn't like returning <Recurrence> for any appointment
- * without a timezone, even if it's an all day event like a
- * birthday. We need to handle the error and correctly report it
- * to the user, but for now we'll just ignore it... */
- if (error_code != EWS_CONNECTION_ERROR_CORRUPTDATA &&
- /* Ick, another one. If we try to set the IsRead flag on certain
- * types of item (task requests, those stupid 'recall' requests),
- * it complains. We really need to find a better way to return
- * individual errors for each response to a multiple request; it
- * isn't necessarily the case that a single error should be reported
- * as an error for the whole transaction */
- error_code != EWS_CONNECTION_ERROR_INVALIDPROPERTYREQUEST) {
- g_set_error (error,
- EWS_CONNECTION_ERROR,
- error_code,
- "%s", desc);
- ret = FALSE;
- }
-
- g_free (desc);
- g_free (res);
- }
-
- g_free (value);
-
- return ret;
-}
-
-static gboolean
ews_next_request (gpointer _cnc)
{
EEwsConnection *cnc = _cnc;
diff --git a/src/server/ews-errors.c b/src/server/ews-errors.c
index 03bed9e..31105e6 100644
--- a/src/server/ews-errors.c
+++ b/src/server/ews-errors.c
@@ -321,3 +321,67 @@ ews_get_error_code (const gchar *str)
return error_code;
}
+
+gboolean
+ews_get_response_status (ESoapParameter *param,
+ GError **error)
+{
+ ESoapParameter *subparam;
+ gchar *value;
+ gchar *message_text;
+ gchar *response_code;
+ gint error_code;
+ gboolean success = TRUE;
+
+ value = e_soap_parameter_get_property (param, "ResponseClass");
+ g_return_val_if_fail (value != NULL, FALSE);
+
+ if (g_ascii_strcasecmp (value, "Error") != 0)
+ goto exit;
+
+ subparam = e_soap_parameter_get_first_child_by_name (param, "MessageText");
+ message_text = e_soap_parameter_get_string_value (subparam);
+
+ subparam = e_soap_parameter_get_first_child_by_name (param, "ResponseCode");
+ response_code = e_soap_parameter_get_string_value (subparam);
+ error_code = ews_get_error_code (response_code);
+
+ switch (error_code) {
+ case EWS_CONNECTION_ERROR_CORRUPTDATA:
+ /* FIXME: This happens because of a bug in the
+ * Exchange server, which doesn't like returning
+ * <Recurrence> for any appointment without a
+ * timezone, even if it's an all day event like a
+ * birthday. We need to handle the error and
+ * correctly report it to the user, but for now
+ * we'll just ignore it... */
+ break;
+
+ case EWS_CONNECTION_ERROR_INVALIDPROPERTYREQUEST:
+ /* Ick, another one. If we try to set the IsRead
+ * flag on certain types of item (task requests,
+ * those stupid 'recall' requests), it complains.
+ * We really need to find a better way to return
+ * individual errors for each response to a multiple
+ * request; it isn't necessarily the case that a
+ * single error should be reported as an error for
+ * the whole transaction */
+ break;
+
+ default:
+ g_set_error (
+ error, EWS_CONNECTION_ERROR,
+ error_code, "%s", message_text);
+ success = FALSE;
+ break;
+ }
+
+ g_free (message_text);
+ g_free (response_code);
+
+exit:
+ g_free (value);
+
+ return success;
+}
+
diff --git a/src/server/ews-errors.h b/src/server/ews-errors.h
index 86897e8..93a3331 100644
--- a/src/server/ews-errors.h
+++ b/src/server/ews-errors.h
@@ -1,7 +1,7 @@
#ifndef EWS_ERRORS_H
#define EWS_ERRORS_H
-#include <glib.h>
+#include <server/e-soap-response.h>
G_BEGIN_DECLS
@@ -309,8 +309,10 @@ struct EwsErrorMap {
gint error_code;
};
-gint ews_get_error_code (const gchar *str);
+gint ews_get_error_code (const gchar *str);
+gboolean ews_get_response_status (ESoapParameter *param,
+ GError **error);
G_END_DECLS
-#endif
+#endif /* EWS_ERRORS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]