summaryrefslogtreecommitdiff
path: root/telepathy-glib/protocol.c
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-04-11 14:41:08 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-08-29 14:14:33 +0200
commit56729b46480a21d43da33bc7dc9e854d9ed3093a (patch)
tree96757942cd2c392da15b3bbfb9f3f500b05e9b9b /telepathy-glib/protocol.c
parent0b7e9eab27502bbafc3f097c5c4496de9a24c3ca (diff)
downloadtelepathy-glib-56729b46480a21d43da33bc7dc9e854d9ed3093a.tar.gz
TpProtocol: add API to get avatars requirements (fdo #36049)
https://bugs.freedesktop.org/show_bug.cgi?id=36049
Diffstat (limited to 'telepathy-glib/protocol.c')
-rw-r--r--telepathy-glib/protocol.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index de9010043..db9bcb37b 100644
--- a/telepathy-glib/protocol.c
+++ b/telepathy-glib/protocol.c
@@ -141,6 +141,7 @@ struct _TpProtocolPrivate
gchar *icon_name;
GStrv authentication_types;
TpCapabilities *capabilities;
+ TpAvatarRequirements *avatar_req;
};
enum
@@ -153,6 +154,7 @@ enum
PROP_CAPABILITIES,
PROP_PARAM_NAMES,
PROP_AUTHENTICATION_TYPES,
+ PROP_AVATAR_REQUIREMENTS,
N_PROPS
};
@@ -279,6 +281,10 @@ tp_protocol_get_property (GObject *object,
g_value_set_boxed (value, tp_protocol_get_authentication_types (self));
break;
+ case PROP_AVATAR_REQUIREMENTS:
+ g_value_set_pointer (value, tp_protocol_get_avatar_requirements (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -357,6 +363,8 @@ tp_protocol_dispose (GObject *object)
self->priv->authentication_types = NULL;
}
+ tp_clear_pointer (&self->priv->avatar_req, tp_avatar_requirements_destroy);
+
if (dispose != NULL)
dispose (object);
}
@@ -508,6 +516,28 @@ tp_protocol_constructed (GObject *object)
tp_proxy_add_interfaces (proxy, interfaces);
+ if (tp_proxy_has_interface_by_id (self,
+ TP_IFACE_QUARK_PROTOCOL_INTERFACE_AVATARS))
+ {
+ self->priv->avatar_req = tp_avatar_requirements_new (
+ (GStrv) tp_asv_get_strv (self->priv->protocol_properties,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_SUPPORTED_AVATAR_MIME_TYPES),
+ tp_asv_get_uint32 (self->priv->protocol_properties,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MINIMUM_AVATAR_WIDTH, NULL),
+ tp_asv_get_uint32 (self->priv->protocol_properties,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MINIMUM_AVATAR_HEIGHT, NULL),
+ tp_asv_get_uint32 (self->priv->protocol_properties,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_RECOMMENDED_AVATAR_WIDTH, NULL),
+ tp_asv_get_uint32 (self->priv->protocol_properties,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_RECOMMENDED_AVATAR_HEIGHT, NULL),
+ tp_asv_get_uint32 (self->priv->protocol_properties,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MAXIMUM_AVATAR_WIDTH, NULL),
+ tp_asv_get_uint32 (self->priv->protocol_properties,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MAXIMUM_AVATAR_HEIGHT, NULL),
+ tp_asv_get_uint32 (self->priv->protocol_properties,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MAXIMUM_AVATAR_BYTES, NULL));
+ }
+
/* become ready immediately */
_tp_proxy_set_feature_prepared (proxy, TP_PROTOCOL_FEATURE_PARAMETERS,
had_immutables);
@@ -691,6 +721,21 @@ tp_protocol_class_init (TpProtocolClass *klass)
"A list of authentication types",
G_TYPE_STRV, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ /**
+ * TpProtocol:avatar-requirements:
+ *
+ * A #TpAvatarRequirements representing the avatar requirements on this
+ * protocol, or %NULL if %TP_PROTOCOL_FEATURE_CORE has not been prepared or
+ * if the protocol doesn't support avatars.
+ *
+ * Since: 0.15.UNRELEASED
+ */
+ g_object_class_install_property (object_class, PROP_AVATAR_REQUIREMENTS,
+ g_param_spec_pointer ("avatar-requirements",
+ "Avatars requirements",
+ "Avatars requirements",
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
proxy_class->list_features = tp_protocol_list_features;
proxy_class->must_have_unique_name = FALSE;
proxy_class->interface = TP_IFACE_QUARK_PROTOCOL;
@@ -1461,6 +1506,34 @@ _tp_protocol_parse_manager_file (GKeyFile *file,
G_TYPE_STRV, g_key_file_get_string_list (file, group,
"AuthenticationTypes", NULL, NULL));
+ /* Avatars */
+ tp_asv_take_boxed (immutables,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_SUPPORTED_AVATAR_MIME_TYPES,
+ G_TYPE_STRV,
+ g_key_file_get_string_list (file, group, "SupportedAvatarMIMETypes",
+ NULL, NULL));
+ tp_asv_set_uint32 (immutables,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MINIMUM_AVATAR_HEIGHT,
+ g_key_file_get_uint64 (file, group, "MinimumAvatarHeight", NULL));
+ tp_asv_set_uint32 (immutables,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MINIMUM_AVATAR_WIDTH,
+ g_key_file_get_uint64 (file, group, "MinimumAvatarWidth", NULL));
+ tp_asv_set_uint32 (immutables,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_RECOMMENDED_AVATAR_HEIGHT,
+ g_key_file_get_uint64 (file, group, "RecommendedAvatarHeight", NULL));
+ tp_asv_set_uint32 (immutables,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_RECOMMENDED_AVATAR_WIDTH,
+ g_key_file_get_uint64 (file, group, "RecommendedAvatarWidth", NULL));
+ tp_asv_set_uint32 (immutables,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MAXIMUM_AVATAR_HEIGHT,
+ g_key_file_get_uint64 (file, group, "MaximumAvatarHeight", NULL));
+ tp_asv_set_uint32 (immutables,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MAXIMUM_AVATAR_WIDTH,
+ g_key_file_get_uint64 (file, group, "MaximumAvatarWidth", NULL));
+ tp_asv_set_uint32 (immutables,
+ TP_PROP_PROTOCOL_INTERFACE_AVATARS_MAXIMUM_AVATAR_BYTES,
+ g_key_file_get_uint64 (file, group, "MaximumAvatarBytes", NULL));
+
rccs = g_ptr_array_new ();
rcc_groups = g_key_file_get_string_list (file, group,
@@ -1482,3 +1555,21 @@ _tp_protocol_parse_manager_file (GKeyFile *file,
return immutables;
}
+
+/**
+ * tp_protocol_get_avatar_requirements
+ * @self: a #TpProtocol
+ *
+ * Return the #TpProtocol:avatar-requirements property
+ *
+ * Returns: (transfer none): the value of #TpProtocol:avatar-requirements
+ *
+ * Since: 0.15.UNRELEASED
+ */
+TpAvatarRequirements *
+tp_protocol_get_avatar_requirements (TpProtocol *self)
+{
+ g_return_val_if_fail (TP_IS_PROTOCOL (self), NULL);
+
+ return self->priv->avatar_req;
+}