[telepathy-gabble/master] gabble_presence_pick_best_feature(): add

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Jan 5 11:00:04 PST 2010


This is analogous to gabble_presence_resource_pick_best_feature(), but
checks the aggregated caps of all resources (or, more usefully, the bare
JID's caps, if there are no resources at all).
---
 src/presence.c |   23 +++++++++++++++++++++++
 src/presence.h |    5 +++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/presence.c b/src/presence.c
index 9047a7b..06e1833 100644
--- a/src/presence.c
+++ b/src/presence.c
@@ -666,3 +666,26 @@ gabble_presence_resource_pick_best_feature (GabblePresence *presence,
 
   return NULL;
 }
+
+gconstpointer
+gabble_presence_pick_best_feature (GabblePresence *presence,
+    const GabbleFeatureFallback *table,
+    GabbleCapabilitySetPredicate predicate)
+{
+  const GabbleFeatureFallback *row;
+
+  g_return_val_if_fail (presence != NULL, NULL);
+  g_return_val_if_fail (predicate != NULL, NULL);
+  g_return_val_if_fail (table != NULL, NULL);
+
+  for (row = table; row->result != NULL; row++)
+    {
+      if (row->considered && predicate (presence->priv->cap_set,
+            row->check_data))
+        {
+          return row->result;
+        }
+    }
+
+  return NULL;
+}
diff --git a/src/presence.h b/src/presence.h
index ea16c36..4181db2 100644
--- a/src/presence.h
+++ b/src/presence.h
@@ -114,6 +114,11 @@ gconstpointer gabble_presence_resource_pick_best_feature (
     const GabbleFeatureFallback *table,
     GabbleCapabilitySetPredicate predicate);
 
+gconstpointer
+gabble_presence_pick_best_feature (GabblePresence *presence,
+    const GabbleFeatureFallback *table,
+    GabbleCapabilitySetPredicate predicate);
+
 G_END_DECLS
 
 #endif /* __GABBLE_PRESENCE_H__ */
-- 
1.5.6.5




More information about the telepathy-commits mailing list