summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-03-24 20:12:03 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-03-27 15:59:20 +0000
commitc3c3bb5c6f22269e0a130f96917972ad7263316c (patch)
tree72b26edf8196cc89e449f84fb47e187b3673ae01
parentd09a713e6d3341a44a8141d2c1d847cebd4d5466 (diff)
avatars: be more precise about what we're returningnext-gdbus
The dbus-glib codegen tolerated use of the wrong return_from function, because dbus_g_method_return used unterminated varargs anyway, so it had no way to detect excess arguments. g_dbus_method_invocation_return_value *does* have a way to detect excess arguments, and treats them as programming error. Unfortunately, we had always used tp_svc_connection_interface_avatars1_return_from_set_avatar() (returning (s)) to return from ClearAvatar (returning ()).
-rw-r--r--src/conn-avatars.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/conn-avatars.c b/src/conn-avatars.c
index cdb957b6e..ea531a626 100644
--- a/src/conn-avatars.c
+++ b/src/conn-avatars.c
@@ -427,6 +427,7 @@ struct _set_avatar_ctx {
GabbleConnection *conn;
GDBusMethodInvocation *invocation;
GString *avatar;
+ gboolean is_clear;
};
@@ -483,8 +484,13 @@ _set_avatar_cb2 (GabbleVCardManager *manager,
if (conn_presence_signal_own_presence (ctx->conn, NULL, &error))
{
- tp_svc_connection_interface_avatars1_return_from_set_avatar (
- ctx->invocation, presence->avatar_sha1);
+ if (ctx->is_clear)
+ tp_svc_connection_interface_avatars1_return_from_clear_avatar (
+ ctx->invocation);
+ else
+ tp_svc_connection_interface_avatars1_return_from_set_avatar (
+ ctx->invocation, presence->avatar_sha1);
+
tp_svc_connection_interface_avatars1_emit_avatar_updated (
ctx->conn, tp_base_connection_get_self_handle (base),
presence->avatar_sha1);
@@ -499,21 +505,11 @@ _set_avatar_cb2 (GabbleVCardManager *manager,
_set_avatar_ctx_free (ctx);
}
-
-/**
- * gabble_connection_set_avatar
- *
- * Implements D-Bus method SetAvatar
- * on interface Connection.Interface.Avatars
- *
- * @context: The D-Bus invocation context to use to return values
- * or throw an error.
- */
static void
-gabble_connection_set_avatar (TpSvcConnectionInterfaceAvatars1 *iface,
- const GArray *avatar,
- const gchar *mime_type,
- GDBusMethodInvocation *context)
+set_avatar_internal (TpSvcConnectionInterfaceAvatars1 *iface,
+ const GArray *avatar,
+ const gchar *mime_type,
+ GDBusMethodInvocation *context)
{
GabbleConnection *self = GABBLE_CONNECTION (iface);
TpBaseConnection *base = (TpBaseConnection *) self;
@@ -527,6 +523,7 @@ gabble_connection_set_avatar (TpSvcConnectionInterfaceAvatars1 *iface,
ctx = g_new0 (struct _set_avatar_ctx, 1);
ctx->conn = self;
ctx->invocation = context;
+ ctx->is_clear = (avatar == NULL);
if (avatar != NULL && avatar->len > 0)
{
@@ -567,6 +564,15 @@ gabble_connection_set_avatar (TpSvcConnectionInterfaceAvatars1 *iface,
edits);
}
+static void
+gabble_connection_set_avatar (TpSvcConnectionInterfaceAvatars1 *iface,
+ const GArray *avatar,
+ const gchar *mime_type,
+ GDBusMethodInvocation *context)
+{
+ g_assert (avatar != NULL);
+ set_avatar_internal (iface, avatar, mime_type, context);
+}
/**
* gabble_connection_clear_avatar
@@ -581,7 +587,7 @@ static void
gabble_connection_clear_avatar (TpSvcConnectionInterfaceAvatars1 *iface,
GDBusMethodInvocation *context)
{
- gabble_connection_set_avatar (iface, NULL, NULL, context);
+ set_avatar_internal (iface, NULL, NULL, context);
}
gboolean