summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorten Mjelva <morten.mjelva@gmail.com>2011-02-10 17:06:31 +0100
committerMorten Mjelva <morten.mjelva@gmail.com>2011-02-11 23:59:10 +0100
commit5e98f82007eff276f01449d75c27692a99c9c39e (patch)
treea63ae6c387be0f44a1e0a79b77e77a9396d251d3
parent746c03c35407b038b51fb820709d7c4ec4bb2316 (diff)
Added connection manager and protocol properties to TpConnectionfdo#34148
-rw-r--r--docs/reference/telepathy-glib-sections.txt2
-rw-r--r--telepathy-glib/connection-internal.h3
-rw-r--r--telepathy-glib/connection.c82
-rw-r--r--telepathy-glib/connection.h4
-rw-r--r--tests/dbus/connection.c6
5 files changed, 97 insertions, 0 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 3c3dfc36..d9832fc0 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -3407,6 +3407,8 @@ TpConnectionWhenReadyCb
tp_connection_call_when_ready
tp_connection_is_ready
tp_connection_get_status
+tp_connection_get_connection_manager
+tp_connection_get_protocol
tp_connection_get_self_contact
tp_connection_get_self_handle
tp_connection_has_immortal_handles
diff --git a/telepathy-glib/connection-internal.h b/telepathy-glib/connection-internal.h
index 81c7b03c..e5eb33bf 100644
--- a/telepathy-glib/connection-internal.h
+++ b/telepathy-glib/connection-internal.h
@@ -35,6 +35,9 @@ struct _TpConnectionPrivate {
/* list of TpConnectionProc */
GList *introspect_needed;
+ gchar *cm_name;
+ gchar *proto_name;
+
TpHandle last_known_self_handle;
TpContact *self_contact;
TpConnectionStatus status;
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index 0a9815fa..75ddfdb2 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -230,10 +230,13 @@ tp_errors_disconnected_quark (void)
* Since: 0.7.1
*/
+/* properties */
enum
{
PROP_STATUS = 1,
PROP_STATUS_REASON,
+ PROP_CONNECTION_MANAGER_NAME,
+ PROP_PROTOCOL_NAME,
PROP_CONNECTION_READY,
PROP_SELF_CONTACT,
PROP_SELF_HANDLE,
@@ -255,6 +258,12 @@ tp_connection_get_property (GObject *object,
switch (property_id)
{
+ case PROP_CONNECTION_MANAGER_NAME:
+ g_value_set_string (value, self->priv->cm_name);
+ break;
+ case PROP_PROTOCOL_NAME:
+ g_value_set_string (value, self->priv->proto_name);
+ break;
case PROP_CONNECTION_READY:
g_value_set_boolean (value, self->priv->ready);
break;
@@ -1008,6 +1017,9 @@ tp_connection_constructor (GType type,
tp_cli_connection_connect_to_connection_error (self,
tp_connection_connection_error_cb, NULL, NULL, NULL, NULL);
+ tp_connection_parse_object_path (self, &(self->priv->proto_name),
+ &(self->priv->cm_name));
+
/* get the properties, currently only for HasImmortalHandles */
tp_cli_dbus_properties_call_get_all (self, -1,
TP_IFACE_CONNECTION, _tp_connection_got_properties, NULL, NULL, NULL);
@@ -1231,6 +1243,38 @@ tp_connection_class_init (TpConnectionClass *klass)
param_spec);
/**
+ * TpConnection:connection-manager-name:
+ *
+ * This connection's connection manager name.
+ *
+ * Since: 0.13.UNRELEASED
+ *
+ */
+ g_object_class_install_property (object_class, PROP_CONNECTION_MANAGER_NAME,
+ g_param_spec_string ("connection-manager-name",
+ "Connection manager name",
+ "The connection's connection manager name",
+ NULL,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
+ /**
+ * TpConnection:protocol-name:
+ *
+ * The connection's machine-readable protocol name, such as "jabber",
+ * "msn" or "local-xmpp". Recommended names for most protocols can be
+ * found in the Telepathy D-Bus Interface Specification.
+ *
+ * Since: 0.13.UNRELEASED
+ *
+ */
+ g_object_class_install_property (object_class, PROP_PROTOCOL_NAME,
+ g_param_spec_string ("protocol-name",
+ "Protocol name",
+ "The connection's protocol name",
+ NULL,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
+ /**
* TpConnection:self-handle:
*
* The %TP_HANDLE_TYPE_CONTACT handle of the local user on this connection,
@@ -1464,6 +1508,44 @@ tp_connection_get_status (TpConnection *self,
}
/**
+* tp_connection_get_connection_manager_name:
+* @self: a #TpConnection
+*
+* <!-- -->
+*
+* Returns: the same as the #TpConnection:connection-manager-name property
+*
+* Since: 0.13.UNRELEASED
+*
+*/
+const gchar *
+tp_connection_get_connection_manager_name (TpConnection *self)
+{
+ g_return_val_if_fail (TP_IS_CONNECTION (self), NULL);
+
+ return self->priv->cm_name;
+}
+
+/**
+* tp_connection_get_protocol_name:
+* @self: a #TpConnection
+*
+* <!-- -->
+*
+* Returns: the same as the #TpConnection:protocol-name property
+*
+* Since: 0.13.UNRELEASED
+*
+*/
+const gchar *
+tp_connection_get_protocol_name (TpConnection *self)
+{
+ g_return_val_if_fail (TP_IS_CONNECTION (self), NULL);
+
+ return self->priv->proto_name;
+}
+
+/**
* tp_connection_run_until_ready: (skip)
* @self: a connection
* @connect: if %TRUE, call Connect() if it appears to be necessary;
diff --git a/telepathy-glib/connection.h b/telepathy-glib/connection.h
index 1463023c..0b3e0644 100644
--- a/telepathy-glib/connection.h
+++ b/telepathy-glib/connection.h
@@ -126,6 +126,10 @@ TpConnection *tp_connection_new (TpDBusDaemon *dbus, const gchar *bus_name,
TpConnectionStatus tp_connection_get_status (TpConnection *self,
TpConnectionStatusReason *reason);
+const gchar *tp_connection_get_connection_manager_name (TpConnection *self);
+
+const gchar *tp_connection_get_protocol_name (TpConnection *self);
+
TpHandle tp_connection_get_self_handle (TpConnection *self);
TpContact *tp_connection_get_self_contact (TpConnection *self);
diff --git a/tests/dbus/connection.c b/tests/dbus/connection.c
index 519a83ef..ee77b0d0 100644
--- a/tests/dbus/connection.c
+++ b/tests/dbus/connection.c
@@ -224,6 +224,12 @@ test_prepare (Test *test,
g_assert_cmpint (tp_connection_get_status (test->conn, NULL), ==,
TP_CONNECTION_STATUS_DISCONNECTED);
+ g_assert_cmpstr (tp_connection_get_connection_manager_name (test->conn), ==,
+ "simple");
+
+ g_assert_cmpstr (tp_connection_get_protocol_name (test->conn), ==,
+ "simple-protocol");
+
tp_cli_connection_call_connect (test->conn, -1, NULL, NULL, NULL, NULL);
tp_proxy_prepare_async (test->conn, features, connection_prepared_cb, test);