Mercurial > pidgin.yaz
changeset 32423:ac88c8fc3f47
Convert the jabber prpl to use the new API.
author | andrew.victor@mxit.com |
---|---|
date | Fri, 26 Aug 2011 19:06:02 +0000 |
parents | 92711688c245 |
children | 7c65c7054905 |
files | libpurple/protocols/jabber/oob.c libpurple/protocols/jabber/si.c |
diffstat | 2 files changed, 43 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/oob.c Fri Aug 26 18:37:27 2011 +0000 +++ b/libpurple/protocols/jabber/oob.c Fri Aug 26 19:06:02 2011 +0000 @@ -48,13 +48,13 @@ static void jabber_oob_xfer_init(PurpleXfer *xfer) { - JabberOOBXfer *jox = xfer->data; + JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); purple_xfer_start(xfer, -1, jox->address, jox->port); } static void jabber_oob_xfer_free(PurpleXfer *xfer) { - JabberOOBXfer *jox = xfer->data; + JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); jox->js->oob_file_transfers = g_list_remove(jox->js->oob_file_transfers, xfer); @@ -67,12 +67,12 @@ purple_input_remove(jox->writeh); g_free(jox); - xfer->data = NULL; + purple_xfer_set_protocol_data(xfer, NULL); } static void jabber_oob_xfer_end(PurpleXfer *xfer) { - JabberOOBXfer *jox = xfer->data; + JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); JabberIq *iq; iq = jabber_iq_new(jox->js, JABBER_IQ_RESULT); @@ -86,7 +86,7 @@ static void jabber_oob_xfer_request_send(gpointer data, gint source, PurpleInputCondition cond) { PurpleXfer *xfer = data; - JabberOOBXfer *jox = xfer->data; + JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); int len, total_len = strlen(jox->write_buffer); len = write(xfer->fd, jox->write_buffer + jox->written_len, @@ -110,7 +110,7 @@ static void jabber_oob_xfer_start(PurpleXfer *xfer) { - JabberOOBXfer *jox = xfer->data; + JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); if(jox->write_buffer == NULL) { jox->write_buffer = g_strdup_printf( @@ -126,7 +126,7 @@ } static gssize jabber_oob_xfer_read(guchar **buffer, PurpleXfer *xfer) { - JabberOOBXfer *jox = xfer->data; + JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); char test[2048]; char *tmp, *lenstr; int len; @@ -158,7 +158,7 @@ } static void jabber_oob_xfer_recv_error(PurpleXfer *xfer, const char *code) { - JabberOOBXfer *jox = xfer->data; + JabberOOBXfer *jox = purple_xfer_get_protocol_data(xfer); JabberIq *iq; xmlnode *y, *z; @@ -221,7 +221,7 @@ xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from); if (xfer) { - xfer->data = jox; + purple_xfer_set_protocol_data(xfer, jox); if(!(filename = g_strdup(g_strrstr(jox->page, "/")))) filename = g_strdup(jox->page);
--- a/libpurple/protocols/jabber/si.c Fri Aug 26 18:37:27 2011 +0000 +++ b/libpurple/protocols/jabber/si.c Fri Aug 26 19:06:02 2011 +0000 @@ -87,7 +87,7 @@ for(xfers = js->file_transfers; xfers; xfers = xfers->next) { PurpleXfer *xfer = xfers->data; - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); if(jsx->stream_id && xfer->who && !strcmp(jsx->stream_id, sid) && !strcmp(xfer->who, from)) return xfer; @@ -118,7 +118,7 @@ jabber_si_bytestreams_connect_cb(gpointer data, gint source, const gchar *error_message) { PurpleXfer *xfer = data; - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); JabberIq *iq; xmlnode *query, *su; JabberBytestreamsStreamhost *streamhost = jsx->streamhosts->data; @@ -174,7 +174,7 @@ connect_timeout_cb(gpointer data) { PurpleXfer *xfer = data; - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); purple_debug_info("jabber", "Streamhost connection timeout of %d seconds exceeded.\n", STREAMHOST_CONNECT_TIMEOUT); @@ -203,7 +203,7 @@ jabber_si_bytestreams_ibb_timeout_cb(gpointer data) { PurpleXfer *xfer = (PurpleXfer *) data; - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); if (jsx && !jsx->ibb_session) { purple_debug_info("jabber", @@ -218,7 +218,7 @@ static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer) { - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); JabberBytestreamsStreamhost *streamhost; JabberID *dstjid; @@ -337,7 +337,7 @@ if(!(xfer = jabber_si_xfer_find(js, sid, from))) return; - jsx = xfer->data; + jsx = purple_xfer_get_protocol_data(xfer); if(!jsx->accepted) return; @@ -375,7 +375,7 @@ PurpleInputCondition cond) { PurpleXfer *xfer = data; - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); int len; len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - jsx->rxlen); @@ -412,7 +412,7 @@ PurpleInputCondition cond) { PurpleXfer *xfer = data; - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); char buffer[42]; /* 40 for DST.ADDR + 2 bytes for port number*/ int len; char *dstaddr, *hash; @@ -527,7 +527,7 @@ PurpleInputCondition cond) { PurpleXfer *xfer = data; - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); int len; len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - jsx->rxlen); @@ -568,7 +568,7 @@ PurpleInputCondition cond) { PurpleXfer *xfer = data; - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); int i; int len; char buffer[256]; @@ -680,7 +680,7 @@ PurpleInputCondition cond) { PurpleXfer *xfer = data; - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); int acceptfd, flags; purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_connected_cb\n"); @@ -727,12 +727,12 @@ return; } + jsx = purple_xfer_get_protocol_data(xfer); + /* In the case of a direct file transfer, this is expected to return */ - if(!xfer->data) + if(!jsx) return; - jsx = xfer->data; - if(type != JABBER_IQ_RESULT) { purple_debug_info("jabber", "jabber_si_xfer_connect_proxy_cb: type = error\n"); @@ -835,7 +835,7 @@ JabberBytestreamsStreamhost *sh, *sh2; int streamhost_count = 0; - jsx = xfer->data; + jsx = purple_xfer_get_protocol_data(xfer); jsx->listen_data = NULL; /* I'm not sure under which conditions this can happen @@ -969,7 +969,7 @@ purple_xfer_ref(xfer); - jsx = xfer->data; + jsx = purple_xfer_get_protocol_data(xfer); /* TODO: This should probably be done with an account option instead of * piggy-backing on the TOR proxy type. */ @@ -1017,7 +1017,7 @@ gsize size) { PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess); - JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); if (size <= purple_xfer_get_bytes_remaining(xfer)) { purple_debug_info("jabber", "about to write %" G_GSIZE_FORMAT " bytes from IBB stream\n", @@ -1037,7 +1037,7 @@ static gssize jabber_si_xfer_ibb_read(guchar **out_buffer, PurpleXfer *xfer) { - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); guchar *buffer; gsize size; gsize tmp; @@ -1060,7 +1060,7 @@ const gchar *sid = xmlnode_get_attrib(open, "sid"); PurpleXfer *xfer = jabber_si_xfer_find(js, sid, who); if (xfer) { - JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); JabberIBBSession *sess = jabber_ibb_session_create_from_xmlnode(js, who, id, open, xfer); @@ -1105,7 +1105,7 @@ static gssize jabber_si_xfer_ibb_write(const guchar *buffer, size_t len, PurpleXfer *xfer) { - JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); JabberIBBSession *sess = jsx->ibb_session; gsize packet_size = len < jabber_ibb_session_get_max_data_size(sess) ? len : jabber_ibb_session_get_max_data_size(sess); @@ -1149,7 +1149,7 @@ static void jabber_si_xfer_ibb_send_init(JabberStream *js, PurpleXfer *xfer) { - JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); jsx->ibb_session = jabber_ibb_session_create(js, jsx->stream_id, purple_xfer_get_remote_user(xfer), xfer); @@ -1206,7 +1206,7 @@ for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) { const char *var = xmlnode_get_attrib(field, "var"); - JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); if(var && !strcmp(var, "stream-method")) { if((value = xmlnode_get_child(field, "value"))) { @@ -1237,7 +1237,7 @@ static void jabber_si_xfer_send_request(PurpleXfer *xfer) { - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); JabberIq *iq; xmlnode *si, *file, *feature, *x, *field, *option, *value; char buf[32]; @@ -1309,7 +1309,7 @@ static void jabber_si_xfer_free(PurpleXfer *xfer) { - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); if (jsx) { JabberStream *js = jsx->js; @@ -1356,7 +1356,7 @@ /* XXX: free other stuff */ g_free(jsx->rxqueue); g_free(jsx); - xfer->data = NULL; + purple_xfer_set_protocol_data(xfer, NULL); } } @@ -1367,7 +1367,7 @@ */ static void jabber_si_xfer_cancel_send(PurpleXfer *xfer) { - JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); /* if there is an IBB session active, send close on that */ if (jsx->ibb_session) { @@ -1380,7 +1380,7 @@ static void jabber_si_xfer_request_denied(PurpleXfer *xfer) { - JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); JabberStream *js = jsx->js; /* @@ -1412,7 +1412,7 @@ static void jabber_si_xfer_cancel_recv(PurpleXfer *xfer) { - JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); /* if there is an IBB session active, send close */ if (jsx->ibb_session) { jabber_ibb_session_close(jsx->ibb_session); @@ -1432,7 +1432,7 @@ JabberCapabilities capabilities, gpointer data) { PurpleXfer *xfer = (PurpleXfer *) data; - JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); if (capabilities & JABBER_CAP_IBB) { purple_debug_info("jabber", @@ -1458,7 +1458,7 @@ static void do_transfer_send(PurpleXfer *xfer, const char *resource) { - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); char **who_v = g_strsplit(xfer->who, "/", 2); char *who; JabberBuddy *jb; @@ -1508,7 +1508,7 @@ static void jabber_si_xfer_init(PurpleXfer *xfer) { - JabberSIXfer *jsx = xfer->data; + JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer); JabberIq *iq; if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { JabberBuddy *jb; @@ -1641,7 +1641,8 @@ xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); if (xfer) { - xfer->data = jsx = g_new0(JabberSIXfer, 1); + jsx = g_new0(JabberSIXfer, 1); + purple_xfer_set_protocol_data(xfer, jsx); jsx->js = js; jsx->local_streamhost_fd = -1; @@ -1777,7 +1778,7 @@ xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from); g_return_if_fail(xfer != NULL); - xfer->data = jsx; + purple_xfer_set_protocol_data(xfer, jsx); purple_xfer_set_filename(xfer, filename); if(filesize > 0)