[Telepathy-commits] [telepathy-gabble/master] Remove bundles strings, use a 3-state enum for caps type
Alban Crequy
alban.crequy at collabora.co.uk
Tue Aug 19 10:52:50 PDT 2008
20080521182245-a41c0-b657e309f86c8bb4fd8ea76219ba305a2d72b51b.gz
---
src/capabilities.c | 53 ++++++++++++++++------------------------------
src/capabilities.h | 16 ++++---------
src/gabble-connection.c | 32 ++++++++++-----------------
3 files changed, 36 insertions(+), 65 deletions(-)
diff --git a/src/capabilities.c b/src/capabilities.c
index d3c340c..fa0bb10 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -28,28 +28,28 @@
static const Feature self_advertised_features[] =
{
- { VERSION, NS_GOOGLE_FEAT_SESSION, 0},
- { VERSION, NS_GOOGLE_TRANSPORT_P2P, PRESENCE_CAP_GOOGLE_TRANSPORT_P2P},
- { VERSION, NS_JINGLE, PRESENCE_CAP_JINGLE},
- { VERSION, NS_CHAT_STATES, PRESENCE_CAP_CHAT_STATES},
- { VERSION, NS_NICK, 0},
- { VERSION, NS_NICK "+notify", 0},
- { VERSION, NS_SI, PRESENCE_CAP_SI},
- { VERSION, NS_IBB, PRESENCE_CAP_IBB},
- { VERSION, NS_TUBES, PRESENCE_CAP_SI_TUBES},
-
- { BUNDLE_VOICE_V1, NS_GOOGLE_FEAT_VOICE, PRESENCE_CAP_GOOGLE_VOICE},
- { BUNDLE_JINGLE_AUDIO, NS_JINGLE_DESCRIPTION_AUDIO,
+ { FEATURE_FIXED, NS_GOOGLE_FEAT_SESSION, 0},
+ { FEATURE_FIXED, NS_GOOGLE_TRANSPORT_P2P, PRESENCE_CAP_GOOGLE_TRANSPORT_P2P},
+ { FEATURE_FIXED, NS_JINGLE, PRESENCE_CAP_JINGLE},
+ { FEATURE_FIXED, NS_CHAT_STATES, PRESENCE_CAP_CHAT_STATES},
+ { FEATURE_FIXED, NS_NICK, 0},
+ { FEATURE_FIXED, NS_NICK "+notify", 0},
+ { FEATURE_FIXED, NS_SI, PRESENCE_CAP_SI},
+ { FEATURE_FIXED, NS_IBB, PRESENCE_CAP_IBB},
+ { FEATURE_FIXED, NS_TUBES, PRESENCE_CAP_SI_TUBES},
+
+ { FEATURE_BUNDLE_COMPAT, NS_GOOGLE_FEAT_VOICE, PRESENCE_CAP_GOOGLE_VOICE},
+ { FEATURE_OPTIONAL, NS_JINGLE_DESCRIPTION_AUDIO,
PRESENCE_CAP_JINGLE_DESCRIPTION_AUDIO},
- { BUNDLE_JINGLE_VIDEO, NS_JINGLE_DESCRIPTION_VIDEO,
+ { FEATURE_OPTIONAL, NS_JINGLE_DESCRIPTION_VIDEO,
PRESENCE_CAP_JINGLE_DESCRIPTION_VIDEO},
- { BUNDLE_OLPC_1, NS_OLPC_BUDDY_PROPS "+notify", PRESENCE_CAP_OLPC_1},
- { BUNDLE_OLPC_1, NS_OLPC_ACTIVITIES "+notify", PRESENCE_CAP_OLPC_1},
- { BUNDLE_OLPC_1, NS_OLPC_CURRENT_ACTIVITY "+notify", PRESENCE_CAP_OLPC_1},
- { BUNDLE_OLPC_1, NS_OLPC_ACTIVITY_PROPS "+notify", PRESENCE_CAP_OLPC_1},
+ { FEATURE_OPTIONAL, NS_OLPC_BUDDY_PROPS "+notify", PRESENCE_CAP_OLPC_1},
+ { FEATURE_OPTIONAL, NS_OLPC_ACTIVITIES "+notify", PRESENCE_CAP_OLPC_1},
+ { FEATURE_OPTIONAL, NS_OLPC_CURRENT_ACTIVITY "+notify", PRESENCE_CAP_OLPC_1},
+ { FEATURE_OPTIONAL, NS_OLPC_ACTIVITY_PROPS "+notify", PRESENCE_CAP_OLPC_1},
- { NULL, NULL, 0}
+ { 0, NULL, 0}
};
GSList *
@@ -68,19 +68,6 @@ capabilities_get_features (GabblePresenceCapabilities caps)
void
capabilities_fill_cache (GabblePresenceCache *cache)
{
- const Feature *feat;
-
- /* We don't advertise bundles anymore, but we keep them in the cache. So if
- * we speak to an old version of Gabble, we don't need to make discovery
- * requests for theses bundles. */
- for (feat = self_advertised_features; NULL != feat->ns; feat++)
- {
- gchar *node = g_strconcat (NS_GABBLE_CAPS "#", feat->bundle, NULL);
- gabble_presence_cache_add_bundle_caps (cache,
- node, feat->caps);
- g_free (node);
- }
-
/* Cache this bundle from the Google Talk client as trusted. So Gabble will
* not send any discovery request for this bundle.
*
@@ -99,10 +86,8 @@ capabilities_get_initial_caps ()
for (feat = self_advertised_features; NULL != feat->ns; feat++)
{
- if (g_str_equal (feat->bundle, VERSION))
+ if (feat->feature_type == FEATURE_FIXED)
{
- /* VERSION == bundle means a fixed feature, which we always
- * advertise */
ret |= feat->caps;
}
}
diff --git a/src/capabilities.h b/src/capabilities.h
index 3a6c1c2..20ad1be 100644
--- a/src/capabilities.h
+++ b/src/capabilities.h
@@ -35,21 +35,15 @@
*/
#define BUNDLE_VOICE_V1 "voice-v1"
-/* The bundles "jingle-audio", "jingle-video" and "olpc1" are no more
- * advertised in the 'ext' attribute of the presence stanza. But the following
- * identifiers are still used in self_advertised_features to identify whether
- * it is a fixed feature, which we always advertise. VERSION == bundle means a
- * fixed feature.
- */
-#define BUNDLE_JINGLE_AUDIO "jingle-audio"
-#define BUNDLE_JINGLE_VIDEO "jingle-video"
-#define BUNDLE_OLPC_1 "olpc1"
-
typedef struct _Feature Feature;
struct _Feature
{
- const gchar *bundle;
+ enum {
+ FEATURE_FIXED,
+ FEATURE_OPTIONAL,
+ FEATURE_BUNDLE_COMPAT /* just for voice-v1 */
+ } feature_type;
const gchar *ns;
GabblePresenceCapabilities caps;
};
diff --git a/src/gabble-connection.c b/src/gabble-connection.c
index 72befe5..6548798 100644
--- a/src/gabble-connection.c
+++ b/src/gabble-connection.c
@@ -1431,7 +1431,6 @@ connection_iq_disco_cb (LmMessageHandler *handler,
GSList *features;
GSList *i;
gchar *caps_hash;
- gboolean bundle_found;
if (lm_message_get_sub_type (message) != LM_MESSAGE_SUB_TYPE_GET)
return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
@@ -1486,22 +1485,12 @@ connection_iq_disco_cb (LmMessageHandler *handler,
* legacy XEP-0115 version 1.3 or an hash as defined in XEP-0115 version
* 1.5. */
- bundle_found = FALSE;
- for (i = features; NULL != i; i = i->next)
- {
- const Feature *feature = (const Feature *) i->data;
-
- if (NULL != node && !tp_strdiff (suffix, feature->bundle))
- {
- bundle_found = TRUE;
- DEBUG ("requested node '%s' is an existing bundle", suffix);
- }
- }
-
caps_hash = caps_hash_compute_from_self_presence (self);
DEBUG ("caps_hash='%s'", caps_hash);
- if (NULL == node || bundle_found || !tp_strdiff (suffix, caps_hash))
+ if (NULL == node ||
+ !tp_strdiff (suffix, BUNDLE_VOICE_V1) ||
+ !tp_strdiff (suffix, caps_hash))
{
if (NULL == node)
DEBUG ("No requested node. Send all features.");
@@ -1511,14 +1500,17 @@ connection_iq_disco_cb (LmMessageHandler *handler,
for (i = features; NULL != i; i = i->next)
{
const Feature *feature = (const Feature *) i->data;
+ LmMessageNode *feature_node;
- if (! bundle_found || g_str_equal (suffix, feature->bundle))
- {
- LmMessageNode *feature_node = lm_message_node_add_child
- (result_query, "feature", NULL);
+ /* When BUNDLE_VOICE_V1 is requested, only send the bundle */
+ if (!tp_strdiff (suffix, BUNDLE_VOICE_V1) &&
+ feature->feature_type != FEATURE_BUNDLE_COMPAT)
+ continue;
- lm_message_node_set_attribute (feature_node, "var", feature->ns);
- }
+ /* otherwise (no node or hash), put all features */
+ feature_node = lm_message_node_add_child (result_query, "feature",
+ NULL);
+ lm_message_node_set_attribute (feature_node, "var", feature->ns);
}
NODE_DEBUG (result_iq, "sending disco response");
--
1.5.6.3
More information about the Telepathy-commits
mailing list