[telepathy-gabble/master] Convert CapsToTypeFlagsFunc to be in terms of capability sets
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Aug 24 12:37:52 PDT 2009
---
src/capabilities.h | 2 +-
src/connection.c | 16 +++++++++-------
src/media-channel.c | 18 ++++++++----------
src/media-channel.h | 2 +-
4 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/capabilities.h b/src/capabilities.h
index 59a384f..150bb97 100644
--- a/src/capabilities.h
+++ b/src/capabilities.h
@@ -134,7 +134,7 @@ const GabbleCapabilitySet *gabble_capabilities_get_initial_caps (void);
GabblePresenceCapabilities capabilities_parse (const GabbleCapabilitySet *cap_set);
typedef void (*TypeFlagsToCapsFunc) (guint typeflags, GabbleCapabilitySet *caps);
-typedef guint (*CapsToTypeFlagsFunc) (GabblePresenceCapabilities caps);
+typedef guint (*CapsToTypeFlagsFunc) (const GabbleCapabilitySet *caps);
typedef struct _CapabilityConversionData CapabilityConversionData;
diff --git a/src/connection.c b/src/connection.c
index 9a6ff20..a407e33 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -2274,18 +2274,16 @@ _emit_capabilities_changed (GabbleConnection *conn,
GPtrArray *caps_arr;
const CapabilityConversionData *ccd;
guint i;
- GabblePresenceCapabilities old_caps = capabilities_parse (old_set);
- GabblePresenceCapabilities new_caps = capabilities_parse (new_set);
- if (old_caps == new_caps)
+ if (gabble_capability_set_equals (old_set, new_set))
return;
caps_arr = g_ptr_array_new ();
for (ccd = capabilities_conversions; NULL != ccd->iface; ccd++)
{
- guint old_specific = ccd->c2tf_fn (old_caps);
- guint new_specific = ccd->c2tf_fn (new_caps);
+ guint old_specific = ccd->c2tf_fn (old_set);
+ guint new_specific = ccd->c2tf_fn (new_set);
if (old_specific != 0 || new_specific != 0)
{
@@ -2518,7 +2516,7 @@ gabble_connection_advertise_capabilities (TpSvcConnectionInterfaceCapabilities *
for (ccd = capabilities_conversions; NULL != ccd->iface; ccd++)
{
- guint tp_caps = ccd->c2tf_fn (gabble_presence_get_caps_bitfield (pres));
+ guint tp_caps = ccd->c2tf_fn (cap_set);
if (tp_caps != 0)
{
@@ -2662,9 +2660,11 @@ gabble_connection_get_handle_capabilities (GabbleConnection *self,
if (NULL != pres)
{
+ GabbleCapabilitySet *cap_set = gabble_presence_dup_caps (pres);
+
for (ccd = capabilities_conversions; NULL != ccd->iface; ccd++)
{
- typeflags = ccd->c2tf_fn (gabble_presence_get_caps_bitfield (pres));
+ typeflags = ccd->c2tf_fn (cap_set);
if (typeflags)
{
@@ -2686,6 +2686,8 @@ gabble_connection_get_handle_capabilities (GabbleConnection *self,
g_ptr_array_add (arr, g_value_get_boxed (&monster));
}
}
+
+ gabble_capability_set_free (cap_set);
}
for (assumed = assumed_caps; NULL != *assumed; assumed++)
diff --git a/src/media-channel.c b/src/media-channel.c
index 4cc06d8..f434a47 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -2801,25 +2801,23 @@ session_new_content_cb (GabbleJingleSession *session,
}
TpChannelMediaCapabilities
-_gabble_media_channel_caps_to_typeflags (GabblePresenceCapabilities caps)
+_gabble_media_channel_caps_to_typeflags (const GabbleCapabilitySet *caps)
{
TpChannelMediaCapabilities typeflags = 0;
gboolean has_a_transport;
/* FIXME: shouldn't we support audio/video for people with any transport
* that we ourselves support, not just gtalk-p2p? */
- has_a_transport = ((caps & PRESENCE_CAP_GOOGLE_TRANSPORT_P2P) != 0);
+ has_a_transport = gabble_capability_set_has (caps, NS_GOOGLE_TRANSPORT_P2P);
if (has_a_transport &&
- (caps & (PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO |
- PRESENCE_CAP_JINGLE_RTP_AUDIO |
- PRESENCE_CAP_GOOGLE_VOICE)) != 0)
+ gabble_capability_set_has_one (caps,
+ gabble_capabilities_get_any_audio ()))
typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_AUDIO;
if (has_a_transport &&
- (caps & (PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO |
- PRESENCE_CAP_JINGLE_RTP_VIDEO |
- PRESENCE_CAP_GOOGLE_VIDEO)) != 0)
+ gabble_capability_set_has_one (caps,
+ gabble_capabilities_get_any_video ()))
typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_VIDEO;
/* The checks below are an intentional asymmetry with the function going the
@@ -2827,10 +2825,10 @@ _gabble_media_channel_caps_to_typeflags (GabblePresenceCapabilities caps)
* transport capability separately because old GTalk clients didn't do that.
* Having Google voice implied Google session and GTalk-P2P. */
- if ((caps & PRESENCE_CAP_GOOGLE_VOICE) != 0)
+ if (gabble_capability_set_has (caps, NS_GOOGLE_FEAT_VOICE))
typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_AUDIO;
- if ((caps & PRESENCE_CAP_GOOGLE_VIDEO) != 0)
+ if (gabble_capability_set_has (caps, NS_GOOGLE_FEAT_VIDEO))
typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_VIDEO;
return typeflags;
diff --git a/src/media-channel.h b/src/media-channel.h
index 3966815..224212f 100644
--- a/src/media-channel.h
+++ b/src/media-channel.h
@@ -75,7 +75,7 @@ void _gabble_media_channel_typeflags_to_caps (TpChannelMediaCapabilities flags,
GabbleCapabilitySet *caps);
TpChannelMediaCapabilities
-_gabble_media_channel_caps_to_typeflags (GabblePresenceCapabilities caps);
+_gabble_media_channel_caps_to_typeflags (const GabbleCapabilitySet *caps);
void gabble_media_channel_request_initial_streams (GabbleMediaChannel *chan,
GFunc succeeded_cb,
--
1.5.6.5
More information about the telepathy-commits
mailing list