[Telepathy-commits] [telepathy-salut/master] ChannelManager: add a helper to check for unknown properties in requests

Will Thompson will.thompson at collabora.co.uk
Thu Oct 23 07:30:39 PDT 2008


---
 src/channel-manager.c |   28 ++++++++++++++++++++++++++++
 src/channel-manager.h |    6 ++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/channel-manager.c b/src/channel-manager.c
index dfe18e6..45236c8 100644
--- a/src/channel-manager.c
+++ b/src/channel-manager.c
@@ -24,6 +24,8 @@
 #include "channel-manager.h"
 
 #include <telepathy-glib/dbus.h>
+#include <telepathy-glib/errors.h>
+#include <telepathy-glib/util.h>
 
 #include "exportable-channel.h"
 #include "signals-marshal.h"
@@ -416,3 +418,29 @@ salut_channel_manager_request_channel (SalutChannelManager *manager,
   else
     return FALSE;
 }
+
+
+gboolean
+salut_channel_manager_asv_has_unknown_properties (GHashTable *properties,
+                                                  const gchar * const *fixed,
+                                                  const gchar * const *allowed,
+                                                  GError **error)
+{
+  GHashTableIter iter;
+  gpointer key;
+  const gchar *property_name;
+
+  g_hash_table_iter_init (&iter, properties);
+  while (g_hash_table_iter_next (&iter, &key, NULL))
+    {
+      property_name = key;
+      if (!tp_strv_contains (fixed, property_name) &&
+          !tp_strv_contains (allowed, property_name))
+        {
+          g_set_error (error, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
+              "Request contained unknown property '%s'", property_name);
+          return TRUE;
+        }
+    }
+  return FALSE;
+}
diff --git a/src/channel-manager.h b/src/channel-manager.h
index f374bf9..771c000 100644
--- a/src/channel-manager.h
+++ b/src/channel-manager.h
@@ -124,6 +124,12 @@ void salut_channel_manager_emit_request_failed_printf (gpointer instance,
     gpointer request_token, GQuark domain, gint code, const gchar *format,
     ...) G_GNUC_PRINTF (5, 6);
 
+/* helpers */
+
+gboolean salut_channel_manager_asv_has_unknown_properties (
+    GHashTable *properties, const gchar * const *fixed,
+    const gchar * const *allowed, GError **error);
+
 G_END_DECLS
 
 #endif
-- 
1.5.6.5




More information about the Telepathy-commits mailing list