/soc/2013/ankitkv/gobjectification: cacde085bb16: Refactored sil...
Ankit Vani
a at nevitus.org
Thu Sep 5 17:19:02 EDT 2013
Changeset: cacde085bb167fa3106b8bdc42ffbf71d416edba
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-06 02:29 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/cacde085bb16
Description:
Refactored silc to use the GObject xfer API
diffstat:
libpurple/protocols/silc/ft.c | 57 +++++++++++++++++++++++++++++++++++-------
1 files changed, 47 insertions(+), 10 deletions(-)
diffs (102 lines):
diff --git a/libpurple/protocols/silc/ft.c b/libpurple/protocols/silc/ft.c
--- a/libpurple/protocols/silc/ft.c
+++ b/libpurple/protocols/silc/ft.c
@@ -186,6 +186,19 @@ silcpurple_ftp_ask_name_ok(PurpleXfer *x
xfer->completion(name, xfer->completion_context);
}
+static PurpleXferIoOps askname_ops =
+{
+ NULL, /* init */
+ NULL, /* request_denied */
+ NULL, /* start */
+ NULL, /* end */
+ NULL, /* cancel_send */
+ NULL, /* cancel_recv */
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* ack */
+};
+
static void
silcpurple_ftp_ask_name(SilcClient client,
SilcClientConnection conn,
@@ -200,8 +213,11 @@ silcpurple_ftp_ask_name(SilcClient clien
xfer->completion = completion;
xfer->completion_context = completion_context;
- purple_xfer_set_init_fnc(xfer->xfer, silcpurple_ftp_ask_name_ok);
- purple_xfer_set_request_denied_fnc(xfer->xfer, silcpurple_ftp_ask_name_cancel);
+ askname_ops = *purple_xfer_get_io_ops(xfer->xfer);
+
+ askname_ops.init = silcpurple_ftp_ask_name_ok;
+ askname_ops.request_denied = silcpurple_ftp_ask_name_cancel;
+ purple_xfer_set_io_ops(xfer->xfer, &askname_ops);
/* Request to save the file */
purple_xfer_set_filename(xfer->xfer, remote_filename);
@@ -302,6 +318,19 @@ silcpurple_ftp_request_denied(PurpleXfer
}
+static PurpleXferIoOps recieve_ops =
+{
+ silcpurple_ftp_request_result, /* init */
+ silcpurple_ftp_request_denied, /* request_denied */
+ NULL, /* start */
+ NULL, /* end */
+ NULL, /* cancel_send */
+ silcpurple_ftp_cancel, /* cancel_recv */
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* ack */
+};
+
void silcpurple_ftp_request(SilcClient client, SilcClientConnection conn,
SilcClientEntry client_entry, SilcUInt32 session_id,
const char *hostname, SilcUInt16 port)
@@ -329,11 +358,8 @@ void silcpurple_ftp_request(SilcClient c
silc_free(xfer);
return;
}
- purple_xfer_set_init_fnc(xfer->xfer, silcpurple_ftp_request_result);
- purple_xfer_set_request_denied_fnc(xfer->xfer, silcpurple_ftp_request_denied);
- purple_xfer_set_cancel_recv_fnc(xfer->xfer, silcpurple_ftp_cancel);
- xfer->xfer->remote_ip = g_strdup(hostname);
- xfer->xfer->remote_port = port;
+ purple_xfer_set_io_ops(xfer->xfer, &recieve_ops);
+ purple_xfer_start(xfer->xfer, -1, hostname, port);
purple_xfer_set_protocol_data(xfer->xfer, xfer);
/* File transfer request */
@@ -430,6 +456,19 @@ silcpurple_ftp_send_file_resolved(SilcCl
g_free(context);
}
+static PurpleXferIoOps send_ops =
+{
+ silcpurple_ftp_send, /* init */
+ silcpurple_ftp_request_denied, /* request_denied */
+ NULL, /* start */
+ NULL, /* end */
+ silcpurple_ftp_send_cancel, /* cancel_send */
+ NULL, /* cancel_recv */
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* ack */
+};
+
PurpleXfer *silcpurple_ftp_new_xfer(PurpleConnection *gc, const char *name)
{
SilcPurple sg = purple_connection_get_protocol_data(gc);
@@ -461,9 +500,7 @@ PurpleXfer *silcpurple_ftp_new_xfer(Purp
silc_free(xfer);
return NULL;
}
- purple_xfer_set_init_fnc(xfer->xfer, silcpurple_ftp_send);
- purple_xfer_set_request_denied_fnc(xfer->xfer, silcpurple_ftp_request_denied);
- purple_xfer_set_cancel_send_fnc(xfer->xfer, silcpurple_ftp_send_cancel);
+ purple_xfer_set_io_ops(xfer->xfer, &send_ops);
purple_xfer_set_protocol_data(xfer->xfer, xfer);
silc_free(clients);
More information about the Commits
mailing list