/soc/2013/ankitkv/gobjectification: ace4d80b11cd: Backed out cha...

Ankit Vani a at nevitus.org
Fri Sep 13 09:44:38 EDT 2013


Changeset: ace4d80b11cdf4e1743f1b6b84fc353bd2c3378f
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-13 18:54 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/ace4d80b11cd

Description:

Backed out changeset 2961685df856

diffstat:

 libpurple/protocols/bonjour/bonjour.c    |   2 -
 libpurple/protocols/bonjour/bonjour_ft.c |  59 ++++++++++---------------------
 libpurple/protocols/bonjour/bonjour_ft.h |  31 ----------------
 3 files changed, 19 insertions(+), 73 deletions(-)

diffs (249 lines):

diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -693,7 +693,6 @@ static void
 bonjour_protocol_interface_init(PurpleProtocolInterface *iface)
 {
 	iface->connection_new       = bonjour_connection_new;
-	iface->xfer_new             = xep_xfer_new;
 	iface->list_icon            = bonjour_list_icon;
 	iface->status_text          = bonjour_status_text;
 	iface->tooltip_text         = bonjour_tooltip_text;
@@ -743,7 +742,6 @@ plugin_load(PurplePlugin *plugin, GError
 {
 	bonjour_connection_register_type(plugin);
 	bonjour_protocol_register_type(plugin);
-	xep_xfer_register_type(plugin);
 
 	my_protocol = purple_protocols_add(BONJOUR_TYPE_PROTOCOL, error);
 	if (!my_protocol)
diff --git a/libpurple/protocols/bonjour/bonjour_ft.c b/libpurple/protocols/bonjour/bonjour_ft.c
--- a/libpurple/protocols/bonjour/bonjour_ft.c
+++ b/libpurple/protocols/bonjour/bonjour_ft.c
@@ -45,32 +45,6 @@ static void bonjour_free_xfer(PurpleXfer
 static unsigned int next_id = 0;
 
 static void
-xep_xfer_init(GObject *object)
-{
-}
-
-static void
-xep_xfer_class_init(GObjectClass *klass)
-{
-}
-
-PurpleXfer *
-xep_xfer_new(PurpleAccount *account, PurpleXferType type, const char *who)
-{
-	g_return_val_if_fail(type    != PURPLE_XFER_TYPE_UNKNOWN, NULL);
-	g_return_val_if_fail(account != NULL, NULL);
-	g_return_val_if_fail(who     != NULL, NULL);
-
-	return g_object_new(XEP_TYPE_XFER,
-	                    "account",      account,
-	                    "type",         type,
-	                    "remote-user",  who,
-	                    NULL);
-}
-
-PURPLE_DEFINE_TYPE(XepXfer, xep_xfer, PURPLE_TYPE_XFER);
-
-static void
 xep_ft_si_reject(BonjourConnection *bd, const char *id, const char *to, const char *error_code, const char *error_type)
 {
 	PurpleXmlNode *error_node;
@@ -116,7 +90,7 @@ static void bonjour_xfer_cancel_send(Pur
 
 static void bonjour_xfer_request_denied(PurpleXfer *xfer)
 {
-	XepXfer *xf = XEP_XFER(xfer);
+	XepXfer *xf = purple_xfer_get_protocol_data(xfer);
 
 	purple_debug_info("bonjour", "Bonjour-xfer-request-denied.\n");
 
@@ -188,7 +162,7 @@ bonjour_si_xfer_find(BonjourConnection *
 		xfer = xfers->data;
 		if(xfer == NULL)
 			break;
-		xf = XEP_XFER(xfer);
+		xf = purple_xfer_get_protocol_data(xfer);
 		if(xf == NULL)
 			break;
 		if(xf->sid && purple_xfer_get_remote_user(xfer) && !strcmp(xf->sid, sid) &&
@@ -206,7 +180,7 @@ xep_ft_si_offer(PurpleXfer *xfer, const 
 {
 	PurpleXmlNode *si_node, *feature, *field, *file, *x;
 	XepIq *iq;
-	XepXfer *xf = XEP_XFER(xfer);
+	XepXfer *xf = purple_xfer_get_protocol_data(xfer);
 	BonjourConnection *bd = NULL;
 	char buf[32];
 
@@ -275,7 +249,7 @@ xep_ft_si_result(PurpleXfer *xfer, const
 
 	if(!to || !xfer)
 		return;
-	xf = XEP_XFER(xfer);
+	xf = purple_xfer_get_protocol_data(xfer);
 	if(!xf)
 		return;
 
@@ -337,7 +311,7 @@ bonjour_free_xfer(PurpleXfer *xfer)
 
 	purple_debug_misc("bonjour", "bonjour-free-xfer-%p.\n", xfer);
 
-	xf = XEP_XFER(xfer);
+	xf = purple_xfer_get_protocol_data(xfer);
 	if(xf != NULL) {
 		BonjourConnection *bd = (BonjourConnection*)xf->data;
 		if(bd != NULL) {
@@ -357,6 +331,9 @@ bonjour_free_xfer(PurpleXfer *xfer)
 		g_free(xf->sid);
 
 		purple_xmlnode_free_tree(xf->streamhost);
+
+		g_free(xf);
+		purple_xfer_set_protocol_data(xfer, NULL);
 	}
 
 	purple_debug_misc("bonjour", "Need close socket.\n");
@@ -379,7 +356,8 @@ bonjour_new_xfer(PurpleConnection *gc, c
 
 	/* Build the file transfer handle */
 	xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_TYPE_SEND, who);
-	xep_xfer = XEP_XFER(xfer);
+	xep_xfer = g_new0(XepXfer, 1);
+	purple_xfer_set_protocol_data(xfer, xep_xfer);
 	xep_xfer->data = bd;
 
 	purple_debug_info("bonjour", "Bonjour-new-xfer bd=%p data=%p.\n", bd, xep_xfer->data);
@@ -424,7 +402,7 @@ bonjour_xfer_init(PurpleXfer *xfer)
 	BonjourBuddy *bb;
 	XepXfer *xf;
 
-	xf = XEP_XFER(xfer);
+	xf = purple_xfer_get_protocol_data(xfer);
 	if(xf == NULL)
 		return;
 
@@ -679,7 +657,7 @@ static gboolean
 	char *tmp_iq_id;
 	const char *jid, *host, *port;
 	int portnum;
-	XepXfer *xf = XEP_XFER(xfer);
+	XepXfer *xf = purple_xfer_get_protocol_data(xfer);
 
 	for(; streamhost; streamhost = purple_xmlnode_get_next_twin(streamhost)) {
 		if(!(jid = purple_xmlnode_get_attrib(streamhost, "jid")) ||
@@ -784,7 +762,8 @@ bonjour_xfer_receive(PurpleConnection *p
 
 	/* Build the file transfer handle */
 	xfer = purple_xfer_new(purple_connection_get_account(pc), PURPLE_XFER_TYPE_RECEIVE, from);
-	xf = XEP_XFER(xfer);
+	xf = g_new0(XepXfer, 1);
+	purple_xfer_set_protocol_data(xfer, xf);
 	xf->data = bd;
 	purple_xfer_set_filename(xfer, filename);
 	xf->iq_id = g_strdup(id);
@@ -806,7 +785,7 @@ static void
 bonjour_sock5_request_cb(gpointer data, gint source, PurpleInputCondition cond)
 {
 	PurpleXfer *xfer = data;
-	XepXfer *xf = XEP_XFER(xfer);
+	XepXfer *xf = purple_xfer_get_protocol_data(xfer);
 	int acceptfd;
 	int len = 0;
 
@@ -942,7 +921,7 @@ bonjour_bytestreams_listen(int sock, gpo
 
 	purple_xfer_set_watcher(xfer, purple_input_add(sock, PURPLE_INPUT_READ,
 					 bonjour_sock5_request_cb, xfer));
-	xf = XEP_XFER(xfer);
+	xf = purple_xfer_get_protocol_data(xfer);
 	xf->listen_data = NULL;
 
 	bd = xf->data;
@@ -980,7 +959,7 @@ bonjour_bytestreams_init(PurpleXfer *xfe
 		return;
 
 	purple_debug_info("bonjour", "Bonjour-bytestreams-init.\n");
-	xf = XEP_XFER(xfer);
+	xf = purple_xfer_get_protocol_data(xfer);
 
 	xf->listen_data = purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, FALSE,
 						      bonjour_bytestreams_listen, xfer);
@@ -994,7 +973,7 @@ static void
 bonjour_bytestreams_connect_cb(gpointer data, gint source, const gchar *error_message)
 {
 	PurpleXfer *xfer = data;
-	XepXfer *xf = XEP_XFER(xfer);
+	XepXfer *xf = purple_xfer_get_protocol_data(xfer);
 	XepIq *iq;
 	PurpleXmlNode *q_node, *tmp_node;
 	BonjourConnection *bd;
@@ -1052,7 +1031,7 @@ bonjour_bytestreams_connect(PurpleXfer *
 
 	purple_debug_info("bonjour", "bonjour-bytestreams-connect.\n");
 
-	xf = XEP_XFER(xfer);
+	xf = purple_xfer_get_protocol_data(xfer);
 	if(!xf)
 		return;
 
diff --git a/libpurple/protocols/bonjour/bonjour_ft.h b/libpurple/protocols/bonjour/bonjour_ft.h
--- a/libpurple/protocols/bonjour/bonjour_ft.h
+++ b/libpurple/protocols/bonjour/bonjour_ft.h
@@ -23,16 +23,7 @@
 #define _BONJOUR_FT_H_
 #include "network.h"
 #include "proxy.h"
-
-#define XEP_TYPE_XFER             (xep_xfer_get_type())
-#define XEP_XFER(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), XEP_TYPE_XFER, XepXfer))
-#define XEP_XFER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), XEP_TYPE_XFER, XepXferClass))
-#define XEP_IS_XFER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), XEP_TYPE_XFER))
-#define XEP_IS_XFER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), XEP_TYPE_XFER))
-#define XEP_XFER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), XEP_TYPE_XFER, XepXferClass))
 typedef struct _XepXfer XepXfer;
-typedef struct _XepXferClass XepXferClass;
-
 typedef enum {
 	XEP_BYTESTREAMS = 1,
 	XEP_IBB = 2,
@@ -41,8 +32,6 @@ typedef enum {
 
 struct _XepXfer
 {
-	PurpleXfer parent;
-
 	void *data;
 	char *filename;
 	int filesize;
@@ -65,26 +54,6 @@ struct _XepXfer
 	PurpleBuddy *pb;
 };
 
-struct _XepXferClass
-{
-	PurpleXferClass parent_class;
-};
-
-/**
- * Registers the type for XepXfer in the type system.
- */
-void xep_xfer_register_type(PurplePlugin *plugin);
-
-/**
- * Returns the GType for the XepXfer object.
- */
-GType xep_xfer_get_type(void);
-
-/**
- * Returns a new XepXfer instance.
- */
-PurpleXfer *xep_xfer_new(PurpleAccount *account, PurpleXferType type, const char *who);
-
 /**
  * Create a new PurpleXfer
  *



More information about the Commits mailing list