[Telepathy-commits] [telepathy-sofiasip/call-group-fixes] The "handle" property on TpsipMediaChannel really conveys the requested handle
Mikhail Zabaluev
mikhail.zabaluev at nokia.com
Mon Oct 20 04:59:02 PDT 2008
---
src/media-factory.c | 35 +++++++++++++++++++++++++++++++----
src/sip-media-channel.c | 18 ++++++++++++++----
2 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/src/media-factory.c b/src/media-factory.c
index 46e7988..42dab90 100644
--- a/src/media-factory.c
+++ b/src/media-factory.c
@@ -274,14 +274,36 @@ tpsip_media_factory_new_channel (TpsipMediaFactory *fac,
GError **error)
{
TpsipMediaFactoryPrivate *priv;
- TpsipMediaChannel *chan;
+ TpsipMediaChannel *chan = NULL;
TpBaseConnection *conn;
gchar *object_path;
const gchar *nat_traversal = "none";
- g_assert (TPSIP_IS_MEDIA_FACTORY (fac));
g_assert (initiator != 0);
+ switch (handle_type)
+ {
+ case TP_HANDLE_TYPE_CONTACT:
+ if (!tp_handle_is_valid (
+ tp_base_connection_get_handles (conn, TP_HANDLE_TYPE_CONTACT),
+ handle, error))
+ goto err;
+ break;
+ case TP_HANDLE_TYPE_NONE:
+ if (handle != 0)
+ {
+ g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "TargetHandle must be zero or omitted if TargetHandleType is "
+ "NONE");
+ goto err;
+ }
+ break;
+ default:
+ g_set_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
+ "SIP media channels can not be created with this handle type");
+ goto err;
+ }
+
priv = TPSIP_MEDIA_FACTORY_GET_PRIVATE (fac);
conn = (TpBaseConnection *)priv->conn;
@@ -298,6 +320,7 @@ tpsip_media_factory_new_channel (TpsipMediaFactory *fac,
chan = g_object_new (TPSIP_TYPE_MEDIA_CHANNEL,
"connection", priv->conn,
"object-path", object_path,
+ "handle", handle,
"initiator", initiator,
"nat-traversal", nat_traversal,
NULL);
@@ -338,7 +361,8 @@ tpsip_media_factory_new_channel (TpsipMediaFactory *fac,
return chan;
err:
- g_object_unref (chan);
+ if (chan != NULL)
+ g_object_unref (chan);
return NULL;
}
@@ -383,9 +407,12 @@ tpsip_media_factory_request (TpChannelFactoryIface *iface,
switch (error->code)
{
case TP_ERROR_INVALID_HANDLE:
- /* case TP_ERROR_INVALID_ARGUMENT: */
+ case TP_ERROR_INVALID_ARGUMENT:
status = TP_CHANNEL_FACTORY_REQUEST_STATUS_INVALID_HANDLE;
break;
+ case TP_ERROR_NOT_AVAILABLE:
+ status = TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_AVAILABLE;
+ break;
default:
status = TP_CHANNEL_FACTORY_REQUEST_STATUS_ERROR;
}
diff --git a/src/sip-media-channel.c b/src/sip-media-channel.c
index 3c2c88e..f764395 100644
--- a/src/sip-media-channel.c
+++ b/src/sip-media-channel.c
@@ -129,6 +129,7 @@ struct _TpsipMediaChannelPrivate
TpsipConnection *conn;
TpsipMediaSession *session;
gchar *object_path;
+ TpHandle handle;
TpHandle initiator;
GHashTable *call_states;
@@ -173,7 +174,10 @@ tpsip_media_channel_constructed (GObject *obj)
contact_repo = tp_base_connection_get_handles (conn,
TP_HANDLE_TYPE_CONTACT);
-
+
+ if (priv->handle != 0)
+ tp_handle_ref (contact_repo, priv->handle);
+
/* register object on the bus */
bus = tp_get_bus ();
@@ -369,10 +373,11 @@ tpsip_media_channel_get_property (GObject *object,
g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
break;
case PROP_HANDLE:
- g_value_set_uint (value, 0);
+ g_value_set_uint (value, priv->handle);
break;
case PROP_HANDLE_TYPE:
- g_value_set_uint (value, TP_HANDLE_TYPE_NONE);
+ g_value_set_uint (value, priv->handle?
+ TP_HANDLE_TYPE_CONTACT : TP_HANDLE_TYPE_NONE);
break;
case PROP_TARGET_ID:
g_value_set_static_string (value, "");
@@ -432,7 +437,6 @@ tpsip_media_channel_set_property (GObject *object,
switch (property_id) {
case PROP_HANDLE_TYPE:
- case PROP_HANDLE:
case PROP_CHANNEL_TYPE:
/* this property is writable in the interface, but not actually
* meaningfully changable on this channel, so we do nothing */
@@ -444,7 +448,13 @@ tpsip_media_channel_set_property (GObject *object,
g_free (priv->object_path);
priv->object_path = g_value_dup_string (value);
break;
+ case PROP_HANDLE:
+ /* we don't ref it here because we don't necessarily have access to the
+ * contact repo yet - instead we ref it in constructed. */
+ priv->handle = g_value_get_uint (value);
+ break;
case PROP_INITIATOR:
+ /* similarly we can't ref this yet */
priv->initiator = g_value_get_uint (value);
break;
default:
--
1.5.6.5
More information about the Telepathy-commits
mailing list