/soc/2013/ankitkv/gobjectification: c3e8690bc6d9: Refactored osc...

Ankit Vani a at nevitus.org
Thu Sep 5 17:19:02 EDT 2013


Changeset: c3e8690bc6d9b9bd8650615c87cd9d1555c630f5
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-06 01:46 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/c3e8690bc6d9

Description:

Refactored oscar to use the GObject xfer API

diffstat:

 libpurple/protocols/oscar/oscar.c |  19 ++++++++++++++-----
 libpurple/protocols/oscar/peer.c  |  20 ++++++++++++++------
 2 files changed, 28 insertions(+), 11 deletions(-)

diffs (80 lines):

diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -5225,6 +5225,19 @@ oscar_can_receive_file(PurpleConnection 
 	return FALSE;
 }
 
+static PurpleXferIoOps send_ops =
+{
+	peer_oft_sendcb_init,        /* init */
+	peer_oft_cb_generic_cancel,  /* request_denied */
+	NULL,                        /* start */
+	NULL,                        /* end */
+	peer_oft_cb_generic_cancel,  /* cancel_send */
+	NULL,                        /* cancel_recv */
+	NULL,                        /* read */
+	NULL,                        /* write */
+	peer_oft_sendcb_ack,         /* ack */
+};
+
 PurpleXfer *
 oscar_new_xfer(PurpleConnection *gc, const char *who)
 {
@@ -5239,11 +5252,7 @@ oscar_new_xfer(PurpleConnection *gc, con
 	xfer = purple_xfer_new(account, PURPLE_XFER_SEND, who);
 	if (xfer)
 	{
-		g_object_ref(xfer);
-		purple_xfer_set_init_fnc(xfer, peer_oft_sendcb_init);
-		purple_xfer_set_cancel_send_fnc(xfer, peer_oft_cb_generic_cancel);
-		purple_xfer_set_request_denied_fnc(xfer, peer_oft_cb_generic_cancel);
-		purple_xfer_set_ack_fnc(xfer, peer_oft_sendcb_ack);
+		purple_xfer_set_io_ops(xfer, &send_ops);
 
 		conn = peer_connection_new(od, OSCAR_CAPABILITY_SENDFILE, who);
 		conn->flags |= PEER_CONNECTION_FLAG_INITIATED_BY_ME;
diff --git a/libpurple/protocols/oscar/peer.c b/libpurple/protocols/oscar/peer.c
--- a/libpurple/protocols/oscar/peer.c
+++ b/libpurple/protocols/oscar/peer.c
@@ -1011,6 +1011,19 @@ peer_connection_got_proposition_no_cb(gp
 	peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL);
 }
 
+static PurpleXferIoOps recieve_ops =
+{
+	peer_oft_recvcb_init,        /* init */
+	peer_oft_cb_generic_cancel,  /* request_denied */
+	NULL,                        /* start */
+	peer_oft_recvcb_end,         /* end */
+	NULL,                        /* cancel_send */
+	peer_oft_cb_generic_cancel,  /* cancel_recv */
+	NULL,                        /* read */
+	NULL,                        /* write */
+	peer_oft_recvcb_ack_recv,    /* ack */
+};
+
 /**
  * Someone else wants to establish a peer connection with us.
  */
@@ -1114,7 +1127,6 @@ peer_connection_got_proposition(OscarDat
 		if (conn->xfer)
 		{
 			purple_xfer_set_protocol_data(conn->xfer, conn);
-			g_object_ref(conn->xfer);
 			purple_xfer_set_size(conn->xfer, args->info.sendfile.totsize);
 
 			/* Set the file name */
@@ -1151,11 +1163,7 @@ peer_connection_got_proposition(OscarDat
 			}
 
 			/* Setup our I/O op functions */
-			purple_xfer_set_init_fnc(conn->xfer, peer_oft_recvcb_init);
-			purple_xfer_set_end_fnc(conn->xfer, peer_oft_recvcb_end);
-			purple_xfer_set_request_denied_fnc(conn->xfer, peer_oft_cb_generic_cancel);
-			purple_xfer_set_cancel_recv_fnc(conn->xfer, peer_oft_cb_generic_cancel);
-			purple_xfer_set_ack_fnc(conn->xfer, peer_oft_recvcb_ack_recv);
+			purple_xfer_set_io_ops(conn->xfer, &recieve_ops);
 
 			/* Now perform the request */
 			purple_xfer_request(conn->xfer);



More information about the Commits mailing list