summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-03-21 17:56:55 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-03-27 15:40:40 +0000
commit8ba869f6cc0f4af6073e6efeb8bbe276d5be8389 (patch)
treec8360c1bb12a95ebad20bb1543580b1917ec2076
parent65ccb152f3a7c477a4dc814abc741668590a0b04 (diff)
downloadtelepathy-mission-control-8ba869f6cc0f4af6073e6efeb8bbe276d5be8389.tar.gz
McdConnection: rewrite translate_g_error() using g_dbus_error_encode_gerror()
-rw-r--r--src/mcd-connection.c36
1 files changed, 5 insertions, 31 deletions
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index 88d63ee9..c6f0be22 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -1270,36 +1270,12 @@ mcd_connection_early_get_interfaces_cb (TpProxy *proxy,
}
static gchar *
-translate_g_error (GQuark domain,
- gint code,
- const gchar *message)
+translate_g_error (const GError *error)
{
- if (domain == TP_ERROR)
+ if (error->domain == TP_DBUS_ERRORS)
{
- return g_strdup (tp_error_get_dbus_name (code));
- }
- else if (domain == TP_DBUS_ERRORS)
- {
- switch (code)
+ switch (error->code)
{
- case TP_DBUS_ERROR_UNKNOWN_REMOTE_ERROR:
- {
- const gchar *p = strchr (message, ':');
-
- if (p != NULL)
- {
- gchar *tmp = g_strndup (message, message - p);
-
- /* The syntactic restrictions for error names are the same
- * as for interface names. */
- if (g_dbus_is_interface_name (tmp))
- return tmp;
-
- g_free (tmp);
- }
- }
- break;
-
case TP_DBUS_ERROR_NO_INTERFACE:
return g_strdup (DBUS_ERROR_UNKNOWN_INTERFACE);
@@ -1308,8 +1284,7 @@ translate_g_error (GQuark domain,
}
}
- /* catch-all */
- return g_strdup (DBUS_ERROR_FAILED);
+ return g_dbus_error_encode_gerror (error);
}
static void
@@ -1357,8 +1332,7 @@ request_connection_cb (TpConnectionManager *proxy, const gchar *bus_name,
if (tperror)
{
- gchar *dbus_error = translate_g_error (tperror->domain,
- tperror->code, tperror->message);
+ gchar *dbus_error = translate_g_error (tperror);
GHashTable *details = tp_asv_new (
"debug-message", G_TYPE_STRING, tperror->message,
NULL);