[Telepathy-commits] [telepathy-gabble/master] GabbleJingleFactory: add methods to look up transports
Simon McVittie
simon.mcvittie at collabora.co.uk
Wed Feb 25 04:27:42 PST 2009
Also improve coding style (object whose method is implemented is named
self, avoid use of C++ keyword "namespace", indentation) and when
registering new transports/content-types, assert that they have the
correct GObject interface/type.
---
src/jingle-factory.c | 35 +++++++++++++++++++++++++++++------
src/jingle-factory.h | 14 ++++++++++----
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/src/jingle-factory.c b/src/jingle-factory.c
index 526ab39..d6e2641 100644
--- a/src/jingle-factory.c
+++ b/src/jingle-factory.c
@@ -598,21 +598,44 @@ gabble_jingle_factory_create_session (GabbleJingleFactory *fac,
}
void
-gabble_jingle_factory_register_transport (GabbleJingleFactory *factory,
- gchar *namespace, GType transport_type)
+gabble_jingle_factory_register_transport (GabbleJingleFactory *self,
+ gchar *xmlns,
+ GType transport_type)
{
- g_hash_table_insert (factory->transports, namespace,
+ g_return_if_fail (g_type_is_a (transport_type,
+ GABBLE_TYPE_JINGLE_TRANSPORT_IFACE));
+
+ g_hash_table_insert (self->transports, xmlns,
GSIZE_TO_POINTER (transport_type));
}
+GType
+gabble_jingle_factory_lookup_transport (GabbleJingleFactory *self,
+ const gchar *xmlns)
+{
+ return GPOINTER_TO_SIZE (g_hash_table_lookup (self->transports,
+ xmlns));
+}
+
void
-gabble_jingle_factory_register_content_type (GabbleJingleFactory *factory,
- gchar *namespace, GType content_type)
+gabble_jingle_factory_register_content_type (GabbleJingleFactory *self,
+ gchar *xmlns,
+ GType content_type)
{
- g_hash_table_insert (factory->content_types, namespace,
+ g_return_if_fail (g_type_is_a (content_type, GABBLE_TYPE_JINGLE_CONTENT));
+
+ g_hash_table_insert (self->content_types, xmlns,
GSIZE_TO_POINTER (content_type));
}
+GType
+gabble_jingle_factory_lookup_content_type (GabbleJingleFactory *self,
+ const gchar *xmlns)
+{
+ return GPOINTER_TO_SIZE (g_hash_table_lookup (self->content_types,
+ xmlns));
+}
+
static void
session_terminated_cb (GabbleJingleSession *session,
gboolean local_terminator, GabbleJingleFactory *factory)
diff --git a/src/jingle-factory.h b/src/jingle-factory.h
index 5371bc4..a9b390b 100644
--- a/src/jingle-factory.h
+++ b/src/jingle-factory.h
@@ -134,10 +134,16 @@ struct _GabbleJingleFactory {
GabbleJingleFactoryPrivate *priv;
};
-void gabble_jingle_factory_register_content_type (GabbleJingleFactory *factory,
- gchar *namespace, GType content_type);
-void gabble_jingle_factory_register_transport (GabbleJingleFactory *factory,
- gchar *namespace, GType transport_type);
+void gabble_jingle_factory_register_content_type (GabbleJingleFactory *self,
+ gchar *xmlns, GType content_type);
+GType gabble_jingle_factory_lookup_content_type (GabbleJingleFactory *self,
+ const gchar *xmlns);
+
+void gabble_jingle_factory_register_transport (GabbleJingleFactory *self,
+ gchar *xmlns, GType transport_type);
+GType gabble_jingle_factory_lookup_transport (GabbleJingleFactory *self,
+ const gchar *xmlns);
+
void _jingle_factory_unregister_session (GabbleJingleFactory *factory,
const gchar *sid);
--
1.5.6.5
More information about the telepathy-commits
mailing list