summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.co.uk>2013-09-20 15:51:27 -0400
committerXavier Claessens <xavier.claessens@collabora.co.uk>2013-09-23 10:32:26 -0400
commit7ba46141a7bfd7469ed1dba1d2938b2b62a10f85 (patch)
tree941aa17cd2193253fd5e8c0f12fd4285beff8a83
parent35f5131ef8ce3660ca57854142e2c9a77cb7382c (diff)
downloadtelepathy-glib-7ba46141a7bfd7469ed1dba1d2938b2b62a10f85.tar.gz
TpBaseConnection: Implement SelfID and SelfContactChanged
-rw-r--r--docs/reference/telepathy-glib-sections.txt4
-rw-r--r--spec/Channel.xml2
-rw-r--r--spec/Connection.xml42
-rw-r--r--telepathy-glib/base-connection.c60
4 files changed, 92 insertions, 16 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index b336ed15e..9a0003bd1 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -1215,6 +1215,7 @@ tp_svc_connection_implement_request_handles
tp_svc_connection_return_from_request_handles
tp_svc_connection_emit_new_channel
tp_svc_connection_emit_self_handle_changed
+tp_svc_connection_emit_self_contact_changed
tp_svc_connection_emit_status_changed
tp_svc_connection_emit_connection_error
tp_svc_connection_add_client_interest_impl
@@ -3517,6 +3518,7 @@ TP_PROP_CONNECTION_MANAGER_INTERFACES
TP_PROP_CONNECTION_MANAGER_PROTOCOLS
TP_PROP_CONNECTION_INTERFACES
TP_PROP_CONNECTION_SELF_HANDLE
+TP_PROP_CONNECTION_SELF_ID
TP_PROP_CONNECTION_STATUS
TP_PROP_DEBUG_ENABLED
TP_PROP_MEDIA_STREAM_HANDLER_CREATED_LOCALLY
@@ -4403,6 +4405,8 @@ tp_cli_connection_signal_callback_new_channel
tp_cli_connection_connect_to_new_channel
tp_cli_connection_signal_callback_self_handle_changed
tp_cli_connection_connect_to_self_handle_changed
+tp_cli_connection_signal_callback_self_contact_changed
+tp_cli_connection_connect_to_self_contact_changed
tp_cli_connection_signal_callback_status_changed
tp_cli_connection_connect_to_status_changed
tp_cli_connection_signal_callback_connection_error
diff --git a/spec/Channel.xml b/spec/Channel.xml
index e0fa76594..12a486e4c 100644
--- a/spec/Channel.xml
+++ b/spec/Channel.xml
@@ -390,7 +390,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</
<tp:rationale>
<p>On some protocols, the SelfHandle may change (as signalled by
<tp:dbus-ref
- namespace="org.freedesktop.Telepathy">Connection.SelfHandleChanged</tp:dbus-ref>),
+ namespace="org.freedesktop.Telepathy">Connection.SelfContactChanged</tp:dbus-ref>),
but this property is immutable. Hence, locally-requested channels'
InitiatorHandle and InitiatorID may not match the current
SelfHandle; <tp:member-ref>Requested</tp:member-ref> can be used to
diff --git a/spec/Connection.xml b/spec/Connection.xml
index 6a560fc30..ed0243786 100644
--- a/spec/Connection.xml
+++ b/spec/Connection.xml
@@ -145,6 +145,8 @@ USA.</p>
<tp:added version="0.17.10">Clients MAY assume that if the
SelfHandle property exists, this signal will be emitted when
necessary.</tp:added>
+ <tp:deprecated version="0.UNRELEASED">Use SelfContactChanged to get the
+ new SelfID at the same time</tp:deprecated>
<arg type="u" tp:type="Contact_Handle" name="Self_Handle">
<tp:docstring>
@@ -153,13 +155,38 @@ USA.</p>
</arg>
</signal>
+ <signal name="SelfContactChanged"
+ tp:name-for-bindings="Self_Contact_Changed">
+ <tp:docstring>
+ Emitted whenever the <tp:member-ref>SelfHandle</tp:member-ref> and
+ <tp:member-ref>SelfID</tp:member-ref> property
+ changes. If the connection
+ is not yet in the CONNECTED state, this signal is not guaranteed
+ to be emitted.
+ </tp:docstring>
+ <tp:added version="0.UNRELEASED">Clients MAY assume that if the
+ SelfHandle and SelfID property exists, this signal will be emitted when
+ necessary.</tp:added>
+
+ <arg type="u" tp:type="Contact_Handle" name="Self_Handle">
+ <tp:docstring>
+ The new value of the SelfHandle property.
+ </tp:docstring>
+ </arg>
+ <arg type="s" name="Self_ID">
+ <tp:docstring>
+ The new value of the SelfID property.
+ </tp:docstring>
+ </arg>
+ </signal>
+
<property name="SelfHandle" tp:name-for-bindings="Self_Handle"
type="u" tp:type="Contact_Handle" access="read">
<tp:docstring>
The handle which represents the user on this connection, which will
remain valid for the lifetime of this connection, or until a change
in the user's identifier is signalled by the
- <tp:member-ref>SelfHandleChanged</tp:member-ref> signal.
+ <tp:member-ref>SelfContactChanged</tp:member-ref> signal.
If the connection is not yet in the CONNECTED state, the value of
this property MAY be zero.
</tp:docstring>
@@ -169,6 +196,19 @@ USA.</p>
method.</tp:added>
</property>
+ <property name="SelfID" tp:name-for-bindings="Self_ID"
+ type="s" access="read">
+ <tp:docstring>
+ The identifier which represents the user on this connection, which will
+ remain valid for the lifetime of this connection, or until a change
+ in the user's identifier is signalled by the
+ <tp:member-ref>SelfContactChanged</tp:member-ref> signal.
+ If the connection is not yet in the CONNECTED state, the value of
+ this property MAY be empty string.
+ </tp:docstring>
+ <tp:added version="0.UNRELEASED"/>
+ </property>
+
<method name="GetSelfHandle" tp:name-for-bindings="Get_Self_Handle">
<arg direction="out" type="u" tp:type="Contact_Handle"
name="Self_Handle">
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index 22167dc20..dee9f8a27 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -286,6 +286,7 @@ enum
{
PROP_PROTOCOL = 1,
PROP_SELF_HANDLE,
+ PROP_SELF_ID,
PROP_INTERFACES,
PROP_DBUS_STATUS,
PROP_DBUS_DAEMON,
@@ -390,6 +391,8 @@ channel_request_cancel (gpointer data, gpointer user_data)
struct _TpBaseConnectionPrivate
{
+ const gchar *self_id;
+
/* Telepathy properties */
gchar *protocol;
@@ -477,6 +480,10 @@ tp_base_connection_get_property (GObject *object,
g_value_set_uint (value, self->self_handle);
break;
+ case PROP_SELF_ID:
+ g_value_set_string (value, self->priv->self_id);
+ break;
+
case PROP_INTERFACES:
g_value_set_boxed (value, tp_base_connection_get_interfaces (self));
break;
@@ -516,19 +523,7 @@ tp_base_connection_set_property (GObject *object,
break;
case PROP_SELF_HANDLE:
- {
- TpHandle new_self_handle = g_value_get_uint (value);
-
- if (self->status == TP_CONNECTION_STATUS_CONNECTED)
- g_return_if_fail (new_self_handle != 0);
-
- if (self->self_handle == new_self_handle)
- return;
-
- self->self_handle = new_self_handle;
-
- tp_svc_connection_emit_self_handle_changed (self, self->self_handle);
- }
+ tp_base_connection_set_self_handle (self, g_value_get_uint (value));
break;
case PROP_DBUS_DAEMON:
@@ -1549,6 +1544,7 @@ tp_base_connection_class_init (TpBaseConnectionClass *klass)
{
static TpDBusPropertiesMixinPropImpl connection_properties[] = {
{ "SelfHandle", "self-handle", NULL },
+ { "SelfID", "self-id", NULL },
{ "Status", "dbus-status", NULL },
{ "Interfaces", "interfaces", NULL },
{ "HasImmortalHandles", "has-immortal-handles", NULL },
@@ -1601,6 +1597,21 @@ tp_base_connection_class_init (TpBaseConnectionClass *klass)
g_object_class_install_property (object_class, PROP_SELF_HANDLE, param_spec);
/**
+ * TpBaseConnection:self-id: (skip)
+ *
+ * The identifier representing the local user. This is the result of
+ * inspecting #TpBaseConnection:self-handle.
+ *
+ * Since: 0.UNRELEASED
+ */
+ param_spec = g_param_spec_string ("self-id",
+ "Connection.SelfID",
+ "The identifier representing the local user.",
+ "",
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_SELF_ID, param_spec);
+
+ /**
* TpBaseConnection:interfaces: (skip)
*
* The set of D-Bus interfaces available on this Connection, other than
@@ -2830,7 +2841,28 @@ void
tp_base_connection_set_self_handle (TpBaseConnection *self,
TpHandle self_handle)
{
- g_object_set (self, "self-handle", self_handle, NULL);
+ if (self->status == TP_CONNECTION_STATUS_CONNECTED)
+ g_return_if_fail (self_handle != 0);
+
+ if (self->self_handle == self_handle)
+ return;
+
+ self->self_handle = self_handle;
+ self->priv->self_id = NULL;
+
+ if (self_handle != 0)
+ {
+ self->priv->self_id = tp_handle_inspect (
+ self->priv->handles[TP_HANDLE_TYPE_CONTACT], self_handle);
+ }
+
+ tp_svc_connection_emit_self_handle_changed (self, self->self_handle);
+
+ tp_svc_connection_emit_self_contact_changed (self,
+ self->self_handle, self->priv->self_id);
+
+ g_object_notify ((GObject *) self, "self-handle");
+ g_object_notify ((GObject *) self, "self-id");
}