[evolution-data-server] Bug #597157 - Better error handling and dbus signal names without '-'
- From: Milan Crha <mcrha src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #597157 - Better error handling and dbus signal names without '-'
- Date: Thu, 8 Oct 2009 09:02:23 +0000 (UTC)
commit 518975c957cb27123701e7578be159c4c3863873
Author: Milan Crha <mcrha redhat com>
Date: Thu Oct 8 11:01:32 2009 +0200
Bug #597157 - Better error handling and dbus signal names without '-'
calendar/libecal/e-cal.c | 10 +++---
calendar/libedata-cal/e-data-cal-factory.c | 38 ++++++++++++++++++++-------
calendar/libedata-cal/e-data-cal.xml | 4 +-
3 files changed, 35 insertions(+), 17 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index e365aeb..1b8a502 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -740,7 +740,7 @@ e_cal_new (ESource *source, ECalSourceType type)
GError *error = NULL;
if (!e_cal_activate (&error)) {
- g_warning("Cannot activate ECal: %s\n", error->message);
+ g_warning("Cannot activate ECal: %s\n", error ? error->message : "Unknown error");
g_error_free (error);
return NULL;
}
@@ -755,7 +755,7 @@ e_cal_new (ESource *source, ECalSourceType type)
xml = e_source_to_standalone_xml (priv->source);
if (!org_gnome_evolution_dataserver_calendar_CalFactory_get_cal (factory_proxy, xml, convert_type (priv->type), &path, &error)) {
g_free (xml);
- g_warning ("Cannot get cal from factory: %s", error->message);
+ g_warning ("Cannot get cal from factory: %s", error ? error->message : "Unknown error");
g_error_free (error);
g_object_unref (ecal);
return NULL;
@@ -1653,7 +1653,7 @@ e_cal_set_mode (ECal *ecal, CalMode mode)
g_return_val_if_fail (priv->load_state == E_CAL_LOAD_LOADED, FALSE);
if (!org_gnome_evolution_dataserver_calendar_Cal_set_mode (priv->proxy, mode, &error)) {
- g_printerr("%s: %s\n", __FUNCTION__, error->message);
+ g_printerr ("%s: %s\n", G_STRFUNC, error ? error->message : "Unknown error");
g_error_free (error);
return FALSE;
}
@@ -1804,7 +1804,7 @@ e_cal_get_object (ECal *ecal, const gchar *uid, const gchar *rid, icalcomponent
}
if (!org_gnome_evolution_dataserver_calendar_Cal_get_object (priv->proxy, uid, rid ? rid : "", &object, error)) {
- g_warning ("%s failed with uid %s, rid %s", __FUNCTION__, uid, rid ? rid : "");
+ g_warning ("%s failed with uid %s, rid %s", G_STRFUNC, uid, rid ? rid : "");
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
}
@@ -2486,7 +2486,7 @@ try_again:
goto try_again;
}
- g_message ("Failed to get recurrence objects for uid %s \n", error->message);
+ g_message ("Failed to get recurrence objects for uid %s \n", error ? error->message : "Unknown error");
g_clear_error (&error);
return;
}
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index d0a9993..905fe18 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -117,6 +117,23 @@ calobjtype_to_icalkind (const EDataCalObjType type)
return ICAL_NO_COMPONENT;
}
+static const gchar *
+calobjtype_to_string (const EDataCalObjType type)
+{
+ switch (type){
+ case Event:
+ return "VEVENT";
+ case Todo:
+ return "VTODO";
+ case Journal:
+ return "VJOURNAL";
+ case AnyType:
+ break;
+ }
+
+ return "UNKNOWN COMPONENT";
+}
+
static ECalSourceType
icalkind_to_ecalsourcetype (const icalcomponent_kind kind)
{
@@ -277,7 +294,6 @@ find_backend_cb (gpointer key, gpointer value, gpointer data)
}
}
-/* TODO: Error checking! */
static void
impl_CalFactory_getCal (EDataCalFactory *factory,
const gchar *source_xml,
@@ -292,8 +308,9 @@ impl_CalFactory_getCal (EDataCalFactory *factory,
gchar *str_uri;
EUri *uri;
gchar *uid_type_string;
- gchar *path, *sender;
+ gchar *path = NULL, *sender;
GList *list;
+ GError *error = NULL;
/* Remove a pending exit */
if (priv->exit_timeout) {
@@ -303,7 +320,6 @@ impl_CalFactory_getCal (EDataCalFactory *factory,
source = e_source_new_from_standalone_xml (source_xml);
if (!source) {
- /* TODO ERROR */
dbus_g_method_return_error (context, g_error_new (E_DATA_CAL_ERROR, NoSuchCal, _("Invalid source")));
return;
}
@@ -313,7 +329,6 @@ impl_CalFactory_getCal (EDataCalFactory *factory,
if (!str_uri) {
g_object_unref (source);
- /* TODO ERROR */
dbus_g_method_return_error (context, g_error_new (E_DATA_CAL_ERROR, NoSuchCal, _("Invalid source")));
return;
}
@@ -321,7 +336,6 @@ impl_CalFactory_getCal (EDataCalFactory *factory,
/* Parse the uri */
uri = e_uri_new (str_uri);
if (!uri) {
- /* TODO ERROR */
dbus_g_method_return_error (context, g_error_new (E_DATA_CAL_ERROR, NoSuchCal, _("Invalid URI")));
return;
}
@@ -331,8 +345,10 @@ impl_CalFactory_getCal (EDataCalFactory *factory,
/* Find the associated backend factory (if any) */
backend_factory = get_backend_factory (priv->methods, uri->protocol, calobjtype_to_icalkind (type));
if (!backend_factory) {
- /* FIXME Distinguish between method and kind failures? */
- /* TODO ERROR */
+ gchar *msg = g_strdup_printf (_("No backend factory for '%s' of '%s'"), uri->protocol, calobjtype_to_string (type));
+ error = g_error_new (E_DATA_CAL_ERROR, NoSuchCal, msg);
+ g_free (msg);
+
goto cleanup2;
}
@@ -370,8 +386,7 @@ impl_CalFactory_getCal (EDataCalFactory *factory,
backend = e_cal_backend_factory_new_backend (backend_factory, source);
if (!backend) {
- g_warning (G_STRLOC ": could not instantiate backend");
- /* TODO ERROR */
+ error = g_error_new (E_DATA_CAL_ERROR, NoSuchCal, _("Could not instantiate backend"));
goto cleanup;
}
@@ -419,7 +434,10 @@ impl_CalFactory_getCal (EDataCalFactory *factory,
g_free (uid_type_string);
g_object_unref (source);
- dbus_g_method_return (context, path);
+ if (error)
+ dbus_g_method_return_error (context, error);
+ else
+ dbus_g_method_return (context, path);
}
static void
diff --git a/calendar/libedata-cal/e-data-cal.xml b/calendar/libedata-cal/e-data-cal.xml
index fad272b..8b60530 100644
--- a/calendar/libedata-cal/e-data-cal.xml
+++ b/calendar/libedata-cal/e-data-cal.xml
@@ -4,9 +4,9 @@
<interface name="org.gnome.evolution.dataserver.calendar.Cal">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="EDataCal"/>
- <signal name="auth-required"/>
+ <signal name="auth_required"/>
- <signal name="backend-error">
+ <signal name="backend_error">
<arg name="error" type="s"/>
</signal>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]