summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-04 16:24:14 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-08 19:53:38 +0100
commit5778343c0b5af3d3ef14483a584da5e492d8e13e (patch)
tree5e085764d95996804ab455fa65fbe2673fed0cab
parentae62786bd1a7d7722b72c36063067c4137659621 (diff)
TpAccountRequest:avatar: change from GArray<guchar> to GBytes
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77139 Reviewed-by: Xavier Claessens
-rw-r--r--telepathy-glib/account-request.c11
-rw-r--r--tests/dbus/account-request.c17
2 files changed, 15 insertions, 13 deletions
diff --git a/telepathy-glib/account-request.c b/telepathy-glib/account-request.c
index da3e1cf29..1e349fec7 100644
--- a/telepathy-glib/account-request.c
+++ b/telepathy-glib/account-request.c
@@ -285,7 +285,12 @@ tp_account_request_get_property (GObject *object,
TP_STRUCT_TYPE_AVATAR);
if (array != NULL)
- g_value_set_boxed (value, g_value_get_boxed (array->values));
+ {
+ GArray *uchars = g_value_get_boxed (array->values);
+
+ g_value_take_boxed (value,
+ g_bytes_new (uchars->data, uchars->len));
+ }
}
break;
case PROP_AVATAR_MIME_TYPE:
@@ -668,14 +673,12 @@ tp_account_request_class_init (TpAccountRequestClass *klass)
* The avatar set on the account. The avatar's mime type can be read
* in the #TpAccountRequest:avatar-mime-type property. To change this
* property, use tp_account_request_set_avatar().
- *
- * Since: 0.19.1
*/
g_object_class_install_property (object_class, PROP_AVATAR,
g_param_spec_boxed ("avatar",
"Avatar",
"The account's avatar data",
- G_TYPE_ARRAY,
+ G_TYPE_BYTES,
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
/**
diff --git a/tests/dbus/account-request.c b/tests/dbus/account-request.c
index 5a6ddce76..2e82289cd 100644
--- a/tests/dbus/account-request.c
+++ b/tests/dbus/account-request.c
@@ -202,7 +202,8 @@ test_properties (Test *test,
gchar *presence_status, *presence_message;
gboolean enabled, connect_automatically;
gchar **supersedes;
- GArray *avatar;
+ GBytes *avatar;
+ gsize len;
gchar *mime_type;
gboolean found;
const gchar *s;
@@ -338,12 +339,9 @@ test_properties (Test *test,
g_variant_unref (props);
/* avatar */
- avatar = g_array_new (FALSE, FALSE, sizeof (guchar));
- g_array_append_vals (avatar, "hello world", strlen ("hello world") + 1);
tp_account_request_set_avatar (test->ar,
- (const guchar *) avatar->data, avatar->len, "image/lolz");
- g_array_unref (avatar);
- avatar = NULL;
+ (const guchar *) "hello world", strlen ("hello world") + 1,
+ "image/lolz");
g_object_get (test->ar,
"properties", &props,
@@ -351,8 +349,9 @@ test_properties (Test *test,
"avatar-mime-type", &mime_type,
NULL);
- g_assert_cmpstr (avatar->data, ==, "hello world");
- g_assert_cmpuint (avatar->len, ==, strlen ("hello world") + 1);
+ g_assert_cmpstr ((const gchar *) g_bytes_get_data (avatar, &len), ==,
+ "hello world");
+ g_assert_cmpuint (len, ==, strlen ("hello world") + 1);
g_assert_cmpstr (mime_type, ==, "image/lolz");
v = g_variant_lookup_value (props, TP_PROP_ACCOUNT_INTERFACE_AVATAR1_AVATAR,
@@ -361,7 +360,7 @@ test_properties (Test *test,
g_variant_unref (v);
g_variant_unref (props);
- g_array_unref (avatar);
+ g_bytes_unref (avatar);
g_free (mime_type);
/* service */