summaryrefslogtreecommitdiff
path: root/telepathy-glib/channel-group.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-04-26 16:34:04 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-04-27 16:56:32 +0100
commitae180225dee13397bc81b4ad09d14cbb38a323d6 (patch)
treef3b2202281cd9df9bec01b956a3396a9cfdbb855 /telepathy-glib/channel-group.c
parente9f2f749a19c1e1de3eb0492e612b6cb17ce742a (diff)
downloadtelepathy-glib-ae180225dee13397bc81b4ad09d14cbb38a323d6.tar.gz
fd.o #23369: TpChannel: if the CM gives us a recognized error name, use it for invalidation
More specifically: if "error" is present in MembersChangedDetailed, *and* it can be mapped to a GError domain and code, use that domain and code as the invalidation reason. If it's absent or would be mapped to TP_DBUS_ERROR_REMOTE_ERROR, continue to use TP_ERRORS_REMOVED_FROM_GROUP as the invalidation reason.
Diffstat (limited to 'telepathy-glib/channel-group.c')
-rw-r--r--telepathy-glib/channel-group.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/telepathy-glib/channel-group.c b/telepathy-glib/channel-group.c
index b006b48f4..7ce15a0ea 100644
--- a/telepathy-glib/channel-group.c
+++ b/telepathy-glib/channel-group.c
@@ -937,17 +937,46 @@ handle_members_changed (TpChannel *self,
handle == tp_connection_get_self_handle (self->priv->connection))
{
const gchar *error_detail = tp_asv_get_string (details, "error");
+ const gchar *debug_message = tp_asv_get_string (details,
+ "debug-message");
- self->priv->group_remove_reason = reason;
- g_free (self->priv->group_remove_message);
+ if (debug_message == NULL && message[0] != '\0')
+ debug_message = message;
- /* If there's an error detail and a message, "$error: $message", else
- * just the non-empty one (or indeed the empty string).
- */
- self->priv->group_remove_message = g_strdup_printf ("%s%s%s",
- (error_detail != NULL ? error_detail : ""),
- (error_detail != NULL && message[0] != '\0' ? ": " : ""),
- message);
+ if (debug_message == NULL && error_detail != NULL)
+ debug_message = error_detail;
+
+ if (debug_message == NULL)
+ debug_message = "(no message provided)";
+
+ if (self->priv->group_remove_error != NULL)
+ g_clear_error (&self->priv->group_remove_error);
+
+ if (error_detail != NULL)
+ {
+ /* CM specified a D-Bus error name */
+ tp_proxy_dbus_error_to_gerror (self, error_detail,
+ debug_message == NULL || debug_message[0] == '\0'
+ ? error_detail
+ : debug_message,
+ &self->priv->group_remove_error);
+
+ /* ... but if we don't know anything about that D-Bus error
+ * name, we can still do better by using RemovedFromGroup */
+ if (g_error_matches (self->priv->group_remove_error,
+ TP_DBUS_ERRORS, TP_DBUS_ERROR_UNKNOWN_REMOTE_ERROR))
+ {
+ self->priv->group_remove_error->domain =
+ TP_ERRORS_REMOVED_FROM_GROUP;
+ self->priv->group_remove_error->code = reason;
+ }
+ }
+ else
+ {
+ /* Use our separate error domain */
+ g_set_error_literal (&self->priv->group_remove_error,
+ TP_ERRORS_REMOVED_FROM_GROUP, reason, debug_message);
+ }
}
}