/soc/2013/ankitkv/gobjectification: d5f0fbacfbc8: Refactored msn...
Ankit Vani
a at nevitus.org
Thu Sep 5 16:14:32 EDT 2013
Changeset: d5f0fbacfbc8c140f1928d5bce3ea50e62f6fa51
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-06 00:39 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/d5f0fbacfbc8
Description:
Refactored msn to use the GObject xfer API.
Renamed msn/xfer.[ch] to msn/ft.[ch].
diffstat:
libpurple/protocols/msn/Makefile.am | 4 ++--
libpurple/protocols/msn/xfer.c | 4 ++--
libpurple/protocols/msn/xfer.h | 8 ++++----
libpurple/protocols/msn/msn.c | 17 ++++++++++++++---
libpurple/protocols/msn/slp.c | 10 ++++++----
libpurple/protocols/msn/slpcall.c | 21 +++++++++++++++------
6 files changed, 43 insertions(+), 21 deletions(-)
diffs (190 lines):
diff --git a/libpurple/protocols/msn/Makefile.am b/libpurple/protocols/msn/Makefile.am
--- a/libpurple/protocols/msn/Makefile.am
+++ b/libpurple/protocols/msn/Makefile.am
@@ -16,6 +16,8 @@ MSNSOURCES = \
directconn.h \
error.c \
error.h \
+ ft.c \
+ ft.h \
group.c \
group.h \
history.c \
@@ -70,8 +72,6 @@ MSNSOURCES = \
user.h \
userlist.c \
userlist.h \
- xfer.c \
- xfer.h \
msnutils.c \
msnutils.h
diff --git a/libpurple/protocols/msn/xfer.c b/libpurple/protocols/msn/ft.c
rename from libpurple/protocols/msn/xfer.c
rename to libpurple/protocols/msn/ft.c
--- a/libpurple/protocols/msn/xfer.c
+++ b/libpurple/protocols/msn/ft.c
@@ -1,5 +1,5 @@
/**
- * @file xfer.c MSN File Transfer functions
+ * @file ft.c MSN File Transfer functions
*
* purple
*
@@ -27,7 +27,7 @@
#include "msnutils.h"
#include "sbconn.h"
-#include "xfer.h"
+#include "ft.h"
/**************************************************************************
* Xfer
diff --git a/libpurple/protocols/msn/xfer.h b/libpurple/protocols/msn/ft.h
rename from libpurple/protocols/msn/xfer.h
rename to libpurple/protocols/msn/ft.h
--- a/libpurple/protocols/msn/xfer.h
+++ b/libpurple/protocols/msn/ft.h
@@ -1,5 +1,5 @@
/**
- * @file xfer.h MSN File Transfer functions
+ * @file ft.h MSN File Transfer functions
*
* purple
*
@@ -22,8 +22,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
-#ifndef MSN_XFER_H
-#define MSN_XFER_H
+#ifndef MSN_FT_H
+#define MSN_FT_H
#include "slpcall.h"
@@ -67,5 +67,5 @@ msn_file_context_to_wire(MsnFileContext
MsnFileContext *
msn_file_context_from_wire(const char *buf, gsize len);
-#endif /* MSN_XFER_H */
+#endif /* MSN_FT_H */
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -875,6 +875,19 @@ t_msn_xfer_cancel_send(PurpleXfer *xfer)
msn_slplink_unref(slplink);
}
+static PurpleXferIoOps send_ops =
+{
+ t_msn_xfer_init, /* init */
+ NULL, /* request_denied */
+ NULL, /* start */
+ NULL, /* end */
+ t_msn_xfer_cancel_send, /* cancel_send */
+ NULL, /* cancel_recv */
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* ack */
+};
+
static PurpleXfer*
msn_new_xfer(PurpleConnection *gc, const char *who)
{
@@ -888,9 +901,7 @@ msn_new_xfer(PurpleConnection *gc, const
g_return_val_if_fail(xfer != NULL, NULL);
purple_xfer_set_protocol_data(xfer, msn_slplink_ref(msn_session_get_slplink(session, who)));
-
- purple_xfer_set_init_fnc(xfer, t_msn_xfer_init);
- purple_xfer_set_cancel_send_fnc(xfer, t_msn_xfer_cancel_send);
+ purple_xfer_set_io_ops(xfer, &send_ops);
return xfer;
}
diff --git a/libpurple/protocols/msn/slp.c b/libpurple/protocols/msn/slp.c
--- a/libpurple/protocols/msn/slp.c
+++ b/libpurple/protocols/msn/slp.c
@@ -36,7 +36,7 @@
#include "sbconn.h"
#include "directconn.h"
#include "p2p.h"
-#include "xfer.h"
+#include "ft.h"
/* seconds to delay between sending buddy icon requests to the server. */
#define BUDDY_ICON_DELAY 20
@@ -369,11 +369,13 @@ msn_request_ft(PurpleXfer *xfer)
char *context;
const char *fn;
const char *fp;
+ PurpleXferIoOps *io_ops;
fn = purple_xfer_get_filename(xfer);
fp = purple_xfer_get_local_filename(xfer);
slplink = purple_xfer_get_protocol_data(xfer);
+ io_ops = purple_xfer_get_io_ops(xfer);
g_return_if_fail(slplink != NULL);
g_return_if_fail(fp != NULL);
@@ -389,9 +391,9 @@ msn_request_ft(PurpleXfer *xfer)
slpcall->pending = TRUE;
- purple_xfer_set_cancel_send_fnc(xfer, msn_xfer_cancel);
- purple_xfer_set_read_fnc(xfer, msn_xfer_read);
- purple_xfer_set_write_fnc(xfer, msn_xfer_write);
+ io_ops->cancel_send = msn_xfer_cancel;
+ io_ops->read = msn_xfer_read;
+ io_ops->write = msn_xfer_write;
purple_xfer_set_protocol_data(xfer, slpcall);
diff --git a/libpurple/protocols/msn/slpcall.c b/libpurple/protocols/msn/slpcall.c
--- a/libpurple/protocols/msn/slpcall.c
+++ b/libpurple/protocols/msn/slpcall.c
@@ -31,7 +31,7 @@
#include "slp.h"
#include "p2p.h"
-#include "xfer.h"
+#include "ft.h"
/**************************************************************************
* Main
@@ -445,6 +445,19 @@ msn_slp_process_transresp(MsnSlpCall *sl
return;
}
+static PurpleXferIoOps recieve_ops =
+{
+ msn_xfer_init, /* init */
+ msn_xfer_cancel, /* request_denied */
+ NULL, /* start */
+ NULL, /* end */
+ NULL, /* cancel_send */
+ msn_xfer_cancel, /* cancel_recv */
+ msn_xfer_read, /* read */
+ msn_xfer_write, /* write */
+ NULL, /* ack */
+};
+
static void
got_sessionreq(MsnSlpCall *slpcall, const char *branch,
const char *euf_guid, const char *context)
@@ -536,11 +549,7 @@ got_sessionreq(MsnSlpCall *slpcall, cons
purple_xfer_set_filename(xfer, file_name ? file_name : "");
g_free(file_name);
purple_xfer_set_size(xfer, file_context->file_size);
- purple_xfer_set_init_fnc(xfer, msn_xfer_init);
- purple_xfer_set_request_denied_fnc(xfer, msn_xfer_cancel);
- purple_xfer_set_cancel_recv_fnc(xfer, msn_xfer_cancel);
- purple_xfer_set_read_fnc(xfer, msn_xfer_read);
- purple_xfer_set_write_fnc(xfer, msn_xfer_write);
+ purple_xfer_set_io_ops(xfer, &recieve_ops);
slpcall->u.incoming_data = g_byte_array_new();
More information about the Commits
mailing list