/soc/2013/ankitkv/gobjectification: 4dfe09057bed: Register jingl...

Ankit Vani a at nevitus.org
Sat Oct 12 08:23:31 EDT 2013


Changeset: 4dfe09057bed60a1f48fe976e1c21f4ca77407f5
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-10-12 17:43 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/4dfe09057bed

Description:

Register jingle types dynamically

diffstat:

 libpurple/protocols/jabber/google/google_p2p.c |  23 +----------------------
 libpurple/protocols/jabber/google/google_p2p.h |   7 ++++++-
 libpurple/protocols/jabber/jabber.c            |  13 +++++++++++++
 libpurple/protocols/jabber/jingle/content.c    |  23 +----------------------
 libpurple/protocols/jabber/jingle/content.h    |   7 ++++++-
 libpurple/protocols/jabber/jingle/iceudp.c     |  23 +----------------------
 libpurple/protocols/jabber/jingle/iceudp.h     |   7 ++++++-
 libpurple/protocols/jabber/jingle/rawudp.c     |  23 +----------------------
 libpurple/protocols/jabber/jingle/rawudp.h     |   7 ++++++-
 libpurple/protocols/jabber/jingle/rtp.c        |  23 +----------------------
 libpurple/protocols/jabber/jingle/rtp.h        |   7 ++++++-
 libpurple/protocols/jabber/jingle/session.c    |  23 +----------------------
 libpurple/protocols/jabber/jingle/session.h    |   7 ++++++-
 libpurple/protocols/jabber/jingle/transport.c  |  23 +----------------------
 libpurple/protocols/jabber/jingle/transport.h  |   7 ++++++-
 15 files changed, 62 insertions(+), 161 deletions(-)

diffs (truncated from 387 to 300 lines):

diff --git a/libpurple/protocols/jabber/google/google_p2p.c b/libpurple/protocols/jabber/google/google_p2p.c
--- a/libpurple/protocols/jabber/google/google_p2p.c
+++ b/libpurple/protocols/jabber/google/google_p2p.c
@@ -120,28 +120,7 @@ jingle_google_p2p_candidate_new(const gc
 	return candidate;
 }
 
-GType
-jingle_google_p2p_get_type(void)
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		static const GTypeInfo info = {
-			sizeof(JingleGoogleP2PClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) jingle_google_p2p_class_init,
-			NULL,
-			NULL,
-			sizeof(JingleGoogleP2P),
-			0,
-			(GInstanceInitFunc) jingle_google_p2p_init,
-			NULL
-		};
-		type = g_type_register_static(JINGLE_TYPE_TRANSPORT, "JingleGoogleP2P", &info, 0);
-	}
-	return type;
-}
+PURPLE_DEFINE_TYPE(JingleGoogleP2P, jingle_google_p2p, JINGLE_TYPE_TRANSPORT);
 
 static void
 jingle_google_p2p_class_init(JingleGoogleP2PClass *klass)
diff --git a/libpurple/protocols/jabber/google/google_p2p.h b/libpurple/protocols/jabber/google/google_p2p.h
--- a/libpurple/protocols/jabber/google/google_p2p.h
+++ b/libpurple/protocols/jabber/google/google_p2p.h
@@ -89,7 +89,12 @@ GType jingle_google_p2p_candidate_get_ty
  *
  * @return The Google P2P class's GType.
  */
-GType jingle_google_p2p_get_type(void);
+G_MODULE_EXPORT GType jingle_google_p2p_get_type(void);
+
+/**
+ * Registers the JingleGoogleP2P type in the type system.
+ */
+void jingle_google_p2p_register_type(PurplePlugin *plugin);
 
 JingleGoogleP2PCandidate *jingle_google_p2p_candidate_new(const gchar *id,
 		guint generation, const gchar *address, guint port, guint preference,
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -52,6 +52,7 @@
 #include "data.h"
 #include "disco.h"
 #include "google/google.h"
+#include "google/google_p2p.h"
 #include "google/google_roster.h"
 #include "google/google_session.h"
 #include "ibb.h"
@@ -73,6 +74,8 @@
 #include "facebook.h"
 
 #include "jingle/jingle.h"
+#include "jingle/iceudp.h"
+#include "jingle/rawudp.h"
 #include "jingle/rtp.h"
 
 #define PING_TIMEOUT 60
@@ -4317,6 +4320,16 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
+	jingle_session_register_type(plugin);
+
+	jingle_transport_register_type(plugin);
+	jingle_iceudp_register_type(plugin);
+	jingle_rawudp_register_type(plugin);
+	jingle_google_p2p_register_type(plugin);
+
+	jingle_content_register_type(plugin);
+	jingle_rtp_register_type(plugin);
+
 	jabber_protocol_register_type(plugin);
 
 	facebook_protocol_register_type(plugin);
diff --git a/libpurple/protocols/jabber/jingle/content.c b/libpurple/protocols/jabber/jingle/content.c
--- a/libpurple/protocols/jabber/jingle/content.c
+++ b/libpurple/protocols/jabber/jingle/content.c
@@ -65,28 +65,7 @@ enum {
 	PROP_PENDING_TRANSPORT,
 };
 
-GType
-jingle_content_get_type()
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		static const GTypeInfo info = {
-			sizeof(JingleContentClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) jingle_content_class_init,
-			NULL,
-			NULL,
-			sizeof(JingleContent),
-			0,
-			(GInstanceInitFunc) jingle_content_init,
-			NULL
-		};
-		type = g_type_register_static(G_TYPE_OBJECT, "JingleContent", &info, 0);
-	}
-	return type;
-}
+PURPLE_DEFINE_TYPE(JingleContent, jingle_content, G_TYPE_OBJECT);
 
 static void
 jingle_content_class_init (JingleContentClass *klass)
diff --git a/libpurple/protocols/jabber/jingle/content.h b/libpurple/protocols/jabber/jingle/content.h
--- a/libpurple/protocols/jabber/jingle/content.h
+++ b/libpurple/protocols/jabber/jingle/content.h
@@ -73,7 +73,12 @@ struct _JingleContent
  *
  * @return The content class's GType.
  */
-GType jingle_content_get_type(void);
+G_MODULE_EXPORT GType jingle_content_get_type(void);
+
+/**
+ * Registers the JingleContent type in the type system.
+ */
+void jingle_content_register_type(PurplePlugin *plugin);
 
 JingleContent *jingle_content_create(const gchar *type, const gchar *creator,
 		const gchar *disposition, const gchar *name,
diff --git a/libpurple/protocols/jabber/jingle/iceudp.c b/libpurple/protocols/jabber/jingle/iceudp.c
--- a/libpurple/protocols/jabber/jingle/iceudp.c
+++ b/libpurple/protocols/jabber/jingle/iceudp.c
@@ -133,28 +133,7 @@ jingle_iceudp_candidate_new(const gchar 
 	return candidate;
 }
 
-GType
-jingle_iceudp_get_type()
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		static const GTypeInfo info = {
-			sizeof(JingleIceUdpClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) jingle_iceudp_class_init,
-			NULL,
-			NULL,
-			sizeof(JingleIceUdp),
-			0,
-			(GInstanceInitFunc) jingle_iceudp_init,
-			NULL
-		};
-		type = g_type_register_static(JINGLE_TYPE_TRANSPORT, "JingleIceUdp", &info, 0);
-	}
-	return type;
-}
+PURPLE_DEFINE_TYPE(JingleIceUdp, jingle_iceudp, JINGLE_TYPE_TRANSPORT);
 
 static void
 jingle_iceudp_class_init (JingleIceUdpClass *klass)
diff --git a/libpurple/protocols/jabber/jingle/iceudp.h b/libpurple/protocols/jabber/jingle/iceudp.h
--- a/libpurple/protocols/jabber/jingle/iceudp.h
+++ b/libpurple/protocols/jabber/jingle/iceudp.h
@@ -94,7 +94,12 @@ GType jingle_iceudp_candidate_get_type(v
  *
  * @return The iceudp class's GType.
  */
-GType jingle_iceudp_get_type(void);
+G_MODULE_EXPORT GType jingle_iceudp_get_type(void);
+
+/**
+ * Registers the JingleIceUdp type in the type system.
+ */
+void jingle_iceudp_register_type(PurplePlugin *plugin);
 
 JingleIceUdpCandidate *jingle_iceudp_candidate_new(const gchar *id,
 		guint component, const gchar *foundation, guint generation,
diff --git a/libpurple/protocols/jabber/jingle/rawudp.c b/libpurple/protocols/jabber/jingle/rawudp.c
--- a/libpurple/protocols/jabber/jingle/rawudp.c
+++ b/libpurple/protocols/jabber/jingle/rawudp.c
@@ -104,28 +104,7 @@ jingle_rawudp_candidate_new(const gchar 
 	return candidate;
 }
 
-GType
-jingle_rawudp_get_type()
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		static const GTypeInfo info = {
-			sizeof(JingleRawUdpClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) jingle_rawudp_class_init,
-			NULL,
-			NULL,
-			sizeof(JingleRawUdp),
-			0,
-			(GInstanceInitFunc) jingle_rawudp_init,
-			NULL
-		};
-		type = g_type_register_static(JINGLE_TYPE_TRANSPORT, "JingleRawUdp", &info, 0);
-	}
-	return type;
-}
+PURPLE_DEFINE_TYPE(JingleRawUdp, jingle_rawudp, JINGLE_TYPE_TRANSPORT);
 
 static void
 jingle_rawudp_class_init (JingleRawUdpClass *klass)
diff --git a/libpurple/protocols/jabber/jingle/rawudp.h b/libpurple/protocols/jabber/jingle/rawudp.h
--- a/libpurple/protocols/jabber/jingle/rawudp.h
+++ b/libpurple/protocols/jabber/jingle/rawudp.h
@@ -84,7 +84,12 @@ GType jingle_rawudp_candidate_get_type(v
  *
  * @return The rawudp class's GType.
  */
-GType jingle_rawudp_get_type(void);
+G_MODULE_EXPORT GType jingle_rawudp_get_type(void);
+
+/**
+ * Registers the JingleRawUdp type in the type system.
+ */
+void jingle_rawudp_register_type(PurplePlugin *plugin);
 
 JingleRawUdpCandidate *jingle_rawudp_candidate_new(const gchar *id,
 		guint generation, guint component, const gchar *ip, guint port);
diff --git a/libpurple/protocols/jabber/jingle/rtp.c b/libpurple/protocols/jabber/jingle/rtp.c
--- a/libpurple/protocols/jabber/jingle/rtp.c
+++ b/libpurple/protocols/jabber/jingle/rtp.c
@@ -72,28 +72,7 @@ enum {
 	PROP_SSRC,
 };
 
-GType
-jingle_rtp_get_type()
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		static const GTypeInfo info = {
-			sizeof(JingleRtpClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) jingle_rtp_class_init,
-			NULL,
-			NULL,
-			sizeof(JingleRtp),
-			0,
-			(GInstanceInitFunc) jingle_rtp_init,
-			NULL
-		};
-		type = g_type_register_static(JINGLE_TYPE_CONTENT, "JingleRtp", &info, 0);
-	}
-	return type;
-}
+PURPLE_DEFINE_TYPE(JingleRtp, jingle_rtp, JINGLE_TYPE_CONTENT);
 
 static void
 jingle_rtp_class_init (JingleRtpClass *klass)
diff --git a/libpurple/protocols/jabber/jingle/rtp.h b/libpurple/protocols/jabber/jingle/rtp.h
--- a/libpurple/protocols/jabber/jingle/rtp.h
+++ b/libpurple/protocols/jabber/jingle/rtp.h
@@ -70,7 +70,12 @@ struct _JingleRtp
  *
  * @return The rtp class's GType.
  */
-GType jingle_rtp_get_type(void);
+G_MODULE_EXPORT GType jingle_rtp_get_type(void);
+
+/**
+ * Registers the JingleRtp type in the type system.
+ */
+void jingle_rtp_register_type(PurplePlugin *plugin);
 
 gchar *jingle_rtp_get_media_type(JingleContent *content);
 gchar *jingle_rtp_get_ssrc(JingleContent *content);
diff --git a/libpurple/protocols/jabber/jingle/session.c b/libpurple/protocols/jabber/jingle/session.c
--- a/libpurple/protocols/jabber/jingle/session.c
+++ b/libpurple/protocols/jabber/jingle/session.c
@@ -65,28 +65,7 @@ enum {
 	PROP_PENDING_CONTENTS,
 };
 
-GType
-jingle_session_get_type()
-{
-	static GType type = 0;
-
-	if (type == 0) {



More information about the Commits mailing list