telepathy-glib: protocol: add a _get_cm_name function and :cm-name property
Jonny Lamb
jonny at kemper.freedesktop.org
Thu May 10 07:41:19 PDT 2012
Module: telepathy-glib
Branch: master
Commit: 226414747dc89925f51f82985573613f0b91e9b5
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=226414747dc89925f51f82985573613f0b91e9b5
Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date: Fri Apr 27 16:25:02 2012 +0100
protocol: add a _get_cm_name function and :cm-name property
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
docs/reference/telepathy-glib-sections.txt | 1 +
telepathy-glib/protocol.c | 45 ++++++++++++++++++++++++++++
telepathy-glib/protocol.h | 2 +
tests/dbus/protocol-objects.c | 3 ++
4 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 6078009..52dc358 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -5991,6 +5991,7 @@ TpProtocol
TpProtocolClass
tp_protocol_new
tp_protocol_get_name
+tp_protocol_get_cm_name
tp_protocol_init_known_interfaces
<SUBSECTION>
TP_PROTOCOL_FEATURE_PARAMETERS
diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index 3621853..98167a1 100644
--- a/telepathy-glib/protocol.c
+++ b/telepathy-glib/protocol.c
@@ -143,6 +143,7 @@ struct _TpProtocolPrivate
GStrv authentication_types;
TpCapabilities *capabilities;
TpAvatarRequirements *avatar_req;
+ gchar *cm_name;
};
enum
@@ -156,6 +157,7 @@ enum
PROP_PARAM_NAMES,
PROP_AUTHENTICATION_TYPES,
PROP_AVATAR_REQUIREMENTS,
+ PROP_CM_NAME,
N_PROPS
};
@@ -286,6 +288,10 @@ tp_protocol_get_property (GObject *object,
g_value_set_pointer (value, tp_protocol_get_avatar_requirements (self));
break;
+ case PROP_CM_NAME:
+ g_value_set_string (value, tp_protocol_get_cm_name (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -312,6 +318,11 @@ tp_protocol_set_property (GObject *object,
self->priv->protocol_properties = g_value_dup_boxed (value);
break;
+ case PROP_CM_NAME:
+ g_assert (self->priv->cm_name == NULL);
+ self->priv->cm_name = g_value_dup_string (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -381,6 +392,7 @@ tp_protocol_finalize (GObject *object)
g_free (self->priv->vcard_field);
g_free (self->priv->english_name);
g_free (self->priv->icon_name);
+ g_free (self->priv->cm_name);
if (self->priv->protocol_properties != NULL)
g_hash_table_unref (self->priv->protocol_properties);
@@ -737,6 +749,20 @@ tp_protocol_class_init (TpProtocolClass *klass)
"Avatars requirements",
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ /**
+ * TpProtocol:cm-name:
+ *
+ * The name of the connection manager this protocol is on.
+ *
+ * Since: 0.UNRELEASED
+ */
+ g_object_class_install_property (object_class, PROP_CM_NAME,
+ g_param_spec_string ("cm-name",
+ "Connection manager name",
+ "Name of the CM this protocol is on",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | 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;
@@ -795,6 +821,7 @@ tp_protocol_new (TpDBusDaemon *dbus,
"object-path", object_path,
"protocol-name", protocol_name,
"protocol-properties", immutable_properties,
+ "cm-name", cm_name,
NULL));
finally:
@@ -1696,3 +1723,21 @@ tp_protocol_get_avatar_requirements (TpProtocol *self)
return self->priv->avatar_req;
}
+
+/**
+ * tp_protocol_get_cm_name:
+ * @self: a #TpProtocol
+ *
+ * Return the #TpProtocol:cm-name property.
+ *
+ * Returns: the value of #TpProtocol:cm-name
+ *
+ * Since: 0.UNRELEASED
+ */
+const gchar *
+tp_protocol_get_cm_name (TpProtocol *self)
+{
+ g_return_val_if_fail (TP_IS_PROTOCOL (self), NULL);
+
+ return self->priv->cm_name;
+}
diff --git a/telepathy-glib/protocol.h b/telepathy-glib/protocol.h
index 7d1164a..3d32f73 100644
--- a/telepathy-glib/protocol.h
+++ b/telepathy-glib/protocol.h
@@ -80,6 +80,8 @@ TpProtocol *tp_protocol_new (TpDBusDaemon *dbus, const gchar *cm_name,
const gchar *tp_protocol_get_name (TpProtocol *self);
+const gchar *tp_protocol_get_cm_name (TpProtocol *self);
+
#define TP_PROTOCOL_FEATURE_PARAMETERS \
(tp_protocol_get_feature_quark_parameters ())
GQuark tp_protocol_get_feature_quark_parameters (void) G_GNUC_CONST;
diff --git a/tests/dbus/protocol-objects.c b/tests/dbus/protocol-objects.c
index df78eb5..1645751 100644
--- a/tests/dbus/protocol-objects.c
+++ b/tests/dbus/protocol-objects.c
@@ -399,6 +399,9 @@ test_protocol_object (Test *test,
g_assert_cmpstr (tp_protocol_get_name (test->protocol), ==, "example");
+ g_assert_cmpstr (tp_protocol_get_cm_name (test->protocol),
+ ==, "example_echo_2");
+
g_assert (tp_proxy_has_interface_by_id (test->protocol,
TP_IFACE_QUARK_PROTOCOL));
g_assert (tp_proxy_has_interface_by_id (test->protocol,
More information about the telepathy-commits
mailing list